2005-01-04 21:22:40 +00:00
|
|
|
/* Copyright (C) 2003 Russ Cox, Massachusetts Institute of Technology */
|
|
|
|
|
/* See COPYRIGHT */
|
|
|
|
|
|
|
|
|
|
#include <u.h>
|
|
|
|
|
#include <libc.h>
|
|
|
|
|
#include <fcall.h>
|
|
|
|
|
#include <9pclient.h>
|
|
|
|
|
#include "fsimpl.h"
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
fsdirwstat(CFsys *fs, char *name, Dir *d)
|
|
|
|
|
{
|
|
|
|
|
int n;
|
|
|
|
|
CFid *fid;
|
|
|
|
|
|
2006-07-23 02:55:34 +00:00
|
|
|
if((fid = fswalk(fs->root, name)) == nil)
|
2005-01-04 21:22:40 +00:00
|
|
|
return -1;
|
2020-01-10 14:44:21 +00:00
|
|
|
|
2005-01-04 21:22:40 +00:00
|
|
|
n = fsdirfwstat(fid, d);
|
|
|
|
|
fsclose(fid);
|
|
|
|
|
return n;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
fsdirfwstat(CFid *fid, Dir *d)
|
|
|
|
|
{
|
|
|
|
|
uchar *a;
|
|
|
|
|
int n, nn;
|
|
|
|
|
Fcall tx, rx;
|
|
|
|
|
|
2010-12-07 13:34:11 -05:00
|
|
|
n = sizeD2M(d);
|
2005-01-04 21:22:40 +00:00
|
|
|
a = malloc(n);
|
|
|
|
|
if(a == nil)
|
|
|
|
|
return -1;
|
2010-12-07 13:34:11 -05:00
|
|
|
nn = convD2M(d, a, n);
|
2005-01-04 21:22:40 +00:00
|
|
|
if(n != nn){
|
|
|
|
|
werrstr("convD2M and sizeD2M disagree");
|
|
|
|
|
free(a);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tx.type = Twstat;
|
|
|
|
|
tx.fid = fid->fid;
|
|
|
|
|
tx.stat = a;
|
|
|
|
|
tx.nstat = n;
|
|
|
|
|
n = _fsrpc(fid->fs, &tx, &rx, 0);
|
|
|
|
|
free(a);
|
|
|
|
|
return n;
|
|
|
|
|
}
|