libsysio-commit Mailing List for libsysio (Page 40)
Brought to you by:
lward
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
(25) |
May
(28) |
Jun
(25) |
Jul
(30) |
Aug
(60) |
Sep
(52) |
Oct
(100) |
Nov
(15) |
Dec
(34) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(89) |
Feb
(48) |
Mar
(22) |
Apr
(59) |
May
(16) |
Jun
(15) |
Jul
(50) |
Aug
(26) |
Sep
(40) |
Oct
(27) |
Nov
(12) |
Dec
|
2005 |
Jan
(24) |
Feb
(11) |
Mar
|
Apr
|
May
(3) |
Jun
(6) |
Jul
|
Aug
(14) |
Sep
(21) |
Oct
(10) |
Nov
|
Dec
|
2006 |
Jan
(8) |
Feb
(5) |
Mar
(2) |
Apr
(6) |
May
(11) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(3) |
2007 |
Jan
(3) |
Feb
(5) |
Mar
(20) |
Apr
(41) |
May
(21) |
Jun
(3) |
Jul
(5) |
Aug
(12) |
Sep
(21) |
Oct
(5) |
Nov
(16) |
Dec
|
2008 |
Jan
|
Feb
(2) |
Mar
(4) |
Apr
(23) |
May
|
Jun
(22) |
Jul
(13) |
Aug
|
Sep
|
Oct
(9) |
Nov
(3) |
Dec
(13) |
2009 |
Jan
(14) |
Feb
(10) |
Mar
(2) |
Apr
(11) |
May
(7) |
Jun
(1) |
Jul
(1) |
Aug
(36) |
Sep
(12) |
Oct
|
Nov
|
Dec
(10) |
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: Lee W. <lw...@us...> - 2003-10-15 18:01:01
|
Update of /cvsroot/libsysio/libsysio/drivers/yod In directory sc8-pr-cvs1:/tmp/cvs-serv9577/drivers/yod Modified Files: fs_yod.c Log Message: Eliminated the i-node number field from the inode structure. We already carry the file identifier so it was redundant. Problematic too, in that it can be 32 or 64 bits in size. This forced _sysio_i_new() and _sysio_i_find() to change -- They no longer take the i-node number as an argument. Updated the driver calls to reflect the new usage. The i-node cache is now indexed by hashing the file identifier as opposed to just using the, no longer maintained, i-node number. This caused _sysio_i_find to become 2+ percent more expensive to use. Acceptable for me. Index: fs_yod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/yod/fs_yod.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- fs_yod.c 13 Oct 2003 01:04:34 -0000 1.3 +++ fs_yod.c 15 Oct 2003 18:00:55 -0000 1.4 @@ -297,7 +297,6 @@ yod_i_new(struct filesys *fs, struct int nino->ni_fpos = 0; ino = _sysio_i_new(fs, - buf->st_ino, &nino->ni_fileid, #ifndef AUTOMOUNT_FILE_NAME buf->st_mode & S_IFMT, @@ -539,7 +538,7 @@ yod_iget(struct filesys *fs, #endif fileid.fid_data = &ident; fileid.fid_len = sizeof(ident); - ino = _sysio_i_find(fs, stbuf.st_ino, &fileid); + ino = _sysio_i_find(fs, &fileid); if (ino && forced) { /* * Insertion was forced but it's already present! |
From: Ruth K. <rk...@us...> - 2003-10-15 00:01:03
|
Update of /cvsroot/libsysio/libsysio/drivers/incore In directory sc8-pr-cvs1:/tmp/cvs-serv1022 Modified Files: Tag: cplant fs_incore.c Log Message: Merge HEAD changes into cplant branch Index: fs_incore.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/incore/fs_incore.c,v retrieving revision 1.5.2.1 retrieving revision 1.5.2.2 diff -u -w -b -B -p -r1.5.2.1 -r1.5.2.2 --- fs_incore.c 20 Aug 2003 21:05:49 -0000 1.5.2.1 +++ fs_incore.c 15 Oct 2003 00:00:58 -0000 1.5.2.2 @@ -56,7 +56,9 @@ #include <sys/types.h> #include <dirent.h> #include <sys/stat.h> +#ifdef _HAVE_STATVFS #include <sys/statvfs.h> +#endif #include <sys/queue.h> #include "sysio.h" @@ -132,18 +134,18 @@ static int _sysio_incore_inop_setattr(st static ssize_t _sysio_incore_dirop_getdirentries(struct inode *ino, char *buf, size_t nbytes, - off64_t *basep); + _SYSIO_OFF_T *basep); static int _sysio_incore_dirop_mkdir(struct pnode *pno, mode_t mode); static int _sysio_incore_dirop_rmdir(struct pnode *pno); static int _sysio_incore_inop_open(struct pnode *pno, int flags, mode_t mode); static int _sysio_incore_inop_close(struct inode *ino); +static int _sysio_incore_dirop_link(struct pnode *old, struct pnode *new); static int _sysio_incore_dirop_unlink(struct pnode *pno); +static int _sysio_incore_dirop_rename(struct pnode *old, struct pnode *new); static int _sysio_incore_filop_ipreadv(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp); + struct ioctx *ioctx); static int _sysio_incore_filop_ipwritev(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp); + struct ioctx *ioctx); static int _sysio_incore_filop_iodone(struct ioctx *ioctx); static int _sysio_incore_filop_fcntl(struct inode *ino, int cmd, va_list ap); static int _sysio_incore_inop_sync(struct inode *ino); @@ -151,12 +153,13 @@ static int _sysio_incore_filop_ioctl(str unsigned long int request, va_list ap); static int _sysio_incore_dirop_mknod(struct pnode *pno, mode_t mode, dev_t dev); +#ifdef _HAVE_STATVFS static int _sysio_incore_inop_statvfs(struct pnode *pno, struct inode *ino, struct intnl_statvfs *buf); +#endif static void _sysio_incore_inop_gone(struct inode *ino); static int _sysio_incore_e_isdir(void); -static int _sysio_incore_e_notdir(void); static int _sysio_incore_e_inval(void); static int _sysio_incore_e_nosys(void); static void _sysio_incore_illop(void); @@ -167,12 +170,10 @@ static void _sysio_incore_illop(void); (int (*)(struct pnode *, char *, size_t))_sysio_incore_e_inval #define _sysio_incore_dirop_ipreadv \ (int (*)(struct inode *, \ - struct io_arguments *, \ - struct ioctx **))_sysio_incore_e_isdir + struct ioctx *))_sysio_incore_e_isdir #define _sysio_incore_dirop_ipwritev \ (int (*)(struct inode *, \ - struct io_arguments *, \ - struct ioctx **))_sysio_incore_e_isdir + struct ioctx *))_sysio_incore_e_isdir #define _sysio_incore_dirop_iodone \ (int (*)(struct ioctx *))_sysio_incore_illop #define _sysio_incore_dirop_fcntl \ @@ -193,7 +194,9 @@ static struct inode_ops _sysio_incore_di _sysio_incore_dirop_readlink, _sysio_incore_inop_open, _sysio_incore_inop_close, + _sysio_incore_dirop_link, _sysio_incore_dirop_unlink, + _sysio_incore_dirop_rename, _sysio_incore_dirop_ipreadv, _sysio_incore_dirop_ipwritev, _sysio_incore_dirop_iodone, @@ -202,7 +205,9 @@ static struct inode_ops _sysio_incore_di _sysio_incore_inop_sync, _sysio_incore_dirop_ioctl, _sysio_incore_dirop_mknod, +#ifdef _HAVE_STATVFS _sysio_incore_inop_statvfs, +#endif _sysio_incore_inop_gone }; @@ -210,24 +215,28 @@ static struct inode_ops _sysio_incore_di (int (*)(struct pnode *, \ struct inode **, \ struct intent *, \ - const char *))_sysio_incore_e_notdir + const char *))_sysio_incore_illop #define _sysio_incore_filop_getdirentries \ (ssize_t (*)(struct inode *, \ char *, \ size_t, \ - off64_t *))_sysio_incore_e_notdir + _SYSIO_OFF_T *))_sysio_incore_illop #define _sysio_incore_filop_mkdir \ - (int (*)(struct pnode *, mode_t))_sysio_incore_e_notdir + (int (*)(struct pnode *, mode_t))_sysio_incore_illop #define _sysio_incore_filop_rmdir \ - (int (*)(struct pnode *))_sysio_incore_e_notdir + (int (*)(struct pnode *))_sysio_incore_illop #define _sysio_incore_filop_symlink \ (int (*)(struct pnode *, const char *))_sysio_incore_illop #define _sysio_incore_symlinkop_readlink \ (int (*)(struct pnode *, char *, size_t))_sysio_incore_illop +#define _sysio_incore_filop_link \ + (int (*)(struct pnode *old, struct pnode *new))_sysio_incore_illop #define _sysio_incore_filop_unlink \ - (int (*)(struct pnode *pno))_sysio_incore_e_notdir + (int (*)(struct pnode *pno))_sysio_incore_illop +#define _sysio_incore_filop_rename \ + (int (*)(struct pnode *old, struct pnode *new))_sysio_incore_illop #define _sysio_incore_filop_mknod \ - (int (*)(struct pnode *pno, mode_t, dev_t))_sysio_incore_e_notdir + (int (*)(struct pnode *pno, mode_t, dev_t))_sysio_incore_illop static struct inode_ops _sysio_incore_file_ops = { _sysio_incore_filop_lookup, @@ -240,7 +249,9 @@ static struct inode_ops _sysio_incore_fi _sysio_incore_symlinkop_readlink, _sysio_incore_inop_open, _sysio_incore_inop_close, + _sysio_incore_filop_link, _sysio_incore_filop_unlink, + _sysio_incore_filop_rename, _sysio_incore_filop_ipreadv, _sysio_incore_filop_ipwritev, _sysio_incore_filop_iodone, @@ -249,7 +260,9 @@ static struct inode_ops _sysio_incore_fi _sysio_incore_inop_sync, _sysio_incore_filop_ioctl, _sysio_incore_filop_mknod, +#ifdef _HAVE_STATVFS _sysio_incore_inop_statvfs, +#endif _sysio_incore_inop_gone }; @@ -264,7 +277,9 @@ static struct inode_ops _sysio_incore_de _sysio_incore_symlinkop_readlink, _sysio_nodev_inop_open, _sysio_nodev_inop_close, + _sysio_incore_filop_link, _sysio_incore_filop_unlink, + _sysio_incore_filop_rename, _sysio_nodev_inop_ipreadv, _sysio_nodev_inop_ipwritev, _sysio_nodev_inop_iodone, @@ -273,7 +288,9 @@ static struct inode_ops _sysio_incore_de _sysio_nodev_inop_sync, _sysio_nodev_inop_ioctl, _sysio_incore_filop_mknod, +#ifdef _HAVE_STATVFS _sysio_incore_inop_statvfs, +#endif _sysio_incore_inop_gone }; @@ -309,7 +326,7 @@ struct lookup_data { */ #define INCORE_D_RECLEN(namlen) \ (((size_t )&((struct intnl_dirent *)0)->d_name + \ - (namlen) + sizeof(void *)) & \ + (namlen) + 1 + sizeof(void *)) & \ ~(sizeof(void *) - 1)) /* @@ -350,14 +367,30 @@ _sysio_incore_init() * Fill in the directory template. */ de = (struct intnl_dirent *)incore_dir_template; - de->d_off = off = de->d_reclen = INCORE_D_RECLEN(1); +#ifdef _DIRENT_HAVE_D_OFF + de->d_off = +#endif + off = de->d_reclen = INCORE_D_RECLEN(1); de->d_type = INCORE_D_TYPEOF(S_IFDIR); de->d_name[0] = '.'; - de = (void *)de + de->d_off; +#ifdef _DIRENT_HAVE_D_NAMLEN + de->d_namlen = 1; +#endif + /* + * Move to entry for `..' + */ + de = (void *)de + off; de->d_reclen = INCORE_D_RECLEN(2); - de->d_off = off += de->d_reclen; +#ifdef _DIRENT_HAVE_D_NAMLEN + de->d_namlen = 2; +#endif +#ifdef _DIRENT_HAVE_D_OFF + de->d_off = +#endif + off += de->d_reclen; de->d_type = INCORE_D_TYPEOF(S_IFDIR); de->d_name[0] = de->d_name[1] = '.'; + de->d_name[2] = ' '; return _sysio_fssw_register("incore", &incore_fssw_ops); } @@ -394,9 +427,9 @@ incore_i_alloc(struct incore_filesys *ic } static int -incore_trunc(struct incore_inode *icino, off64_t size, int clear) +incore_trunc(struct incore_inode *icino, _SYSIO_OFF_T size, int clear) { - off64_t n; + _SYSIO_OFF_T n; void *p; if (size < 0) @@ -464,7 +497,12 @@ incore_directory_new(struct incore_files sizeof(incore_dir_template)); de = icino->ici_data; de->d_ino = st->st_ino; - (void *)de += de->d_off; + (void *)de += +#ifdef _DIRENT_HAVE_D_OFF + de->d_off; +#else + de->d_reclen; +#endif de->d_ino = parent->ici_st.st_ino; /* @@ -682,7 +720,11 @@ _sysio_incore_fsop_gone(struct filesys * static void * incore_directory_probe(void *data, size_t siz, - off64_t origin, + _SYSIO_OFF_T origin +#ifndef _DIRENT_HAVE_D_OFF + __IS_UNUSED +#endif + , probe_ty entry, probe_ty hole, void *arg) @@ -693,15 +735,21 @@ incore_directory_probe(void *data, de = data; for (;;) { +#ifdef _DIRENT_HAVE_D_OFF assert(de->d_off); +#else + assert(de->d_reclen); +#endif if (entry && (p = (*entry)(de, de->d_reclen, arg))) return p; - n = de->d_off - origin; - if (hole && n > de->d_reclen) { - p = - (*hole)((void *)de + de->d_reclen, - n - de->d_reclen, - arg); + n = +#ifdef _DIRENT_HAVE_D_OFF + de->d_off - origin; +#else + ((void *)de - data) + de->d_reclen; +#endif + if (hole) { + p = (*hole)((void *)de, de->d_reclen, arg); if (p) return p; } @@ -719,7 +767,15 @@ incore_directory_match(struct intnl_dire struct lookup_data *ld) { - if (strncmp(de->d_name, ld->name->name, ld->name->len) == 0) +#if defined(BSD) || defined(REDSTORM) + if (IFTODT(de->d_type) == DT_WHT) + return NULL; +#endif + if ( +#ifdef _DIRENT_HAVE_D_NAMLEN + ld->name->len == de->d_namlen && +#endif + strncmp(de->d_name, ld->name->name, ld->name->len) == 0) return de; ld->de = de; return NULL; @@ -879,6 +935,13 @@ struct copy_info { size_t nbytes; }; +/* + * Eumeration callback. + * + * Note: + * On those systems supporting white-out entries, they are returned. On + * systems without, they are not. + */ static void * incore_directory_enumerate(struct intnl_dirent *de, size_t reclen, @@ -896,7 +959,7 @@ static ssize_t _sysio_incore_dirop_getdirentries(struct inode *ino, char *buf, size_t nbytes, - off64_t *basep) + _SYSIO_OFF_T *basep) { struct incore_inode *icino = I2IC(ino); off_t off; @@ -960,7 +1023,9 @@ incore_directory_insert(struct incore_in size_t reclen; struct lookup_data lookup_data; struct intnl_dirent *de; + size_t xt; size_t n; + size_t r; reclen = INCORE_D_RECLEN(name->len); INCORE_LD_INIT(&lookup_data, reclen, name); @@ -974,38 +1039,74 @@ incore_directory_insert(struct incore_in if (de) return -EEXIST; de = lookup_data.de; - n = de->d_off; - if (n >= (size_t )parent->ici_st.st_size) { + xt = (void *)lookup_data.de - parent->ici_data; + n = +#ifdef _DIRENT_HAVE_D_OFF + de->d_off; +#else + xt + de->d_reclen; +#endif + r = +#ifdef _DIRENT_HAVE_D_OFF + de->d_reclen; +#else + INCORE_D_RECLEN(de->d_namlen); +#endif + if (!parent->ici_st.st_size || + xt + r + reclen > (size_t )parent->ici_st.st_size) { int err; - size_t xt; - xt = (void *)lookup_data.de - parent->ici_data; - err = - incore_trunc(parent, - ((size_t )((void *)de - parent->ici_data) + - de->d_reclen + - reclen), - 1); + err = incore_trunc(parent, xt + r + reclen, 1); if (err) return err; de = parent->ici_data + xt; n = parent->ici_st.st_size; } +#ifdef _DIRENT_HAVE_D_OFF + de->d_off = xt + r; /* trim */ +#else + de->d_reclen = r; +#endif + (void *)de += r; /* reposition */ + xt += r; + +#ifndef _DIRENT_HAVE_D_OFF /* - * Fix previous entry. + * Will we split this hole or use all of it? */ - de->d_off = (void *)de - parent->ici_data + de->d_reclen; + if (lookup_data.hole.len - reclen && + lookup_data.hole.len - reclen <= INCORE_D_RECLEN(1)) + reclen = lookup_data.hole.len; +#endif /* * Insert new. */ - (void *)de += de->d_reclen; de->d_ino = inum; +#ifdef _DIRENT_HAVE_D_OFF de->d_off = n; +#endif de->d_reclen = reclen; de->d_type = type; (void )memcpy(de->d_name, name->name, name->len); +#ifdef _DIRENT_HAVE_D_NAMLEN + de->d_namlen = name->len; +#endif + +#ifndef _DIRENT_HAVE_D_OFF + xt += reclen; + if (n - xt) { + /* + * White-out remaining part of the hole. + */ + (void *)de += reclen; + de->d_ino = 0; + de->d_reclen = n - xt; + de->d_type = DT_WHT; + de->d_namlen = 0; + } +#endif /* * Update attributes to reflect the new entry. @@ -1095,6 +1196,10 @@ incore_unlink_entry(struct incore_inode { struct lookup_data lookup_data; struct intnl_dirent *de; + size_t reclen; +#ifdef _DIRENT_HAVE_D_OFF + size_t off; +#endif if (!S_ISDIR(icino->ici_st.st_mode)) return -ENOTDIR; @@ -1111,8 +1216,25 @@ incore_unlink_entry(struct incore_inode return -ENOENT; assert((size_t )((void *)de - icino->ici_data) >= sizeof(incore_dir_template)); - lookup_data.de->d_off = de->d_off; /* unlink */ - (void )memset(de, 0, de->d_reclen); /* clear */ +#ifndef _DIRENT_HAVE_D_OFF + reclen = de->d_reclen; +#else + off = de->d_off; + reclen = off - ((void *)de - icino->ici_data); +#endif + (void )memset(de, 0, reclen); +#ifndef _DIRENT_HAVE_D_OFF + de->d_type = (__uint8_t )DTTOIF(DT_WHT); + de->d_reclen = reclen; +#else + lookup_data.de->d_off = off; +#endif + + /* + * Adjust link count. + */ + assert(icino->ici_st.st_nlink > 2); + icino->ici_st.st_nlink--; return 0; } @@ -1145,6 +1267,12 @@ _sysio_incore_dirop_rmdir(struct pnode * return err; I_RELE(ino); + /* + * Adjust link count. + */ + assert(icino->ici_st.st_nlink > 2); + icino->ici_st.st_nlink--; + return 0; } @@ -1242,6 +1370,94 @@ _sysio_incore_inop_close(struct inode *i } static int +_sysio_incore_dirop_link(struct pnode *old, struct pnode *new) +{ + struct incore_inode *icino = I2IC(old->p_base->pb_ino); + int err; + + assert(!new->p_base->pb_ino); + assert(!S_ISDIR(old->p_base->pb_ino->i_mode)); + + /* + * Can bump the link count? + */ + if (!(icino->ici_st.st_nlink + 1)) + return -EMLINK; + /* + * Insert into parent. + */ + err = + incore_directory_insert(I2IC(new->p_parent->p_base->pb_ino), + &new->p_base->pb_name, + icino->ici_st.st_ino, + INCORE_D_TYPEOF(icino->ici_st.st_mode)); + if (err) + return err; + /* + * Bump the link count. + */ + icino->ici_st.st_nlink++; + + return 0; +} + +static int +_sysio_incore_dirop_rename(struct pnode *old, struct pnode *new) +{ + int err; + struct incore_inode *icino = I2IC(old->p_base->pb_ino); + + if (new->p_base->pb_ino) { + /* + * Have to kill off the target first. + */ + if (S_ISDIR(I2IC(new->p_base->pb_ino)->ici_st.st_mode) && + I2IC(new->p_base->pb_ino)->ici_st.st_nlink > 2) + return -ENOTEMPTY; + err = + incore_unlink_entry(I2IC(new->p_parent->p_base->pb_ino), + &new->p_base->pb_name); + if (err) + return err; + I_RELE(new->p_base->pb_ino); + _sysio_i_gone(new->p_base->pb_ino); + new->p_base->pb_ino = NULL; + } + + /* + * Insert into new parent. + */ + err = + incore_directory_insert(I2IC(new->p_parent->p_base->pb_ino), + &new->p_base->pb_name, + icino->ici_st.st_ino, + INCORE_D_TYPEOF(icino->ici_st.st_mode)); + if (err) + abort(); + /* + * Remove from the old parent. + */ + err = + incore_unlink_entry(I2IC(old->p_parent->p_base->pb_ino), + &old->p_base->pb_name); + if (err) + abort(); + + if (S_ISDIR(icino->ici_st.st_mode)) { + struct intnl_dirent *de; + + /* + * We moved a directory. The entry for `..' must be corrected. + */ + de = icino->ici_data; + de++; + assert(strcmp(de->d_name, "..") == 0); + de->d_ino = I2IC(new->p_parent->p_base->pb_ino)->ici_st.st_ino; + } + return 0; +} + +static int _sysio_incore_dirop_unlink(struct pnode *pno) { struct inode *ino = pno->p_base->pb_ino; @@ -1251,7 +1467,6 @@ _sysio_incore_dirop_unlink(struct pnode if (S_ISDIR(icino->ici_st.st_mode)) return -EISDIR; - pno->p_base->pb_ino = NULL; err = incore_unlink_entry(I2IC(pno->p_parent->p_base->pb_ino), &pno->p_base->pb_name); @@ -1265,18 +1480,12 @@ _sysio_incore_dirop_unlink(struct pnode static int incore_doio(ssize_t (*f)(struct incore_inode *, off_t, char *, size_t), struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp) + struct ioctx *ioctx) { - struct ioctx *ioctx; const struct iovec *iov; size_t n; ssize_t cc = 0; - ioctx = _sysio_ioctx_new(ino, ioargs); - if (!ioctx) - return -ENOMEM; - iov = ioctx->ioctx_iovec; for (n = ioctx->ioctx_iovlen, iov = ioctx->ioctx_iovec; n--; @@ -1297,18 +1506,17 @@ incore_doio(ssize_t (*f)(struct incore_i ioctx->ioctx_errno = -cc; } - *ioctxp = ioctx; return 0; } static ssize_t incore_read(struct incore_inode *icino, off_t off, char *buf, size_t nbytes) { - off64_t n; + _SYSIO_OFF_T n; if (!nbytes || off > icino->ici_st.st_size) return 0; - n = (off64_t )nbytes; + n = (_SYSIO_OFF_T )nbytes; if (!(n > 0 && (size_t )n == nbytes)) return -EINVAL; if (n > icino->ici_st.st_size - off) @@ -1320,11 +1528,10 @@ incore_read(struct incore_inode *icino, static int _sysio_incore_filop_ipreadv(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp) + struct ioctx *ioctx) { - return incore_doio(incore_read, ino, ioargs, ioctxp); + return incore_doio(incore_read, ino, ioctx); } static ssize_t @@ -1334,11 +1541,11 @@ incore_write(struct incore_inode *icino, size_t nbytes) { int err; - off64_t n; + _SYSIO_OFF_T n; if (!nbytes) return 0; - n = (off64_t )nbytes; + n = (_SYSIO_OFF_T )nbytes; if (!(n > 0 && (size_t )n == nbytes)) return -EINVAL; if (off + n > icino->ici_st.st_size) { @@ -1353,8 +1560,7 @@ incore_write(struct incore_inode *icino, static int _sysio_incore_filop_ipwritev(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp) + struct ioctx *ioctx) { return incore_doio((ssize_t (*)(struct incore_inode *, @@ -1362,8 +1568,7 @@ _sysio_incore_filop_ipwritev(struct inod char *, size_t))incore_write, ino, - ioargs, - ioctxp); + ioctx); } static int @@ -1430,7 +1635,7 @@ _sysio_incore_dirop_mknod(struct pnode * return -EINVAL; /* - * Must create a new, regular, file. + * Initialize attributes. */ (void )memset(&stat, 0, sizeof(stat)); stat.st_dev = pno->p_parent->p_base->pb_ino->i_fs->fs_dev; @@ -1452,6 +1657,7 @@ _sysio_incore_dirop_mknod(struct pnode * return incore_create(pno, &stat); } +#ifdef _HAVE_STATVFS static int _sysio_incore_inop_statvfs(struct pnode *pno, struct inode *ino, @@ -1472,7 +1678,8 @@ _sysio_incore_inop_statvfs(struct pnode */ buf->f_bsize = fs->fs_bsize; buf->f_frsize = buf->f_bsize; - buf->f_blocks = (0xffffffffffffffff - 1) / buf->f_bsize; + buf->f_blocks = ~0; + buf->f_blocks /= buf->f_bsize; buf->f_bfree = buf->f_blocks - 1; buf->f_bavail = buf->f_bfree; buf->f_files = buf->f_blocks; @@ -1488,6 +1695,7 @@ _sysio_incore_inop_statvfs(struct pnode return 0; } +#endif void _sysio_incore_inop_gone(struct inode *ino) @@ -1502,13 +1710,6 @@ _sysio_incore_e_isdir(void) { return -EISDIR; -} - -static int -_sysio_incore_e_notdir(void) -{ - - return -ENOTDIR; } static int |
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv28674/src Modified Files: Tag: cplant Makefile.am chdir.c chmod.c chown.c dev.c file.c getdirentries.c inode.c ioctx.c link.c lseek.c mknod.c mount.c open.c read.c rmdir.c statvfs.c statvfs64.c truncate.c unlink.c write.c Log Message: Merge HEAD changes into cplant branch Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/Makefile.am,v retrieving revision 1.7 retrieving revision 1.7.2.1 diff -u -w -b -B -p -r1.7 -r1.7.2.1 --- Makefile.am 14 Aug 2003 18:39:33 -0000 1.7 +++ Makefile.am 14 Oct 2003 23:39:36 -0000 1.7.2.1 @@ -2,8 +2,9 @@ lib_LIBRARIES = libsysio.a libsysio_a_SOURCES = chdir.c chmod.c chown.c dev.c dup.c fcntl.c file.c fs.c \ fsync.c getdirentries.c init.c inode.c ioctl.c ioctx.c iowait.c \ - lseek.c mkdir.c mknod.c mount.c namei.c open.c read.c rmdir.c stat.c \ - stat64.c statvfs.c symlink.c truncate.c unlink.c write.c access.c + link.c lseek.c mkdir.c mknod.c mount.c namei.c open.c read.c rename.c \ + rmdir.c stat.c stat64.c statvfs.c symlink.c truncate.c unlink.c \ + utime.c write.c access.c include $(top_srcdir)/Rules.make Index: chdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chdir.c,v retrieving revision 1.4.2.2 retrieving revision 1.4.2.3 diff -u -w -b -B -p -r1.4.2.2 -r1.4.2.3 --- chdir.c 6 Oct 2003 21:14:21 -0000 1.4.2.2 +++ chdir.c 14 Oct 2003 23:39:36 -0000 1.4.2.3 @@ -64,12 +64,13 @@ */ #include <stdlib.h> +#include <sys/types.h> +#include <sys/stat.h> #include <unistd.h> #include <string.h> #include <limits.h> #include <errno.h> #include <assert.h> -#include <sys/types.h> #include <sys/queue.h> #include "sysio.h" @@ -81,6 +82,49 @@ struct pnode *_sysio_cwd = NULL; +/* + * Change to directory specified by the given pnode. + */ +int +_sysio_p_chdir(struct pnode *pno) +{ + int err; + struct intnl_stat stbuf; + + /* + * Revalidate + */ + err = _sysio_p_validate(pno, NULL, NULL); + if (err) + return err; + if (!pno->p_base->pb_ino) + return -ENOTDIR; + /* + * Stat the node and ensure it's a directory. + */ + err = + pno->p_base->pb_ino->i_ops.inop_getattr(pno, + NULL, + &stbuf); + if (err) + return err; + if (!S_ISDIR(stbuf.st_mode)) + return -ENOTDIR; + + /* + * Release old if set. + */ + if (_sysio_cwd) + P_RELE(_sysio_cwd); + + /* + * Finally, change to the new. + */ + _sysio_cwd = pno; + + return 0; +} + int chdir(const char *path) { @@ -93,11 +137,7 @@ chdir(const char *path) return -1; } - if (_sysio_cwd) - P_RELE(_sysio_cwd); - - _sysio_cwd = pno; - return 0; + return _sysio_p_chdir(pno); } /* Index: chmod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chmod.c,v retrieving revision 1.3 retrieving revision 1.3.10.1 diff -u -w -b -B -p -r1.3 -r1.3.10.1 --- chmod.c 24 Mar 2003 22:09:06 -0000 1.3 +++ chmod.c 14 Oct 2003 23:39:36 -0000 1.3.10.1 @@ -51,6 +51,21 @@ #include "sysio.h" #include "inode.h" +#include "file.h" + +static int +do_chmod(struct pnode *pno, struct inode *ino, mode_t mode) +{ + int err; + struct intnl_stat stbuf; + unsigned mask; + + (void )memset(&stbuf, 0, sizeof(struct intnl_stat)); + stbuf.st_mode = mode & 0777; + mask = SETATTR_MODE; + err = _sysio_setattr(pno, ino, mask, &stbuf); + return err; +} int chmod(const char *path, mode_t mode) @@ -58,18 +73,35 @@ chmod(const char *path, mode_t mode) struct intent intent; int err; struct pnode *pno; - struct intnl_stat stbuf; - unsigned mask; INTENT_INIT(&intent, INT_SETATTR, NULL, NULL); err = _sysio_namei(_sysio_cwd, path, 0, &intent, &pno); if (err) goto out; - (void )memset(&stbuf, 0, sizeof(struct intnl_stat)); - stbuf.st_mode = mode & 0777; - mask = SETATTR_MODE; - err = _sysio_setattr(pno, pno->p_base->pb_ino, mask, &stbuf); + err = do_chmod(pno, pno->p_base->pb_ino, mode); P_RELE(pno); +out: + if (err) { + errno = -err; + err = -1; + } + return err; +} + +int +fchmod(int fd, mode_t mode) +{ + int err; + struct file *fil; + + err = 0; + fil = _sysio_fd_find(fd); + if (!fil) { + err = -EBADF; + goto out; + } + + err = do_chmod(NULL, fil->f_ino, mode); out: if (err) { errno = -err; Index: chown.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chown.c,v retrieving revision 1.3 retrieving revision 1.3.10.1 diff -u -w -b -B -p -r1.3 -r1.3.10.1 --- chown.c 24 Mar 2003 22:09:06 -0000 1.3 +++ chown.c 14 Oct 2003 23:39:36 -0000 1.3.10.1 @@ -51,18 +51,15 @@ #include "sysio.h" #include "inode.h" +#include "file.h" -int -chown(const char *path, uid_t owner, gid_t group) +static int +_do_chown(struct pnode *pno, struct inode *ino, uid_t owner, gid_t group) { int err; - struct pnode *pno; struct intnl_stat stbuf; unsigned mask; - err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno); - if (err) - goto out; (void )memset(&stbuf, 0, sizeof(struct intnl_stat)); mask = 0; if (owner != (uid_t )-1) { @@ -73,11 +70,44 @@ chown(const char *path, uid_t owner, gid stbuf.st_gid = group; mask |= SETATTR_GID; } - if (!mask) - goto done; - err = _sysio_setattr(pno, pno->p_base->pb_ino, mask, &stbuf); -done: + err = _sysio_setattr(pno, ino, mask, &stbuf); + return err; +} + +int +chown(const char *path, uid_t owner, gid_t group) +{ + int err; + struct pnode *pno; + + err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno); + if (err) + goto out; + + err = _do_chown(pno, pno->p_base->pb_ino, owner, group); P_RELE(pno); +out: + if (err) { + errno = -err; + err = -1; + } + return err; +} + +int +fchown(int fd, uid_t owner, gid_t group) +{ + int err; + struct file *fil; + + err = 0; + fil = _sysio_fd_find(fd); + if (!fil) { + err = -EBADF; + goto out; + } + + err = _do_chown(NULL, fil->f_ino, owner, group); out: if (err) { errno = -err; Index: dev.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/dev.c,v retrieving revision 1.2 retrieving revision 1.2.10.1 diff -u -w -b -B -p -r1.2 -r1.2.10.1 --- dev.c 24 Mar 2003 22:09:06 -0000 1.2 +++ dev.c 14 Oct 2003 23:39:36 -0000 1.2.10.1 @@ -63,7 +63,9 @@ const struct inode_ops _sysio_nodev_ops _sysio_nodev_inop_readlink, _sysio_nodev_inop_open, _sysio_nodev_inop_close, + _sysio_nodev_inop_link, _sysio_nodev_inop_unlink, + _sysio_nodev_inop_rename, _sysio_nodev_inop_ipreadv, _sysio_nodev_inop_ipwritev, _sysio_nodev_inop_iodone, @@ -72,7 +74,9 @@ const struct inode_ops _sysio_nodev_ops _sysio_nodev_inop_datasync, _sysio_nodev_inop_ioctl, _sysio_nodev_inop_mknod, +#ifdef _HAVE_STATVFS _sysio_nodev_inop_statvfs, +#endif _sysio_nodev_inop_gone }; @@ -167,45 +171,10 @@ _sysio_dev_lookup(mode_t mode, dev_t dev } int -_sysio_dev_e_notdir() -{ - - return -ENOTDIR; -} - -int -_sysio_dev_e_badf() -{ - - return -EBADF; -} - -int -_sysio_dev_e_inval() -{ - - return -EINVAL; -} - -int -_sysio_dev_e_nxio() -{ - - return -ENXIO; -} - -int -_sysio_dev_e_illop() +_sysio_dev_illop() { abort(); -} - -int -_sysio_dev_e_notty() -{ - - return -ENOTTY; } void Index: file.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/file.c,v retrieving revision 1.5 retrieving revision 1.5.2.1 diff -u -w -b -B -p -r1.5 -r1.5.2.1 --- file.c 6 Aug 2003 19:12:46 -0000 1.5 +++ file.c 14 Oct 2003 23:39:36 -0000 1.5.2.1 @@ -97,14 +97,12 @@ _sysio_fgone(struct file *fil) * IO operation completion handler. */ void -_sysio_fcompletio(struct ioctx *ioctx) +_sysio_fcompletio(struct ioctx *ioctx, struct file *fil) { - struct file *fil; if (ioctx->ioctx_errno) return; - fil = (struct file *)ioctx->ioctx_data; assert(ioctx->ioctx_ino == fil->f_ino); fil->f_pos = ioctx->ioctx_offset + ioctx->ioctx_cc; } Index: getdirentries.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/getdirentries.c,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -w -b -B -p -r1.2 -r1.2.2.1 --- getdirentries.c 31 Jul 2003 22:21:35 -0000 1.2 +++ getdirentries.c 14 Oct 2003 23:39:36 -0000 1.2.2.1 @@ -1,7 +1,6 @@ -#ifdef __GNUC__ -#include <alloca.h> -#else #include <stdlib.h> +#ifdef __GLIBC__ +#include <alloca.h> #endif #include <string.h> #include <errno.h> @@ -19,8 +18,11 @@ #define __restrict #endif -ssize_t -getdirentries64(int fd, char *buf, size_t nbytes, off64_t * __restrict basep) +static ssize_t +_getdirentries64(int fd, + char *buf, + size_t nbytes, + _SYSIO_OFF_T * __restrict basep) { struct file *fil; ssize_t cc; @@ -44,6 +46,13 @@ getdirentries64(int fd, char *buf, size_ return cc; } +#if _LARGEFILE64_SOURCE +#undef getdirentries64 +sysio_sym_strong_alias(_getdirentries64, getdirentries64) +#endif + +#undef getdirentries + #ifndef DIRENT64_IS_NATURAL #ifndef EOVERFLOW @@ -56,33 +65,59 @@ getdirentries64(int fd, char *buf, size_ #define _namlen(dp) (strlen((dp)->d_name)) #endif +#ifndef _rndup +#define _rndup(n, boundary) \ + ((((n) + (boundary) - 1 ) / (boundary)) * (boundary)) +#endif + +#if !(defined(BSD) || defined(REDSTORM)) ssize_t -getdirentries(int fd, char *buf, size_t nbytes, off_t * __restrict basep) +getdirentries(int fd, + char *buf, + size_t nbytes, + off_t * __restrict basep) +#else +int +getdirentries(int fd, + char *buf, + int nbytes, + long * __restrict basep) +#endif { size_t inbytes; void *ibuf; - off64_t ibase; + _SYSIO_OFF_T ibase; ssize_t cc; struct dirent *dp, *nxtdp; - struct dirent64 *od64p = NULL, *d64p = NULL; +#if defined(BSD) || defined(REDSTORM) + int off; +#endif + struct intnl_dirent *od64p, *d64p; size_t n; size_t reclen; char *cp; #define _dbaselen ((size_t )&((struct dirent *)0)->d_name[0]) -#ifdef __GNUC__ +#ifdef __GLIBC__ #define _dreclen(namlen) \ ((_dbaselen + (namlen) + __alignof__ (struct dirent)) & \ ~(__alignof__ (struct dirent) - 1)) #define _fast_alloc(n) alloca(n) #define _fast_free(p) -#else /* !defined(__GNUC__) */ -#define _dreclen(namelen) \ - (_rndup(_dbaselen + (namlen) + 1, sizeof(unsigned long long)) +#else /* !defined(__GLIBC__) */ +#define _dreclen(namlen) \ + _rndup(_dbaselen + (namlen) + 1, sizeof(int)) #define _fast_alloc(n) malloc(n) #define _fast_free(p) free(p) #endif +#if defined(BSD) || defined(REDSTORM) + if (nbytes < 0) { + errno = -EINVAL; + return -1; + } +#endif + inbytes = nbytes; if (inbytes > 8 * 1024) { /* @@ -99,7 +134,7 @@ getdirentries(int fd, char *buf, size_t dp = (struct dirent *)buf; ibase = *basep; - cc = getdirentries64(fd, ibuf, inbytes, &ibase); + cc = _getdirentries64(fd, ibuf, inbytes, &ibase); if (cc < 0) { cc = -errno; goto out; @@ -110,6 +145,9 @@ getdirentries(int fd, char *buf, size_t goto out; } +#if defined(BSD) || defined(REDSTORM) + off = *basep; +#endif od64p = NULL; d64p = ibuf; for (;;) { @@ -121,14 +159,22 @@ getdirentries(int fd, char *buf, size_t n = strlen(d64p->d_name); #endif reclen = _dreclen(n); - if (reclen >= nbytes) + if (reclen >= (unsigned )nbytes) break; dp->d_ino = (ino_t )d64p->d_ino; +#if !(defined(BSD) || defined(REDSTORM)) dp->d_off = (off_t )d64p->d_off; +#endif if ((sizeof(dp->d_ino) != sizeof(d64p->d_ino) && - dp->d_ino != d64p->d_ino) && + dp->d_ino != d64p->d_ino) + || +#if !(defined(BSD) || defined(REDSTORM)) (sizeof(dp->d_off) != sizeof(d64p->d_off) && - dp->d_off != d64p->d_off)) { + dp->d_off != d64p->d_off) +#else + (off + (int )reclen < off) +#endif + ) { cc = -EOVERFLOW; break; } @@ -142,6 +188,9 @@ getdirentries(int fd, char *buf, size_t od64p = d64p; d64p = (void *)d64p + d64p->d_reclen; nbytes -= reclen; +#if defined(BSD) || defined(REDSTORM) + off += reclen; +#endif dp = nxtdp; } @@ -154,10 +203,15 @@ out: } cc = (char *)dp - buf; if (cc) - *basep = od64p->d_off; + *basep = +#if !(defined(BSD) || defined(REDSTORM)) + od64p->d_off; +#else + off; +#endif return cc; -#ifdef __GNUC__ +#ifdef __GLIBC__ #undef _fast_alloc #undef _fast_free #endif @@ -165,6 +219,5 @@ out: #undef _dbaselen } #else /* !defined(DIRENT64_IS_NATURAL) */ -sysio_sym_strong_alias(getdirentries64, getdirentries) +sysio_sym_strong_alias(_getdirentries64, getdirentries) #endif - Index: inode.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v retrieving revision 1.8.2.1 retrieving revision 1.8.2.2 diff -u -w -b -B -p -r1.8.2.1 -r1.8.2.2 --- inode.c 26 Aug 2003 17:21:39 -0000 1.8.2.1 +++ inode.c 14 Oct 2003 23:39:36 -0000 1.8.2.2 @@ -606,6 +606,30 @@ _sysio_p_find_alias(struct pnode *parent } /* + * Prune idle path base nodes freom the passed sub-tree, including the root. + */ +static void +_sysio_prune(struct pnode_base *rpb) +{ + struct pnode_base *nxtpb, *pb; + + nxtpb = rpb->pb_children.lh_first; + while ((pb = nxtpb)) { + nxtpb = pb->pb_sibs.le_next; + if (pb->pb_aliases.lh_first) + continue; + if (pb->pb_children.lh_first) { + _sysio_prune(pb); + continue; + } + _sysio_pb_gone(pb); + } + if (rpb->pb_children.lh_first) + return; + _sysio_pb_gone(rpb); +} + +/* * Prune idle nodes from the passed sub-tree, including the root. * * Returns the number of aliases on the same mount that could not be pruned. @@ -623,6 +647,10 @@ _sysio_p_prune(struct pnode *root) while ((pb = nxtpb)) { nxtpb = pb->pb_sibs.le_next; nxtpno = pb->pb_aliases.lh_first; + if (!nxtpno) { + _sysio_prune(pb); + continue; + } while ((pno = nxtpno)) { nxtpno = pno->p_links.le_next; if (pno->p_mount != root->p_mount) { @@ -664,10 +692,10 @@ _sysio_p_prune(struct pnode *root) if (_sysio_do_unmount(pno->p_mount) != 0) { P_RELE(pno); count++; - continue; } + continue; #endif - } else + } _sysio_p_gone(pno); } } @@ -682,9 +710,9 @@ _sysio_p_prune(struct pnode *root) /* * All that is left is the root. Try for it too. */ - if (root->p_ref) + if (root->p_ref) { count++; - else if (root->p_mount->mnt_root == root) { + } else if (root->p_mount->mnt_root == root) { #ifndef AUTOMOUNT_FILE_NAME count++; #else Index: ioctx.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/ioctx.c,v retrieving revision 1.2 retrieving revision 1.2.16.1 diff -u -w -b -B -p -r1.2 -r1.2.16.1 --- ioctx.c 7 Mar 2003 03:31:36 -0000 1.2 +++ ioctx.c 14 Oct 2003 23:39:36 -0000 1.2.16.1 @@ -78,40 +78,67 @@ _sysio_ioctx_init() * Allocate and initialisze a new IO context. */ struct ioctx * -_sysio_ioctx_new(struct inode *ino, struct io_arguments *ioargs) +_sysio_ioctx_new(struct inode *ino, + const struct iovec *iov, + size_t iovlen, + _SYSIO_OFF_T offset) { struct ioctx *ioctx; ioctx = - malloc(sizeof(struct ioctx) + - ioargs->ioarg_iovlen * sizeof(struct iovec)); + malloc(sizeof(struct ioctx) + iovlen * sizeof(struct iovec)); if (!ioctx) return NULL; I_REF(ino); + ioctx->ioctx_iovec = (void *)ioctx + sizeof(struct ioctx); + (void )memcpy((void *)ioctx->ioctx_iovec, + iov, + iovlen * sizeof(struct iovec)); + IOCTX_INIT(ioctx, + 0, + (ioid_t )ioctx, + ino, + ioctx->ioctx_iovec, + iovlen, + offset); + /* * Link request onto the outstanding requests queue. */ LIST_INSERT_HEAD(&aioq, ioctx, ioctx_link); - ioctx->ioctx_id = (ioid_t )ioctx; - ioctx->ioctx_ino = ino; - ioctx->ioctx_iovec = (void *)ioctx + sizeof(struct ioctx); - (void )memcpy((void *)ioctx->ioctx_iovec, - ioargs->ioarg_iovec, - ioargs->ioarg_iovlen * sizeof(struct iovec)); - ioctx->ioctx_iovlen = ioargs->ioarg_iovlen; - ioctx->ioctx_offset = ioargs->ioarg_offset; - ioctx->ioctx_cc = 0; - ioctx->ioctx_errno = 0; - ioctx->ioctx_cb = ioargs->ioarg_completion; - ioctx->ioctx_data = ioargs->ioarg_completion_arg; - return ioctx; } /* + * Add an IO completion call-back to the end of the context call-back queue. + * These are called in iowait() as the last thing, right before the context + * is destroyed. + * + * They are called in order. Beware. + */ +int +_sysio_ioctx_cb(struct ioctx *ioctx, + void (*f)(struct ioctx *, void *), + void *data) +{ + struct ioctx_callback *entry; + + entry = malloc(sizeof(struct ioctx_callback)); + if (!entry) + return -ENOMEM; + + entry->iocb_f = f; + entry->iocb_data = data; + + TAILQ_INSERT_TAIL(&ioctx->ioctx_cbq, entry, iocb_next); + + return 0; +} + +/* * Find an IO context given it's identifier. * * NB: This is dog-slow. If there are alot of these, we will need to change @@ -170,26 +197,37 @@ _sysio_ioctx_wait(struct ioctx *ioctx) void _sysio_ioctx_complete(struct ioctx *ioctx) { +#if 0 struct inode *ino; +#endif + struct ioctx_callback *entry; - /* - * Unlink from the file record's outstanding request queue. - */ - LIST_REMOVE(ioctx, ioctx_link); - +#if 0 /* * Wait for IO to complete and remember completion values. */ ino = ioctx->ioctx_ino; while (ino && !(*ino->i_ops.inop_iodone)(ioctx)) ; +#endif + /* - * Notify interested parties. + * Run the call-back queue. */ - if (ioctx->ioctx_cb) - (*ioctx->ioctx_cb)(ioctx); + while ((entry = ioctx->ioctx_cbq.tqh_first)) { + TAILQ_REMOVE(&ioctx->ioctx_cbq, entry, iocb_next); + (*entry->iocb_f)(ioctx, entry->iocb_data); + free(entry); + } - I_RELE(ino); + if (ioctx->ioctx_fast) + return; + + /* + * Unlink from the file record's outstanding request queue. + */ + LIST_REMOVE(ioctx, ioctx_link); + I_RELE(ioctx->ioctx_ino); free(ioctx); } Index: link.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/link.c,v retrieving revision 1.1 retrieving revision 1.1.6.1 diff -u -w -b -B -p -r1.1 -r1.1.6.1 --- link.c 27 Sep 2003 19:42:03 -0000 1.1 +++ link.c 14 Oct 2003 23:39:36 -0000 1.1.6.1 @@ -72,7 +72,7 @@ link(const char *oldpath, const char *ne err = _sysio_namei(_sysio_cwd, newpath, ND_NEGOK, &intent, &new); if (err && !new) goto error2; - if (!err || (err && err != -ENOENT)) { + if (err && err != -ENOENT) { err = -EEXIST; goto error1; } Index: lseek.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/lseek.c,v retrieving revision 1.6.2.1 retrieving revision 1.6.2.2 diff -u -w -b -B -p -r1.6.2.1 -r1.6.2.2 --- lseek.c 6 Oct 2003 21:14:22 -0000 1.6.2.1 +++ lseek.c 14 Oct 2003 23:39:36 -0000 1.6.2.2 @@ -53,8 +53,8 @@ #include "sysio-symbols.h" -static off64_t -_sysio_lseek(int fd, off64_t offset, int whence) +static _SYSIO_OFF_T +_sysio_lseek(int fd, _SYSIO_OFF_T offset, int whence) { int err; struct file *fil; @@ -117,11 +117,44 @@ sysio_sym_weak_alias(_sysio_lseek, __lse extern off_t lseek(int fd, off_t offset, int whence) { + _SYSIO_OFF_T off; + off_t rtn; - return (off_t )_sysio_lseek(fd, offset, whence); + off = _sysio_lseek(fd, offset, whence); + if (off < 0) + return -1; + rtn = (off_t )off; + if ((_SYSIO_OFF_T )rtn != off) { + errno = EINVAL; + return -1; + } + return rtn; } #ifdef __GLIBC__ #undef __lseek sysio_sym_weak_alias(lseek, __lseek) +#endif + +#if 0 +#ifdef __linux__ +#undef llseek +int +llseek(unsigned int fd __IS_UNUSED, + unsigned long offset_high __IS_UNUSED, + unsigned long offset_low __IS_UNUSED, + loff_t *result __IS_UNUSED, + unsigned int whence __IS_UNUSED) +{ + + /* + * Something is very wrong if this was called. + */ + errno = ENOTSUP; + return -1; +} + +#undef __llseek +sysio_sym_weak_alias(llseek, __llseek) +#endif #endif Index: mknod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mknod.c,v retrieving revision 1.3 retrieving revision 1.3.10.1 diff -u -w -b -B -p -r1.3 -r1.3.10.1 --- mknod.c 26 Mar 2003 00:06:05 -0000 1.3 +++ mknod.c 14 Oct 2003 23:39:36 -0000 1.3.10.1 @@ -62,6 +62,10 @@ #undef mknod #undef __xmknod +#if defined(BSD) || defined(REDSTORM) +#define _MKNOD_VER 0 +#endif + int __xmknod(int __ver, const char *path, mode_t mode, dev_t *dev) { Index: mount.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mount.c,v retrieving revision 1.5.8.1 retrieving revision 1.5.8.2 diff -u -w -b -B -p -r1.5.8.1 -r1.5.8.2 --- mount.c 26 Aug 2003 17:21:39 -0000 1.5.8.1 +++ mount.c 14 Oct 2003 23:39:36 -0000 1.5.8.2 @@ -563,8 +563,7 @@ _sysio_automount(struct pnode *mntpno) struct inode *ino; struct intnl_stat stbuf; struct iovec iovec; - struct io_arguments ioarguments; - struct ioctx *ioctx; + struct ioctx iocontext; ssize_t cc; char *fstype, *source, *opts; unsigned flags; @@ -598,13 +597,14 @@ _sysio_automount(struct pnode *mntpno) err = _sysio_open(mntpno, O_RDONLY, 0); if (err) goto out; - IOARG_INIT(&ioarguments, &iovec, 1, 0, NULL, NULL); - err = (*ino->i_ops.inop_ipreadv)(ino, &ioarguments, &ioctx); + IOCTX_INIT(&iocontext, 1, (ioid_t )&iocontext, ino, &iovec, 1, 0); + err = (*ino->i_ops.inop_ipreadv)(ino, &iocontext); if (err) { + _sysio_ioctx_complete(&iocontext); (void )(*ino->i_ops.inop_close)(ino); goto out; } - cc = _sysio_ioctx_wait(ioctx); + cc = _sysio_ioctx_wait(&iocontext); err = (*ino->i_ops.inop_close)(ino); if (err) goto out; Index: open.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/open.c,v retrieving revision 1.8.2.1 retrieving revision 1.8.2.2 diff -u -w -b -B -p -r1.8.2.1 -r1.8.2.2 --- open.c 6 Oct 2003 21:14:22 -0000 1.8.2.1 +++ open.c 14 Oct 2003 23:39:36 -0000 1.8.2.2 @@ -118,6 +118,8 @@ _sysio_open(struct pnode *pno, int flags return err; } +#undef open + int open(const char *path, int flags, ...) { @@ -146,7 +148,12 @@ open(const char *path, int flags, ...) * Will need mode too. */ va_start(ap, flags); - mode = va_arg(ap, mode_t); + mode = +#ifndef REDSTORM + va_arg(ap, mode_t); +#else + va_arg(ap, int); +#endif va_end(ap); mode &= ~_sysio_umask; /* apply umask */ Index: read.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/read.c,v retrieving revision 1.3.2.1 retrieving revision 1.3.2.2 diff -u -w -b -B -p -r1.3.2.1 -r1.3.2.2 --- read.c 6 Oct 2003 21:14:22 -0000 1.3.2.1 +++ read.c 14 Oct 2003 23:39:36 -0000 1.3.2.2 @@ -59,13 +59,13 @@ * Schedule asynchronous read of iovec at some file extent. */ static struct ioctx * -do_ipreadv(struct file *fil, +do_ixreadv(struct file *fil, const struct iovec *iov, size_t count, - off_t offset) + _SYSIO_OFF_T offset, + void (*fcompletio)(struct ioctx *, struct file *)) { struct inode *ino; int err; - struct io_arguments ioarguments; struct ioctx *ioctx; if (fil->f_flags & O_WRONLY) { @@ -81,12 +81,23 @@ do_ipreadv(struct file *fil, errno = EBADF; return NULL; } - IOARG_INIT(&ioarguments, - iov, count, - offset, - (void (*)(void *))_sysio_fcompletio, fil); - err = ino->i_ops.inop_ipreadv(fil->f_ino, &ioarguments, &ioctx); + ioctx = _sysio_ioctx_new(fil->f_ino, iov, count, offset); + if (!ioctx || + (fcompletio && + _sysio_ioctx_cb(ioctx, + (void (*)(struct ioctx *, void *))fcompletio, + fil) != 0)) { + err = -ENOMEM; + goto out; + } + err = ino->i_ops.inop_ipreadv(fil->f_ino, ioctx); +out: if (err) { + if (ioctx) { + ioctx->ioctx_cc = -1; + ioctx->ioctx_errno = -err; + _sysio_ioctx_complete(ioctx); + } errno = -err; return NULL; } @@ -97,7 +108,7 @@ do_ipreadv(struct file *fil, * API interface to accomplish asynch read into iovec from given file offset. */ ioid_t -ipreadv(int fd, const struct iovec *iov, size_t count, off_t offset) +ipreadv(int fd, const struct iovec *iov, size_t count, _SYSIO_OFF_T offset) { struct file *fil; struct ioctx *ioctxp; @@ -108,7 +119,7 @@ ipreadv(int fd, const struct iovec *iov, return IOID_FAIL; } - ioctxp = do_ipreadv(fil, iov, count, offset); + ioctxp = do_ixreadv(fil, iov, count, offset, NULL); return ioctxp ? ioctxp->ioctx_id : IOID_FAIL; } @@ -116,7 +127,7 @@ ipreadv(int fd, const struct iovec *iov, * API interface to accomplish asynch read into buf from given file offset. */ ioid_t -ipread(int fd, void *buf, size_t count, off_t offset) +ipread(int fd, void *buf, size_t count, _SYSIO_OFF_T offset) { struct iovec iov[1]; @@ -131,7 +142,7 @@ ipread(int fd, void *buf, size_t count, * API interface to accomplish read into iovec from given file offset. */ ssize_t -preadv(int fd, const struct iovec *iov, size_t count, off_t offset) +preadv(int fd, const struct iovec *iov, size_t count, _SYSIO_OFF_T offset) { ioid_t ioid; @@ -144,8 +155,8 @@ preadv(int fd, const struct iovec *iov, /* * API interface to accomplish read into buf from given file offset. */ -ssize_t -pread(int fd, void *buf, size_t count, off_t offset) +static ssize_t +_pread(int fd, void *buf, size_t count, _SYSIO_OFF_T offset) { ioid_t ioid; @@ -155,6 +166,21 @@ pread(int fd, void *buf, size_t count, o return iowait(ioid); } +#if _LARGEFILE64_SOURCE +#undef pread64 +sysio_sym_weak_alias(_pread, pread64) + +ssize_t +pread(int fd, void *buf, size_t count, off_t offset) +{ + + return _pread(fd, buf, count, offset); +} +#else +#undef pread +sysio_sym_weak_alias(_pread, pread) +#endif + /* * API interface to accomplish asynch read into iovec from current file offset. */ @@ -170,7 +196,7 @@ ireadv(int fd, const struct iovec *iov, return IOID_FAIL; } - ioctxp = do_ipreadv(fil, iov, count, fil->f_pos); + ioctxp = do_ixreadv(fil, iov, count, fil->f_pos, _sysio_fcompletio); if (!ioctxp) return IOID_FAIL; return ioctxp->ioctx_id; Index: rmdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/rmdir.c,v retrieving revision 1.3 retrieving revision 1.3.10.1 diff -u -w -b -B -p -r1.3 -r1.3.10.1 --- rmdir.c 24 Mar 2003 22:09:06 -0000 1.3 +++ rmdir.c 14 Oct 2003 23:39:36 -0000 1.3.10.1 @@ -68,6 +68,13 @@ rmdir(const char *path) goto error; } err = pno->p_base->pb_ino->i_ops.inop_rmdir(pno); + if (err) + goto error; + /* + * Invalide the path-base node. The inode reference was dropped + * by the driver. + */ + pno->p_base->pb_ino = NULL; error: P_RELE(pno); out: Index: statvfs.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/statvfs.c,v retrieving revision 1.3 retrieving revision 1.3.10.1 diff -u -w -b -B -p -r1.3 -r1.3.10.1 --- statvfs.c 24 Mar 2003 22:09:07 -0000 1.3 +++ statvfs.c 14 Oct 2003 23:39:36 -0000 1.3.10.1 @@ -41,6 +41,10 @@ * le...@sa... */ +#ifdef _HAVE_STATVFS + +#if !(defined(BSD) || defined(REDSTORM)) + #include <unistd.h> #include <errno.h> #include <assert.h> @@ -136,3 +140,5 @@ err: out: return err; } +#endif /* if !(defined(BSD) || defined(REDSTORM)) */ +#endif /* defined(_HAVE_STATVFS) */ Index: statvfs64.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/statvfs64.c,v retrieving revision 1.3 retrieving revision 1.3.10.1 diff -u -w -b -B -p -r1.3 -r1.3.10.1 --- statvfs64.c 24 Mar 2003 22:09:07 -0000 1.3 +++ statvfs64.c 14 Oct 2003 23:39:36 -0000 1.3.10.1 @@ -41,6 +41,9 @@ * le...@sa... */ +#ifdef _HAVE_STATVFS + +#if !(defined(BSD) || defined(REDSTORM)) #include <unistd.h> #include <errno.h> #include <assert.h> @@ -93,3 +96,5 @@ out: } return err; } +#endif /* if !(defined(BSD) || defined(REDSTORM)) */ +#endif /* define(_HAVE_STATVFS) */ Index: truncate.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/truncate.c,v retrieving revision 1.3 retrieving revision 1.3.10.1 diff -u -w -b -B -p -r1.3 -r1.3.10.1 --- truncate.c 24 Mar 2003 22:09:07 -0000 1.3 +++ truncate.c 14 Oct 2003 23:39:36 -0000 1.3.10.1 @@ -53,11 +53,13 @@ #include "inode.h" #include "file.h" +#include "sysio-symbols.h" + /* * Truncate file, given path (alias) or index node. */ static int -do_truncate(struct pnode *pno, struct inode *ino, off_t length) +do_truncate(struct pnode *pno, struct inode *ino, _SYSIO_OFF_T length) { struct intnl_stat stbuf; unsigned mask; @@ -75,8 +77,8 @@ do_truncate(struct pnode *pno, struct in return _sysio_setattr(pno, ino, mask, &stbuf); } -int -truncate(const char *path, off_t length) +static int +_truncate(const char *path, _SYSIO_OFF_T length) { int err; struct pnode *pno; @@ -95,8 +97,24 @@ out: return err; } +#if _LARGEFILE64_SOURCE +#undef truncate64 +sysio_sym_weak_alias(_truncate, truncate64) + +#undef truncate int -ftruncate(int fd, off_t length) +truncate(const char *path, off_t length) +{ + + return _truncate(path, length); +} +#else +#undef truncate +sysio_sym_weak_alias(_truncate, truncate) +#endif + +static int +_ftruncate(int fd, _SYSIO_OFF_T length) { int err; struct file *fil; @@ -115,3 +133,19 @@ out: } return err; } + +#if _LARGEFILE64_SOURCE +#undef ftruncate64 +sysio_sym_weak_alias(_ftruncate, ftruncate64) + +#undef ftruncate +int +ftruncate(int fd, off_t length) +{ + + return _ftruncate(fd, length); +} +#else +#undef ftruncate +sysio_sym_weak_alias(_ftruncate, ftruncate) +#endif Index: unlink.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/unlink.c,v retrieving revision 1.3 retrieving revision 1.3.10.1 diff -u -w -b -B -p -r1.3 -r1.3.10.1 --- unlink.c 24 Mar 2003 22:09:07 -0000 1.3 +++ unlink.c 14 Oct 2003 23:39:36 -0000 1.3.10.1 @@ -68,6 +68,13 @@ unlink(const char *path) goto error; } err = (*pno->p_base->pb_ino->i_ops.inop_unlink)(pno); + if (err) + goto error; + /* + * Invalidate the path-base node. The inode reference was + * dropped by the driver. + */ + pno->p_base->pb_ino = NULL; error: P_RELE(pno); out: Index: write.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/write.c,v retrieving revision 1.3.2.1 retrieving revision 1.3.2.2 diff -u -w -b -B -p -r1.3.2.1 -r1.3.2.2 --- write.c 6 Oct 2003 21:14:22 -0000 1.3.2.1 +++ write.c 14 Oct 2003 23:39:36 -0000 1.3.2.2 @@ -52,8 +52,10 @@ #include "sysio.h" #include "file.h" #include "inode.h" -#include "fs.h" -#include "mount.h" + +#include "sysio-symbols.h" + +#include "sysio-symbols.h" #include "sysio-symbols.h" @@ -61,16 +63,16 @@ * Schedule asynchronous write of iovec at some file extent. */ static struct ioctx * -do_ipwritev(struct file *fil, +do_ixwritev(struct file *fil, const struct iovec *iov, size_t count, - off_t offset) + _SYSIO_OFF_T offset, + void (*fcompletio)(struct ioctx *, struct file *)) { struct inode *ino; int err; - struct io_arguments ioarguments; struct ioctx *ioctx; - if (!(fil->f_flags & (O_WRONLY|O_RDWR))) { + if (fil->f_flags & O_RDONLY) { errno = EBADF; return IOID_FAIL; } @@ -80,19 +82,26 @@ do_ipwritev(struct file *fil, /* * Huh? It's dead. */ - errno = -EBADF; + errno = EBADF; return NULL; } - if (IS_RDONLY(NULL, ino)) { - errno = -EROFS; - return NULL; + ioctx = _sysio_ioctx_new(fil->f_ino, iov, count, offset); + if (!ioctx || + (fcompletio && + _sysio_ioctx_cb(ioctx, + (void (*)(struct ioctx *, void *))fcompletio, + fil) != 0)) { + err = -ENOMEM; + goto out; } - IOARG_INIT(&ioarguments, - iov, count, - offset, - (void (*)(void *))_sysio_fcompletio, fil); - err = ino->i_ops.inop_ipwritev(fil->f_ino, &ioarguments, &ioctx); + err = ino->i_ops.inop_ipwritev(fil->f_ino, ioctx); +out: if (err) { + if (ioctx) { + ioctx->ioctx_cc = -1; + ioctx->ioctx_errno = -err; + _sysio_ioctx_complete(ioctx); + } errno = -err; return NULL; } @@ -100,10 +109,10 @@ do_ipwritev(struct file *fil, } /* - * API interface to accomplish asynch write from iovec at given file offset. + * API interface to accomplish asynch write into iovec from given file offset. */ ioid_t -ipwritev(int fd, const struct iovec *iov, size_t count, off_t offset) +ipwritev(int fd, const struct iovec *iov, size_t count, _SYSIO_OFF_T offset) { struct file *fil; struct ioctx *ioctxp; @@ -114,15 +123,15 @@ ipwritev(int fd, const struct iovec *iov return IOID_FAIL; } - ioctxp = do_ipwritev(fil, iov, count, offset); + ioctxp = do_ixwritev(fil, iov, count, offset, NULL); return ioctxp ? ioctxp->ioctx_id : IOID_FAIL; } /* - * API interface to accomplish asynch write from buf from given file offset. + * API interface to accomplish asynch write into buf from given file offset. */ ioid_t -ipwrite(int fd, const void *buf, size_t count, off_t offset) +ipwrite(int fd, const void *buf, size_t count, _SYSIO_OFF_T offset) { struct iovec iov[1]; @@ -134,10 +143,10 @@ ipwrite(int fd, const void *buf, size_t } /* - * API interface to accomplish write from iovec at given file offset. + * API interface to accomplish write into iovec from given file offset. */ ssize_t -pwritev(int fd, const struct iovec *iov, size_t count, off_t offset) +pwritev(int fd, const struct iovec *iov, size_t count, _SYSIO_OFF_T offset) { ioid_t ioid; @@ -148,10 +157,10 @@ pwritev(int fd, const struct iovec *iov, } /* - * API interface to accomplish write from buf from given file offset. + * API interface to accomplish write into buf from given file offset. */ -ssize_t -pwrite(int fd, const void *buf, size_t count, off_t offset) +static ssize_t +_pwrite(int fd, const void *buf, size_t count, _SYSIO_OFF_T offset) { ioid_t ioid; @@ -161,8 +170,23 @@ pwrite(int fd, const void *buf, size_t c return iowait(ioid); } +#if _LARGEFILE64_SOURCE +#undef pwrite64 +sysio_sym_weak_alias(_pwrite, pwrite64) + +ssize_t +pwrite(int fd, const void *buf, size_t count, off_t offset) +{ + + return _pwrite(fd, buf, count, offset); +} +#else +#undef pwrite +sysio_sym_weak_alias(_pwrite, pwrite) +#endif + /* - * API interface to accomplish asynch write from iovec at current file offset. + * API interface to accomplish asynch write into iovec from current file offset. */ ioid_t iwritev(int fd, const struct iovec *iov, int count) @@ -176,14 +200,14 @@ iwritev(int fd, const struct iovec *iov, return IOID_FAIL; } - ioctxp = do_ipwritev(fil, iov, count, fil->f_pos); + ioctxp = do_ixwritev(fil, iov, count, fil->f_pos, _sysio_fcompletio); if (!ioctxp) return IOID_FAIL; return ioctxp->ioctx_id; } /* - * API interface to accomplish asynch write from buf at current file offset. + * API interface to accomplish asynch write into buf from current file offset. */ ioid_t iwrite(int fd, const void *buf, size_t count) |
From: Ruth K. <rk...@us...> - 2003-10-14 23:39:47
|
Update of /cvsroot/libsysio/libsysio/drivers/incore In directory sc8-pr-cvs1:/tmp/cvs-serv28674/drivers/incore Modified Files: Tag: cplant fs_incore.c Log Message: Merge HEAD changes into cplant branch Index: fs_incore.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/incore/fs_incore.c,v retrieving revision 1.5.2.1 retrieving revision 1.5.2.2 diff -u -w -b -B -p -r1.5.2.1 -r1.5.2.2 --- fs_incore.c 20 Aug 2003 21:05:49 -0000 1.5.2.1 +++ fs_incore.c 14 Oct 2003 23:39:36 -0000 1.5.2.2 @@ -56,7 +56,9 @@ #include <sys/types.h> #include <dirent.h> #include <sys/stat.h> +#ifdef _HAVE_STATVFS #include <sys/statvfs.h> +#endif #include <sys/queue.h> #include "sysio.h" @@ -132,18 +134,18 @@ static int _sysio_incore_inop_setattr(st static ssize_t _sysio_incore_dirop_getdirentries(struct inode *ino, char *buf, size_t nbytes, - off64_t *basep); + _SYSIO_OFF_T *basep); static int _sysio_incore_dirop_mkdir(struct pnode *pno, mode_t mode); static int _sysio_incore_dirop_rmdir(struct pnode *pno); static int _sysio_incore_inop_open(struct pnode *pno, int flags, mode_t mode); static int _sysio_incore_inop_close(struct inode *ino); +static int _sysio_incore_dirop_link(struct pnode *old, struct pnode *new); static int _sysio_incore_dirop_unlink(struct pnode *pno); +static int _sysio_incore_dirop_rename(struct pnode *old, struct pnode *new); static int _sysio_incore_filop_ipreadv(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp); + struct ioctx *ioctx); static int _sysio_incore_filop_ipwritev(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp); + struct ioctx *ioctx); static int _sysio_incore_filop_iodone(struct ioctx *ioctx); static int _sysio_incore_filop_fcntl(struct inode *ino, int cmd, va_list ap); static int _sysio_incore_inop_sync(struct inode *ino); @@ -151,12 +153,13 @@ static int _sysio_incore_filop_ioctl(str unsigned long int request, va_list ap); static int _sysio_incore_dirop_mknod(struct pnode *pno, mode_t mode, dev_t dev); +#ifdef _HAVE_STATVFS static int _sysio_incore_inop_statvfs(struct pnode *pno, struct inode *ino, struct intnl_statvfs *buf); +#endif static void _sysio_incore_inop_gone(struct inode *ino); static int _sysio_incore_e_isdir(void); -static int _sysio_incore_e_notdir(void); static int _sysio_incore_e_inval(void); static int _sysio_incore_e_nosys(void); static void _sysio_incore_illop(void); @@ -167,12 +170,10 @@ static void _sysio_incore_illop(void); (int (*)(struct pnode *, char *, size_t))_sysio_incore_e_inval #define _sysio_incore_dirop_ipreadv \ (int (*)(struct inode *, \ - struct io_arguments *, \ - struct ioctx **))_sysio_incore_e_isdir + struct ioctx *))_sysio_incore_e_isdir #define _sysio_incore_dirop_ipwritev \ (int (*)(struct inode *, \ - struct io_arguments *, \ - struct ioctx **))_sysio_incore_e_isdir + struct ioctx *))_sysio_incore_e_isdir #define _sysio_incore_dirop_iodone \ (int (*)(struct ioctx *))_sysio_incore_illop #define _sysio_incore_dirop_fcntl \ @@ -193,7 +194,9 @@ static struct inode_ops _sysio_incore_di _sysio_incore_dirop_readlink, _sysio_incore_inop_open, _sysio_incore_inop_close, + _sysio_incore_dirop_link, _sysio_incore_dirop_unlink, + _sysio_incore_dirop_rename, _sysio_incore_dirop_ipreadv, _sysio_incore_dirop_ipwritev, _sysio_incore_dirop_iodone, @@ -202,7 +205,9 @@ static struct inode_ops _sysio_incore_di _sysio_incore_inop_sync, _sysio_incore_dirop_ioctl, _sysio_incore_dirop_mknod, +#ifdef _HAVE_STATVFS _sysio_incore_inop_statvfs, +#endif _sysio_incore_inop_gone }; @@ -210,24 +215,28 @@ static struct inode_ops _sysio_incore_di (int (*)(struct pnode *, \ struct inode **, \ struct intent *, \ - const char *))_sysio_incore_e_notdir + const char *))_sysio_incore_illop #define _sysio_incore_filop_getdirentries \ (ssize_t (*)(struct inode *, \ char *, \ size_t, \ - off64_t *))_sysio_incore_e_notdir + _SYSIO_OFF_T *))_sysio_incore_illop #define _sysio_incore_filop_mkdir \ - (int (*)(struct pnode *, mode_t))_sysio_incore_e_notdir + (int (*)(struct pnode *, mode_t))_sysio_incore_illop #define _sysio_incore_filop_rmdir \ - (int (*)(struct pnode *))_sysio_incore_e_notdir + (int (*)(struct pnode *))_sysio_incore_illop #define _sysio_incore_filop_symlink \ (int (*)(struct pnode *, const char *))_sysio_incore_illop #define _sysio_incore_symlinkop_readlink \ (int (*)(struct pnode *, char *, size_t))_sysio_incore_illop +#define _sysio_incore_filop_link \ + (int (*)(struct pnode *old, struct pnode *new))_sysio_incore_illop #define _sysio_incore_filop_unlink \ - (int (*)(struct pnode *pno))_sysio_incore_e_notdir + (int (*)(struct pnode *pno))_sysio_incore_illop +#define _sysio_incore_filop_rename \ + (int (*)(struct pnode *old, struct pnode *new))_sysio_incore_illop #define _sysio_incore_filop_mknod \ - (int (*)(struct pnode *pno, mode_t, dev_t))_sysio_incore_e_notdir + (int (*)(struct pnode *pno, mode_t, dev_t))_sysio_incore_illop static struct inode_ops _sysio_incore_file_ops = { _sysio_incore_filop_lookup, @@ -240,7 +249,9 @@ static struct inode_ops _sysio_incore_fi _sysio_incore_symlinkop_readlink, _sysio_incore_inop_open, _sysio_incore_inop_close, + _sysio_incore_filop_link, _sysio_incore_filop_unlink, + _sysio_incore_filop_rename, _sysio_incore_filop_ipreadv, _sysio_incore_filop_ipwritev, _sysio_incore_filop_iodone, @@ -249,7 +260,9 @@ static struct inode_ops _sysio_incore_fi _sysio_incore_inop_sync, _sysio_incore_filop_ioctl, _sysio_incore_filop_mknod, +#ifdef _HAVE_STATVFS _sysio_incore_inop_statvfs, +#endif _sysio_incore_inop_gone }; @@ -264,7 +277,9 @@ static struct inode_ops _sysio_incore_de _sysio_incore_symlinkop_readlink, _sysio_nodev_inop_open, _sysio_nodev_inop_close, + _sysio_incore_filop_link, _sysio_incore_filop_unlink, + _sysio_incore_filop_rename, _sysio_nodev_inop_ipreadv, _sysio_nodev_inop_ipwritev, _sysio_nodev_inop_iodone, @@ -273,7 +288,9 @@ static struct inode_ops _sysio_incore_de _sysio_nodev_inop_sync, _sysio_nodev_inop_ioctl, _sysio_incore_filop_mknod, +#ifdef _HAVE_STATVFS _sysio_incore_inop_statvfs, +#endif _sysio_incore_inop_gone }; @@ -309,7 +326,7 @@ struct lookup_data { */ #define INCORE_D_RECLEN(namlen) \ (((size_t )&((struct intnl_dirent *)0)->d_name + \ - (namlen) + sizeof(void *)) & \ + (namlen) + 1 + sizeof(void *)) & \ ~(sizeof(void *) - 1)) /* @@ -350,14 +367,30 @@ _sysio_incore_init() * Fill in the directory template. */ de = (struct intnl_dirent *)incore_dir_template; - de->d_off = off = de->d_reclen = INCORE_D_RECLEN(1); +#ifdef _DIRENT_HAVE_D_OFF + de->d_off = +#endif + off = de->d_reclen = INCORE_D_RECLEN(1); de->d_type = INCORE_D_TYPEOF(S_IFDIR); de->d_name[0] = '.'; - de = (void *)de + de->d_off; +#ifdef _DIRENT_HAVE_D_NAMLEN + de->d_namlen = 1; +#endif + /* + * Move to entry for `..' + */ + de = (void *)de + off; de->d_reclen = INCORE_D_RECLEN(2); - de->d_off = off += de->d_reclen; +#ifdef _DIRENT_HAVE_D_NAMLEN + de->d_namlen = 2; +#endif +#ifdef _DIRENT_HAVE_D_OFF + de->d_off = +#endif + off += de->d_reclen; de->d_type = INCORE_D_TYPEOF(S_IFDIR); de->d_name[0] = de->d_name[1] = '.'; + de->d_name[2] = ' '; return _sysio_fssw_register("incore", &incore_fssw_ops); } @@ -394,9 +427,9 @@ incore_i_alloc(struct incore_filesys *ic } static int -incore_trunc(struct incore_inode *icino, off64_t size, int clear) +incore_trunc(struct incore_inode *icino, _SYSIO_OFF_T size, int clear) { - off64_t n; + _SYSIO_OFF_T n; void *p; if (size < 0) @@ -464,7 +497,12 @@ incore_directory_new(struct incore_files sizeof(incore_dir_template)); de = icino->ici_data; de->d_ino = st->st_ino; - (void *)de += de->d_off; + (void *)de += +#ifdef _DIRENT_HAVE_D_OFF + de->d_off; +#else + de->d_reclen; +#endif de->d_ino = parent->ici_st.st_ino; /* @@ -682,7 +720,11 @@ _sysio_incore_fsop_gone(struct filesys * static void * incore_directory_probe(void *data, size_t siz, - off64_t origin, + _SYSIO_OFF_T origin +#ifndef _DIRENT_HAVE_D_OFF + __IS_UNUSED +#endif + , probe_ty entry, probe_ty hole, void *arg) @@ -693,15 +735,21 @@ incore_directory_probe(void *data, de = data; for (;;) { +#ifdef _DIRENT_HAVE_D_OFF assert(de->d_off); +#else + assert(de->d_reclen); +#endif if (entry && (p = (*entry)(de, de->d_reclen, arg))) return p; - n = de->d_off - origin; - if (hole && n > de->d_reclen) { - p = - (*hole)((void *)de + de->d_reclen, - n - de->d_reclen, - arg); + n = +#ifdef _DIRENT_HAVE_D_OFF + de->d_off - origin; +#else + ((void *)de - data) + de->d_reclen; +#endif + if (hole) { + p = (*hole)((void *)de, de->d_reclen, arg); if (p) return p; } @@ -719,7 +767,15 @@ incore_directory_match(struct intnl_dire struct lookup_data *ld) { - if (strncmp(de->d_name, ld->name->name, ld->name->len) == 0) +#if defined(BSD) || defined(REDSTORM) + if (IFTODT(de->d_type) == DT_WHT) + return NULL; +#endif + if ( +#ifdef _DIRENT_HAVE_D_NAMLEN + ld->name->len == de->d_namlen && +#endif + strncmp(de->d_name, ld->name->name, ld->name->len) == 0) return de; ld->de = de; return NULL; @@ -879,6 +935,13 @@ struct copy_info { size_t nbytes; }; +/* + * Eumeration callback. + * + * Note: + * On those systems supporting white-out entries, they are returned. On + * systems without, they are not. + */ static void * incore_directory_enumerate(struct intnl_dirent *de, size_t reclen, @@ -896,7 +959,7 @@ static ssize_t _sysio_incore_dirop_getdirentries(struct inode *ino, char *buf, size_t nbytes, - off64_t *basep) + _SYSIO_OFF_T *basep) { struct incore_inode *icino = I2IC(ino); off_t off; @@ -960,7 +1023,9 @@ incore_directory_insert(struct incore_in size_t reclen; struct lookup_data lookup_data; struct intnl_dirent *de; + size_t xt; size_t n; + size_t r; reclen = INCORE_D_RECLEN(name->len); INCORE_LD_INIT(&lookup_data, reclen, name); @@ -974,38 +1039,74 @@ incore_directory_insert(struct incore_in if (de) return -EEXIST; de = lookup_data.de; - n = de->d_off; - if (n >= (size_t )parent->ici_st.st_size) { + xt = (void *)lookup_data.de - parent->ici_data; + n = +#ifdef _DIRENT_HAVE_D_OFF + de->d_off; +#else + xt + de->d_reclen; +#endif + r = +#ifdef _DIRENT_HAVE_D_OFF + de->d_reclen; +#else + INCORE_D_RECLEN(de->d_namlen); +#endif + if (!parent->ici_st.st_size || + xt + r + reclen > (size_t )parent->ici_st.st_size) { int err; - size_t xt; - xt = (void *)lookup_data.de - parent->ici_data; - err = - incore_trunc(parent, - ((size_t )((void *)de - parent->ici_data) + - de->d_reclen + - reclen), - 1); + err = incore_trunc(parent, xt + r + reclen, 1); if (err) return err; de = parent->ici_data + xt; n = parent->ici_st.st_size; } +#ifdef _DIRENT_HAVE_D_OFF + de->d_off = xt + r; /* trim */ +#else + de->d_reclen = r; +#endif + (void *)de += r; /* reposition */ + xt += r; + +#ifndef _DIRENT_HAVE_D_OFF /* - * Fix previous entry. + * Will we split this hole or use all of it? */ - de->d_off = (void *)de - parent->ici_data + de->d_reclen; + if (lookup_data.hole.len - reclen && + lookup_data.hole.len - reclen <= INCORE_D_RECLEN(1)) + reclen = lookup_data.hole.len; +#endif /* * Insert new. */ - (void *)de += de->d_reclen; de->d_ino = inum; +#ifdef _DIRENT_HAVE_D_OFF de->d_off = n; +#endif de->d_reclen = reclen; de->d_type = type; (void )memcpy(de->d_name, name->name, name->len); +#ifdef _DIRENT_HAVE_D_NAMLEN + de->d_namlen = name->len; +#endif + +#ifndef _DIRENT_HAVE_D_OFF + xt += reclen; + if (n - xt) { + /* + * White-out remaining part of the hole. + */ + (void *)de += reclen; + de->d_ino = 0; + de->d_reclen = n - xt; + de->d_type = DT_WHT; + de->d_namlen = 0; + } +#endif /* * Update attributes to reflect the new entry. @@ -1095,6 +1196,10 @@ incore_unlink_entry(struct incore_inode { struct lookup_data lookup_data; struct intnl_dirent *de; + size_t reclen; +#ifdef _DIRENT_HAVE_D_OFF + size_t off; +#endif if (!S_ISDIR(icino->ici_st.st_mode)) return -ENOTDIR; @@ -1111,8 +1216,37 @@ incore_unlink_entry(struct incore_inode return -ENOENT; assert((size_t )((void *)de - icino->ici_data) >= sizeof(incore_dir_template)); - lookup_data.de->d_off = de->d_off; /* unlink */ - (void )memset(de, 0, de->d_reclen); /* clear */ +#ifndef _DIRENT_HAVE_D_OFF + reclen = de->d_reclen; +#else + off = de->d_off; + reclen = off - ((void *)de - icino->ici_data); +#endif + (void )memset(de, 0, reclen); +#ifndef _DIRENT_HAVE_D_OFF + de->d_type = (__uint8_t )DTTOIF(DT_WHT); + de->d_reclen = reclen; +#else + lookup_data.de->d_off = off; +#endif + + /* + * Adjust link count. + */ + assert(icino->ici_st.st_nlink > 2); + icino->ici_st.st_nlink--; + + /* + * Adjust link count. + */ + assert(icino->ici_st.st_nlink > 2); + icino->ici_st.st_nlink--; + + /* + * Adjust link count. + */ + assert(icino->ici_st.st_nlink > 2); + icino->ici_st.st_nlink--; return 0; } @@ -1145,6 +1279,12 @@ _sysio_incore_dirop_rmdir(struct pnode * return err; I_RELE(ino); + /* + * Adjust link count. + */ + assert(icino->ici_st.st_nlink > 2); + icino->ici_st.st_nlink--; + return 0; } @@ -1242,6 +1382,94 @@ _sysio_incore_inop_close(struct inode *i } static int +_sysio_incore_dirop_link(struct pnode *old, struct pnode *new) +{ + struct incore_inode *icino = I2IC(old->p_base->pb_ino); + int err; + + assert(!new->p_base->pb_ino); + assert(!S_ISDIR(old->p_base->pb_ino->i_mode)); + + /* + * Can bump the link count? + */ + if (!(icino->ici_st.st_nlink + 1)) + return -EMLINK; + /* + * Insert into parent. + */ + err = + incore_directory_insert(I2IC(new->p_parent->p_base->pb_ino), + &new->p_base->pb_name, + icino->ici_st.st_ino, + INCORE_D_TYPEOF(icino->ici_st.st_mode)); + if (err) + return err; + /* + * Bump the link count. + */ + icino->ici_st.st_nlink++; + + return 0; +} + +static int +_sysio_incore_dirop_rename(struct pnode *old, struct pnode *new) +{ + int err; + struct incore_inode *icino = I2IC(old->p_base->pb_ino); + + if (new->p_base->pb_ino) { + /* + * Have to kill off the target first. + */ + if (S_ISDIR(I2IC(new->p_base->pb_ino)->ici_st.st_mode) && + I2IC(new->p_base->pb_ino)->ici_st.st_nlink > 2) + return -ENOTEMPTY; + err = + incore_unlink_entry(I2IC(new->p_parent->p_base->pb_ino), + &new->p_base->pb_name); + if (err) + return err; + I_RELE(new->p_base->pb_ino); + _sysio_i_gone(new->p_base->pb_ino); + new->p_base->pb_ino = NULL; + } + + /* + * Insert into new parent. + */ + err = + incore_directory_insert(I2IC(new->p_parent->p_base->pb_ino), + &new->p_base->pb_name, + icino->ici_st.st_ino, + INCORE_D_TYPEOF(icino->ici_st.st_mode)); + if (err) + abort(); + /* + * Remove from the old parent. + */ + err = + incore_unlink_entry(I2IC(old->p_parent->p_base->pb_ino), + &old->p_base->pb_name); + if (err) + abort(); + + if (S_ISDIR(icino->ici_st.st_mode)) { + struct intnl_dirent *de; + + /* + * We moved a directory. The entry for `..' must be corrected. + */ + de = icino->ici_data; + de++; + assert(strcmp(de->d_name, "..") == 0); + de->d_ino = I2IC(new->p_parent->p_base->pb_ino)->ici_st.st_ino; + } + return 0; +} + +static int _sysio_incore_dirop_unlink(struct pnode *pno) { struct inode *ino = pno->p_base->pb_ino; @@ -1251,7 +1479,6 @@ _sysio_incore_dirop_unlink(struct pnode if (S_ISDIR(icino->ici_st.st_mode)) return -EISDIR; - pno->p_base->pb_ino = NULL; err = incore_unlink_entry(I2IC(pno->p_parent->p_base->pb_ino), &pno->p_base->pb_name); @@ -1265,18 +1492,12 @@ _sysio_incore_dirop_unlink(struct pnode static int incore_doio(ssize_t (*f)(struct incore_inode *, off_t, char *, size_t), struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp) + struct ioctx *ioctx) { - struct ioctx *ioctx; const struct iovec *iov; size_t n; ssize_t cc = 0; - ioctx = _sysio_ioctx_new(ino, ioargs); - if (!ioctx) - return -ENOMEM; - iov = ioctx->ioctx_iovec; for (n = ioctx->ioctx_iovlen, iov = ioctx->ioctx_iovec; n--; @@ -1297,18 +1518,17 @@ incore_doio(ssize_t (*f)(struct incore_i ioctx->ioctx_errno = -cc; } - *ioctxp = ioctx; return 0; } static ssize_t incore_read(struct incore_inode *icino, off_t off, char *buf, size_t nbytes) { - off64_t n; + _SYSIO_OFF_T n; if (!nbytes || off > icino->ici_st.st_size) return 0; - n = (off64_t )nbytes; + n = (_SYSIO_OFF_T )nbytes; if (!(n > 0 && (size_t )n == nbytes)) return -EINVAL; if (n > icino->ici_st.st_size - off) @@ -1320,11 +1540,10 @@ incore_read(struct incore_inode *icino, static int _sysio_incore_filop_ipreadv(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp) + struct ioctx *ioctx) { - return incore_doio(incore_read, ino, ioargs, ioctxp); + return incore_doio(incore_read, ino, ioctx); } static ssize_t @@ -1334,11 +1553,11 @@ incore_write(struct incore_inode *icino, size_t nbytes) { int err; - off64_t n; + _SYSIO_OFF_T n; if (!nbytes) return 0; - n = (off64_t )nbytes; + n = (_SYSIO_OFF_T )nbytes; if (!(n > 0 && (size_t )n == nbytes)) return -EINVAL; if (off + n > icino->ici_st.st_size) { @@ -1353,8 +1572,7 @@ incore_write(struct incore_inode *icino, static int _sysio_incore_filop_ipwritev(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp) + struct ioctx *ioctx) { return incore_doio((ssize_t (*)(struct incore_inode *, @@ -1362,8 +1580,7 @@ _sysio_incore_filop_ipwritev(struct inod char *, size_t))incore_write, ino, - ioargs, - ioctxp); + ioctx); } static int @@ -1430,7 +1647,7 @@ _sysio_incore_dirop_mknod(struct pnode * return -EINVAL; /* - * Must create a new, regular, file. + * Initialize attributes. */ (void )memset(&stat, 0, sizeof(stat)); stat.st_dev = pno->p_parent->p_base->pb_ino->i_fs->fs_dev; @@ -1452,6 +1669,7 @@ _sysio_incore_dirop_mknod(struct pnode * return incore_create(pno, &stat); } +#ifdef _HAVE_STATVFS static int _sysio_incore_inop_statvfs(struct pnode *pno, struct inode *ino, @@ -1472,7 +1690,8 @@ _sysio_incore_inop_statvfs(struct pnode */ buf->f_bsize = fs->fs_bsize; buf->f_frsize = buf->f_bsize; - buf->f_blocks = (0xffffffffffffffff - 1) / buf->f_bsize; + buf->f_blocks = ~0; + buf->f_blocks /= buf->f_bsize; buf->f_bfree = buf->f_blocks - 1; buf->f_bavail = buf->f_bfree; buf->f_files = buf->f_blocks; @@ -1488,6 +1707,7 @@ _sysio_incore_inop_statvfs(struct pnode return 0; } +#endif void _sysio_incore_inop_gone(struct inode *ino) @@ -1502,13 +1722,6 @@ _sysio_incore_e_isdir(void) { return -EISDIR; -} - -static int -_sysio_incore_e_notdir(void) -{ - - return -ENOTDIR; } static int |
From: Ruth K. <rk...@us...> - 2003-10-14 23:39:46
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs1:/tmp/cvs-serv28674/drivers/native Modified Files: Tag: cplant fs_native.c Log Message: Merge HEAD changes into cplant branch Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.16.2.1 retrieving revision 1.16.2.2 diff -u -w -b -B -p -r1.16.2.1 -r1.16.2.2 --- fs_native.c 20 Aug 2003 21:05:49 -0000 1.16.2.1 +++ fs_native.c 14 Oct 2003 23:39:36 -0000 1.16.2.2 @@ -57,8 +57,12 @@ #include <sys/types.h> #include <sys/stat.h> #include <sys/fcntl.h> +#if 0 #include <sys/vfs.h> +#endif +#ifdef _HAVE_STATVFS #include <sys/statvfs.h> +#endif #include <utime.h> #include <sys/queue.h> @@ -69,6 +73,21 @@ #include "fs_native.h" +#ifdef REDSTORM +#include <catamount/syscall.h> /* ! in sys include? */ +#endif + +#ifdef REDSTORM +/* + * The cnos IO routines on Red Storm can't do scatter/gather IO. We + * must use a different interface, then. The doio() routine will loop + * over the vector entries. + */ +typedef ssize_t (*iof)(int, void *, size_t, _SYSIO_OFF_T); +#else +typedef ssize_t (*iof)(int, const struct iovec *, int); +#endif + /* * Local host file system driver. */ @@ -126,18 +145,15 @@ do { #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) -#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 @@ -200,20 +216,20 @@ static int native_inop_setattr(struct pn static ssize_t native_getdirentries(struct inode *ino, char *buf, size_t nbytes, - off64_t *basep); + _SYSIO_OFF_T *basep); static int native_inop_mkdir(struct pnode *pno, mode_t mode); static int native_inop_rmdir(struct pnode *pno); static int native_inop_symlink(struct pnode *pno, const char *data); 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); + struct ioctx *ioctx); static int native_inop_ipwritev(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp); + struct ioctx *ioctx); static int native_inop_iodone(struct ioctx *ioctx); static int native_inop_fcntl(struct inode *ino, int cmd, va_list ap); static int native_inop_sync(struct inode *ino); @@ -222,9 +238,11 @@ static int native_inop_ioctl(struct inod unsigned long int request, va_list ap); static int native_inop_mknod(struct pnode *pno, mode_t mode, dev_t dev); +#ifdef _HAVE_STATVFS static int native_inop_statvfs(struct pnode *pno, struct inode *ino, struct intnl_statvfs *buf); +#endif static void native_inop_gone(struct inode *ino); static struct inode_ops native_i_ops = { @@ -238,7 +256,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, @@ -247,7 +267,9 @@ static struct inode_ops native_i_ops = { native_inop_datasync, native_inop_ioctl, native_inop_mknod, +#ifdef _HAVE_STATVFS native_inop_statvfs, +#endif native_inop_gone }; @@ -264,7 +286,7 @@ static struct fssw_ops native_fssw_ops = static void native_fsop_gone(struct filesys *fs); static struct filesys_ops native_inodesys_ops = { - native_fsop_gone, + native_fsop_gone }; /* @@ -832,30 +854,92 @@ out: return err; } +static int +native_pos(int fd, +#if _LARGEFILE64_SOURCE + loff_t *offset +#else + _SYSIO_OFF_T *offset +#endif + ) +{ + + assert(fd >= 0); + assert(*offset >= 0); + +#if _LARGEFILE64_SOURCE && defined(SYS__llseek) + { + int err; + err = + syscall(SYS__llseek, + (unsigned int)fd, + (unsigned int)(*offset >> 32), + (unsigned int)*offset, + offset, + SEEK_SET); + if (err == -1) + return -errno; + } +#else + *offset = + syscall(SYS_lseek, + fd, + *offset, + SEEK_SET); + if (*offset == -1) + return -errno; +#endif + + return 0; +} + + static ssize_t native_getdirentries(struct inode *ino, char *buf, size_t nbytes, - off64_t *basep) + _SYSIO_OFF_T *basep) { struct native_inode *nino = I2NI(ino); + int err; +#ifndef SYS_getdirentries +#if _LARGEFILE64_SOURCE loff_t result; +#else + _SYSIO_OFF_T result; +#endif +#endif ssize_t cc; assert(nino->ni_fd >= 0); +#ifndef SYS_getdirentries result = *basep; - if (*basep != nino->ni_fpos && - CALL_LSEEK(nino->ni_fd, - *basep, - result, - SEEK_SET) == -1) - return -errno; + if (*basep != nino->ni_fpos) { + err = native_pos(nino->ni_fd, &result); + if (err) + return err; + } nino->ni_fpos = result; - cc = syscall(__SYS_GETDENTS, nino->ni_fd, buf, nbytes); +#ifdef SYS_getdents64 + cc = syscall(SYS_getdents64, nino->ni_fd, buf, nbytes); +#else + cc = syscall(SYS_getdents, nino->ni_fd, buf, nbytes); +#endif +#else /* defined(SYS_getdirentries) */ + cc = + syscall(SYS_getdirentries, + nino->ni_fd, + buf, + nbytes, + basep, + &nino->ni_fpos); +#endif /* !defined(SYS_getdirentries) */ if (cc < 0) return -errno; +#ifndef SYS_getdirentries nino->ni_fpos += cc; +#endif return cc; } @@ -1019,6 +1103,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; @@ -1053,30 +1163,32 @@ native_inop_unlink(struct pnode *pno) * now. */ static int -doio(ssize_t (*f)(int, const struct iovec *, int), +doio(iof f, struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp) + struct ioctx *ioctx) { struct native_inode *nino = I2NI(ino); - struct ioctx *ioctx; +#ifndef REDSTORM +#if _LARGEFILE64_SOURCE loff_t result; +#else + _SYSIO_OFF_T result; +#endif +#endif assert(nino->ni_fd >= 0); - if (ioargs->ioarg_iovlen && (int )ioargs->ioarg_iovlen < 0) + if ((ioctx->ioctx_iovlen && (int )ioctx->ioctx_iovlen < 0) || + !(S_ISREG(ino->i_mode) || + S_ISCHR(ino->i_mode) || + S_ISSOCK(ino->i_mode) || + S_ISFIFO(ino->i_mode))) return -EINVAL; - /* - * Get a new IO context. - */ - ioctx = _sysio_ioctx_new(ino, ioargs); - if (!ioctx) - return -ENOMEM; - +#ifndef REDSTORM /* * This implementation first positions the real system descriptor, then - * performs the operation. This is silly because it's not atomic. + * performs the operation. This is not atomic. * * An alternative, more complex, less efficient but atomic, * implementation might consider each entry of the iovec separately. @@ -1086,71 +1198,138 @@ doio(ssize_t (*f)(int, const struct iove * Avoid the reposition call if we're already at the right place. * Allows us to access pipes and fifos. */ - result = nino->ni_fpos; - if (ioctx->ioctx_offset != nino->ni_fpos && - !(S_ISCHR(ino->i_mode) || - S_ISSOCK(ino->i_mode) || - S_ISFIFO(ino->i_mode)) && - CALL_LSEEK(nino->ni_fd, - ioctx->ioctx_offset, - result, - SEEK_SET) == -1) { + result = ioctx->ioctx_offset; + if (ioctx->ioctx_offset != nino->ni_fpos) { + int err; + + err = native_pos(nino->ni_fd, &result); + if (err) { ioctx->ioctx_cc = -1; - ioctx->ioctx_errno = errno; - } else { + ioctx->ioctx_errno = -err; + goto out; + } + nino->ni_fpos = result; + } +#endif + /* * Call the appropriate (read/write) IO function to * transfer the data now. */ - nino->ni_fpos = result; +#ifdef REDSTORM + { + size_t count = ioctx->ioctx_iovlen; + struct iovec *iov = ioctx->ioctx_iovec; + ssize_t cc; + + while (count) { + cc = + (*f)(nino->ni_fd, + iov->base, + iov->len, + nino->ni_fpos); + if (cc < 0) { + if (ioctx->ioctx_cc) { + /* + * No data written at all. Return + * error. + */ + ioctx->ioctx_cc = -1; + } + break; + } + count--, iov++; + } + } +#else /* !defined(REDSTORM) */ ioctx->ioctx_cc = (*f)(nino->ni_fd, ioctx->ioctx_iovec, ioctx->ioctx_iovlen); +#endif /* defined(REDSTORM) */ if (ioctx->ioctx_cc < 0) ioctx->ioctx_errno = errno; if (ioctx->ioctx_cc > 0) nino->ni_fpos += ioctx->ioctx_cc; - } - *ioctxp = ioctx; +out: return 0; } /* * Helper function passed to doio(), above, to accomplish a real readv. */ +#ifdef REDSTORM +static ssize_t +native_read(int fd, void *buf, size_t count, _SYSIO_OFF_T offset) +{ + + return syscall(SYS_pread, fd, buf, count, offset); +} +#else static ssize_t -_readv(int fd, const struct iovec *vector, int count) +native_read(int fd, const struct iovec *vector, int count) { return syscall(SYS_readv, fd, vector, count); } +#endif + +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 native_inop_ipreadv(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp) + struct ioctx *ioctx) { - return doio(_readv, ino, ioargs, ioctxp); + return doio(native_read, ino, ioctx); } /* * Helper function passed to doio(), above, to accomplish a real writev. */ +#ifdef REDSTORM +static ssize_t +native_write(int fd, void *buf, size_t count, _SYSIO_OFF_T offset) +{ + + return syscall(SYS_pwrite, fd, buf, count, offset); +} +#else static ssize_t -_writev(int fd, const struct iovec *vector, int count) +native_write(int fd, const struct iovec *vector, int count) { return syscall(SYS_writev, fd, vector, count); } +#endif static int native_inop_ipwritev(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp) + struct ioctx *ioctx) { - return doio(_writev, ino, ioargs, ioctxp); + return doio(native_write, ino, ioctx); } static int @@ -1185,6 +1364,7 @@ native_inop_mknod(struct pnode *pno __IS return -ENOSYS; } +#ifdef _HAVE_STATVFS static int native_inop_statvfs(struct pnode *pno, struct inode *ino, @@ -1235,6 +1415,7 @@ native_inop_statvfs(struct pnode *pno, buf->f_namemax = fs.f_namelen; return 0; } +#endif static int native_inop_sync(struct inode *ino) @@ -1251,7 +1432,14 @@ native_inop_datasync(struct inode *ino) assert(I2NI(ino)->ni_fd >= 0); - return syscall(__SYS_FDATASYNC, I2NI(ino)->ni_fd); +#ifdef NATIVE_FDATASYNC + return syscall(NATIVE_FDATASYNC, I2NI(ino)->ni_fd); +#else +#if 0 +#warning No fdatasync system call -- Using fsync instead! +#endif + return syscall(SYS_fsync, I2NI(ino)->ni_fd); +#endif } static int |
From: Ruth K. <rk...@us...> - 2003-10-14 23:39:46
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1:/tmp/cvs-serv28674/tests Modified Files: Tag: cplant Makefile.am Log Message: Merge HEAD changes into cplant branch Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Makefile.am,v retrieving revision 1.12.2.3 retrieving revision 1.12.2.4 diff -u -w -b -B -p -r1.12.2.3 -r1.12.2.4 --- Makefile.am 9 Oct 2003 15:04:10 -0000 1.12.2.3 +++ Makefile.am 14 Oct 2003 23:39:36 -0000 1.12.2.4 @@ -36,6 +36,7 @@ endif if WITH_CPLANT_YOD YOD_DRIVER_NAME=yod YOD_DRIVER_CFLAGS= -DCPLANT_YOD +YOD_DRIVER_LIB=$(top_builddir)/drivers/yod/libsysio_yod.a else YOD_DRIVER_NAME= YOD_DRIVER_CFLAGS= @@ -107,7 +108,7 @@ test_driver_CFLAGS=$(CFL) test_driver_LDADD=$(LIBS) test_driver_DEPENDENCIES=$(LIBS) -EXTRA_DIST=gendrvdata.sh test.h test_driver.h +EXTRA_DIST=$(shell ls *.pl *.pm) gendrvdata.sh test.h test_driver.h drv_data.c: $(CONFIG_DEPENDENCIES) $(top_srcdir)/tests/gendrvdata.sh test -z "drv_data.c" && rm -f drv_data.c; \ |
From: Ruth K. <rk...@us...> - 2003-10-14 23:39:46
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs1:/tmp/cvs-serv28674/include Modified Files: Tag: cplant cplant-yod.h dev.h file.h inode.h sysio.h Log Message: Merge HEAD changes into cplant branch Index: cplant-yod.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/cplant-yod.h,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -u -w -b -B -p -r1.2 -r1.2.4.1 --- cplant-yod.h 14 Aug 2003 18:39:33 -0000 1.2 +++ cplant-yod.h 14 Oct 2003 23:39:36 -0000 1.2.4.1 @@ -48,14 +48,17 @@ extern int chmod_yod(const char* path, m extern int chown_yod(const char* path, uid_t, gid_t); extern int stat_yod(const char *path, struct stat *sbuf); extern int fstat_yod(int fd, struct stat *buf); +#ifdef _HAVE_STATVFS extern int statfs_yod(const char *path, struct statfs *sbuf); extern int fstatfs_yod(int fd, struct statfs *buf); +#endif extern int mkdir_yod(const char *path, mode_t mode); extern int rmdir_yod(const char *path); extern int getdirentries_yod(int fd, char *buf, size_t nbytes, loff_t *basep); extern int link_yod(const char *path1, const char *path2); extern int unlink_yod(const char *path); extern int symlink_yod(const char *path1, const char *path2 ); +extern int rename_yod( const char *path1, const char *path2 ); extern int open_yod(const char *fname, int flags, mode_t mode); extern int close_yod(int); extern ssize_t write_yod(int fd, const void *buff, size_t nbytes); Index: dev.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/dev.h,v retrieving revision 1.2 retrieving revision 1.2.10.1 diff -u -w -b -B -p -r1.2 -r1.2.10.1 --- dev.h 24 Mar 2003 22:09:04 -0000 1.2 +++ dev.h 14 Oct 2003 23:39:36 -0000 1.2.10.1 @@ -70,71 +70,75 @@ extern const struct inode_ops _sysio_nod (int (*)(struct pnode *, \ struct inode **, \ struct intent *, \ - const char *))_sysio_dev_e_notdir + const char *))_sysio_dev_illop #define _sysio_nodev_inop_getattr \ (int (*)(struct pnode *, \ struct inode *, \ - struct intnl_stat *))_sysio_dev_e_badf + struct intnl_stat *))_sysio_dev_illop #define _sysio_nodev_inop_setattr \ (int (*)(struct pnode *, \ struct inode *, \ unsigned , \ - struct intnl_stat *))_sysio_dev_e_badf + struct intnl_stat *))_sysio_dev_illop #define _sysio_nodev_getdirentries \ (ssize_t (*)(struct inode *, \ char *, \ size_t , \ - off64_t *))_sysio_dev_e_notdir + _SYSIO_OFF_T *))_sysio_dev_illop #define _sysio_nodev_inop_mkdir \ (int (*)(struct pnode *, \ - mode_t))_sysio_dev_e_notdir + mode_t))_sysio_dev_illop #define _sysio_nodev_inop_rmdir \ - (int (*)(struct pnode *))_sysio_dev_e_notdir + (int (*)(struct pnode *))_sysio_dev_illop #define _sysio_nodev_inop_symlink \ (int (*)(struct pnode *, \ - const char *))_sysio_dev_e_notdir + const char *))_sysio_dev_illop #define _sysio_nodev_inop_readlink \ (int (*)(struct pnode *, \ char *, \ - size_t))_sysio_dev_e_inval + size_t))_sysio_dev_illop #define _sysio_nodev_inop_open \ (int (*)(struct pnode *, \ int, \ - mode_t))_sysio_dev_e_nxio + mode_t))_sysio_dev_illop #define _sysio_nodev_inop_close \ - (int (*)(struct inode *))_sysio_dev_e_badf + (int (*)(struct inode *))_sysio_dev_illop +#define _sysio_nodev_inop_link \ + (int (*)(struct pnode *, struct pnode *))_sysio_dev_illop #define _sysio_nodev_inop_unlink \ - (int (*)(struct pnode *))_sysio_dev_e_notdir + (int (*)(struct pnode *))_sysio_dev_illop +#define _sysio_nodev_inop_rename \ + (int (*)(struct pnode *, struct pnode *))_sysio_dev_illop #define _sysio_nodev_inop_ipreadv \ (int (*)(struct inode *, \ - struct io_arguments *, \ - struct ioctx **))_sysio_dev_e_inval + struct ioctx *))_sysio_dev_illop #define _sysio_nodev_inop_ipwritev \ (int (*)(struct inode *, \ - struct io_arguments *, \ - struct ioctx **))_sysio_dev_e_inval + struct ioctx *))_sysio_dev_illop #define _sysio_nodev_inop_iodone \ - (int (*)(struct ioctx *))_sysio_dev_e_illop + (int (*)(struct ioctx *))_sysio_dev_illop #define _sysio_nodev_inop_fcntl \ (int (*)(struct inode *, \ int, \ - va_list))_sysio_dev_e_inval + va_list))_sysio_dev_illop #define _sysio_nodev_inop_sync \ - (int (*)(struct inode *))_sysio_dev_e_inval + (int (*)(struct inode *))_sysio_dev_illop #define _sysio_nodev_inop_datasync \ - (int (*)(struct inode *))_sysio_dev_e_inval + (int (*)(struct inode *))_sysio_dev_illop #define _sysio_nodev_inop_ioctl \ (int (*)(struct inode *, \ unsigned long int, \ - va_list))_sysio_dev_e_notty + va_list))_sysio_dev_illop #define _sysio_nodev_inop_mknod \ (int (*)(struct pnode *, \ mode_t, \ - dev_t))_sysio_dev_e_notdir + dev_t))_sysio_dev_illop +#ifdef _HAVE_STATVFS #define _sysio_nodev_inop_statvfs \ (int (*)(struct pnode *, \ struct inode *, \ - struct intnl_statvfs *))_sysio_dev_e_inval + struct intnl_statvfs *))_sysio_dev_illop +#endif #define _sysio_nodev_inop_gone \ (void (*)(struct inode *ino))_sysio_dev_noop @@ -144,10 +148,5 @@ extern struct inode_ops *_sysio_dev_look extern int _sysio_char_dev_register(int major, const char *name, struct inode_ops *ops); -extern int _sysio_dev_e_notdir(void); -extern int _sysio_dev_e_badf(void); -extern int _sysio_dev_e_inval(void); -extern int _sysio_dev_e_nxio(void); -extern int _sysio_dev_e_illop(void); -extern int _sysio_dev_e_notty(void); +extern int _sysio_dev_illop(void); extern void _sysio_dev_noop(void); Index: file.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/file.h,v retrieving revision 1.5 retrieving revision 1.5.10.1 diff -u -w -b -B -p -r1.5 -r1.5.10.1 --- file.h 24 Mar 2003 22:09:05 -0000 1.5 +++ file.h 14 Oct 2003 23:39:36 -0000 1.5.10.1 @@ -52,7 +52,7 @@ */ struct file { struct inode *f_ino; /* path node */ - off64_t f_pos; /* current stream pos */ + _SYSIO_OFF_T f_pos; /* current stream pos */ unsigned f_ref; /* ref count */ int f_flags; /* open/fcntl flags */ }; @@ -92,7 +92,7 @@ struct ioctx; extern struct file *_sysio_fnew(struct inode *ino, int flags); extern void _sysio_fgone(struct file *fil); -extern void _sysio_fcompletio(struct ioctx *ioctx); +extern void _sysio_fcompletio(struct ioctx *ioctx, struct file *fil); extern int _sysio_fd_close(int fd); extern struct file *_sysio_fd_find(int fd); extern int _sysio_fd_set(struct file *fil, int fd); Index: inode.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/inode.h,v retrieving revision 1.7.2.1 retrieving revision 1.7.2.2 diff -u -w -b -B -p -r1.7.2.1 -r1.7.2.2 --- inode.h 28 Aug 2003 13:43:09 -0000 1.7.2.1 +++ inode.h 14 Oct 2003 23:39:36 -0000 1.7.2.2 @@ -63,7 +63,9 @@ struct inode; struct intent; struct intnl_dirent; struct intnl_stat; +#ifdef _HAVE_STATVFS struct intnl_statvfs; +#endif struct io_arguments; struct ioctx; @@ -87,29 +89,29 @@ struct inode_ops { ssize_t (*inop_getdirentries)(struct inode *ino, char *buf, size_t nbytes, - off64_t *basep); + _SYSIO_OFF_T *basep); int (*inop_mkdir)(struct pnode *pno, mode_t mode); int (*inop_rmdir)(struct pnode *pno); int (*inop_symlink)(struct pnode *pno, const char *data); int (*inop_readlink)(struct pnode *pno, char *buf, size_t bufsiz); int (*inop_open)(struct pnode *pno, int flags, mode_t mode); int (*inop_close)(struct inode *ino); + int (*inop_link)(struct pnode *old, struct pnode *new); int (*inop_unlink)(struct pnode *pno); - int (*inop_ipreadv)(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp); - int (*inop_ipwritev)(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp); + int (*inop_rename)(struct pnode *old, struct pnode *new); + int (*inop_ipreadv)(struct inode *ino, struct ioctx *ioctx); + int (*inop_ipwritev)(struct inode *ino, struct ioctx *ioctx); int (*inop_iodone)(struct ioctx *iocp); int (*inop_fcntl)(struct inode *ino, int cmd, va_list ap); int (*inop_sync)(struct inode *ino); int (*inop_datasync)(struct inode *ino); int (*inop_ioctl)(struct inode *ino, unsigned long int request, va_list ap); int (*inop_mknod)(struct pnode *pno, mode_t mode, dev_t dev); +#ifdef _HAVE_STATVFS int (*inop_statvfs)(struct pnode *pno, struct inode *ino, struct intnl_statvfs *buf); +#endif void (*inop_gone)(struct inode *ino); }; @@ -341,46 +343,48 @@ struct nameidata { } while (0) /* - * Bundled up arguments to file system driver IO calls. + * IO completion callback record. */ -struct io_arguments { - const struct iovec *ioarg_iovec; /* io vector */ - size_t ioarg_iovlen; /* iovec length */ - off64_t ioarg_offset; /* beginning offset */ - void (*ioarg_completion)(void *); /* callback */ - void *ioarg_completion_arg; /* callback data */ +struct ioctx_callback { + TAILQ_ENTRY(ioctx_callback) iocb_next; /* list link */ + void (*iocb_f)(struct ioctx *, void *); /* cb func */ + void *iocb_data; /* cb data */ }; /* - * Init IO arguments bundle. - */ -#define IOARG_INIT(ioarg, iov, len, off, cb, data) \ - do { \ - (ioarg)->ioarg_iovec = (iov); \ - (ioarg)->ioarg_iovlen = (len); \ - (ioarg)->ioarg_offset = (off); \ - (ioarg)->ioarg_completion = (cb); \ - (ioarg)->ioarg_completion_arg = (data); \ - } while (0) - -/* * All IO internally is done with an asynchronous mechanism. This record * holds the completion information. It's too big :-( */ struct ioctx { LIST_ENTRY(ioctx) ioctx_link; /* AIO list link */ + unsigned + ioctx_fast : 1; /* from stack space */ ioid_t ioctx_id; /* unique ident */ struct inode *ioctx_ino; /* i-node */ const struct iovec *ioctx_iovec; /* scatter/gather vec */ size_t ioctx_iovlen; /* iovec length */ - off64_t ioctx_offset; /* file offset */ + _SYSIO_OFF_T ioctx_offset; /* file offset */ ssize_t ioctx_cc; /* rtn char count */ int ioctx_errno; /* error number */ - void (*ioctx_cb)(void *); /* callback */ - void *ioctx_data; /* callback data */ + TAILQ_HEAD(, ioctx_callback) ioctx_cbq; /* error number */ }; /* + * Init IO context record. + */ +#define IOCTX_INIT(ioctx, fast, id, ino, iov, iovlen, off) \ + do { \ + (ioctx)->ioctx_fast = (fast); \ + (ioctx)->ioctx_id = (id); \ + (ioctx)->ioctx_ino = (ino); \ + (ioctx)->ioctx_iovec = (iov); \ + (ioctx)->ioctx_iovlen = (iovlen); \ + (ioctx)->ioctx_offset = (off); \ + (ioctx)->ioctx_cc = 0; \ + (ioctx)->ioctx_errno = 0; \ + TAILQ_INIT(&(ioctx)->ioctx_cbq); \ + } while (0) +/* * Return whether a pnode/inode is on a read-only mount or file system. */ #define IS_RDONLY(pno, ino) \ @@ -441,9 +445,15 @@ extern int _sysio_namei(struct pnode *pn unsigned flags, struct intent *intnt, struct pnode **pnop); +extern int _sysio_p_chdir(struct pnode *pno); extern int _sysio_ioctx_init(void); extern struct ioctx *_sysio_ioctx_new(struct inode *ino, - struct io_arguments *ioargs); + const struct iovec *iov, + size_t iovlen, + _SYSIO_OFF_T offset); +extern int _sysio_ioctx_cb(struct ioctx *ioctx, + void (*f)(struct ioctx *, void *), + void *data); extern struct ioctx *_sysio_ioctx_find(ioid_t id); extern ssize_t _sysio_ioctx_wait(struct ioctx *ioctx); extern void _sysio_ioctx_complete(struct ioctx *ioctx); Index: sysio.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/sysio.h,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -u -w -b -B -p -r1.8 -r1.8.2.1 --- sysio.h 29 Jul 2003 19:53:33 -0000 1.8 +++ sysio.h 14 Oct 2003 23:39:36 -0000 1.8.2.1 @@ -79,11 +79,27 @@ typedef void *ioid_t; #define MAX_SYMLINK 250 #endif +#ifndef __USE_LARGEFILE64 +/* + * Not glibc. Define this ourselves. + */ +#define __USE_LARGEFILE64 0 +#endif + +/* + * Define internal file-offset type. + */ +#if __USE_LARGEFILE64 +#define _SYSIO_OFF_T off64_t +#else +#define _SYSIO_OFF_T off_t +#endif + /* * Internally, all directory entries are carried in the 64-bit capable * structure. */ -#ifdef _LARGEFILE64_SOURCE +#if __USE_LARGEFILE64 #define intnl_dirent dirent64 #else #define intnl_dirent dirent @@ -94,22 +110,28 @@ struct dirent; * Internally, all file status is carried in the 64-bit capable * structure. */ -#ifdef _LARGEFILE64_SOURCE +#if __USE_LARGEFILE64 #define intnl_stat stat64 #else #define intnl_stat stat #endif struct stat; -#ifdef _LARGEFILE64_SOURCE +#ifdef _HAVE_STATVFS +#if __USE_LARGEFILE64 #define intnl_statvfs statvfs64 #else #define intnl_statvfs statvfs #define INTNL_STATVFS_IS_NATURAL 1 #endif struct statvfs; +#endif struct iovec; +struct utimbuf; + +struct intnl_stat; + struct pnode; extern struct pnode *_sysio_cwd; @@ -127,28 +149,67 @@ extern void _sysio_shutdown(void); extern int access(const char *path, int amode); extern int chdir(const char *path); extern int chmod(const char *path, mode_t mode); +extern int fchmod(int fd, mode_t mode); extern int chown(const char *path, uid_t owner, gid_t group); +extern int fchown(int fd, uid_t owner, gid_t group); extern int close(int d); extern int dup(int oldfd); extern int dup2(int oldfd, int newfd); extern int fcntl(int fd, int cmd, ...); extern int fstat(int fd, struct stat *buf); extern int fsync(int fd); -extern int ftruncate(int fd, off_t length); extern char *getcwd(char *buf, size_t size); -extern off_t lseek(int fd, off_t offset, int whence); +#if __USE_LARGEFILE64 +extern off64_t lseek64(int fd, off64_t offset, int whence); +#endif extern int lstat(const char *path, struct stat *buf); +#if defined(BSD) || defined(REDSTORM) +extern int getdirentries(int fd, char *buf, int nbytes , long *basep); +#else extern ssize_t getdirentries(int fd, char *buf, size_t nbytes , off_t *basep); +#if __USE_LARGEFILE64 +extern ssize_t getdirentries64(int fd, + char *buf, + size_t nbytes, + off64_t *basep); +#endif +#endif extern int mkdir(const char *path, mode_t mode); extern int open(const char *path, int flag, ...); +#if __USE_LARGEFILE64 +extern int open64(const char *path, int flag, ...); +#endif extern int creat(const char *path, mode_t mode); +#if __USE_LARGEFILE64 +extern int creat64(const char *path, mode_t mode); +#endif extern int stat(const char *path, struct stat *buf); +#if __USE_LARGEFILE64 +extern int stat64(const char *path, struct stat64 *buf); +#endif +#ifdef _HAVE_STATVFS extern int statvfs(const char *path, struct statvfs *buf); -extern int truncate(const char *path, off_t length); +#if __USE_LARGEFILE64 +extern int statvfs64(const char *path, struct statvfs64 *buf); +#endif extern int fstatvfs(int fd, struct statvfs *buf); +#if __USE_LARGEFILE64 +extern int fstatvfs64(int fd, struct statvfs64 *buf); +#endif +#endif +extern int truncate(const char *path, off_t length); +#if __USE_LARGEFILE64 +extern int truncate64(const char *path, off64_t length); +#endif +extern int ftruncate(int fd, off_t length); +#if __USE_LARGEFILE64 +extern int ftruncate64(int fd, off64_t length); +#endif extern int rmdir(const char *path); extern int symlink(const char *path1, const char *path2); +extern int link(const char *oldpath, const char *newpath); extern int unlink(const char *path); +extern int rename(const char *oldpath, const char *newpath); extern int fdatasync(int fd); extern int ioctl(int fd, unsigned long request, ...); extern mode_t umask(mode_t mask); @@ -156,26 +217,40 @@ extern int iodone(ioid_t ioid); extern ssize_t iowait(ioid_t ioid); extern int iodone(ioid_t ioid); extern ioid_t ipreadv(int fd, const struct iovec *iov, size_t count, - off_t offset); -extern ioid_t ipread(int fd, void *buf, size_t count, off_t offset); + _SYSIO_OFF_T offset); +extern ioid_t ipread(int fd, void *buf, size_t count, _SYSIO_OFF_T offset); extern ssize_t preadv(int fd, const struct iovec *iov, size_t count, - off_t offset); + _SYSIO_OFF_T offset); extern ssize_t pread(int fd, void *buf, size_t count, off_t offset); +#if __USE_LARGEFILE64 +extern ssize_t pread64(int fd, void *buf, size_t count, off64_t offset); +#endif extern ioid_t ireadv(int fd, const struct iovec *iov, int count); extern ioid_t iread(int fd, void *buf, size_t count); extern ssize_t readv(int fd, const struct iovec *iov, int count); extern ssize_t read(int fd, void *buf, size_t count); +#if __USE_LARGEFILE64 +extern ssize_t read64(int fd, void *buf, size_t count); +#endif extern ioid_t ipwritev(int fd, const struct iovec *iov, size_t count, - off_t offset); -extern ioid_t ipwrite(int fd, const void *buf, size_t count, off_t offset); + _SYSIO_OFF_T offset); +extern ioid_t ipwrite(int fd, const void *buf, size_t count, + _SYSIO_OFF_T offset); extern ssize_t pwritev(int fd, const struct iovec *iov, size_t count, - off_t offset); + _SYSIO_OFF_T offset); extern ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset); +#if __USE_LARGEFILE64 +extern ssize_t pwrite64(int fd, const void *buf, size_t count, off64_t offset); +#endif extern ioid_t iwritev(int fd, const struct iovec *iov, int count); extern ioid_t iwrite(int fd, const void *buf, size_t count); extern ssize_t writev(int fd, const struct iovec *iov, int count); extern ssize_t write(int fd, const void *buf, size_t count); +#if __USE_LARGEFILE64 +extern ssize_t write64(int fd, const void *buf, size_t count); +#endif extern int mknod(const char *path, mode_t mode, dev_t dev); +extern int utime(const char *path, const struct utimbuf *buf); extern int mount(const char *source, const char *target, const char *filesystemtype, unsigned long mountflags, |
From: Ruth K. <rk...@us...> - 2003-10-14 23:39:46
|
Update of /cvsroot/libsysio/libsysio/drivers/yod In directory sc8-pr-cvs1:/tmp/cvs-serv28674/drivers/yod Modified Files: Tag: cplant Makefile.am fs_yod.c Log Message: Merge HEAD changes into cplant branch Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/yod/Makefile.am,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -u -w -b -B -p -r1.2 -r1.2.4.1 --- Makefile.am 14 Aug 2003 18:39:33 -0000 1.2 +++ Makefile.am 14 Oct 2003 23:39:36 -0000 1.2.4.1 @@ -1,6 +1,6 @@ lib_LIBRARIES = libsysio_yod.a -EXTRA_DIST = fs_yod.h +EXTRA_DIST = ../../include/cplant-yod.h fs_yod.h libsysio_yod_a_SOURCES = fs_yod.c Index: fs_yod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/yod/fs_yod.c,v retrieving revision 1.2.4.1 retrieving revision 1.2.4.2 diff -u -w -b -B -p -r1.2.4.1 -r1.2.4.2 --- fs_yod.c 20 Aug 2003 21:05:49 -0000 1.2.4.1 +++ fs_yod.c 14 Oct 2003 23:39:36 -0000 1.2.4.2 @@ -57,8 +57,12 @@ #include <sys/types.h> #include <sys/stat.h> #include <sys/fcntl.h> +#if 0 #include <sys/vfs.h> +#endif +#ifdef _HAVE_STATVFS #include <sys/statvfs.h> +#endif #include <utime.h> #include <sys/queue.h> #include <sys/uio.h> @@ -167,13 +171,13 @@ static int yod_inop_symlink(struct pnode static int yod_inop_readlink(struct pnode *pno, char *buf, size_t bufsiz); static int yod_inop_open(struct pnode *pno, int flags, mode_t mode); static int yod_inop_close(struct inode *ino); +static int yod_inop_link(struct pnode *old, struct pnode *new); static int yod_inop_unlink(struct pnode *pno); +static int yod_inop_rename(struct pnode *old, struct pnode *new); static int yod_inop_ipreadv(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp); + struct ioctx *ioctx); static int yod_inop_ipwritev(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp); + struct ioctx *ioctx); static int yod_inop_iodone(struct ioctx *ioctx); static int yod_inop_fcntl(struct inode *ino, int cmd, va_list ap); static int yod_inop_sync(struct inode *ino); @@ -182,9 +186,11 @@ static int yod_inop_ioctl(struct inode * unsigned long int request, va_list ap); static int yod_inop_mknod(struct pnode *pno, mode_t mode, dev_t dev); +#ifdef _HAVE_STATVFS static int yod_inop_statvfs(struct pnode *pno, struct inode *ino, struct intnl_statvfs *buf); +#endif static void yod_inop_gone(struct inode *ino); static struct inode_ops yod_i_ops = { @@ -198,7 +204,9 @@ static struct inode_ops yod_i_ops = { yod_inop_readlink, yod_inop_open, yod_inop_close, + yod_inop_link, yod_inop_unlink, + yod_inop_rename, yod_inop_ipreadv, yod_inop_ipwritev, yod_inop_iodone, @@ -207,7 +215,9 @@ static struct inode_ops yod_i_ops = { yod_inop_datasync, yod_inop_ioctl, yod_inop_mknod, +#ifdef _HAVE_STATVFS yod_inop_statvfs, +#endif yod_inop_gone }; @@ -228,7 +238,7 @@ static struct filesys_ops yod_inodesys_o }; /* - * Placeholder internal mount as in native driver + * Placeholder internal mount as in yod driver */ static struct mount *yod_internal_mount = NULL; @@ -284,6 +293,7 @@ yod_i_new(struct filesys *fs, struct int nino = malloc(sizeof(struct yod_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 @@ -534,6 +544,7 @@ yod_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 @@ -704,7 +715,7 @@ yod_inop_setattr(struct pnode *pno, } if (err) mask &= ~(SETATTR_UID|SETATTR_GID); - if (mask & SETATTR_LEN) { + else if (mask & SETATTR_LEN) { /* * Do the truncate last. It can't be undone. */ @@ -727,15 +738,6 @@ yod_inop_setattr(struct pnode *pno, ? st.st_gid : (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 )utime_yod(path, &ut); - } -#endif if (mask & SETATTR_MODE) { chmod_yod(path, st.st_mode & 0777); } @@ -923,10 +924,36 @@ yod_inop_close(struct inode *ino) } static int +yod_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 = link_yod(opath, npath); + +out: + if (opath) + free(opath); + if (npath) + free(npath); + + return err; +} + +static int yod_inop_unlink(struct pnode *pno) { char *path; - int err; + int err = 0; path = _sysio_pb_path(pno->p_base, '/'); if (!path) @@ -944,7 +971,8 @@ 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 = unlink_yod(path); + if (unlink_yod(path) != 0) + err = -errno; free(path); return err; } @@ -958,30 +986,21 @@ yod_inop_unlink(struct pnode *pno) static int doio(ssize_t (*f)(int, const struct iovec *, int), struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp) + struct ioctx *ioctx) { struct yod_inode *nino = I2NI(ino); - struct ioctx *ioctx; loff_t result; assert(nino->ni_fd >= 0); - if (ioargs->ioarg_iovlen && (int )ioargs->ioarg_iovlen < 0) + if (ioctx->ioctx_iovlen && (int )ioctx->ioctx_iovlen < 0) return -EINVAL; /* - * Get a new IO context. - */ - ioctx = _sysio_ioctx_new(ino, ioargs); - if (!ioctx) - return -ENOMEM; - - /* * This implementation first positions the real system descriptor, then * performs the operation. This is silly because it's not atomic. * - * An alternative, more complex, less efficient but atomic, + * An alteryod, more complex, less efficient but atomic, * implementation might consider each entry of the iovec separately. * Then, the system implementations of the POSIX p{reaad,write} calls * could be used. @@ -1013,7 +1032,6 @@ doio(ssize_t (*f)(int, const struct iove nino->ni_fpos += ioctx->ioctx_cc; } - *ioctxp = ioctx; return 0; } @@ -1021,20 +1039,48 @@ doio(ssize_t (*f)(int, const struct iove * Helper function passed to doio(), above, to accomplish a real readv. */ static ssize_t -_readv(int fd, const struct iovec *vector, int count __IS_UNUSED) +_readv(int fd, const struct iovec *vector, int count) +{ + int i; + ssize_t total = 0; + + for (i = 0; i < count; i++) + total += read_yod(fd, + vector[i].iov_base, + vector[i].iov_len); + return total; +} + +static int +yod_inop_rename(struct pnode *old, struct pnode *new) { - return read_yod(fd, - vector[0].iov_base, - vector[0].iov_len); + 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 = rename_yod(opath, npath); + +out: + if (opath) + free(opath); + if (npath) + free(npath); + + return err; } static int yod_inop_ipreadv(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp) + struct ioctx *ioctx) { - return doio(_readv, ino, ioargs, ioctxp); + return doio(_readv, ino, ioctx); } /* @@ -1055,11 +1101,10 @@ _writev(int fd, const struct iovec *vect static int yod_inop_ipwritev(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp) + struct ioctx *ioctx) { - return doio(_writev, ino, ioargs, ioctxp); + return doio(_writev, ino, ioctx); } static int @@ -1096,6 +1141,7 @@ yod_inop_mknod(struct pnode *pno __IS_UN return -ENOSYS; } +#ifdef _HAVE_STATVFS static int yod_inop_statvfs(struct pnode *pno, struct inode *ino, @@ -1146,6 +1192,7 @@ yod_inop_statvfs(struct pnode *pno, buf->f_namemax = fs.f_namelen; return 0; } +#endif static int yod_inop_sync(struct inode *ino) @@ -1189,13 +1236,11 @@ yod_inop_gone(struct inode *ino) } static void -yod_fsop_gone(struct filesys *fs) +yod_fsop_gone(struct filesys *fs __IS_UNUSED) { /* - * Release fs private data + * Do nothing. There is no private part maintained for the + * yod file interface. */ - - if (fs->fs_private) free(fs->fs_private); - } |
From: Ruth K. <rk...@us...> - 2003-10-14 23:39:46
|
Update of /cvsroot/libsysio/libsysio In directory sc8-pr-cvs1:/tmp/cvs-serv28674 Modified Files: Tag: cplant README Log Message: Merge HEAD changes into cplant branch Index: README =================================================================== RCS file: /cvsroot/libsysio/libsysio/README,v retrieving revision 1.2.16.1 retrieving revision 1.2.16.2 diff -u -w -b -B -p -r1.2.16.1 -r1.2.16.2 --- README 28 Aug 2003 13:43:09 -0000 1.2.16.1 +++ README 14 Oct 2003 23:39:36 -0000 1.2.16.2 @@ -53,3 +53,14 @@ is required. They are not on a timer, un one for them. They just disappear as resource is needed elsewhere. As they were automatically mounted to begin with, they should re-establish as needed, transparently. + +REDSTORM +-------- + +The following works for me: + +#!/bin/sh + +export CFLAGS="-DREDSTORM -nostdinc -isystem /home/lee/REDSTORM/catamount/computeincs/i386 -isystem /home/lee/REDSTORM/catamount/include -g -W -Wall -ansi" + +sh configure --with-autmount=".mount" --with-native=yes --with-incore-yes --with-stdfd=yes --with-tests=yes |
From: Ruth K. <rk...@us...> - 2003-10-14 23:39:45
|
Update of /cvsroot/libsysio/libsysio/dev/stdfd In directory sc8-pr-cvs1:/tmp/cvs-serv28674/dev/stdfd Modified Files: Tag: cplant stdfd.c Log Message: Merge HEAD changes into cplant branch Index: stdfd.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/dev/stdfd/stdfd.c,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -w -b -B -p -r1.4 -r1.4.2.1 --- stdfd.c 14 Aug 2003 18:39:33 -0000 1.4 +++ stdfd.c 14 Oct 2003 23:39:36 -0000 1.4.2.1 @@ -58,6 +58,10 @@ #include "stdfd.h" +#ifdef REDSTORM +#include <catamount/syscall.h> /* ! in sys include? */ +#endif + #ifdef CPLANT_YOD #include <sys/statfs.h> #include "cplant-yod.h" @@ -75,11 +79,9 @@ static int stdfd_open(struct pnode *pno, int flags, mode_t mode); static int stdfd_close(struct inode *ino); static int stdfd_ipreadv(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp); + struct ioctx *ioctx); static int stdfd_ipwritev(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp); + struct ioctx *ioctx); static int stdfd_iodone(struct ioctx *ioctx); static int stdfd_datasync(struct inode *ino); static int stdfd_ioctl(struct inode *ino, @@ -124,18 +126,12 @@ stdfd_close(struct inode *ino __IS_UNUSE static int doio(ssize_t (*f)(int, char *, size_t), struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp) + struct ioctx *ioctx) { - struct ioctx *ioctx; const struct iovec *iov; size_t n; ssize_t cc = 0; - ioctx = _sysio_ioctx_new(ino, ioargs); - if (!ioctx) - return -ENOMEM; - iov = ioctx->ioctx_iovec; for (n = ioctx->ioctx_iovlen, iov = ioctx->ioctx_iovec; n--; @@ -155,7 +151,6 @@ doio(ssize_t (*f)(int, char *, size_t), ioctx->ioctx_errno = -cc; } - *ioctxp = ioctx; return 0; } @@ -168,11 +163,10 @@ stdfd_read(int fd, char *buf, size_t nby static int stdfd_ipreadv(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp) + struct ioctx *ioctx) { - return doio(stdfd_read, ino, ioargs, ioctxp); + return doio(stdfd_read, ino, ioctx); } static ssize_t @@ -186,14 +180,12 @@ stdfd_write(int fd, static int stdfd_ipwritev(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp) + struct ioctx *ioctx) { return doio((ssize_t (*)(int, char *, size_t))stdfd_write, ino, - ioargs, - ioctxp); + ioctx); } static int |
From: Lee W. <lw...@us...> - 2003-10-14 18:00:35
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv24178/src Modified Files: fcntl.c getdirentries.c ioctl.c open.c read.c stat.c write.c Log Message: Added missing symbol aliases for Red Storm plus some that seemed missing. Index: fcntl.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/fcntl.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -b -B -p -r1.5 -r1.6 --- fcntl.c 6 Oct 2003 21:19:31 -0000 1.5 +++ fcntl.c 14 Oct 2003 18:00:29 -0000 1.6 @@ -102,3 +102,8 @@ out: #undef __fcntl sysio_sym_weak_alias(fcntl, __fcntl) #endif + +#if defined(BSD) || defined(REDSTORM) +#undef _fcntl +sysio_sym_weak_alias(fcntl, _fcntl) +#endif Index: getdirentries.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/getdirentries.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- getdirentries.c 10 Oct 2003 18:50:31 -0000 1.3 +++ getdirentries.c 14 Oct 2003 18:00:29 -0000 1.4 @@ -221,3 +221,8 @@ out: #else /* !defined(DIRENT64_IS_NATURAL) */ sysio_sym_strong_alias(_getdirentries64, getdirentries) #endif + +#if defined(BSD) || defined(REDSTORM) +#undef _getdirentries +sysio_sym_weak_alias(getdirentries, _getdirentries) +#endif Index: ioctl.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/ioctl.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- ioctl.c 6 Oct 2003 21:19:31 -0000 1.3 +++ ioctl.c 14 Oct 2003 18:00:30 -0000 1.4 @@ -83,3 +83,8 @@ out: #undef __ioctl sysio_sym_weak_alias(ioctl, __ioctl) #endif + +#if defined(BSD) || defined(REDSTORM) +#undef _ioctl +sysio_sym_weak_alias(ioctl, _ioctl) +#endif Index: open.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/open.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -w -b -B -p -r1.10 -r1.11 --- open.c 10 Oct 2003 18:50:31 -0000 1.10 +++ open.c 14 Oct 2003 18:00:30 -0000 1.11 @@ -216,6 +216,11 @@ sysio_sym_weak_alias(open, open64) sysio_sym_weak_alias(open, __open64) #endif +#if defined(BSD) || defined(REDSTORM) +#undef _open +sysio_sym_weak_alias(open, _open) +#endif + int close(int fd) { @@ -232,6 +237,11 @@ close(int fd) sysio_sym_weak_alias(close, __close) #endif +#if defined(BSD) || defined(REDSTORM) +#undef _close +sysio_sym_weak_alias(close, _close) +#endif + int creat(const char *path, mode_t mode) { @@ -246,6 +256,11 @@ sysio_sym_weak_alias(creat, __creat) sysio_sym_weak_alias(creat, creat64) #undef __creat64 sysio_sym_weak_alias(creat, __creat64) +#endif + +#if defined(BSD) || defined(REDSTORM) +#undef _creat +sysio_sym_weak_alias(creat, _creat) #endif mode_t Index: read.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/read.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -w -b -B -p -r1.8 -r1.9 --- read.c 13 Oct 2003 12:19:25 -0000 1.8 +++ read.c 14 Oct 2003 18:00:30 -0000 1.9 @@ -227,6 +227,11 @@ readv(int fd, const struct iovec *iov, i return iowait(ioid); } +#if defined(BSD) || defined(REDSTORM) +#undef _readv +sysio_sym_weak_alias(readv, _readv) +#endif + ssize_t read(int fd, void *buf, size_t count) { @@ -241,6 +246,11 @@ read(int fd, void *buf, size_t count) #ifdef __GLIBC__ #undef __read sysio_sym_weak_alias(read, __read) +#endif + +#if defined(BSD) || defined(REDSTORM) +#undef _read +sysio_sym_weak_alias(read, _read) #endif #if _LARGEFILE64_SOURCE Index: stat.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/stat.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -w -b -B -p -r1.4 -r1.5 --- stat.c 10 Oct 2003 18:50:31 -0000 1.4 +++ stat.c 14 Oct 2003 18:00:30 -0000 1.5 @@ -108,6 +108,11 @@ __fstat(int fd, struct stat *buf) sysio_sym_weak_alias(__fstat, fstat) +#if defined(BSD) || defined(REDSTORM) +#undef _fstat +sysio_sym_weak_alias(__fstat, _fstat) +#endif + int __xstat(int __ver, const char *__filename, struct stat *__stat_buf) { @@ -148,6 +153,11 @@ __stat(const char *filename, struct stat sysio_sym_weak_alias(__stat, stat) +#if defined(BSD) || defined(REDSTORM) +#undef _stat +sysio_sym_weak_alias(__stat, _stat) +#endif + int __lxstat(int __ver, const char *__filename, struct stat *__stat_buf) { @@ -188,3 +198,7 @@ __lstat(const char *filename, struct sta sysio_sym_weak_alias(__lstat, lstat) +#if defined(BSD) || defined(REDSTORM) +#undef _lstat +sysio_sym_weak_alias(__lstat, _lstat) +#endif Index: write.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/write.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -w -b -B -p -r1.8 -r1.9 --- write.c 13 Oct 2003 12:19:25 -0000 1.8 +++ write.c 14 Oct 2003 18:00:30 -0000 1.9 @@ -229,6 +229,11 @@ writev(int fd, const struct iovec *iov, return iowait(ioid); } +#if defined(BSD) || defined(REDSTORM) +#undef _writev +sysio_sym_weak_alias(writev, _writev) +#endif + ssize_t write(int fd, const void *buf, size_t count) { @@ -243,6 +248,11 @@ write(int fd, const void *buf, size_t co #ifdef __GLIBC__ #undef __write sysio_sym_weak_alias(write, __write) +#endif + +#if defined(BSD) || defined(REDSTORM) +#undef _write +sysio_sym_weak_alias(write, _write) #endif #if _LARGEFILE64_SOURCE |
From: Lee W. <lw...@us...> - 2003-10-14 17:50:39
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv22567/src Modified Files: Tag: RedStorm fcntl.c getdirentries.c ioctl.c open.c read.c stat.c write.c Log Message: Somehow, all the needed symbol aliases for Red Storm cnos were lost in the integration. Added back those we know are missing plus a few that make sense from what I believe should be symmetry. Index: fcntl.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/fcntl.c,v retrieving revision 1.3.4.2 retrieving revision 1.3.4.3 diff -u -w -b -B -p -r1.3.4.2 -r1.3.4.3 --- fcntl.c 27 Sep 2003 23:01:23 -0000 1.3.4.2 +++ fcntl.c 14 Oct 2003 17:50:34 -0000 1.3.4.3 @@ -102,3 +102,7 @@ out: #undef __fcntl sysio_sym_weak_alias(fcntl, __fcntl) #endif + +#if defined(REDSTORM) || defined(BSD) +sysio_sym_weak_alias(fcntl, _fcntl) +#endif Index: getdirentries.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/getdirentries.c,v retrieving revision 1.1.10.4 retrieving revision 1.1.10.5 diff -u -w -b -B -p -r1.1.10.4 -r1.1.10.5 --- getdirentries.c 29 Sep 2003 14:57:01 -0000 1.1.10.4 +++ getdirentries.c 14 Oct 2003 17:50:34 -0000 1.1.10.5 @@ -221,3 +221,7 @@ out: #else /* !defined(DIRENT64_IS_NATURAL) */ sysio_sym_strong_alias(_getdirentries64, getdirentries) #endif + +#if defined(REDSTORM) || defined(BSD) +sysio_sym_strong_alias(getdirentries, _getdirentries) +#endif Index: ioctl.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/ioctl.c,v retrieving revision 1.1.1.1.14.2 retrieving revision 1.1.1.1.14.3 diff -u -w -b -B -p -r1.1.1.1.14.2 -r1.1.1.1.14.3 --- ioctl.c 27 Sep 2003 23:01:23 -0000 1.1.1.1.14.2 +++ ioctl.c 14 Oct 2003 17:50:34 -0000 1.1.1.1.14.3 @@ -82,4 +81,8 @@ out: #ifdef __GLIBC__ #undef __ioctl sysio_sym_weak_alias(ioctl, __ioctl) +#endif + +#if defined(REDSTORM) || defined(BSD) +sysio_sym_strong_alias(ioctl, _ioctl) #endif Index: open.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/open.c,v retrieving revision 1.7.4.4 retrieving revision 1.7.4.5 diff -u -w -b -B -p -r1.7.4.4 -r1.7.4.5 --- open.c 27 Sep 2003 23:01:23 -0000 1.7.4.4 +++ open.c 14 Oct 2003 17:50:34 -0000 1.7.4.5 @@ -216,6 +216,10 @@ sysio_sym_weak_alias(open, open64) sysio_sym_weak_alias(open, __open64) #endif +#if defined(REDSTORM) || defined(BSD) +sysio_sym_strong_alias(open, _open) +#endif + int close(int fd) { @@ -232,6 +236,10 @@ close(int fd) sysio_sym_weak_alias(close, __close) #endif +#if defined(REDSTORM) || defined(BSD) +sysio_sym_strong_alias(close, _close) +#endif + int creat(const char *path, mode_t mode) { @@ -246,6 +254,10 @@ sysio_sym_weak_alias(creat, __creat) sysio_sym_weak_alias(creat, creat64) #undef __creat64 sysio_sym_weak_alias(creat, __creat64) +#endif + +#if defined(REDSTORM) || defined(BSD) +sysio_sym_strong_alias(creat, _creat) #endif mode_t Index: read.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/read.c,v retrieving revision 1.2.10.3 retrieving revision 1.2.10.4 diff -u -w -b -B -p -r1.2.10.3 -r1.2.10.4 --- read.c 29 Sep 2003 14:57:01 -0000 1.2.10.3 +++ read.c 14 Oct 2003 17:50:34 -0000 1.2.10.4 @@ -171,6 +171,10 @@ pread(int fd, void *buf, size_t count, o sysio_sym_weak_alias(_pread, pread) #endif +#if defined(REDSTORM) || defined(BSD) +sysio_sym_strong_alias(pread, _pread) +#endif + /* * API interface to accomplish asynch read into iovec from current file offset. */ @@ -217,6 +221,10 @@ readv(int fd, const struct iovec *iov, i return iowait(ioid); } +#if defined(REDSTORM) || defined(BSD) +sysio_sym_strong_alias(readv, _readv) +#endif + ssize_t read(int fd, void *buf, size_t count) { @@ -231,6 +239,10 @@ read(int fd, void *buf, size_t count) #ifdef __GLIBC__ #undef __read sysio_sym_weak_alias(read, __read) +#endif + +#if defined(REDSTORM) || defined(BSD) +sysio_sym_strong_alias(read, _read) #endif #if _LARGEFILE64_SOURCE Index: stat.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/stat.c,v retrieving revision 1.3.6.2 retrieving revision 1.3.6.3 diff -u -w -b -B -p -r1.3.6.2 -r1.3.6.3 --- stat.c 19 May 2003 13:51:20 -0000 1.3.6.2 +++ stat.c 14 Oct 2003 17:50:34 -0000 1.3.6.3 @@ -108,6 +108,10 @@ __fstat(int fd, struct stat *buf) sysio_sym_weak_alias(__fstat, fstat) +#if defined(REDSTORM) || defined(BSD) +sysio_sym_strong_alias(__fstat, _fstat) +#endif + int __xstat(int __ver, const char *__filename, struct stat *__stat_buf) { @@ -148,6 +152,10 @@ __stat(const char *filename, struct stat sysio_sym_weak_alias(__stat, stat) +#if defined(REDSTORM) || defined(BSD) +sysio_sym_strong_alias(__stat, _stat) +#endif + int __lxstat(int __ver, const char *__filename, struct stat *__stat_buf) { @@ -188,3 +196,6 @@ __lstat(const char *filename, struct sta sysio_sym_weak_alias(__lstat, lstat) +#if defined(REDSTORM) || defined(BSD) +sysio_sym_strong_alias(__lstat, _lstat) +#endif Index: write.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/write.c,v retrieving revision 1.2.12.3 retrieving revision 1.2.12.4 diff -u -w -b -B -p -r1.2.12.3 -r1.2.12.4 --- write.c 29 Sep 2003 14:57:01 -0000 1.2.12.3 +++ write.c 14 Oct 2003 17:50:34 -0000 1.2.12.4 @@ -171,6 +171,10 @@ pwrite(int fd, const void *buf, size_t c sysio_sym_weak_alias(_pwrite, pwrite) #endif +#if defined(REDSTORM) || defined(BSD) +sysio_sym_strong_alias(pwrite, _pwrite) +#endif + /* * API interface to accomplish asynch write into iovec from current file offset. */ @@ -217,6 +221,10 @@ writev(int fd, const struct iovec *iov, return iowait(ioid); } +#if defined(REDSTORM) || defined(BSD) +sysio_sym_strong_alias(writev, _writev) +#endif + ssize_t write(int fd, const void *buf, size_t count) { @@ -231,6 +239,10 @@ write(int fd, const void *buf, size_t co #ifdef __GLIBC__ #undef __write sysio_sym_weak_alias(write, __write) +#endif + +#if defined(REDSTORM) || defined(BSD) +sysio_sym_strong_alias(write, _write) #endif #if _LARGEFILE64_SOURCE |
From: Lee W. <lw...@us...> - 2003-10-13 21:23:48
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv10077/src Modified Files: rename.c Log Message: Crafted new test for rename call. Fixed a few bugs in rename: Path node parent at root is NULL, not a cycle. Check for cross device renames, not simple cross mount. Check to make sure that that the source is not covered and that neither the source nor the destination is a mountpoint. Index: rename.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/rename.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -w -b -B -p -r1.1 -r1.2 --- rename.c 27 Sep 2003 19:42:03 -0000 1.1 +++ rename.c 13 Oct 2003 21:23:44 -0000 1.2 @@ -78,9 +78,15 @@ rename(const char *oldpath, const char * if (err && !new) goto error2; - if (old->p_mount->mnt_root != new->p_mount->mnt_root) { + if (old->p_mount->mnt_root == old || old->p_cover || + new->p_mount->mnt_root == new) { + err = -EBUSY; + goto error1; + } + + if (old->p_mount->mnt_fs != new->p_mount->mnt_fs) { /* - * Oops. They're trying to move it across mounts. + * Oops. They're trying to move it across file systems. */ err = -EXDEV; goto error1; @@ -99,7 +105,7 @@ rename(const char *oldpath, const char * err = -EINVAL; goto error1; } - } while (pb != nxtpb); + } while (nxtpb); while (new->p_base->pb_ino) { /* @@ -134,6 +140,7 @@ rename(const char *oldpath, const char * err = -EEXIST; goto error1; } + break; } /* |
From: Lee W. <lw...@us...> - 2003-10-13 21:23:48
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1:/tmp/cvs-serv10077/tests Modified Files: Makefile.am Added Files: test_rename.c Log Message: Crafted new test for rename call. Fixed a few bugs in rename: Path node parent at root is NULL, not a cycle. Check for cross device renames, not simple cross mount. Check to make sure that that the source is not covered and that neither the source nor the destination is a mountpoint. --- NEW FILE --- /* * This Cplant(TM) source code is the property of Sandia National * Laboratories. * * This Cplant(TM) source code is copyrighted by Sandia National * Laboratories. * * The redistribution of this Cplant(TM) source code is subject to the * terms of the GNU Lesser General Public License * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) * * Cplant(TM) Copyright 1998-2003 Sandia Corporation. * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive * license for use of this work by or on behalf of the US Government. * Export of this program may require a license from the United States * Government. */ /* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Questions or comments about this library should be sent to: * * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 * Albuquerque, NM 87185-1110 * * le...@sa... */ #define _BSD_SOURCE #include <stdio.h> #include <stdlib.h> #include <unistd.h> #ifndef REDSTORM #include <getopt.h> #endif #include <errno.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/queue.h> #include "sysio.h" #include "mount.h" #include "fs_native.h" #include "test.h" /* * Rename a file system object. * * Usage: test_rename [-a] [-r <source>] [-m <root-driver>] <src> <dest> */ char *root_driver = DEFAULT_DRIVER; char *mntpath = "/"; unsigned mntflgs = 0; void usage(void); int rename_file(const char *spath, const char *dpath); int main(int argc, char * const argv[]) { int i; int err; const char *spath, *dpath; /* * Parse command-line args. */ while ((i = getopt(argc, argv, #ifdef AUTOMOUNT_FILE_NAME "a" #endif "r:m:")) != -1) switch (i) { #ifdef AUTOMOUNT_FILE_NAME case 'a': mntflgs |= MOUNT_F_AUTO; break; #endif case 'r': /* set working dir */ mntpath = optarg; break; case 'm': root_driver = optarg; break; default: usage(); } if (!(argc - optind)) usage(); #ifndef CPLANT_YOD if (_sysio_init() != 0) { perror("init sysio"); exit(1); } err = drv_init_all(); if (err) { perror("init drivers"); exit(1); } err = _sysio_mount_root(mntpath, root_driver, mntflgs, NULL); if (err) { errno = -err; perror(root_driver); exit(1); } #endif (void )umask(022); /* * Source */ spath = argv[optind++]; if (!(argc - optind)) usage(); /* * Destination */ dpath = argv[optind++]; if (argc - optind) usage(); if (rename(spath, dpath) != 0) perror("rename"); #ifndef CPLANT_YOD _sysio_shutdown(); #endif return err; } void usage() { (void )fprintf(stderr, "Usage: test_rename " #ifdef AUTOMOUNT_FILE_NAME "[-a] " #endif "[-r <source>] [-m <fsname>]" " source destination\n"); exit(1); } Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Makefile.am,v retrieving revision 1.13 retrieving revision 1.14 diff -u -w -b -B -p -r1.13 -r1.14 --- Makefile.am 10 Oct 2003 18:50:31 -0000 1.13 +++ Makefile.am 13 Oct 2003 21:23:44 -0000 1.14 @@ -1,5 +1,5 @@ noinst_PROGRAMS = test_copy test_stats test_path test_mounts test_list \ - test_getcwd test_stdfd test_unlink test_driver + test_getcwd test_stdfd test_unlink test_rename test_driver CLEANFILES=drv_data.c @@ -101,6 +101,11 @@ test_unlink_SOURCES=test_unlink.c $(CMNS test_unlink_CFLAGS=$(CFL) test_unlink_LDADD=$(LIBS) test_unlink_DEPENDENCIES=$(LIBS) + +test_rename_SOURCES=test_rename.c $(CMNSRC) +test_rename_CFLAGS=$(CFL) +test_rename_LDADD=$(LIBS) +test_rename_DEPENDENCIES=$(LIBS) test_driver_SOURCES=test_driver.c sysio_tests.c sysio_stubs.c help.c $(CMNSRC) test_driver_CFLAGS=$(CFL) |
From: Lee W. <lw...@us...> - 2003-10-13 12:19:32
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv31106 Modified Files: read.c write.c Log Message: Fixed bug in do_ipx{read,write}v where on error a NULL pointer could be dereferenced. Index: read.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/read.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -w -b -B -p -r1.7 -r1.8 --- read.c 13 Oct 2003 01:04:35 -0000 1.7 +++ read.c 13 Oct 2003 12:19:25 -0000 1.8 @@ -93,9 +93,11 @@ do_ixreadv(struct file *fil, err = ino->i_ops.inop_ipreadv(fil->f_ino, ioctx); out: if (err) { + if (ioctx) { ioctx->ioctx_cc = -1; ioctx->ioctx_errno = -err; _sysio_ioctx_complete(ioctx); + } errno = -err; return NULL; } Index: write.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/write.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -w -b -B -p -r1.7 -r1.8 --- write.c 13 Oct 2003 01:04:35 -0000 1.7 +++ write.c 13 Oct 2003 12:19:25 -0000 1.8 @@ -95,9 +95,11 @@ do_ixwritev(struct file *fil, err = ino->i_ops.inop_ipwritev(fil->f_ino, ioctx); out: if (err) { + if (ioctx) { ioctx->ioctx_cc = -1; ioctx->ioctx_errno = -err; _sysio_ioctx_complete(ioctx); + } errno = -err; return NULL; } |
From: Lee W. <lw...@us...> - 2003-10-13 02:43:23
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv11818/src Modified Files: ioctx.c Log Message: Another oops from the addition of the callback chains... Must not remove the io context record from the global chain if it's marked `fast'. This because it was never put on the list in the first place :-( Index: ioctx.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/ioctx.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -w -b -B -p -r1.4 -r1.5 --- ioctx.c 13 Oct 2003 01:53:57 -0000 1.4 +++ ioctx.c 13 Oct 2003 02:43:17 -0000 1.5 @@ -202,11 +202,6 @@ _sysio_ioctx_complete(struct ioctx *ioct #endif struct ioctx_callback *entry; - /* - * Unlink from the file record's outstanding request queue. - */ - LIST_REMOVE(ioctx, ioctx_link); - #if 0 /* * Wait for IO to complete and remember completion values. @@ -227,6 +222,11 @@ _sysio_ioctx_complete(struct ioctx *ioct if (ioctx->ioctx_fast) return; + + /* + * Unlink from the file record's outstanding request queue. + */ + LIST_REMOVE(ioctx, ioctx_link); I_RELE(ioctx->ioctx_ino); free(ioctx); |
From: Lee W. <lw...@us...> - 2003-10-13 01:54:07
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv6057 Modified Files: ioctx.c Log Message: Oops. We should not drop the inode reference for fast IO context records. Index: ioctx.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/ioctx.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- ioctx.c 13 Oct 2003 01:04:35 -0000 1.3 +++ ioctx.c 13 Oct 2003 01:53:57 -0000 1.4 @@ -225,8 +225,9 @@ _sysio_ioctx_complete(struct ioctx *ioct free(entry); } - I_RELE(ioctx->ioctx_ino); + if (ioctx->ioctx_fast) + return; - if (!ioctx->ioctx_fast) + I_RELE(ioctx->ioctx_ino); free(ioctx); } |
From: Lee W. <lw...@us...> - 2003-10-13 01:04:44
|
Update of /cvsroot/libsysio/libsysio/drivers/incore In directory sc8-pr-cvs1:/tmp/cvs-serv31768/drivers/incore Modified Files: fs_incore.c Log Message: The IO context record supported one call-back. It now supports a chain. This was changed to accommodate the Sandia-PVFS driver. Also, it's needed for the, coming, {read,write}_strided calls. To add a callback to the chain use: _sysio_ioctx_cb(struct ioctx *ioctx, void (*func)(struct ioctx *, void *), void *data) Callbacks are added to the end of the existing chain. When called, by _sysio_io_complete, they are run in order. So... If you're freeing things using callbacks be careful not to depend on something in a later callback that you previously free'd. Also, _sysio_io_complete no longer waits for the driver. To call this, now, is to signal completion. Index: fs_incore.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/incore/fs_incore.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -w -b -B -p -r1.7 -r1.8 --- fs_incore.c 10 Oct 2003 18:50:31 -0000 1.7 +++ fs_incore.c 13 Oct 2003 01:04:34 -0000 1.8 @@ -143,11 +143,9 @@ static int _sysio_incore_dirop_link(stru static int _sysio_incore_dirop_unlink(struct pnode *pno); static int _sysio_incore_dirop_rename(struct pnode *old, struct pnode *new); static int _sysio_incore_filop_ipreadv(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp); + struct ioctx *ioctx); static int _sysio_incore_filop_ipwritev(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp); + struct ioctx *ioctx); static int _sysio_incore_filop_iodone(struct ioctx *ioctx); static int _sysio_incore_filop_fcntl(struct inode *ino, int cmd, va_list ap); static int _sysio_incore_inop_sync(struct inode *ino); @@ -172,12 +170,10 @@ static void _sysio_incore_illop(void); (int (*)(struct pnode *, char *, size_t))_sysio_incore_e_inval #define _sysio_incore_dirop_ipreadv \ (int (*)(struct inode *, \ - struct io_arguments *, \ - struct ioctx **))_sysio_incore_e_isdir + struct ioctx *))_sysio_incore_e_isdir #define _sysio_incore_dirop_ipwritev \ (int (*)(struct inode *, \ - struct io_arguments *, \ - struct ioctx **))_sysio_incore_e_isdir + struct ioctx *))_sysio_incore_e_isdir #define _sysio_incore_dirop_iodone \ (int (*)(struct ioctx *))_sysio_incore_illop #define _sysio_incore_dirop_fcntl \ @@ -1490,18 +1486,12 @@ _sysio_incore_dirop_unlink(struct pnode static int incore_doio(ssize_t (*f)(struct incore_inode *, off_t, char *, size_t), struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp) + struct ioctx *ioctx) { - struct ioctx *ioctx; const struct iovec *iov; size_t n; ssize_t cc = 0; - ioctx = _sysio_ioctx_new(ino, ioargs); - if (!ioctx) - return -ENOMEM; - iov = ioctx->ioctx_iovec; for (n = ioctx->ioctx_iovlen, iov = ioctx->ioctx_iovec; n--; @@ -1522,7 +1512,6 @@ incore_doio(ssize_t (*f)(struct incore_i ioctx->ioctx_errno = -cc; } - *ioctxp = ioctx; return 0; } @@ -1545,11 +1534,10 @@ incore_read(struct incore_inode *icino, static int _sysio_incore_filop_ipreadv(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp) + struct ioctx *ioctx) { - return incore_doio(incore_read, ino, ioargs, ioctxp); + return incore_doio(incore_read, ino, ioctx); } static ssize_t @@ -1578,8 +1566,7 @@ incore_write(struct incore_inode *icino, static int _sysio_incore_filop_ipwritev(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp) + struct ioctx *ioctx) { return incore_doio((ssize_t (*)(struct incore_inode *, @@ -1587,8 +1574,7 @@ _sysio_incore_filop_ipwritev(struct inod char *, size_t))incore_write, ino, - ioargs, - ioctxp); + ioctx); } static int |
From: Lee W. <lw...@us...> - 2003-10-13 01:04:43
|
Update of /cvsroot/libsysio/libsysio/drivers/yod In directory sc8-pr-cvs1:/tmp/cvs-serv31768/drivers/yod Modified Files: fs_yod.c Log Message: The IO context record supported one call-back. It now supports a chain. This was changed to accommodate the Sandia-PVFS driver. Also, it's needed for the, coming, {read,write}_strided calls. To add a callback to the chain use: _sysio_ioctx_cb(struct ioctx *ioctx, void (*func)(struct ioctx *, void *), void *data) Callbacks are added to the end of the existing chain. When called, by _sysio_io_complete, they are run in order. So... If you're freeing things using callbacks be careful not to depend on something in a later callback that you previously free'd. Also, _sysio_io_complete no longer waits for the driver. To call this, now, is to signal completion. Index: fs_yod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/yod/fs_yod.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -b -B -p -r1.2 -r1.3 --- fs_yod.c 14 Aug 2003 18:39:33 -0000 1.2 +++ fs_yod.c 13 Oct 2003 01:04:34 -0000 1.3 @@ -169,11 +169,9 @@ static int yod_inop_open(struct pnode *p static int yod_inop_close(struct inode *ino); static int yod_inop_unlink(struct pnode *pno); static int yod_inop_ipreadv(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp); + struct ioctx *ioctx); static int yod_inop_ipwritev(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp); + struct ioctx *ioctx); static int yod_inop_iodone(struct ioctx *ioctx); static int yod_inop_fcntl(struct inode *ino, int cmd, va_list ap); static int yod_inop_sync(struct inode *ino); @@ -958,26 +956,17 @@ yod_inop_unlink(struct pnode *pno) static int doio(ssize_t (*f)(int, const struct iovec *, int), struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp) + struct ioctx *ioctx) { struct yod_inode *nino = I2NI(ino); - struct ioctx *ioctx; loff_t result; assert(nino->ni_fd >= 0); - if (ioargs->ioarg_iovlen && (int )ioargs->ioarg_iovlen < 0) + if (ioctx->ioctx_iovlen && (int )ioctx->ioctx_iovlen < 0) return -EINVAL; /* - * Get a new IO context. - */ - ioctx = _sysio_ioctx_new(ino, ioargs); - if (!ioctx) - return -ENOMEM; - - /* * This implementation first positions the real system descriptor, then * performs the operation. This is silly because it's not atomic. * @@ -1013,7 +1002,6 @@ doio(ssize_t (*f)(int, const struct iove nino->ni_fpos += ioctx->ioctx_cc; } - *ioctxp = ioctx; return 0; } @@ -1030,11 +1018,10 @@ _readv(int fd, const struct iovec *vecto static int yod_inop_ipreadv(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp) + struct ioctx *ioctx) { - return doio(_readv, ino, ioargs, ioctxp); + return doio(_readv, ino, ioctx); } /* @@ -1055,11 +1042,10 @@ _writev(int fd, const struct iovec *vect static int yod_inop_ipwritev(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp) + struct ioctx *ioctx) { - return doio(_writev, ino, ioargs, ioctxp); + return doio(_writev, ino, ioctx); } static int |
From: Lee W. <lw...@us...> - 2003-10-13 01:04:43
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv31768/src Modified Files: file.c ioctx.c mount.c read.c write.c Log Message: The IO context record supported one call-back. It now supports a chain. This was changed to accommodate the Sandia-PVFS driver. Also, it's needed for the, coming, {read,write}_strided calls. To add a callback to the chain use: _sysio_ioctx_cb(struct ioctx *ioctx, void (*func)(struct ioctx *, void *), void *data) Callbacks are added to the end of the existing chain. When called, by _sysio_io_complete, they are run in order. So... If you're freeing things using callbacks be careful not to depend on something in a later callback that you previously free'd. Also, _sysio_io_complete no longer waits for the driver. To call this, now, is to signal completion. Index: file.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/file.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -b -B -p -r1.5 -r1.6 --- file.c 6 Aug 2003 19:12:46 -0000 1.5 +++ file.c 13 Oct 2003 01:04:35 -0000 1.6 @@ -97,14 +97,12 @@ _sysio_fgone(struct file *fil) * IO operation completion handler. */ void -_sysio_fcompletio(struct ioctx *ioctx) +_sysio_fcompletio(struct ioctx *ioctx, struct file *fil) { - struct file *fil; if (ioctx->ioctx_errno) return; - fil = (struct file *)ioctx->ioctx_data; assert(ioctx->ioctx_ino == fil->f_ino); fil->f_pos = ioctx->ioctx_offset + ioctx->ioctx_cc; } Index: ioctx.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/ioctx.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -b -B -p -r1.2 -r1.3 --- ioctx.c 7 Mar 2003 03:31:36 -0000 1.2 +++ ioctx.c 13 Oct 2003 01:04:35 -0000 1.3 @@ -78,40 +78,67 @@ _sysio_ioctx_init() * Allocate and initialisze a new IO context. */ struct ioctx * -_sysio_ioctx_new(struct inode *ino, struct io_arguments *ioargs) +_sysio_ioctx_new(struct inode *ino, + const struct iovec *iov, + size_t iovlen, + _SYSIO_OFF_T offset) { struct ioctx *ioctx; ioctx = - malloc(sizeof(struct ioctx) + - ioargs->ioarg_iovlen * sizeof(struct iovec)); + malloc(sizeof(struct ioctx) + iovlen * sizeof(struct iovec)); if (!ioctx) return NULL; I_REF(ino); + ioctx->ioctx_iovec = (void *)ioctx + sizeof(struct ioctx); + (void )memcpy((void *)ioctx->ioctx_iovec, + iov, + iovlen * sizeof(struct iovec)); + IOCTX_INIT(ioctx, + 0, + (ioid_t )ioctx, + ino, + ioctx->ioctx_iovec, + iovlen, + offset); + /* * Link request onto the outstanding requests queue. */ LIST_INSERT_HEAD(&aioq, ioctx, ioctx_link); - ioctx->ioctx_id = (ioid_t )ioctx; - ioctx->ioctx_ino = ino; - ioctx->ioctx_iovec = (void *)ioctx + sizeof(struct ioctx); - (void )memcpy((void *)ioctx->ioctx_iovec, - ioargs->ioarg_iovec, - ioargs->ioarg_iovlen * sizeof(struct iovec)); - ioctx->ioctx_iovlen = ioargs->ioarg_iovlen; - ioctx->ioctx_offset = ioargs->ioarg_offset; - ioctx->ioctx_cc = 0; - ioctx->ioctx_errno = 0; - ioctx->ioctx_cb = ioargs->ioarg_completion; - ioctx->ioctx_data = ioargs->ioarg_completion_arg; - return ioctx; } /* + * Add an IO completion call-back to the end of the context call-back queue. + * These are called in iowait() as the last thing, right before the context + * is destroyed. + * + * They are called in order. Beware. + */ +int +_sysio_ioctx_cb(struct ioctx *ioctx, + void (*f)(struct ioctx *, void *), + void *data) +{ + struct ioctx_callback *entry; + + entry = malloc(sizeof(struct ioctx_callback)); + if (!entry) + return -ENOMEM; + + entry->iocb_f = f; + entry->iocb_data = data; + + TAILQ_INSERT_TAIL(&ioctx->ioctx_cbq, entry, iocb_next); + + return 0; +} + +/* * Find an IO context given it's identifier. * * NB: This is dog-slow. If there are alot of these, we will need to change @@ -170,26 +197,36 @@ _sysio_ioctx_wait(struct ioctx *ioctx) void _sysio_ioctx_complete(struct ioctx *ioctx) { +#if 0 struct inode *ino; +#endif + struct ioctx_callback *entry; /* * Unlink from the file record's outstanding request queue. */ LIST_REMOVE(ioctx, ioctx_link); +#if 0 /* * Wait for IO to complete and remember completion values. */ ino = ioctx->ioctx_ino; while (ino && !(*ino->i_ops.inop_iodone)(ioctx)) ; +#endif + /* - * Notify interested parties. + * Run the call-back queue. */ - if (ioctx->ioctx_cb) - (*ioctx->ioctx_cb)(ioctx); + while ((entry = ioctx->ioctx_cbq.tqh_first)) { + TAILQ_REMOVE(&ioctx->ioctx_cbq, entry, iocb_next); + (*entry->iocb_f)(ioctx, entry->iocb_data); + free(entry); + } - I_RELE(ino); + I_RELE(ioctx->ioctx_ino); + if (!ioctx->ioctx_fast) free(ioctx); } Index: mount.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mount.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -w -b -B -p -r1.7 -r1.8 --- mount.c 26 Aug 2003 15:53:59 -0000 1.7 +++ mount.c 13 Oct 2003 01:04:35 -0000 1.8 @@ -563,8 +563,7 @@ _sysio_automount(struct pnode *mntpno) struct inode *ino; struct intnl_stat stbuf; struct iovec iovec; - struct io_arguments ioarguments; - struct ioctx *ioctx; + struct ioctx iocontext; ssize_t cc; char *fstype, *source, *opts; unsigned flags; @@ -598,13 +597,14 @@ _sysio_automount(struct pnode *mntpno) err = _sysio_open(mntpno, O_RDONLY, 0); if (err) goto out; - IOARG_INIT(&ioarguments, &iovec, 1, 0, NULL, NULL); - err = (*ino->i_ops.inop_ipreadv)(ino, &ioarguments, &ioctx); + IOCTX_INIT(&iocontext, 1, (ioid_t )&iocontext, ino, &iovec, 1, 0); + err = (*ino->i_ops.inop_ipreadv)(ino, &iocontext); if (err) { + _sysio_ioctx_complete(&iocontext); (void )(*ino->i_ops.inop_close)(ino); goto out; } - cc = _sysio_ioctx_wait(ioctx); + cc = _sysio_ioctx_wait(&iocontext); err = (*ino->i_ops.inop_close)(ino); if (err) goto out; Index: read.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/read.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -b -B -p -r1.6 -r1.7 --- read.c 10 Oct 2003 18:50:31 -0000 1.6 +++ read.c 13 Oct 2003 01:04:35 -0000 1.7 @@ -62,11 +62,10 @@ static struct ioctx * do_ixreadv(struct file *fil, const struct iovec *iov, size_t count, _SYSIO_OFF_T offset, - void (*fcompletio)(struct ioctx *)) + void (*fcompletio)(struct ioctx *, struct file *)) { struct inode *ino; int err; - struct io_arguments ioarguments; struct ioctx *ioctx; if (fil->f_flags & O_WRONLY) { @@ -82,12 +81,21 @@ do_ixreadv(struct file *fil, errno = EBADF; return NULL; } - IOARG_INIT(&ioarguments, - iov, count, - offset, - (void (*)(void *))fcompletio, fil); - err = ino->i_ops.inop_ipreadv(fil->f_ino, &ioarguments, &ioctx); + ioctx = _sysio_ioctx_new(fil->f_ino, iov, count, offset); + if (!ioctx || + (fcompletio && + _sysio_ioctx_cb(ioctx, + (void (*)(struct ioctx *, void *))fcompletio, + fil) != 0)) { + err = -ENOMEM; + goto out; + } + err = ino->i_ops.inop_ipreadv(fil->f_ino, ioctx); +out: if (err) { + ioctx->ioctx_cc = -1; + ioctx->ioctx_errno = -err; + _sysio_ioctx_complete(ioctx); errno = -err; return NULL; } Index: write.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/write.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -b -B -p -r1.6 -r1.7 --- write.c 10 Oct 2003 18:50:31 -0000 1.6 +++ write.c 13 Oct 2003 01:04:35 -0000 1.7 @@ -64,11 +64,10 @@ static struct ioctx * do_ixwritev(struct file *fil, const struct iovec *iov, size_t count, _SYSIO_OFF_T offset, - void (*fcompletio)(struct ioctx *)) + void (*fcompletio)(struct ioctx *, struct file *)) { struct inode *ino; int err; - struct io_arguments ioarguments; struct ioctx *ioctx; if (fil->f_flags & O_RDONLY) { @@ -84,12 +83,21 @@ do_ixwritev(struct file *fil, errno = EBADF; return NULL; } - IOARG_INIT(&ioarguments, - iov, count, - offset, - (void (*)(void *))fcompletio, fil); - err = ino->i_ops.inop_ipwritev(fil->f_ino, &ioarguments, &ioctx); + ioctx = _sysio_ioctx_new(fil->f_ino, iov, count, offset); + if (!ioctx || + (fcompletio && + _sysio_ioctx_cb(ioctx, + (void (*)(struct ioctx *, void *))fcompletio, + fil) != 0)) { + err = -ENOMEM; + goto out; + } + err = ino->i_ops.inop_ipwritev(fil->f_ino, ioctx); +out: if (err) { + ioctx->ioctx_cc = -1; + ioctx->ioctx_errno = -err; + _sysio_ioctx_complete(ioctx); errno = -err; return NULL; } |
From: Lee W. <lw...@us...> - 2003-10-13 01:04:43
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs1:/tmp/cvs-serv31768/drivers/native Modified Files: fs_native.c Log Message: The IO context record supported one call-back. It now supports a chain. This was changed to accommodate the Sandia-PVFS driver. Also, it's needed for the, coming, {read,write}_strided calls. To add a callback to the chain use: _sysio_ioctx_cb(struct ioctx *ioctx, void (*func)(struct ioctx *, void *), void *data) Callbacks are added to the end of the existing chain. When called, by _sysio_io_complete, they are run in order. So... If you're freeing things using callbacks be careful not to depend on something in a later callback that you previously free'd. Also, _sysio_io_complete no longer waits for the driver. To call this, now, is to signal completion. Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -w -b -B -p -r1.18 -r1.19 --- fs_native.c 10 Oct 2003 18:50:31 -0000 1.18 +++ fs_native.c 13 Oct 2003 01:04:34 -0000 1.19 @@ -222,11 +222,9 @@ static int native_inop_link(struct pnode 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); + struct ioctx *ioctx); static int native_inop_ipwritev(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp); + struct ioctx *ioctx); static int native_inop_iodone(struct ioctx *ioctx); static int native_inop_fcntl(struct inode *ino, int cmd, va_list ap); static int native_inop_sync(struct inode *ino); @@ -1162,11 +1160,9 @@ native_inop_unlink(struct pnode *pno) static int doio(iof f, struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp) + struct ioctx *ioctx) { struct native_inode *nino = I2NI(ino); - struct ioctx *ioctx; #ifndef REDSTORM #if _LARGEFILE64_SOURCE loff_t result; @@ -1177,17 +1173,7 @@ doio(iof f, assert(nino->ni_fd >= 0); - if (ioargs->ioarg_iovlen && (int )ioargs->ioarg_iovlen < 0) - return -EINVAL; - - /* - * Get a new IO context. - */ - ioctx = _sysio_ioctx_new(ino, ioargs); - if (!ioctx) - return -ENOMEM; - - if ((ioargs->ioarg_iovlen && (int )ioargs->ioarg_iovlen < 0) || + if ((ioctx->ioctx_iovlen && (int )ioctx->ioctx_iovlen < 0) || !(S_ISREG(ino->i_mode) || S_ISCHR(ino->i_mode) || S_ISSOCK(ino->i_mode) || @@ -1259,7 +1245,6 @@ doio(iof f, if (ioctx->ioctx_cc > 0) nino->ni_fpos += ioctx->ioctx_cc; - *ioctxp = ioctx; out: return 0; } @@ -1309,11 +1294,10 @@ out: static int native_inop_ipreadv(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp) + struct ioctx *ioctx) { - return doio(native_read, ino, ioargs, ioctxp); + return doio(native_read, ino, ioctx); } /* @@ -1337,11 +1321,10 @@ native_write(int fd, const struct iovec static int native_inop_ipwritev(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp) + struct ioctx *ioctx) { - return doio(native_write, ino, ioargs, ioctxp); + return doio(native_write, ino, ioctx); } static int |
From: Lee W. <lw...@us...> - 2003-10-13 01:04:43
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs1:/tmp/cvs-serv31768/include Modified Files: dev.h file.h inode.h Log Message: The IO context record supported one call-back. It now supports a chain. This was changed to accommodate the Sandia-PVFS driver. Also, it's needed for the, coming, {read,write}_strided calls. To add a callback to the chain use: _sysio_ioctx_cb(struct ioctx *ioctx, void (*func)(struct ioctx *, void *), void *data) Callbacks are added to the end of the existing chain. When called, by _sysio_io_complete, they are run in order. So... If you're freeing things using callbacks be careful not to depend on something in a later callback that you previously free'd. Also, _sysio_io_complete no longer waits for the driver. To call this, now, is to signal completion. Index: dev.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/dev.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -w -b -B -p -r1.4 -r1.5 --- dev.h 10 Oct 2003 18:50:31 -0000 1.4 +++ dev.h 13 Oct 2003 01:04:34 -0000 1.5 @@ -111,12 +111,10 @@ extern const struct inode_ops _sysio_nod (int (*)(struct pnode *, struct pnode *))_sysio_dev_illop #define _sysio_nodev_inop_ipreadv \ (int (*)(struct inode *, \ - struct io_arguments *, \ - struct ioctx **))_sysio_dev_illop + struct ioctx *))_sysio_dev_illop #define _sysio_nodev_inop_ipwritev \ (int (*)(struct inode *, \ - struct io_arguments *, \ - struct ioctx **))_sysio_dev_illop + struct ioctx *))_sysio_dev_illop #define _sysio_nodev_inop_iodone \ (int (*)(struct ioctx *))_sysio_dev_illop #define _sysio_nodev_inop_fcntl \ Index: file.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/file.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -b -B -p -r1.6 -r1.7 --- file.h 10 Oct 2003 18:50:31 -0000 1.6 +++ file.h 13 Oct 2003 01:04:35 -0000 1.7 @@ -92,7 +92,7 @@ struct ioctx; extern struct file *_sysio_fnew(struct inode *ino, int flags); extern void _sysio_fgone(struct file *fil); -extern void _sysio_fcompletio(struct ioctx *ioctx); +extern void _sysio_fcompletio(struct ioctx *ioctx, struct file *fil); extern int _sysio_fd_close(int fd); extern struct file *_sysio_fd_find(int fd); extern int _sysio_fd_set(struct file *fil, int fd); Index: inode.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/inode.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -w -b -B -p -r1.10 -r1.11 --- inode.h 10 Oct 2003 18:50:31 -0000 1.10 +++ inode.h 13 Oct 2003 01:04:35 -0000 1.11 @@ -99,12 +99,8 @@ struct inode_ops { int (*inop_link)(struct pnode *old, struct pnode *new); int (*inop_unlink)(struct pnode *pno); int (*inop_rename)(struct pnode *old, struct pnode *new); - int (*inop_ipreadv)(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp); - int (*inop_ipwritev)(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp); + int (*inop_ipreadv)(struct inode *ino, struct ioctx *ioctx); + int (*inop_ipwritev)(struct inode *ino, struct ioctx *ioctx); int (*inop_iodone)(struct ioctx *iocp); int (*inop_fcntl)(struct inode *ino, int cmd, va_list ap); int (*inop_sync)(struct inode *ino); @@ -347,34 +343,22 @@ struct nameidata { } while (0) /* - * Bundled up arguments to file system driver IO calls. + * IO completion callback record. */ -struct io_arguments { - const struct iovec *ioarg_iovec; /* io vector */ - size_t ioarg_iovlen; /* iovec length */ - _SYSIO_OFF_T ioarg_offset; /* beginning offset */ - void (*ioarg_completion)(void *); /* callback */ - void *ioarg_completion_arg; /* callback data */ +struct ioctx_callback { + TAILQ_ENTRY(ioctx_callback) iocb_next; /* list link */ + void (*iocb_f)(struct ioctx *, void *); /* cb func */ + void *iocb_data; /* cb data */ }; /* - * Init IO arguments bundle. - */ -#define IOARG_INIT(ioarg, iov, len, off, cb, data) \ - do { \ - (ioarg)->ioarg_iovec = (iov); \ - (ioarg)->ioarg_iovlen = (len); \ - (ioarg)->ioarg_offset = (off); \ - (ioarg)->ioarg_completion = (cb); \ - (ioarg)->ioarg_completion_arg = (data); \ - } while (0) - -/* * All IO internally is done with an asynchronous mechanism. This record * holds the completion information. It's too big :-( */ struct ioctx { LIST_ENTRY(ioctx) ioctx_link; /* AIO list link */ + unsigned + ioctx_fast : 1; /* from stack space */ ioid_t ioctx_id; /* unique ident */ struct inode *ioctx_ino; /* i-node */ const struct iovec *ioctx_iovec; /* scatter/gather vec */ @@ -382,11 +366,25 @@ struct ioctx { _SYSIO_OFF_T ioctx_offset; /* file offset */ ssize_t ioctx_cc; /* rtn char count */ int ioctx_errno; /* error number */ - void (*ioctx_cb)(void *); /* callback */ - void *ioctx_data; /* callback data */ + TAILQ_HEAD(, ioctx_callback) ioctx_cbq; /* error number */ }; /* + * Init IO context record. + */ +#define IOCTX_INIT(ioctx, fast, id, ino, iov, iovlen, off) \ + do { \ + (ioctx)->ioctx_fast = (fast); \ + (ioctx)->ioctx_id = (id); \ + (ioctx)->ioctx_ino = (ino); \ + (ioctx)->ioctx_iovec = (iov); \ + (ioctx)->ioctx_iovlen = (iovlen); \ + (ioctx)->ioctx_offset = (off); \ + (ioctx)->ioctx_cc = 0; \ + (ioctx)->ioctx_errno = 0; \ + TAILQ_INIT(&(ioctx)->ioctx_cbq); \ + } while (0) +/* * Return whether a pnode/inode is on a read-only mount or file system. */ #define IS_RDONLY(pno, ino) \ @@ -450,7 +448,12 @@ extern int _sysio_namei(struct pnode *pn extern int _sysio_p_chdir(struct pnode *pno); extern int _sysio_ioctx_init(void); extern struct ioctx *_sysio_ioctx_new(struct inode *ino, - struct io_arguments *ioargs); + const struct iovec *iov, + size_t iovlen, + _SYSIO_OFF_T offset); +extern int _sysio_ioctx_cb(struct ioctx *ioctx, + void (*f)(struct ioctx *, void *), + void *data); extern struct ioctx *_sysio_ioctx_find(ioid_t id); extern ssize_t _sysio_ioctx_wait(struct ioctx *ioctx); extern void _sysio_ioctx_complete(struct ioctx *ioctx); |
From: Lee W. <lw...@us...> - 2003-10-13 01:04:43
|
Update of /cvsroot/libsysio/libsysio/dev/stdfd In directory sc8-pr-cvs1:/tmp/cvs-serv31768/dev/stdfd Modified Files: stdfd.c Log Message: The IO context record supported one call-back. It now supports a chain. This was changed to accommodate the Sandia-PVFS driver. Also, it's needed for the, coming, {read,write}_strided calls. To add a callback to the chain use: _sysio_ioctx_cb(struct ioctx *ioctx, void (*func)(struct ioctx *, void *), void *data) Callbacks are added to the end of the existing chain. When called, by _sysio_io_complete, they are run in order. So... If you're freeing things using callbacks be careful not to depend on something in a later callback that you previously free'd. Also, _sysio_io_complete no longer waits for the driver. To call this, now, is to signal completion. Index: stdfd.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/dev/stdfd/stdfd.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -b -B -p -r1.5 -r1.6 --- stdfd.c 10 Oct 2003 18:50:30 -0000 1.5 +++ stdfd.c 13 Oct 2003 01:04:34 -0000 1.6 @@ -79,11 +79,9 @@ static int stdfd_open(struct pnode *pno, int flags, mode_t mode); static int stdfd_close(struct inode *ino); static int stdfd_ipreadv(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp); + struct ioctx *ioctx); static int stdfd_ipwritev(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp); + struct ioctx *ioctx); static int stdfd_iodone(struct ioctx *ioctx); static int stdfd_datasync(struct inode *ino); static int stdfd_ioctl(struct inode *ino, @@ -128,18 +126,12 @@ stdfd_close(struct inode *ino __IS_UNUSE static int doio(ssize_t (*f)(int, char *, size_t), struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp) + struct ioctx *ioctx) { - struct ioctx *ioctx; const struct iovec *iov; size_t n; ssize_t cc = 0; - ioctx = _sysio_ioctx_new(ino, ioargs); - if (!ioctx) - return -ENOMEM; - iov = ioctx->ioctx_iovec; for (n = ioctx->ioctx_iovlen, iov = ioctx->ioctx_iovec; n--; @@ -159,7 +151,6 @@ doio(ssize_t (*f)(int, char *, size_t), ioctx->ioctx_errno = -cc; } - *ioctxp = ioctx; return 0; } @@ -172,11 +163,10 @@ stdfd_read(int fd, char *buf, size_t nby static int stdfd_ipreadv(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp) + struct ioctx *ioctx) { - return doio(stdfd_read, ino, ioargs, ioctxp); + return doio(stdfd_read, ino, ioctx); } static ssize_t @@ -190,14 +180,12 @@ stdfd_write(int fd, static int stdfd_ipwritev(struct inode *ino, - struct io_arguments *ioargs, - struct ioctx **ioctxp) + struct ioctx *ioctx) { return doio((ssize_t (*)(int, char *, size_t))stdfd_write, ino, - ioargs, - ioctxp); + ioctx); } static int |
From: Lee W. <le...@sa...> - 2003-10-10 18:57:08
|
Folks, The mega-merge, just completed, of the Red Storm branch was very intrusive. All ports in the head need to be retested. Other branches will probably experience conflicts, broken builds, etc. if/when you integrate/merge. Watch out! --Lee -- Lee Ward <le...@sa...> Sandia National Laboratories |
From: Lee W. <lw...@us...> - 2003-10-10 18:52:31
|
Update of /cvsroot/libsysio/libsysio/drivers/incore In directory sc8-pr-cvs1:/tmp/cvs-serv14350/drivers/incore Modified Files: fs_incore.c Log Message: Red Storm branch mega-merge. Please, no more changes to any of the Red Storm branches. We'll keep them for reference for awhile but then, they go away. Finally! Index: fs_incore.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/incore/fs_incore.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -b -B -p -r1.6 -r1.7 --- fs_incore.c 27 Sep 2003 19:42:01 -0000 1.6 +++ fs_incore.c 10 Oct 2003 18:50:31 -0000 1.7 @@ -56,7 +56,9 @@ #include <sys/types.h> #include <dirent.h> #include <sys/stat.h> +#ifdef _HAVE_STATVFS #include <sys/statvfs.h> +#endif #include <sys/queue.h> #include "sysio.h" @@ -132,7 +134,7 @@ static int _sysio_incore_inop_setattr(st static ssize_t _sysio_incore_dirop_getdirentries(struct inode *ino, char *buf, size_t nbytes, - off64_t *basep); + _SYSIO_OFF_T *basep); static int _sysio_incore_dirop_mkdir(struct pnode *pno, mode_t mode); static int _sysio_incore_dirop_rmdir(struct pnode *pno); static int _sysio_incore_inop_open(struct pnode *pno, int flags, mode_t mode); @@ -153,9 +155,11 @@ static int _sysio_incore_filop_ioctl(str unsigned long int request, va_list ap); static int _sysio_incore_dirop_mknod(struct pnode *pno, mode_t mode, dev_t dev); +#ifdef _HAVE_STATVFS static int _sysio_incore_inop_statvfs(struct pnode *pno, struct inode *ino, struct intnl_statvfs *buf); +#endif static void _sysio_incore_inop_gone(struct inode *ino); static int _sysio_incore_e_isdir(void); static int _sysio_incore_e_inval(void); @@ -205,7 +209,9 @@ static struct inode_ops _sysio_incore_di _sysio_incore_inop_sync, _sysio_incore_dirop_ioctl, _sysio_incore_dirop_mknod, +#ifdef _HAVE_STATVFS _sysio_incore_inop_statvfs, +#endif _sysio_incore_inop_gone }; @@ -218,7 +224,7 @@ static struct inode_ops _sysio_incore_di (ssize_t (*)(struct inode *, \ char *, \ size_t, \ - off64_t *))_sysio_incore_illop + _SYSIO_OFF_T *))_sysio_incore_illop #define _sysio_incore_filop_mkdir \ (int (*)(struct pnode *, mode_t))_sysio_incore_illop #define _sysio_incore_filop_rmdir \ @@ -258,7 +264,9 @@ static struct inode_ops _sysio_incore_fi _sysio_incore_inop_sync, _sysio_incore_filop_ioctl, _sysio_incore_filop_mknod, +#ifdef _HAVE_STATVFS _sysio_incore_inop_statvfs, +#endif _sysio_incore_inop_gone }; @@ -284,7 +292,9 @@ static struct inode_ops _sysio_incore_de _sysio_nodev_inop_sync, _sysio_nodev_inop_ioctl, _sysio_incore_filop_mknod, +#ifdef _HAVE_STATVFS _sysio_incore_inop_statvfs, +#endif _sysio_incore_inop_gone }; @@ -361,13 +371,27 @@ _sysio_incore_init() * Fill in the directory template. */ de = (struct intnl_dirent *)incore_dir_template; - de->d_off = off = de->d_reclen = INCORE_D_RECLEN(1); +#ifdef _DIRENT_HAVE_D_OFF + de->d_off = +#endif + off = de->d_reclen = INCORE_D_RECLEN(1); de->d_type = INCORE_D_TYPEOF(S_IFDIR); de->d_name[0] = '.'; - de->d_name[1] = ' '; - de = (void *)de + de->d_off; +#ifdef _DIRENT_HAVE_D_NAMLEN + de->d_namlen = 1; +#endif + /* + * Move to entry for `..' + */ + de = (void *)de + off; de->d_reclen = INCORE_D_RECLEN(2); - de->d_off = off += de->d_reclen; +#ifdef _DIRENT_HAVE_D_NAMLEN + de->d_namlen = 2; +#endif +#ifdef _DIRENT_HAVE_D_OFF + de->d_off = +#endif + off += de->d_reclen; de->d_type = INCORE_D_TYPEOF(S_IFDIR); de->d_name[0] = de->d_name[1] = '.'; de->d_name[2] = ' '; @@ -407,9 +431,9 @@ incore_i_alloc(struct incore_filesys *ic } static int -incore_trunc(struct incore_inode *icino, off64_t size, int clear) +incore_trunc(struct incore_inode *icino, _SYSIO_OFF_T size, int clear) { - off64_t n; + _SYSIO_OFF_T n; void *p; if (size < 0) @@ -477,7 +501,12 @@ incore_directory_new(struct incore_files sizeof(incore_dir_template)); de = icino->ici_data; de->d_ino = st->st_ino; - (void *)de += de->d_off; + (void *)de += +#ifdef _DIRENT_HAVE_D_OFF + de->d_off; +#else + de->d_reclen; +#endif de->d_ino = parent->ici_st.st_ino; /* @@ -695,7 +724,11 @@ _sysio_incore_fsop_gone(struct filesys * static void * incore_directory_probe(void *data, size_t siz, - off64_t origin, + _SYSIO_OFF_T origin +#ifndef _DIRENT_HAVE_D_OFF + __IS_UNUSED +#endif + , probe_ty entry, probe_ty hole, void *arg) @@ -706,15 +739,21 @@ incore_directory_probe(void *data, de = data; for (;;) { +#ifdef _DIRENT_HAVE_D_OFF assert(de->d_off); +#else + assert(de->d_reclen); +#endif if (entry && (p = (*entry)(de, de->d_reclen, arg))) return p; - n = de->d_off - origin; - if (hole && n > de->d_reclen) { - p = - (*hole)((void *)de + de->d_reclen, - n - de->d_reclen, - arg); + n = +#ifdef _DIRENT_HAVE_D_OFF + de->d_off - origin; +#else + ((void *)de - data) + de->d_reclen; +#endif + if (hole) { + p = (*hole)((void *)de, de->d_reclen, arg); if (p) return p; } @@ -732,7 +771,14 @@ incore_directory_match(struct intnl_dire struct lookup_data *ld) { - if (strlen(de->d_name) == ld->name->len && +#if defined(BSD) || defined(REDSTORM) + if (IFTODT(de->d_type) == DT_WHT) + return NULL; +#endif + if ( +#ifdef _DIRENT_HAVE_D_NAMLEN + ld->name->len == de->d_namlen && +#endif strncmp(de->d_name, ld->name->name, ld->name->len) == 0) return de; ld->de = de; @@ -893,6 +939,13 @@ struct copy_info { size_t nbytes; }; +/* + * Eumeration callback. + * + * Note: + * On those systems supporting white-out entries, they are returned. On + * systems without, they are not. + */ static void * incore_directory_enumerate(struct intnl_dirent *de, size_t reclen, @@ -910,7 +963,7 @@ static ssize_t _sysio_incore_dirop_getdirentries(struct inode *ino, char *buf, size_t nbytes, - off64_t *basep) + _SYSIO_OFF_T *basep) { struct incore_inode *icino = I2IC(ino); off_t off; @@ -974,7 +1027,9 @@ incore_directory_insert(struct incore_in size_t reclen; struct lookup_data lookup_data; struct intnl_dirent *de; + size_t xt; size_t n; + size_t r; reclen = INCORE_D_RECLEN(name->len); INCORE_LD_INIT(&lookup_data, reclen, name); @@ -988,39 +1043,74 @@ incore_directory_insert(struct incore_in if (de) return -EEXIST; de = lookup_data.de; - n = de->d_off; - if (n >= (size_t )parent->ici_st.st_size) { + xt = (void *)lookup_data.de - parent->ici_data; + n = +#ifdef _DIRENT_HAVE_D_OFF + de->d_off; +#else + xt + de->d_reclen; +#endif + r = +#ifdef _DIRENT_HAVE_D_OFF + de->d_reclen; +#else + INCORE_D_RECLEN(de->d_namlen); +#endif + if (!parent->ici_st.st_size || + xt + r + reclen > (size_t )parent->ici_st.st_size) { int err; - size_t xt; - xt = (void *)lookup_data.de - parent->ici_data; - err = - incore_trunc(parent, - ((size_t )((void *)de - parent->ici_data) + - de->d_reclen + - reclen), - 1); + err = incore_trunc(parent, xt + r + reclen, 1); if (err) return err; de = parent->ici_data + xt; n = parent->ici_st.st_size; } +#ifdef _DIRENT_HAVE_D_OFF + de->d_off = xt + r; /* trim */ +#else + de->d_reclen = r; +#endif + (void *)de += r; /* reposition */ + xt += r; + +#ifndef _DIRENT_HAVE_D_OFF /* - * Fix previous entry. + * Will we split this hole or use all of it? */ - de->d_off = (void *)de - parent->ici_data + de->d_reclen; + if (lookup_data.hole.len - reclen && + lookup_data.hole.len - reclen <= INCORE_D_RECLEN(1)) + reclen = lookup_data.hole.len; +#endif /* * Insert new. */ - (void *)de += de->d_reclen; de->d_ino = inum; +#ifdef _DIRENT_HAVE_D_OFF de->d_off = n; +#endif de->d_reclen = reclen; de->d_type = type; (void )memcpy(de->d_name, name->name, name->len); - de->d_name[name->len] = '\0'; +#ifdef _DIRENT_HAVE_D_NAMLEN + de->d_namlen = name->len; +#endif + +#ifndef _DIRENT_HAVE_D_OFF + xt += reclen; + if (n - xt) { + /* + * White-out remaining part of the hole. + */ + (void *)de += reclen; + de->d_ino = 0; + de->d_reclen = n - xt; + de->d_type = DT_WHT; + de->d_namlen = 0; + } +#endif /* * Update attributes to reflect the new entry. @@ -1110,6 +1200,10 @@ incore_unlink_entry(struct incore_inode { struct lookup_data lookup_data; struct intnl_dirent *de; + size_t reclen; +#ifdef _DIRENT_HAVE_D_OFF + size_t off; +#endif if (!S_ISDIR(icino->ici_st.st_mode)) return -ENOTDIR; @@ -1126,8 +1220,25 @@ incore_unlink_entry(struct incore_inode return -ENOENT; assert((size_t )((void *)de - icino->ici_data) >= sizeof(incore_dir_template)); - lookup_data.de->d_off = de->d_off; /* unlink */ - (void )memset(de, 0, de->d_reclen); /* clear */ +#ifndef _DIRENT_HAVE_D_OFF + reclen = de->d_reclen; +#else + off = de->d_off; + reclen = off - ((void *)de - icino->ici_data); +#endif + (void )memset(de, 0, reclen); +#ifndef _DIRENT_HAVE_D_OFF + de->d_type = (__uint8_t )DTTOIF(DT_WHT); + de->d_reclen = reclen; +#else + lookup_data.de->d_off = off; +#endif + + /* + * Adjust link count. + */ + assert(icino->ici_st.st_nlink > 2); + icino->ici_st.st_nlink--; /* * Adjust link count. @@ -1418,11 +1529,11 @@ incore_doio(ssize_t (*f)(struct incore_i static ssize_t incore_read(struct incore_inode *icino, off_t off, char *buf, size_t nbytes) { - off64_t n; + _SYSIO_OFF_T n; if (!nbytes || off > icino->ici_st.st_size) return 0; - n = (off64_t )nbytes; + n = (_SYSIO_OFF_T )nbytes; if (!(n > 0 && (size_t )n == nbytes)) return -EINVAL; if (n > icino->ici_st.st_size - off) @@ -1448,11 +1559,11 @@ incore_write(struct incore_inode *icino, size_t nbytes) { int err; - off64_t n; + _SYSIO_OFF_T n; if (!nbytes) return 0; - n = (off64_t )nbytes; + n = (_SYSIO_OFF_T )nbytes; if (!(n > 0 && (size_t )n == nbytes)) return -EINVAL; if (off + n > icino->ici_st.st_size) { @@ -1544,7 +1655,7 @@ _sysio_incore_dirop_mknod(struct pnode * return -EINVAL; /* - * Must create a new, regular, file. + * Initialize attributes. */ (void )memset(&stat, 0, sizeof(stat)); stat.st_dev = pno->p_parent->p_base->pb_ino->i_fs->fs_dev; @@ -1566,6 +1677,7 @@ _sysio_incore_dirop_mknod(struct pnode * return incore_create(pno, &stat); } +#ifdef _HAVE_STATVFS static int _sysio_incore_inop_statvfs(struct pnode *pno, struct inode *ino, @@ -1599,6 +1711,7 @@ _sysio_incore_inop_statvfs(struct pnode return 0; } +#endif void _sysio_incore_inop_gone(struct inode *ino) |