[Libsysio-commit] HEAD: libsysio/drivers/native fs_native.c
Brought to you by:
lward
|
From: Lee W. <lw...@us...> - 2003-09-27 20:19:13
|
Update of /cvsroot/libsysio/libsysio/drivers/native
In directory sc8-pr-cvs1:/tmp/cvs-serv6348/drivers/native
Modified Files:
fs_native.c
Log Message:
- Better checking during chdir().
- Added _sysio_p_chdir() to call change working directory with a pnode.
- test_path.c doesn't follow symlinks anymore.
- sysio_stubs.c defined a bunch of disk ioctl's inappropriately. Removed.
- Added fchmod(), fchown(), rename(), link(), utime().
Index: fs_native.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -w -b -B -p -r1.16 -r1.17
--- fs_native.c 14 Aug 2003 18:39:33 -0000 1.16
+++ fs_native.c 27 Sep 2003 19:42:02 -0000 1.17
@@ -132,12 +132,12 @@ do {
#endif
#if defined(USE_NATIVE_STAT)
-#define __SYS_STAT SYS_stat
+#define __SYS_STAT SYS_lstat
#define __SYS_FSTAT SYS_fstat
#define __SYS_TRUNCATE SYS_truncate
#define __SYS_FTRUNCATE SYS_ftruncate
#else
-#define __SYS_STAT SYS_stat64
+#define __SYS_STAT SYS_lstat64
#define __SYS_FSTAT SYS_fstat64
#define __SYS_TRUNCATE SYS_truncate64
#define __SYS_FTRUNCATE SYS_ftruncate64
@@ -202,7 +202,9 @@ static int native_inop_symlink(struct pn
static int native_inop_readlink(struct pnode *pno, char *buf, size_t bufsiz);
static int native_inop_open(struct pnode *pno, int flags, mode_t mode);
static int native_inop_close(struct inode *ino);
+static int native_inop_link(struct pnode *old, struct pnode *new);
static int native_inop_unlink(struct pnode *pno);
+static int native_inop_rename(struct pnode *old, struct pnode *new);
static int native_inop_ipreadv(struct inode *ino,
struct io_arguments *ioargs,
struct ioctx **ioctxp);
@@ -233,7 +235,9 @@ static struct inode_ops native_i_ops = {
native_inop_readlink,
native_inop_open,
native_inop_close,
+ native_inop_link,
native_inop_unlink,
+ native_inop_rename,
native_inop_ipreadv,
native_inop_ipwritev,
native_inop_iodone,
@@ -1014,6 +1018,32 @@ native_inop_close(struct inode *ino)
}
static int
+native_inop_link(struct pnode *old, struct pnode *new)
+{
+ int err;
+ char *opath, *npath;
+
+ err = 0;
+
+ opath = _sysio_pb_path(old->p_base, '/');
+ npath = _sysio_pb_path(new->p_base, '/');
+ if (!(opath && npath)) {
+ err = -ENOMEM;
+ goto out;
+ }
+
+ err = syscall(SYS_link, opath, npath);
+
+out:
+ if (opath)
+ free(opath);
+ if (npath)
+ free(npath);
+
+ return err;
+}
+
+static int
native_inop_unlink(struct pnode *pno)
{
char *path;
@@ -1118,6 +1148,30 @@ _readv(int fd, const struct iovec *vecto
{
return syscall(SYS_readv, fd, vector, count);
+}
+
+static int
+native_inop_rename(struct pnode *old, struct pnode *new)
+{
+ int err;
+ char *opath, *npath;
+
+ opath = _sysio_pb_path(old->p_base, '/');
+ npath = _sysio_pb_path(new->p_base, '/');
+ if (!(opath && npath)) {
+ err = -ENOMEM;
+ goto out;
+ }
+
+ err = syscall(SYS_rename, opath, npath);
+
+out:
+ if (opath)
+ free(opath);
+ if (npath)
+ free(npath);
+
+ return err;
}
static int
|