Commit 632c7e08 authored by Stephen Lord's avatar Stephen Lord Committed by Stephen Lord

[XFS] Code cleanup

SGI Modid: 2.5.x-xfs:slinx:159439a
parent aa641e8a
...@@ -386,6 +386,7 @@ linvfs_readlink( ...@@ -386,6 +386,7 @@ linvfs_readlink(
uio.uio_segflg = UIO_USERSPACE; uio.uio_segflg = UIO_USERSPACE;
uio.uio_resid = size; uio.uio_resid = size;
uio.uio_iovcnt = 1; uio.uio_iovcnt = 1;
uio.uio_fmode = 0;
VOP_READLINK(vp, &uio, NULL, error); VOP_READLINK(vp, &uio, NULL, error);
if (error) if (error)
......
...@@ -28,6 +28,37 @@ ...@@ -28,6 +28,37 @@
* For further information regarding this notice, see: * For further information regarding this notice, see:
* *
* http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
*
* Portions Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/ */
#ifndef __XFS_VNODE_H__ #ifndef __XFS_VNODE_H__
#define __XFS_VNODE_H__ #define __XFS_VNODE_H__
...@@ -39,19 +70,9 @@ struct page_buf_bmap_s; ...@@ -39,19 +70,9 @@ struct page_buf_bmap_s;
struct attrlist_cursor_kern; struct attrlist_cursor_kern;
/* /*
* Vnode types (unrelated to on-disk inodes). VNON means no type. * Vnode types. VNON means no type.
*/ */
typedef enum vtype { enum vtype { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VFIFO, VBAD, VSOCK };
VNON = 0,
VREG = 1,
VDIR = 2,
VBLK = 3,
VCHR = 4,
VLNK = 5,
VFIFO = 6,
VBAD = 7,
VSOCK = 8
} vtype_t;
typedef xfs_ino_t vnumber_t; typedef xfs_ino_t vnumber_t;
typedef struct dentry vname_t; typedef struct dentry vname_t;
...@@ -115,14 +136,15 @@ typedef enum { ...@@ -115,14 +136,15 @@ typedef enum {
#define LINVFS_GET_IP(vp) (&(vp)->v_inode) #define LINVFS_GET_IP(vp) (&(vp)->v_inode)
/* /*
* Conversion between vnode types/modes and encoded type/mode as * Convert between vnode types and inode formats (since POSIX.1
* seen by stat(2) and mknod(2). * defines mode word of stat structure in terms of inode formats).
*/ */
extern enum vtype iftovt_tab[]; extern enum vtype iftovt_tab[];
extern ushort vttoif_tab[]; extern u_short vttoif_tab[];
#define IFTOVT(M) (iftovt_tab[((M) & S_IFMT) >> 12]) #define IFTOVT(mode) (iftovt_tab[((mode) & S_IFMT) >> 12])
#define VTTOIF(T) (vttoif_tab[(int)(T)]) #define VTTOIF(indx) (vttoif_tab[(int)(indx)])
#define MAKEIMODE(T, M) (VTTOIF(T) | ((M) & ~S_IFMT)) #define MAKEIMODE(indx, mode) (int)(VTTOIF(indx) | (mode))
/* /*
* Vnode flags. * Vnode flags.
...@@ -370,30 +392,29 @@ typedef struct vnodeops { ...@@ -370,30 +392,29 @@ typedef struct vnodeops {
/* /*
* Vnode attributes. va_mask indicates those attributes the caller * Vnode attributes. va_mask indicates those attributes the caller
* wants to set (setattr) or extract (getattr). * wants to set or extract.
*/ */
typedef struct vattr { typedef struct vattr {
int va_mask; /* bit-mask of attributes */ int va_mask; /* bit-mask of attributes present */
vtype_t va_type; /* vnode type (for create) */ enum vtype va_type; /* vnode type (for create) */
mode_t va_mode; /* file access mode */ mode_t va_mode; /* file access mode and type */
nlink_t va_nlink; /* number of references to file */
uid_t va_uid; /* owner user id */ uid_t va_uid; /* owner user id */
gid_t va_gid; /* owner group id */ gid_t va_gid; /* owner group id */
xfs_ino_t va_nodeid; /* node id */ xfs_ino_t va_nodeid; /* file id */
nlink_t va_nlink; /* number of references to file */
xfs_off_t va_size; /* file size in bytes */ xfs_off_t va_size; /* file size in bytes */
timespec_t va_atime; /* time of last access */ u_long va_blocksize; /* blocksize preferred for i/o */
timespec_t va_mtime; /* time of last modification */ struct timespec va_atime; /* time of last access */
timespec_t va_ctime; /* time file ``created'' */ struct timespec va_mtime; /* time of last modification */
xfs_dev_t va_rdev; /* device the file represents */ struct timespec va_ctime; /* time file changed */
u_long va_blksize; /* fundamental block size */ u_int va_gen; /* generation number of file */
__int64_t va_nblocks; /* # of blocks allocated */ xfs_dev_t va_rdev; /* device the special file represents */
u_long va_vcode; /* version code */ __int64_t va_nblocks; /* number of blocks allocated */
u_long va_xflags; /* random extended file flags */ u_long va_xflags; /* random extended file flags */
u_long va_extsize; /* file extent size */ u_long va_extsize; /* file extent size */
u_long va_nextents; /* number of extents in file */ u_long va_nextents; /* number of extents in file */
u_long va_anextents; /* number of attr extents in file */ u_long va_anextents; /* number of attr extents in file */
int va_projid; /* project id */ int va_projid; /* project id */
u_int va_gencount; /* object generation count */
} vattr_t; } vattr_t;
/* /*
...@@ -449,11 +470,17 @@ typedef struct vattr { ...@@ -449,11 +470,17 @@ typedef struct vattr {
XFS_AT_TYPE|XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_VCODE|\ XFS_AT_TYPE|XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_VCODE|\
XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_GENCOUNT) XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_GENCOUNT)
#define VREAD 00400 /*
#define VWRITE 00200 * Modes.
#define VEXEC 00100 */
#define VSGID 02000 /* set group id on execution */ #define VSUID S_ISUID /* set user id on execution */
#define MODEMASK 07777 /* mode bits plus permission bits */ #define VSGID S_ISGID /* set group id on execution */
#define VSVTX S_ISVTX /* save swapped text even after use */
#define VREAD S_IRUSR /* read, write, execute permissions */
#define VWRITE S_IWUSR
#define VEXEC S_IXUSR
#define MODEMASK S_IALLUGO /* mode bits plus permission bits */
/* /*
* Check whether mandatory file locking is enabled. * Check whether mandatory file locking is enabled.
...@@ -568,13 +595,9 @@ static __inline__ void vn_flagclr(struct vnode *vp, uint flag) ...@@ -568,13 +595,9 @@ static __inline__ void vn_flagclr(struct vnode *vp, uint flag)
* Flags to VOP_SETATTR/VOP_GETATTR. * Flags to VOP_SETATTR/VOP_GETATTR.
*/ */
#define ATTR_UTIME 0x01 /* non-default utime(2) request */ #define ATTR_UTIME 0x01 /* non-default utime(2) request */
#define ATTR_EXEC 0x02 /* invocation from exec(2) */
#define ATTR_COMM 0x04 /* yield common vp attributes */
#define ATTR_DMI 0x08 /* invocation from a DMI function */ #define ATTR_DMI 0x08 /* invocation from a DMI function */
#define ATTR_LAZY 0x80 /* set/get attributes lazily */ #define ATTR_LAZY 0x80 /* set/get attributes lazily */
#define ATTR_NONBLOCK 0x100 /* return EAGAIN if operation would block */ #define ATTR_NONBLOCK 0x100 /* return EAGAIN if operation would block */
#define ATTR_NOLOCK 0x200 /* Don't grab any conflicting locks */
#define ATTR_NOSIZETOK 0x400 /* Don't get the DVN_SIZE_READ token */
/* /*
* Flags to VOP_FSYNC and VOP_RECLAIM. * Flags to VOP_FSYNC and VOP_RECLAIM.
......
...@@ -165,9 +165,9 @@ typedef struct xfs_dquot_acct { ...@@ -165,9 +165,9 @@ typedef struct xfs_dquot_acct {
* Users are allowed to have a usage exceeding their softlimit for * Users are allowed to have a usage exceeding their softlimit for
* a period this long. * a period this long.
*/ */
#define XFS_QM_BTIMELIMIT DQ_BTIMELIMIT #define XFS_QM_BTIMELIMIT (7 * 24*60*60) /* 1 week */
#define XFS_QM_RTBTIMELIMIT DQ_BTIMELIMIT #define XFS_QM_RTBTIMELIMIT (7 * 24*60*60) /* 1 week */
#define XFS_QM_ITIMELIMIT DQ_FTIMELIMIT #define XFS_QM_ITIMELIMIT (7 * 24*60*60) /* 1 week */
#define XFS_QM_BWARNLIMIT 5 #define XFS_QM_BWARNLIMIT 5
#define XFS_QM_IWARNLIMIT 5 #define XFS_QM_IWARNLIMIT 5
......
...@@ -38,57 +38,37 @@ ...@@ -38,57 +38,37 @@
#include "debug.h" #include "debug.h"
#include "move.h" #include "move.h"
/* /* Read from kernel buffer at src to user/kernel buffer defined
* Move "n" bytes at byte address "cp"; "rw" indicates the direction * by the uio structure. Advance the pointer in the uio struct
* of the move, and the I/O parameters are provided in "uio", which is * as we go.
* update to reflect the data which was moved. Returns 0 on success or
* a non-zero errno on failure.
*/ */
int int
uiomove(void *cp, size_t n, enum uio_rw rw, struct uio *uio) uio_read(caddr_t src, size_t len, struct uio *uio)
{ {
register struct iovec *iov; struct iovec *iov;
u_int cnt; u_int cnt;
int error; int error;
while (n > 0 && uio->uio_resid) { if (len > 0 && uio->uio_resid) {
iov = uio->uio_iov; iov = uio->uio_iov;
cnt = (u_int)iov->iov_len; cnt = (u_int)iov->iov_len;
if (cnt == 0) { if (cnt == 0)
uio->uio_iov++; return 0;
uio->uio_iovcnt--; if (cnt > len)
continue; cnt = (u_int)len;
} if (uio->uio_segflg == UIO_USERSPACE) {
if (cnt > n) error = copy_to_user(iov->iov_base, src, cnt);
cnt = (u_int)n;
switch (uio->uio_segflg) {
case UIO_USERSPACE:
if (rw == UIO_READ)
error = copy_to_user(iov->iov_base, cp, cnt);
else
error = copy_from_user(cp, iov->iov_base, cnt);
if (error) if (error)
return EFAULT; return EFAULT;
break; } else if (uio->uio_segflg == UIO_SYSSPACE) {
memcpy(iov->iov_base, src, cnt);
} else {
case UIO_SYSSPACE:
if (rw == UIO_READ)
memcpy(iov->iov_base, cp, cnt);
else
memcpy(cp, iov->iov_base, cnt);
break;
default:
ASSERT(0); ASSERT(0);
break;
} }
iov->iov_base = (void *)((char *)iov->iov_base + cnt); iov->iov_base = (void *)((char *)iov->iov_base + cnt);
iov->iov_len -= cnt; iov->iov_len -= cnt;
uio->uio_resid -= cnt; uio->uio_resid -= cnt;
uio->uio_offset += cnt; uio->uio_offset += cnt;
cp = (void *)((char *)cp + cnt);
n -= cnt;
} }
return 0; return 0;
} }
...@@ -47,11 +47,6 @@ typedef struct uio { ...@@ -47,11 +47,6 @@ typedef struct uio {
ssize_t uio_resid; /* residual count */ ssize_t uio_resid; /* residual count */
} uio_t; } uio_t;
/*
* I/O direction.
*/
typedef enum uio_rw { UIO_READ, UIO_WRITE } uio_rw_t;
/* /*
* Segment flag values. * Segment flag values.
*/ */
...@@ -60,7 +55,6 @@ typedef enum uio_seg { ...@@ -60,7 +55,6 @@ typedef enum uio_seg {
UIO_SYSSPACE, /* uio_iov describes system space */ UIO_SYSSPACE, /* uio_iov describes system space */
} uio_seg_t; } uio_seg_t;
extern int uio_read (caddr_t, size_t, uio_t *);
extern int uiomove (void *, size_t, uio_rw_t, uio_t *);
#endif /* __XFS_SUPPORT_MOVE_H__ */ #endif /* __XFS_SUPPORT_MOVE_H__ */
...@@ -439,25 +439,21 @@ void xfs_dfork_next_set(xfs_dinode_t *dip, int w, int n); ...@@ -439,25 +439,21 @@ void xfs_dfork_next_set(xfs_dinode_t *dip, int w, int n);
/* /*
* File types (mode field) * File types (mode field)
*/ */
#define IFMT 0170000 /* type of file */ #define IFMT S_IFMT
#define IFIFO 0010000 /* named pipe (fifo) */ #define IFSOCK S_IFSOCK
#define IFCHR 0020000 /* character special */ #define IFLNK S_IFLNK
#define IFDIR 0040000 /* directory */ #define IFREG S_IFREG
#define IFBLK 0060000 /* block special */ #define IFBLK S_IFBLK
#define IFREG 0100000 /* regular */ #define IFDIR S_IFDIR
#define IFLNK 0120000 /* symbolic link */ #define IFCHR S_IFCHR
#define IFSOCK 0140000 /* socket */ #define IFIFO S_IFIFO
#define IFMNT 0160000 /* mount point */
#define ISUID S_ISUID
/* #define ISGID S_ISGID
* File execution and access modes. #define ISVTX S_ISVTX
*/ #define IREAD S_IRUSR
#define ISUID 04000 /* set user id on execution */ #define IWRITE S_IWUSR
#define ISGID 02000 /* set group id on execution */ #define IEXEC S_IXUSR
#define ISVTX 01000 /* sticky directory */
#define IREAD 0400 /* read, write, execute permissions */
#define IWRITE 0200
#define IEXEC 0100
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_DINODE) #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_DINODE)
xfs_dinode_t *xfs_buf_to_dinode(struct xfs_buf *bp); xfs_dinode_t *xfs_buf_to_dinode(struct xfs_buf *bp);
......
...@@ -773,7 +773,7 @@ xfs_dir2_put_dirent64_uio( ...@@ -773,7 +773,7 @@ xfs_dir2_put_dirent64_uio(
idbp->d_off = pa->cook; idbp->d_off = pa->cook;
idbp->d_name[namelen] = '\0'; idbp->d_name[namelen] = '\0';
memcpy(idbp->d_name, pa->name, namelen); memcpy(idbp->d_name, pa->name, namelen);
rval = uiomove((caddr_t)idbp, reclen, UIO_READ, uio); rval = uio_read((caddr_t)idbp, reclen, uio);
pa->done = (rval == 0); pa->done = (rval == 0);
return rval; return rval;
} }
......
...@@ -2225,7 +2225,7 @@ xfs_dir_put_dirent64_uio(xfs_dir_put_args_t *pa) ...@@ -2225,7 +2225,7 @@ xfs_dir_put_dirent64_uio(xfs_dir_put_args_t *pa)
idbp->d_off = pa->cook.o; idbp->d_off = pa->cook.o;
idbp->d_name[namelen] = '\0'; idbp->d_name[namelen] = '\0';
memcpy(idbp->d_name, pa->name, namelen); memcpy(idbp->d_name, pa->name, namelen);
retval = uiomove((caddr_t)idbp, reclen, UIO_READ, uio); retval = uio_read((caddr_t)idbp, reclen, uio);
pa->done = (retval == 0); pa->done = (retval == 0);
return retval; return retval;
} }
...@@ -188,7 +188,7 @@ xfs_getattr( ...@@ -188,7 +188,7 @@ xfs_getattr(
* stripe size through is not a good * stripe size through is not a good
* idea for now. * idea for now.
*/ */
vap->va_blksize = mp->m_swidth ? vap->va_blocksize = mp->m_swidth ?
/* /*
* If the underlying volume is a stripe, then * If the underlying volume is a stripe, then
* return the stripe width in bytes as the * return the stripe width in bytes as the
...@@ -205,7 +205,7 @@ xfs_getattr( ...@@ -205,7 +205,7 @@ xfs_getattr(
mp->m_writeio_log)); mp->m_writeio_log));
#else #else
vap->va_blksize = vap->va_blocksize =
/* /*
* Return the largest of the preferred buffer * Return the largest of the preferred buffer
* sizes since doing small I/Os into larger * sizes since doing small I/Os into larger
...@@ -223,13 +223,13 @@ xfs_getattr( ...@@ -223,13 +223,13 @@ xfs_getattr(
* realtime extent size or the realtime volume's * realtime extent size or the realtime volume's
* extent size. * extent size.
*/ */
vap->va_blksize = ip->i_d.di_extsize ? vap->va_blocksize = ip->i_d.di_extsize ?
(ip->i_d.di_extsize << mp->m_sb.sb_blocklog) : (ip->i_d.di_extsize << mp->m_sb.sb_blocklog) :
(mp->m_sb.sb_rextsize << mp->m_sb.sb_blocklog); (mp->m_sb.sb_rextsize << mp->m_sb.sb_blocklog);
} }
} else { } else {
vap->va_rdev = ip->i_df.if_u2.if_rdev; vap->va_rdev = ip->i_df.if_u2.if_rdev;
vap->va_blksize = BLKDEV_IOSIZE; vap->va_blocksize = BLKDEV_IOSIZE;
} }
vap->va_atime.tv_sec = ip->i_d.di_atime.t_sec; vap->va_atime.tv_sec = ip->i_d.di_atime.t_sec;
...@@ -289,8 +289,7 @@ xfs_getattr( ...@@ -289,8 +289,7 @@ xfs_getattr(
ip->i_d.di_anextents; ip->i_d.di_anextents;
else else
vap->va_anextents = 0; vap->va_anextents = 0;
vap->va_gencount = ip->i_d.di_gen; vap->va_gen = ip->i_d.di_gen;
vap->va_vcode = 0L;
all_done: all_done:
if (!(flags & ATTR_LAZY)) if (!(flags & ATTR_LAZY))
...@@ -1044,7 +1043,7 @@ xfs_readlink( ...@@ -1044,7 +1043,7 @@ xfs_readlink(
pathlen = (int)ip->i_d.di_size; pathlen = (int)ip->i_d.di_size;
if (ip->i_df.if_flags & XFS_IFINLINE) { if (ip->i_df.if_flags & XFS_IFINLINE) {
error = uiomove(ip->i_df.if_u1.if_data, pathlen, UIO_READ, uiop); error = uio_read(ip->i_df.if_u1.if_data, pathlen, uiop);
} }
else { else {
/* /*
...@@ -1075,8 +1074,7 @@ xfs_readlink( ...@@ -1075,8 +1074,7 @@ xfs_readlink(
byte_cnt = pathlen; byte_cnt = pathlen;
pathlen -= byte_cnt; pathlen -= byte_cnt;
error = uiomove(XFS_BUF_PTR(bp), byte_cnt, error = uio_read(XFS_BUF_PTR(bp), byte_cnt, uiop);
UIO_READ, uiop);
xfs_buf_relse (bp); xfs_buf_relse (bp);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment