From fc97341f492be10f20e4c8a639614e0230d53471 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Sat, 30 Dec 2000 19:11:29 +0000 Subject: 2000-12-30 Marcus Brinkmann * dir.c: Include , , (diskfs_get_directs): Cast *data to struct dirent *. * node.c: Include . (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 , , , , . (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 . --- tmpfs/node.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'tmpfs/node.c') 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 + #include "tmpfs.h" #include @@ -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) -- cgit v1.2.3