From 46f79934b79ef526ed42bbe5a565e6b5d884d24a Mon Sep 17 00:00:00 2001 From: rsc Date: Tue, 4 Jan 2005 21:22:40 +0000 Subject: lib9pclient is the new libfs --- src/lib9pclient/stat.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/lib9pclient/stat.c (limited to 'src/lib9pclient/stat.c') diff --git a/src/lib9pclient/stat.c b/src/lib9pclient/stat.c new file mode 100644 index 00000000..cb5d8261 --- /dev/null +++ b/src/lib9pclient/stat.c @@ -0,0 +1,54 @@ +/* Copyright (C) 2003 Russ Cox, Massachusetts Institute of Technology */ +/* See COPYRIGHT */ + +#include +#include +#include +#include <9pclient.h> +#include "fsimpl.h" + +Dir* +fsdirstat(CFsys *fs, char *name) +{ + Dir *d; + CFid *fid; + + if((fid = _fswalk(fs->root, name)) == nil) + return nil; + + d = fsdirfstat(fid); + fsclose(fid); + return d; +} + +Dir* +fsdirfstat(CFid *fid) +{ + Dir *d; + CFsys *fs; + Fcall tx, rx; + void *freep; + int n; + + fs = fid->fs; + tx.type = Tstat; + tx.fid = fid->fid; + + if(_fsrpc(fs, &tx, &rx, &freep) < 0) + return nil; + + d = malloc(sizeof(Dir)+rx.nstat); + if(d == nil){ + free(freep); + return nil; + } + n = convM2D(rx.stat, rx.nstat, d, (char*)&d[1]); + free(freep); + if(n != rx.nstat){ + free(d); + werrstr("rx.nstat and convM2D disagree about dir length"); + return nil; + } + return d; +} + -- cgit v1.2.3