9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] /proc/n/fd format clarification
@ 2021-06-05 13:26 binary cat
  2021-06-05 21:04 ` [9front] " Anthony Martin
  2021-06-05 21:58 ` [9front] " nicolagi
  0 siblings, 2 replies; 7+ messages in thread
From: binary cat @ 2021-06-05 13:26 UTC (permalink / raw)
  To: 9front

proc(3) lists 8 entries for each line:

>The read-only file lists the open file descriptors of the process. The first line of the file is its current directory;
>subsequent lines list, one per line, the open files, giving the decimal file descriptor number [1]; whether the file is open for
>read (r) write (w), or both (rw) [2]; the type [3], device number [4], and qid [5] of the file; its I/O unit [6] (the amount of data that may be
>transferred on the file as a contiguous piece; see iounit(2)), its I/O offset [7]; and its name at the time it was opened [8].

But this still leaves me with some questions when I look at this:

  0 r  M   68 (0000000000000001 0 00)  8192      166 /dev/cons

It seems that the qid is split into 3 parts. What are those parts?
I found this in intro(5):

          Replies (R-messages) to auth, attach, walk, open, and create
          requests convey a qid field back to the client.  The qid
          represents the server's unique identification for the file
          being accessed: two files on the same server hierarchy are
          the same if and only if their qids are the same.  (The
          client may have multiple fids pointing to a single file on a
          server and hence having a single qid.)  The thirteen-byte
          qid fields hold a one-byte type, specifying whether the file
          is a directory, append-only file, etc., and two unsigned
          integers: first the four-byte qid version, then the eight-
          byte qid path.  The path is an integer unique among all
          files in the hierarchy.  If a file is deleted and recreated
          with the same name in the same directory, the old and new
          path components of the qids should be different.  The ver-
          sion is a version number for a file; typically, it is incre-
          mented every time the file is modified.

So this mentions 3 things, a path, a version, and a type. This
checks out, until you look at the supposed lengths. The path is
supposed to be 8 bytes, which would be 16 hex digits, that's ok,
but it says 4 bytes for the version, which would be 8 hex digits,
and we don't see anything like that here. What's going on here?

-- binarycat

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-06-09 22:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-05 13:26 [9front] /proc/n/fd format clarification binary cat
2021-06-05 21:04 ` [9front] " Anthony Martin
2021-06-05 21:58 ` [9front] " nicolagi
2021-06-07 17:16   ` binary cat
2021-06-07 23:37     ` ori
2021-06-07 23:46     ` Anthony Martin
2021-06-09 21:24       ` binary cat

9front - general discussion about 9front

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/9front

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 9front 9front/ http://inbox.vuxu.org/9front \
	public-inbox-index 9front

Example config snippet for mirrors.
Newsgroup available over NNTP:

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git