Update of /cvsroot/libsysio/libsysio/drivers/native
In directory sc8-pr-cvs1:/tmp/cvs-serv16559/libsysio/drivers/native
Modified Files:
Tag: libsysio_tests
fs_native.c
Log Message:
Trying to get these missing files in again...it turns out I am not very good at CVS commands..
Index: fs_native.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v
retrieving revision 1.11
retrieving revision 1.11.6.1
diff -u -w -b -B -p -r1.11 -r1.11.6.1
--- fs_native.c 23 Apr 2003 18:18:38 -0000 1.11
+++ fs_native.c 14 Aug 2003 18:42:22 -0000 1.11.6.1
@@ -151,6 +151,9 @@ do {
struct native_inode_identifier {
dev_t dev; /* device number */
ino_t ino; /* i-number */
+#ifdef HAVE_GENERATION
+ unsigned int gen; /* generation number */
+#endif
};
/*
@@ -310,8 +313,12 @@ native_i_new(struct filesys *fs, struct
nino = malloc(sizeof(struct native_inode));
if (!nino)
return NULL;
+ bzero(&nino->ni_ident, sizeof(nino->ni_ident));
nino->ni_ident.dev = buf->st_dev;
nino->ni_ident.ino = buf->st_ino;
+#ifdef HAVE_GENERATION
+ nino->ni_ident.gen = buf->st_gen;
+#endif
nino->ni_fileid.fid_data = &nino->ni_ident;
nino->ni_fileid.fid_len = sizeof(nino->ni_ident);
nino->ni_fd = -1;
@@ -496,6 +503,27 @@ native_fsswop_mount(const char *source,
return err;
}
+static int
+native_i_invalid(struct inode *inop, struct intnl_stat stbuf)
+{
+ /*
+ * Validate passed in inode against stat struct info
+ */
+ struct native_inode *nino = I2NI(inop);
+
+ if ((nino->ni_ident.dev != stbuf.st_dev ||
+ nino->ni_ident.ino != stbuf.st_ino ||
+#ifdef HAVE_GENERATION
+ nino->ni_ident.gen != stbuf.st_gen ||
+#endif
+ ((inop)->i_mode & S_IFMT) != (stbuf.st_mode & S_IFMT)) ||
+ (((inop)->i_rdev != stbuf.st_rdev) &&
+ (S_ISCHR((inop)->i_mode) || S_ISBLK((inop)->i_mode))))
+ return 1;
+
+ return 0;
+}
+
/*
* Find, and validate, or create i-node by host-relative path. Returned i-node
* is referenced.
@@ -525,11 +553,7 @@ native_iget(struct filesys *fs,
* Validate?
*/
if (*inop) {
- struct native_inode *nino = I2NI(*inop);
-
- if (nino->ni_ident.dev == stbuf.st_dev &&
- nino->ni_ident.ino == stbuf.st_ino &&
- ((*inop)->i_mode & stbuf.st_mode) == (*inop)->i_mode)
+ if (!native_i_invalid(*inop, stbuf))
return 0;
/*
* Invalidate.
@@ -540,23 +564,40 @@ native_iget(struct filesys *fs,
/*
* I-node is not already known. Find or create it.
*/
+ bzero(&ident, sizeof(ident));
ident.dev = stbuf.st_dev;
ident.ino = stbuf.st_ino;
+#ifdef HAVE_GENERATION
+ ident.gen = stbuf.st_gen;
+#endif
fileid.fid_data = &ident;
fileid.fid_len = sizeof(ident);
ino = _sysio_i_find(fs, stbuf.st_ino, &fileid);
- if (!ino) {
- ino = native_i_new(fs, &stbuf);
- if (!ino)
- err = -ENOMEM;
- } else if (forced) {
+ if (ino && forced) {
/*
* Insertion was forced but it's already present!
*/
+ if (native_i_invalid(ino, stbuf)) {
+ /*
+ * Cached inode has stale attrs
+ * make way for the new one
+ */
I_RELE(ino);
- err = -EEXIST;
+ _sysio_i_undead(ino);
+ ino = NULL;
+ } else
+ /*
+ * OK to reuse cached inode
+ */
+ goto out;
}
+ if (!ino) {
+ ino = native_i_new(fs, &stbuf);
+ if (!ino)
+ err = -ENOMEM;
+ }
+out:
if (!err)
*inop = ino;
return err;
@@ -965,7 +1006,7 @@ static int
native_inop_unlink(struct pnode *pno)
{
char *path;
- int err;
+ int err = 0;
path = _sysio_pb_path(pno->p_base, '/');
if (!path)
@@ -983,7 +1024,8 @@ native_inop_unlink(struct pnode *pno)
* (usually .NFSXXXXXX, where the X's are replaced by the PID and some
* unique characters) in order to simulate the proper semantic.
*/
- err = syscall(SYS_unlink, path);
+ if (syscall(SYS_unlink, path) != 0)
+ err = -errno;
free(path);
return err;
}
|