bo-yang / plan9front

Automatically exported from code.google.com/p/plan9front
0 stars 0 forks source link

Some directories have their contents listed twice when using lc #121

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
For example, see the directories under /mnt

term% cd /mnt
term% lc
exportfs/   factotum/   temp/
factotum/   keys/       term/
factotum/   plumb/      wsys/
term% 

The multiple factotum/ entries shouldn't be there.

Original issue reported on code.google.com by 9...@vrtra.net on 13 May 2012 at 1:12

GoogleCodeExporter commented 9 years ago
Examine the output of the ns command. These are probably binds.

Original comment by stanley....@gmail.com on 13 May 2012 at 3:40

GoogleCodeExporter commented 9 years ago
For example:

term% ls /mnt
/mnt/exportfs
/mnt/factotum
/mnt/plumb
/mnt/temp
/mnt/web
/mnt/webcookies
/mnt/wsys
term% auth/factotum
term% ls /mnt
/mnt/exportfs
/mnt/factotum
/mnt/factotum
/mnt/plumb
/mnt/temp
/mnt/web
/mnt/webcookies
/mnt/wsys

Original comment by stanley....@gmail.com on 13 May 2012 at 3:42

GoogleCodeExporter commented 9 years ago
Agreed, they are binds, but should ls print duplicate entries?

Original comment by rahul.g....@gmail.com on 13 May 2012 at 6:33

GoogleCodeExporter commented 9 years ago
Depending on what options were used when mounting/binding the resource, the 
directory listing may include items from multiple resources, even items with 
the same file names:

term% touch tmp/rc
term% ls -q tmp/rc
(00000000000db916 1 00) tmp/rc
term% ls -q /bin/rc
(00000000000001cd 864 00) /bin/rc
term% bind -a tmp /bin
term% ls -q /bin | grep -e '\/rc$'
(00000000000001cd    864 00) /bin/rc
(00000000000db916      1 00) /bin/rc

The items are still distinct, identified by quid. From stat(2):

               typedef
               struct Dir {
                     /* system-modified data */
                     uint  type;    /* server type */
                     uint  dev;     /* server subtype */
                     /* file data */
                     Qid   qid;     /* unique id from server */
                     ulong mode;    /* permissions */
                     ulong atime;   /* last read time */
                     ulong mtime;   /* last write time */
                     vlong length;  /* file length: see <u.h> */
                     char  *name;   /* last element of path */
                     char  *uid;    /* owner name */
                     char  *gid;    /* group name */
                     char  *muid;   /* last modifier name */
               } Dir;

Original comment by stanley....@gmail.com on 13 May 2012 at 7:00

GoogleCodeExporter commented 9 years ago
If bind had been called without any flags in the example above, tmp  would have 
completely replaced /bin in the present namespace. Thus, tmp/rc would have 
replaced the original /bin/rc and there would be no duplicate file name in the 
directory listing.

Original comment by stanley....@gmail.com on 13 May 2012 at 7:07

GoogleCodeExporter commented 9 years ago
To answer your question, the current behavior is intentional.

Original comment by stanley....@gmail.com on 13 May 2012 at 7:08

GoogleCodeExporter commented 9 years ago
Thanks, makes sense.

Original comment by 9...@vrtra.net on 14 May 2012 at 4:30

GoogleCodeExporter commented 9 years ago

Original comment by stanley....@gmail.com on 14 May 2012 at 4:32