From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Ronald G. Minnich" To: 9fans@cse.psu.edu Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: [9fans] clwalk on open directories Date: Mon, 3 Mar 2003 07:10:34 -0700 Topicbox-Message-UUID: 76d34dc6-eacb-11e9-9e20-41e7f4b1d025 A simple question has come up: given that your are reading a directory, should you be able to clwalk it (i.e. do a walk with a name and a newfid). On my old 9p server I allowed this. u9fs does not. Details follow. Also I am curious as to why my earlier message was impounded as 'suspicious' so I am trying this one more time. ron ---------- Forwarded message ---------- Date: Sun, 2 Mar 2003 19:47:07 -0700 (MST) From: Ronald G. Minnich To: 9fans@cse.psu.edu Subject: another question on u9fs u9fs serving; v9fs2k client; mounted at /mnt stat /mnt/tmp/file does this: <- Twalk tag 0 fid 0 newfid 1 nwname 1 0:tmp -> Rwalk tag 0 nwqid 1 0:(0000000000030300 1047737901 d) <- Tstat tag 0 fid 1 -> Rstat tag 0 stat 'tmp' '00000000' '00000000' '' q (0000000000030300 1046689325 d) m 020000000777 at 1046689902 mt 1046689325 l 0 t 0 d 0 . . <- Topen tag 0 fid 1 mode 0 -> Ropen tag 0 qid (0000000000030300 1046689325 d) iounit 0 (open /mnt//tmp/ for a readdir from the linux side) <- Tread tag 0 fid 1 offset 0 count 512 -> Rread tag 0 count 499 '49000000 00000000 80a77a71 3e670b2d 00000000 00ff0100 80a77a61 3ea77a61 3e001000 00000000 000a002e 666f6e74 2d756e69 78080030 30303030 30326208' <- Tread tag 0 fid 1 offset 499 count 512 -> Rread tag 0 count 507 '40000000 00000000 80decfa8 3dbf4716 00000000 00fd0100 805a6a2f 3edecfb8 3d001000 00000000 00010078 08003030 30303031 66340800 30303030 30316634' . . . read the directory <- Twalk tag 0 fid 1 newfid 2 nwname 1 0:bad -> Rerror tag 0 ename bad use of fid Try to stat /mnt/tmp/bad by walking from /mnt/tmp (fid 1) to bad with newfid 2. the bad use of fid is due to the fact that fid 1 is open. (gdb) 432 if(fid->omode != -1){ (gdb) 433 seterror(tx, Ebadusefid); (gdb) print *fid $1 = {fid = 1, path = 0x80cc498 "/tmp", st = {st_dev = 769, __pad1 = 0, st_ino = 196609, st_mode = 17407, st_nlink = 18, st_uid = 0, st_gid = 0, st_rdev = 0, __pad2 = 0, st_size = 0, st_blksize = 4096, st_blocks = 8, st_atime = 1046689902, __unused1 = 0, st_mtime = 1046689325, __unused2 = 0, st_ctime = 1046689335, __unused3 = 0, __unused4 = 0, __unused5 = 0}, u = 0x80cbe38, omode = 0, dir = 0x80cc4a8, diroffset = 2971, fd = -1, dirent = 0x0, next = 0x80cbda0, prev = 0x0} OK, here's the question. If the newfid is != fid, does it really matter that the fid is open? This is pretty much the classical Linux way to ls -l: open dir, read dir, stat each thing in dir. So the dir is going to be open. Should I be cloning the dir when I open it? Seems inefficient. Or should we add code to u9fs rwalk to do this: if ((rx->newfid == rx->fid ) && (fid->omode != -1)){ seterror(tx, Ebadusefid); return; } i.e. it's an error to walk an opened fid, but not an error to walk if you're going to a new fid? What's the right thing to do? ron