start adding DM bits
This commit is contained in:
parent
8a26417b7a
commit
0a22905232
4 changed files with 16 additions and 8 deletions
|
|
@ -80,7 +80,7 @@ disksize(int fd, int dev)
|
|||
* getpwnam in the first place, so I'm not too worried.
|
||||
*/
|
||||
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 tmp[20];
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ dirfstat(int fd)
|
|||
if(d == nil)
|
||||
return nil;
|
||||
str = (char*)&d[1];
|
||||
_p9dir(&st, tmp, d, &str, str+nstr);
|
||||
_p9dir(&st, &st, tmp, d, &str, str+nstr);
|
||||
return d;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -82,10 +82,14 @@ dirpackage(int fd, char *buf, int n, Dir **dp)
|
|||
de = (struct dirent*)p;
|
||||
if(de->d_name[0] == 0)
|
||||
/* nothing */ {}
|
||||
else if(stat(de->d_name, &st) < 0)
|
||||
else if(lstat(de->d_name, &lst) < 0)
|
||||
de->d_name[0] = 0;
|
||||
else
|
||||
nstr += _p9dir(&st, de->d_name, nil, nil, nil);
|
||||
else{
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,20 +9,24 @@ extern int _p9dir(struct stat*, char*, Dir*, char**, char*);
|
|||
Dir*
|
||||
dirstat(char *file)
|
||||
{
|
||||
struct lstat lst;
|
||||
struct stat st;
|
||||
int nstr;
|
||||
Dir *d;
|
||||
char *str;
|
||||
|
||||
if(stat(file, &st) < 0)
|
||||
if(lstat(file, &lst) < 0)
|
||||
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);
|
||||
if(d == nil)
|
||||
return nil;
|
||||
str = (char*)&d[1];
|
||||
_p9dir(&st, file, d, &str, str+nstr);
|
||||
_p9dir(&lst, &st, file, d, &str, str+nstr);
|
||||
return d;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue