17 if ((bp = Bopen(file, OREAD)) == 0)
18 error("Can't open passwd/group");
19 up = emalloc(1*sizeof(Idmap));
22 while ((cp = Brdline(bp, '\n'))) {
24 cp[Blinelen(bp)-1] = 0;
25 nf = getfields(cp, line, 3, 0, ":\n");
27 fprint(2, "bad format in %s\n", file);
32 up = (Idmap *)erealloc(up, maxid*sizeof(Idmap));
34 up[nid].id = atoi(line[2]);
35 up[nid].name = strdup(line[0]);
44 mapid(Idmap *up, int id)
51 return strdup(up->name);
54 sprint(buf, "%d", id);
59 poppath(Fileinf fi, int new)
61 char *suffix, *origname;
67 origname = estrdup(fi.name);
68 if (suffix=strrchr(fi.name, '/')){
74 return poppath(fi, 1);
77 * create parent directory of suffix;
78 * may recurse, thus shortening fi.name even further.
90 if (strcmp(suffix, ".")==0) {
95 ent = lookup(dir, suffix);
96 fi.mode |= 0400; /* at least user read */
98 if (((fi.mode&DMDIR)!=0) != ((ent->qid.type&QTDIR)!=0)){
100 "%s file type changed; probably due to union dir.; ignoring\n",
106 ent->ndata = fi.size;
110 ent->mtime = fi.mdate;
111 ent->user = mapid(uidmap, fi.uid);
112 ent->group = mapid(gidmap, fi.gid);
116 ent = popfile(dir, fi);
123 popfile(Ram *dir, Fileinf fi)
125 Ram *ent = (Ram *)emalloc(sizeof(Ram));
131 ent->next = dir->child;
134 ent->qid.path = ++path;
137 ent->qid.type = QTDIR;
139 ent->qid.type = QTFILE;
141 ent->name = estrdup(fi.name);
142 ent->atime = ent->mtime = fi.mdate;
143 ent->user = mapid(uidmap, fi.uid);
144 ent->group = mapid(gidmap, fi.gid);
145 ent->ndata = fi.size;
148 ent->replete |= replete;
153 lookup(Ram *dir, char *name)
159 for (r=dir->child; r; r=r->next){
160 if (r->busy==0 || strcmp(r->name, name)!=0)