aboutsummaryrefslogtreecommitdiff
path: root/src/libfs/wstat.c
blob: f1f14ea587f8fc00b39306cf57f383de1f53b575 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* Copyright (C) 2003 Russ Cox, Massachusetts Institute of Technology */
/* See COPYRIGHT */

#include <u.h>
#include <libc.h>
#include <fcall.h>
#include <fs.h>
#include "fsimpl.h"

int
fsdirwstat(Fsys *fs, char *name, Dir *d)
{
	int n;
	Fid *fid;

	if((fid = fswalk(fs->root, name)) == nil)
		return -1;
	
	n = fsdirfwstat(fid, d);
	fsclose(fid);
	return n;
}

int
fsdirfwstat(Fid *fid, Dir *d)
{
	uchar *a;
	int n, nn;
	Fcall tx, rx;

	n = sizeD2M(d);
	a = malloc(n);
	if(a == nil)
		return -1;
	nn = convD2M(d, a, n);
	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;
}