summaryrefslogtreecommitdiff
path: root/ext2fs/inode.c
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1996-06-24 21:32:01 +0000
committerMiles Bader <miles@gnu.org>1996-06-24 21:32:01 +0000
commitf74b90d7e3174cca883b072903adaa7dc77c2724 (patch)
treedeb9d066a5465bc362e84c9d14fd90cf9eb45d95 /ext2fs/inode.c
parenta13f5d0b8a4c4372936a92ef66f56b25530b8429 (diff)
(check_high_bits, diskfs_validate_owner_change,
diskfs_validate_group_change, diskfs_validate_mode_change, diskfs_validate_author_change): New functions. (write_node): For non-hurd filesystems, assert that no hurd extensions should be used.
Diffstat (limited to 'ext2fs/inode.c')
-rw-r--r--ext2fs/inode.c63
1 files changed, 59 insertions, 4 deletions
diff --git a/ext2fs/inode.c b/ext2fs/inode.c
index 7d30a21c..68c9451e 100644
--- a/ext2fs/inode.c
+++ b/ext2fs/inode.c
@@ -176,7 +176,7 @@ diskfs_new_hardrefs (struct node *np)
{
allow_pager_softrefs (np);
}
-
+
/* Read stat information out of the ext2_inode. */
static error_t
read_disknode (struct node *np)
@@ -277,6 +277,54 @@ read_disknode (struct node *np)
return 0;
}
+
+/* Return EINVAL if this is not a hurd filesystem and any bits are set in L
+ except the low 16 bits, else 0. */
+static inline error_t
+check_high_bits (struct node *np, long l)
+{
+ if (sblock->s_creator_os == EXT2_OS_HURD)
+ return 0;
+ else
+ return ((l & ~0xFFFF) == 0) ? 0 : EINVAL;
+}
+
+/* Return 0 if NP's owner can be changed to UID; otherwise return an error
+ code. */
+error_t
+diskfs_validate_owner_change (struct node *np, uid_t uid)
+{
+ return check_high_bits (np, uid);
+}
+
+/* Return 0 if NP's group can be changed to GID; otherwise return an error
+ code. */
+error_t
+diskfs_validate_group_change (struct node *np, gid_t gid)
+{
+ return check_high_bits (np, gid);
+}
+
+/* Return 0 if NP's mode can be changed to MODE; otherwise return an error
+ code. It must always be possible to clear the mode; diskfs will not ask
+ for permission before doing so. */
+error_t
+diskfs_validate_mode_change (struct node *np, mode_t mode)
+{
+ return check_high_bits (np, mode);
+}
+
+/* Return 0 if NP's author can be changed to AUTHOR; otherwise return an
+ error code. */
+error_t
+diskfs_validate_author_change (struct node *np, uid_t author)
+{
+ if (sblock->s_creator_os == EXT2_OS_HURD)
+ return 0;
+ else
+ /* For non-hurd filesystems, the auther & owner are the same. */
+ return (author == np->dn_stat.st_uid) ? 0 : EINVAL;
+}
/* Writes everything from NP's inode to the disk image, and returns a pointer
to it, or NULL if nothing need be done. */
@@ -314,14 +362,21 @@ write_node (struct node *np)
di->i_gid = st->st_gid & 0xFFFF;
if (sblock->s_creator_os == EXT2_OS_HURD)
- /* If this is a hurd-compatible filesystem, write the high bits too.
- XXX what should we do if we can't and they're not 0? */
+ /* If this is a hurd-compatible filesystem, write the high bits too. */
{
di->i_mode_high = (st->st_mode >> 16) & 0xffff;
di->i_uid_high = st->st_uid >> 16;
di->i_gid_high = st->st_gid >> 16;
di->i_author = st->st_author;
}
+ else
+ /* No hurd extensions should be turned on. */
+ {
+ assert ((st->st_uid & ~0xFFFF) == 0);
+ assert ((st->st_gid & ~0xFFFF) == 0);
+ assert ((st->st_mode & ~0xFFFF) == 0);
+ assert (st->st_author == st->st_uid);
+ }
di->i_links_count = st->st_nlink;
di->i_size = st->st_size;
@@ -361,7 +416,7 @@ write_node (struct node *np)
else
return NULL;
}
-
+
/* Reload all data specific to NODE from disk, without writing anything.
Always called with DISKFS_READONLY true. */
error_t