summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1998-10-20 19:20:07 +0000
committerRoland McGrath <roland@gnu.org>1998-10-20 19:20:07 +0000
commitb607a94656e5c698dbb2cfc4b701dd7c50acc875 (patch)
treed2c4cc2083278cd17341c04ed63df1157f08cdbd
parent691cc5992adb373ed6422915fa504f13ebc77238 (diff)
1998-09-04 Roland McGrath <roland@baalperazim.frob.com>
* dir.c (diskfs_lookup_hard): Fix defn with `const'. (diskfs_direnter_hard): Likewise. (dirscanblock): Likewise. * inode.c (diskfs_create_symlink_hook, create_symlink_hook): Likewise. (diskfs_set_translator): Likewise.
-rw-r--r--ufs/dir.c172
-rw-r--r--ufs/inode.c98
2 files changed, 135 insertions, 135 deletions
diff --git a/ufs/dir.c b/ufs/dir.c
index bdf84be6..01432829 100644
--- a/ufs/dir.c
+++ b/ufs/dir.c
@@ -1,5 +1,5 @@
/* Directory management routines
- Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation
+ Copyright (C) 1994, 1995, 1996, 1997, 1998 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
@@ -64,8 +64,8 @@ struct dirstat
/* Index of this directory block. */
int idx;
-
- /* For stat COMPRESS, this is the address (inside mapbuf)
+
+ /* For stat COMPRESS, this is the address (inside mapbuf)
of the first direct in the directory block to be compressed. */
/* For stat HERE_TIS, SHRINK, and TAKE, this is the entry referenced. */
struct directory_entry *entry;
@@ -82,21 +82,21 @@ struct dirstat
size_t diskfs_dirstat_size = sizeof (struct dirstat);
/* Initialize DS such that diskfs_drop_dirstat will ignore it. */
-void
+void
diskfs_null_dirstat (struct dirstat *ds)
{
ds->type = LOOKUP;
}
-static error_t
-dirscanblock (vm_address_t blockoff, struct node *dp, int idx, char *name,
- int namelen, enum lookup_type type, struct dirstat *ds,
- ino_t *inum);
+static error_t
+dirscanblock (vm_address_t blockoff, struct node *dp, int idx,
+ const char *name, int namelen, enum lookup_type type,
+ struct dirstat *ds, ino_t *inum);
/* Implement the diskfs_lookup from the diskfs library. See
<hurd/diskfs.h> for the interface specification. */
error_t
-diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type,
+diskfs_lookup_hard (struct node *dp, const char *name, enum lookup_type type,
struct node **npp, struct dirstat *ds, struct protid *cred)
{
error_t err;
@@ -113,7 +113,7 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type,
int blockaddr;
int idx, lastidx;
int looped;
-
+
if ((type == REMOVE) || (type == RENAME))
assert (npp);
@@ -122,12 +122,12 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type,
spec_dotdot = type & SPEC_DOTDOT;
type &= ~SPEC_DOTDOT;
-
+
namelen = strlen (name);
if (namelen > MAXNAMLEN)
return ENAMETOOLONG;
-
+
try_again:
if (ds)
{
@@ -157,10 +157,10 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type,
mach_port_deallocate (mach_task_self (), memobj);
inum = 0;
-
+
if (!diskfs_check_readonly ())
dp->dn_set_atime = 1;
-
+
/* Start the lookup at DP->dn->dir_idx. */
idx = dp->dn->dir_idx;
if (idx * DIRBLKSIZ > dp->dn_stat.st_size)
@@ -221,7 +221,7 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type,
goto out;
}
}
-
+
/* We are looking up .. */
/* Check to see if this is the root of the filesystem. */
else if (dp->dn->number == 2)
@@ -229,7 +229,7 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type,
err = EAGAIN;
goto out;
}
-
+
/* We can't just do diskfs_cached_lookup, because we would then deadlock.
So we do this. Ick. */
else if (retry_dotdot)
@@ -263,11 +263,11 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type,
retry_dotdot = inum;
goto try_again;
}
-
+
/* Here below are the spec dotdot cases. */
else if (type == RENAME || type == REMOVE)
np = ifind (inum);
-
+
else if (type == LOOKUP)
{
diskfs_nput (dp);
@@ -278,7 +278,7 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type,
else
assert (0);
}
-
+
if ((type == CREATE || type == RENAME) && !inum && ds && ds->stat == LOOKING)
{
/* We didn't find any room, so mark ds to extend the dir */
@@ -304,7 +304,7 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type,
ds->mapbuf = buf;
ds->mapextent = buflen;
}
-
+
if (np)
{
assert (npp);
@@ -338,8 +338,8 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type,
diskfs_lookup. If found, set *INUM to the inode number, else
return ENOENT. */
static error_t
-dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name,
- int namelen, enum lookup_type type,
+dirscanblock (vm_address_t blockaddr, struct node *dp, int idx,
+ const char *name, int namelen, enum lookup_type type,
struct dirstat *ds, ino_t *inum)
{
int nfree = 0;
@@ -351,7 +351,7 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name,
int looking = 0;
int countcopies = 0;
int consider_compress = 0;
-
+
if (ds && (ds->stat == LOOKING
|| ds->stat == COMPRESS))
{
@@ -365,11 +365,11 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name,
prevoff = currentoff, currentoff += read_disk_entry (entry->d_reclen))
{
entry = (struct directory_entry *)currentoff;
-
+
if (!entry->d_reclen
|| read_disk_entry (entry->d_reclen) % 4
|| DIRECT_NAMLEN (entry) > MAXNAMLEN
- || (currentoff + read_disk_entry (entry->d_reclen)
+ || (currentoff + read_disk_entry (entry->d_reclen)
> blockaddr + DIRBLKSIZ)
|| entry->d_name[DIRECT_NAMLEN (entry)]
|| DIRSIZ (DIRECT_NAMLEN (entry)) > read_disk_entry (entry->d_reclen)
@@ -379,16 +379,16 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name,
dp->dn->number, currentoff - blockaddr + idx * DIRBLKSIZ);
return ENOENT;
}
-
+
if (looking || countcopies)
{
int thisfree;
-
+
/* Count how much free space this entry has in it. */
if (entry->d_ino == 0)
thisfree = read_disk_entry (entry->d_reclen);
else
- thisfree = (read_disk_entry (entry->d_reclen)
+ thisfree = (read_disk_entry (entry->d_reclen)
- DIRSIZ (DIRECT_NAMLEN (entry)));
/* If this isn't at the front of the block, then it will
@@ -396,9 +396,9 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name,
number of bytes there too. */
if (countcopies && currentoff != blockaddr)
nbytes += DIRSIZ (DIRECT_NAMLEN (entry));
-
+
if (ds->stat == COMPRESS && nbytes > ds->nbytes)
- /* The previously found compress is better than
+ /* The previously found compress is better than
this one, so don't bother counting any more. */
countcopies = 0;
@@ -415,9 +415,9 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name,
nfree += thisfree;
if (nfree >= needed)
consider_compress = 1;
- }
+ }
}
-
+
if (entry->d_ino)
nentries++;
@@ -428,7 +428,7 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name,
break;
}
- if (consider_compress
+ if (consider_compress
&& (ds->type == LOOKING
|| (ds->type == COMPRESS && ds->nbytes > nbytes)))
{
@@ -438,7 +438,7 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name,
ds->idx = idx;
ds->nbytes = nbytes;
}
-
+
if (currentoff >= blockaddr + DIRBLKSIZ)
{
int i;
@@ -448,9 +448,9 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name,
down how many entries there were. */
if (!dp->dn->dirents)
{
- dp->dn->dirents = malloc ((dp->dn_stat.st_size / DIRBLKSIZ)
+ dp->dn->dirents = malloc ((dp->dn_stat.st_size / DIRBLKSIZ)
* sizeof (int));
- for (i = 0; i < dp->dn_stat.st_size/DIRBLKSIZ; i++)
+ for (i = 0; i < dp->dn_stat.st_size/DIRBLKSIZ; i++)
dp->dn->dirents[i] = -1;
}
/* Make sure the count is correct if there is one now. */
@@ -460,7 +460,7 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name,
return ENOENT;
}
-
+
/* We have found the required name. */
if (ds && type == CREATE)
@@ -486,7 +486,7 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, int idx, char *name,
the preceding lookup call, and only if that call returned ENOENT. */
error_t
diskfs_direnter_hard(struct node *dp,
- char *name,
+ const char *name,
struct node *np,
struct dirstat *ds,
struct protid *cred)
@@ -496,21 +496,21 @@ diskfs_direnter_hard(struct node *dp,
int needed = DIRSIZ (namelen);
int oldneeded;
vm_address_t fromoff, tooff;
- int totfreed;
+ int totfreed;
error_t err;
off_t oldsize = 0;
assert (ds->type == CREATE);
-
+
dp->dn_set_mtime = 1;
switch (ds->stat)
{
case TAKE:
/* We are supposed to consume this slot. */
- assert (ds->entry->d_ino == 0
+ assert (ds->entry->d_ino == 0
&& read_disk_entry (ds->entry->d_reclen) >= needed);
-
+
write_disk_entry (ds->entry->d_ino, np->dn->number);
DIRECT_NAMLEN (ds->entry) = namelen;
if (direct_symlink_extension)
@@ -518,27 +518,27 @@ diskfs_direnter_hard(struct node *dp,
bcopy (name, ds->entry->d_name, namelen + 1);
break;
-
+
case SHRINK:
/* We are supposed to take the extra space at the end
of this slot. */
oldneeded = DIRSIZ (DIRECT_NAMLEN (ds->entry));
assert (read_disk_entry (ds->entry->d_reclen) - oldneeded >= needed);
-
+
new = (struct directory_entry *) ((vm_address_t) ds->entry + oldneeded);
write_disk_entry (new->d_ino, np->dn->number);
- write_disk_entry (new->d_reclen,
+ write_disk_entry (new->d_reclen,
read_disk_entry (ds->entry->d_reclen) - oldneeded);
DIRECT_NAMLEN (new) = namelen;
if (direct_symlink_extension)
new->d_type = IFTODT (np->dn_stat.st_mode);
bcopy (name, new->d_name, namelen + 1);
-
+
write_disk_entry (ds->entry->d_reclen, oldneeded);
-
+
break;
-
+
case COMPRESS:
/* We are supposed to move all the entries to the
front of the block, giving each the minimum
@@ -566,7 +566,7 @@ diskfs_direnter_hard(struct node *dp,
totfreed = (vm_address_t) ds->entry + DIRBLKSIZ - tooff;
assert (totfreed >= needed);
-
+
new = (struct directory_entry *) tooff;
write_disk_entry (new->d_ino, np->dn->number);
write_disk_entry (new->d_reclen, totfreed);
@@ -579,7 +579,7 @@ diskfs_direnter_hard(struct node *dp,
case EXTEND:
/* Extend the file. */
assert (needed <= DIRBLKSIZ);
-
+
oldsize = dp->dn_stat.st_size;
while (oldsize + DIRBLKSIZ > dp->allocsize)
{
@@ -603,7 +603,7 @@ diskfs_direnter_hard(struct node *dp,
new->d_type = IFTODT (np->dn_stat.st_mode);
bcopy (name, new->d_name, namelen + 1);
break;
-
+
default:
assert (0);
}
@@ -611,10 +611,10 @@ diskfs_direnter_hard(struct node *dp,
dp->dn_set_mtime = 1;
vm_deallocate (mach_task_self (), ds->mapbuf, ds->mapextent);
-
+
if (ds->stat != EXTEND)
{
- /* If we are keeping count of this block, then keep the count up
+ /* If we are keeping count of this block, then keep the count up
to date. */
if (dp->dn->dirents && dp->dn->dirents[ds->idx] != -1)
dp->dn->dirents[ds->idx]++;
@@ -626,10 +626,10 @@ diskfs_direnter_hard(struct node *dp,
anything at all. */
if (dp->dn->dirents)
{
- dp->dn->dirents = realloc (dp->dn->dirents,
+ dp->dn->dirents = realloc (dp->dn->dirents,
(dp->dn_stat.st_size / DIRBLKSIZ
* sizeof (int)));
- for (i = oldsize / DIRBLKSIZ;
+ for (i = oldsize / DIRBLKSIZ;
i < dp->dn_stat.st_size / DIRBLKSIZ;
i++)
dp->dn->dirents[i] = -1;
@@ -638,14 +638,14 @@ diskfs_direnter_hard(struct node *dp,
}
else
{
- dp->dn->dirents = malloc (dp->dn_stat.st_size / DIRBLKSIZ
+ dp->dn->dirents = malloc (dp->dn_stat.st_size / DIRBLKSIZ
* sizeof (int));
for (i = 0; i < dp->dn_stat.st_size / DIRBLKSIZ; i++)
dp->dn->dirents[i] = -1;
dp->dn->dirents[ds->idx] = 1;
}
}
-
+
diskfs_file_update (dp, 1);
return 0;
@@ -662,7 +662,7 @@ diskfs_dirremove_hard(struct node *dp,
{
assert (ds->type == REMOVE);
assert (ds->stat == HERE_TIS);
-
+
dp->dn_set_mtime = 1;
if (ds->preventry == 0)
@@ -671,7 +671,7 @@ diskfs_dirremove_hard(struct node *dp,
{
assert ((vm_address_t) ds->entry - (vm_address_t) ds->preventry
== read_disk_entry (ds->preventry->d_reclen));
- write_disk_entry (ds->preventry->d_reclen,
+ write_disk_entry (ds->preventry->d_reclen,
(read_disk_entry (ds->preventry->d_reclen)
+ read_disk_entry (ds->entry->d_reclen)));
}
@@ -684,27 +684,27 @@ diskfs_dirremove_hard(struct node *dp,
to date. */
if (dp->dn->dirents && dp->dn->dirents[ds->idx] != -1)
dp->dn->dirents[ds->idx]--;
-
+
diskfs_file_update (dp, 1);
return 0;
}
-
+
/* Following a lookup call for RENAME, this changes the inode number
- on a directory entry. DP is the directory being changed; NP is
- the new node being linked in; DP is the cached information returned
+ on a directory entry. DP is the directory being changed; NP is
+ the new node being linked in; DP is the cached information returned
by lookup. This call is only valid if the directory has been locked
continuously since the call to lookup, and only if that call
succeeded. */
error_t
-diskfs_dirrewrite_hard(struct node *dp,
+diskfs_dirrewrite_hard(struct node *dp,
struct node *np,
struct dirstat *ds)
{
assert (ds->type == RENAME);
assert (ds->stat == HERE_TIS);
-
+
dp->dn_set_mtime = 1;
write_disk_entry (ds->entry->d_ino, np->dn->number);
if (direct_symlink_extension)
@@ -712,7 +712,7 @@ diskfs_dirrewrite_hard(struct node *dp,
dp->dn_set_mtime = 1;
vm_deallocate (mach_task_self (), ds->mapbuf, ds->mapextent);
-
+
diskfs_file_update (dp, 1);
return 0;
@@ -737,7 +737,7 @@ diskfs_dirempty(struct node *dp,
return 0;
buf = 0;
-
+
err = vm_map (mach_task_self (), &buf, dp->dn_stat.st_size, 0,
1, memobj, 0, 0, VM_PROT_READ, VM_PROT_READ, 0);
mach_port_deallocate (mach_task_self (), memobj);
@@ -746,7 +746,7 @@ diskfs_dirempty(struct node *dp,
if (!diskfs_check_readonly ())
dp->dn_set_atime = 1;
- for (curoff = buf;
+ for (curoff = buf;
curoff < buf + dp->dn_stat.st_size;
curoff += read_disk_entry (entry->d_reclen))
{
@@ -766,7 +766,7 @@ diskfs_dirempty(struct node *dp,
return 0;
}
}
- if (!diskfs_check_readonly ())
+ if (!diskfs_check_readonly ())
dp->dn_set_atime = 1;
if (diskfs_synchronous)
diskfs_node_update (dp, 1);
@@ -802,12 +802,12 @@ count_dirents (struct node *dp, int nb, char *buf)
assert (dp->dn->dirents);
assert ((nb + 1) * DIRBLKSIZ <= dp->dn_stat.st_size);
-
+
err = diskfs_node_rdwr (dp, buf, nb * DIRBLKSIZ, DIRBLKSIZ, 0, 0, &amt);
if (err)
return err;
assert (amt == DIRBLKSIZ);
-
+
for (offinblk = buf;
offinblk < buf + DIRBLKSIZ;
offinblk += read_disk_entry (entry->d_reclen))
@@ -816,7 +816,7 @@ count_dirents (struct node *dp, int nb, char *buf)
if (entry->d_ino)
count++;
}
-
+
assert (dp->dn->dirents[nb] == -1 || dp->dn->dirents[nb] == count);
dp->dn->dirents[nb] = count;
return 0;
@@ -825,8 +825,8 @@ count_dirents (struct node *dp, int nb, char *buf)
/* Implement the disikfs_get_directs callback as described in
<hurd/diskfs.h>. */
error_t
-diskfs_get_directs (struct node *dp,
- int entry,
+diskfs_get_directs (struct node *dp,
+ int entry,
int nentries,
char **data,
u_int *datacnt,
@@ -846,7 +846,7 @@ diskfs_get_directs (struct node *dp,
int allocsize;
int checklen;
struct dirent *userp;
-
+
nblks = dp->dn_stat.st_size/DIRBLKSIZ;
if (!dp->dn->dirents)
@@ -864,7 +864,7 @@ diskfs_get_directs (struct node *dp,
if (allocsize > *datacnt)
vm_allocate (mach_task_self (), (vm_address_t *) data, allocsize, 1);
-
+
/* Scan through the entries to find ENTRY. If we encounter
a -1 in the process then stop to fill it. When we run
off the end, ENTRY is too big. */
@@ -885,10 +885,10 @@ diskfs_get_directs (struct node *dp,
break;
curentry += dp->dn->dirents[blkno];
-
+
bufvalid = 0;
}
-
+
if (blkno == nblks)
{
*datacnt = 0;
@@ -911,15 +911,15 @@ diskfs_get_directs (struct node *dp,
assert (checklen == DIRBLKSIZ);
bufvalid = 1;
}
- for (i = 0, bufp = buf;
- i < entry - curentry && bufp - buf < DIRBLKSIZ;
+ for (i = 0, bufp = buf;
+ i < entry - curentry && bufp - buf < DIRBLKSIZ;
(bufp
- += read_disk_entry (((struct directory_entry *)bufp)->d_reclen)),
+ += read_disk_entry (((struct directory_entry *)bufp)->d_reclen)),
i++)
;
/* Make sure we didn't run off the end. */
assert (bufp - buf < DIRBLKSIZ);
- }
+ }
i = 0;
datap = *data;
@@ -931,7 +931,7 @@ diskfs_get_directs (struct node *dp,
{
if (!bufvalid)
{
- err = diskfs_node_rdwr (dp, buf, blkno * DIRBLKSIZ, DIRBLKSIZ,
+ err = diskfs_node_rdwr (dp, buf, blkno * DIRBLKSIZ, DIRBLKSIZ,
0, 0, &checklen);
if (err)
return err;
@@ -962,17 +962,17 @@ diskfs_get_directs (struct node *dp,
bufvalid = 0;
}
}
-
+
/* We've copied all we can. If we allocated our own array
but didn't fill all of it, then free whatever memory we didn't use. */
if (allocsize > *datacnt)
{
if (round_page (datap - *data) < allocsize)
- vm_deallocate (mach_task_self (),
+ vm_deallocate (mach_task_self (),
(vm_address_t) (*data + round_page (datap - *data)),
allocsize - round_page (datap - *data));
}
-
+
/* Set variables for return */
*datacnt = datap - *data;
*amt = i;
diff --git a/ufs/inode.c b/ufs/inode.c
index fe5abbb9..658d6187 100644
--- a/ufs/inode.c
+++ b/ufs/inode.c
@@ -1,5 +1,5 @@
/* Inode management routines
- Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation
+ Copyright (C) 1994, 1995, 1996, 1997, 1998 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
@@ -44,9 +44,9 @@ inode_init ()
nodehash[n] = 0;
}
-/* Fetch inode INUM, set *NPP to the node structure;
+/* Fetch inode INUM, set *NPP to the node structure;
gain one user reference and lock the node. */
-error_t
+error_t
diskfs_cached_lookup (int inum, struct node **npp)
{
struct disknode *dn;
@@ -88,7 +88,7 @@ diskfs_cached_lookup (int inum, struct node **npp)
spin_unlock (&diskfs_node_refcnt_lock);
err = read_disknode (np);
-
+
if (!diskfs_check_readonly () && !np->dn_stat.st_gen)
{
spin_lock (&gennumberlock);
@@ -98,7 +98,7 @@ diskfs_cached_lookup (int inum, struct node **npp)
spin_unlock (&gennumberlock);
np->dn_set_ctime = 1;
}
-
+
if (err)
return err;
else
@@ -114,13 +114,13 @@ struct node *
ifind (ino_t inum)
{
struct node *np;
-
+
spin_lock (&diskfs_node_refcnt_lock);
for (np = nodehash[INOHASH(inum)]; np; np = np->dn->hnext)
{
if (np->dn->number != inum)
continue;
-
+
assert (np->references);
spin_unlock (&diskfs_node_refcnt_lock);
return np;
@@ -130,7 +130,7 @@ ifind (ino_t inum)
/* The last reference to a node has gone away; drop
it from the hash table and clean all state in the dn structure. */
-void
+void
diskfs_node_norefs (struct node *np)
{
*np->dn->hprevp = np->dn->hnext;
@@ -158,7 +158,7 @@ diskfs_lost_hardrefs (struct node *np)
#ifdef notanymore
struct port_info *pi;
struct pager *p;
-
+
/* Check and see if there is a pager which has only
one reference (ours). If so, then drop that reference,
breaking the cycle. The complexity in this routine
@@ -170,17 +170,17 @@ diskfs_lost_hardrefs (struct node *np)
pi = (struct port_info *) np->dn->fileinfo->p;
if (pi->refcnt == 1)
{
-
+
/* The only way to get a new reference to the pager
in this state is to call diskfs_get_filemap; this
can't happen as long as we hold NP locked. So
we can safely unlock _libports_portrefcntlock for
the following call. */
spin_unlock (&_libports_portrefcntlock);
-
+
/* Right now the node is locked with no hard refs;
this is an anomolous situation. Before messing with
- the reference count on the file pager, we have to
+ the reference count on the file pager, we have to
give ourselves a reference back so that we are really
allowed to hold the lock. Then we can do the
unreference. */
@@ -216,7 +216,7 @@ read_disknode (struct node *np)
struct stat *st = &np->dn_stat;
struct dinode *di = dino (np->dn->number);
error_t err;
-
+
err = diskfs_catch_exception ();
if (err)
return err;
@@ -232,7 +232,7 @@ read_disknode (struct node *np)
st->st_ino = np->dn->number;
st->st_gen = read_disk_entry (di->di_gen);
st->st_rdev = read_disk_entry(di->di_rdev);
- st->st_mode = (((read_disk_entry (di->di_model)
+ st->st_mode = (((read_disk_entry (di->di_model)
| (read_disk_entry (di->di_modeh) << 16))
& ~S_ITRANS)
| (di->di_trans ? S_IPTRANS : 0));
@@ -249,11 +249,11 @@ read_disknode (struct node *np)
st->st_mtime_usec = read_disk_entry (di->di_mtime.tv_nsec) / 1000;
st->st_ctime = read_disk_entry (di->di_ctime.tv_sec);
st->st_ctime_usec = read_disk_entry (di->di_ctime.tv_nsec) / 1000;
-#endif
+#endif
st->st_blksize = sblock->fs_bsize;
st->st_blocks = read_disk_entry (di->di_blocks);
st->st_flags = read_disk_entry (di->di_flags);
-
+
if (sblock->fs_inodefmt < FS_44INODEFMT)
{
st->st_uid = read_disk_entry (di->di_ouid);
@@ -274,8 +274,8 @@ read_disknode (struct node *np)
if (!S_ISBLK (st->st_mode) && !S_ISCHR (st->st_mode))
st->st_rdev = 0;
- if (S_ISLNK (st->st_mode)
- && direct_symlink_extension
+ if (S_ISLNK (st->st_mode)
+ && direct_symlink_extension
&& st->st_size < sblock->fs_maxsymlinklen)
np->allocsize = 0;
else
@@ -319,7 +319,7 @@ write_node (struct node *np)
struct stat *st = &np->dn_stat;
struct dinode *di = dino (np->dn->number);
error_t err;
-
+
assert (!np->dn_set_ctime && !np->dn_set_atime && !np->dn_set_mtime);
if (np->dn_stat_dirty)
{
@@ -328,9 +328,9 @@ write_node (struct node *np)
err = diskfs_catch_exception ();
if (err)
return;
-
+
write_disk_entry (di->di_gen, st->st_gen);
-
+
if (S_ISBLK (st->st_mode) || S_ISCHR (st->st_mode))
write_disk_entry (di->di_rdev, st->st_rdev);
@@ -343,7 +343,7 @@ write_node (struct node *np)
write_disk_entry (di->di_model, mode & 0xffff);
write_disk_entry (di->di_modeh, (mode >> 16) & 0xffff);
}
- else
+ else
{
write_disk_entry (di->di_model, st->st_mode & 0xffff & ~S_ITRANS);
di->di_modeh = 0;
@@ -354,7 +354,7 @@ write_node (struct node *np)
write_disk_entry (di->di_uid, st->st_uid);
write_disk_entry (di->di_gid, st->st_gid);
}
-
+
if (sblock->fs_inodefmt < FS_44INODEFMT)
{
write_disk_entry (di->di_ouid, st->st_uid & 0xffff);
@@ -376,38 +376,38 @@ write_node (struct node *np)
write_disk_entry (di->di_mtime.tv_nsec, st->st_mtime_usec * 1000);
write_disk_entry (di->di_ctime.tv_sec, st->st_ctime);
write_disk_entry (di->di_ctime.tv_nsec, st->st_ctime_usec * 1000);
-#endif
+#endif
write_disk_entry (di->di_blocks, st->st_blocks);
write_disk_entry (di->di_flags, st->st_flags);
-
+
diskfs_end_catch_exception ();
np->dn_stat_dirty = 0;
record_poke (di, sizeof (struct dinode));
}
-}
+}
/* See if we should create a symlink by writing it directly into
the block pointer array. Returning EINVAL tells diskfs to do it
the usual way. */
static error_t
-create_symlink_hook (struct node *np, char *target)
+create_symlink_hook (struct node *np, const char *target)
{
int len = strlen (target);
error_t err;
struct dinode *di;
-
+
if (!direct_symlink_extension)
return EINVAL;
-
+
assert (compat_mode != COMPAT_BSD42);
if (len >= sblock->fs_maxsymlinklen)
return EINVAL;
-
+
err = diskfs_catch_exception ();
if (err)
return err;
-
+
di = dino (np->dn->number);
bcopy (target, di->di_shortlink, len);
np->dn_stat.st_size = len;
@@ -418,25 +418,25 @@ create_symlink_hook (struct node *np, char *target)
diskfs_end_catch_exception ();
return 0;
}
-error_t (*diskfs_create_symlink_hook)(struct node *, char *)
+error_t (*diskfs_create_symlink_hook)(struct node *, const char *)
= create_symlink_hook;
/* Check if this symlink is stored directly in the block pointer array.
Returning EINVAL tells diskfs to do it the usual way. */
-static error_t
+static error_t
read_symlink_hook (struct node *np,
char *buf)
{
error_t err;
-
- if (!direct_symlink_extension
+
+ if (!direct_symlink_extension
|| np->dn_stat.st_size >= sblock->fs_maxsymlinklen)
return EINVAL;
err = diskfs_catch_exception ();
if (err)
return err;
-
+
bcopy ((dino (np->dn->number))->di_shortlink, buf, np->dn_stat.st_size);
if (! diskfs_check_readonly ())
@@ -456,7 +456,7 @@ diskfs_node_iterate (error_t (*fun)(struct node *))
struct item *i;
error_t err;
int n;
-
+
/* Acquire a reference on all the nodes in the hash table
and enter them into a list on the stack. */
spin_lock (&diskfs_node_refcnt_lock);
@@ -496,10 +496,10 @@ write_all_disknodes ()
write_node (np);
return 0;
}
-
+
diskfs_node_iterate (helper);
}
-
+
void
diskfs_write_disknode (struct node *np, int wait)
{
@@ -530,7 +530,7 @@ diskfs_set_statfs (struct statfs *st)
/* Implement the diskfs_set_translator callback from the diskfs
library; see <hurd/diskfs.h> for the interface description. */
error_t
-diskfs_set_translator (struct node *np, char *name, u_int namelen,
+diskfs_set_translator (struct node *np, const char *name, u_int namelen,
struct protid *cred)
{
daddr_t blkno;
@@ -547,10 +547,10 @@ diskfs_set_translator (struct node *np, char *name, u_int namelen,
err = diskfs_catch_exception ();
if (err)
return err;
-
+
di = dino (np->dn->number);
blkno = read_disk_entry (di->di_trans);
-
+
if (namelen && !blkno)
{
/* Allocate block for translator */
@@ -574,7 +574,7 @@ diskfs_set_translator (struct node *np, char *name, u_int namelen,
np->dn_stat.st_mode &= ~S_IPTRANS;
np->dn_set_ctime = 1;
}
-
+
if (namelen)
{
bcopy (&namelen, buf, sizeof (u_int));
@@ -586,7 +586,7 @@ diskfs_set_translator (struct node *np, char *name, u_int namelen,
np->dn_stat.st_mode |= S_IPTRANS;
np->dn_set_ctime = 1;
}
-
+
diskfs_end_catch_exception ();
return err;
}
@@ -608,7 +608,7 @@ diskfs_get_translator (struct node *np, char **namep, u_int *namelen)
blkno = read_disk_entry ((dino (np->dn->number))->di_trans);
assert (blkno);
transloc = disk_image + fsaddr (sblock, blkno);
-
+
datalen = *(u_int *)transloc;
*namep = malloc (datalen);
bcopy (transloc + sizeof (u_int), *namep, datalen);
@@ -649,13 +649,13 @@ diskfs_S_file_get_storage_info (struct protid *cred,
struct store *file_store;
struct store_run runs[NDADDR];
size_t num_runs = 0;
-
+
if (! cred)
return EOPNOTSUPP;
np = cred->po->np;
mutex_lock (&np->lock);
-
+
/* See if this file fits in the direct block pointers. If not, punt
for now. (Reading indir blocks is a pain, and I'm postponing
pain.) XXX */
@@ -679,7 +679,7 @@ diskfs_S_file_get_storage_info (struct protid *cred,
for (i = 0; i < NDADDR; i++)
{
off_t start = fsbtodb (sblock, read_disk_entry (di->di_db[i]));
- off_t length =
+ off_t length =
(((i + 1) * sblock->fs_bsize > np->allocsize)
? np->allocsize - i * sblock->fs_bsize
: sblock->fs_bsize);
@@ -694,7 +694,7 @@ diskfs_S_file_get_storage_info (struct protid *cred,
diskfs_end_catch_exception ();
mutex_unlock (&np->lock);
-
+
if (! err)
err = store_clone (store, &file_store);
if (! err)