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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
/*
Copyright (C) 1994 Free Software Foundation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Implement the netfs_validate_stat callback as described in
<hurd/netfs.h>. */
error_t
netfs_validate_stat (struct node *np, struct protid *cred)
{
struct vfsv2_fattr *fattr;
size_t hsize;
char *rpc;
struct nfsv2_attrstat *reply;
error_t err;
/* The only arg is the file handle. */
hsize = rpc_compute_header_size (cred->nc.auth);
rpc = alloca (hsize + sizeof (nfsv2_fhandle_t));
/* Fill in request arg */
bcopy (&np->nn.handle, rpc + hsize, NFSV2_FHSIZE);
/* Transmit */
err = nfs_rpc_send (NFSV2_GETATTR, rpc, hsize + NFSV2_FHSIZE,
&reply, sizeof (struct nfsv2_attrstat));
if (err)
return err;
xdr_to_native_attrstat (reply);
if (reply->status != NFSV2_OK)
err = nfsv2err_to_hurderr (reply->status);
else
{
np->nn_stat.st_mode = nfsv2mode_to_hurdmode (reply->attributes.type,
reply->attributes.mode);
np->nn_stat.st_nlink = reply->attributes.nlink;
np->nn_stat.st_uid = reply->attributes.uid;
np->nn_stat.st_gid = reply->attributes.gid;
np->nn_stat.st_size = reply->attributes.size;
np->nn_stat.st_blksize = reply->attributes.blocksize;
np->nn_stat.st_rdev = reply->attributes.rdev;
np->nn_stat.st_blocks = reply->attributes.blocks;
np->nn_stat.st_fstype = FSTYPE_NFS;
np->nn_stat.st_fsid = reply->attributes.fsid; /* surely wrong XXX */
np->nn_stat.st_fileid = reply->attributes.fileid;
np->nn_stat.st_atime = reply->attributes.atime.seconds;
np->nn_stat.st_atime_usec = reply->attributes.atime.useconds;
np->nn_stat.st_mtime = reply->attributes.mtime.seconds;
np->nn_stat.st_mtime_usec = reply->attributes.mtime.useconds;
np->nn_stat.st_ctime = reply->attributes.ctime.seconds;
np->nn_stat.st_ctime_usec = reply->attributes.ctime.useconds;
/* Deal with other values appropriately? */
err = 0;
}
deallocate_reply_buffer (reply);
return err;
}
|