diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 1998-08-31 05:13:30 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 1998-08-31 05:13:30 +0000 |
commit | 30ed0a197fb0271433d779fa72cef1e9f946acdb (patch) | |
tree | 4d8a397b4c8d27c7ae2896852d222e32f20b2c52 | |
parent | 1de9611a8756024513a888ef62be9f487f9dc81f (diff) |
indent the code and move around some includes, after discussion with Theo
-rw-r--r-- | sys/sys/xfs_attr.h | 133 | ||||
-rw-r--r-- | sys/sys/xfs_message.h | 390 | ||||
-rw-r--r-- | sys/sys/xfs_pioctl.h | 99 | ||||
-rw-r--r-- | sys/xfs/xfs_common.c | 18 | ||||
-rw-r--r-- | sys/xfs/xfs_common.h | 13 | ||||
-rw-r--r-- | sys/xfs/xfs_deb.h | 8 | ||||
-rw-r--r-- | sys/xfs/xfs_dev.c | 945 | ||||
-rw-r--r-- | sys/xfs/xfs_dev.h | 58 | ||||
-rw-r--r-- | sys/xfs/xfs_extern.h | 6 | ||||
-rw-r--r-- | sys/xfs/xfs_fs.h | 47 | ||||
-rw-r--r-- | sys/xfs/xfs_message.c | 250 | ||||
-rw-r--r-- | sys/xfs/xfs_msg_locl.h | 33 | ||||
-rw-r--r-- | sys/xfs/xfs_node.c | 571 | ||||
-rw-r--r-- | sys/xfs/xfs_node.h | 31 | ||||
-rw-r--r-- | sys/xfs/xfs_syscalls.c | 412 | ||||
-rw-r--r-- | sys/xfs/xfs_syscalls.h | 16 | ||||
-rw-r--r-- | sys/xfs/xfs_vfsops.c | 501 | ||||
-rw-r--r-- | sys/xfs/xfs_vnodeops.c | 1393 |
18 files changed, 2153 insertions, 2771 deletions
diff --git a/sys/sys/xfs_attr.h b/sys/sys/xfs_attr.h deleted file mode 100644 index a0812f2250f..00000000000 --- a/sys/sys/xfs_attr.h +++ /dev/null @@ -1,133 +0,0 @@ -/* $OpenBSD: xfs_attr.h,v 1.2 1998/08/30 17:35:44 art Exp $ */ -/* - * Copyright (c) 1998 Kungliga Tekniska Högskolan - * (Royal Institute of Technology, Stockholm, Sweden). - * 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 Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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. - */ - -/* $KTH: xfs_attr.h,v 1.7 1998/07/12 15:29:09 map Exp $ */ - -#ifndef _XFS_ATTR_H -#define _XFS_ATTR_H - -#define XA_V_NONE 0 -#define XA_V_MODE (1 << 0) -#define XA_V_NLINK (1 << 1) -#define XA_V_SIZE (1 << 2) -#define XA_V_UID (1 << 3) -#define XA_V_GID (1 << 4) -#define XA_V_ATIME (1 << 5) -#define XA_V_MTIME (1 << 6) -#define XA_V_CTIME (1 << 7) -#define XA_V_FILEID (1 << 8) -#define XA_V_TYPE (1 << 9) - -enum xfs_file_type { XFS_FILE_NON, XFS_FILE_REG, XFS_FILE_DIR, - XFS_FILE_BLK, XFS_FILE_CHR, XFS_FILE_LNK, - XFS_FILE_SOCK, XFS_FILE_FIFO, XFS_FILE_BAD }; - -#define XA_CLEAR(xa_p) \ - ((xa_p)->valid = XA_V_NONE) -#define XA_SET_MODE(xa_p, value) \ - (((xa_p)->valid) |= XA_V_MODE, ((xa_p)->xa_mode) = value) -#define XA_SET_NLINK(xa_p, value) \ - (((xa_p)->valid) |= XA_V_NLINK, ((xa_p)->xa_nlink) = value) -#define XA_SET_SIZE(xa_p, value) \ - (((xa_p)->valid) |= XA_V_SIZE, ((xa_p)->xa_size) = value) -#define XA_SET_UID(xa_p, value) \ - (((xa_p)->valid) |= XA_V_UID, ((xa_p)->xa_uid) = value) -#define XA_SET_GID(xa_p, value) \ - (((xa_p)->valid) |= XA_V_GID, ((xa_p)->xa_gid) = value) -#define XA_SET_ATIME(xa_p, value) \ - (((xa_p)->valid) |= XA_V_ATIME, ((xa_p)->xa_atime) = value) -#define XA_SET_MTIME(xa_p, value) \ - (((xa_p)->valid) |= XA_V_MTIME, ((xa_p)->xa_mtime) = value) -#define XA_SET_CTIME(xa_p, value) \ - (((xa_p)->valid) |= XA_V_CTIME, ((xa_p)->xa_ctime) = value) -#define XA_SET_FILEID(xa_p, value) \ - (((xa_p)->valid) |= XA_V_FILEID, ((xa_p)->xa_fileid) = value) -#define XA_SET_TYPE(xa_p, value) \ - (((xa_p)->valid) |= XA_V_TYPE, ((xa_p)->xa_type) = value) - - -#define XA_VALID_MODE(xa_p) \ - (((xa_p)->valid) & XA_V_MODE) -#define XA_VALID_NLINK(xa_p) \ - (((xa_p)->valid) & XA_V_NLINK) -#define XA_VALID_SIZE(xa_p) \ - (((xa_p)->valid) & XA_V_SIZE) -#define XA_VALID_UID(xa_p) \ - (((xa_p)->valid) & XA_V_UID) -#define XA_VALID_GID(xa_p) \ - (((xa_p)->valid) & XA_V_GID) -#define XA_VALID_ATIME(xa_p) \ - (((xa_p)->valid) & XA_V_ATIME) -#define XA_VALID_MTIME(xa_p) \ - (((xa_p)->valid) & XA_V_MTIME) -#define XA_VALID_CTIME(xa_p) \ - (((xa_p)->valid) & XA_V_CTIME) -#define XA_VALID_FILEID(xa_p) \ - (((xa_p)->valid) & XA_V_FILEID) -#define XA_VALID_TYPE(xa_p) \ - (((xa_p)->valid) & XA_V_TYPE) - -/* - * Under glibc and Linux, foo_t in the kernel is not the same type as - * foo_t in user-level. Therefore we need these defines. - */ - -#if !defined(HAVE_LINUX_TYPES_H) && !defined(__KERNEL__) -typedef mode_t __kernel_mode_t; -typedef nlink_t __kernel_nlink_t; -typedef off_t __kernel_off_t; -typedef uid_t __kernel_uid_t; -typedef gid_t __kernel_gid_t; -#endif - -struct xfs_attr { - u_int32_t valid; - __kernel_mode_t xa_mode; - __kernel_nlink_t xa_nlink; - __kernel_off_t xa_size; - __kernel_uid_t xa_uid; - __kernel_gid_t xa_gid; - time_t xa_atime; - time_t xa_mtime; - time_t xa_ctime; - u_int32_t xa_fileid; - enum xfs_file_type xa_type; -}; - -#endif /* _XFS_ATTR_H */ diff --git a/sys/sys/xfs_message.h b/sys/sys/xfs_message.h deleted file mode 100644 index 9a193a4c6ca..00000000000 --- a/sys/sys/xfs_message.h +++ /dev/null @@ -1,390 +0,0 @@ -/* $OpenBSD: xfs_message.h,v 1.2 1998/08/30 17:35:43 art Exp $ */ -/* - * Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska Högskolan - * (Royal Institute of Technology, Stockholm, Sweden). - * 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 Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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. - */ - -/* $Id: xfs_message.h,v 1.2 1998/08/30 17:35:43 art Exp $ */ - -#ifndef _xmsg_h -#define _xmsg_h - -#if !defined(__LINUX__) && !defined(HAVE_GLIBC) -#include <sys/types.h> -#include <sys/param.h> -#else -#include <linux/types.h> -#include <linux/param.h> -#endif - -#include <sys/xfs_attr.h> - -/* Temporary hack? */ -#define MAX_XMSG_SIZE (1024*64) - -typedef u_int32_t pag_t; - -/* - * The xfs_cred, if pag == 0, use uid - */ -struct xfs_cred { - __kernel_uid_t uid; - pag_t pag; -}; -typedef struct xfs_cred xfs_cred; - -#define MAXHANDLE (4*4) -#define MAXRIGHTS 8 - -#define XFS_ANONYMOUSID 32766 - -typedef struct xfs_handle { - u_int a, b, c, d; -} xfs_handle; - -#define xfs_handle_eq(p, q) \ -((p)->a == (q)->a && (p)->b == (q)->b && (p)->c == (q)->c && (p)->d == (q)->d) - -#define CACHEHANDLESIZE 4 - -typedef struct xfs_cache_handle { - u_char data[CACHEHANDLESIZE]; -} xfs_cache_handle; - -/* - * Tokens that apply to nodes, open modes and attributes. Shared - * reading might be used for exec and exclusive write for remove. - */ -#define XFS_OPEN_MASK 0x000f -#define XFS_OPEN_NR 0x0001 /* Normal reading, data might change */ -#define XFS_OPEN_SR 0x0002 /* Shared reading, data won't change */ -#define XFS_OPEN_NW 0x0004 /* Normal writing, multiple writers */ -#define XFS_OPEN_EW 0x0008 /* Exclusive writing (open really) */ - -#define XFS_ATTR_MASK 0x0030 -#define XFS_ATTR_R 0x0010 /* Attributes valid */ -#define XFS_ATTR_W 0x0020 /* Attributes valid and modifiable */ - -/* - * Tokens that apply to node data. - */ -#define XFS_DATA_MASK 0x00c0 -#define XFS_DATA_R 0x0040 /* Data valid */ -#define XFS_DATA_W 0x0080 /* Data valid and modifiable */ -#define XFS_LOCK_MASK 0x0300 -#define XFS_LOCK_R 0x0100 /* Data Shared locks? */ -#define XFS_LOCK_W 0x0200 /* Data Exclusive locks? */ - -#define XFS_ATTR_VALID XFS_ATTR_R -#define XFS_DATA_VALID XFS_DATA_W - -/* xfs_node.flags */ -#define XFS_DATA_DIRTY 0x0001 -#define XFS_ATTR_DIRTY 0x0002 - -/* Are necessary tokens available? */ -#define XFS_TOKEN_GOT(xn, tok) ((xn)->tokens & (tok)) -#define XFS_TOKEN_SET(xn, tok, mask) ((xn)->tokens |= ((tok) & (mask))) -#define XFS_TOKEN_CLEAR(xn, tok, mask) ((xn)->tokens &= ~((tok) & (mask))) - -/* definitions for the rights fields */ -#define XFS_RIGHT_R 0x01 /* may read? */ -#define XFS_RIGHT_W 0x02 /* may write? */ -#define XFS_RIGHT_X 0x04 /* may execute? */ - -struct xfs_msg_node { - xfs_handle handle; - u_int tokens; - struct xfs_attr attr; - pag_t id[MAXRIGHTS]; - u_char rights[MAXRIGHTS]; - u_char anonrights; -}; - -/* - * Messages passed through the xfs_dev. - */ -struct xfs_message_header { - u_int size; - u_int opcode; - u_int sequence_num; /* Private */ -}; - -/* - * Used by putdata flag - */ - -enum { XFS_READ = 1, XFS_WRITE = 2, XFS_NONBLOCK = 4, XFS_APPEND = 8}; - -/* - * Flags for inactivenode - */ - -enum { XFS_NOREFS = 1, XFS_DELETE = 2 }; - -/* - * Defined message types and their opcodes. - */ -#define XFS_MSG_VERSION 0 -#define XFS_MSG_WAKEUP 1 - -#define XFS_MSG_GETROOT 2 -#define XFS_MSG_INSTALLROOT 3 - -#define XFS_MSG_GETNODE 4 -#define XFS_MSG_INSTALLNODE 5 - -#define XFS_MSG_GETATTR 6 -#define XFS_MSG_INSTALLATTR 7 - -#define XFS_MSG_GETDATA 8 -#define XFS_MSG_INSTALLDATA 9 - -#define XFS_MSG_INACTIVENODE 10 -#define XFS_MSG_INVALIDNODE 11 - /* XXX Must handle dropped/revoked tokens better */ - -#define XFS_MSG_OPEN 12 - -#define XFS_MSG_PUTDATA 13 -#define XFS_MSG_PUTATTR 14 - -/* Directory manipulating messages. */ -#define XFS_MSG_CREATE 15 -#define XFS_MSG_MKDIR 16 -#define XFS_MSG_LINK 17 -#define XFS_MSG_SYMLINK 18 - -#define XFS_MSG_REMOVE 19 -#define XFS_MSG_RMDIR 20 - -#define XFS_MSG_RENAME 21 - -#define XFS_MSG_PIOCTL 22 -#define XFS_MSG_WAKEUP_DATA 23 - -#define XFS_MSG_COUNT 24 - -/* XFS_MESSAGE_WAKEUP */ -struct xfs_message_wakeup { - struct xfs_message_header header; - int sleepers_sequence_num; /* Where to send wakeup */ - int error; /* Return value */ -}; - -/* XFS_MESSAGE_GETROOT */ -struct xfs_message_getroot { - struct xfs_message_header header; - struct xfs_cred cred; -}; - -/* XFS_MESSAGE_INSTALLROOT */ -struct xfs_message_installroot { - struct xfs_message_header header; - struct xfs_msg_node node; -}; - -/* XFS_MESSAGE_GETNODE */ -struct xfs_message_getnode { - struct xfs_message_header header; - struct xfs_cred cred; - xfs_handle parent_handle; - char name[256]; /* XXX */ -}; - -/* XFS_MESSAGE_INSTALLNODE */ -struct xfs_message_installnode { - struct xfs_message_header header; - xfs_handle parent_handle; - char name[256]; /* XXX */ - struct xfs_msg_node node; -}; - -/* XFS_MESSAGE_GETATTR */ -struct xfs_message_getattr { - struct xfs_message_header header; - struct xfs_cred cred; - xfs_handle handle; -}; - -/* XFS_MESSAGE_INSTALLATTR */ -struct xfs_message_installattr { - struct xfs_message_header header; - struct xfs_msg_node node; -}; - -/* XFS_MESSAGE_GETDATA */ -struct xfs_message_getdata { - struct xfs_message_header header; - struct xfs_cred cred; - xfs_handle handle; - u_int tokens; -}; - -/* XFS_MESSAGE_INSTALLDATA */ -struct xfs_message_installdata { - struct xfs_message_header header; - struct xfs_msg_node node; - struct xfs_cache_handle cache_handle; -}; - -/* XFS_MSG_INACTIVENODE */ -struct xfs_message_inactivenode { - struct xfs_message_header header; - xfs_handle handle; - u_int flag; -}; - -/* XFS_MSG_INVALIDNODE */ -struct xfs_message_invalidnode { - struct xfs_message_header header; - xfs_handle handle; -}; - -/* XFS_MSG_OPEN */ -struct xfs_message_open { - struct xfs_message_header header; - struct xfs_cred cred; - xfs_handle handle; - u_int tokens; -}; - -/* XFS_MSG_PUTDATA */ -struct xfs_message_putdata { - struct xfs_message_header header; - xfs_handle handle; - struct xfs_attr attr; /* XXX ??? */ - struct xfs_cred cred; - u_int flag; -}; - -/* XFS_MSG_PUTATTR */ -struct xfs_message_putattr { - struct xfs_message_header header; - xfs_handle handle; - struct xfs_attr attr; - struct xfs_cred cred; -}; - -/* XFS_MSG_CREATE */ -struct xfs_message_create { - struct xfs_message_header header; - xfs_handle parent_handle; - char name[256]; /* XXX */ - struct xfs_attr attr; -#if 0 /* XXX ??? */ - enum vcexcl exclusive; -#endif - int mode; - struct xfs_cred cred; -}; - -/* XFS_MSG_MKDIR */ -struct xfs_message_mkdir { - struct xfs_message_header header; - xfs_handle parent_handle; - char name[256]; /* XXX */ - struct xfs_attr attr; - struct xfs_cred cred; -}; - -/* XFS_MSG_LINK */ -struct xfs_message_link { - struct xfs_message_header header; - xfs_handle parent_handle; - char name[256]; /* XXX */ - xfs_handle from_handle; - struct xfs_cred cred; -}; - -/* XFS_MSG_SYMLINK */ -struct xfs_message_symlink { - struct xfs_message_header header; - xfs_handle parent_handle; - char name[256]; /* XXX */ - char contents[2048]; /* XXX */ - struct xfs_attr attr; - struct xfs_cred cred; -}; - -/* XFS_MSG_REMOVE */ -struct xfs_message_remove { - struct xfs_message_header header; - xfs_handle parent_handle; - char name[256]; /* XXX */ - struct xfs_cred cred; -}; - -/* XFS_MSG_RMDIR */ -struct xfs_message_rmdir { - struct xfs_message_header header; - xfs_handle parent_handle; - char name[256]; /* XXX */ - struct xfs_cred cred; -}; - -/* XFS_MSG_RENAME */ -struct xfs_message_rename { - struct xfs_message_header header; - xfs_handle old_parent_handle; - char old_name[256]; /* XXX */ - xfs_handle new_parent_handle; - char new_name[256]; /* XXX */ - struct xfs_cred cred; -}; - -/* XFS_MSG_PIOCTL */ -struct xfs_message_pioctl { - struct xfs_message_header header; - int opcode ; - xfs_cred cred; /* XXX we should also use PAG */ - int insize; - int outsize; - char msg[2048] ; /* XXX */ - xfs_handle handle; -}; - - -/* XFS_MESSAGE_WAKEUP_DATA */ -struct xfs_message_wakeup_data { - struct xfs_message_header header; - int sleepers_sequence_num; /* Where to send wakeup */ - int error; /* Return value */ - int len; - char msg[2048] ; /* XXX */ -}; - -#endif /* _xmsg_h */ diff --git a/sys/sys/xfs_pioctl.h b/sys/sys/xfs_pioctl.h deleted file mode 100644 index 5efde785ed0..00000000000 --- a/sys/sys/xfs_pioctl.h +++ /dev/null @@ -1,99 +0,0 @@ -/* $OpenBSD: xfs_pioctl.h,v 1.1 1998/08/30 18:06:26 art Exp $ */ -/* - * Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Högskolan - * (Royal Institute of Technology, Stockholm, Sweden). - * 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 Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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 _SYS_PIOCTL_H_ -#define _SYS_PIOCTL_H_ - -/* - */ -#define AFSCALL_PIOCTL 20 -#define AFSCALL_SETPAG 21 - -#ifndef _VICEIOCTL -#define _VICEIOCTL(id) ((unsigned int ) _IOW('V', id, struct ViceIoctl)) -#endif /* _VICEIOCTL */ - -#define VIOCSETAL _VICEIOCTL(1) -#define VIOCGETAL _VICEIOCTL(2) -#define VIOCSETTOK _VICEIOCTL(3) -#define VIOCGETVOLSTAT _VICEIOCTL(4) -#define VIOCSETVOLSTAT _VICEIOCTL(5) -#define VIOCFLUSH _VICEIOCTL(6) -#define VIOCGETTOK _VICEIOCTL(8) -#define VIOCUNLOG _VICEIOCTL(9) -#define VIOCCKSERV _VICEIOCTL(10) -#define VIOCCKBACK _VICEIOCTL(11) -#define VIOCCKCONN _VICEIOCTL(12) -#define VIOCWHEREIS _VICEIOCTL(14) -#define VIOCACCESS _VICEIOCTL(20) -#define VIOCUNPAG _VICEIOCTL(21) -#define VIOCGETFID _VICEIOCTL(22) -#define VIOCSETCACHESIZE _VICEIOCTL(24) -#define VIOCFLUSHCB _VICEIOCTL(25) -#define VIOCNEWCELL _VICEIOCTL(26) -#define VIOCGETCELL _VICEIOCTL(27) -#define VIOC_AFS_DELETE_MT_PT _VICEIOCTL(28) -#define VIOC_AFS_STAT_MT_PT _VICEIOCTL(29) -#define VIOC_FILE_CELL_NAME _VICEIOCTL(30) -#define VIOC_GET_WS_CELL _VICEIOCTL(31) -#define VIOC_AFS_MARINER_HOST _VICEIOCTL(32) -#define VIOC_GET_PRIMARY_CELL _VICEIOCTL(33) -#define VIOC_VENUSLOG _VICEIOCTL(34) -#define VIOC_GETCELLSTATUS _VICEIOCTL(35) -#define VIOC_SETCELLSTATUS _VICEIOCTL(36) -#define VIOC_FLUSHVOLUME _VICEIOCTL(37) -#define VIOC_AFS_SYSNAME _VICEIOCTL(38) -#define VIOC_EXPORTAFS _VICEIOCTL(39) -#define VIOCGETCACHEPARAMS _VICEIOCTL(40) - -struct ViceIoctl { - caddr_t in, out; - short in_size; - short out_size; -}; - -struct ClearToken { - int32_t AuthHandle; - char HandShakeKey[8]; - int32_t ViceId; - int32_t BeginTimestamp; - int32_t EndTimestamp; -}; - -#endif diff --git a/sys/xfs/xfs_common.c b/sys/xfs/xfs_common.c index c40fc071b60..059a7611ef3 100644 --- a/sys/xfs/xfs_common.c +++ b/sys/xfs/xfs_common.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xfs_common.c,v 1.1 1998/08/30 16:47:20 art Exp $ */ +/* $OpenBSD: xfs_common.c,v 1.2 1998/08/31 05:13:13 art Exp $ */ /* * Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). @@ -44,22 +44,22 @@ RCSID("$KTH: xfs_common.c,v 1.6 1998/07/19 21:14:19 art Exp $"); -static u_int xfs_allocs; -static u_int xfs_frees; +static u_int xfs_allocs; +static u_int xfs_frees; void * xfs_alloc(u_int size) { - xfs_allocs++; - XFSDEB(XDEBMEM, ("xfs_alloc: xfs_allocs-xfs_frees %d\n", - xfs_allocs - xfs_frees)); - return malloc(size, M_TEMP, M_WAITOK); /* XXX - What kind? */ + xfs_allocs++; + XFSDEB(XDEBMEM, ("xfs_alloc: xfs_allocs-xfs_frees %d\n", + xfs_allocs - xfs_frees)); + return malloc(size, M_TEMP, M_WAITOK); /* XXX - What kind? */ } void xfs_free(void *ptr, u_int size) { - xfs_frees++; - free(ptr, M_TEMP); + xfs_frees++; + free(ptr, M_TEMP); } #endif diff --git a/sys/xfs/xfs_common.h b/sys/xfs/xfs_common.h index 1433e09bef4..ea927f3858a 100644 --- a/sys/xfs/xfs_common.h +++ b/sys/xfs/xfs_common.h @@ -1,4 +1,4 @@ -/* $OpenBSD: xfs_common.h,v 1.1 1998/08/30 16:47:20 art Exp $ */ +/* $OpenBSD: xfs_common.h,v 1.2 1998/08/31 05:13:21 art Exp $ */ /* * Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). @@ -39,19 +39,18 @@ /* $KTH: xfs_common.h,v 1.5 1998/07/13 20:36:36 art Exp $ */ -#ifndef _xfs_common_h -#define _xfs_common_h +#ifndef _XFS_XFS_COMMON_H_ +#define _XFS_XFS_COMMON_H_ #include <sys/malloc.h> #ifdef DEBUG -void *xfs_alloc(u_int size); -void xfs_free(void *, u_int size); +void *xfs_alloc __P((u_int size)); +void xfs_free __P((void *, u_int size)); #else #define xfs_alloc(s) malloc((s), M_TEMP, M_WAITOK) /* XXX - what kind? */ #define xfs_free(p, s) free((p), M_TEMP) #endif #define RCSID(x) - -#endif /* _xfs_common_h */ +#endif diff --git a/sys/xfs/xfs_deb.h b/sys/xfs/xfs_deb.h index 7b28784cc5c..cfec18d92af 100644 --- a/sys/xfs/xfs_deb.h +++ b/sys/xfs/xfs_deb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: xfs_deb.h,v 1.1 1998/08/30 16:47:20 art Exp $ */ +/* $OpenBSD: xfs_deb.h,v 1.2 1998/08/31 05:13:22 art Exp $ */ /* * Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). @@ -37,8 +37,8 @@ * SUCH DAMAGE. */ -#ifndef _xfs_deb_h -#define _xfs_deb_h +#ifndef _XFS_XFS_DEB_H_ +#define _XFS_XFS_DEB_H_ /* masks */ #define XDEBANY 0xffffffff @@ -60,4 +60,4 @@ extern int xfsdeb; #define XFSDEB(mask, args) do { ; } while (0) #endif -#endif /* _xfs_deb_h */ +#endif diff --git a/sys/xfs/xfs_dev.c b/sys/xfs/xfs_dev.c index 3b34ef61449..2e772181ecc 100644 --- a/sys/xfs/xfs_dev.c +++ b/sys/xfs/xfs_dev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xfs_dev.c,v 1.1 1998/08/30 16:47:20 art Exp $ */ +/* $OpenBSD: xfs_dev.c,v 1.2 1998/08/31 05:13:14 art Exp $ */ /* * Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). @@ -49,7 +49,7 @@ #include <sys/fcntl.h> #include <xfs/xfs_common.h> -#include <sys/xfs_message.h> +#include <xfs/xfs_message.h> #include <xfs/xfs_msg_locl.h> #include <xfs/xfs_dev.h> #include <xfs/xfs_fs.h> @@ -65,29 +65,30 @@ RCSID("$KTH: xfs_dev.c,v 1.14 1998/07/19 00:19:53 art Exp $"); * delivered or dropped. */ struct xfs_link { - struct xfs_link *prev, *next; - struct xfs_message_header *message; - u_int error_or_size; /* error on sleepq and size on - * messageq */ + struct xfs_link *prev; + struct xfs_link *next; + struct xfs_message_header *message; + u_int error_or_size; /* error on sleepq and size on + * messageq */ }; struct xfs_channel { - struct xfs_link messageq; /* Messages not yet read */ - struct xfs_link sleepq; /* Waiting for reply message */ - u_int nsequence; - struct proc *selecting_proc; - struct xfs_message_header *message_buffer; - int status; + struct xfs_link messageq; /* Messages not yet read */ + struct xfs_link sleepq; /* Waiting for reply message */ + u_int nsequence; + struct proc *selecting_proc; + struct xfs_message_header *message_buffer; + int status; #define CHANNEL_OPENED 0x1 }; static struct xfs_channel xfs_channel[NXFS]; static void -xfs_initq(struct xfs_link * q) +xfs_initq(struct xfs_link *q) { - q->next = q; - q->prev = q; + q->next = q; + q->prev = q; } /* Is this queue empty? */ @@ -98,162 +99,160 @@ xfs_initq(struct xfs_link * q) /* Append q with p */ static void -xfs_appendq(struct xfs_link * q, struct xfs_link * p) +xfs_appendq(struct xfs_link *q, struct xfs_link *p) { - p->next = q; - p->prev = q->prev; - p->prev->next = p; - q->prev = p; + p->next = q; + p->prev = q->prev; + p->prev->next = p; + q->prev = p; } static void -xfs_outq(struct xfs_link * p) +xfs_outq(struct xfs_link *p) { - p->next->prev = p->prev; - p->prev->next = p->next; - p->next = p->prev = 0; + p->next->prev = p->prev; + p->prev->next = p->next; + p->next = p->prev = 0; } /* * Only allow one open. */ int -xfs_devopen(dev_t dev, int flags, int devtype, struct proc * p) +xfs_devopen(dev_t dev, int flags, int devtype, struct proc *p) { - struct xfs_channel *chan; + struct xfs_channel *chan; - XFSDEB(XDEBDEV, ("xfs_devopen dev = %d.%d, flags = %d\n", major(dev), - minor(dev), flags)); + XFSDEB(XDEBDEV, ("xfs_devopen dev = %d.%d, flags = %d\n", major(dev), + minor(dev), flags)); - if (minor(dev) < 0 || minor(dev) >= NXFS) - return ENXIO; + if (minor(dev) < 0 || minor(dev) >= NXFS) + return ENXIO; - chan = &xfs_channel[minor(dev)]; + chan = &xfs_channel[minor(dev)]; - /* Only allow one reader/writer */ - if (chan->status & CHANNEL_OPENED) { - XFSDEB(XDEBDEV, ("xfs_devopen: already open\n")); - return EBUSY; - } else - chan->status |= CHANNEL_OPENED; + /* Only allow one reader/writer */ + if (chan->status & CHANNEL_OPENED) { + XFSDEB(XDEBDEV, ("xfs_devopen: already open\n")); + return EBUSY; + } else + chan->status |= CHANNEL_OPENED; - chan->message_buffer = xfs_alloc(MAX_XMSG_SIZE); + chan->message_buffer = xfs_alloc(MAX_XMSG_SIZE); - /* initalize the queues if they have not been initialized before */ - xfs_initq(&chan->sleepq); - xfs_initq(&chan->messageq); + /* initalize the queues if they have not been initialized before */ + xfs_initq(&chan->sleepq); + xfs_initq(&chan->messageq); - return 0; + return 0; } /* * Wakeup all sleepers and cleanup. */ int -xfs_devclose(dev_t dev, int flags, int devtype, struct proc * p) +xfs_devclose(dev_t dev, int flags, int devtype, struct proc *p) { - struct xfs_channel *chan = &xfs_channel[minor(dev)]; - struct xfs_link *first; + struct xfs_channel *chan = &xfs_channel[minor(dev)]; + struct xfs_link *first; - XFSDEB(XDEBDEV, ("xfs_devclose dev = %d, flags = %d\n", dev, flags)); + XFSDEB(XDEBDEV, ("xfs_devclose dev = %d, flags = %d\n", dev, flags)); - /* Sanity check, paranoia? */ - if (!(chan->status & CHANNEL_OPENED)) - panic("xfs_devclose never opened?"); + /* Sanity check, paranoia? */ + if (!(chan->status & CHANNEL_OPENED)) + panic("xfs_devclose never opened?"); - chan->status &= ~CHANNEL_OPENED; + chan->status &= ~CHANNEL_OPENED; - /* No one is going to read those messages so empty queue! */ - while (!xfs_emptyq(&chan->messageq)) { - XFSDEB(XDEBDEV, ("before outq(messageq)\n")); - first = chan->messageq.next; - xfs_outq(first); - if (first->error_or_size != 0) { - xfs_free(first, first->error_or_size); - first = NULL; - } - XFSDEB(XDEBDEV, ("after outq(messageq)\n")); - } - - /* Wakeup those waiting for replies that will never arrive. */ - while (!xfs_emptyq(&chan->sleepq)) { - XFSDEB(XDEBDEV, ("before outq(sleepq)\n")); - first = chan->sleepq.next; - xfs_outq(first); - first->error_or_size = ENODEV; - wakeup((caddr_t) first); - XFSDEB(XDEBDEV, ("after outq(sleepq)\n")); - } - - if (chan->message_buffer) { - xfs_free(chan->message_buffer, MAX_XMSG_SIZE); - chan->message_buffer = NULL; - } - - /* - * Free all xfs nodes. - * The force flag is set because we do not have any choice. - * - * Only try to unmount a mounted xfs... - */ - - if (xfs[minor(dev)].mp != NULL) { - - if (vfs_busy(xfs[minor(dev)].mp, 0, 0, p)) { - XFSDEB(XDEBNODE, ("xfs_dev_close: vfs_busy() --> BUSY\n")); - return EBUSY; + /* No one is going to read those messages so empty queue! */ + while (!xfs_emptyq(&chan->messageq)) { + XFSDEB(XDEBDEV, ("before outq(messageq)\n")); + first = chan->messageq.next; + xfs_outq(first); + if (first->error_or_size != 0) { + xfs_free(first, first->error_or_size); + first = NULL; + } + + XFSDEB(XDEBDEV, ("after outq(messageq)\n")); } - free_all_xfs_nodes(&xfs[minor(dev)], FORCECLOSE); - vfs_unbusy(xfs[minor(dev)].mp, p); + /* Wakeup those waiting for replies that will never arrive. */ + while (!xfs_emptyq(&chan->sleepq)) { + XFSDEB(XDEBDEV, ("before outq(sleepq)\n")); + first = chan->sleepq.next; + xfs_outq(first); + first->error_or_size = ENODEV; + wakeup((caddr_t) first); + XFSDEB(XDEBDEV, ("after outq(sleepq)\n")); + } - } + if (chan->message_buffer) { + xfs_free(chan->message_buffer, MAX_XMSG_SIZE); + chan->message_buffer = NULL; + } + /* + * Free all xfs nodes. + * The force flag is set because we do not have any choice. + * + * Only try to unmount a mounted xfs... + */ + + if (xfs[minor(dev)].mp != NULL) { + if (vfs_busy(xfs[minor(dev)].mp, 0, 0, p)) { + XFSDEB(XDEBNODE, ("xfs_dev_close: vfs_busy() BUSY\n")); + return EBUSY; + } + free_all_xfs_nodes(&xfs[minor(dev)], FORCECLOSE); + + vfs_unbusy(xfs[minor(dev)].mp, p); + } - return 0; + return 0; } /* * Move messages from kernel to user space. */ int -xfs_devread(dev_t dev, struct uio * uiop, int ioflag) +xfs_devread(dev_t dev, struct uio *uiop, int ioflag) { - struct xfs_channel *chan = &xfs_channel[minor(dev)]; - struct xfs_link *first; - int error = 0; - - XFSDEB(XDEBDEV, ("xfs_devread dev = %d\n", dev)); - - XFSDEB(XDEBDEV, ("xfs_devread: m = %p, m->prev = %p, m->next = %p\n", - &chan->messageq, chan->messageq.prev, chan->messageq.next)); - - while (!xfs_emptyq (&chan->messageq)) { - - /* Remove message */ - first = chan->messageq.next; - XFSDEB(XDEBDEV, ("xfs_devread: first = %p, " - "first->prev = %p, first->next = %p\n", - first, first->prev, first->next)); - - XFSDEB(XDEBDEV, ("xfs_devread: message->size = %u\n", - first->message->size)); - - error = uiomove((caddr_t) first->message, first->message->size, uiop); - if (error) - break; - - xfs_outq(first); - - if (first->error_or_size != 0) { - xfs_free(first, first->error_or_size); - first = NULL; + struct xfs_channel *chan = &xfs_channel[minor(dev)]; + struct xfs_link *first; + int error = 0; + + XFSDEB(XDEBDEV, ("xfs_devread dev = %d\n", dev)); + + XFSDEB(XDEBDEV, ("xfs_devread: m = %p, m->prev = %p, m->next = %p\n", + &chan->messageq, chan->messageq.prev, + chan->messageq.next)); + + while (!xfs_emptyq (&chan->messageq)) { + /* Remove message */ + first = chan->messageq.next; + XFSDEB(XDEBDEV, ("xfs_devread: first = %p, " + "first->prev = %p, first->next = %p\n", + first, first->prev, first->next)); + XFSDEB(XDEBDEV, ("xfs_devread: message->size = %u\n", + first->message->size)); + + error = uiomove((caddr_t) first->message, + first->message->size, uiop); + if (error) + break; + + xfs_outq(first); + + if (first->error_or_size != 0) { + xfs_free(first, first->error_or_size); + first = NULL; + } } - } - XFSDEB(XDEBDEV, ("xfs_devread done error = %d\n", error)); + XFSDEB(XDEBDEV, ("xfs_devread done error = %d\n", error)); - return error; + return error; } /* @@ -263,35 +262,36 @@ xfs_devread(dev_t dev, struct uio * uiop, int ioflag) int xfs_devwrite(dev_t dev, struct uio *uiop, int ioflag) { - struct xfs_channel *chan = &xfs_channel[minor(dev)]; - char *p; - int error; - u_int cnt; - struct xfs_message_header *msg_buf; - - XFSDEB(XDEBDEV, ("xfs_devwrite dev = %d\n", dev)); + struct xfs_channel *chan = &xfs_channel[minor(dev)]; + char *p; + int error; + u_int cnt; + struct xfs_message_header *msg_buf; + + XFSDEB(XDEBDEV, ("xfs_devwrite dev = %d\n", dev)); + + cnt = uiop->uio_resid; + error = uiomove((caddr_t) chan->message_buffer, MAX_XMSG_SIZE, uiop); + if (error != 0) + return error; + + cnt -= uiop->uio_resid; + + /* + * This thread handles the received message. + */ + for (p = (char *)chan->message_buffer; + cnt > 0; + p += msg_buf->size, cnt -= msg_buf->size) { + msg_buf = (struct xfs_message_header *)p; + error = xfs_message_receive (minor(dev), + msg_buf, + msg_buf->size, + uiop->uio_procp); + } - cnt = uiop->uio_resid; - error = uiomove((caddr_t) chan->message_buffer, MAX_XMSG_SIZE, uiop); - if (error != 0) + XFSDEB(XDEBDEV, ("xfs_devwrite error = %d\n", error)); return error; - - cnt -= uiop->uio_resid; - - /* - * This thread handles the received message. - */ - for (p = (char *)chan->message_buffer; - cnt > 0; - p += msg_buf->size, cnt -= msg_buf->size) { - msg_buf = (struct xfs_message_header *)p; - error = xfs_message_receive (minor(dev), - msg_buf, - msg_buf->size, - uiop->uio_procp); - } - XFSDEB(XDEBDEV, ("xfs_devwrite error = %d\n", error)); - return error; } /* @@ -300,13 +300,13 @@ xfs_devwrite(dev_t dev, struct uio *uiop, int ioflag) int #if defined(__NetBSD__) || defined(__OpenBSD__) -xfs_devioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc * p) +xfs_devioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) #elif defined(__FreeBSD__) -xfs_devioctl(dev_t dev, int cmd, caddr_t data, int flags, struct proc * p) +xfs_devioctl(dev_t dev, int cmd, caddr_t data, int flags, struct proc *p) #endif { - XFSDEB(XDEBDEV, ("xfs_devioctl dev = %d, flags = %d\n", dev, flags)); - return EINVAL; + XFSDEB(XDEBDEV, ("xfs_devioctl dev = %d, flags = %d\n", dev, flags)); + return EINVAL; } /* @@ -316,43 +316,45 @@ xfs_devioctl(dev_t dev, int cmd, caddr_t data, int flags, struct proc * p) static int xfs_realselect(dev_t dev, struct proc * p) { - struct xfs_channel *chan = &xfs_channel[minor(dev)]; + struct xfs_channel *chan = &xfs_channel[minor(dev)]; - if (!xfs_emptyq(&chan->messageq)) - return 1; /* Something to read */ + if (!xfs_emptyq(&chan->messageq)) + return 1; /* Something to read */ - /* - * No need to handle a "collission" since we only allow one - * concurrent open. */ - chan->selecting_proc = p; - return 0; + /* + * No need to handle a "collission" since we only allow one + * concurrent open. + */ + chan->selecting_proc = p; + + return 0; } #ifdef USE_POLL static int -xfs_devpoll(dev_t dev, int events, struct proc * p) +xfs_devpoll(dev_t dev, int events, struct proc *p) { - XFSDEB(XDEBDEV, ("xfs_devpoll dev = %d, events = %d\n", dev, events)); + XFSDEB(XDEBDEV, ("xfs_devpoll dev = %d, events = %d\n", dev, events)); - if (!(events & POLLRDNORM)) - return 0; + if (!(events & POLLRDNORM)) + return 0; - return xfs_realselect(dev, p); + return xfs_realselect(dev, p); } #endif #ifdef USE_SELECT int -xfs_devselect(dev_t dev, int which, struct proc * p) +xfs_devselect(dev_t dev, int which, struct proc *p) { - XFSDEB(XDEBDEV, ("xfs_devselect dev = %d, which = %d\n", dev, which)); + XFSDEB(XDEBDEV, ("xfs_devselect dev = %d, which = %d\n", dev, which)); - if (which != FREAD) - return 0; + if (which != FREAD) + return 0; - return xfs_realselect(dev, p); + return xfs_realselect(dev, p); } #endif @@ -363,41 +365,42 @@ xfs_devselect(dev_t dev, int which, struct proc * p) int xfs_message_send(int fd, struct xfs_message_header * message, u_int size) { - struct xfs_channel *chan = &xfs_channel[fd]; - struct { - struct xfs_link this_message; - struct xfs_message_header msg; - } *t; + struct xfs_channel *chan = &xfs_channel[fd]; + struct { + struct xfs_link this_message; + struct xfs_message_header msg; + } *t; - XFSDEB(XDEBMSG, ("xfs_message_send opcode = %d\n", message->opcode)); + XFSDEB(XDEBMSG, ("xfs_message_send opcode = %d\n", message->opcode)); - if (!(chan->status & CHANNEL_OPENED)) /* No receiver? */ - return ENODEV; + if (!(chan->status & CHANNEL_OPENED)) /* No receiver? */ + return ENODEV; - /* Prepare message and copy it later */ - message->size = size; - message->sequence_num = chan->nsequence++; + /* Prepare message and copy it later */ + message->size = size; + message->sequence_num = chan->nsequence++; - t = xfs_alloc(sizeof(t->this_message) + size); - t->this_message.error_or_size = sizeof(t->this_message) + size; - bcopy(message, &t->msg, size); + t = xfs_alloc(sizeof(t->this_message) + size); + t->this_message.error_or_size = sizeof(t->this_message) + size; + bcopy(message, &t->msg, size); - t->this_message.message = &t->msg; - xfs_appendq(&chan->messageq, &t->this_message); - if (chan->selecting_proc != 0 - && chan->selecting_proc->p_wchan == (caddr_t) & selwait) { - struct selinfo selinfo; + t->this_message.message = &t->msg; + xfs_appendq(&chan->messageq, &t->this_message); + if (chan->selecting_proc != 0 + && chan->selecting_proc->p_wchan == (caddr_t) & selwait) { + struct selinfo selinfo; #if defined(__NetBSD__) || defined(__FreeBSD__) - selinfo.si_pid = chan->selecting_proc->p_pid; + selinfo.si_pid = chan->selecting_proc->p_pid; #else - selinfo.si_selpid = chan->selecting_proc->p_pid; + selinfo.si_selpid = chan->selecting_proc->p_pid; #endif - selinfo.si_flags = 0; + selinfo.si_flags = 0; + + selwakeup(&selinfo); + chan->selecting_proc = 0; + } - selwakeup(&selinfo); - chan->selecting_proc = 0; - } return 0; } @@ -405,77 +408,83 @@ xfs_message_send(int fd, struct xfs_message_header * message, u_int size) * Send a message to user space and wait for reply. */ int -xfs_message_rpc(int fd, struct xfs_message_header * message, u_int size) +xfs_message_rpc(int fd, struct xfs_message_header *message, u_int size) { - int ret; - struct xfs_channel *chan = &xfs_channel[fd]; - struct xfs_link *this_message = xfs_alloc(sizeof(struct xfs_link)); - struct xfs_link *this_process = xfs_alloc(sizeof(struct xfs_link)); - struct xfs_message_header *msg; - - XFSDEB(XDEBMSG, ("xfs_message_rpc opcode = %d\n", message->opcode)); - - if (!(chan->status & CHANNEL_OPENED)) /* No receiver? */ - return ENODEV; - - if (size < sizeof(struct xfs_message_wakeup)) { - printf("XFS PANIC Error: Message to small to receive wakeup, opcode = %d\n", message->opcode); - return ENOMEM; - } - msg = xfs_alloc(size); - bcopy(message, msg, size); - - msg->size = size; - msg->sequence_num = chan->nsequence++; - this_message->error_or_size = 0; - this_message->message = msg; /* message; */ - this_process->message = msg; /* message; */ - xfs_appendq(&chan->messageq, this_message); - xfs_appendq(&chan->sleepq, this_process); - if (chan->selecting_proc != 0 - && chan->selecting_proc->p_wchan == (caddr_t) & selwait) { - struct selinfo selinfo; + int ret; + struct xfs_channel *chan = &xfs_channel[fd]; + struct xfs_link *this_message; + struct xfs_link *this_process; + struct xfs_message_header *msg; + + this_message = xfs_alloc(sizeof(struct xfs_link)); + this_process = xfs_alloc(sizeof(struct xfs_link)); + + XFSDEB(XDEBMSG, ("xfs_message_rpc opcode = %d\n", message->opcode)); + + if (!(chan->status & CHANNEL_OPENED)) /* No receiver? */ + return ENODEV; + +#ifdef DIAGNOSTIC + if (size < sizeof(struct xfs_message_wakeup)) { + printf("XFS Error: Message to small for wakeup, opcode = %d\n", + message->opcode); + return ENOMEM; + } +#endif + msg = xfs_alloc(size); + bcopy(message, msg, size); + + msg->size = size; + msg->sequence_num = chan->nsequence++; + this_message->error_or_size = 0; + this_message->message = msg; /* message; */ + this_process->message = msg; /* message; */ + xfs_appendq(&chan->messageq, this_message); + xfs_appendq(&chan->sleepq, this_process); + if (chan->selecting_proc != 0 + && chan->selecting_proc->p_wchan == (caddr_t) & selwait) { + struct selinfo selinfo; #if defined(__NetBSD__) || defined(__FreeBSD__) - selinfo.si_pid = chan->selecting_proc->p_pid; + selinfo.si_pid = chan->selecting_proc->p_pid; #else - selinfo.si_selpid = chan->selecting_proc->p_pid; + selinfo.si_selpid = chan->selecting_proc->p_pid; #endif - selinfo.si_flags = 0; - - selwakeup(&selinfo); - chan->selecting_proc = 0; - } - this_process->error_or_size = 0; - - if (tsleep((caddr_t) this_process, (PZERO + 1) | PCATCH, "hej", 0)) { - XFSDEB(XDEBMSG, ("caught signal\n")); - this_process->error_or_size = EINTR; - } - /* - * Caught signal, got reply message or device was closed. - * Need to clean up both messageq and sleepq. - */ - if (xfs_onq(this_message)) { - xfs_outq(this_message); - } - if (xfs_onq(this_process)) { - xfs_outq(this_process); - } - ret = this_process->error_or_size; - - XFSDEB(XDEBMSG, ("xfs_message_rpc opcode this_process->error_or_size = %d\n", this_process->error_or_size)); - XFSDEB(XDEBMSG, ("xfs_message_rpc opcode ((xfs_message_wakeup*)(this_process->message))->error = %d\n", ((struct xfs_message_wakeup *) (this_process->message))->error)); - - bcopy(msg, message, size); - - xfs_free(this_message, sizeof(*this_message)); - this_message = NULL; - xfs_free(this_process, sizeof(*this_process)); - this_process = NULL; - xfs_free(msg, size); - msg = NULL; - return ret; + selinfo.si_flags = 0; + + selwakeup(&selinfo); + chan->selecting_proc = 0; + } + this_process->error_or_size = 0; + + if (tsleep((caddr_t) this_process, (PZERO + 1) | PCATCH, "xfs", 0)) { + XFSDEB(XDEBMSG, ("caught signal\n")); + this_process->error_or_size = EINTR; + } + /* + * Caught signal, got reply message or device was closed. + * Need to clean up both messageq and sleepq. + */ + if (xfs_onq(this_message)) { + xfs_outq(this_message); + } + if (xfs_onq(this_process)) { + xfs_outq(this_process); + } + ret = this_process->error_or_size; + + XFSDEB(XDEBMSG, ("xfs_message_rpc this_process->error_or_size = %d\n", + this_process->error_or_size)); + XFSDEB(XDEBMSG, ("xfs_message_rpc this_process->error = %d\n", + ((struct xfs_message_wakeup *) (this_process->message))->error)); + + bcopy(msg, message, size); + + xfs_free(this_message, sizeof(*this_message)); + xfs_free(this_process, sizeof(*this_process)); + xfs_free(msg, size); + + return ret; } /* @@ -485,54 +494,55 @@ xfs_message_rpc(int fd, struct xfs_message_header * message, u_int size) */ int xfs_message_receive(int fd, - struct xfs_message_header *message, - u_int size, - struct proc *p) + struct xfs_message_header *message, + u_int size, + struct proc *p) { - XFSDEB(XDEBMSG, ("xfs_message_receive opcode = %d\n", message->opcode)); - - /* Dispatch and coerce message type */ - switch (message->opcode) { - case XFS_MSG_WAKEUP: - return xfs_message_wakeup(fd, - (struct xfs_message_wakeup *) message, - message->size, - p); - case XFS_MSG_WAKEUP_DATA: - return xfs_message_wakeup_data(fd, - (struct xfs_message_wakeup_data *) message, - message->size, - p); - case XFS_MSG_INSTALLROOT: - return xfs_message_installroot(fd, - (struct xfs_message_installroot *) message, - message->size, - p); - case XFS_MSG_INSTALLNODE: - return xfs_message_installnode(fd, - (struct xfs_message_installnode *) message, - message->size, - p); - case XFS_MSG_INSTALLATTR: - return xfs_message_installattr(fd, - (struct xfs_message_installattr *) message, - message->size, - p); - case XFS_MSG_INSTALLDATA: - return xfs_message_installdata(fd, - (struct xfs_message_installdata *) message, - message->size, - p); - case XFS_MSG_INVALIDNODE: + XFSDEB(XDEBMSG, ("xfs_message_receive opcode = %d\n", + message->opcode)); + + /* Dispatch and coerce message type */ + switch (message->opcode) { + case XFS_MSG_WAKEUP: + return xfs_message_wakeup(fd, + (struct xfs_message_wakeup *) message, + message->size, + p); + case XFS_MSG_WAKEUP_DATA: + return xfs_message_wakeup_data(fd, + (struct xfs_message_wakeup_data *) message, + message->size, + p); + case XFS_MSG_INSTALLROOT: + return xfs_message_installroot(fd, + (struct xfs_message_installroot *) message, + message->size, + p); + case XFS_MSG_INSTALLNODE: + return xfs_message_installnode(fd, + (struct xfs_message_installnode *) message, + message->size, + p); + case XFS_MSG_INSTALLATTR: + return xfs_message_installattr(fd, + (struct xfs_message_installattr *) message, + message->size, + p); + case XFS_MSG_INSTALLDATA: + return xfs_message_installdata(fd, + (struct xfs_message_installdata *) message, + message->size, + p); + case XFS_MSG_INVALIDNODE: return xfs_message_invalidnode(fd, - (struct xfs_message_invalidnode *) message, - message->size, - p); - default: - printf("XFS PANIC Warning xfs_dev: Unknown message opcode == %d\n", - message->opcode); - return EINVAL; - } + (struct xfs_message_invalidnode *) message, + message->size, + p); + default: + printf("XFS Warning xfs_dev: Unknown message opcode == %d\n", + message->opcode); + return EINVAL; + } } int @@ -541,48 +551,54 @@ xfs_message_wakeup(int fd, u_int size, struct proc *p) { - struct xfs_channel *chan = &xfs_channel[fd]; - struct xfs_link *sleepq = &chan->sleepq; - struct xfs_link *t = chan->sleepq.next; /* Really first in q */ - - XFSDEB(XDEBMSG, ("xfs_message_wakeup error: %d\n", message->error)); - - for (; t != sleepq; t = t->next) - if (t->message->sequence_num == message->sleepers_sequence_num) { - if (t->message->size < size) { - printf("XFS PANIC Error: Could not wakeup requestor with opcode = %d properly, to small receive buffer.\n", t->message->opcode); - t->error_or_size = ENOMEM; - } else - bcopy(message, t->message, size); - wakeup((caddr_t) t); - break; - } - return 0; + struct xfs_channel *chan = &xfs_channel[fd]; + struct xfs_link *sleepq = &chan->sleepq; + struct xfs_link *t = chan->sleepq.next; /* Really first in q */ + + XFSDEB(XDEBMSG, ("xfs_message_wakeup error: %d\n", message->error)); + + for (; t != sleepq; t = t->next) + if (t->message->sequence_num == + message->sleepers_sequence_num) { + if (t->message->size < size) { + printf("XFS Error: Could not wakeup requestor with opcode = %d properly, to small receive buffer.\n", t->message->opcode); + t->error_or_size = ENOMEM; + } else + bcopy(message, t->message, size); + + wakeup((caddr_t) t); + break; + } + + return 0; } int xfs_message_wakeup_data(int fd, - struct xfs_message_wakeup_data * message, + struct xfs_message_wakeup_data *message, u_int size, struct proc *p) { - struct xfs_channel *chan = &xfs_channel[fd]; - struct xfs_link *sleepq = &chan->sleepq; - struct xfs_link *t = chan->sleepq.next; /* Really first in q */ - - XFSDEB(XDEBMSG, ("xfs_message_wakeup_data error: %d\n", message->error)); - - for (; t != sleepq; t = t->next) - if (t->message->sequence_num == message->sleepers_sequence_num) { - if (t->message->size < size) { - printf("XFS PANIC Error: Could not wakeup requestor with opcode = %d properly, to small receive buffer.\n", t->message->opcode); - t->error_or_size = ENOMEM; - } else - bcopy(message, t->message, size); - wakeup((caddr_t) t); - break; - } - return 0; + struct xfs_channel *chan = &xfs_channel[fd]; + struct xfs_link *sleepq = &chan->sleepq; + struct xfs_link *t = chan->sleepq.next; /* Really first in q */ + + XFSDEB(XDEBMSG, ("xfs_message_wakeup_data error: %d\n", + message->error)); + + for (; t != sleepq; t = t->next) + if (t->message->sequence_num == + message->sleepers_sequence_num) { + if (t->message->size < size) { + printf("XFS PANIC Error: Could not wakeup requestor with opcode = %d properly, to small receive buffer.\n", t->message->opcode); + t->error_or_size = ENOMEM; + } else + bcopy(message, t->message, size); + wakeup((caddr_t) t); + break; + } + + return 0; } #ifdef ACTUALLY_LKM_NOT_KERNEL @@ -593,22 +609,22 @@ static int xfs_uprintf_device(void) { #if 0 - int i; - - for (i = 0; i < NXFS; i++) { - uprintf("xfs_channel[%d] = {\n", i); - uprintf("messageq.next = 0x%x ", (u_int) xfs_channel[i].messageq.next); - uprintf("messageq.prev = 0x%x ", (u_int) xfs_channel[i].messageq.prev); - uprintf("sleepq.next = 0x%x ", (u_int) xfs_channel[i].sleepq.next); - uprintf("sleepq.prev = 0x%x ", (u_int) xfs_channel[i].sleepq.prev); - uprintf("nsequence = %d selecting_proc = 0x%x status = %d\n", - xfs_channel[i].nsequence, - (u_int) xfs_channel[i].selecting_proc, - xfs_channel[i].status); - uprintf("}\n"); - } + int i; + + for (i = 0; i < NXFS; i++) { + uprintf("xfs_channel[%d] = {\n", i); + uprintf("messageq.next = 0x%x ", (u_int) xfs_channel[i].messageq.next); + uprintf("messageq.prev = 0x%x ", (u_int) xfs_channel[i].messageq.prev); + uprintf("sleepq.next = 0x%x ", (u_int) xfs_channel[i].sleepq.next); + uprintf("sleepq.prev = 0x%x ", (u_int) xfs_channel[i].sleepq.prev); + uprintf("nsequence = %d selecting_proc = 0x%x status = %d\n", + xfs_channel[i].nsequence, + (u_int) xfs_channel[i].selecting_proc, + xfs_channel[i].status); + uprintf("}\n"); + } #endif - return 0; + return 0; } /* @@ -617,36 +633,36 @@ xfs_uprintf_device(void) #if defined(__NetBSD__) || defined(__OpenBSD__) static struct cdevsw xfs_dev = { - xfs_devopen, - xfs_devclose, - xfs_devread, - xfs_devwrite, - xfs_devioctl, - (dev_type_stop((*))) enodev, - 0, + xfs_devopen, + xfs_devclose, + xfs_devread, + xfs_devwrite, + xfs_devioctl, + (dev_type_stop((*))) enodev, + 0, #ifdef __OpenBSD__ - xfs_devselect, + xfs_devselect, #else - xfs_devpoll, + xfs_devpoll, #endif - (dev_type_mmap((*))) enodev, - 0 + (dev_type_mmap((*))) enodev, + 0 }; #elif defined(__FreeBSD__) static struct cdevsw xfs_dev = { - xfs_devopen, - xfs_devclose, - xfs_devread, - xfs_devwrite, - xfs_devioctl, - nostop, - noreset, - nodevtotty, - xfs_devselect, - nommap, - nostrategy, - NULL, - 0 + xfs_devopen, + xfs_devclose, + xfs_devread, + xfs_devwrite, + xfs_devioctl, + nostop, + noreset, + nodevtotty, + xfs_devselect, + nommap, + nostrategy, + NULL, + 0 }; #endif @@ -658,66 +674,67 @@ static struct cdevsw dev_olddev; int xfs_install_device(void) { - int i; - - /* - * Search the table looking for a slot... - */ - for (i = 0; i < nchrdev; i++) - if (cdevsw[i].d_open == (dev_type_open((*))) lkmenodev) - break; /* found it! */ - /* out of allocable slots? */ - if (i == nchrdev) { - XFSDEB(XDEBDEV, ("xfs_install_device: no available slots\n")); - return (ENFILE); - } - - /* save old */ - dev_olddev = cdevsw[i]; - - /* replace with new */ - cdevsw[i] = xfs_dev; - - printf("done installing cdev !\n"); - - /* done! */ - dev_offset = i; - - printf("Char device number %d\n", i); - - for (i = 0; i < NXFS; i++) { - XFSDEB(XDEBDEV, ("before initq(messageq and sleepq)\n")); - xfs_initq(&xfs_channel[i].messageq); - xfs_initq(&xfs_channel[i].sleepq); - xfs_channel[i].status = 0; - } - return 0; + int i; + + /* + * Search the table looking for a slot... + */ + for (i = 0; i < nchrdev; i++) + if (cdevsw[i].d_open == (dev_type_open((*))) lkmenodev) + break; /* found it! */ + /* out of allocable slots? */ + if (i == nchrdev) { + XFSDEB(XDEBDEV, ("xfs_install_device: no available slots\n")); + return (ENFILE); + } + + /* save old */ + dev_olddev = cdevsw[i]; + + /* replace with new */ + cdevsw[i] = xfs_dev; + + printf("done installing cdev !\n"); + + /* done! */ + dev_offset = i; + + printf("Char device number %d\n", i); + + for (i = 0; i < NXFS; i++) { + XFSDEB(XDEBDEV, ("before initq(messageq and sleepq)\n")); + xfs_initq(&xfs_channel[i].messageq); + xfs_initq(&xfs_channel[i].sleepq); + xfs_channel[i].status = 0; + } + + return 0; } int xfs_uninstall_device(void) { - int i; - dev_t dev; - struct xfs_channel *chan; - - for (i = 0; i < NXFS; i++) { - dev = makedev(dev_offset, i); - chan = &xfs_channel[minor(dev)]; - if (chan->status & CHANNEL_OPENED) - xfs_devclose(dev, 0, 0, NULL); - } + int i; + dev_t dev; + struct xfs_channel *chan; + + for (i = 0; i < NXFS; i++) { + dev = makedev(dev_offset, i); + chan = &xfs_channel[minor(dev)]; + if (chan->status & CHANNEL_OPENED) + xfs_devclose(dev, 0, 0, NULL); + } - /* replace current slot contents with old contents */ - cdevsw[dev_offset] = dev_olddev; + /* replace current slot contents with old contents */ + cdevsw[dev_offset] = dev_olddev; - return 0; + return 0; } int xfs_stat_device(void) { - return xfs_uprintf_device(); + return xfs_uprintf_device(); } #elif defined(__FreeBSD__) @@ -725,49 +742,49 @@ xfs_stat_device(void) int xfs_install_device(void) { - int i; - int err; - dev_t dev = NODEV; - - err = cdevsw_add(&dev, - &xfs_dev, - NULL); - if (err) - return err; - printf("char device number %d\n", major(dev)); - - for (i = 0; i < NXFS; i++) { - XFSDEB(XDEBDEV, ("before initq(messageq and sleepq)\n")); - xfs_initq(&xfs_channel[i].messageq); - xfs_initq(&xfs_channel[i].sleepq); - } + int i; + int err; + dev_t dev = NODEV; + + err = cdevsw_add(&dev, + &xfs_dev, + NULL); + if (err) + return err; + printf("char device number %d\n", major(dev)); + + for (i = 0; i < NXFS; i++) { + XFSDEB(XDEBDEV, ("before initq(messageq and sleepq)\n")); + xfs_initq(&xfs_channel[i].messageq); + xfs_initq(&xfs_channel[i].sleepq); + } - return 0; + return 0; } int xfs_uninstall_device(void) { - int i; - struct xfs_channel *chan; - dev_t dev = makedev(xfs_dev.d_maj, 0); - - for (i = 0; i < NXFS; i++) { - chan = &xfs_channel[minor(dev)]; - if (chan->status & CHANNEL_OPENED) - xfs_devclose(dev, 0, 0, NULL); - } + int i; + struct xfs_channel *chan; + dev_t dev = makedev(xfs_dev.d_maj, 0); + + for (i = 0; i < NXFS; i++) { + chan = &xfs_channel[minor(dev)]; + if (chan->status & CHANNEL_OPENED) + xfs_devclose(dev, 0, 0, NULL); + } - /* replace current slot contents with old contents */ - cdevsw_add(&dev, NULL, NULL); + /* replace current slot contents with old contents */ + cdevsw_add(&dev, NULL, NULL); - return 0; + return 0; } int xfs_stat_device(void) { - return xfs_uprintf_device(); + return xfs_uprintf_device(); } #endif diff --git a/sys/xfs/xfs_dev.h b/sys/xfs/xfs_dev.h index 24c90f012c9..4b95a68959c 100644 --- a/sys/xfs/xfs_dev.h +++ b/sys/xfs/xfs_dev.h @@ -1,4 +1,4 @@ -/* $OpenBSD: xfs_dev.h,v 1.1 1998/08/30 16:47:21 art Exp $ */ +/* $OpenBSD: xfs_dev.h,v 1.2 1998/08/31 05:13:23 art Exp $ */ /* * Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). @@ -39,44 +39,32 @@ /* $KTH: xfs_dev.h,v 1.4 1998/04/05 18:19:50 art Exp $ */ -#ifndef _xfs_dev_h -#define _xfs_dev_h +#ifndef _XFS_XFS_DEV_H_ +#define _XFS_XFS_DEV_H_ -int xfs_devopen(dev_t dev, int flags, int devtype, struct proc * p); +int xfs_devopen __P((dev_t dev, int flags, int devtype, struct proc * p)); -int xfs_install_device(void); -int xfs_uninstall_device(void); +int xfs_install_device __P((void)); +int xfs_uninstall_device __P((void)); -int xfs_install_filesys(void); -int xfs_uninstall_filesys(void); +int xfs_install_filesys __P((void)); +int xfs_uninstall_filesys __P((void)); -int xfs_stat_filesys(void); -int xfs_stat_device(void); - -int -xfs_message_send(int fd, struct xfs_message_header * message, u_int size); - -int -xfs_message_rpc(int fd, struct xfs_message_header * message, u_int size); - -int -xfs_message_receive(int fd, - struct xfs_message_header *message, - u_int size, - struct proc *p); - -int -xfs_message_wakeup(int fd, - struct xfs_message_wakeup *message, - u_int size, - struct proc *p); - -int -xfs_message_wakeup_data(int fd, - struct xfs_message_wakeup_data * message, - u_int size, - struct proc *p); +int xfs_stat_filesys __P((void)); +int xfs_stat_device __P((void)); +int xfs_message_send __P((int fd, struct xfs_message_header *message, + u_int size)); +int xfs_message_rpc __P((int fd, struct xfs_message_header *message, + u_int size)); +int xfs_message_receive __P((int fd,struct xfs_message_header *message, + u_int size,struct proc *p)); +int xfs_message_wakeup __P((int fd, struct xfs_message_wakeup *message, + u_int size, struct proc *p)); +int xfs_message_wakeup_data __P((int fd, + struct xfs_message_wakeup_data *message, + u_int size, struct proc *p)); #define USE_SELECT -#endif /* _xfs_dev_h */ +#endif + diff --git a/sys/xfs/xfs_extern.h b/sys/xfs/xfs_extern.h index 6cc4e5b7f15..1816c704035 100644 --- a/sys/xfs/xfs_extern.h +++ b/sys/xfs/xfs_extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: xfs_extern.h,v 1.2 1998/08/30 17:35:42 art Exp $ */ +/* $OpenBSD: xfs_extern.h,v 1.3 1998/08/31 05:13:25 art Exp $ */ /* * Copyright (c) 1998 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). @@ -37,8 +37,8 @@ * SUCH DAMAGE. */ -#ifndef _XFS_XFS_EXTERN_H -#define _XFS_XFS_EXTERN_H +#ifndef _XFS_XFS_EXTERN_H_ +#define _XFS_XFS_EXTERN_H_ #ifdef _KERNEL diff --git a/sys/xfs/xfs_fs.h b/sys/xfs/xfs_fs.h index d52b1bf09c3..007c32e706f 100644 --- a/sys/xfs/xfs_fs.h +++ b/sys/xfs/xfs_fs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: xfs_fs.h,v 1.1 1998/08/30 16:47:21 art Exp $ */ +/* $OpenBSD: xfs_fs.h,v 1.2 1998/08/31 05:13:26 art Exp $ */ /* * Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). @@ -39,27 +39,25 @@ /* $KTH: xfs_fs.h,v 1.8 1998/04/04 01:17:26 art Exp $ */ -#ifndef _xfs_h -#define _xfs_h +#ifndef _XFS_XFS_H_ +#define _XFS_XFS_H_ #include <sys/types.h> #include <xfs/xfs_node.h> -#include <sys/xfs_attr.h> - -#define NXFS 2 /* maximal number of filesystems on a single device */ +#include <xfs/xfs_attr.h> +#include <xfs/nxfs.h> /* * Filesystem struct. */ struct xfs { - u_int status; /* Inited, opened or mounted */ + u_int status; /* Inited, opened or mounted */ #define XFS_MOUNTED 0x1 - struct mount *mp; - struct xfs_node *root; - u_int nnodes; - - int fd; + struct mount *mp; + struct xfs_node *root; + u_int nnodes; + int fd; }; #define VFS_TO_XFS(v) ((struct xfs *) ((v)->mnt_data)) @@ -72,19 +70,20 @@ extern struct xfs xfs[]; extern struct vnodeops xfs_vnodeops; -struct xfs_node *xfs_node_find(struct xfs *, struct xfs_handle *); -int new_xfs_node(struct xfs *, struct xfs_msg_node *, struct xfs_node **, - struct proc *); -void free_xfs_node(struct xfs_node *); -int free_all_xfs_nodes(struct xfs *, int); +struct xfs_node *xfs_node_find __P((struct xfs *, struct xfs_handle *)); +int new_xfs_node __P((struct xfs *, struct xfs_msg_node *, struct xfs_node **, + struct proc *)); +void free_xfs_node __P((struct xfs_node *)); +int free_all_xfs_nodes __P((struct xfs *, int)); -int xfs_dnlc_enter(struct vnode *, char *, struct vnode *); -void xfs_dnlc_purge(struct mount *); -int xfs_dnlc_lookup(struct vnode *, struct componentname *, struct vnode **); +int xfs_dnlc_enter __P((struct vnode *, char *, struct vnode *)); +void xfs_dnlc_purge __P((struct mount *)); +int xfs_dnlc_lookup __P((struct vnode *, struct componentname *, + struct vnode **)); -void vattr2xfs_attr(const struct vattr * va, struct xfs_attr *xa); -void xfs_attr2vattr(const struct xfs_attr *xa, struct vattr * va); +void vattr2xfs_attr __P((const struct vattr * va, struct xfs_attr *xa)); +void xfs_attr2vattr __P((const struct xfs_attr *xa, struct vattr * va)); -int xfs_has_pag(const struct xfs_node *xn, pag_t pag); +int xfs_has_pag __P((const struct xfs_node *xn, pag_t pag)); -#endif /* _xfs_h */ +#endif diff --git a/sys/xfs/xfs_message.c b/sys/xfs/xfs_message.c index 1300a6cf043..aa554861d99 100644 --- a/sys/xfs/xfs_message.c +++ b/sys/xfs/xfs_message.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xfs_message.c,v 1.1 1998/08/30 16:47:21 art Exp $ */ +/* $OpenBSD: xfs_message.c,v 1.2 1998/08/31 05:13:15 art Exp $ */ /* * Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). @@ -45,167 +45,171 @@ #include <xfs/xfs_common.h> #include <xfs/xfs_deb.h> #include <xfs/xfs_fs.h> -#include <sys/xfs_message.h> +#include <xfs/xfs_message.h> #include <xfs/xfs_msg_locl.h> RCSID("$KTH: xfs_message.c,v 1.16 1998/07/19 00:19:54 art Exp $"); int xfs_message_installroot(int fd, - struct xfs_message_installroot * message, + struct xfs_message_installroot *message, u_int size, struct proc *p) { - int error = 0; - - XFSDEB(XDEBMSG, ("xfs_message_installroot\n")); - - if (xfs[fd].root != NULL) { - printf("XFS PANIC WARNING! xfs_message_installroot: called again!\n"); - error = EBUSY; - } else { - error = new_xfs_node(&xfs[fd], &message->node, &xfs[fd].root, p); - if (error) - return error; - xfs[fd].root->vn->v_flag |= VROOT; - } - return error; + int error = 0; + + XFSDEB(XDEBMSG, ("xfs_message_installroot\n")); + + if (xfs[fd].root != NULL) { + printf("XFS WARNING! xfs_message_installroot: again!\n"); + error = EBUSY; + } else { + error = new_xfs_node(&xfs[fd], &message->node, &xfs[fd].root, + p); + if (error) + return error; + xfs[fd].root->vn->v_flag |= VROOT; + } + + return error; } int xfs_message_installnode(int fd, - struct xfs_message_installnode * message, + struct xfs_message_installnode *message, u_int size, struct proc *p) { - int error = 0; - struct xfs_node *n, *dp; - - XFSDEB(XDEBMSG, ("xfs_message_installnode\n")); - - dp = xfs_node_find(&xfs[fd], &message->parent_handle); - if (dp) { - error = new_xfs_node(&xfs[fd], &message->node, &n, p); - if (error) - return error; - cache_purge (XNODE_TO_VNODE(dp)); - xfs_dnlc_enter(XNODE_TO_VNODE(dp), message->name, XNODE_TO_VNODE(n)); - vrele(XNODE_TO_VNODE(n)); - } else { - printf("XFS PANIC WARNING! xfs_message_installnode: no parent\n"); - error = ENOENT; - } - XFSDEB(XDEBMSG, ("return: xfs_message_installnode: %d\n", error)); - - return error; + int error = 0; + struct xfs_node *n, *dp; + + XFSDEB(XDEBMSG, ("xfs_message_installnode\n")); + + dp = xfs_node_find(&xfs[fd], &message->parent_handle); + if (dp) { + error = new_xfs_node(&xfs[fd], &message->node, &n, p); + if (error) + return error; + cache_purge (XNODE_TO_VNODE(dp)); + xfs_dnlc_enter(XNODE_TO_VNODE(dp), message->name, + XNODE_TO_VNODE(n)); + vrele(XNODE_TO_VNODE(n)); + } else { + printf("XFS WARNING! xfs_message_installnode: no parent\n"); + error = ENOENT; + } + XFSDEB(XDEBMSG, ("return: xfs_message_installnode: %d\n", error)); + + return error; } int xfs_message_installattr(int fd, - struct xfs_message_installattr * message, + struct xfs_message_installattr *message, u_int size, struct proc *p) { - int error = 0; - struct xfs_node *t; - - t = xfs_node_find(&xfs[fd], &message->node.handle); - if (t != 0) { - t->tokens = message->node.tokens; - xfs_attr2vattr(&message->node.attr, &t->attr); - bcopy(message->node.id, t->id, sizeof(t->id)); - bcopy(message->node.rights, t->rights, sizeof(t->rights)); - t->anonrights = message->node.anonrights; - } else { - printf("XFS PANIC WARNING! xfs_message_installattr: no node!\n"); - error = ENOENT; - } - - return error; + int error = 0; + struct xfs_node *t; + + t = xfs_node_find(&xfs[fd], &message->node.handle); + if (t != 0) { + t->tokens = message->node.tokens; + xfs_attr2vattr(&message->node.attr, &t->attr); + bcopy(message->node.id, t->id, sizeof(t->id)); + bcopy(message->node.rights, t->rights, sizeof(t->rights)); + t->anonrights = message->node.anonrights; + } else { + printf("XFS WARNING! xfs_message_installattr: no node!\n"); + error = ENOENT; + } + + return error; } int xfs_message_installdata(int fd, - struct xfs_message_installdata * message, + struct xfs_message_installdata *message, u_int size, struct proc *p) { - struct xfs_node *t; - int error = 0; - - XFSDEB(XDEBMSG, ("xfs_message_installdata\n")); - - t = xfs_node_find(&xfs[fd], &message->node.handle); - - if (t != NULL) { - struct nameidata nd; - char tmp[CACHEHANDLESIZE + 1]; - struct vnode *vp; - - bcopy((char *) &message->cache_handle.data, tmp, CACHEHANDLESIZE); - tmp[CACHEHANDLESIZE] = '\0'; - - XFSDEB(XDEBMSG, ("cache_handle = '%s'\n", tmp)); - - NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, tmp, p); - error = namei(&nd); - vp = nd.ni_vp; - - if (error == 0) { - if (DATA_FROM_XNODE(t)) - vrele(DATA_FROM_XNODE(t)); - VOP_UNLOCK(vp, 0, p); - DATA_FROM_XNODE(t) = vp; - XFSDEB(XDEBMSG, ("xfs_message_installdata: t = %p ; tokens = %x\n", - t, message->node.tokens)); - - t->tokens = message->node.tokens; - xfs_attr2vattr(&message->node.attr, &t->attr); - if (XNODE_TO_VNODE(t)->v_type == VDIR) - cache_purge (XNODE_TO_VNODE(t)); - bcopy(message->node.id, t->id, sizeof(t->id)); - bcopy(message->node.rights, t->rights, sizeof(t->rights)); - t->anonrights = message->node.anonrights; + struct xfs_node *t; + int error = 0; + + XFSDEB(XDEBMSG, ("xfs_message_installdata\n")); + + t = xfs_node_find(&xfs[fd], &message->node.handle); + if (t != NULL) { + struct nameidata nd; + char tmp[CACHEHANDLESIZE + 1]; + struct vnode *vp; + + bcopy((char *) &message->cache_handle.data, tmp, sizeof(tmp)); + tmp[CACHEHANDLESIZE] = '\0'; + + XFSDEB(XDEBMSG, ("cache_handle = '%s'\n", tmp)); + + NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, tmp, p); + error = namei(&nd); + vp = nd.ni_vp; + if (error == 0) { + if (DATA_FROM_XNODE(t)) + vrele(DATA_FROM_XNODE(t)); + VOP_UNLOCK(vp, 0, p); + DATA_FROM_XNODE(t) = vp; + XFSDEB(XDEBMSG, + ("xfs_message_installdata: t= %p tokens= %x\n", + t, message->node.tokens)); + + t->tokens = message->node.tokens; + xfs_attr2vattr(&message->node.attr, &t->attr); + if (XNODE_TO_VNODE(t)->v_type == VDIR) + cache_purge (XNODE_TO_VNODE(t)); + + bcopy(message->node.id, t->id, sizeof(t->id)); + bcopy(message->node.rights, t->rights, + sizeof(t->rights)); + t->anonrights = message->node.anonrights; + } else { + printf("XFS WARNING! xfs_message_installdata fail!\n"); + printf("Reason: lookup failed on cache file '%s', " + "error = %d\n", tmp, error); + } } else { - printf("XFS PANIC WARNING! xfs_message_installdata failed!\n"); - printf("Reason: lookup failed on cache file '%s', error = %d\n", - tmp, error); + printf("XFS WARNING! xfs_message_installdata failed\n"); + printf("Reason: No node to install the data into!\n"); + error = ENOENT; } - } else { - printf("XFS PANIC WARNING! xfs_message_installdata failed\n"); - printf("Reason: No node to install the data into!\n"); - error = ENOENT; - } - return error; + return error; } int xfs_message_invalidnode(int fd, - struct xfs_message_invalidnode * message, + struct xfs_message_invalidnode *message, u_int size, struct proc *p) { - int error = 0; - struct xfs_node *t; - - XFSDEB(XDEBMSG, ("xfs_message_invalidnode\n")); - - t = xfs_node_find(&xfs[fd], &message->handle); - if (t != 0) { - /* XXX Really need to put back dirty data first. */ - if (DATA_FROM_XNODE(t)) { - vrele(DATA_FROM_XNODE(t)); - DATA_FROM_XNODE(t) = (struct vnode *) 0; + int error = 0; + struct xfs_node *t; + + XFSDEB(XDEBMSG, ("xfs_message_invalidnode\n")); + + t = xfs_node_find(&xfs[fd], &message->handle); + if (t != 0) { + /* XXX Really need to put back dirty data first. */ + if (DATA_FROM_XNODE(t)) { + vrele(DATA_FROM_XNODE(t)); + DATA_FROM_XNODE(t) = (struct vnode *) 0; + } + XFS_TOKEN_CLEAR(t, ~0, + XFS_OPEN_MASK | XFS_ATTR_MASK | + XFS_DATA_MASK | XFS_LOCK_MASK); + cache_purge(XNODE_TO_VNODE(t)); + } else { + printf("XFS WARNING! xfs_message_invalidnode: no node!\n"); + error = ENOENT; } - XFS_TOKEN_CLEAR(t, ~0, - XFS_OPEN_MASK | XFS_ATTR_MASK | - XFS_DATA_MASK | XFS_LOCK_MASK); - cache_purge(XNODE_TO_VNODE(t)); - } else { - printf("XFS PANIC WARNING! xfs_message_invalidnode: no node!\n"); - error = ENOENT; - } - - return error; + + return error; } diff --git a/sys/xfs/xfs_msg_locl.h b/sys/xfs/xfs_msg_locl.h index 48fc0237255..18fe0613a93 100644 --- a/sys/xfs/xfs_msg_locl.h +++ b/sys/xfs/xfs_msg_locl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: xfs_msg_locl.h,v 1.1 1998/08/30 16:47:21 art Exp $ */ +/* $OpenBSD: xfs_msg_locl.h,v 1.2 1998/08/31 05:13:27 art Exp $ */ /* * Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). @@ -39,18 +39,23 @@ /* $KTH: xfs_msg_locl.h,v 1.1 1998/03/26 02:25:53 assar Exp $ */ -#ifndef _xfs_msg_locl_h -#define _xfs_msg_locl_h +#ifndef _XFS_XFS_MSG_LOCL_H_ +#define _XFS_XFS_MSG_LOCL_H_ -int xfs_message_installroot(int fd, struct xfs_message_installroot * message, - u_int size, struct proc *p); -int xfs_message_installnode(int fd, struct xfs_message_installnode * message, - u_int size,struct proc *p); -int xfs_message_installattr(int fd, struct xfs_message_installattr * message, - u_int size,struct proc *p); -int xfs_message_installdata(int fd, struct xfs_message_installdata * message, - u_int size, struct proc *p); -int xfs_message_invalidnode(int fd, struct xfs_message_invalidnode * message, - u_int size, struct proc *p); +int xfs_message_installroot __P((int fd, + struct xfs_message_installroot *message, + u_int size, struct proc *p)); +int xfs_message_installnode __P((int fd, + struct xfs_message_installnode *message, + u_int size,struct proc *p)); +int xfs_message_installattr __P((int fd, + struct xfs_message_installattr *message, + u_int size,struct proc *p)); +int xfs_message_installdata __P((int fd, + struct xfs_message_installdata *message, + u_int size, struct proc *p)); +int xfs_message_invalidnode __P((int fd, + struct xfs_message_invalidnode *message, + u_int size, struct proc *p)); -#endif /* _xfs_msg_locl_h */ +#endif diff --git a/sys/xfs/xfs_node.c b/sys/xfs/xfs_node.c index 3c063d0db33..a0ad87b616d 100644 --- a/sys/xfs/xfs_node.c +++ b/sys/xfs/xfs_node.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xfs_node.c,v 1.1 1998/08/30 16:47:21 art Exp $ */ +/* $OpenBSD: xfs_node.c,v 1.2 1998/08/31 05:13:16 art Exp $ */ /* * Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). @@ -66,285 +66,283 @@ extern vop_t **xfs_vnodeop_p; */ int -new_xfs_node(struct xfs *xfsp, - struct xfs_msg_node *node, - struct xfs_node **xpp, - struct proc *p) +new_xfs_node(struct xfs *xfsp, struct xfs_msg_node *node, + struct xfs_node **xpp, struct proc *p) { - int do_vget = 0; - struct xfs_node *result; + int do_vget = 0; + struct xfs_node *result; - XFSDEB(XDEBNODE, ("new_xfs_node %d.%d.%d.%d\n", - node->handle.a, - node->handle.b, - node->handle.c, - node->handle.d)); + XFSDEB(XDEBNODE, ("new_xfs_node %d.%d.%d.%d\n", + node->handle.a, + node->handle.b, + node->handle.c, + node->handle.d)); - /* Does not allow duplicates */ - result = xfs_node_find(xfsp, &node->handle); - - if (result == 0) { - int error; - struct vnode *v; - - result = xfs_alloc(sizeof(*result)); + /* Does not allow duplicates */ + result = xfs_node_find(xfsp, &node->handle); if (result == 0) { - printf("xfs_alloc(%d) failed\n", (int) sizeof(*result)); - panic("new_xfs_node: You Loose!"); + int error; + struct vnode *v; + + result = xfs_alloc(sizeof(*result)); + if (result == 0) { + printf("xfs_alloc(%d) failed\n", + (int) sizeof(*result)); + panic("new_xfs_node: You Loose!"); + } + + bzero(result, sizeof(*result)); + + error = getnewvnode(VT_AFS, XFS_TO_VFS(xfsp), xfs_vnodeop_p, + &v); + if (error) { + xfs_free(result, sizeof(*result)); + return error; + } + + v->v_data = result; + result->vn = v; + + result->anonrights = node->anonrights; + result->handle = node->handle; + result->flags = 0; + result->tokens = 0; + + xfsp->nnodes++; + } else { + /* Node is already cached */ + do_vget = 1; } - bzero(result, sizeof(*result)); - error = getnewvnode(VT_AFS, XFS_TO_VFS(xfsp), xfs_vnodeop_p, &v); - if (error) { - XFSDEB(XDEBVNOPS, - ("XFS PANIC! new_xfs_node: could not allocate node")); - return error; - } - v->v_data = result; - result->vn = v; - - result->anonrights = node->anonrights; - - result->handle = node->handle; - result->flags = 0; - result->tokens = 0; - - xfsp->nnodes++; - } else { - /* Node is already cached */ - do_vget = 1; - } - - /* Init other fields */ - xfs_attr2vattr(&node->attr, &result->attr); - result->vn->v_type = result->attr.va_type; - XFS_TOKEN_SET(result, XFS_ATTR_R, XFS_ATTR_MASK); - bcopy(node->id, result->id, sizeof(result->id)); - bcopy(node->rights, result->rights, sizeof(result->rights)); - - /* - * We need to postpone this until here because (on FreeBSD) vget - * tries to install a pager on the vnode and for that it wants to - * retrieve the size with getattr. - */ - - if(do_vget) - vget(XNODE_TO_VNODE(result), 0, p); - - *xpp = result; - XFSDEB(XDEBNODE, ("return: new_xfs_node\n")); - return 0; + /* Init other fields */ + xfs_attr2vattr(&node->attr, &result->attr); + result->vn->v_type = result->attr.va_type; + XFS_TOKEN_SET(result, XFS_ATTR_R, XFS_ATTR_MASK); + bcopy(node->id, result->id, sizeof(result->id)); + bcopy(node->rights, result->rights, sizeof(result->rights)); + + /* + * We need to postpone this until here because (on FreeBSD) vget + * tries to install a pager on the vnode and for that it wants to + * retrieve the size with getattr. + */ + + if(do_vget) + vget(XNODE_TO_VNODE(result), 0, p); + + *xpp = result; + XFSDEB(XDEBNODE, ("return: new_xfs_node\n")); + return 0; } void free_xfs_node(struct xfs_node *node) { - struct xfs *xfsp = XFS_FROM_XNODE(node); + struct xfs *xfsp = XFS_FROM_XNODE(node); - XFSDEB(XDEBNODE, ("free_xfs_node starting\n")); + XFSDEB(XDEBNODE, ("free_xfs_node starting\n")); - /* XXX Really need to put back dirty data first. */ + /* XXX Really need to put back dirty data first. */ - if (DATA_FROM_XNODE(node)) { - vrele(DATA_FROM_XNODE(node)); - DATA_FROM_XNODE(node) = NULL; - } - xfsp->nnodes--; - XNODE_TO_VNODE(node)->v_data = NULL; - xfs_free(node, sizeof(*node)); + if (DATA_FROM_XNODE(node)) { + vrele(DATA_FROM_XNODE(node)); + DATA_FROM_XNODE(node) = NULL; + } + xfsp->nnodes--; + XNODE_TO_VNODE(node)->v_data = NULL; + xfs_free(node, sizeof(*node)); - XFSDEB(XDEBNODE, ("free_xfs_node done\n")); + XFSDEB(XDEBNODE, ("free_xfs_node done\n")); } int free_all_xfs_nodes(struct xfs *xfsp, int flags) { - int error = 0; - struct mount *mp = XFS_TO_VFS(xfsp); + int error = 0; + struct mount *mp = XFS_TO_VFS(xfsp); - if (mp == NULL) { - XFSDEB(XDEBNODE, ("free_all_xfs_nodes already freed\n")); - return 0; - } + if (mp == NULL) { + XFSDEB(XDEBNODE, ("free_all_xfs_nodes already freed\n")); + return 0; + } - XFSDEB(XDEBNODE, ("free_all_xfs_nodes starting\n")); + XFSDEB(XDEBNODE, ("free_all_xfs_nodes starting\n")); - xfs_dnlc_purge(mp); + xfs_dnlc_purge(mp); - XFSDEB(XDEBNODE, ("free_all_xfs_nodes now removing root\n")); + XFSDEB(XDEBNODE, ("free_all_xfs_nodes now removing root\n")); - if (xfsp->root) { - vgone(XNODE_TO_VNODE(xfsp->root)); - xfsp->root = 0; - } + if (xfsp->root) { + vgone(XNODE_TO_VNODE(xfsp->root)); + xfsp->root = 0; + } - XFSDEB(XDEBNODE, ("free_all_xfs_nodes root removed\n")); - XFSDEB(XDEBNODE, ("free_all_xfs_nodes now killing all remaining nodes\n")); + XFSDEB(XDEBNODE, ("free_all_xfs_nodes root removed\n")); + XFSDEB(XDEBNODE, ("free_all_xfs_nodes killing all remaining nodes\n")); - error = vflush(mp, NULL, flags); + error = vflush(mp, NULL, flags); + if (error) { + XFSDEB(XDEBNODE, ("xfree_all_xfs_nodes: vflush error == %d\n", + error)); + return error; + } - if (error) { - XFSDEB(XDEBNODE, ("xfree_all_xfs_nodes: vflush() error == %d\n", - error)); + XFSDEB(XDEBNODE, ("free_all_xfs_nodes done\n")); return error; - } - - XFSDEB(XDEBNODE, ("free_all_xfs_nodes done\n")); - return error; } struct xfs_node * xfs_node_find(struct xfs *xfsp, xfs_handle *handlep) { - struct vnode *t; - struct xfs_node *xn = NULL; + struct vnode *t; + struct xfs_node *xn = NULL; - XFSDEB(XDEBNODE, ("xfs_node_find: xfsp = %p handlep = %p\n", - xfsp, handlep)); + XFSDEB(XDEBNODE, ("xfs_node_find: xfsp = %p handlep = %p\n", + xfsp, handlep)); - for (t = XFS_TO_VFS(xfsp)->mnt_vnodelist.lh_first; - t != NULL; - t = t->v_mntvnodes.le_next) { - xn = VNODE_TO_XNODE(t); + for (t = XFS_TO_VFS(xfsp)->mnt_vnodelist.lh_first; + t != NULL; + t = t->v_mntvnodes.le_next) { + xn = VNODE_TO_XNODE(t); - if (xn && xfs_handle_eq(&xn->handle, handlep)) - break; - } + if (xn && xfs_handle_eq(&xn->handle, handlep)) + break; + } - if (t != NULL) - return xn; - else - return NULL; + if (t != NULL) + return xn; + else + return NULL; } void vattr2xfs_attr(const struct vattr *va, struct xfs_attr *xa) { - bzero(xa, sizeof(*xa)); - if (va->va_mode != (mode_t) VNOVAL) - XA_SET_MODE(xa, va->va_mode); - if (va->va_nlink != VNOVAL) - XA_SET_NLINK(xa, va->va_nlink); - if (va->va_size != (u_quad_t) VNOVAL) - XA_SET_SIZE(xa, va->va_size); - if (va->va_uid != VNOVAL) - XA_SET_UID(xa, va->va_uid); - if (va->va_gid != VNOVAL) - XA_SET_GID(xa, va->va_gid); - if (va->va_atime.tv_sec != VNOVAL) - XA_SET_ATIME(xa, va->va_atime.tv_sec); - if (va->va_mtime.tv_sec != VNOVAL) - XA_SET_MTIME(xa, va->va_mtime.tv_sec); - if (va->va_ctime.tv_sec != VNOVAL) - XA_SET_CTIME(xa, va->va_ctime.tv_sec); - if (va->va_fileid != VNOVAL) - XA_SET_FILEID(xa, va->va_fileid); - switch (va->va_type) { - case VNON: - xa->xa_type = XFS_FILE_NON; - break; - case VREG: - xa->xa_type = XFS_FILE_REG; - break; - case VDIR: - xa->xa_type = XFS_FILE_DIR; - break; - case VBLK: - xa->xa_type = XFS_FILE_BLK; - break; - case VCHR: - xa->xa_type = XFS_FILE_CHR; - break; - case VLNK: - xa->xa_type = XFS_FILE_LNK; - break; - case VSOCK: - xa->xa_type = XFS_FILE_SOCK; - break; - case VFIFO: - xa->xa_type = XFS_FILE_FIFO; - break; - case VBAD: - xa->xa_type = XFS_FILE_BAD; - break; - default: - panic("xfs_attr2attr: bad value"); - } + bzero(xa, sizeof(*xa)); + if (va->va_mode != (mode_t) VNOVAL) + XA_SET_MODE(xa, va->va_mode); + if (va->va_nlink != VNOVAL) + XA_SET_NLINK(xa, va->va_nlink); + if (va->va_size != (u_quad_t) VNOVAL) + XA_SET_SIZE(xa, va->va_size); + if (va->va_uid != VNOVAL) + XA_SET_UID(xa, va->va_uid); + if (va->va_gid != VNOVAL) + XA_SET_GID(xa, va->va_gid); + if (va->va_atime.tv_sec != VNOVAL) + XA_SET_ATIME(xa, va->va_atime.tv_sec); + if (va->va_mtime.tv_sec != VNOVAL) + XA_SET_MTIME(xa, va->va_mtime.tv_sec); + if (va->va_ctime.tv_sec != VNOVAL) + XA_SET_CTIME(xa, va->va_ctime.tv_sec); + if (va->va_fileid != VNOVAL) + XA_SET_FILEID(xa, va->va_fileid); + switch (va->va_type) { + case VNON: + xa->xa_type = XFS_FILE_NON; + break; + case VREG: + xa->xa_type = XFS_FILE_REG; + break; + case VDIR: + xa->xa_type = XFS_FILE_DIR; + break; + case VBLK: + xa->xa_type = XFS_FILE_BLK; + break; + case VCHR: + xa->xa_type = XFS_FILE_CHR; + break; + case VLNK: + xa->xa_type = XFS_FILE_LNK; + break; + case VSOCK: + xa->xa_type = XFS_FILE_SOCK; + break; + case VFIFO: + xa->xa_type = XFS_FILE_FIFO; + break; + case VBAD: + xa->xa_type = XFS_FILE_BAD; + break; + default: + panic("xfs_attr2attr: bad value"); + } } void xfs_attr2vattr(const struct xfs_attr *xa, struct vattr *va) { - VATTR_NULL(va); - if (XA_VALID_MODE(xa)) - va->va_mode = xa->xa_mode; - if (XA_VALID_NLINK(xa)) - va->va_nlink = xa->xa_nlink; - if (XA_VALID_SIZE(xa)) - va->va_size = xa->xa_size; - if (XA_VALID_UID(xa)) - va->va_uid = xa->xa_uid; - if (XA_VALID_GID(xa)) - va->va_gid = xa->xa_gid; - if (XA_VALID_ATIME(xa)) { - va->va_atime.tv_sec = xa->xa_atime; - va->va_atime.tv_nsec = 0; - } - if (XA_VALID_MTIME(xa)) { - va->va_mtime.tv_sec = xa->xa_mtime; - va->va_mtime.tv_nsec = 0; - } - if (XA_VALID_CTIME(xa)) { - va->va_ctime.tv_sec = xa->xa_ctime; - va->va_ctime.tv_nsec = 0; - } - if (XA_VALID_FILEID(xa)) { - va->va_fileid = xa->xa_fileid; - } - if (XA_VALID_TYPE(xa)) { - switch (xa->xa_type) { - case XFS_FILE_NON: - va->va_type = VNON; - break; - case XFS_FILE_REG: - va->va_type = VREG; - break; - case XFS_FILE_DIR: - va->va_type = VDIR; - break; - case XFS_FILE_BLK: - va->va_type = VBLK; - break; - case XFS_FILE_CHR: - va->va_type = VCHR; - break; - case XFS_FILE_LNK: - va->va_type = VLNK; - break; - case XFS_FILE_SOCK: - va->va_type = VSOCK; - break; - case XFS_FILE_FIFO: - va->va_type = VFIFO; - break; - case XFS_FILE_BAD: - va->va_type = VBAD; - break; - default: - panic("xfs_attr2vattr: bad value"); + VATTR_NULL(va); + if (XA_VALID_MODE(xa)) + va->va_mode = xa->xa_mode; + if (XA_VALID_NLINK(xa)) + va->va_nlink = xa->xa_nlink; + if (XA_VALID_SIZE(xa)) + va->va_size = xa->xa_size; + if (XA_VALID_UID(xa)) + va->va_uid = xa->xa_uid; + if (XA_VALID_GID(xa)) + va->va_gid = xa->xa_gid; + if (XA_VALID_ATIME(xa)) { + va->va_atime.tv_sec = xa->xa_atime; + va->va_atime.tv_nsec = 0; + } + if (XA_VALID_MTIME(xa)) { + va->va_mtime.tv_sec = xa->xa_mtime; + va->va_mtime.tv_nsec = 0; + } + if (XA_VALID_CTIME(xa)) { + va->va_ctime.tv_sec = xa->xa_ctime; + va->va_ctime.tv_nsec = 0; + } + if (XA_VALID_FILEID(xa)) { + va->va_fileid = xa->xa_fileid; } - } - va->va_flags = 0; - va->va_blocksize = 8192; - va->va_bytes = va->va_size; + if (XA_VALID_TYPE(xa)) { + switch (xa->xa_type) { + case XFS_FILE_NON: + va->va_type = VNON; + break; + case XFS_FILE_REG: + va->va_type = VREG; + break; + case XFS_FILE_DIR: + va->va_type = VDIR; + break; + case XFS_FILE_BLK: + va->va_type = VBLK; + break; + case XFS_FILE_CHR: + va->va_type = VCHR; + break; + case XFS_FILE_LNK: + va->va_type = VLNK; + break; + case XFS_FILE_SOCK: + va->va_type = VSOCK; + break; + case XFS_FILE_FIFO: + va->va_type = VFIFO; + break; + case XFS_FILE_BAD: + va->va_type = VBAD; + break; + default: + panic("xfs_attr2vattr: bad value"); + } + } + va->va_flags = 0; + va->va_blocksize = 8192; + va->va_bytes = va->va_size; } struct long_entry { - struct vnode *dvp, *vp; - char name[MAXNAMLEN + 1]; - size_t len; - u_long dvpid, vpid; + struct vnode *dvp, *vp; + char name[MAXNAMLEN + 1]; + size_t len; + u_long dvpid, vpid; }; static struct long_entry tbl; @@ -352,89 +350,88 @@ static struct long_entry tbl; int xfs_dnlc_enter(struct vnode *dvp, char *name, struct vnode *vp) { - struct componentname cn; - char *p; + struct componentname cn; + char *p; - XFSDEB(XDEBDNLC, ("xfs_dnlc_enter(0x%x, \"%s\", 0x%x)\n", - (int) dvp, name, (int) vp)); + XFSDEB(XDEBDNLC, ("xfs_dnlc_enter(0x%x, \"%s\", 0x%x)\n", + (int) dvp, name, (int) vp)); - XFSDEB(XDEBDNLC, ("xfs_dnlc_enter: v_id = %ld\n", - dvp->v_id)); + XFSDEB(XDEBDNLC, ("xfs_dnlc_enter: v_id = %ld\n", + dvp->v_id)); - cn.cn_namelen = strlen(name); - cn.cn_nameptr = name; - cn.cn_hash = 0; - for (p = name; *p; ++p) - cn.cn_hash += *p; + cn.cn_namelen = strlen(name); + cn.cn_nameptr = name; + cn.cn_hash = 0; + for (p = name; *p; ++p) + cn.cn_hash += *p; - XFSDEB(XDEBDNLC, ("xfs_dnlc_enter: calling cache_enter:" - "dvp = %p, vp = %p, cnp = (%s, %ld, %lu)\n", - dvp, vp, cn.cn_nameptr, cn.cn_namelen, cn.cn_hash)); + XFSDEB(XDEBDNLC, ("xfs_dnlc_enter: calling cache_enter:" + "dvp = %p, vp = %p, cnp = (%s, %ld, %lu)\n", + dvp, vp, cn.cn_nameptr, cn.cn_namelen, cn.cn_hash)); - if (cn.cn_namelen <= NCHNAMLEN) - cache_enter(dvp, vp, &cn); + if (cn.cn_namelen <= NCHNAMLEN) + cache_enter(dvp, vp, &cn); - tbl.len = cn.cn_namelen; - bcopy(name, tbl.name, tbl.len); - tbl.dvp = dvp; - tbl.vp = vp; - tbl.dvpid = dvp->v_id; - tbl.vpid = vp->v_id; + tbl.len = cn.cn_namelen; + bcopy(name, tbl.name, tbl.len); + tbl.dvp = dvp; + tbl.vp = vp; + tbl.dvpid = dvp->v_id; + tbl.vpid = vp->v_id; - return 0; + return 0; } int -xfs_dnlc_lookup(struct vnode *dvp, - struct componentname *cnp, +xfs_dnlc_lookup(struct vnode *dvp, struct componentname *cnp, struct vnode **res) { - int error; + int error; - XFSDEB(XDEBDNLC, ("xfs_dnlc_lookup(0x%x, \"%s\")\n", - (int) dvp, cnp->cn_nameptr)); + XFSDEB(XDEBDNLC, ("xfs_dnlc_lookup(0x%x, \"%s\")\n", + (int) dvp, cnp->cn_nameptr)); - XFSDEB(XDEBDNLC, ("xfs_dnlc_lookup: v_id = %ld\n", - dvp->v_id)); + XFSDEB(XDEBDNLC, ("xfs_dnlc_lookup: v_id = %ld\n", + dvp->v_id)); - XFSDEB(XDEBDNLC, ("xfs_dnlc_lookup: calling cache_lookup:" - "dvp = %p, cnp = (%s, %ld, %lu), flags = %lx\n", - dvp, cnp->cn_nameptr, cnp->cn_namelen, cnp->cn_hash, - cnp->cn_flags)); + XFSDEB(XDEBDNLC, ("xfs_dnlc_lookup: calling cache_lookup:" + "dvp = %p, cnp = (%s, %ld, %lu), flags = %lx\n", + dvp, cnp->cn_nameptr, cnp->cn_namelen, cnp->cn_hash, + cnp->cn_flags)); - cnp->cn_flags |= MAKEENTRY; + cnp->cn_flags |= MAKEENTRY; - error = cache_lookup(dvp, res, cnp); + error = cache_lookup(dvp, res, cnp); - XFSDEB(XDEBDNLC, ("xfs_dnlc_lookup: cache_lookup returned. " - "error == %d, *res == %p\n", error, *res)); + XFSDEB(XDEBDNLC, ("xfs_dnlc_lookup: cache_lookup returned. " + "error == %d, *res == %p\n", error, *res)); - if (error == -1 || error == ENOENT) - return error; + if (error == -1 || error == ENOENT) + return error; - if (tbl.dvp == dvp - && tbl.len == cnp->cn_namelen - && strncmp(tbl.name, cnp->cn_nameptr, cnp->cn_namelen) == 0 - && tbl.dvpid == tbl.dvp->v_id - && tbl.vpid == tbl.vp->v_id) { - *res = tbl.vp; - return -1; - } + if (tbl.dvp == dvp + && tbl.len == cnp->cn_namelen + && strncmp(tbl.name, cnp->cn_nameptr, cnp->cn_namelen) == 0 + && tbl.dvpid == tbl.dvp->v_id + && tbl.vpid == tbl.vp->v_id) { + *res = tbl.vp; + return -1; + } - return 0; + return 0; } void xfs_dnlc_purge(struct mount *mp) { - XFSDEB(XDEBDNLC, ("xfs_dnlc_purge()\n")); + XFSDEB(XDEBDNLC, ("xfs_dnlc_purge()\n")); - tbl.dvp = tbl.vp = NULL; - tbl.name[0] = '\0'; - tbl.len = 0; - tbl.dvpid = tbl.vpid = 0; + tbl.dvp = tbl.vp = NULL; + tbl.name[0] = '\0'; + tbl.len = 0; + tbl.dvpid = tbl.vpid = 0; - cache_purgevfs(mp); + cache_purgevfs(mp); } /* @@ -443,11 +440,11 @@ xfs_dnlc_purge(struct mount *mp) int xfs_has_pag(const struct xfs_node *xn, pag_t pag) { - int i; + int i; - for (i = 0; i < MAXRIGHTS; i++) - if (xn->id[i] == pag) - return 1; + for (i = 0; i < MAXRIGHTS; i++) + if (xn->id[i] == pag) + return 1; - return 0; + return 0; } diff --git a/sys/xfs/xfs_node.h b/sys/xfs/xfs_node.h index 8db5929ffd0..e6d3bea0eec 100644 --- a/sys/xfs/xfs_node.h +++ b/sys/xfs/xfs_node.h @@ -1,4 +1,4 @@ -/* $OpenBSD: xfs_node.h,v 1.1 1998/08/30 16:47:21 art Exp $ */ +/* $OpenBSD: xfs_node.h,v 1.2 1998/08/31 05:13:28 art Exp $ */ /* * Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). @@ -39,33 +39,32 @@ /* $KTH: xfs_node.h,v 1.3 1998/07/13 20:36:37 art Exp $ */ -#ifndef _xfs_xnode_h -#define _xfs_xnode_h +#ifndef _XFS_XFS_NODE_H_ +#define _XFS_XFS_NODE_H_ #include <sys/types.h> #include <sys/time.h> #include <sys/vnode.h> -#include <sys/xfs_attr.h> -#include <sys/xfs_message.h> +#include <xfs/xfs_attr.h> +#include <xfs/xfs_message.h> struct xfs_node { - struct vnode *vn; - struct vnode *data; - struct vattr attr; - u_int flags; - u_int tokens; - xfs_handle handle; - pag_t id[MAXRIGHTS]; - u_char rights[MAXRIGHTS]; - u_char anonrights; + struct vnode *vn; + struct vnode *data; + struct vattr attr; + u_int flags; + u_int tokens; + xfs_handle handle; + pag_t id[MAXRIGHTS]; + u_char rights[MAXRIGHTS]; + u_char anonrights; }; #define DATA_FROM_VNODE(vp) DATA_FROM_XNODE(VNODE_TO_XNODE(vp)) - #define DATA_FROM_XNODE(xp) ((xp)->data) #define XNODE_TO_VNODE(xp) ((xp)->vn) #define VNODE_TO_XNODE(vp) ((struct xfs_node *) (vp)->v_data) -#endif /* _xfs_xnode_h */ +#endif diff --git a/sys/xfs/xfs_syscalls.c b/sys/xfs/xfs_syscalls.c index fe07630dbc2..323eb0ea95c 100644 --- a/sys/xfs/xfs_syscalls.c +++ b/sys/xfs/xfs_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xfs_syscalls.c,v 1.2 1998/08/30 18:06:19 art Exp $ */ +/* $OpenBSD: xfs_syscalls.c,v 1.3 1998/08/31 05:13:17 art Exp $ */ /* * Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). @@ -55,24 +55,25 @@ RCSID("$KTH: xfs_syscalls.c,v 1.20 1998/07/19 21:18:30 art Exp $"); /* * XFS system calls. */ - -#include <sys/xfs_message.h> +#include <xfs/xfs_message.h> #include <xfs/xfs_syscalls.h> #include <xfs/xfs_dev.h> #include <xfs/xfs_node.h> #include <xfs/xfs_deb.h> /* Misc syscalls */ -#include <sys/xfs_pioctl.h> +#include <xfs/xfs_pioctl.h> #include <sys/syscallargs.h> #ifdef ACTUALLY_LKM_NOT_KERNEL + /* XXX really defined in kern/kern_lkm.c */ extern int sys_lkmnosys(struct proc *p, void *v, register_t *retval); #ifndef SYS_MAXSYSCALL /* Workaround for OpenBSD */ #define SYS_MAXSYSCALL 255 #endif + #endif /* ACTUALLY_LKM_NOT_KERNEL */ @@ -93,63 +94,61 @@ static gid_t pag_part_two = XFS_PAG2_LLIM; static int xfs_is_pag(struct ucred *cred) { - /* The first group is the gid of the user ? */ - - if (cred->cr_ngroups >= 3 && - cred->cr_groups[1] >= XFS_PAG1_LLIM && - cred->cr_groups[1] <= XFS_PAG1_ULIM && - cred->cr_groups[2] >= XFS_PAG2_LLIM && - cred->cr_groups[2] <= XFS_PAG2_ULIM) - return 1; - else - return 0; + /* The first group is the gid of the user ? */ + + if (cred->cr_ngroups >= 3 && + cred->cr_groups[1] >= XFS_PAG1_LLIM && + cred->cr_groups[1] <= XFS_PAG1_ULIM && + cred->cr_groups[2] >= XFS_PAG2_LLIM && + cred->cr_groups[2] <= XFS_PAG2_ULIM) + return 1; + else + return 0; } pag_t xfs_get_pag(struct ucred *cred) { - if (xfs_is_pag(cred)) { - - return (((cred->cr_groups[1] << 16) & 0xFFFF0000) | - ((cred->cr_groups[2] & 0x0000FFFF))); - - } else - return cred->cr_uid; /* XXX */ + if (xfs_is_pag(cred)) { + return (((cred->cr_groups[1] << 16) & 0xFFFF0000) | + ((cred->cr_groups[2] & 0x0000FFFF))); + } else + return cred->cr_uid; /* XXX */ } static int xfs_setpag_call(struct ucred **ret_cred) { - struct ucred *cred = *ret_cred; - int i; + struct ucred *cred = *ret_cred; + int i; - if (!xfs_is_pag(cred)) { + if (!xfs_is_pag(cred)) { + /* Check if it fits */ + if (cred->cr_ngroups + 2 >= NGROUPS) + return E2BIG; /* XXX Hmmm, better error ? */ - /* Check if it fits */ - if (cred->cr_ngroups + 2 >= NGROUPS) - return E2BIG; /* XXX Hmmm, better error ? */ + cred = crcopy (cred); - cred = crcopy (cred); + /* Copy the groups */ + for (i = cred->cr_ngroups - 1; i > 0; i--) { + cred->cr_groups[i + 2] = cred->cr_groups[i]; + } + cred->cr_ngroups += 2; - /* Copy the groups */ - for (i = cred->cr_ngroups - 1; i > 0; i--) { - cred->cr_groups[i + 2] = cred->cr_groups[i]; - } - cred->cr_ngroups += 2; + } else + cred = crcopy(cred); - } else - cred = crcopy(cred); + cred->cr_groups[1] = pag_part_one; + cred->cr_groups[2] = pag_part_two++; - cred->cr_groups[1] = pag_part_one; - cred->cr_groups[2] = pag_part_two++; + if (pag_part_two > XFS_PAG2_ULIM) { + pag_part_one++; + pag_part_two = XFS_PAG2_LLIM; + } + *ret_cred = cred; - if (pag_part_two > XFS_PAG2_ULIM) { - pag_part_one++; - pag_part_two = XFS_PAG2_LLIM; - } - *ret_cred = cred; - return 0; + return 0; } #ifdef ACTUALLY_LKM_NOT_KERNEL @@ -158,21 +157,21 @@ xfs_setpag_call(struct ucred **ret_cred) #define syscallarg(x) union { x datum; register_t pad; } struct sys_xfspioctl_args { - syscallarg(int) operation; - syscallarg(char *) a_pathP; - syscallarg(int) a_opcode; - syscallarg(struct ViceIoctl *) a_paramsP; - syscallarg(int) a_followSymlinks; + syscallarg(int) operation; + syscallarg(char *) a_pathP; + syscallarg(int) a_opcode; + syscallarg(struct ViceIoctl *) a_paramsP; + syscallarg(int) a_followSymlinks; }; #elif defined(__FreeBSD__) struct sys_xfspioctl_args { - int operation; - char *a_pathP; - int a_opcode; - struct ViceIoctl *a_paramsP; - int a_followSymlinks; + int operation; + char *a_pathP; + int a_opcode; + struct ViceIoctl *a_paramsP; + int a_followSymlinks; }; #ifndef SCARG @@ -180,106 +179,104 @@ struct sys_xfspioctl_args { #endif #endif -#endif +#endif /* ACTUALLY_LKM_NOT_KERNEL */ static int xfs_pioctl_call(struct proc *p, void *v, int *i) { - int error; - struct ViceIoctl vice_ioctl; - struct xfs_message_pioctl msg; - struct xfs_message_wakeup_data *msg2; - char *pathptr; + int error; + struct ViceIoctl vice_ioctl; + struct xfs_message_pioctl msg; + struct xfs_message_wakeup_data *msg2; + char *pathptr; - struct sys_xfspioctl_args *arg = (struct sys_xfspioctl_args *) v; + struct sys_xfspioctl_args *arg = (struct sys_xfspioctl_args *) v; - /* Copy in the data structure for us */ - - error = copyin(SCARG(arg, a_paramsP), - &vice_ioctl, - sizeof(vice_ioctl)); - - if (error) - return error; - - if (vice_ioctl.in_size > 2048) { - printf("xfs_pioctl_call: got a humongous in packet: opcode: %d", - SCARG(arg, a_opcode)); - return EINVAL; - } - if (vice_ioctl.in_size != 0) { - error = copyin(vice_ioctl.in, - &msg.msg, - vice_ioctl.in_size); + /* Copy in the data structure for us */ + error = copyin(SCARG(arg, a_paramsP), + &vice_ioctl, + sizeof(vice_ioctl)); if (error) - return error; - } - - pathptr = SCARG(arg, a_pathP); - - if (pathptr != NULL) { - char path[MAXPATHLEN]; - struct xfs_node *xn; - struct nameidata nd; - struct vnode *vp; - size_t done; + return error; - XFSDEB(XDEBSYS, ("xfs_syscall: looking up: %p\n", pathptr)); - - error = copyinstr(pathptr, path, MAXPATHLEN, &done); + if (vice_ioctl.in_size > 2048) { + printf("xfs_pioctl_call: got a humongous inpacket: opcode: %d", + SCARG(arg, a_opcode)); + return EINVAL; + } + if (vice_ioctl.in_size != 0) { + error = copyin(vice_ioctl.in, + &msg.msg, + vice_ioctl.in_size); - XFSDEB(XDEBSYS, ("xfs_syscall: looking up: %s len: %d error: %d\n", - path, done, error)); + if (error) + return error; + } - if (error) - return error; + pathptr = SCARG(arg, a_pathP); - NDINIT(&nd, LOOKUP, - SCARG(arg, a_followSymlinks) ? FOLLOW : 0, - UIO_SYSSPACE, path, p); + if (pathptr != NULL) { + char path[MAXPATHLEN]; + struct xfs_node *xn; + struct nameidata nd; + struct vnode *vp; + size_t done; - error = namei(&nd); - - if (error != 0) { - XFSDEB(XDEBSYS, ("xfs_syscall: error during namei: %d\n", error)); - return EINVAL; - } + XFSDEB(XDEBSYS, ("xfs_syscall: looking up: %p\n", pathptr)); - vp = nd.ni_vp; + error = copyinstr(pathptr, path, sizeof(path) - 1, &done); + path[sizeof(path) - 1] = '\0'; + XFSDEB(XDEBSYS, ("xfs_syscall: path: %s len: %d error: %d\n", + path, done, error)); - if (vp->v_tag != VT_AFS) { - XFSDEB(XDEBSYS, ("xfs_syscall: %s not in afs\n", path)); - vrele(vp); - return EINVAL; - } + if (error) + return error; - xn = VNODE_TO_XNODE(vp); + NDINIT(&nd, LOOKUP, + SCARG(arg, a_followSymlinks) ? FOLLOW : 0, + UIO_SYSSPACE, path, p); - msg.handle = xn->handle; - vrele(vp); - } + error = namei(&nd); + if (error != 0) { + XFSDEB(XDEBSYS, ("xfs_syscall: error in namei: %d\n", + error)); + return EINVAL; + } - msg.header.opcode = XFS_MSG_PIOCTL; - msg.opcode = SCARG(arg, a_opcode); + vp = nd.ni_vp; - msg.insize = vice_ioctl.in_size; - msg.outsize = vice_ioctl.out_size; - msg.cred.uid = p->p_cred->p_ruid; - msg.cred.pag = xfs_get_pag(p->p_ucred); + if (vp->v_tag != VT_AFS) { + XFSDEB(XDEBSYS, ("xfs_syscall: %s not in afs\n", + path)); + vrele(vp); + return EINVAL; + } - error = xfs_message_rpc(0, &msg.header, sizeof(msg)); /* XXX */ - msg2 = (struct xfs_message_wakeup_data *) &msg; + xn = VNODE_TO_XNODE(vp); - if (error == 0) - error = msg2->error; - else - error = EINVAL; /* return EINVAL to not confuse applications */ + msg.handle = xn->handle; + vrele(vp); + } - if (error == 0 && msg2->header.opcode == XFS_MSG_WAKEUP_DATA) - error = copyout(msg2->msg, vice_ioctl.out, - min(msg2->len, vice_ioctl.out_size)); - return error; + msg.header.opcode = XFS_MSG_PIOCTL; + msg.opcode = SCARG(arg, a_opcode); + msg.insize = vice_ioctl.in_size; + msg.outsize = vice_ioctl.out_size; + msg.cred.uid = p->p_cred->p_ruid; + msg.cred.pag = xfs_get_pag(p->p_ucred); + + error = xfs_message_rpc(0, &msg.header, sizeof(msg)); /* XXX */ + msg2 = (struct xfs_message_wakeup_data *) &msg; + if (error == 0) + error = msg2->error; + else + error = EINVAL; /* return EINVAL to not confuse applications */ + + if (error == 0 && msg2->header.opcode == XFS_MSG_WAKEUP_DATA) + error = copyout(msg2->msg, vice_ioctl.out, + min(msg2->len, vice_ioctl.out_size)); + return error; } @@ -291,23 +288,23 @@ int sys_xfspioctl(struct proc *p, void *v, int *i) #endif { - struct sys_xfspioctl_args *arg = (struct sys_xfspioctl_args *) v; - int error = EINVAL; - - switch (SCARG(arg, operation)) { - case AFSCALL_PIOCTL: - error = xfs_pioctl_call(p, v, i); - break; - case AFSCALL_SETPAG: - error = xfs_setpag_call(&p->p_cred->pc_ucred); - break; - default: - uprintf("Unimplemeted call: %d\n", SCARG(arg, operation)); - error = EINVAL; - break; - } - - return error; + struct sys_xfspioctl_args *arg = (struct sys_xfspioctl_args *) v; + int error = EINVAL; + + switch (SCARG(arg, operation)) { + case AFSCALL_PIOCTL: + error = xfs_pioctl_call(p, v, i); + break; + case AFSCALL_SETPAG: + error = xfs_setpag_call(&p->p_cred->pc_ucred); + break; + default: + uprintf("Unimplemeted call: %d\n", SCARG(arg, operation)); + error = EINVAL; + break; + } + + return error; } #ifdef ACTUALLY_LKM_NOT_KERNEL @@ -317,64 +314,65 @@ static int syscall_offset; static struct sysent syscall_oldent; static struct sysent xfs_syscallent = { - 4, /* number of args */ - sizeof(struct sys_xfspioctl_args), /* size of args */ - xfs_syscall /* function pointer */ + 4, /* number of args */ + sizeof(struct sys_xfspioctl_args), /* size of args */ + xfs_syscall /* function pointer */ }; static int find_first_free_syscall(int *ret) { - int i; - - /* - * Search the table looking for a slot... - */ - for (i = 0; i < SYS_MAXSYSCALL; i++) - if (sysent[i].sy_call == sys_lkmnosys) { - *ret = i; - return 0; - } - return ENFILE; + int i; + + /* + * Search the table looking for a slot... + */ + for (i = 0; i < SYS_MAXSYSCALL; i++) + if (sysent[i].sy_call == sys_lkmnosys) { + *ret = i; + return 0; + } + + return ENFILE; } int xfs_install_syscalls(void) { - int error; + int error; #ifdef AFS_SYSCALL - syscall_offset = AFS_SYSCALL; + syscall_offset = AFS_SYSCALL; #else - error = find_first_free_syscall(&syscall_offset); - if (error) - return error; + error = find_first_free_syscall(&syscall_offset); + if (error) + return error; #endif - syscall_oldent = sysent[syscall_offset]; + syscall_oldent = sysent[syscall_offset]; - /* replace with new */ + /* replace with new */ - sysent[syscall_offset] = xfs_syscallent; + sysent[syscall_offset] = xfs_syscallent; - printf("syscall %d\n", syscall_offset); - return 0; + printf("syscall %d\n", syscall_offset); + return 0; } int xfs_uninstall_syscalls(void) { - /* replace current slot contents with old contents */ - if (syscall_offset) - sysent[syscall_offset] = syscall_oldent; + /* replace current slot contents with old contents */ + if (syscall_offset) + sysent[syscall_offset] = syscall_oldent; - return 0; + return 0; } int xfs_stat_syscalls(void) { - return 0; + return 0; } #elif defined(__FreeBSD__) @@ -383,56 +381,60 @@ static int syscall_offset; static struct sysent syscall_oldent; static struct sysent xfs_syscallent = { - 4, - xfs_syscall + 4, + xfs_syscall }; static int find_first_free_syscall(int *ret) { - int i; - - /* - * Search the table looking for a slot... - */ - for (i = 0; i < aout_sysvec.sv_size; i++) - if (aout_sysvec.sv_table[i].sy_call == (sy_call_t *) lkmnosys) { - *ret = i; - return 0; - } - return ENFILE; + int i; + + /* + * Search the table looking for a slot... + */ + for (i = 0; i < aout_sysvec.sv_size; i++) + if (aout_sysvec.sv_table[i].sy_call == + (sy_call_t *) lkmnosys) { + *ret = i; + return 0; + } + + return ENFILE; } int xfs_install_syscalls(void) { - int i; - int error; + int i; + int error; #ifdef AFS_SYSCALL - i = AFS_SYSCALL; + i = AFS_SYSCALL; #else - error = find_first_free_syscall(&i); - if (error) - return error; + error = find_first_free_syscall(&i); + if (error) + return error; #endif - syscall_oldent = aout_sysvec.sv_table[i]; + syscall_oldent = aout_sysvec.sv_table[i]; - aout_sysvec.sv_table[i] = xfs_syscallent; + aout_sysvec.sv_table[i] = xfs_syscallent; - syscall_offset = i; - printf("syscall %d\n", i); - return 0; + syscall_offset = i; + printf("syscall %d\n", i); + + return 0; } int xfs_uninstall_syscalls(void) { - if (syscall_offset) { - aout_sysvec.sv_table[syscall_offset].sy_call = (sy_call_t *) lkmnosys; - } - return 0; + if (syscall_offset) { + aout_sysvec.sv_table[syscall_offset].sy_call = + (sy_call_t *) lkmnosys; + } + return 0; } int diff --git a/sys/xfs/xfs_syscalls.h b/sys/xfs/xfs_syscalls.h index c1eff921ff7..4a8d1bfaadf 100644 --- a/sys/xfs/xfs_syscalls.h +++ b/sys/xfs/xfs_syscalls.h @@ -1,4 +1,4 @@ -/* $OpenBSD: xfs_syscalls.h,v 1.1 1998/08/30 16:47:22 art Exp $ */ +/* $OpenBSD: xfs_syscalls.h,v 1.2 1998/08/31 05:13:29 art Exp $ */ /* * Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). @@ -39,12 +39,12 @@ /* $KTH: xfs_syscalls.h,v 1.2 1998/01/21 01:03:57 mho Exp $ */ -#ifndef __xfs_syscalls -#define __xfs_syscalls +#ifndef _XFS_XFS_SYSCALLS_H_ +#define _XFS_XFS_SYSCALLS_H_ -int xfs_install_syscalls(void); -int xfs_uninstall_syscalls(void); -int xfs_stat_syscalls(void); -pag_t xfs_get_pag(struct ucred *); +int xfs_install_syscalls __P((void)); +int xfs_uninstall_syscalls __P((void)); +int xfs_stat_syscalls __P((void)); +pag_t xfs_get_pag __P((struct ucred *)); -#endif /* __xfs_syscalls */ +#endif diff --git a/sys/xfs/xfs_vfsops.c b/sys/xfs/xfs_vfsops.c index cc8a39dc536..55d9c59ec5f 100644 --- a/sys/xfs/xfs_vfsops.c +++ b/sys/xfs/xfs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xfs_vfsops.c,v 1.1 1998/08/30 16:47:22 art Exp $ */ +/* $OpenBSD: xfs_vfsops.c,v 1.2 1998/08/31 05:13:19 art Exp $ */ /* * Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). @@ -55,272 +55,262 @@ RCSID("$KTH: xfs_vfsops.c,v 1.22 1998/08/13 01:38:49 art Exp $"); */ #include <xfs/xfs_common.h> -#include <sys/xfs_message.h> +#include <xfs/xfs_message.h> #include <xfs/xfs_dev.h> #include <xfs/xfs_fs.h> #include <xfs/xfs_deb.h> -static struct vnode *make_dead_vnode(struct mount * mp); +static struct vnode *make_dead_vnode(struct mount *mp); struct xfs xfs[NXFS]; static int -xfs_mount(struct mount * mp, - const char *user_path, - caddr_t user_data, - struct nameidata * ndp, - struct proc * p) +xfs_mount(struct mount *mp, + const char *user_path, + caddr_t user_data, + struct nameidata *ndp, + struct proc *p) { - struct vnode *devvp; - dev_t dev; - int error; - struct vattr vat; - char path[MAXPATHLEN]; - char data[MAXPATHLEN]; - size_t len; - - error = copyinstr(user_path, path, MAXPATHLEN, &len); - if (error) - return error; - - error = copyinstr(user_data, data, MAXPATHLEN, &len); - if (error) - return error; - - XFSDEB(XDEBVFOPS, ("xfs_mount: " - "struct mount mp = %p path = %s data = '%s'\n", - mp, path, data)); - - NDINIT(ndp, LOOKUP, FOLLOW | LOCKLEAF, - UIO_SYSSPACE, data, p); - error = namei(ndp); - if (error) - return error; - - devvp = ndp->ni_vp; - - if (devvp->v_type != VCHR) { - vput(devvp); - return ENXIO; - } - error = VOP_GETATTR(devvp, &vat, p->p_ucred, p); - if (error) { + struct vnode *devvp; + dev_t dev; + int error; + struct vattr vat; + char path[MAXPATHLEN]; + char data[MAXPATHLEN]; + size_t len; + + error = copyinstr(user_path, path, MAXPATHLEN, &len); + if (error) + return error; + + error = copyinstr(user_data, data, MAXPATHLEN, &len); + if (error) + return error; + + XFSDEB(XDEBVFOPS, ("xfs_mount: " + "struct mount mp = %p path = %s data = '%s'\n", + mp, path, data)); + + NDINIT(ndp, LOOKUP, FOLLOW | LOCKLEAF, + UIO_SYSSPACE, data, p); + + error = namei(ndp); + if (error) + return error; + + devvp = ndp->ni_vp; + + if (devvp->v_type != VCHR) { + vput(devvp); + return ENXIO; + } + error = VOP_GETATTR(devvp, &vat, p->p_ucred, p); + if (error) { + vput(devvp); + return error; + } + dev = vat.va_rdev; vput(devvp); - return error; - } - dev = vat.va_rdev; - vput(devvp); - - /* Check that this device really is an xfs_dev */ - if (major(dev) < 0 || nchrdev < major(dev)) - return ENXIO; - if (minor(dev) < 0 || NXFS < minor(dev)) - return ENXIO; + + /* Check that this device really is an xfs_dev */ + if (major(dev) < 0 || nchrdev < major(dev)) + return ENXIO; + if (minor(dev) < 0 || NXFS < minor(dev)) + return ENXIO; #if defined(__NetBSD__) || defined(__OpenBSD__) - if (cdevsw[major(dev)].d_open != xfs_devopen) - return ENXIO; + if (cdevsw[major(dev)].d_open != xfs_devopen) + return ENXIO; #elif defined(__FreeBSD__) - if (cdevsw[major(dev)] == NULL - || cdevsw[major(dev)]->d_open != xfs_devopen) - return ENXIO; + if (cdevsw[major(dev)] == NULL + || cdevsw[major(dev)]->d_open != xfs_devopen) + return ENXIO; #endif - if (xfs[minor(dev)].status & XFS_MOUNTED) - return EBUSY; - - xfs[minor(dev)].status = XFS_MOUNTED; - xfs[minor(dev)].mp = mp; - xfs[minor(dev)].root = 0; - xfs[minor(dev)].nnodes = 0; - xfs[minor(dev)].fd = minor(dev); - - VFS_TO_XFS(mp) = &xfs[minor(dev)]; - vfs_getnewfsid(mp); - - mp->mnt_stat.f_bsize = DEV_BSIZE; - mp->mnt_stat.f_iosize = DEV_BSIZE; - mp->mnt_stat.f_blocks = 4711 * 4711; - mp->mnt_stat.f_bfree = 4711 * 4711; - mp->mnt_stat.f_bavail = 4711 * 4711; - mp->mnt_stat.f_files = 4711; - mp->mnt_stat.f_ffree = 4711; - mp->mnt_stat.f_owner = 0; - mp->mnt_stat.f_flags = mp->mnt_flag; - - strncpy(mp->mnt_stat.f_mntonname, - path, - sizeof(mp->mnt_stat.f_mntonname)); - - strncpy(mp->mnt_stat.f_mntfromname, - "arla", - sizeof(mp->mnt_stat.f_mntfromname)); - - strncpy(mp->mnt_stat.f_fstypename, - "xfs", - sizeof(mp->mnt_stat.f_fstypename)); - - return 0; + if (xfs[minor(dev)].status & XFS_MOUNTED) + return EBUSY; + + xfs[minor(dev)].status = XFS_MOUNTED; + xfs[minor(dev)].mp = mp; + xfs[minor(dev)].root = 0; + xfs[minor(dev)].nnodes = 0; + xfs[minor(dev)].fd = minor(dev); + + VFS_TO_XFS(mp) = &xfs[minor(dev)]; + vfs_getnewfsid(mp); + + mp->mnt_stat.f_bsize = DEV_BSIZE; + mp->mnt_stat.f_iosize = DEV_BSIZE; + mp->mnt_stat.f_blocks = 4711 * 4711; + mp->mnt_stat.f_bfree = 4711 * 4711; + mp->mnt_stat.f_bavail = 4711 * 4711; + mp->mnt_stat.f_files = 4711; + mp->mnt_stat.f_ffree = 4711; + mp->mnt_stat.f_owner = 0; + mp->mnt_stat.f_flags = mp->mnt_flag; + + strncpy(mp->mnt_stat.f_mntonname, path, + sizeof(mp->mnt_stat.f_mntonname)); + + /* XXX - It shouldn't be arla, but that will be solved later */ + strncpy(mp->mnt_stat.f_mntfromname, "arla", + sizeof(mp->mnt_stat.f_mntfromname)); + + strncpy(mp->mnt_stat.f_fstypename, "xfs", + sizeof(mp->mnt_stat.f_fstypename)); + + return 0; } static int -xfs_start(struct mount * mp, int flags, struct proc * p) +xfs_start(struct mount *mp, int flags, struct proc *p) { - XFSDEB(XDEBVFOPS, ("xfs_start mp = 0x%x\n", (u_int) mp)); - return 0; + XFSDEB(XDEBVFOPS, ("xfs_start mp = 0x%x\n", (u_int) mp)); + return 0; } static int -xfs_unmount(struct mount * mp, int mntflags, struct proc * p) +xfs_unmount(struct mount *mp, int mntflags, struct proc *p) { - struct xfs *xfsp = VFS_TO_XFS(mp); - extern int doforce; - int flags = 0; - int error; + struct xfs *xfsp = VFS_TO_XFS(mp); + extern int doforce; + int flags = 0; + int error; - XFSDEB(XDEBVFOPS, ("xfs_unmount mp = 0x%x\n", (u_int) mp)); + XFSDEB(XDEBVFOPS, ("xfs_unmount mp = 0x%x\n", (u_int) mp)); - if (mntflags & MNT_FORCE) { - if (!doforce) - return EINVAL; - flags |= FORCECLOSE; - } + if (mntflags & MNT_FORCE) { + if (!doforce) + return EINVAL; + flags |= FORCECLOSE; + } - error = free_all_xfs_nodes(xfsp, flags); - if (error) - return error; + error = free_all_xfs_nodes(xfsp, flags); + if (error) + return error; - xfsp->status = 0; + xfsp->status = 0; - return 0; + return 0; } static int -xfs_root(struct mount * mp, struct vnode ** vpp) +xfs_root(struct mount *mp, struct vnode **vpp) { - struct xfs *xfsp = VFS_TO_XFS(mp); - struct xfs_message_getroot msg; - int error; - - XFSDEB(XDEBVFOPS, ("xfs_root mp = 0x%x\n", (u_int) mp)); - - do { - if (xfsp->root != NULL) { - *vpp = XNODE_TO_VNODE(xfsp->root); - VREF(*vpp); - return 0; - } - msg.header.opcode = XFS_MSG_GETROOT; - msg.cred.uid = curproc->p_ucred->cr_uid; - msg.cred.pag = 0; /* XXX */ - error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); - if (error == 0) - error = ((struct xfs_message_wakeup *) & msg)->error; - } while (error == 0); - /* - * Failed to get message through, need to pretend that all went well - * and return a fake dead vnode to be able to unmount. - */ - *vpp = make_dead_vnode(mp); - (*vpp)->v_flag |= VROOT; - return 0; + struct xfs *xfsp = VFS_TO_XFS(mp); + struct xfs_message_getroot msg; + int error; + + XFSDEB(XDEBVFOPS, ("xfs_root mp = 0x%x\n", (u_int) mp)); + + do { + if (xfsp->root != NULL) { + *vpp = XNODE_TO_VNODE(xfsp->root); + VREF(*vpp); + return 0; + } + msg.header.opcode = XFS_MSG_GETROOT; + msg.cred.uid = curproc->p_ucred->cr_uid; + msg.cred.pag = 0; /* XXX */ + error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); + if (error == 0) + error = ((struct xfs_message_wakeup *) & msg)->error; + } while (error == 0); + /* + * Failed to get message through, need to pretend that all went well + * and return a fake dead vnode to be able to unmount. + */ + *vpp = make_dead_vnode(mp); + (*vpp)->v_flag |= VROOT; + + return 0; } static int -xfs_quotactl(struct mount * mp, - int cmd, - uid_t uid, - caddr_t arg, - struct proc * p) +xfs_quotactl(struct mount *mp, int cmd, uid_t uid, caddr_t arg, struct proc *p) { - XFSDEB(XDEBVFOPS, ("xfs_quotactl\n")); - return (EOPNOTSUPP); + XFSDEB(XDEBVFOPS, ("xfs_quotactl\n")); + + return (EOPNOTSUPP); } static int -xfs_statfs(struct mount * mp, - struct statfs * sbp, - struct proc * p) +xfs_statfs(struct mount *mp, struct statfs *sbp, struct proc *p) { - XFSDEB(XDEBVFOPS, ("xfs_statfs\n")); + XFSDEB(XDEBVFOPS, ("xfs_statfs\n")); - bcopy(&mp->mnt_stat, sbp, sizeof(*sbp)); - return 0; + bcopy(&mp->mnt_stat, sbp, sizeof(*sbp)); + return 0; } static int -xfs_sync(struct mount * mp, - int waitfor, - struct ucred * cred, - struct proc * p) +xfs_sync(struct mount *mp, int waitfor, struct ucred *cred, struct proc *p) { - XFSDEB(XDEBVFOPS, ("xfs_sync\n")); - return 0; + XFSDEB(XDEBVFOPS, ("xfs_sync\n")); + + return 0; } +/* + * This could be implemented by searching if ino_t was bigger. + */ static int -xfs_vget(struct mount * mp, - ino_t ino, - struct vnode ** vpp) +xfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp) { - XFSDEB(XDEBVFOPS, ("xfs_vget\n")); - return EOPNOTSUPP; + XFSDEB(XDEBVFOPS, ("xfs_vget\n")); + + return EOPNOTSUPP; } static int -xfs_fhtovp(struct mount * mp, - struct fid * fhp, - struct mbuf * nam, - struct vnode ** vpp, - int *exflagsp, - struct ucred ** credanonp) +xfs_fhtovp(struct mount *mp, struct fid *fhp, struct mbuf *nam, + struct vnode **vpp, int *exflagsp, struct ucred **credanonp) { - XFSDEB(XDEBVFOPS, ("xfs_fhtovp\n")); - return EOPNOTSUPP; + XFSDEB(XDEBVFOPS, ("xfs_fhtovp\n")); + + return EOPNOTSUPP; } static int -xfs_vptofh(struct vnode * vp, - struct fid * fhp) +xfs_vptofh(struct vnode *vp, struct fid *fhp) { - XFSDEB(XDEBVFOPS, ("xfs_vptofh\n")); - return EOPNOTSUPP; -} + XFSDEB(XDEBVFOPS, ("xfs_vptofh\n")); + return EOPNOTSUPP; +} /* sysctl()able variables :-) */ static int -xfs_sysctl(int *name, u_int namelen, void *oldp, size_t * oldlenp, - void *newp, size_t newlen, struct proc * p) +xfs_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, + void *newp, size_t newlen, struct proc *p) { - /* Supposed to be terminal... */ - if (namelen != 1) - return (ENOTDIR); + /* Supposed to be terminal... */ + if (namelen != 1) + return (ENOTDIR); - return (EOPNOTSUPP); + return (EOPNOTSUPP); } static int -xfs_init(struct vfsconf * vfsp) +xfs_init(struct vfsconf *vfsp) { - XFSDEB(XDEBVFOPS, ("xfs_init\n")); + XFSDEB(XDEBVFOPS, ("xfs_init\n")); - return (0); + return (0); } - struct vfsops xfs_vfsops = { - xfs_mount, - xfs_start, - xfs_unmount, - xfs_root, - xfs_quotactl, - xfs_statfs, - xfs_sync, - xfs_vget, - xfs_fhtovp, - xfs_vptofh, - xfs_init, - xfs_sysctl + xfs_mount, + xfs_start, + xfs_unmount, + xfs_root, + xfs_quotactl, + xfs_statfs, + xfs_sync, + xfs_vget, + xfs_fhtovp, + xfs_vptofh, + xfs_init, + xfs_sysctl }; /* @@ -329,7 +319,7 @@ struct vfsops xfs_vfsops = { static int xfs_uprintf_filsys(void) { - return 0; + return 0; } /* @@ -341,83 +331,77 @@ extern struct vnodeopv_desc xfs_vnodeop_opv_desc; int xfs_install_filesys(void) { + struct vfsconf *vfsp; + struct vfsconf **vfspp; - struct vfsconf *vfsp; - struct vfsconf **vfspp; - + /* Check if filesystem already known */ + for (vfspp = &vfsconf, vfsp = vfsconf; + vfsp; + vfspp = &vfsp->vfc_next, vfsp = vfsp->vfc_next) + if (strncmp(vfsp->vfc_name, + "xfs", MFSNAMELEN) == 0) + return (EEXIST); - /* Check if filesystem already known */ - for (vfspp = &vfsconf, vfsp = vfsconf; - vfsp; - vfspp = &vfsp->vfc_next, vfsp = vfsp->vfc_next) - if (strncmp(vfsp->vfc_name, - "xfs", MFSNAMELEN) == 0) - return (EEXIST); + /* Allocate and initialize */ + MALLOC(vfsp, struct vfsconf *, sizeof(struct vfsconf), + M_VFS, M_WAITOK); - /* Allocate and initialize */ - MALLOC(vfsp, struct vfsconf *, sizeof(struct vfsconf), - M_VFS, M_WAITOK); + vfsp->vfc_vfsops = &xfs_vfsops; + strncpy(vfsp->vfc_name, "xfs", MFSNAMELEN); + vfsp->vfc_typenum = 0; + vfsp->vfc_refcount = 0; + vfsp->vfc_flags = 0; + vfsp->vfc_mountroot = 0; + vfsp->vfc_next = NULL; - vfsp->vfc_vfsops = &xfs_vfsops; - strncpy(vfsp->vfc_name, "xfs", MFSNAMELEN); - vfsp->vfc_typenum = 0; - vfsp->vfc_refcount = 0; - vfsp->vfc_flags = 0; - vfsp->vfc_mountroot = 0; - vfsp->vfc_next = NULL; + maxvfsconf++; - maxvfsconf++; + /* Add to the end of the list */ + *vfspp = vfsp; - /* Add to the end of the list */ - *vfspp = vfsp; + /* Call vfs_init() */ + printf("Calling vfs_init()\n"); + (*(vfsp->vfc_vfsops->vfs_init)) (vfsp); - /* Call vfs_init() */ - printf("Calling vfs_init()\n"); - (*(vfsp->vfc_vfsops->vfs_init)) (vfsp); + /* done! */ - /* done! */ - - return 0; + return 0; } int xfs_uninstall_filesys(void) { + struct vfsconf *vfsp; + struct vfsconf **vfspp; - struct vfsconf *vfsp; - struct vfsconf **vfspp; - + /* Find our vfsconf struct */ + for (vfspp = &vfsconf, vfsp = vfsconf; + vfsp; + vfspp = &vfsp->vfc_next, vfsp = vfsp->vfc_next) + if (strncmp(vfsp->vfc_name, + "xfs", + MFSNAMELEN) == 0) + break; - /* Find our vfsconf struct */ - for (vfspp = &vfsconf, vfsp = vfsconf; - vfsp; - vfspp = &vfsp->vfc_next, vfsp = vfsp->vfc_next) - if (strncmp(vfsp->vfc_name, - "xfs", - MFSNAMELEN) == 0) - break; + if (!vfsp) /* Not found */ + return (EEXIST); - if (!vfsp) /* Not found */ - return (EEXIST); + if (vfsp->vfc_refcount) /* In use */ + return (EBUSY); - if (vfsp->vfc_refcount) /* In use */ - return (EBUSY); + /* Remove from list and free */ + *vfspp = vfsp->vfc_next; + FREE(vfsp, M_VFS); - /* Remove from list and free */ - *vfspp = vfsp->vfc_next; - FREE(vfsp, M_VFS); + maxvfsconf--; - maxvfsconf--; - - return 0; + return 0; } - - int xfs_stat_filesys(void) { - return xfs_uprintf_filsys(); + return xfs_uprintf_filsys(); } /* @@ -427,15 +411,16 @@ xfs_stat_filesys(void) extern int (**dead_vnodeop_p) (void *); static struct vnode * -make_dead_vnode(struct mount * mp) +make_dead_vnode(struct mount *mp) { - struct vnode *dead; - int error; + struct vnode *dead; + int error; - XFSDEB(XDEBNODE, ("make_dead_vnode mp = 0x%x\n", (u_int) mp)); + XFSDEB(XDEBNODE, ("make_dead_vnode mp = 0x%x\n", (u_int) mp)); - if ((error = getnewvnode(VT_NON, mp, dead_vnodeop_p, &dead))) - panic("make_dead_vnode: getnewvnode failed: error = %d\n", error); + if ((error = getnewvnode(VT_NON, mp, dead_vnodeop_p, &dead))) + panic("make_dead_vnode: getnewvnode failed: error = %d\n", + error); - return dead; + return dead; } diff --git a/sys/xfs/xfs_vnodeops.c b/sys/xfs/xfs_vnodeops.c index 67dcd4fdc67..aeef10d1a0c 100644 --- a/sys/xfs/xfs_vnodeops.c +++ b/sys/xfs/xfs_vnodeops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xfs_vnodeops.c,v 1.1 1998/08/30 16:47:22 art Exp $ */ +/* $OpenBSD: xfs_vnodeops.c,v 1.2 1998/08/31 05:13:20 art Exp $ */ /* * Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). @@ -50,7 +50,7 @@ #include <sys/mount.h> #include <sys/fcntl.h> -#include <sys/xfs_message.h> +#include <xfs/xfs_message.h> #include <xfs/xfs_dev.h> #include <xfs/xfs_common.h> #include <xfs/xfs_fs.h> @@ -60,149 +60,148 @@ RCSID("$KTH: xfs_vnodeops.c,v 1.41 1998/08/14 04:54:09 art Exp $"); static int -xfs_open_valid(struct vnode * vp, struct ucred * cred, u_int tok) +xfs_open_valid(struct vnode *vp, struct ucred *cred, u_int tok) { - struct xfs *xfsp = XFS_FROM_VNODE(vp); - struct xfs_node *xn = VNODE_TO_XNODE(vp); - int error = 0; - - XFSDEB(XDEBVFOPS, ("xfs_open_valid\n")); - - do { - if (!XFS_TOKEN_GOT(xn, tok)) { - struct xfs_message_open msg; - - msg.header.opcode = XFS_MSG_OPEN; - msg.cred.uid = cred->cr_uid; - msg.cred.pag = xfs_get_pag(cred); - msg.handle = xn->handle; - msg.tokens = tok; - error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); - if (error == 0) - error = ((struct xfs_message_wakeup *) & msg)->error; - } else { - goto done; - } - } while (error == 0); - -done: - return error; + struct xfs *xfsp = XFS_FROM_VNODE(vp); + struct xfs_node *xn = VNODE_TO_XNODE(vp); + int error = 0; + + XFSDEB(XDEBVFOPS, ("xfs_open_valid\n")); + + do { + if (!XFS_TOKEN_GOT(xn, tok)) { + struct xfs_message_open msg; + + msg.header.opcode = XFS_MSG_OPEN; + msg.cred.uid = cred->cr_uid; + msg.cred.pag = xfs_get_pag(cred); + msg.handle = xn->handle; + msg.tokens = tok; + error = xfs_message_rpc(xfsp->fd, &msg.header, + sizeof(msg)); + if (error == 0) + error = ((struct xfs_message_wakeup *)&msg)->error; + } else { + goto done; + } + } while (error == 0); + + done: + return error; } static int -xfs_attr_valid(struct vnode * vp, struct ucred * cred, u_int tok) +xfs_attr_valid(struct vnode *vp, struct ucred *cred, u_int tok) { - struct xfs *xfsp = XFS_FROM_VNODE(vp); - struct xfs_node *xn = VNODE_TO_XNODE(vp); - int error = 0; - - pag_t pag = xfs_get_pag(cred); - - do { - if (!XFS_TOKEN_GOT(xn, tok)) { - struct xfs_message_getattr msg; - - msg.header.opcode = XFS_MSG_GETATTR; - msg.cred.uid = cred->cr_uid; - msg.cred.pag = pag; - msg.handle = xn->handle; - error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); - if (error == 0) - error = ((struct xfs_message_wakeup *) & msg)->error; - } else { - goto done; - } - } while (error == 0); - -done: - return error; + struct xfs *xfsp = XFS_FROM_VNODE(vp); + struct xfs_node *xn = VNODE_TO_XNODE(vp); + int error = 0; + pag_t pag = xfs_get_pag(cred); + + do { + if (!XFS_TOKEN_GOT(xn, tok)) { + struct xfs_message_getattr msg; + + msg.header.opcode = XFS_MSG_GETATTR; + msg.cred.uid = cred->cr_uid; + msg.cred.pag = pag; + msg.handle = xn->handle; + error = xfs_message_rpc(xfsp->fd, &msg.header, + sizeof(msg)); + if (error == 0) + error = ((struct xfs_message_wakeup *) &msg)->error; + } else { + goto done; + } + } while (error == 0); + + done: + return error; } static int -xfs_rights_valid(struct vnode * vp, struct ucred * cred) +xfs_rights_valid(struct vnode *vp, struct ucred *cred) { - struct xfs *xfsp = XFS_FROM_VNODE(vp); - struct xfs_node *xn = VNODE_TO_XNODE(vp); - int error = 0; - - pag_t pag = xfs_get_pag(cred); - - do { - if (!xfs_has_pag(xn, pag)) { - struct xfs_message_getattr msg; - - msg.header.opcode = XFS_MSG_GETATTR; - msg.cred.uid = cred->cr_uid; - msg.cred.pag = pag; - msg.handle = xn->handle; - error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); - if (error == 0) - error = ((struct xfs_message_wakeup *) & msg)->error; - } else { - goto done; - } - } while (error == 0); - -done: - return error; + struct xfs *xfsp = XFS_FROM_VNODE(vp); + struct xfs_node *xn = VNODE_TO_XNODE(vp); + int error = 0; + pag_t pag = xfs_get_pag(cred); + + do { + if (!xfs_has_pag(xn, pag)) { + struct xfs_message_getattr msg; + + msg.header.opcode = XFS_MSG_GETATTR; + msg.cred.uid = cred->cr_uid; + msg.cred.pag = pag; + msg.handle = xn->handle; + error = xfs_message_rpc(xfsp->fd, &msg.header, + sizeof(msg)); + if (error == 0) + error = ((struct xfs_message_wakeup *) &msg)->error; + } else { + goto done; + } + } while (error == 0); + + done: + return error; } static int -xfs_data_valid(struct vnode * vp, struct ucred * cred, u_int tok) +xfs_data_valid(struct vnode *vp, struct ucred *cred, u_int tok) { - struct xfs *xfsp = XFS_FROM_VNODE(vp); - struct xfs_node *xn = VNODE_TO_XNODE(vp); - int error = 0; - - do { - if (!XFS_TOKEN_GOT(xn, tok)) { - struct xfs_message_getdata msg; - - msg.header.opcode = XFS_MSG_GETDATA; - msg.cred.uid = cred->cr_uid; - msg.cred.pag = xfs_get_pag(cred); - msg.handle = xn->handle; - msg.tokens = tok; - error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); - if (error == 0) - error = ((struct xfs_message_wakeup *) & msg)->error; - } else { - goto done; - } - } while (error == 0); - -done: - return error; + struct xfs *xfsp = XFS_FROM_VNODE(vp); + struct xfs_node *xn = VNODE_TO_XNODE(vp); + int error = 0; + + do { + if (!XFS_TOKEN_GOT(xn, tok)) { + struct xfs_message_getdata msg; + + msg.header.opcode = XFS_MSG_GETDATA; + msg.cred.uid = cred->cr_uid; + msg.cred.pag = xfs_get_pag(cred); + msg.handle = xn->handle; + msg.tokens = tok; + error = xfs_message_rpc(xfsp->fd, &msg.header, + sizeof(msg)); + if (error == 0) + error = ((struct xfs_message_wakeup *) &msg)->error; + } else { + goto done; + } + } while (error == 0); + + done: + return error; } static int -do_fsync(struct xfs * xfsp, - struct xfs_node * xn, - struct ucred * cred, - u_int flag) +do_fsync(struct xfs *xfsp, struct xfs_node *xn, struct ucred *cred, u_int flag) { - int error; - struct xfs_message_putdata msg; - - msg.header.opcode = XFS_MSG_PUTDATA; - if (cred != NOCRED) { - msg.cred.uid = cred->cr_uid; - msg.cred.pag = xfs_get_pag(cred); - } else { - msg.cred.uid = 0; - msg.cred.pag = XFS_ANONYMOUSID; - } - msg.handle = xn->handle; + int error; + struct xfs_message_putdata msg; + + msg.header.opcode = XFS_MSG_PUTDATA; + if (cred != NOCRED) { + msg.cred.uid = cred->cr_uid; + msg.cred.pag = xfs_get_pag(cred); + } else { + msg.cred.uid = 0; + msg.cred.pag = XFS_ANONYMOUSID; + } + msg.handle = xn->handle; - msg.flag = flag; - error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); - if (error == 0) - error = ((struct xfs_message_wakeup *) & msg)->error; + msg.flag = flag; + error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); + if (error == 0) + error = ((struct xfs_message_wakeup *) &msg)->error; - if (error == 0) - xn->flags &= ~XFS_DATA_DIRTY; + if (error == 0) + xn->flags &= ~XFS_DATA_DIRTY; - return error; + return error; } /* @@ -212,227 +211,237 @@ do_fsync(struct xfs * xfsp, static int xfs_open(void *vap) { - struct vop_open_args *ap = vap; + struct vop_open_args *ap = vap; - XFSDEB(XDEBVNOPS, ("xfs_open\n")); + XFSDEB(XDEBVNOPS, ("xfs_open\n")); - if (ap->a_mode & FWRITE) - return xfs_open_valid(ap->a_vp, ap->a_cred, XFS_OPEN_NW); - else - return xfs_open_valid(ap->a_vp, ap->a_cred, XFS_OPEN_NR); + if (ap->a_mode & FWRITE) + return xfs_open_valid(ap->a_vp, ap->a_cred, XFS_OPEN_NW); + else + return xfs_open_valid(ap->a_vp, ap->a_cred, XFS_OPEN_NR); } static int xfs_fsync(void *vap) { - struct vop_fsync_args *ap = vap; - - struct xfs *xfsp = XFS_FROM_VNODE(ap->a_vp); - struct xfs_node *xn = VNODE_TO_XNODE(ap->a_vp); - int error = 0; + struct vop_fsync_args *ap = vap; - XFSDEB(XDEBVNOPS, ("xfs_fsync: 0x%x\n", (int) ap->a_vp)); + struct xfs *xfsp = XFS_FROM_VNODE(ap->a_vp); + struct xfs_node *xn = VNODE_TO_XNODE(ap->a_vp); + int error = 0; - /* - * It seems that fsync is sometimes called after reclaiming a node. - * In that case we just look happy. - */ + XFSDEB(XDEBVNOPS, ("xfs_fsync: 0x%x\n", (int) ap->a_vp)); - if (xn == NULL) { - printf("XFS PANIC WARNING! xfs_fsync called after reclaiming!\n"); - return 0; - } + /* + * It seems that fsync is sometimes called after reclaiming a node. + * In that case we just look happy. + */ + if (xn == NULL) { + printf("XFS PANIC WARNING! xfs_fsync after reclaiming!\n"); + return 0; + } - if (xn->flags & XFS_DATA_DIRTY) - error = do_fsync(xfsp, xn, ap->a_cred, XFS_WRITE); + if (xn->flags & XFS_DATA_DIRTY) + error = do_fsync(xfsp, xn, ap->a_cred, XFS_WRITE); - return error; + return error; } static int xfs_close(void *vap) { - struct vop_close_args *ap = vap; + struct vop_close_args *ap = vap; - struct xfs *xfsp = XFS_FROM_VNODE(ap->a_vp); - struct xfs_node *xn = VNODE_TO_XNODE(ap->a_vp); - int error = 0; + struct xfs *xfsp = XFS_FROM_VNODE(ap->a_vp); + struct xfs_node *xn = VNODE_TO_XNODE(ap->a_vp); + int error = 0; - XFSDEB(XDEBVNOPS, ("xfs_close cred = %p\n", ap->a_cred)); + XFSDEB(XDEBVNOPS, ("xfs_close cred = %p\n", ap->a_cred)); - if (ap->a_fflag & FWRITE && xn->flags & XFS_DATA_DIRTY) - error = do_fsync(xfsp, xn, ap->a_cred, XFS_WRITE); + if (ap->a_fflag & FWRITE && xn->flags & XFS_DATA_DIRTY) + error = do_fsync(xfsp, xn, ap->a_cred, XFS_WRITE); - return error; + return error; } static int xfs_read(void *vap) { - struct vop_read_args *ap = vap; + struct vop_read_args *ap = vap; - int error = 0; + int error = 0; - XFSDEB(XDEBVNOPS, ("xfs_read\n")); + XFSDEB(XDEBVNOPS, ("xfs_read\n")); - error = xfs_data_valid(ap->a_vp, ap->a_cred, XFS_DATA_R); + error = xfs_data_valid(ap->a_vp, ap->a_cred, XFS_DATA_R); + if (error == 0) { + struct vnode *t = DATA_FROM_VNODE(ap->a_vp); - if (error == 0) { - struct vnode *t = DATA_FROM_VNODE(ap->a_vp); + vn_lock(t, LK_EXCLUSIVE | LK_RETRY, ap->a_uio->uio_procp); + error = VOP_READ(t, ap->a_uio, ap->a_ioflag, ap->a_cred); + VOP_UNLOCK(t, 0, ap->a_uio->uio_procp); + } - vn_lock(t, LK_EXCLUSIVE | LK_RETRY, ap->a_uio->uio_procp); - error = VOP_READ(t, ap->a_uio, ap->a_ioflag, ap->a_cred); - VOP_UNLOCK(t, 0, ap->a_uio->uio_procp); - } - return error; + return error; } static int xfs_write(void *vap) { - struct vop_read_args *ap = vap; - - struct vnode *vp = ap->a_vp; - struct uio *uiop = ap->a_uio; - int ioflag = ap->a_ioflag; - struct ucred *cred = ap->a_cred; - int error = 0; + struct vop_read_args *ap = vap; - XFSDEB(XDEBVNOPS, ("xfs_write\n")); + struct vnode *vp = ap->a_vp; + struct uio *uiop = ap->a_uio; + int ioflag = ap->a_ioflag; + struct ucred *cred = ap->a_cred; + int error = 0; - error = xfs_data_valid(vp, cred, XFS_DATA_W); + XFSDEB(XDEBVNOPS, ("xfs_write\n")); - if (error == 0) { - struct xfs_node *xn = VNODE_TO_XNODE(vp); - struct vnode *t = DATA_FROM_XNODE(xn); - struct vattr sub_attr; - int error2 = 0; - - vn_lock(t, LK_EXCLUSIVE | LK_RETRY, uiop->uio_procp); - error = VOP_WRITE(t, uiop, ioflag, cred); - VNODE_TO_XNODE(ap->a_vp)->flags |= XFS_DATA_DIRTY; - - error2 = VOP_GETATTR(t, &sub_attr, cred, uiop->uio_procp); - if (error2 == 0) { - xn->attr.va_size = sub_attr.va_size; - xn->attr.va_mtime = sub_attr.va_mtime; + error = xfs_data_valid(vp, cred, XFS_DATA_W); + if (error == 0) { + struct xfs_node *xn = VNODE_TO_XNODE(vp); + struct vnode *t = DATA_FROM_XNODE(xn); + struct vattr sub_attr; + int error2 = 0; + + vn_lock(t, LK_EXCLUSIVE | LK_RETRY, uiop->uio_procp); + error = VOP_WRITE(t, uiop, ioflag, cred); + VNODE_TO_XNODE(ap->a_vp)->flags |= XFS_DATA_DIRTY; + + /* Update size an mtime on the xfs node from the cache node */ + error2 = VOP_GETATTR(t, &sub_attr, cred, uiop->uio_procp); + if (error2 == 0) { + xn->attr.va_size = sub_attr.va_size; + xn->attr.va_mtime = sub_attr.va_mtime; + } + + VOP_UNLOCK(t, 0, ap->a_uio->uio_procp); } - VOP_UNLOCK(t, 0, ap->a_uio->uio_procp); - } - - return error; + return error; } static int xfs_getattr(void *vap) { - struct vop_getattr_args *ap = vap; - int error = 0; + struct vop_getattr_args *ap = vap; - struct xfs_node *xn = VNODE_TO_XNODE(ap->a_vp); + int error = 0; + struct xfs_node *xn = VNODE_TO_XNODE(ap->a_vp); - XFSDEB(XDEBVNOPS, ("xfs_getattr\n")); + XFSDEB(XDEBVNOPS, ("xfs_getattr\n")); - error = xfs_attr_valid(ap->a_vp, ap->a_cred, XFS_ATTR_R); - if (error == 0) { - *ap->a_vap = xn->attr; - } - return error; + error = xfs_attr_valid(ap->a_vp, ap->a_cred, XFS_ATTR_R); + if (error == 0) { + *ap->a_vap = xn->attr; + } + + return error; } static int xfs_setattr(void *vap) { - struct vop_setattr_args *ap = vap; - struct xfs *xfsp = XFS_FROM_VNODE(ap->a_vp); - struct xfs_node *xn = VNODE_TO_XNODE(ap->a_vp); - int error = 0; - - XFSDEB(XDEBVNOPS, ("xfs_setattr\n")); - if (XFS_TOKEN_GOT(xn, XFS_ATTR_W)) { - /* Update attributes and mark them dirty. */ - VNODE_TO_XNODE(ap->a_vp)->flags |= XFS_ATTR_DIRTY; - error = EINVAL; /* XXX not yet implemented */ - goto done; - } else { - struct xfs_message_putattr msg; - - msg.header.opcode = XFS_MSG_PUTATTR; - if (ap->a_cred != NOCRED) { - msg.cred.uid = ap->a_cred->cr_uid; - msg.cred.pag = xfs_get_pag(ap->a_cred); + struct vop_setattr_args *ap = vap; + + struct xfs *xfsp = XFS_FROM_VNODE(ap->a_vp); + struct xfs_node *xn = VNODE_TO_XNODE(ap->a_vp); + int error = 0; + + XFSDEB(XDEBVNOPS, ("xfs_setattr\n")); + if (XFS_TOKEN_GOT(xn, XFS_ATTR_W)) { + /* Update attributes and mark them dirty. */ + VNODE_TO_XNODE(ap->a_vp)->flags |= XFS_ATTR_DIRTY; + error = EINVAL; /* XXX not yet implemented */ + goto done; } else { - msg.cred.uid = 0; - msg.cred.pag = XFS_ANONYMOUSID; + struct xfs_message_putattr msg; + + msg.header.opcode = XFS_MSG_PUTATTR; + if (ap->a_cred != NOCRED) { + msg.cred.uid = ap->a_cred->cr_uid; + msg.cred.pag = xfs_get_pag(ap->a_cred); + } else { + msg.cred.uid = 0; + msg.cred.pag = XFS_ANONYMOUSID; + } + msg.handle = xn->handle; + vattr2xfs_attr(ap->a_vap, &msg.attr); + + XFS_TOKEN_CLEAR(xn, XFS_ATTR_VALID, XFS_ATTR_MASK); + error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); + if (error == 0) + error = ((struct xfs_message_wakeup *) &msg)->error; } - msg.handle = xn->handle; - vattr2xfs_attr(ap->a_vap, &msg.attr); - error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); - if (error == 0) - error = ((struct xfs_message_wakeup *) & msg)->error; - XFS_TOKEN_CLEAR(xn, XFS_ATTR_VALID, XFS_ATTR_MASK); - } -done: - return error; + done: + return error; } +/* + * HANDS OFF! Don't touch this one if you aren't really really sure what you + * are doing! + */ static int check_rights (u_char rights, int mode) { - int error = 0; - - if (mode & VREAD) - if ((rights & XFS_RIGHT_R) == 0) - error = EACCES; - if (mode & VWRITE) - if ((rights & XFS_RIGHT_W) == 0) - error = EACCES; - if (mode & VEXEC) - if ((rights & XFS_RIGHT_X) == 0) - error = EACCES; - return error; + int error = 0; + + if (mode & VREAD) + if ((rights & XFS_RIGHT_R) == 0) + error = EACCES; + if (mode & VWRITE) + if ((rights & XFS_RIGHT_W) == 0) + error = EACCES; + if (mode & VEXEC) + if ((rights & XFS_RIGHT_X) == 0) + error = EACCES; + + return error; } +/* + * HANDS OFF! Don't touch this one if you aren't really really sure what you + * are doing! + */ static int xfs_access(void *vap) { - struct vop_access_args *ap = vap; - - int error = 0; - int mode = ap->a_mode; - pag_t pag = xfs_get_pag(ap->a_cred); - - XFSDEB(XDEBVNOPS, ("xfs_access mode = 0%o\n", mode)); + struct vop_access_args *ap = vap; - error = xfs_attr_valid(ap->a_vp, ap->a_cred, XFS_ATTR_R); - if (error == 0) { - struct xfs_node *xn = VNODE_TO_XNODE(ap->a_vp); - int i; + int error = 0; + int mode = ap->a_mode; + pag_t pag = xfs_get_pag(ap->a_cred); - error = check_rights (xn->anonrights, mode); + XFSDEB(XDEBVNOPS, ("xfs_access mode = 0%o\n", mode)); - if (error == 0) - goto done; + error = xfs_attr_valid(ap->a_vp, ap->a_cred, XFS_ATTR_R); + if (error == 0) { + struct xfs_node *xn = VNODE_TO_XNODE(ap->a_vp); + int i; - XFSDEB(XDEBVNOPS, ("xfs_access anonaccess failed\n")); + error = check_rights (xn->anonrights, mode); + if (error == 0) + goto done; - xfs_rights_valid(ap->a_vp, ap->a_cred); /* ignore error */ + XFSDEB(XDEBVNOPS, ("xfs_access anonaccess failed\n")); - error = EACCES; /* default to EACCES if pag isn't in xn->id */ + xfs_rights_valid(ap->a_vp, ap->a_cred); /* ignore error */ - for (i = 0; i < MAXRIGHTS; i++) - if (xn->id[i] == pag) { - error = check_rights (xn->rights[i], mode); - break; - } - } + /* default to EACCES if pag isn't in xn->id */ + error = EACCES; -done: - XFSDEB(XDEBVNOPS, ("xfs_access(0%o) = %d\n", mode, error)); + for (i = 0; i < MAXRIGHTS; i++) + if (xn->id[i] == pag) { + error = check_rights (xn->rights[i], mode); + break; + } + } - return error; + done: + XFSDEB(XDEBVNOPS, ("xfs_access(0%o) = %d\n", mode, error)); + return error; } /* @@ -446,555 +455,555 @@ static int do_actual_lookup(struct vnode *dvp, struct componentname *cnp, struct vnode **vpp) { - int error; - struct xfs_node *d = VNODE_TO_XNODE(dvp); - struct xfs_message_getnode msg; - struct xfs *xfsp = XFS_FROM_VNODE(dvp); - - if (dvp->v_type != VDIR) - return ENOTDIR; - - do { - error = xfs_dnlc_lookup(dvp, cnp, vpp); - if (error == 0) { - msg.header.opcode = XFS_MSG_GETNODE; - if (cnp->cn_cred != NOCRED) { - msg.cred.uid = cnp->cn_cred->cr_uid; - msg.cred.pag = xfs_get_pag(cnp->cn_cred); - } else { - msg.cred.uid = 0; - msg.cred.pag = XFS_ANONYMOUSID; - } - msg.parent_handle = d->handle; - - bcopy(cnp->cn_nameptr, msg.name, cnp->cn_namelen); - msg.name[cnp->cn_namelen] = '\0'; - - error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); - - if (error == 0) - error = ((struct xfs_message_wakeup *) & msg)->error; - if (error == ENOENT && cnp->cn_namelen <= NCHNAMLEN) { - XFSDEB(XDEBVNOPS, ("xfs_lookup: neg cache %p (%s, %ld)\n", - dvp, - cnp->cn_nameptr, cnp->cn_namelen)); - cache_enter (dvp, NULL, cnp); - } - - XFSDEB(XDEBVNOPS, ("xfs_lookup error: %d\n", error)); - } else if (error == -1) { - vget(*vpp, 0, cnp->cn_proc); - error = 0; - goto done; - } - } while (error == 0); - -done: - - return error; + int error; + struct xfs_node *d = VNODE_TO_XNODE(dvp); + struct xfs *xfsp = XFS_FROM_VNODE(dvp); + struct xfs_message_getnode msg; + + if (dvp->v_type != VDIR) + return ENOTDIR; + + do { + error = xfs_dnlc_lookup(dvp, cnp, vpp); + if (error == 0) { + msg.header.opcode = XFS_MSG_GETNODE; + + if (cnp->cn_cred != NOCRED) { + msg.cred.uid = cnp->cn_cred->cr_uid; + msg.cred.pag = xfs_get_pag(cnp->cn_cred); + } else { + msg.cred.uid = 0; + msg.cred.pag = XFS_ANONYMOUSID; + } + msg.parent_handle = d->handle; + + bcopy(cnp->cn_nameptr, msg.name, cnp->cn_namelen); + msg.name[cnp->cn_namelen] = '\0'; + + error = xfs_message_rpc(xfsp->fd, &msg.header, + sizeof(msg)); + if (error == 0) + error = ((struct xfs_message_wakeup *) &msg)->error; + if (error == ENOENT && cnp->cn_namelen <= NCHNAMLEN) { + XFSDEB(XDEBVNOPS, + ("xfs_lookup: neg cache %p (%s, %ld)\n", + dvp, + cnp->cn_nameptr, cnp->cn_namelen)); + cache_enter (dvp, NULL, cnp); + } + + XFSDEB(XDEBVNOPS, ("xfs_lookup error: %d\n", error)); + } else if (error == -1) { + vget(*vpp, 0, cnp->cn_proc); + error = 0; + goto done; + } + } while (error == 0); + + done: + return error; } static int xfs_lookup(void *vap) { - struct vop_lookup_args *ap = vap; - - struct vnode *dvp = ap->a_dvp; - struct componentname *cnp = ap->a_cnp; - int nameiop = cnp->cn_nameiop; - int flags = cnp->cn_flags; - int islastcn = flags & ISLASTCN; - struct proc *p = cnp->cn_proc; - int error = 0; + struct vop_lookup_args *ap = vap; + + struct vnode *dvp = ap->a_dvp; + struct componentname *cnp = ap->a_cnp; + int nameiop = cnp->cn_nameiop; + int flags = cnp->cn_flags; + int islastcn = flags & ISLASTCN; + struct proc *p = cnp->cn_proc; + int error = 0; + + XFSDEB(XDEBVNOPS, ("xfs_lookup: (%s, %ld)\n", + cnp->cn_nameptr, + cnp->cn_namelen)); + + *ap->a_vpp = NULL; + + error = do_actual_lookup(dvp, cnp, ap->a_vpp); + if (error == ENOENT + && (nameiop == CREATE || nameiop == RENAME) + && islastcn) { + error = EJUSTRETURN; + } - XFSDEB(XDEBVNOPS, ("xfs_lookup: (%s, %ld)\n", - cnp->cn_nameptr, - cnp->cn_namelen)); + if (nameiop != LOOKUP && islastcn) + cnp->cn_flags |= SAVENAME; - *ap->a_vpp = NULL; + if ((error == EJUSTRETURN || error == 0) && + !(islastcn && flags & LOCKPARENT)) + VOP_UNLOCK(ap->a_dvp, 0, p); - error = do_actual_lookup(dvp, cnp, ap->a_vpp); + XFSDEB(XDEBVNOPS, ("xfs_lookup() error = %d\n", error)); + return error; +} - if (error == ENOENT - && (nameiop == CREATE || nameiop == RENAME) - && islastcn) { - error = EJUSTRETURN; +static int +xfs_create(void *vap) +{ + struct vop_create_args *ap = vap; + + struct xfs *xfsp = XFS_FROM_VNODE(ap->a_dvp); + struct xfs_node *xn = VNODE_TO_XNODE(ap->a_dvp); + struct componentname *cnp = ap->a_cnp; + int error = 0; + + XFSDEB(XDEBVNOPS, ("xfs_create: (%s, %ld)\n", + cnp->cn_nameptr, + cnp->cn_namelen)); + { + struct xfs_message_create msg; + + msg.header.opcode = XFS_MSG_CREATE; + msg.parent_handle = xn->handle; + strncpy(msg.name, cnp->cn_nameptr, 256); + vattr2xfs_attr(ap->a_vap, &msg.attr); + + msg.mode = 0; /* XXX - mode */ + if (cnp->cn_cred != NOCRED) { + msg.cred.uid = cnp->cn_cred->cr_uid; + msg.cred.pag = xfs_get_pag(cnp->cn_cred); + } else { + msg.cred.uid = 0; + msg.cred.pag = XFS_ANONYMOUSID; + } + + error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); + if (error == 0) + error = ((struct xfs_message_wakeup *) &msg)->error; } - if (nameiop != LOOKUP && islastcn) - cnp->cn_flags |= SAVENAME; + if (error == 0) { + error = do_actual_lookup(ap->a_dvp, cnp, ap->a_vpp); + } + + if (error != 0 || (cnp->cn_flags & SAVESTART) == 0) + free(cnp->cn_pnbuf, M_NAMEI); - if ((error == EJUSTRETURN || error == 0) && - !(islastcn && flags & LOCKPARENT)) - VOP_UNLOCK(ap->a_dvp, 0, p); + vput(ap->a_dvp); - XFSDEB(XDEBVNOPS, ("xfs_lookup() error = %d\n", error)); - return error; + return error; } static int -xfs_create(void *vap) +xfs_remove(void *vap) { - struct vop_create_args *ap = vap; - - struct xfs *xfsp = XFS_FROM_VNODE(ap->a_dvp); - struct xfs_node *xn = VNODE_TO_XNODE(ap->a_dvp); - struct componentname *cnp = ap->a_cnp; - int error = 0; + struct vop_remove_args *ap = vap; + struct vnode *dvp = ap->a_dvp; + struct vnode *vp = ap->a_vp; + struct xfs *xfsp = XFS_FROM_VNODE(dvp); + struct xfs_node *xn = VNODE_TO_XNODE(dvp); + struct componentname *cnp = ap->a_cnp; + struct xfs_message_remove msg; + int error; - XFSDEB(XDEBVNOPS, ("xfs_create: (%s, %ld)\n", - cnp->cn_nameptr, - cnp->cn_namelen)); - { - struct xfs_message_create msg; + XFSDEB(XDEBVNOPS, ("xfs_remove: (%s, %ld\n", + cnp->cn_nameptr, + cnp->cn_namelen)); - msg.header.opcode = XFS_MSG_CREATE; + msg.header.opcode = XFS_MSG_REMOVE; msg.parent_handle = xn->handle; strncpy(msg.name, cnp->cn_nameptr, 256); - vattr2xfs_attr(ap->a_vap, &msg.attr); + msg.cred.uid = cnp->cn_cred->cr_uid; + msg.cred.pag = xfs_get_pag(cnp->cn_cred); - msg.mode = 0; /* XXX - mode */ - if (cnp->cn_cred != NOCRED) { - msg.cred.uid = cnp->cn_cred->cr_uid; - msg.cred.pag = xfs_get_pag(cnp->cn_cred); - } else { - msg.cred.uid = 0; - msg.cred.pag = XFS_ANONYMOUSID; - } error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); if (error == 0) - error = ((struct xfs_message_wakeup *) & msg)->error; - } + error = ((struct xfs_message_wakeup *) &msg)->error; - if (error == 0) { - error = do_actual_lookup(ap->a_dvp, cnp, ap->a_vpp); - } + if (error == 0) + cache_purge (vp); - if (error != 0 || (cnp->cn_flags & SAVESTART) == 0) - free (cnp->cn_pnbuf, M_NAMEI); + if (dvp == vp) + vrele(vp); + else + vput(vp); - vput(ap->a_dvp); + vput(dvp); - return error; -} + if (error != 0 || (cnp->cn_flags & SAVESTART) == 0) + free(cnp->cn_pnbuf, M_NAMEI); -static int -xfs_remove(void *vap) -{ - struct vop_remove_args *ap = vap; - struct vnode *dvp = ap->a_dvp; - struct vnode *vp = ap->a_vp; - struct xfs *xfsp = XFS_FROM_VNODE(dvp); - struct xfs_node *xn = VNODE_TO_XNODE(dvp); - struct componentname *cnp = ap->a_cnp; - struct xfs_message_remove msg; - int error; - - XFSDEB(XDEBVNOPS, ("xfs_remove: (%s, %ld\n", - cnp->cn_nameptr, - cnp->cn_namelen)); - - msg.header.opcode = XFS_MSG_REMOVE; - msg.parent_handle = xn->handle; - strncpy(msg.name, cnp->cn_nameptr, 256); - msg.cred.uid = cnp->cn_cred->cr_uid; - msg.cred.pag = xfs_get_pag(cnp->cn_cred); - error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); - if (error == 0) - error = ((struct xfs_message_wakeup *) &msg)->error; - - if (error == 0) - cache_purge (vp); - -#ifdef DIAGNOSTIC - /* - * vp == dvp should not happen. - * 1. vp == dvp means that we are removing a directory and this is - * remove, not rmdir. - */ - if (dvp == vp) - panic("vp == dvp"); -#endif - - vput(vp); - vput(dvp); - - if (error != 0 || (cnp->cn_flags & SAVESTART) == 0) - free (cnp->cn_pnbuf, M_NAMEI); - - return error; + return error; } static int xfs_rename(void *vap) { - struct vop_rename_args *ap = vap; - - struct vnode *fdvp = ap->a_fdvp; - struct vnode *fvp = ap->a_fvp; - struct componentname *fcnp = ap->a_fcnp; - struct vnode *tdvp = ap->a_tdvp; - struct vnode *tvp = ap->a_tvp; - struct componentname *tcnp = ap->a_tcnp; - struct xfs *xfsp = XFS_FROM_VNODE(fdvp); - int error; - - XFSDEB(XDEBVNOPS, ("xfs_rename\n")); - - if ((fvp->v_mount != tdvp->v_mount) - || (tvp && (fvp->v_mount != tvp->v_mount))) { - error = EXDEV; - goto abort; - } + struct vop_rename_args *ap = vap; + + struct vnode *fdvp = ap->a_fdvp; + struct vnode *fvp = ap->a_fvp; + struct componentname *fcnp = ap->a_fcnp; + struct vnode *tdvp = ap->a_tdvp; + struct vnode *tvp = ap->a_tvp; + struct componentname *tcnp = ap->a_tcnp; + struct xfs *xfsp = XFS_FROM_VNODE(fdvp); + int error; + + XFSDEB(XDEBVNOPS, ("xfs_rename\n")); + + if ((fvp->v_mount != tdvp->v_mount) + || (tvp && (fvp->v_mount != tvp->v_mount))) { + error = EXDEV; + goto abort; + } - if (tvp) { - struct xfs_message_remove msg; + if (tvp) { + struct xfs_message_remove msg; - msg.header.opcode = XFS_MSG_REMOVE; - msg.parent_handle = VNODE_TO_XNODE(tdvp)->handle; - strncpy(msg.name, tcnp->cn_nameptr, 256); - msg.cred.uid = tcnp->cn_cred->cr_uid; - msg.cred.pag = xfs_get_pag(tcnp->cn_cred); - error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); - if (error == 0) - error = ((struct xfs_message_wakeup *) &msg)->error; + msg.header.opcode = XFS_MSG_REMOVE; + msg.parent_handle = VNODE_TO_XNODE(tdvp)->handle; + strncpy(msg.name, tcnp->cn_nameptr, 256); + msg.cred.uid = tcnp->cn_cred->cr_uid; + msg.cred.pag = xfs_get_pag(tcnp->cn_cred); - if (error) - goto abort; + error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); + if (error == 0) + error = ((struct xfs_message_wakeup *) &msg)->error; - vput(tvp); - tvp = NULL; - } + if (error) + goto abort; - { - struct xfs_message_rename msg; + vput(tvp); + tvp = NULL; + } - msg.header.opcode = XFS_MSG_RENAME; - msg.old_parent_handle = VNODE_TO_XNODE(fdvp)->handle; - strncpy(msg.old_name, fcnp->cn_nameptr, 256); - msg.new_parent_handle = VNODE_TO_XNODE(tdvp)->handle; - strncpy(msg.new_name, tcnp->cn_nameptr, 256); - msg.cred.uid = tcnp->cn_cred->cr_uid; - msg.cred.pag = xfs_get_pag(tcnp->cn_cred); - error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); - if (error == 0) - error = ((struct xfs_message_wakeup *) &msg)->error; + { + struct xfs_message_rename msg; - } + msg.header.opcode = XFS_MSG_RENAME; + msg.old_parent_handle = VNODE_TO_XNODE(fdvp)->handle; + strncpy(msg.old_name, fcnp->cn_nameptr, 256); + msg.new_parent_handle = VNODE_TO_XNODE(tdvp)->handle; + strncpy(msg.new_name, tcnp->cn_nameptr, 256); + msg.cred.uid = tcnp->cn_cred->cr_uid; + msg.cred.pag = xfs_get_pag(tcnp->cn_cred); + error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); + if (error == 0) + error = ((struct xfs_message_wakeup *) &msg)->error; + } -abort: - VOP_ABORTOP(tdvp, tcnp); - if(tdvp == tvp) - vrele(tdvp); - else - vput(tdvp); - if(tvp) - vput(tvp); - VOP_ABORTOP(fdvp, fcnp); - vrele(fdvp); - vrele(fvp); - return error; + abort: + VOP_ABORTOP(tdvp, tcnp); + if(tdvp == tvp) + vrele(tdvp); + else + vput(tdvp); + if(tvp) + vput(tvp); + VOP_ABORTOP(fdvp, fcnp); + vrele(fdvp); + vrele(fvp); + + return error; } static int xfs_mkdir(void *vap) { - struct vop_mkdir_args *ap = vap; + struct vop_mkdir_args *ap = vap; + + struct xfs *xfsp = XFS_FROM_VNODE(ap->a_dvp); + struct xfs_node *xn = VNODE_TO_XNODE(ap->a_dvp); + struct componentname *cnp = ap->a_cnp; + int error = 0; + + XFSDEB(XDEBVNOPS, ("xfs_mkdir\n")); + { + struct xfs_message_mkdir msg; + + msg.header.opcode = XFS_MSG_MKDIR; + msg.parent_handle = xn->handle; + strncpy(msg.name, cnp->cn_nameptr, 256); + vattr2xfs_attr(ap->a_vap, &msg.attr); + if (cnp->cn_cred != NOCRED) { + msg.cred.uid = cnp->cn_cred->cr_uid; + msg.cred.pag = xfs_get_pag(cnp->cn_cred); + } else { + msg.cred.uid = 0; + msg.cred.pag = XFS_ANONYMOUSID; + } + + error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); + if (error == 0) + error = ((struct xfs_message_wakeup *) &msg)->error; + } + + if (error == 0) { + error = do_actual_lookup(ap->a_dvp, cnp, ap->a_vpp); + } + + if (error != 0 || (cnp->cn_flags & SAVESTART) == 0) + free(cnp->cn_pnbuf, M_NAMEI); + + vput(ap->a_dvp); + return error; +} + +static int +xfs_rmdir(void *vap) +{ + struct vop_rmdir_args *ap = vap; - struct xfs *xfsp = XFS_FROM_VNODE(ap->a_dvp); - struct xfs_node *xn = VNODE_TO_XNODE(ap->a_dvp); - struct componentname *cnp = ap->a_cnp; - int error = 0; + struct vnode *dvp = ap->a_dvp; + struct vnode *vp = ap->a_vp; + struct xfs *xfsp = XFS_FROM_VNODE(dvp); + struct xfs_node *xn = VNODE_TO_XNODE(dvp); + struct componentname *cnp = ap->a_cnp; + struct xfs_message_rmdir msg; + int error; - XFSDEB(XDEBVNOPS, ("xfs_mkdir\n")); - { - struct xfs_message_mkdir msg; + XFSDEB(XDEBVNOPS, ("xfs_rmdir: (%s, %ld\n", + cnp->cn_nameptr, + cnp->cn_namelen)); - msg.header.opcode = XFS_MSG_MKDIR; + msg.header.opcode = XFS_MSG_RMDIR; msg.parent_handle = xn->handle; strncpy(msg.name, cnp->cn_nameptr, 256); - vattr2xfs_attr(ap->a_vap, &msg.attr); - if (cnp->cn_cred != NOCRED) { - msg.cred.uid = cnp->cn_cred->cr_uid; - msg.cred.pag = xfs_get_pag(cnp->cn_cred); - } else { - msg.cred.uid = 0; - msg.cred.pag = XFS_ANONYMOUSID; - } + msg.cred.uid = cnp->cn_cred->cr_uid; + msg.cred.pag = xfs_get_pag(cnp->cn_cred); + error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); if (error == 0) - error = ((struct xfs_message_wakeup *) & msg)->error; - } + error = ((struct xfs_message_wakeup *) &msg)->error; - if (error == 0) { - error = do_actual_lookup(ap->a_dvp, cnp, ap->a_vpp); - } + if (error == 0) + cache_purge(vp); - if (error != 0 || (cnp->cn_flags & SAVESTART) == 0) - free (cnp->cn_pnbuf, M_NAMEI); + /* + * sys_rmdir should not allow this to happen. + */ + if (dvp == vp) + vrele(vp); + else + vput(vp); + vput(dvp); - vput(ap->a_dvp); - return error; -} + if (error != 0 || (cnp->cn_flags & SAVESTART) == 0) + free(cnp->cn_pnbuf, M_NAMEI); -static int -xfs_rmdir(void *vap) -{ - struct vop_rmdir_args *ap = vap; - - struct vnode *dvp = ap->a_dvp; - struct vnode *vp = ap->a_vp; - struct xfs *xfsp = XFS_FROM_VNODE(dvp); - struct xfs_node *xn = VNODE_TO_XNODE(dvp); - struct componentname *cnp = ap->a_cnp; - struct xfs_message_rmdir msg; - int error; - - XFSDEB(XDEBVNOPS, ("xfs_rmdir: (%s, %ld\n", - cnp->cn_nameptr, - cnp->cn_namelen)); - - msg.header.opcode = XFS_MSG_RMDIR; - msg.parent_handle = xn->handle; - strncpy(msg.name, cnp->cn_nameptr, 256); - msg.cred.uid = cnp->cn_cred->cr_uid; - msg.cred.pag = xfs_get_pag(cnp->cn_cred); - error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); - if (error == 0) - error = ((struct xfs_message_wakeup *) &msg)->error; - - if (error == 0) - cache_purge(vp); - -#ifdef DIAGNOSTIC - /* - * sys_rmdir should not allow this to happen. - */ - if (dvp == vp) - panic("xfs_rmdir dvp == vp"); -#endif - - vput(vp); - vput(dvp); - - if (error != 0 || (cnp->cn_flags & SAVESTART) == 0) - free (cnp->cn_pnbuf, M_NAMEI); - - return error; + return error; } static int xfs_readdir(void *vap) { - struct vop_readdir_args *ap = vap; + struct vop_readdir_args *ap = vap; - int error = 0; + int error = 0; - XFSDEB(XDEBVNOPS, ("xfs_readdir\n")); + XFSDEB(XDEBVNOPS, ("xfs_readdir\n")); - error = xfs_data_valid(ap->a_vp, ap->a_cred, XFS_DATA_R); - if (error == 0) { - struct vnode *t = DATA_FROM_VNODE(ap->a_vp); + error = xfs_data_valid(ap->a_vp, ap->a_cred, XFS_DATA_R); + if (error == 0) { + struct vnode *t = DATA_FROM_VNODE(ap->a_vp); - vn_lock(t, LK_EXCLUSIVE | LK_RETRY, ap->a_uio->uio_procp); - error = VOP_READ(t, ap->a_uio, 0, ap->a_cred); - VOP_UNLOCK(t, 0, ap->a_uio->uio_procp); - } - return error; + vn_lock(t, LK_EXCLUSIVE | LK_RETRY, ap->a_uio->uio_procp); + error = VOP_READ(t, ap->a_uio, 0, ap->a_cred); + VOP_UNLOCK(t, 0, ap->a_uio->uio_procp); + } + + return error; } static int xfs_link(void *vap) { - struct vop_link_args *ap = vap; - - struct xfs *xfsp = XFS_FROM_VNODE(ap->a_dvp); - struct xfs_node *xn = VNODE_TO_XNODE(ap->a_dvp); - struct xfs_node *xn2 = VNODE_TO_XNODE(ap->a_vp); - struct componentname *cnp = ap->a_cnp; - struct xfs_message_link msg; - int error = 0; - - XFSDEB(XDEBVNOPS, ("xfs_link: (%s, %ld\n", - cnp->cn_nameptr, - cnp->cn_namelen)); - - msg.header.opcode = XFS_MSG_LINK; - msg.parent_handle = xn->handle; - msg.from_handle = xn2->handle; - strncpy(msg.name, cnp->cn_nameptr, 256); - msg.cred.uid = cnp->cn_cred->cr_uid; - msg.cred.pag = xfs_get_pag(cnp->cn_cred); - - error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); - if (error == 0) - error = ((struct xfs_message_wakeup *) & msg)->error; - - if (error != 0 || (cnp->cn_flags & SAVESTART) == 0) - free (cnp->cn_pnbuf, M_NAMEI); - - vput(ap->a_dvp); - return error; + struct vop_link_args *ap = vap; + + struct xfs *xfsp = XFS_FROM_VNODE(ap->a_dvp); + struct xfs_node *xn = VNODE_TO_XNODE(ap->a_dvp); + struct xfs_node *xn2 = VNODE_TO_XNODE(ap->a_vp); + struct componentname *cnp = ap->a_cnp; + struct xfs_message_link msg; + int error = 0; + + XFSDEB(XDEBVNOPS, ("xfs_link: (%s, %ld\n", + cnp->cn_nameptr, + cnp->cn_namelen)); + + msg.header.opcode = XFS_MSG_LINK; + msg.parent_handle = xn->handle; + msg.from_handle = xn2->handle; + strncpy(msg.name, cnp->cn_nameptr, 256); + msg.cred.uid = cnp->cn_cred->cr_uid; + msg.cred.pag = xfs_get_pag(cnp->cn_cred); + + error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); + if (error == 0) + error = ((struct xfs_message_wakeup *) &msg)->error; + + if (error != 0 || (cnp->cn_flags & SAVESTART) == 0) + free(cnp->cn_pnbuf, M_NAMEI); + + vput(ap->a_dvp); + return error; } static int xfs_symlink(void *vap) { - struct vop_symlink_args *ap = vap; - - struct xfs *xfsp = XFS_FROM_VNODE(ap->a_dvp); - struct xfs_node *xn = VNODE_TO_XNODE(ap->a_dvp); - struct componentname *cnp = ap->a_cnp; - struct xfs_message_symlink msg; - int error = 0; - - XFSDEB(XDEBVNOPS, ("xfs_symlink: (%s, %ld)\n", - cnp->cn_nameptr, - cnp->cn_namelen)); - - msg.header.opcode = XFS_MSG_SYMLINK; - msg.parent_handle = xn->handle; - strncpy(msg.name, cnp->cn_nameptr, 256); - vattr2xfs_attr(ap->a_vap, &msg.attr); - msg.cred.uid = cnp->cn_cred->cr_uid; - msg.cred.pag = xfs_get_pag(cnp->cn_cred); - strncpy (msg.contents, ap->a_target, sizeof(msg.contents)); - - error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); - if (error == 0) - error = ((struct xfs_message_wakeup *) & msg)->error; - - if (error == 0) { - error = do_actual_lookup(ap->a_dvp, cnp, ap->a_vpp); - } + struct vop_symlink_args *ap = vap; - if (error != 0 || (cnp->cn_flags & SAVESTART) == 0) - free (cnp->cn_pnbuf, M_NAMEI); + struct xfs *xfsp = XFS_FROM_VNODE(ap->a_dvp); + struct xfs_node *xn = VNODE_TO_XNODE(ap->a_dvp); + struct componentname *cnp = ap->a_cnp; + struct xfs_message_symlink msg; + int error = 0; + + XFSDEB(XDEBVNOPS, ("xfs_symlink: (%s, %ld)\n", + cnp->cn_nameptr, + cnp->cn_namelen)); + + msg.header.opcode = XFS_MSG_SYMLINK; + msg.parent_handle = xn->handle; + strncpy(msg.name, cnp->cn_nameptr, 256); + vattr2xfs_attr(ap->a_vap, &msg.attr); + msg.cred.uid = cnp->cn_cred->cr_uid; + msg.cred.pag = xfs_get_pag(cnp->cn_cred); + strncpy (msg.contents, ap->a_target, sizeof(msg.contents)); - vput(ap->a_dvp); - return error; + error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); + if (error == 0) + error = ((struct xfs_message_wakeup *) &msg)->error; + + if (error == 0) { + error = do_actual_lookup(ap->a_dvp, cnp, ap->a_vpp); + } + + if (error != 0 || (cnp->cn_flags & SAVESTART) == 0) + free(cnp->cn_pnbuf, M_NAMEI); + + vput(ap->a_dvp); + return error; } static int xfs_readlink(void *vap) { - struct vop_readlink_args *ap = vap; + struct vop_readlink_args *ap = vap; - int error = 0; + int error = 0; - XFSDEB(XDEBVNOPS, ("xfs_readlink\n")); + XFSDEB(XDEBVNOPS, ("xfs_readlink\n")); - error = xfs_data_valid(ap->a_vp, ap->a_cred, XFS_DATA_R); - if (error == 0) { - struct vnode *t = DATA_FROM_VNODE(ap->a_vp); + error = xfs_data_valid(ap->a_vp, ap->a_cred, XFS_DATA_R); + if (error == 0) { + struct vnode *t = DATA_FROM_VNODE(ap->a_vp); - vn_lock(t, LK_EXCLUSIVE | LK_RETRY, ap->a_uio->uio_procp); - error = VOP_READ(t, ap->a_uio, 0, ap->a_cred); - VOP_UNLOCK(t, 0, ap->a_uio->uio_procp); - } - return error; + vn_lock(t, LK_EXCLUSIVE | LK_RETRY, ap->a_uio->uio_procp); + error = VOP_READ(t, ap->a_uio, 0, ap->a_cred); + VOP_UNLOCK(t, 0, ap->a_uio->uio_procp); + } + + return error; } static int xfs_inactive(void *vap) { - struct vop_inactive_args *ap = vap; - struct xfs_message_inactivenode msg; - struct xfs *xfsp = XFS_FROM_VNODE(ap->a_vp); - struct xfs_node *xn = VNODE_TO_XNODE(ap->a_vp); + struct vop_inactive_args *ap = vap; + + struct xfs_message_inactivenode msg; + struct xfs *xfsp = XFS_FROM_VNODE(ap->a_vp); + struct xfs_node *xn = VNODE_TO_XNODE(ap->a_vp); - XFSDEB(XDEBVNOPS, ("xfs_inactive, 0x%x\n", (int) ap->a_vp)); + XFSDEB(XDEBVNOPS, ("xfs_inactive, 0x%x\n", (int) ap->a_vp)); - xn->tokens = 0; - msg.header.opcode = XFS_MSG_INACTIVENODE; - msg.handle = xn->handle; - msg.flag = XFS_NOREFS; - xfs_message_send(xfsp->fd, &msg.header, sizeof(msg)); + xn->tokens = 0; + msg.header.opcode = XFS_MSG_INACTIVENODE; + msg.handle = xn->handle; + msg.flag = XFS_NOREFS; + xfs_message_send(xfsp->fd, &msg.header, sizeof(msg)); - VOP_UNLOCK(ap->a_vp, 0, ap->a_p); + VOP_UNLOCK(ap->a_vp, 0, ap->a_p); - return 0; + return 0; } static int xfs_reclaim(void *vap) { - struct vop_reclaim_args *ap = vap; + struct vop_reclaim_args *ap = vap; - struct xfs_message_inactivenode msg; - struct xfs *xfsp = XFS_FROM_VNODE(ap->a_vp); - struct xfs_node *xn = VNODE_TO_XNODE(ap->a_vp); + struct xfs_message_inactivenode msg; + struct xfs *xfsp = XFS_FROM_VNODE(ap->a_vp); + struct xfs_node *xn = VNODE_TO_XNODE(ap->a_vp); - XFSDEB(XDEBVNOPS, ("xfs_reclaim, 0x%x\n", (int) ap->a_vp)); + XFSDEB(XDEBVNOPS, ("xfs_reclaim, 0x%x\n", (int) ap->a_vp)); - msg.header.opcode = XFS_MSG_INACTIVENODE; - msg.handle = xn->handle; - msg.flag = XFS_NOREFS | XFS_DELETE; - xfs_message_send(xfsp->fd, &msg.header, sizeof(msg)); + msg.header.opcode = XFS_MSG_INACTIVENODE; + msg.handle = xn->handle; + msg.flag = XFS_NOREFS | XFS_DELETE; + xfs_message_send(xfsp->fd, &msg.header, sizeof(msg)); - cache_purge(ap->a_vp); - free_xfs_node(xn); + cache_purge(ap->a_vp); + free_xfs_node(xn); - return 0; + return 0; } static int xfs_abortop (void *vap) { - struct vop_abortop_args *ap = vap; - struct componentname *cnp = ap->a_cnp; + struct vop_abortop_args *ap = vap; + struct componentname *cnp = ap->a_cnp; - XFSDEB(XDEBVNOPS, ("xfs_abortop\n")); + XFSDEB(XDEBVNOPS, ("xfs_abortop\n")); - if ((cnp->cn_flags & (HASBUF | SAVESTART)) == HASBUF) { - FREE(cnp->cn_pnbuf, M_NAMEI); - cnp->cn_pnbuf = NULL; - } - return 0; + if ((cnp->cn_flags & (HASBUF | SAVESTART)) == HASBUF) { + FREE(cnp->cn_pnbuf, M_NAMEI); + cnp->cn_pnbuf = NULL; + } + return 0; } static int xfs_notsupp(void *vap) { - return EOPNOTSUPP; + return EOPNOTSUPP; } int (**xfs_vnodeop_p) __P((void *)); static struct vnodeopv_entry_desc xfs_vnodeop_entries[] = { - {&vop_default_desc, vn_default_error}, - {&vop_lookup_desc, xfs_lookup}, - {&vop_open_desc, xfs_open}, - {&vop_fsync_desc, xfs_fsync}, - {&vop_close_desc, xfs_close}, - {&vop_read_desc, xfs_read}, - {&vop_write_desc, xfs_write}, - {&vop_mmap_desc, xfs_notsupp}, - {&vop_bmap_desc, xfs_notsupp}, - {&vop_ioctl_desc, xfs_notsupp}, - {&vop_select_desc, xfs_notsupp}, - {&vop_getattr_desc, xfs_getattr}, - {&vop_setattr_desc, xfs_setattr}, - {&vop_access_desc, xfs_access}, - {&vop_create_desc, xfs_create}, - {&vop_remove_desc, xfs_remove}, - {&vop_link_desc, xfs_link}, - {&vop_rename_desc, xfs_rename}, - {&vop_mkdir_desc, xfs_mkdir}, - {&vop_rmdir_desc, xfs_rmdir}, - {&vop_readdir_desc, xfs_readdir}, - {&vop_symlink_desc, xfs_symlink}, - {&vop_readlink_desc, xfs_readlink}, - {&vop_inactive_desc, xfs_inactive}, - {&vop_reclaim_desc, xfs_reclaim}, - {&vop_lock_desc, vop_generic_lock}, - {&vop_unlock_desc, vop_generic_unlock}, - {&vop_abortop_desc, xfs_abortop}, - {(struct vnodeop_desc *) NULL, (int (*) __P((void *))) NULL} + {&vop_default_desc, vn_default_error}, + {&vop_lookup_desc, xfs_lookup}, + {&vop_open_desc, xfs_open}, + {&vop_fsync_desc, xfs_fsync}, + {&vop_close_desc, xfs_close}, + {&vop_read_desc, xfs_read}, + {&vop_write_desc, xfs_write}, + {&vop_mmap_desc, xfs_notsupp}, + {&vop_bmap_desc, xfs_notsupp}, + {&vop_ioctl_desc, xfs_notsupp}, + {&vop_select_desc, xfs_notsupp}, + {&vop_getattr_desc, xfs_getattr}, + {&vop_setattr_desc, xfs_setattr}, + {&vop_access_desc, xfs_access}, + {&vop_create_desc, xfs_create}, + {&vop_remove_desc, xfs_remove}, + {&vop_link_desc, xfs_link}, + {&vop_rename_desc, xfs_rename}, + {&vop_mkdir_desc, xfs_mkdir}, + {&vop_rmdir_desc, xfs_rmdir}, + {&vop_readdir_desc, xfs_readdir}, + {&vop_symlink_desc, xfs_symlink}, + {&vop_readlink_desc, xfs_readlink}, + {&vop_inactive_desc, xfs_inactive}, + {&vop_reclaim_desc, xfs_reclaim}, + {&vop_lock_desc, vop_generic_lock}, + {&vop_unlock_desc, vop_generic_unlock}, + {&vop_abortop_desc, xfs_abortop}, + {(struct vnodeop_desc *) NULL, (int (*) __P((void *))) NULL} }; struct vnodeopv_desc xfs_vnodeop_opv_desc = -{&xfs_vnodeop_p, xfs_vnodeop_entries}; + {&xfs_vnodeop_p, xfs_vnodeop_entries}; |