diff options
author | Hector Chu <hectorchu@gmail.com> | 2009-11-30 11:53:11 -0800 |
---|---|---|
committer | Hector Chu <hectorchu@gmail.com> | 2009-11-30 11:53:11 -0800 |
commit | 8eabe8208c32050802c06abdc2baf49febf6fb7a (patch) | |
tree | 7ac62e529fdf4675e7449e7171ed7cc0a573e517 /src/lib9/_p9dir.c | |
parent | 2c880cf84880cfac9c667f48087c7c30d19b76ba (diff) | |
download | golang-8eabe8208c32050802c06abdc2baf49febf6fb7a.tar.gz |
Ports of lib9, libbio and libmach to Windows.
R=rsc
http://codereview.appspot.com/157159
Committer: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/lib9/_p9dir.c')
-rw-r--r-- | src/lib9/_p9dir.c | 39 |
1 files changed, 9 insertions, 30 deletions
diff --git a/src/lib9/_p9dir.c b/src/lib9/_p9dir.c index ededa0a92..58c0822a4 100644 --- a/src/lib9/_p9dir.c +++ b/src/lib9/_p9dir.c @@ -29,20 +29,6 @@ THE SOFTWARE. #include <sys/types.h> #include <sys/stat.h> #include <dirent.h> -#include <pwd.h> -#include <grp.h> - -/* - * No need for a real disk size function here: - * the Go build isn't looking at raw disk devices, - * so this avoids portability problems. - */ -#define _HAVEDISKSIZE -static vlong -disksize(int fd, int x) -{ - return 0; -} /* * Caching the last group and passwd looked up is @@ -55,9 +41,6 @@ _p9dir(struct stat *lst, struct stat *st, char *name, Dir *d, char **str, char * { char *s; char tmp[20]; - static struct group *g; - static struct passwd *p; - static int gid, uid; int sz, fd; fd = -1; @@ -88,11 +71,8 @@ _p9dir(struct stat *lst, struct stat *st, char *name, Dir *d, char **str, char * sz += strlen(s)+1; /* user */ - if(p == nil || st->st_uid != uid || p->pw_uid != uid){ - snprint(tmp, sizeof tmp, "%d", (int)st->st_uid); - s = tmp; - }else - s = p->pw_name; + snprint(tmp, sizeof tmp, "%d", (int)st->st_uid); + s = tmp; sz += strlen(s)+1; if(d){ if(*str+strlen(s)+1 > estr) @@ -105,11 +85,8 @@ _p9dir(struct stat *lst, struct stat *st, char *name, Dir *d, char **str, char * } /* group */ - if(g == nil || st->st_gid != gid || g->gr_gid != gid){ - snprint(tmp, sizeof tmp, "%d", (int)st->st_gid); - s = tmp; - }else - s = g->gr_name; + snprint(tmp, sizeof tmp, "%d", (int)st->st_gid); + s = tmp; sz += strlen(s)+1; if(d){ if(*str + strlen(s)+1 > estr) @@ -141,12 +118,16 @@ _p9dir(struct stat *lst, struct stat *st, char *name, Dir *d, char **str, char * d->mode |= DMDIR; d->qid.type = QTDIR; } +#ifdef S_ISLNK if(S_ISLNK(lst->st_mode)) /* yes, lst not st */ d->mode |= DMSYMLINK; +#endif if(S_ISFIFO(st->st_mode)) d->mode |= DMNAMEDPIPE; +#ifdef S_ISSOCK if(S_ISSOCK(st->st_mode)) d->mode |= DMSOCKET; +#endif if(S_ISBLK(st->st_mode)){ d->mode |= DMDEVICE; d->qid.path = ('b'<<16)|st->st_rdev; @@ -156,12 +137,10 @@ _p9dir(struct stat *lst, struct stat *st, char *name, Dir *d, char **str, char * d->qid.path = ('c'<<16)|st->st_rdev; } /* fetch real size for disks */ -#ifdef _HAVEDISKSIZE if(S_ISBLK(st->st_mode) && (fd = open(name, O_RDONLY)) >= 0){ - d->length = disksize(fd, major(st->st_dev)); + d->length = 0; close(fd); } -#endif #if defined(DIOCGMEDIASIZE) if(isdisk(st)){ int fd; |