static void fsdestroyfid(Fid *f) { Aux *a = f->aux; if(ptype(f->qid.path) == Pinfo) freeinfo(pindex(f->qid.path)); f->omode = -1; if(! a) return; if(a->fh != -1) if(CIFSclose(Sess, a->sp, a->fh) == -1) fprint(2, "%s: close failed fh=%d %r\n", argv0, a->fh); if(a->sh != -1) if(CIFSfindclose2(Sess, a->sp, a->sh) == -1) fprint(2, "%s: findclose failed sh=%d %r\n", argv0, a->sh); if(a->path) free(a->path); if(a->cache) free(a->cache); if(a == Auxroot) Auxroot = a->next; a->prev->next = a->next; a->next->prev = a->prev; if(a->next == a->prev) Auxroot = nil; if(a) free(a); }
void upd_names(Session *s, Share *sp, char *path, Dir *d) { int fh, result; char *usid, *gsid; FInfo fi; if(d->uid) free(d->uid); if(d->gid) free(d->gid); if((fh = CIFS_NT_opencreate(s, sp, path, 0, 0, 0, READ_CONTROL, FILE_SHARE_ALL, FILE_OPEN, &result, &fi)) == -1){ d->uid = estrdup9p("unknown"); d->gid = estrdup9p("unknown"); return; } usid = nil; gsid = nil; TNTquerysecurity(s, sp, fh, &usid, &gsid); d->uid = sid2name(usid); d->gid = sid2name(gsid); if(fh != -1) CIFSclose(s, sp, fh); }