Lines Matching +full:pkt +full:- +full:size
6 The sub-namespace td has type definitions (qid, stat) and values
24 dotu-specific members (used only when packing for dotu/dotl and
47 wirestat objects, which are basically size-counted pre-sequenced
48 stat objects. The pre-sequencing uses:
68 The sub-namespace rrd has request (Tversion, Topen, etc) and
101 course are the pre-filled fields in a Tversion PFOD instance).
104 >>> pkt = dotu.pack(fcall='Tversion', args=args)
105 >>> len(pkt)
111 size[4] fcall[1] tag[2] msize[4] version[s]
113 which corresponds to a struct's IBHIH (for the fixed size parts)
115 long, so we have size=9, fcall=100, tag=1, msize=1000, and the
119 >>> struct.unpack('<IBHIHB', pkt)
130 >>> pkt = dotu.pack(fcall='Tversion', args=args)
131 >>> len(pkt)
137 >>> pkt == pkt2
146 >>> pkt == pkt2
151 a downgrade_to() method that gets you a possibly-downgraded instance.
169 pkt = protocol.plain.pack(fcall='Rerror',
173 pkt = proto.pack(fcall='Rversion', args={'tag': tag, 'msize': msize})
185 pkt = proto.pack_from(reply)
206 >>> utf8 = os.strerror(errno.ENOENT).encode('utf-8')
207 >>> pkt = None
211 ... pkt = plain.error(1, err)
213 >>> pkt[-len(utf8):] == utf8
216 >>> pkt == pkt2
223 >>> len(pkt)
250 >>> pkt = dotl.Rlink(12345)
251 >>> struct.unpack('<IBH', pkt)
259 The overall length is 21 bytes: 4 bytes of size, 1 byte of code 100
274 (where the size is already removed and is implied by len(data)),
282 >>> pkt = pkt[4:] # strip generated size
285 >>> b2s = lambda x: x.decode('utf-8') if py3k else x
286 >>> d = plain.unpack_header(pkt[0:1], noerror=True)
289 Header(size=5, dsize=0, fcall=71, data='')
290 >>> d = plain.unpack_header(pkt[0:2], noerror=True)
293 Header(size=6, dsize=1, fcall=71, data='9')
297 >>> plain.unpack_header(pkt[0:0]) # doctest: +IGNORE_EXCEPTION_DETAIL
304 >>> d = plain.unpack_header(pkt)
307 Header(size=7, dsize=2, fcall=71, data='90')
310 (This is impossible for a header, though, since the size and
311 data size are both implied: either there is an fcall code, and
323 >>> plain.unpack(pkt) # doctest: +IGNORE_EXCEPTION_DETAIL
327 >>> dotl.unpack(pkt)
335 >>> plain.unpack(pkt, noerror=True) # doctest: +IGNORE_EXCEPTION_DETAIL
340 The same applies to much-too-short packets even if noerror is set.
341 Specifically, if the (post-"size") header shortens down to the empty
351 >>> dotl.unpack(pkt[0:1], noerror=True)
353 >>> dotl.unpack(pkt[0:2], noerror=True)
358 >>> dotl.unpack(pkt + b'x') # doctest: +IGNORE_EXCEPTION_DETAIL
362 >>> dotl.unpack(pkt + b'x', noerror=True)
366 use pack_wirestat. This puts a size in front of the packed stat
367 data (they're represented this way in read()-of-directory data,
410 Similarly, use unpack_dirent to unpack the result of a dot-L
415 >>> pkt = dotl.pack_dirent(dirent)
416 >>> len(pkt)
421 >>> newde, offset = dotl.unpack_dirent(pkt, 0)
445 # to interfere with (eg) the size part of the packet:
446 # pkt = proto.pack(fcall=protocol.td.Tversion,
447 # size=123, # wrong
450 # pkt = proto.pack(fcall=protocol.td.Twrite,
453 # pkt = proto.pack(fcall=protocol.td.Twrite,
456 # pkt = proto.pack(fcall=protocol.td.Twrite,
458 # 'data': b'rawdata' }) -- XXX won't work (yet?)
472 and we check for coders that are string coders ('data[size]').
498 If rodata ("read-only data") is True we make sure not
504 # False conditionals don't need to be filled-in.
509 # sub-coder's name ('version') is the test item.
517 # sub-coders's repeat item ('count') is the
574 # define rich-comparison operators, so we can, e.g., test vers > plain
590 Downgrade from this protocol to a not-greater one.
598 other_name = other_name.decode('utf-8', 'surrogateescape')
618 "pack up a pfod or fcall-and-arguments"
624 # data=pfod as well). The size is implied, and
689 pkt = packinfo.pack(self.auto_vars, self.conditions, data, rodata)
696 # outer data. The size is implied by len(pkt). There
699 # NB: the size includes the size of the header itself
700 # and the fcall code byte, plus the size of the data.
701 data = _9p_data.header_pfod(size=4 + 1 + len(pkt), dsize=len(pkt),
702 fcall=fcall_code, data=pkt)
704 pkt = _9p_data.header_pack_seq.pack(data, empty)
705 return pkt
713 overall size field (4 bytes), leaving us with the fcall
714 (1 byte) and data (len(bstring)-1 bytes). If len(bstring)
719 vdict['size'] = len(bstring) + 4
720 vdict['dsize'] = max(0, len(bstring) - 1)
731 # size = vdict['size']
735 # Note: it's possible for size and/or fcall to be None,
737 # clearly fcall is not None; and since fcall follows size,
759 on a directory. Essentially, we prefix the data with a size.
762 return td.wirestat_seq.pack({'size': len(data), 'data': data}, {})
766 Produce the next td.stat object from byte-string,
770 d = { 'size': None }
773 size = d['size']
774 if size is None: # implies noerror; newoff==offset+2
776 # We now have size and data. If noerror, data might be
779 # that while len(data) == size, not all the data get used.
784 # if size != used ... then what?
789 Dirents (dot-L only) are easy to pack, but we provide
797 Produces the next td.dirent object from byte-string,
827 ret = ret.encode('utf-8')
838 # builtin. This and stat are the only variable-length
839 # decoders, and this is the only recursively-variable-length
840 # one (i.e., stat decoding is effectively fixed size once we
843 # Note that _string_ is, in effect, size[2] orig_var[size].
889 # This defines a wirestat decoder. A wirestat is a size and then
890 # a (previously encoded, or future-decoded) stat.
892 typedef wirestat: size[2] data[size]
895 # This defines a dirent decoder, which has a dot-L specific format.
930 long f_bsize; /* optimal transfer block size */
933 long f_bavail; /* free blocks avail to non-superuser */
1016 rdev[8] size[8] blksize[8] blocks[8] \
1033 off_t st_size; /* total size, in bytes */
1072 Tsetattr.L = 26: tag[2] fid[4] valid[4] mode[4] uid[4] gid[4] size[8] \
1079 mode - Linux chmod(2) mode bits.
1081 uid, gid - New owner, group of the file as described in Linux chown(2).
1083 size - New file size as handled by Linux truncate(2).
1085 atime_sec, atime_nsec - Time of last file access.
1087 mtime_sec, mtime_nsec - Time of last file modification.
1106 Rxattrwalk.L: tag[2] size[8]
1139 Directory entries are represented as variable-length records:
1188 whole-file POSIX record locks. v9fs does not implement
1192 properties, pass-through servers must be implemented
1248 size inclusive of the size value that can be handled by both
1276 in both .u and .L (unlike most .u-specific features).
1291 flush aborts an in-flight request referenced by oldtag, if any.
1323 return, the fid refers to the then-created file.
1354 Rstat: tag[2] size[2] data[size]
1356 Twstat = 126: tag[2] fid[4] size[2] data[size]
1372 - 'word', 'word*', or 'label':
1375 - 'aux': ':' followed by '\w+' (used for :auto annotation)
1377 - 'type':
1381 - '(', ')', '{', '}': themeselves
1437 tok = _Token('label', item[0:-1], item)
1439 tok = _Token('word*', item[0:-1], item)
1442 if item[-1] != ']':
1445 tok = _Token('type', item[1:-1], item)
1459 Parse "expression-ish" items, which is a list of:
1468 or decode a fixed-size field of <integer> bytes, using the
1473 of these expands to a variable-size encode/decode. See the
1478 earlier name provides a repeat-count.
1480 Inside the parens we get a name[type] sub-expressino. This may
1522 case for string types, and another for using an earlier-defined
1533 # and the sub-sequence is sub. But if cls is None
1558 Note that the conditional is buried in the sub-coder for
1559 name2. It must be passed through anyway in case the sub-
1560 coder is only partly conditional. If the sub-coder is
1561 fully conditional, each sub-coding uses or produces no
1582 # count*(data[type]). The "sub-coder" is handled directly
1585 # As a peculiar side effect, all bytes-repeats cause the
1717 '(at line offset +{2}, discounting \\-newline)\n'
1728 and possibly-empty comment; these are our arguments.
1750 using backslach-newline if needed).
1777 - The name of the protocol option such as Tversion,
1779 - The protocol version, if any (.u or .L).
1780 - The value, if specified. If no value is specified
1782 - The expression to parse.
1815 just size - 5. We can't express this in our mini language,
1816 so we just hard-code the sequencer and pfod.
1819 size field, only the fcall and the data.
1821 self.header_pfod = pfod.pfod('Header', 'size dsize fcall data')
1823 seq = sequencer.Sequencer('Header-pack')
1824 # size: 4 bytes
1825 seq.append_encdec(None, sequencer.EncDecSimple('size', 4, None))
1831 print('Header-pack:', file=sys.stderr)
1835 seq = sequencer.Sequencer('Header-unpack')
1839 print('Header-unpack:', file=sys.stderr)
1893 # Hook up PFOD's for each protocol object -- for
1895 # They go in the rrd name-space, and also in dictionaries
1896 # per-protocol here, with the lookup pointing to a _PackInfo
1904 # (This is sort-of-wrong for Rerror vs Rlerror, but we
1935 # Currently we look up by text-string, in lowercase.
1957 will be on a string-ified, lower-cased version of the vers_string
1961 vers_string = vers_string.decode('utf-8', 'surrogateescape')
1975 'append-only'
1984 td.QTAPPEND: 'append-only',