[Libsysio-commit] cplant: libsysio/drivers/yod Makefile.am fs_yod.c fs_yod.h portals_io.c portals_io
Brought to you by:
lward
From: Ruth K. <rk...@us...> - 2003-05-01 15:44:50
|
Update of /cvsroot/libsysio/libsysio/drivers/yod In directory sc8-pr-cvs1:/tmp/cvs-serv19380 Modified Files: Tag: cplant Makefile.am fs_yod.c fs_yod.h Removed Files: Tag: cplant portals_io.c portals_io.h Log Message: make calls to cplant libs existing functions Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/yod/Attic/Makefile.am,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -w -b -B -p -r1.1.2.1 -r1.1.2.2 --- Makefile.am 28 Apr 2003 20:21:39 -0000 1.1.2.1 +++ Makefile.am 1 May 2003 15:44:42 -0000 1.1.2.2 @@ -2,8 +2,7 @@ lib_LIBRARIES = libsysio_yod.a EXTRA_DIST = fs_yod.h -libsysio_yod_a_SOURCES = fs_yod.c portals_io.c +libsysio_yod_a_SOURCES = fs_yod.c include $(top_srcdir)/Rules.make -AM_CPPFLAGS += $(PORTALS_INCLUDE) Index: fs_yod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/yod/Attic/fs_yod.c,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -w -b -B -p -r1.1.2.2 -r1.1.2.3 --- fs_yod.c 29 Apr 2003 17:13:07 -0000 1.1.2.2 +++ fs_yod.c 1 May 2003 15:44:42 -0000 1.1.2.3 @@ -61,6 +61,7 @@ #include <sys/statvfs.h> #include <utime.h> #include <sys/queue.h> +#include <sys/uio.h> #include "sysio.h" #include "fs.h" @@ -68,52 +69,16 @@ #include "inode.h" #include "fs_yod.h" -#include "portals_io.h" /* - * Remote file system driver. Assumes that file ops are - * redirected via portals to another host. - * - * The unique remote server is identified by nid, pid, ptl. - */ -server_t _yod_server; - -/* - * store the actual file handle pointers given by yod - * via remote open. std{in, out, err} are retrieved in - * startup.c and passed into this lib via _sysio_yod_init - */ -off_t _yodfd_handles[FOPEN_MAX]; - -/* - * remote calls require ids + * Remote file system driver + * calls are re-directed to the initiating yod */ -uid_t _yod_uid, _yod_euid; -gid_t _yod_gid, _yod_egid; -#if defined(ALPHA_LINUX) - -/* stat struct from asm/stat.h, as returned - * by alpha linux kernel +/* stat struct used by yod, which + * is not compiled with __USE_FILE_OFFSET64 */ -struct __native_stat { - unsigned int st_dev; - unsigned int st_ino; - unsigned int st_mode; - unsigned int st_nlink; - unsigned int st_uid; - unsigned int st_gid; - unsigned int st_rdev; - long st_size; - unsigned long st_atime; - unsigned long st_mtime; - unsigned long st_ctime; - unsigned int st_blksize; - int st_blocks; - unsigned int st_flags; - unsigned int st_gen; -}; - +#define __yod_stat stat #define COPY_STAT(src, dest) \ do { \ memset((dest), 0, sizeof((*dest))); \ @@ -134,11 +99,6 @@ do { (dest)->st_gen = (src)->st_gen; \ } while (0); -#else -#define __native_stat intnl_stat -#define COPY_STAT(src, dest) *(dest) = *(src) -#endif - /* * Yod file identifiers format. */ @@ -243,8 +203,10 @@ static struct filesys_ops yod_inodesys_o yod_fsop_gone }; -static ino_t yod_inum = 1; -static struct qstr noname = { NULL, 0, 0 }; +/* + * Placeholder internal mount as in native driver + */ +static struct mount *yod_internal_mount = NULL; /* * Given i-node, return driver private part. @@ -259,9 +221,9 @@ static int yod_stat(const char *path, struct intnl_stat *buf) { int err; - struct __native_stat stbuf; + struct __yod_stat stbuf; - err = rpc_stat(path, buf); + err = stat_yod(path, &stbuf); if (err) err = -errno; COPY_STAT(&stbuf, buf); @@ -277,7 +239,7 @@ yod_fstat(int fd, struct intnl_stat *buf { int err; - err = rpc_fstat(fd, buf); + err = fstat_yod(fd, buf); if (err) err = -errno; @@ -327,25 +289,9 @@ yod_i_new(struct filesys *fs, struct int /* * Initialize this driver. */ -server_t _yod_server; int -_sysio_yod_init(int nid, int pid, int ptl, - off_t yod_stdin, - off_t yod_stdout, - off_t yod_stderr) -{ - _yod_server.nid = nid; - _yod_server.pid = pid; - _yod_server.ptl = ptl; - - _yodfd_handles[0] = yod_stdin; - _yodfd_handles[1] = yod_stdout; - _yodfd_handles[2] = yod_stderr; - - _yod_uid = getuid(); - _yod_gid = getgid(); - _yod_euid = geteuid(); - _yod_egid = getegid(); +_sysio_yod_init() +{ /* * Capture current process umask and reset our process umask to @@ -357,69 +303,147 @@ _sysio_yod_init(int nid, int pid, int pt return _sysio_fssw_register("yod", &yod_fssw_ops); } +/* + * Create private, internal, view of the hosts name space. + */ static int -yod_fsswop_mount(const char *source, - unsigned flags, - const void *data, - struct pnode *tocover, - struct mount **mntp) +create_internal_namespace() { int err; - struct filesys *fs = NULL; - struct inode *rooti = NULL; + struct mount *mnt; + struct inode *rootino; + struct pnode_base *rootpb; + static struct qstr noname = { NULL, 0, 0 }; + struct filesys *fs; struct intnl_stat stbuf; - struct pnode_base *rootpb = NULL; - struct mount *mnt = NULL; - + if (yod_internal_mount) { /* - * Create new fs - * private data, the portals target, was imported - * at init time + * Reentered! */ - fs = _sysio_fs_new(&yod_inodesys_ops, flags, &_yod_server); + abort(); + } + + /* + * We maintain an artificial, internal, name space in order to + * have access to fully qualified path names in the various routines. + * Initialize that name space now. + */ + mnt = NULL; + rootino = NULL; + rootpb = NULL; + fs = _sysio_fs_new(&yod_inodesys_ops, 0, NULL); if (!fs) { err = -ENOMEM; goto error; } /* - * Create root inode + * Get root i-node. */ - err = yod_stat(source, &stbuf); - if (err) { - err = -errno; + err = yod_stat("/", &stbuf); + if (err) goto error; - } - rooti = yod_i_new(fs, &stbuf); - if (!rooti) { + rootino = yod_i_new(fs, &stbuf); + if (!rootino) { err = -ENOMEM; goto error; } - rootpb = _sysio_pb_new(&noname, NULL, rooti); + + /* + * Generate base path-node for root. + */ + rootpb = _sysio_pb_new(&noname, NULL, rootino); if (!rootpb) { err = -ENOMEM; goto error; } - FS_REF(fs); - return err; + /* + * Mount it. This name space is disconnected from the + * rest of the system -- Only available within this driver. + */ + err = _sysio_do_mount(fs, rootpb, 0, NULL, &mnt); + if (err) + goto error; + yod_internal_mount = mnt; + return 0; error: + if (mnt) { + if (_sysio_do_unmount(mnt) != 0) + abort(); + fs = NULL; + rootpb = NULL; + rootino = NULL; + } if (rootpb) _sysio_pb_gone(rootpb); - if (rooti->i_private) - free(rooti->i_private); - if (rooti) { - I_RELE(rooti); - free(rooti); - } - if (fs) + if (fs) { FS_RELE(fs); + _sysio_fs_gone(fs); + } return err; } +static int +yod_fsswop_mount(const char *source, + unsigned flags, + const void *data __IS_UNUSED, + struct pnode *tocover, + struct mount **mntp) +{ + int err; + struct nameidata nameidata; + struct mount *mnt; + + /* + * Caller must use fully qualified path names when specifying + * the source. + */ + if (*source != '/') + return -ENOENT; + + if (!yod_internal_mount) { + err = create_internal_namespace(); + if (err) + return err; + } + + /* + * Lookup the source in the internally maintained name space. + */ + ND_INIT(&nameidata, 0, source, yod_internal_mount->mnt_root, NULL); + err = _sysio_path_walk(yod_internal_mount->mnt_root, &nameidata); + if (err) + return err; + + /* + * Have path-node specified by the given source argument. Let the + * system finish the job, now. + */ + err = + _sysio_do_mount(yod_internal_mount->mnt_fs, + nameidata.nd_pno->p_base, + flags, + tocover, + &mnt); + /* + * Release the internal name space pnode and clean up any + * aliases we might have generated. We really don't need to cache them + * as they are only used at mount time.. + */ + P_RELE(nameidata.nd_pno); + (void )_sysio_p_prune(yod_internal_mount->mnt_root); + + if (!err) { + FS_REF(yod_internal_mount->mnt_fs); + *mntp = mnt; + } + return err; +} + /* * Find, and validate, or create i-node by host-relative path. Returned i-node * is referenced. @@ -599,16 +623,13 @@ yod_inop_setattr(struct pnode *pno, * Alter permissions attribute. */ mode = stbuf->st_mode & 0777; - err = - fd < 0 - ? rpc_chmod(path, mode) - : rpc_fchmod(fd, mode); + err = chmod_yod(path, mode); } if (err) mask &= ~SETATTR_MODE; +#if 0 else if (mask & (SETATTR_MTIME|SETATTR_ATIME)) { struct utimbuf ut; - /* * Alter access and/or modify time attributes. */ @@ -618,27 +639,18 @@ yod_inop_setattr(struct pnode *pno, ut.modtime = stbuf->st_mtime; if (mask & SETATTR_ATIME) ut.actime = stbuf->st_atime; - err = rpc_utime(path, &ut); + err = utime_yod(path, &ut); } if (err) mask &= ~(SETATTR_MTIME|SETATTR_ATIME); - else if (mask & (SETATTR_UID|SETATTR_GID)) { + else +#endif + if (mask & (SETATTR_UID|SETATTR_GID)) { /* * Alter owner and/or group identifiers. */ - err = - fd < 0 - ? rpc_chown( - path, - mask & SETATTR_UID - ? stbuf->st_uid - : (uid_t )-1, - mask & SETATTR_GID - ? stbuf->st_gid - : (gid_t )-1) - : rpc_fchown( - fd, + err = chown_yod(path, mask & SETATTR_UID ? stbuf->st_uid : (uid_t )-1, @@ -653,8 +665,8 @@ yod_inop_setattr(struct pnode *pno, * Do the truncate last. It can't be undone. */ (void )(fd < 0 - ? rpc_truncate(path, stbuf->st_size) - : rpc_ftruncate(fd, stbuf->st_size)); + ? truncate_yod(path, stbuf->st_size) + : ftruncate_yod(fd, stbuf->st_size)); } if (!err) goto out; @@ -663,35 +675,25 @@ yod_inop_setattr(struct pnode *pno, * can but try. */ if (mask & (SETATTR_UID|SETATTR_GID)) { - (void )(fd < 0 - ? rpc_chown( - path, - mask & SETATTR_UID - ? st.st_uid - : (uid_t )-1, - mask & SETATTR_GID - ? st.st_gid - : (gid_t )-1) - : rpc_fchown( - fd, + (void )chown_yod(path, mask & SETATTR_UID ? st.st_uid : (uid_t )-1, mask & SETATTR_GID ? st.st_gid - : (gid_t )-1)); + : (gid_t )-1); } +#if 0 if (mask & (SETATTR_MTIME|SETATTR_ATIME)) { struct utimbuf ut; ut.actime = st.st_atime; ut.modtime = st.st_mtime; - (void )rpc_utime(path, &ut); + (void )utime_yod(path, &ut); } +#endif if (mask & SETATTR_MODE) { - fd < 0 - ? rpc_chmod(path, st.st_mode & 0777) - : rpc_fchmod(fd, st.st_mode & 0777); + chmod_yod(path, st.st_mode & 0777); } out: if (path) @@ -713,14 +715,14 @@ yod_getdirentries(struct inode *ino, result = *basep; if (*basep != nino->ni_fpos && - rpc_lseek( + lseek_yod( nino->ni_fd, *basep, &result, SEEK_SET) == -1) return -errno; nino->ni_fpos = result; - cc = rpc_getdents64(nino->ni_fd, buf, nbytes); + cc = getdirentries_yod(nino->ni_fd, buf, nbytes); if (cc < 0) return -errno; nino->ni_fpos += cc; @@ -737,7 +739,7 @@ yod_inop_mkdir(struct pnode *pno, mode_t if (!path) return -ENOMEM; - err = rpc_mkdir(path, mode); + err = mkdir_yod(path, mode); free(path); return err; } @@ -752,7 +754,7 @@ yod_inop_rmdir(struct pnode *pno) if (!path) return -ENOMEM; - err = rpc_rmdir(path); + err = rmdir_yod(path); free(path); return err; } @@ -767,25 +769,18 @@ yod_inop_symlink(struct pnode *pno, cons if (!path) return -ENOMEM; - err = rpc_symlink(path, data); + err = symlink_yod(path, data); free(path); return err; } static int -yod_inop_readlink(struct pnode *pno, char *buf, size_t bufsiz) +yod_inop_readlink(struct pnode *pno __IS_UNUSED, + char *buf __IS_UNUSED, + size_t bufsiz __IS_UNUSED) { - char *path; - int i; - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - i = rpc_readlink(path, buf, bufsiz); - if (i < 0) - i = -errno; - free(path); - return i; + return -ENOSYS; } static int @@ -811,7 +806,7 @@ yod_inop_open(struct pnode *pno, int fla flags &= ~O_WRONLY; flags |= O_RDWR; } - fd = rpc_open(path, flags, mode); + fd = open_yod(path, flags, mode); if (!pno->p_base->pb_ino && fd >= 0) { int err; @@ -824,7 +819,7 @@ yod_inop_open(struct pnode *pno, int fla &pno->p_base->pb_ino, 1); if (err) { - (void )rpc_close(fd); + (void )close_yod(fd); if (err == -EEXIST) abort(); fd = err; @@ -849,10 +844,10 @@ yod_inop_open(struct pnode *pno, int fla /* * Keep existing. */ - (void )rpc_close(fd); + (void )close_yod(fd); return 0; } - (void )rpc_close(nino->ni_fd); + (void )close_yod(nino->ni_fd); } /* * Invariant; First open. Must init. @@ -877,7 +872,7 @@ yod_inop_close(struct inode *ino) if (--nino->ni_nopens) return 0; #endif - err = rpc_close(nino->ni_fd); + err = close_yod(nino->ni_fd); if (err) return -errno; nino->ni_fd = -1; @@ -907,7 +902,7 @@ yod_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 = rpc_unlink(path); + err = unlink_yod(path); free(path); return err; } @@ -957,7 +952,7 @@ doio(ssize_t (*f)(int, const struct iove !(S_ISCHR(ino->i_mode) || S_ISSOCK(ino->i_mode) || S_ISFIFO(ino->i_mode)) && - rpc_lseek( + lseek_yod( nino->ni_fd, ioctx->ioctx_offset, &result, @@ -989,7 +984,7 @@ static ssize_t _readv(int fd, const struct iovec *vector, int count) { - return rpc_read(fd, vector, count); + return read_yod(fd, vector, count); } static int @@ -1007,8 +1002,14 @@ yod_inop_ipreadv(struct inode *ino, static ssize_t _writev(int fd, const struct iovec *vector, int count) { + int i; + ssize_t total; - return rpc_write(fd, vector, count); + for (i = 0; i < count; i++) + total += write_yod(fd, + vector[i].iov_base, + vector[i].iov_len); + return total; } static int @@ -1079,8 +1080,8 @@ yod_inop_statvfs(struct pnode *pno, */ rc = path - ? rpc_statfs(path, &fs) - : rpc_fstatfs(I2NI(ino)->ni_fd, &fs); + ? statfs_yod(path, &fs) + : fstatfs_yod(I2NI(ino)->ni_fd, &fs); if (path) free(path); if (rc < 0) @@ -1106,7 +1107,7 @@ yod_inop_sync(struct inode *ino) assert(I2NI(ino)->ni_fd >= 0); - return rpc_fsync(I2NI(ino)->ni_fd); + return fsync_yod(I2NI(ino)->ni_fd); } static int @@ -1115,7 +1116,7 @@ yod_inop_datasync(struct inode *ino) assert(I2NI(ino)->ni_fd >= 0); - return rpc_fdatasync(I2NI(ino)->ni_fd); + return fsync_yod(I2NI(ino)->ni_fd); } static int Index: fs_yod.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/yod/Attic/fs_yod.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -w -b -B -p -r1.1.2.1 -r1.1.2.2 --- fs_yod.h 28 Apr 2003 20:21:40 -0000 1.1.2.1 +++ fs_yod.h 1 May 2003 15:44:42 -0000 1.1.2.2 @@ -42,8 +42,7 @@ */ /* - * Native file system driver support. + * Remote file system driver support. */ -extern int _sysio_yod_init(int, int, int, - off_t, off_t, off_t); +extern int _sysio_yod_init(); --- portals_io.c DELETED --- --- portals_io.h DELETED --- |