[Libsysio-commit] libsysio_tests: libsysio/src access.c Makefile.am file.c getdirentries.c inode.c l
Brought to you by:
lward
From: Sonja T. <so...@us...> - 2003-08-14 18:57:17
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv16559/libsysio/src Modified Files: Tag: libsysio_tests Makefile.am file.c getdirentries.c inode.c lseek.c namei.c Added Files: Tag: libsysio_tests access.c Log Message: Trying to get these missing files in again...it turns out I am not very good at CVS commands.. --- 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... */ #include <stdlib.h> #include <errno.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> int access(const char *path, int amode) { gid_t *list, *entry; size_t n; int err = 0; unsigned mask, mode; struct stat stbuf; err = 0; n = getgroups(0, NULL); list = NULL; if (n) { list = malloc(n * sizeof(gid_t)); if (!list) { err = -1; goto out; } } err = getgroups(n, list); if (err != (int ) n) goto out; err = stat(path, &stbuf); if (err) goto out; mask = 0; if (amode & R_OK) mask |= S_IRUSR; if (amode & W_OK) mask |= S_IWUSR; if (amode & X_OK) mask |= S_IXUSR; mode = stbuf.st_mode; if (stbuf.st_uid == getuid() && (mode & mask) == mask) goto out; mask >>= 3; if (stbuf.st_gid == getgid() && (mode & mask) == mask) goto out; entry = list; while (n--) if (stbuf.st_gid == *entry++ && (mode & mask) == mask) goto out; mask >>= 3; if ((mode & mask) == mask) goto out; err = -1; out: if (list) free(list); return err; } Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/Makefile.am,v retrieving revision 1.5 retrieving revision 1.5.8.1 diff -u -w -b -B -p -r1.5 -r1.5.8.1 --- Makefile.am 24 Mar 2003 22:09:06 -0000 1.5 +++ Makefile.am 14 Aug 2003 18:42:22 -0000 1.5.8.1 @@ -3,6 +3,6 @@ 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 + stat64.c statvfs.c symlink.c truncate.c unlink.c write.c access.c include $(top_srcdir)/Rules.make Index: file.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/file.c,v retrieving revision 1.4 retrieving revision 1.4.12.1 diff -u -w -b -B -p -r1.4 -r1.4.12.1 --- file.c 9 Mar 2003 17:18:57 -0000 1.4 +++ file.c 14 Aug 2003 18:42:22 -0000 1.4.12.1 @@ -128,7 +128,7 @@ fd_grow(size_t n) if (n < 8) n = 8; - if (n > _sysio_oftab_size && n - _sysio_oftab_size < _sysio_oftab_size) + if (n >= _sysio_oftab_size && n - _sysio_oftab_size < _sysio_oftab_size) n = (n + 1) * 2; noftab = realloc(_sysio_oftab, n * sizeof(struct file *)); if (!noftab) Index: getdirentries.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/getdirentries.c,v retrieving revision 1.1 retrieving revision 1.1.12.1 diff -u -w -b -B -p -r1.1 -r1.1.12.1 --- getdirentries.c 9 Mar 2003 13:53:53 -0000 1.1 +++ getdirentries.c 14 Aug 2003 18:42:22 -0000 1.1.12.1 @@ -64,7 +64,7 @@ getdirentries(int fd, char *buf, size_t off64_t ibase; ssize_t cc; struct dirent *dp, *nxtdp; - struct dirent64 *od64p, *d64p; + struct dirent64 *od64p = NULL, *d64p = NULL; size_t n; size_t reclen; char *cp; Index: inode.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v retrieving revision 1.7 retrieving revision 1.7.6.1 diff -u -w -b -B -p -r1.7 -r1.7.6.1 --- inode.c 23 Apr 2003 19:45:52 -0000 1.7 +++ inode.c 14 Aug 2003 18:42:22 -0000 1.7.6.1 @@ -265,6 +265,7 @@ _sysio_i_gone(struct inode *ino) if (ino->i_ref) abort(); + if (!ino->i_zombie) LIST_REMOVE(ino, i_link); TAILQ_REMOVE(&_sysio_inodes, ino, i_nodes); (*ino->i_ops.inop_gone)(ino); @@ -272,6 +273,17 @@ _sysio_i_gone(struct inode *ino) assert(n_inodes); n_inodes--; +} + +/* + * Stale inode, zombie it and move it out of the way + */ +void +_sysio_i_undead(struct inode *ino) +{ + + LIST_REMOVE(ino, i_link); + ino->i_zombie = 1; } /* Index: lseek.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/lseek.c,v retrieving revision 1.4 retrieving revision 1.4.6.1 diff -u -w -b -B -p -r1.4 -r1.4.6.1 --- lseek.c 27 Apr 2003 13:20:01 -0000 1.4 +++ lseek.c 14 Aug 2003 18:42:22 -0000 1.4.6.1 @@ -58,7 +58,7 @@ _sysio_lseek(int fd, off64_t offset, int { int err; struct file *fil; - off_t off; + off_t off = 0; struct intnl_stat stbuf; err = 0; Index: namei.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/namei.c,v retrieving revision 1.5 retrieving revision 1.5.8.1 diff -u -w -b -B -p -r1.5 -r1.5.8.1 --- namei.c 24 Mar 2003 22:09:06 -0000 1.5 +++ namei.c 14 Aug 2003 18:42:22 -0000 1.5.8.1 @@ -293,8 +293,7 @@ _sysio_path_walk(struct pnode *parent, s * Must send the intent-path again. */ path = nd->nd_path; - } else if (err == -ENOENT) - err = 0; + } if (!err) { P_RELE(pno); nd->nd_amcnt++; |