[Libsysio-commit] HEAD: libsysio/include file.h inode.h
Brought to you by:
lward
From: Lee W. <lw...@us...> - 2006-05-03 22:31:09
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18135/include Modified Files: file.h inode.h Log Message: Some code cleanup. Support permission (and RO mount) checks in some routines. Added two new tests; test_mkdir and test_mknod. Index: file.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/file.h,v retrieving revision 1.14 retrieving revision 1.15 diff -u -w -b -B -p -r1.14 -r1.15 --- file.h 10 Apr 2006 23:25:54 -0000 1.14 +++ file.h 3 May 2006 22:31:04 -0000 1.15 @@ -115,18 +115,15 @@ struct file { /* * 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. + * 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. */ #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)) + (((_c) == O_RDONLY && \ + ((_fil)->f_flags & O_RDONLY || (_fil)->f_flags & O_RDWR)) || \ + ((_fil)->f_flags & O_WRONLY || (_fil)->f_flags & O_RDWR)) struct ioctx; Index: inode.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/inode.h,v retrieving revision 1.25 retrieving revision 1.26 diff -u -w -b -B -p -r1.25 -r1.26 --- inode.h 4 Aug 2005 20:17:10 -0000 1.25 +++ inode.h 3 May 2006 22:31:04 -0000 1.26 @@ -325,6 +325,7 @@ struct nameidata { */ #define ND_NOFOLLOW 0x01 /* no follow symlinks */ #define ND_NEGOK 0x02 /* last missing is ok */ +#define ND_NOPERMCHECK 0x04 /* don't check perms */ #ifdef AUTOMOUNT_FILE_NAME #define _ND_INIT_AUTOMOUNT(nd) ((nd)->nd_amcnt = 0) @@ -399,16 +400,10 @@ struct ioctx { } while (0) /* - * Return whether a pnode/inode is on a read-only mount or file system. + * Return whether access to a pnode is read-only. */ -#define IS_RDONLY(pno, ino) \ - ((((struct pnode *)(pno)) && \ - ((((struct pnode *)(pno))->p_mount->mnt_flags & MOUNT_F_RO) || \ - (((struct pnode *)(pno))->p_base->pb_ino && \ - (((struct pnode *)(pno))->p_base->pb_ino->i_fs->fs_flags & \ - FS_F_RO)))) || \ - (((struct inode *)(ino)) && \ - (((struct inode *)(ino))->i_fs->fs_flags & FS_F_RO))) +#define IS_RDONLY(pno) \ + ((pno)->p_mount->mnt_flags & MOUNT_F_RO) extern struct pnode *_sysio_root; @@ -463,7 +458,7 @@ extern int _sysio_path_walk(struct pnode #ifdef AUTOMOUNT_FILE_NAME extern void _sysio_next_component(const char *path, struct qstr *name); #endif -extern int _sysio_permitted(struct inode *ino, int amode); +extern int _sysio_permitted(struct pnode *pno, int amode); extern int _sysio_namei(struct pnode *pno, const char *path, unsigned flags, @@ -487,3 +482,5 @@ extern int _sysio_ioctx_done(struct ioct extern ssize_t _sysio_ioctx_wait(struct ioctx *ioctx); extern void _sysio_ioctx_complete(struct ioctx *ioctx); extern int _sysio_open(struct pnode *pno, int flags, mode_t mode); +extern int _sysio_mkdir(struct pnode *where, mode_t mode); +extern int _sysio_mknod(struct pnode *where, mode_t mode, dev_t dev); |