[Libsysio-commit] RedStorm: libsysio/drivers/native fs_native.c
Brought to you by:
lward
|
From: Lee W. <lw...@us...> - 2003-09-26 21:28:49
|
Update of /cvsroot/libsysio/libsysio/drivers/native
In directory sc8-pr-cvs1:/tmp/cvs-serv12723/drivers/native
Modified Files:
Tag: RedStorm
fs_native.c
Log Message:
Merged with current head.
Index: fs_native.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v
retrieving revision 1.11.4.6
retrieving revision 1.11.4.7
diff -u -w -b -B -p -r1.11.4.6 -r1.11.4.7
--- fs_native.c 4 Aug 2003 15:37:05 -0000 1.11.4.6
+++ fs_native.c 26 Sep 2003 21:28:34 -0000 1.11.4.7
@@ -120,9 +120,19 @@ do {
(dest)->st_gen = (src)->st_gen; \
} while (0);
+/* SYS_lseek has a different interface on alpha
+ */
+#define CALL_LSEEK(fd, off, rc, wh) \
+ (rc = syscall(SYS_lseek, fd, off, wh))
+
#else
+
#define __native_stat intnl_stat
#define COPY_STAT(src, dest) *(dest) = *(src)
+
+#define CALL_LSEEK(fd, off, rc, wh) \
+ (syscall(SYS_lseek, fd, off, &rc, wh))
+
#endif
#if defined(USE_NATIVE_STAT)
@@ -137,6 +147,12 @@ do {
#define __SYS_FTRUNCATE SYS_ftruncate64
#endif
+#if defined(USE_NATIVE_FDATASYNC)
+#define __SYS_FDATASYNC SYS_osf_fdatasync
+#else
+#define __SYS_FDATASYNC SYS_fdatasync
+#endif
+
#if defined(USE_NATIVE_UTIME)
#define __SYS_UTIME SYS_utimes
#else
@@ -295,10 +311,12 @@ static int
native_fstat(int fd, struct intnl_stat *buf)
{
int err;
+ struct __native_stat stbuf;
- err = syscall(__SYS_FSTAT, fd, buf);
+ err = syscall(__SYS_FSTAT, fd, &stbuf);
if (err)
err = -errno;
+ COPY_STAT(&stbuf, buf);
return err;
}
@@ -506,24 +524,24 @@ native_fsswop_mount(const char *source,
}
static int
-native_i_validate(struct inode *inop, struct intnl_stat stbuf)
+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 &&
+ 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 &&
+ nino->ni_ident.gen != stbuf.st_gen ||
#endif
- ((inop)->i_mode & stbuf.st_mode) == (inop)->i_mode) &&
- ((!(S_ISCHR((inop)->i_mode) || S_ISBLK((inop)->i_mode)) ||
- (inop)->i_rdev == stbuf.st_rdev)))
- return 0;
-
+ ((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;
}
/*
@@ -555,7 +573,7 @@ native_iget(struct filesys *fs,
* Validate?
*/
if (*inop) {
- if (!native_i_validate(*inop, stbuf))
+ if (!native_i_invalid(*inop, stbuf))
return 0;
/*
* Invalidate.
@@ -579,7 +597,7 @@ native_iget(struct filesys *fs,
/*
* Insertion was forced but it's already present!
*/
- if (native_i_validate(ino, stbuf)) {
+ if (native_i_invalid(ino, stbuf)) {
/*
* Cached inode has stale attrs
* make way for the new one
@@ -1055,7 +1073,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)
@@ -1073,7 +1091,7 @@ 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.
*/
- if (!syscall(SYS_unlink, path))
+ if (syscall(SYS_unlink, path) != 0)
err = -errno;
free(path);
return err;
@@ -1100,6 +1118,9 @@ doio(ssize_t (*f)(int, const struct iove
#endif
assert(nino->ni_fd >= 0);
+
+ if (ioargs->ioarg_iovlen && (int )ioargs->ioarg_iovlen < 0)
+ return -EINVAL;
/*
* Get a new IO context.
|