start adding DM bits

This commit is contained in:
rsc 2005-02-08 20:08:28 +00:00
parent 8a26417b7a
commit 0a22905232
4 changed files with 16 additions and 8 deletions

View file

@ -80,7 +80,7 @@ disksize(int fd, int dev)
* getpwnam in the first place, so I'm not too worried. * getpwnam in the first place, so I'm not too worried.
*/ */
int int
_p9dir(struct stat *st, char *name, Dir *d, char **str, char *estr) _p9dir(struct stat *lst, struct stat *st, char *name, Dir *d, char **str, char *estr)
{ {
char *s; char *s;
char tmp[20]; char tmp[20];

View file

@ -23,7 +23,7 @@ dirfstat(int fd)
if(d == nil) if(d == nil)
return nil; return nil;
str = (char*)&d[1]; str = (char*)&d[1];
_p9dir(&st, tmp, d, &str, str+nstr); _p9dir(&st, &st, tmp, d, &str, str+nstr);
return d; return d;
} }

View file

@ -82,10 +82,14 @@ dirpackage(int fd, char *buf, int n, Dir **dp)
de = (struct dirent*)p; de = (struct dirent*)p;
if(de->d_name[0] == 0) if(de->d_name[0] == 0)
/* nothing */ {} /* nothing */ {}
else if(stat(de->d_name, &st) < 0) else if(lstat(de->d_name, &lst) < 0)
de->d_name[0] = 0; de->d_name[0] = 0;
else else{
nstr += _p9dir(&st, de->d_name, nil, nil, nil); st = lst;
if((lst.st_mode&S_IFMT) == S_ISLNK)
stat(de->d_name, &st);
nstr += _p9dir(&lst, &st, de->d_name, nil, nil, nil);
}
p += de->d_reclen; p += de->d_reclen;
} }

View file

@ -9,20 +9,24 @@ extern int _p9dir(struct stat*, char*, Dir*, char**, char*);
Dir* Dir*
dirstat(char *file) dirstat(char *file)
{ {
struct lstat lst;
struct stat st; struct stat st;
int nstr; int nstr;
Dir *d; Dir *d;
char *str; char *str;
if(stat(file, &st) < 0) if(lstat(file, &lst) < 0)
return nil; return nil;
st = lst;
if((lst.mode&S_IFMT) == S_ISLNK)
stat(file, &st);
nstr = _p9dir(&st, file, nil, nil, nil); nstr = _p9dir(&lst, &st, file, nil, nil, nil);
d = mallocz(sizeof(Dir)+nstr, 1); d = mallocz(sizeof(Dir)+nstr, 1);
if(d == nil) if(d == nil)
return nil; return nil;
str = (char*)&d[1]; str = (char*)&d[1];
_p9dir(&st, file, d, &str, str+nstr); _p9dir(&lst, &st, file, d, &str, str+nstr);
return d; return d;
} }