Lines Matching +full:4 +full:- +full:data

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
69 response (Rversion, Ropen, etc) data definitions. Each of these
101 course are the pre-filled fields in a Tversion PFOD instance).
111 size[4] fcall[1] tag[2] msize[4] version[s]
151 a downgrade_to() method that gets you a possibly-downgraded instance.
206 >>> utf8 = os.strerror(errno.ENOENT).encode('utf-8')
213 >>> pkt[-len(utf8):] == utf8
237 def do_Tlink(proto, data): # data will be a protocol.rrd.Tlink(...)
238 tag = data.tag
239 dfid = data.dfid
240 fid = data.fid
241 name = data.name
259 The overall length is 21 bytes: 4 bytes of size, 1 byte of code 100
260 for Tversion, 2 bytes of tag, 4 bytes of msize, 2 bytes of string
274 (where the size is already removed and is implied by len(data)),
275 then we unpack the data within the packet. You can invoke the
282 >>> pkt = pkt[4:] # strip generated size
285 >>> b2s = lambda x: x.decode('utf-8') if py3k else x
287 >>> d.data = b2s(d.data)
289 Header(size=5, dsize=0, fcall=71, data='')
291 >>> d.data = b2s(d.data)
293 Header(size=6, dsize=1, fcall=71, data='9')
300 SequenceError: out of data while unpacking 'fcall'
305 >>> d.data = b2s(d.data)
307 Header(size=7, dsize=2, fcall=71, data='90')
311 data size are both implied: either there is an fcall code, and
312 the rest of the bytes are "data", or there isn't and the packet
332 only really decode the header, not the data, if the fcall is
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
365 To pack a stat object when producing data for reading a directory,
367 data (they're represented this way in read()-of-directory data,
376 (First, we'll need to build some valid packet data.)
380 >>> data = plain.pack_wirestat(statobj)
381 >>> len(data)
386 >>> newobj, offset = plain.unpack_wirestat(data, 0)
392 Since the packed data do not include the dotu extensions, we get
395 >>> dotu.unpack_wirestat(data, 0) # doctest: +IGNORE_EXCEPTION_DETAIL
398 SequenceError: out of data while unpacking 'extension'
404 >>> newobj, offset = plain.unpack_wirestat(data[0:10], 0, noerror=True)
410 Similarly, use unpack_dirent to unpack the result of a dot-L
451 # args={ 'tag': 1, 'fid': 2, 'offset': 0, 'data': b'rawdata' })
454 # data=proto.Twrite(tag=1, fid=2, offset=0, data=b'rawdata' })
458 # 'data': b'rawdata' }) -- XXX won't work (yet?)
462 # build the Twrite data as a data structure:
463 # wrdata = protocol.td.Twrite(tag=1, fid=2, offset=0, data=b'rawdata')
465 # turn incoming byte stream data into a Header and remaining data:
466 # foo = proto.pack(data)
472 and we check for coders that are string coders ('data[size]').
493 def pack(self, auto_vars, conditions, data, rodata): argument
495 Pack data. Insert automatic and/or counted variables
496 automatically, if they are not already set in the data.
498 If rodata ("read-only data") is True we make sure not
499 to modify the caller's data. Since data is a PFOD rather
504 # False conditionals don't need to be filled-in.
509 # sub-coder's name ('version') is the test item.
510 if data.get(sub.name) is None:
512 data = data._copy()
514 data[sub.name] = auto_vars[sub.name]
516 # Automatic length, e.g., data[count]. The
517 # sub-coders's repeat item ('count') is the
523 if data.get(sub.repeat) is not None:
525 item = data.get(sub.name)
528 data = data._copy()
530 data[sub.repeat] = len(item)
531 return self.seq.pack(data, conditions)
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
626 data = kwargs.pop('data', None)
627 if data is None:
630 data = args[0]
634 return self._pack_from(data, True, 'pack', None)
636 # Called as pack(fcall=whatever, data={...}).
637 # The data argument must be a dictionary since we're going to
645 data = kwargs.pop('args', None)
649 if not isinstance(data, dict):
650 raise TypeError('pack() with fcall and data '
651 'requires data to be a dictionary')
658 data = cls(**data)
659 return self._pack_from(data, False, 'pack', None)
661 def pack_from(self, data): argument
662 "pack from pfod data, using its type to determine fcall"
663 return self._pack_from(data, True, 'pack_from', None)
665 def _pack_from(self, data, rodata, caller, packinfo): argument
670 modify the incoming data, as it may belong to someone
683 packinfo = self.pfods.get(data.__class__, None)
686 'input'.format(caller, data))
688 # Pack the data
689 pkt = packinfo.pack(self.auto_vars, self.conditions, data, rodata)
691 fcall = data.__class__.__name__
694 # That's the inner data; now we must add the header,
696 # outer data. The size is implied by len(pkt). There
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)
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)
728 # find out how many bytes to copy to vdict['data'], but by
734 data = vdict['data']
753 seq.unpack(vdict, self.conditions, data, noerror)
758 Pack a stat object to appear as data returned by read()
759 on a directory. Essentially, we prefix the data with a size.
761 data = td.stat_seq.pack(statobj, self.conditions)
762 return td.wirestat_seq.pack({'size': len(data), 'data': data}, {})
766 Produce the next td.stat object from byte-string,
776 # We now have size and data. If noerror, data might be
778 # Or (with or without noeror), data might be too long, so
779 # that while len(data) == size, not all the data get used.
781 data = d['data']
782 used = td.stat_seq.unpack_from(statobj, self.conditions, data,
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
848 # which en/decodes 1 byte called type, 4 called version, and
854 typedef qid: type[1] version[4] path[8]
871 typedef stat: type[2] dev[4] qid[qid] mode[4] atime[4] mtime[4] \
873 {.u: extension[s] n_uid[4] n_gid[4] n_muid[4] }
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.
904 #define DT_DIR 4
921 Rlerror.L = 7: tag[2] ecode[4]
924 Tstatfs.L = 8: tag[2] fid[4]
925 Rstatfs.L: tag[2] type[4] bsize[4] blocks[8] bfree[8] bavail[8] \
926 files[8] ffree[8] fsid[8] namelen[4]
931 long f_blocks; /* total data blocks in file system */
933 long f_bavail; /* free blocks avail to non-superuser */
943 Tlopen.L = 12: tag[2] fid[4] flags[4]
944 Rlopen.L: tag[2] qid[qid] iounit[4]
967 Tlcreate.L = 14: tag[2] fid[4] name[s] flags[4] mode[4] gid[4]
968 Rlcreate.L: tag[2] qid[qid] iounit[4]
981 Tsymlink.L = 16: tag[2] dfid[4] name[s] symtgt[s] gid[4]
990 Tmknod.L = 18: tag[2] dfid[4] name[s] mode[4] major[4] minor[4] gid[4]
1003 Trename.L = 20: tag[2] fid[4] dfid[4] name[s]
1010 Treadlink.L = 22: tag[2] fid[4]
1014 Tgetattr.L = 24: tag[2] fid[4] request_mask[8]
1015 Rgetattr.L: tag[2] valid[8] qid[qid] mode[4] uid[4] gid[4] nlink[8] \
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.
1105 Txattrwalk.L = 30: tag[2] fid[4] newfid[4] name[s]
1112 Txattrcreate.L = 32: tag[2] fid[4] name[s] attr_size[8] flags[4]
1133 Treaddir.L = 40: tag[2] fid[4] offset[8] count[4]
1134 Rreaddir.L: tag[2] count[4] data[count]
1139 Directory entries are represented as variable-length records:
1141 At most count bytes will be returned in data. If count is not
1142 zero in the response, more data is available. On subsequent
1146 Tfsync.L = 50: tag[2] fid[4]
1148 fsync tells the server to flush any cached data associated
1151 Tlock.L = 52: tag[2] fid[4] type[1] flags[4] start[8] length[8] \
1152 proc_id[4] client_id[s]
1188 whole-file POSIX record locks. v9fs does not implement
1192 properties, pass-through servers must be implemented
1195 Tgetlock.L = 54: tag[2] fid[4] type[1] start[8] length[8] proc_id[4] \
1197 Rgetlock.L: tag[2] type[1] start[8] length[8] proc_id[4] client_id[s]
1207 Tlink.L = 70: tag[2] dfid[4] fid[4] name[s]
1212 Tmkdir.L = 72: tag[2] dfid[4] name[s] mode[4] gid[4]
1222 Trenameat.L = 74: tag[2] olddirfid[4] oldname[s] newdirfid[4] newname[s]
1231 Tunlinkat.L = 76: tag[2] dirfd[4] name[s] flags[4]
1242 Tversion = 100: tag[2] msize[4] version[s]:auto
1243 Rversion: tag[2] msize[4] version[s]
1254 Tauth = 102: tag[2] afid[4] uname[s] aname[s] n_uname[4]
1262 Tattach = 104: tag[2] fid[4] afid[4] uname[s] aname[s] {.u: n_uname[4] }
1276 in both .u and .L (unlike most .u-specific features).
1287 Rerror = 107: tag[2] errstr[s] {.u: errnum[4] }
1291 flush aborts an in-flight request referenced by oldtag, if any.
1293 Twalk = 110: tag[2] fid[4] newfid[4] nwname[2] nwname*(wname[s])
1304 Topen = 112: tag[2] fid[4] mode[1]
1305 Ropen: tag[2] qid[qid] iounit[4]
1319 Tcreate = 114: tag[2] fid[4] name[s] perm[4] mode[1] {.u: extension[s] }
1320 Rcreate: tag[2] qid[qid] iounit[4]
1323 return, the fid refers to the then-created file.
1325 Tread = 116: tag[2] fid[4] offset[8] count[4]
1326 Rread: tag[2] count[4] data[count]
1334 Twrite = 118: tag[2] fid[4] offset[8] count[4] data[count]
1335 Rwrite: tag[2] count[4]
1343 Tclunk = 120: tag[2] fid[4]
1347 Tremove = 122: tag[2] fid[4]
1353 Tstat = 124: tag[2] fid[4]
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
1519 Convert typeinfo to an encdec. Typeinfo may be 1/2/4/8, or
1522 case for string types, and another for using an earlier-defined
1533 # and the sub-sequence is sub. But if cls is None
1540 if typeinfo.ival not in (1, 2, 4, 8):
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
1565 We don't (currently) have any auxiliary data for arrays.
1578 Emit name1[name2], e.g., data[count].
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.
1814 because data is sized to dsize which is effectively
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))
1828 # data: string of length dsize
1829 seq.append_encdec(None, sequencer.EncDecA('dsize', 'data', None))
1831 print('Header-pack:', file=sys.stderr)
1835 seq = sequencer.Sequencer('Header-unpack')
1837 seq.append_encdec(None, sequencer.EncDecA('dsize', 'data', None))
1839 print('Header-unpack:', file=sys.stderr)
1849 did not define a data structure.
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',