summaryrefslogtreecommitdiff
path: root/tmpfs
diff options
context:
space:
mode:
Diffstat (limited to 'tmpfs')
-rw-r--r--tmpfs/ChangeLog26
-rw-r--r--tmpfs/dir.c8
-rw-r--r--tmpfs/node.c30
-rw-r--r--tmpfs/tmpfs.c12
-rw-r--r--tmpfs/tmpfs.h5
5 files changed, 57 insertions, 24 deletions
diff --git a/tmpfs/ChangeLog b/tmpfs/ChangeLog
index 67a047ba..16d3ba0c 100644
--- a/tmpfs/ChangeLog
+++ b/tmpfs/ChangeLog
@@ -1,3 +1,29 @@
+2000-12-30 Marcus Brinkmann <marcus@gnu.org>
+
+ * dir.c: Include <stddef.h>, <unistd.h>, <sys/mman.h>
+ (diskfs_get_directs): Cast *data to struct dirent *.
+
+ * node.c: Include <stddef.h>.
+ (diskfs_alloc_node): Remove unused variables err, st, np.
+ (diskfs_free_node): Use *np->dn, not *dn to calculate used space.
+ (recompute_blocks): Replace DT_DEV with DT_BLK.
+ (diskfs_node_norefs): Likewise.
+ (recompute_blocks): Take address of np->dn_stat for pointer st.
+ (diskfs_cached_lookup): New variable st.
+ (diskfs_cached_lookup): Set st to &np->dn_stat, not &dn->dn_stat.
+ (create_symlink_hook): Fix malloc call and return code check.
+ (read_symlink_hook): Return 0.
+
+ * tmpfs.c: Include <argp.h>, <string.h>, <inttypes.h>, <argz.h>,
+ <error.h>.
+ (parse_opt): Reverse second and third argument of strtoimax call.
+
+ * tmpfs.h (struct disknode): Remove blind passenger (unnamed copy
+ of anonymous struct {} reg).
+
+ Some of the above were also reported by Alexey Dejneka
+ <adejneka@comail.ru>.
+
2000-12-28 Roland McGrath <roland@frob.com>
* node.c (recompute_blocks): New function, broken out of ...
diff --git a/tmpfs/dir.c b/tmpfs/dir.c
index 595e5437..92fa8e32 100644
--- a/tmpfs/dir.c
+++ b/tmpfs/dir.c
@@ -17,6 +17,10 @@ You should have received a copy of the GNU General Public License
along with the GNU Hurd; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+#include <stddef.h>
+#include <unistd.h>
+#include <sys/mman.h>
+
#include "tmpfs.h"
#include <stdlib.h>
@@ -66,7 +70,7 @@ diskfs_get_directs (struct node *dp, int entry, int n,
return ENOMEM;
}
- entp = *data;
+ entp = (struct dirent *) *data;
entp->d_fileno = dp->dn_stat.st_ino;
entp->d_type = DT_DIR;
entp->d_namlen = 1;
@@ -146,7 +150,7 @@ diskfs_lookup_hard (struct node *dp,
}
if (namelen == 2 && name[0] == '.' && name[1] == '.')
{
- struct disknode *ddnp = dp->dn->dir.dotdot;
+ struct disknode *ddnp = dp->dn->u.dir.dotdot;
assert (np != 0);
if (ddnp == 0) /* root directory */
return EAGAIN;
diff --git a/tmpfs/node.c b/tmpfs/node.c
index 65d1305a..ad9b1cdb 100644
--- a/tmpfs/node.c
+++ b/tmpfs/node.c
@@ -17,6 +17,8 @@ You should have received a copy of the GNU General Public License
along with the GNU Hurd; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+#include <stddef.h>
+
#include "tmpfs.h"
#include <stdlib.h>
@@ -29,9 +31,6 @@ error_t
diskfs_alloc_node (struct node *dp, mode_t mode, struct node **npp)
{
struct disknode *dn;
- struct node *np;
- struct stat *st;
- error_t err;
dn = calloc (1, sizeof *dn);
if (dn == 0)
@@ -75,7 +74,7 @@ diskfs_free_node (struct node *np, mode_t mode)
spin_lock (&diskfs_node_refcnt_lock);
--num_files;
- tmpfs_space_used -= sizeof *dn;
+ tmpfs_space_used -= sizeof *np->dn;
spin_unlock (&diskfs_node_refcnt_lock);
}
@@ -106,7 +105,7 @@ diskfs_node_norefs (struct node *np)
np->dn->u.reg.allocpages = np->allocsize / vm_page_size;
break;
case DT_CHR:
- case DT_DEV:
+ case DT_BLK:
np->dn->u.chr = np->dn_stat.st_rdev;
break;
}
@@ -124,7 +123,7 @@ static void
recompute_blocks (struct node *np)
{
struct disknode *const dn = np->dn;
- struct stat *const st = np->dn_stat;
+ struct stat *const st = &np->dn_stat;
st->st_blocks = sizeof *dn + dn->translen;
switch (dn->type)
@@ -137,7 +136,7 @@ recompute_blocks (struct node *np)
st->st_blocks += st->st_size + 1;
break;
case DT_CHR:
- case DT_DEV:
+ case DT_BLK:
st->st_rdev = dn->u.chr;
break;
case DT_DIR:
@@ -164,6 +163,8 @@ diskfs_cached_lookup (int inum, struct node **npp)
}
else
{
+ struct stat *st;
+
/* Create the new node. */
np = diskfs_make_node (dn);
np->cache_id = (ino_t) dn;
@@ -174,7 +175,7 @@ diskfs_cached_lookup (int inum, struct node **npp)
all_nodes = np;
spin_unlock (&diskfs_node_refcnt_lock);
- st = &dn->dn_stat;
+ st = &np->dn_stat;
memset (st, 0, sizeof *st);
st->st_fstype = FSTYPE_MEMFS;
st->st_fsid = getpid ();
@@ -320,8 +321,8 @@ create_symlink_hook (struct node *np, const char *target)
if (np->dn_stat.st_size > 0)
{
const size_t size = np->dn_stat.st_size + 1;
- char *const new = malloc (np->dn->u.lnk, size);
- if (new == 0)
+ np->dn->u.lnk = malloc (size);
+ if (np->dn->u.lnk == 0)
return ENOSPC;
memcpy (np->dn->u.lnk, target, size);
adjust_used (size);
@@ -329,16 +330,17 @@ create_symlink_hook (struct node *np, const char *target)
}
return 0;
}
-error_t (*diskfs_read_symlink_hook)(struct node *np, char *target)
- = read_symlink_hook;
+error_t (*diskfs_create_symlink_hook)(struct node *np, const char *target)
+ = create_symlink_hook;
static error_t
read_symlink_hook (struct node *np, char *target)
{
memcpy (target, np->dn->u.lnk, np->dn_stat.st_size + 1);
+ return 0;
}
-error_t (*diskfs_create_symlink_hook)(struct node *np, const char *target)
- = create_symlink_hook;
+error_t (*diskfs_read_symlink_hook)(struct node *np, char *target)
+ = read_symlink_hook;
void
diskfs_write_disknode (struct node *np, int wait)
diff --git a/tmpfs/tmpfs.c b/tmpfs/tmpfs.c
index 1df0e04b..caef3861 100644
--- a/tmpfs/tmpfs.c
+++ b/tmpfs/tmpfs.c
@@ -17,6 +17,12 @@ You should have received a copy of the GNU General Public License
along with the GNU Hurd; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+#include <argp.h>
+#include <argz.h>
+#include <string.h>
+#include <inttypes.h>
+#include <error.h>
+
#include "tmpfs.h"
#include <limits.h>
#include <version.h>
@@ -122,7 +128,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
else
{
char *end = NULL;
- intmax_t size = strtoimax (state->argv[state->next], 0, &end);
+ intmax_t size = strtoimax (state->argv[state->next], &end, 0);
if (end == NULL || end == arg)
{
argp_error (state, "argument must be a number");
@@ -229,8 +235,8 @@ main (int argc, char **argv)
error (0, err, "Cannot get host privileged port");
else
{
- err = vm_set_default_memory_manager (host, &default_pager);
- mach_port_deallocate (mach_task_self (), host);
+ err = vm_set_default_memory_manager (host_priv, &default_pager);
+ mach_port_deallocate (mach_task_self (), host_priv);
if (err)
error (0, err, "Cannot get default pager port");
}
diff --git a/tmpfs/tmpfs.h b/tmpfs/tmpfs.h
index 19f05de5..4fb418a2 100644
--- a/tmpfs/tmpfs.h
+++ b/tmpfs/tmpfs.h
@@ -51,11 +51,6 @@ struct disknode
} reg;
struct
{
- mach_port_t memobj;
- unsigned int allocpages; /* largest size while memobj was live */
- };
- struct
- {
struct tmpfs_dirent *entries;
struct disknode *dotdot;
} dir;