[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
patch: diskfs_make_node returns an error_t
From: |
James A Morrison |
Subject: |
patch: diskfs_make_node returns an error_t |
Date: |
Tue, 2 Apr 2002 13:10:54 -0500 (EST) |
I changed the signature of diskfs_make_node to return an error_t like
diskfs_make_peropen or diskfs_make_protid.
I'm holding back on the libnetfs stuff until I know how make_protid should
act wrt it iouser struct.
2002-04-02 James A. Morrison <ja2morri@uwaterloo.ca>
ext2fs:
* inode.c (diskfs_cached_lookup): Check return value of
diskfs_make_node using its new semantics.
isofs:
* inode.c (diskfs_cached_lookup): Check return value of
diskfs_make_node using its new semantics.
(load_inode): Likewise.
libdiskfs:
* diskfs.h (diskfs_make_node): Now returns error_t and takes a pointer
to a node as a new argument.
* node-make.c (diskfs_make_node): Likewise.
tmpfs:
* node.c (diskfs_cached_lookup): Check return value of
diskfs_make_node using its new semantics.
ufs:
* inode.c (diskfs_cached_lookup): Check return value of
diskfs_make_node using its new semantics. Check the return
value of malloc for DN.
Index: ext2fs/inode.c
===================================================================
RCS file: /cvsroot/hurd/hurd/ext2fs/inode.c,v
retrieving revision 1.60
diff -u -p -r1.60 inode.c
--- ext2fs/inode.c 4 Jan 2002 01:39:33 -0000 1.60
+++ ext2fs/inode.c 2 Apr 2002 14:44:42 -0000
@@ -94,7 +94,13 @@ diskfs_cached_lookup (int inum, struct n
pokel_init (&dn->indir_pokel, diskfs_disk_pager, disk_image);
/* Create the new node. */
- np = diskfs_make_node (dn);
+ err = diskfs_make_node (dn, &np);
+ if (err)
+ {
+ spin_unlock (&diskfs_node_refcnt_lock);
+ return err;
+ }
+
np->cache_id = inum;
mutex_lock (&np->lock);
Index: isofs/inode.c
===================================================================
RCS file: /cvsroot/hurd/hurd/isofs/inode.c,v
retrieving revision 1.14
diff -u -p -r1.14 inode.c
--- isofs/inode.c 20 Feb 2001 19:37:28 -0000 1.14
+++ isofs/inode.c 2 Apr 2002 14:44:44 -0000
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 2002 Free Software Foundation, Inc.
Written by Thomas Bushnell, n/BSG.
This file is part of the GNU Hurd.
@@ -198,13 +198,13 @@ diskfs_cached_lookup (int id, struct nod
dn->fileinfo = 0;
dn->dr = c->dr;
dn->file_start = c->file_start;
- np = diskfs_make_node (dn);
- if (!np)
+ err = diskfs_make_node (dn, &np);
+ if (err)
{
free (dn);
spin_unlock (&diskfs_node_refcnt_lock);
release_rrip (&rr);
- return ENOMEM;
+ return err;
}
np->cache_id = id + 1; /* see above for rationale for increment */
mutex_lock (&np->lock);
@@ -357,12 +357,12 @@ load_inode (struct node **npp, struct di
dn->dr = record;
dn->file_start = file_start;
- np = diskfs_make_node (dn);
- if (!np)
+ err = diskfs_make_node (dn, &np);
+ if (err)
{
free (dn);
spin_unlock (&diskfs_node_refcnt_lock);
- return ENOMEM;
+ return err;
}
mutex_lock (&np->lock);
Index: libdiskfs/diskfs.h
===================================================================
RCS file: /cvsroot/hurd/hurd/libdiskfs/diskfs.h,v
retrieving revision 1.94
diff -u -p -r1.94 diskfs.h
--- libdiskfs/diskfs.h 26 Mar 2002 14:59:52 -0000 1.94
+++ libdiskfs/diskfs.h 2 Apr 2002 14:44:45 -0000
@@ -652,9 +652,9 @@ void
diskfs_notice_filechange (struct node *np, enum file_changed_type type,
off_t start, off_t end);
-/* Create a new node structure with DS as its physical disknode.
+/* Create a new node structure with DN as its physical disknode.
The new node will have one hard reference and no light references. */
-struct node *diskfs_make_node (struct disknode *dn);
+error_t diskfs_make_node (struct disknode *dn, struct node **nnp);
/* The library also exports the following functions; they are not generally
Index: libdiskfs/node-make.c
===================================================================
RCS file: /cvsroot/hurd/hurd/libdiskfs/node-make.c,v
retrieving revision 1.15
diff -u -p -r1.15 node-make.c
--- libdiskfs/node-make.c 10 Aug 1998 17:42:39 -0000 1.15
+++ libdiskfs/node-make.c 2 Apr 2002 14:44:46 -0000
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1994, 1995, 1996 Free Software Foundation
+ Copyright (C) 1994, 1995, 1996, 2002 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
@@ -21,11 +21,14 @@
/* Create a and return new node structure with DN as its physical disknode.
The node will have one hard reference and no light references. */
-struct node *
-diskfs_make_node (struct disknode *dn)
+error_t
+diskfs_make_node (struct disknode *dn, struct node **nnp)
{
- struct node *np = malloc (sizeof (struct node));
-
+ struct node *np = *nnp = malloc (sizeof (struct node));
+
+ if (! np)
+ return ENOMEM;
+
np->dn = dn;
np->dn_set_ctime = 0;
np->dn_set_atime = 0;
@@ -45,6 +48,5 @@ diskfs_make_node (struct disknode *dn)
iohelp_initialize_conch (&np->conch, &np->lock);
fshelp_lock_init (&np->userlock);
-
- return np;
+ return 0;
}
Index: tmpfs/node.c
===================================================================
RCS file: /cvsroot/hurd/hurd/tmpfs/node.c,v
retrieving revision 1.10
diff -u -p -r1.10 node.c
--- tmpfs/node.c 24 Mar 2002 01:14:54 -0000 1.10
+++ tmpfs/node.c 2 Apr 2002 14:44:55 -0000
@@ -156,6 +156,7 @@ recompute_blocks (struct node *np)
error_t
diskfs_cached_lookup (int inum, struct node **npp)
{
+ error_t err;
struct disknode *dn = (void *) inum;
struct node *np;
@@ -174,7 +175,9 @@ diskfs_cached_lookup (int inum, struct n
{
struct stat *st;
- np = diskfs_make_node (dn);
+ err = diskfs_make_node (dn, &np);
+ if (err)
+ return err;
np->cache_id = (ino_t) dn;
spin_lock (&diskfs_node_refcnt_lock);
Index: ufs/inode.c
===================================================================
RCS file: /cvsroot/hurd/hurd/ufs/inode.c,v
retrieving revision 1.58
diff -u -p -r1.58 inode.c
--- ufs/inode.c 21 Nov 2001 22:08:48 -0000 1.58
+++ ufs/inode.c 2 Apr 2002 14:44:56 -0000
@@ -1,5 +1,5 @@
/* Inode management routines
- Copyright (C) 1994,95,96,97,98,2000,01 Free Software Foundation, Inc.
+ Copyright (C) 1994,95,96,97,98,2000,01,02 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -67,7 +67,11 @@ diskfs_cached_lookup (int inum, struct n
}
dn = malloc (sizeof (struct disknode));
-
+ if (! dn)
+ {
+ spin_unlock (&diskfs_node_refcnt_lock);
+ return ENOMEM;
+ }
dn->number = inum;
dn->dirents = 0;
dn->dir_idx = 0;
@@ -76,7 +80,12 @@ diskfs_cached_lookup (int inum, struct n
dn->dirty = 0;
dn->fileinfo = 0;
- np = diskfs_make_node (dn);
+ err = diskfs_make_node (dn, &np);
+ if (err)
+ {
+ spin_unlock (&diskfs_node_refcnt_lock);
+ return err;
+ }
np->cache_id = inum;
mutex_lock (&np->lock);
- patch: diskfs_make_node returns an error_t,
James A Morrison <=