summaryrefslogtreecommitdiff
path: root/ufs/dir.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2002-06-11 21:40:58 +0000
committerRoland McGrath <roland@gnu.org>2002-06-11 21:40:58 +0000
commite67c34f0cbacb31f56ad46510857acfe20c4db90 (patch)
treee1ad61105d8c3669798bd01e31528ff58f5a4758 /ufs/dir.c
parent6814a9338d1211625964ca3a702cd38e8708bc6f (diff)
2002-06-08 Roland McGrath <roland@frob.com>
* dir.c (diskfs_direnter_hard): Use size_t for OLDSIZE. Fail with EOVERFLOW when it would exceed that width. * alloc.c, dir.c: Use %Ld format for ino_t values. * alloc.c (diskfs_alloc_node): Use %Ld format for blkcnt_t values.
Diffstat (limited to 'ufs/dir.c')
-rw-r--r--ufs/dir.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/ufs/dir.c b/ufs/dir.c
index 3256bc42..b67e45f6 100644
--- a/ufs/dir.c
+++ b/ufs/dir.c
@@ -379,7 +379,7 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx,
|| DIRSIZ (DIRECT_NAMLEN (entry)) > read_disk_entry (entry->d_reclen)
|| memchr (entry->d_name, '\0', DIRECT_NAMLEN (entry)))
{
- fprintf (stderr, "Bad directory entry: inode: %d offset: %zd\n",
+ fprintf (stderr, "Bad directory entry: inode: %Ld offset: %zd\n",
dp->dn->number, currentoff - blockaddr + idx * DIRBLKSIZ);
return ENOENT;
}
@@ -502,7 +502,7 @@ diskfs_direnter_hard(struct node *dp,
vm_address_t fromoff, tooff;
int totfreed;
error_t err;
- off_t oldsize = 0;
+ size_t oldsize = 0;
assert (ds->type == CREATE);
@@ -585,6 +585,12 @@ diskfs_direnter_hard(struct node *dp,
assert (needed <= DIRBLKSIZ);
oldsize = dp->dn_stat.st_size;
+ if ((off_t)(oldsize + DIRBLKSIZ) != dp->dn_stat.st_size)
+ {
+ /* We can't possibly map the whole directory in. */
+ munmap ((caddr_t) ds->mapbuf, ds->mapextent);
+ return EOVERFLOW;
+ }
while (oldsize + DIRBLKSIZ > dp->allocsize)
{
err = diskfs_grow (dp, oldsize + DIRBLKSIZ, cred);