[Libsysio-commit] HEAD: libsysio/drivers/native fs_native.c
Brought to you by:
lward
From: Lee W. <lw...@us...> - 2009-09-21 18:29:48
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17853/drivers/native Modified Files: fs_native.c Log Message: Split native_stat into two functions. One works as before. The other, native_simple_stat just does a stat and returns the result in the passed buffer, updating no existing records. Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.72 retrieving revision 1.73 diff -u -w -b -B -p -r1.72 -r1.73 --- fs_native.c 5 May 2009 16:35:29 -0000 1.72 +++ fs_native.c 21 Sep 2009 18:29:38 -0000 1.73 @@ -262,41 +262,48 @@ static struct mount *native_internal_mou #define I2NI(ino) ((struct native_inode *)((ino)->i_private)) /* - * stat -- by path. + * Simple stat of path or file. */ static int -native_stat(const char *path, - struct inode *ino, - time_t t, - struct intnl_stat *buf) +native_simple_stat(const char *path, struct inode *ino, struct intnl_stat *buf) { - struct native_inode *nino; int err; + struct native_inode *nino; struct _sysio_native_stat stbuf; - nino = ino ? I2NI(ino) : NULL; - if (path) err = syscall(SYSIO_SYS_stat, path, &stbuf); - else if (nino && nino->ni_fd >= 0) + else if ((nino = ino ? I2NI(ino) : NULL) && nino->ni_fd >= 0) err = syscall(SYSIO_SYS_fstat, nino->ni_fd, &stbuf); else abort(); - if (err) { - if (nino) - nino->ni_attrtim = 0; + if (err) return -errno; - } - if (nino) { - nino->ni_attrtim = t; - SYSIO_COPY_STAT(&stbuf, &ino->i_stbuf); - if (buf) - *buf = ino->i_stbuf; + SYSIO_COPY_STAT(&stbuf, buf); return 0; } + +/* + * stat -- by path. + */ +static int +native_stat(const char *path, + struct inode *ino, + time_t t, + struct intnl_stat *buf) +{ + struct intnl_stat mybuf; + int err; + if (!buf) - return 0; - SYSIO_COPY_STAT(&stbuf, buf); + buf = &mybuf; + err = native_simple_stat(path, ino, buf); + if (err) + t = 0; + else if (ino) + ino->i_stbuf = *buf; + if (ino) + I2NI(ino)->ni_attrtim = t; return 0; } @@ -607,33 +614,28 @@ native_ibind(struct filesys *fs, time_t t, struct inode **inop) { - struct intnl_stat ostbuf, stbuf; + struct intnl_stat buf; int err; struct inode *ino; - if (*inop) - ostbuf = (*inop)->i_stbuf; - - err = native_stat(path, *inop, t, &stbuf); + err = native_simple_stat(path, *inop, &buf); if (err) return err; - - /* - * Validate? - */ + t += FS2NFS(fs)->nfs_atimo; if (*inop) { - if (!native_i_invalid(*inop, &ostbuf)) - return 0; /* - * Invalidate. + * Revalidate. */ + if (!native_i_invalid(*inop, &buf)) { + (*inop)->i_stbuf = buf; + I2NI(*inop)->ni_attrtim = t; + return 0; + } _sysio_i_undead(*inop); *inop = NULL; } - - if (!(ino = native_iget(fs, t + FS2NFS(fs)->nfs_atimo, &stbuf))) + if (!(ino = native_iget(fs, t, &buf))) return -ENOMEM; - *inop = ino; return 0; } @@ -876,7 +878,11 @@ out: /* * We must refresh the cached attributes. */ - if (!err && native_stat(path, ino, _SYSIO_LOCAL_TIME(), NULL) != 0) + if (!err && + native_stat(path, + ino, + _SYSIO_LOCAL_TIME() + FS2NFS(ino->i_fs)->nfs_atimo, + NULL) != 0) abort(); if (path) free(path); |