Thread: [Libsysio-commit] HEAD: libsysio/include file.h
Brought to you by:
lward
From: Lee W. <lw...@us...> - 2004-07-27 14:20:52
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2742/include Modified Files: file.h Log Message: _sysio_fd_dup2 name and usage has changed: 1) New name is _sysio_fd_dup 2) newfd < 0; Same behavior as before. 3) newfd >= 0 && force; Same behavior as before (dup2). 4) newfd >= 0 && !force; Find an available descriptor >= newfd (see fcntl-DUPFD) _sysio_set_fd usage has changed. It takes a new `force' flag. See discussion above (2, 3, and 4) for description. Fixed a bug in fcntl. The error return logic was wrong. Index: file.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/file.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -w -b -B -p -r1.9 -r1.10 --- file.h 28 Apr 2004 12:23:19 -0000 1.9 +++ file.h 27 Jul 2004 14:20:43 -0000 1.10 @@ -102,8 +102,8 @@ extern void _sysio_fgone(struct file *fi 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); -extern int _sysio_fd_dup2(int oldfd, int newfd); +extern int _sysio_fd_set(struct file *fil, int fd, int force); +extern int _sysio_fd_dup(int oldfd, int newfd, int force); extern int _sysio_fd_close_all(void); #if ZERO_SUM_MEMORY extern void _sysio_fd_shutdown(void); |
From: Lee W. <lw...@us...> - 2005-06-16 21:15:23
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13980/include Modified Files: file.h Log Message: Cease tracking the file opens by referencing the inode as well. F_INIT no longer takes the first reference. It must be done explicitly by the caller now. Index: file.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/file.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -w -b -B -p -r1.10 -r1.11 --- file.h 27 Jul 2004 14:20:43 -0000 1.10 +++ file.h 16 Jun 2005 21:14:39 -0000 1.11 @@ -64,7 +64,6 @@ struct file { do { \ (fil)->f_ref++; \ assert((fil)->f_ref); \ - I_REF((fil)->f_ino); \ } while (0) /* @@ -79,7 +78,6 @@ struct file { ino = (fil)->f_ino; \ if (!(fil)->f_ref) \ _sysio_fgone(fil); \ - I_RELE(ino); \ } while (0) /* @@ -91,7 +89,7 @@ struct file { do { \ (fil)->f_ino = (ino); \ (fil)->f_pos = 0; \ - (fil)->f_ref = 1; \ + (fil)->f_ref = 0; \ (fil)->f_flags = (flags); \ } while (0) |
From: Lee W. <lw...@us...> - 2005-10-31 19:47:50
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8158/include Modified Files: file.h Log Message: Extracting the inode pointer from the file reference is no longer necessary when dereferencing a handle. That code is removed. Index: file.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/file.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -w -b -B -p -r1.12 -r1.13 --- file.h 28 Oct 2005 17:59:31 -0000 1.12 +++ file.h 31 Oct 2005 19:47:42 -0000 1.13 @@ -93,11 +93,8 @@ struct file { */ #define F_RELE(fil) \ do { \ - struct inode *ino; \ - \ assert((fil)->f_ref); \ (fil)->f_ref--; \ - ino = (fil)->f_ino; \ if (!(fil)->f_ref) \ _sysio_fgone(fil); \ } while (0) |
From: Lee W. <lw...@us...> - 2006-04-10 23:25:58
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6661/include Modified Files: file.h Log Message: Add a new macro, F_CHKRW, that given a pointer to an open file table entry and one of 'r' or 'w' will return: 0 if the access is permitted against the open file -EBADF if not opened for the desired access -EROFS if 'w' and the file system was mounted read-only Then, using the new macro, implemented a check for the truncate/ftruncate calls to assure the file and mount will permit the operation before attempting it against the lower-level driver. Index: file.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/file.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -w -b -B -p -r1.13 -r1.14 --- file.h 31 Oct 2005 19:47:42 -0000 1.13 +++ file.h 10 Apr 2006 23:25:54 -0000 1.14 @@ -112,6 +112,22 @@ struct file { (fil)->f_flags = (flags); \ } while (0) +/* + * Determine if a file may be read/written. + * + * Give it the open file table ptr and a character indicating read, 'r', or + * write 'w'. It will return 0 if that access is permitted or -EBADF, if not. + */ + +#define F_CHKRW(_fil, _c) \ + ((_c) == O_RDONLY \ + ? (((_fil)->f_flags & O_RDONLY || (_fil)->f_flags & O_RDWR) \ + ? 0 \ + : -EBADF) \ + : (((_fil)->f_flags & O_WRONLY || (_fil)->f_flags & O_RDWR) \ + ? (IS_RDONLY(NULL, (_fil)->f_ino) ? -EROFS : 0) \ + : -EBADF)) + struct ioctx; extern struct file *_sysio_fnew(struct inode *ino, int flags); |
From: Lee W. <lw...@us...> - 2007-04-12 18:00:49
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv25748/include Modified Files: file.h Log Message: F_CHKRW macro in file.h was improperly implemented. Not according to comment. From Bob Glossman at Cray. Reimplemented and new implementation used in truncate.c Index: file.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/file.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -w -b -B -p -r1.16 -r1.17 --- file.h 3 May 2006 22:34:46 -0000 1.16 +++ file.h 12 Apr 2007 18:00:42 -0000 1.17 @@ -115,15 +115,17 @@ struct file { /* * Determine if a file may be read/written. * - * Given a ptr to an open file table entry and a flag indicating read or - * write return 0 if the file record indicates that the access is permitted - * or -EBADF, if not. + * Given a ptr to an open file table entry and a flag indicating desired + * access return non-zero if the file record indicates that the access is + * permitted or zero, if not. + * + * 'r' for read access check + * 'w' for write access check */ #define F_CHKRW(_fil, _c) \ - (((_c) == O_RDONLY && \ - ((_fil)->f_flags & O_RDONLY || (_fil)->f_flags & O_RDWR)) || \ - ((_fil)->f_flags & O_WRONLY || (_fil)->f_flags & O_RDWR)) + (((_c) == 'r' && !((_fil)->f_flags & O_WRONLY)) || \ + ((_c) == 'w' && ((_fil)->f_flags & (O_WRONLY | O_RDWR)))) struct ioctx; |
From: Lee W. <lw...@us...> - 2007-11-20 17:34:41
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv25701/include Modified Files: file.h Log Message: Add two new macros. F_FILEOK tests if the passed file ref is valid; Not NULL and fil->f_pno not NULL. F_WRITEOK tests if the passed file ref is valid and writeable. Index: file.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/file.h,v retrieving revision 1.19 retrieving revision 1.20 diff -u -w -b -B -p -r1.19 -r1.20 --- file.h 1 May 2007 16:33:52 -0000 1.19 +++ file.h 20 Nov 2007 17:34:38 -0000 1.20 @@ -113,6 +113,12 @@ struct file { } while (0) /* + * Valid file object? + */ +#define F_FILEOK(_fil) \ + ((_fil) && (_fil)->f_pno) + +/* * Determine if a file may be read/written. * * Given a ptr to an open file table entry and a flag indicating desired @@ -127,6 +133,15 @@ struct file { (((_c) == 'r' && !((_fil)->f_flags & O_WRONLY)) || \ ((_c) == 'w' && ((_fil)->f_flags & (O_WRONLY | O_RDWR)))) +/* + * Is file object writable? Return 0, if so. Otherwise, the appropriate + * (negated) error number. + */ +#define F_WRITEOK(_fil) \ + (!(F_FILEOK(_fil) && F_CHKRW((_fil), 'w')) \ + ? -EBADF \ + : (IS_RDONLY((_fil)->f_pno) ? -EROFS : 0)) + struct ioctx; extern struct file *_sysio_fnew(struct pnode *pno, int flags); |