X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=libsysio%2Finclude%2Ffile.h;h=d30e84e86d8d0f91d3355d7878ad47ae0841cc9d;hp=ed15f6bb33b36fe887d93d69a08b1a3ebcab7af8;hb=79e65c81349f539aa2960a1889144ce71d91351e;hpb=b8292c00324fbe9a25910ce53d03569186ea3e2c diff --git a/libsysio/include/file.h b/libsysio/include/file.h index ed15f6b..d30e84e 100644 --- a/libsysio/include/file.h +++ b/libsysio/include/file.h @@ -9,7 +9,7 @@ * 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. + * Cplant(TM) Copyright 1998-2006 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 @@ -46,6 +46,28 @@ */ /* + * Test whether large file support on this file. + */ +#ifdef O_LARGEFILE +#define _F_LARGEFILE(fil) \ + ((fil)->f_flags & O_LARGEFILE) +#else +#define _F_LARGEFILE(fil) \ + (1) +#endif +/* + * Return max seek value for this file. + */ +#define _SEEK_MAX(fil) \ + (_F_LARGEFILE(fil) ? _SYSIO_OFF_T_MAX : LONG_MAX) + +#ifdef _LARGEFILE64_SOURCE +#define _SYSIO_FLOCK flock64 +#else +#define _SYSIO_FLOCK flock +#endif + +/* * A file record is maintained for each open file in the system. It holds * all the info necessary to track the context and parameters for the * operations that may be performed. @@ -64,7 +86,6 @@ struct file { do { \ (fil)->f_ref++; \ assert((fil)->f_ref); \ - I_REF((fil)->f_ino); \ } while (0) /* @@ -72,14 +93,10 @@ 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); \ - I_RELE(ino); \ } while (0) /* @@ -91,10 +108,25 @@ 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) +/* + * Determine if a file may be read/written. + * + * 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) == 'r' && !((_fil)->f_flags & O_WRONLY)) || \ + ((_c) == 'w' && ((_fil)->f_flags & (O_WRONLY | O_RDWR)))) + struct ioctx; extern struct file *_sysio_fnew(struct inode *ino, int flags); @@ -102,9 +134,13 @@ extern void _sysio_fgone(struct file *fil); 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 +#ifdef ZERO_SUM_MEMORY extern void _sysio_fd_shutdown(void); #endif +extern _SYSIO_OFF_T _sysio_lseek_prepare(struct file *fil, + _SYSIO_OFF_T offset, + int whence, + _SYSIO_OFF_T max);