summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libdiskfs/fhandle.h17
-rw-r--r--libdiskfs/file-getfh.c22
-rw-r--r--libdiskfs/fsys-getfile.c26
3 files changed, 34 insertions, 31 deletions
diff --git a/libdiskfs/fhandle.h b/libdiskfs/fhandle.h
index 9b1c7105..bd827d84 100644
--- a/libdiskfs/fhandle.h
+++ b/libdiskfs/fhandle.h
@@ -1,6 +1,6 @@
/* File handle type (for nfs server support)
- Copyright (C) 1997 Free Software Foundation
+ Copyright (C) 1997,99 Free Software Foundation, Inc.
This file is part of the GNU Hurd.
@@ -9,7 +9,7 @@
the Free Software Foundation; either version 2, or (at your option)
any later version.
- The GNU Hurd is distributed in the hope that it will be useful,
+ The GNU Hurd 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.
@@ -22,12 +22,15 @@
#define __FHANDLE_H__
/* Must be exactly 28 bytes long */
-struct diskfs_fhandle
+union diskfs_fhandle
{
- int filler1;
- int cache_id;
- long gen;
- int filler2[28 - sizeof (int) + sizeof (int) + sizeof (long)];
+ unsigned char bytes[28];
+ struct
+ {
+ int pad1;
+ int cache_id;
+ unsigned int gen;
+ } data;
};
#endif /* __FHANDLE_H__ */
diff --git a/libdiskfs/file-getfh.c b/libdiskfs/file-getfh.c
index c755e911..a2dbb045 100644
--- a/libdiskfs/file-getfh.c
+++ b/libdiskfs/file-getfh.c
@@ -9,7 +9,7 @@
the Free Software Foundation; either version 2, or (at your option)
any later version.
- The GNU Hurd is distributed in the hope that it will be useful,
+ The GNU Hurd 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.
@@ -29,30 +29,30 @@ error_t
diskfs_S_file_getfh (struct protid *cred, char **fh, unsigned *fh_len)
{
struct node *node;
- struct diskfs_fhandle *f;
+ union diskfs_fhandle *f;
if (! cred)
return EOPNOTSUPP;
if (! idvec_contains (cred->user->uids, 0))
return EPERM;
-
+
+ assert (sizeof *f == sizeof f->bytes);
+
node = cred->po->np;
mutex_lock (&node->lock);
if (*fh_len < sizeof (struct diskfs_fhandle))
- *fh = mmap (0, sizeof (struct diskfs_fhandle), PROT_READ|PROT_WRITE,
+ *fh = mmap (0, sizeof (struct diskfs_fhandle), PROT_READ|PROT_WRITE,
MAP_ANON, 0, 0);
- *fh_len = sizeof (struct diskfs_fhandle);
-
- f = (struct diskfs_fhandle *)*fh;
+ *fh_len = sizeof *f;
- f->cache_id = node->cache_id;
- f->gen = node->dn_stat.st_gen;
+ f = (union diskfs_fhandle *) *fh;
- f->filler1 = 0;
- bzero (f->filler2, sizeof f->filler2);
+ bzero (f, sizeof *f);
+ f->data.cache_id = node->cache_id;
+ f->data.gen = node->dn_stat.st_gen;
mutex_unlock (&node->lock);
diff --git a/libdiskfs/fsys-getfile.c b/libdiskfs/fsys-getfile.c
index 56766ed4..7d125304 100644
--- a/libdiskfs/fsys-getfile.c
+++ b/libdiskfs/fsys-getfile.c
@@ -1,6 +1,6 @@
/* Return the file for a given handle (for nfs server support)
- Copyright (C) 1997 Free Software Foundation
+ Copyright (C) 1997,99 Free Software Foundation, Inc.
This file is part of the GNU Hurd.
@@ -9,7 +9,7 @@
the Free Software Foundation; either version 2, or (at your option)
any later version.
- The GNU Hurd is distributed in the hope that it will be useful,
+ The GNU Hurd 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.
@@ -37,45 +37,45 @@ diskfs_S_fsys_getfile (mach_port_t fsys,
int flags;
error_t err;
struct node *node;
- struct diskfs_fhandle *f;
+ const union diskfs_fhandle *f;
struct protid *new_cred;
struct idvec *uvec, *gvec;
struct iouser *user;
struct port_info *pt =
ports_lookup_port (diskfs_port_bucket, fsys, diskfs_control_class);
-
+
if (!pt)
return EOPNOTSUPP;
- if (handle_len != sizeof (struct diskfs_fhandle))
+ if (handle_len != sizeof *f)
{
ports_port_deref (pt);
return EINVAL;
}
- f = (struct diskfs_fhandle *) handle;
+ f = (const union diskfs_fhandle *) handle;
- err = diskfs_cached_lookup (f->cache_id, &node);
+ err = diskfs_cached_lookup (f->data.cache_id, &node);
if (err)
{
ports_port_deref (pt);
return err;
}
- if (node->dn_stat.st_gen != f->gen)
+ if (node->dn_stat.st_gen != f->data.gen)
{
diskfs_nput (node);
ports_port_deref (pt);
return ESTALE;
}
-
+
uvec = make_idvec ();
gvec = make_idvec ();
idvec_set_ids (uvec, uids, nuids);
idvec_set_ids (gvec, gids, ngids);
user = iohelp_create_iouser (uvec, gvec);
-
+
flags = 0;
if (! fshelp_access (&node->dn_stat, S_IREAD, user))
flags |= O_READ;
@@ -88,12 +88,12 @@ diskfs_S_fsys_getfile (mach_port_t fsys,
err = diskfs_create_protid (diskfs_make_peropen (node, flags, 0),
user, &new_cred);
-
+
iohelp_free_iouser (user);
-
+
diskfs_nput (node);
ports_port_deref (pt);
-
+
if (! err)
{
*file = ports_get_right (new_cred);