URI:
       tstat.c - plan9port - [fork] Plan 9 from user space
  HTML git clone git://src.adamsgaard.dk/plan9port
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
       tstat.c (823B)
       ---
            1 /* Copyright (C) 2003 Russ Cox, Massachusetts Institute of Technology */
            2 /* See COPYRIGHT */
            3 
            4 #include <u.h>
            5 #include <libc.h>
            6 #include <fcall.h>
            7 #include <9pclient.h>
            8 #include "fsimpl.h"
            9 
           10 Dir*
           11 fsdirstat(CFsys *fs, char *name)
           12 {
           13         Dir *d;
           14         CFid *fid;
           15 
           16         if((fid = fswalk(fs->root, name)) == nil)
           17                 return nil;
           18 
           19         d = fsdirfstat(fid);
           20         fsclose(fid);
           21         return d;
           22 }
           23 
           24 Dir*
           25 fsdirfstat(CFid *fid)
           26 {
           27         Dir *d;
           28         CFsys *fs;
           29         Fcall tx, rx;
           30         void *freep;
           31         int n;
           32 
           33         fs = fid->fs;
           34         tx.type = Tstat;
           35         tx.fid = fid->fid;
           36 
           37         if(_fsrpc(fs, &tx, &rx, &freep) < 0)
           38                 return nil;
           39 
           40         d = malloc(sizeof(Dir)+rx.nstat);
           41         if(d == nil){
           42                 free(freep);
           43                 return nil;
           44         }
           45         n = convM2D(rx.stat, rx.nstat, d, (char*)&d[1]);
           46         free(freep);
           47         if(n != rx.nstat){
           48                 free(d);
           49                 werrstr("rx.nstat and convM2D disagree about dir length");
           50                 return nil;
           51         }
           52         return d;
           53 }