diff options
author | attilio <attilio@FreeBSD.org> | 2013-03-02 15:33:54 +0000 |
---|---|---|
committer | attilio <attilio@FreeBSD.org> | 2013-03-02 15:33:54 +0000 |
commit | 44df97db57f445ae083991d3b0923763985673d5 (patch) | |
tree | f2c251656791e363e72e4f525b14deaebd0f6c29 /sys/gnu/fs/xfs/FreeBSD | |
parent | 4b0353fc07e5e0a054a50bb98e473e42ae9c961d (diff) | |
download | FreeBSD-src-44df97db57f445ae083991d3b0923763985673d5.zip FreeBSD-src-44df97db57f445ae083991d3b0923763985673d5.tar.gz |
Garbage collect XFS bits which are now already completely disconnected
from the tree since few months.
This is not targeted for MFC.
Diffstat (limited to 'sys/gnu/fs/xfs/FreeBSD')
52 files changed, 0 insertions, 10701 deletions
diff --git a/sys/gnu/fs/xfs/FreeBSD/support/atomic.h b/sys/gnu/fs/xfs/FreeBSD/support/atomic.h deleted file mode 100644 index 618de8c..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/support/atomic.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef __XFS_SUPPORT_ATOMIC_H__ - -#include <sys/types.h> -#include <machine/atomic.h> - -typedef struct { - volatile unsigned int val; -} atomic_t; - -#define atomic_read(v) ((v)->val) -#define atomic_set(v, i) ((v)->val = (i)) - -#define atomic_add(i, v) atomic_add_int(&(v)->val, (i)) -#define atomic_inc(v) atomic_add_int(&(v)->val, 1) -#define atomic_dec(v) atomic_subtract_int(&(v)->val, 1) -#define atomic_sub(i, v) atomic_subtract_int(&(v)->val, (i)) -#define atomic_dec_and_test(v) (atomic_fetchadd_int(&(v)->val, -1) == 1) - -/* - * This is used for two variables in XFS, one of which is a debug trace - * buffer index. - */ - -static __inline__ int atomicIncWithWrap(volatile unsigned int *ip, int val) -{ - unsigned int oldval, newval; - - do { - oldval = *ip; - newval = (oldval + 1 >= val) ? 0 : oldval + 1; - } while (atomic_cmpset_rel_int(ip, oldval, newval) == 0); - - return oldval; -} - -#endif /* __XFS_SUPPORT_ATOMIC_H__ */ diff --git a/sys/gnu/fs/xfs/FreeBSD/support/debug.c b/sys/gnu/fs/xfs/FreeBSD/support/debug.c deleted file mode 100644 index cf2ef94..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/support/debug.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ - */ - - -#include <sys/param.h> -#include <sys/proc.h> -#include <sys/kernel.h> -#include <sys/systm.h> -#include <sys/sysctl.h> -#include <machine/stdarg.h> - -#include <support/debug.h> - -static SYSCTL_NODE(_debug, OID_AUTO, xfs, CTLFLAG_RD, 0, "XFS debug options"); - -static int verbosity = 10; -SYSCTL_INT(_debug_xfs, OID_AUTO, verbosity, CTLFLAG_RW, &verbosity, 0, ""); - -#ifdef DEBUG - -static int doass = 1; -SYSCTL_INT(_debug_xfs, OID_AUTO, assert, CTLFLAG_RW, &doass, 0, ""); - -void -assfail(char *a, char *f, int l) -{ - if (doass == 0) return; - panic("XFS assertion failed: %s, file: %s, line: %d\n", a, f, l); -} - -int -get_thread_id(void) -{ - return curthread->td_proc->p_pid; -} - -#endif - -void -cmn_err(register int level, char *fmt, ...) -{ - char *fp = fmt; - char message[256]; - va_list ap; - - if (verbosity < level) - return; - - va_start(ap, fmt); - if (*fmt == '!') fp++; - vsprintf(message, fp, ap); - printf("%s\n", message); - va_end(ap); -} - - -void -icmn_err(register int level, char *fmt, va_list ap) -{ - char message[256]; - - if (verbosity < level) - return; - - vsprintf(message, fmt, ap); - printf("cmn_err level %d %s\n",level, message); -} - diff --git a/sys/gnu/fs/xfs/FreeBSD/support/debug.h b/sys/gnu/fs/xfs/FreeBSD/support/debug.h deleted file mode 100644 index 816a717..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/support/debug.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ - */ -#ifndef __XFS_SUPPORT_DEBUG_H__ -#define __XFS_SUPPORT_DEBUG_H__ - -#include <machine/stdarg.h> - -#define CE_DEBUG 7 /* debug */ -#define CE_CONT 6 /* continuation */ -#define CE_NOTE 5 /* notice */ -#define CE_WARN 4 /* warning */ -#define CE_ALERT 1 /* alert */ -#define CE_PANIC 0 /* panic */ - -extern void icmn_err(int, char *, va_list); -extern void cmn_err(int, char *, ...); - -#define prdev(fmt,targ,args...) \ - printf("Device %s - " fmt "\n", XFS_BUFTARG_NAME(targ), ## args) - -#ifndef STATIC -# define STATIC static -#endif - -#if defined(INVARIANTS) -# ifndef DEBUG -# define DEBUG -# endif -#endif - -#if defined(DEBUG) -# ifdef lint -# define ASSERT(EX) ((void)0) /* avoid "constant in conditional" babble */ -# else -# define ASSERT(EX) ((EX)?((void)0):assfail(#EX, __FILE__, __LINE__)) -# endif /* lint */ -#else /* !DEBUG */ -# define ASSERT(x) ((void)0) -#endif /* !DEBUG */ - -#ifdef DEBUG -extern void assfail(char *, char *, int); -extern int get_thread_id(void); -#else -#define assfail(a, b, c) ((void)0) -#endif - -#define ASSERT_ALWAYS(EX) ((EX)?((void)0):assfail(#EX, __FILE__, __LINE__)) - -#endif /* __XFS_SUPPORT_DEBUG_H__ */ diff --git a/sys/gnu/fs/xfs/FreeBSD/support/kdb.c b/sys/gnu/fs/xfs/FreeBSD/support/kdb.c deleted file mode 100644 index b133dfe..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/support/kdb.c +++ /dev/null @@ -1,62 +0,0 @@ -#include <sys/param.h> -#include <sys/kernel.h> -#include <sys/systm.h> - -#include <machine/db_machdep.h> - -#include "opt_ddb.h" -#ifdef DDB -#include <ddb/ddb.h> -#endif - -#include <support/kdb.h> - -#ifdef DDB -DB_FUNC(xfs, xfs_ddb_cmd, db_cmd_table, CS_MORE, NULL) -{ - db_error("No commands registered.\n"); -} -#endif - -int -kdb_register(char *cmd, kdb_func_t func, char *usage, char *help, short minlen) -{ - return 0; -} - -int -kdb_unregister(char *cmd) -{ - return 0; -} - -int -kdbgetaddrarg(int argc, const char **argv, int *nextarg, - kdb_machreg_t *value, long *offset, char **name, struct pt_regs *regs) -{ - return 0; -} - -int -kdbnearsym(unsigned long addr, kdb_symtab_t *symtab) - -{ - return 0; -} - -void -kdb_printf(const char *fmt, ...) -{ -} - -int -kdb_getarea_size(void *res, unsigned long addr, size_t size) -{ - return 0; -} - -int -kdb_putarea_size(unsigned long addr, void *res, size_t size) -{ - return 0; -} diff --git a/sys/gnu/fs/xfs/FreeBSD/support/kdb.h b/sys/gnu/fs/xfs/FreeBSD/support/kdb.h deleted file mode 100644 index d85bd6d..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/support/kdb.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef __XFS_SUPPORT_KGDB_H__ -#define __XFS_SUPPORT_KGDB_H__ - -#define KDB_ARGCOUNT EINVAL - -struct pt_regs -{ - int dummy; -}; - -#define MODULE_AUTHOR(s) static char __module_author[] = s; -#define MODULE_DESCRIPTION(s) static char __module_description[] = s; -#define MODULE_LICENSE(s) static char __module_license[] = s - - -typedef int (*kdb_func_t)(int, const char **, const char **, struct pt_regs *); -typedef register_t kdb_machreg_t; - -/* - * Symbol table format. - */ -typedef struct __ksymtab { - unsigned long value; /* Address of symbol */ - const char *sym_name; /* Full symbol name, including any version */ - unsigned long sym_start; - unsigned long sym_end; -} kdb_symtab_t; - -extern int kdb_register(char *, kdb_func_t, char *, char *, short); -extern int kdb_unregister(char *); - -extern int kdbgetaddrarg(int, const char**, int*, kdb_machreg_t *, - long *, char **, struct pt_regs *); -extern int kdbnearsym(unsigned long, kdb_symtab_t *); -extern void kdb_printf(const char *,...) - __attribute__ ((format (printf, 1, 2))); - -extern int kdb_getarea_size(void *, unsigned long, size_t); -extern int kdb_putarea_size(unsigned long, void *, size_t); - -#define kdb_getarea(x,addr) kdb_getarea_size(&(x), addr, sizeof((x))) -#define kdb_putarea(addr,x) kdb_putarea_size(addr, &(x), sizeof((x))) - -#endif /* __XFS_SUPPORT_KGDB_H__ */ diff --git a/sys/gnu/fs/xfs/FreeBSD/support/kmem.c b/sys/gnu/fs/xfs/FreeBSD/support/kmem.c deleted file mode 100644 index c98e4bc..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/support/kmem.c +++ /dev/null @@ -1,3 +0,0 @@ -#include <support/kmem.h> - -MALLOC_DEFINE(M_XFS, "XFSALLOC", "XFS memory"); diff --git a/sys/gnu/fs/xfs/FreeBSD/support/kmem.h b/sys/gnu/fs/xfs/FreeBSD/support/kmem.h deleted file mode 100644 index 4976008..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/support/kmem.h +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef __XFS_SUPPORT_KMEM_H__ -#define __XFS_SUPPORT_KMEM_H__ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/malloc.h> -#include <sys/kernel.h> -#include <sys/lock.h> -#include <sys/mutex.h> -#include <vm/uma.h> - -typedef unsigned long xfs_pflags_t; - -#define PFLAGS_TEST_NOIO() 0 -#define PFLAGS_TEST_FSTRANS() 0 - -#define PFLAGS_SET_NOIO(STATEP) do { \ -} while (0) - -#define PFLAGS_SET_FSTRANS(STATEP) do { \ -} while (0) - -#define PFLAGS_RESTORE(STATEP) do { \ -} while (0) - -#define PFLAGS_DUP(OSTATEP, NSTATEP) do { \ -} while (0) - -/* Restore the PF_FSTRANS state to what was saved in STATEP */ -#define PFLAGS_RESTORE_FSTRANS(STATEP) do { \ -} while (0) - -/* - * memory management routines - */ -#define KM_SLEEP M_WAITOK -#define KM_NOSLEEP M_NOWAIT -#define KM_NOFS M_WAITOK -#define KM_MAYFAIL 0 - -#define kmem_zone uma_zone - -typedef struct uma_zone kmem_zone_t; -typedef struct uma_zone xfs_zone_t; - - -#define KM_ZONE_HWALIGN 0 -#define KM_ZONE_RECLAIM 0 -#define KM_ZONE_SPREAD 0 - -#define kmem_zone_init(len, name) \ - uma_zcreate(name, len, NULL, NULL, NULL, NULL, 0, 0) - -static inline kmem_zone_t * -kmem_zone_init_flags(int size, char *zone_name, unsigned long flags, - void (*construct)(void *, kmem_zone_t *, unsigned long)) -{ - return uma_zcreate(zone_name, size, NULL, NULL, NULL, NULL, 0, 0); -} - -#define kmem_zone_free(zone, ptr) \ - uma_zfree(zone, ptr) - -static inline void -kmem_zone_destroy(kmem_zone_t *zone) -{ - uma_zdestroy(zone); -} - -#define kmem_zone_alloc(zone, flg) \ - uma_zalloc(zone, flg) -#define kmem_zone_zalloc(zone, flg) \ - uma_zalloc(zone, (flg) | M_ZERO) - -#define kmem_alloc(len, flg) \ - malloc(len, M_XFS, flg) -#define kmem_zalloc(len, flg) \ - malloc(len, M_XFS, (flg) | M_ZERO) -#define kmem_free(ptr, size) \ - free(ptr, M_XFS) -#define kmem_realloc(ptr, nsize, osize, flg) \ - realloc(ptr, nsize, M_XFS, flg) - -MALLOC_DECLARE(M_XFS); - -#endif /* __XFS_SUPPORT_KMEM_H__ */ diff --git a/sys/gnu/fs/xfs/FreeBSD/support/ktrace.c b/sys/gnu/fs/xfs/FreeBSD/support/ktrace.c deleted file mode 100644 index 45a42bf..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/support/ktrace.c +++ /dev/null @@ -1,334 +0,0 @@ -/* - * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include <xfs.h> - -static kmem_zone_t *ktrace_hdr_zone; -static kmem_zone_t *ktrace_ent_zone; -static int ktrace_zentries; -static struct mtx wrap_lock; - -void -ktrace_init(int zentries) -{ - ktrace_zentries = zentries; - - ktrace_hdr_zone = kmem_zone_init(sizeof(ktrace_t), - "ktrace_hdr"); - ASSERT(ktrace_hdr_zone); - - ktrace_ent_zone = kmem_zone_init(ktrace_zentries - * sizeof(ktrace_entry_t), - "ktrace_ent"); - ASSERT(ktrace_ent_zone); - - mtx_init(&wrap_lock, "xfsktr", NULL, MTX_DEF); -} - -void -ktrace_uninit(void) -{ - kmem_zone_destroy(ktrace_hdr_zone); - kmem_zone_destroy(ktrace_ent_zone); - - mtx_destroy(&wrap_lock); -} - -/* - * ktrace_alloc() - * - * Allocate a ktrace header and enough buffering for the given - * number of entries. - */ -ktrace_t * -ktrace_alloc(int nentries, int sleep) -{ - ktrace_t *ktp; - ktrace_entry_t *ktep; - - ktp = (ktrace_t*)kmem_zone_alloc(ktrace_hdr_zone, sleep); - - if (ktp == (ktrace_t*)NULL) { - /* - * KM_SLEEP callers don't expect failure. - */ - if (sleep & KM_SLEEP) - panic("ktrace_alloc: NULL memory on KM_SLEEP request!"); - - return NULL; - } - - /* - * Special treatment for buffers with the ktrace_zentries entries - */ - if (nentries == ktrace_zentries) { - ktep = (ktrace_entry_t*)kmem_zone_zalloc(ktrace_ent_zone, - sleep); - } else { - ktep = (ktrace_entry_t*)kmem_zalloc((nentries * sizeof(*ktep)), - sleep); - } - - if (ktep == NULL) { - /* - * KM_SLEEP callers don't expect failure. - */ - if (sleep & KM_SLEEP) - panic("ktrace_alloc: NULL memory on KM_SLEEP request!"); - - kmem_free(ktp, sizeof(*ktp)); - - return NULL; - } - - spinlock_init(&(ktp->kt_lock), "kt_lock"); - - ktp->kt_entries = ktep; - ktp->kt_nentries = nentries; - ktp->kt_index = 0; - ktp->kt_rollover = 0; - return ktp; -} - - -/* - * ktrace_free() - * - * Free up the ktrace header and buffer. It is up to the caller - * to ensure that no-one is referencing it. - */ -void -ktrace_free(ktrace_t *ktp) -{ - int entries_size; - - if (ktp == (ktrace_t *)NULL) - return; - - spinlock_destroy(&ktp->kt_lock); - - /* - * Special treatment for the Vnode trace buffer. - */ - if (ktp->kt_nentries == ktrace_zentries) { - kmem_zone_free(ktrace_ent_zone, ktp->kt_entries); - } else { - entries_size = (int)(ktp->kt_nentries * sizeof(ktrace_entry_t)); - - kmem_free(ktp->kt_entries, entries_size); - } - - kmem_zone_free(ktrace_hdr_zone, ktp); -} - - -/* - * Enter the given values into the "next" entry in the trace buffer. - * kt_index is always the index of the next entry to be filled. - */ -void -ktrace_enter( - ktrace_t *ktp, - void *val0, - void *val1, - void *val2, - void *val3, - void *val4, - void *val5, - void *val6, - void *val7, - void *val8, - void *val9, - void *val10, - void *val11, - void *val12, - void *val13, - void *val14, - void *val15) -{ - int index; - ktrace_entry_t *ktep; - - ASSERT(ktp != NULL); - - /* - * Grab an entry by pushing the index up to the next one. - */ - mtx_lock(&wrap_lock); - index = ktp->kt_index; - if (++ktp->kt_index == ktp->kt_nentries) - ktp->kt_index = 0; - mtx_unlock(&wrap_lock); - - if (!ktp->kt_rollover && index == ktp->kt_nentries - 1) - ktp->kt_rollover = 1; - - ASSERT((index >= 0) && (index < ktp->kt_nentries)); - - ktep = &(ktp->kt_entries[index]); - - ktep->val[0] = val0; - ktep->val[1] = val1; - ktep->val[2] = val2; - ktep->val[3] = val3; - ktep->val[4] = val4; - ktep->val[5] = val5; - ktep->val[6] = val6; - ktep->val[7] = val7; - ktep->val[8] = val8; - ktep->val[9] = val9; - ktep->val[10] = val10; - ktep->val[11] = val11; - ktep->val[12] = val12; - ktep->val[13] = val13; - ktep->val[14] = val14; - ktep->val[15] = val15; -} - -/* - * Return the number of entries in the trace buffer. - */ -int -ktrace_nentries( - ktrace_t *ktp) -{ - if (ktp == NULL) { - return 0; - } - - return (ktp->kt_rollover ? ktp->kt_nentries : ktp->kt_index); -} - -/* - * ktrace_first() - * - * This is used to find the start of the trace buffer. - * In conjunction with ktrace_next() it can be used to - * iterate through the entire trace buffer. This code does - * not do any locking because it is assumed that it is called - * from the debugger. - * - * The caller must pass in a pointer to a ktrace_snap - * structure in which we will keep some state used to - * iterate through the buffer. This state must not touched - * by any code outside of this module. - */ -ktrace_entry_t * -ktrace_first(ktrace_t *ktp, ktrace_snap_t *ktsp) -{ - ktrace_entry_t *ktep; - int index; - int nentries; - - if (ktp->kt_rollover) - index = ktp->kt_index; - else - index = 0; - - ktsp->ks_start = index; - ktep = &(ktp->kt_entries[index]); - - nentries = ktrace_nentries(ktp); - index++; - if (index < nentries) { - ktsp->ks_index = index; - } else { - ktsp->ks_index = 0; - if (index > nentries) - ktep = NULL; - } - return ktep; -} - -/* - * ktrace_next() - * - * This is used to iterate through the entries of the given - * trace buffer. The caller must pass in the ktrace_snap_t - * structure initialized by ktrace_first(). The return value - * will be either a pointer to the next ktrace_entry or NULL - * if all of the entries have been traversed. - */ -ktrace_entry_t * -ktrace_next( - ktrace_t *ktp, - ktrace_snap_t *ktsp) -{ - int index; - ktrace_entry_t *ktep; - - index = ktsp->ks_index; - if (index == ktsp->ks_start) { - ktep = NULL; - } else { - ktep = &ktp->kt_entries[index]; - } - - index++; - if (index == ktrace_nentries(ktp)) { - ktsp->ks_index = 0; - } else { - ktsp->ks_index = index; - } - - return ktep; -} - -/* - * ktrace_skip() - * - * Skip the next "count" entries and return the entry after that. - * Return NULL if this causes us to iterate past the beginning again. - */ -ktrace_entry_t * -ktrace_skip( - ktrace_t *ktp, - int count, - ktrace_snap_t *ktsp) -{ - int index; - int new_index; - ktrace_entry_t *ktep; - int nentries = ktrace_nentries(ktp); - - index = ktsp->ks_index; - new_index = index + count; - while (new_index >= nentries) { - new_index -= nentries; - } - if (index == ktsp->ks_start) { - /* - * We've iterated around to the start, so we're done. - */ - ktep = NULL; - } else if ((new_index < index) && (index < ktsp->ks_index)) { - /* - * We've skipped past the start again, so we're done. - */ - ktep = NULL; - ktsp->ks_index = ktsp->ks_start; - } else { - ktep = &(ktp->kt_entries[new_index]); - new_index++; - if (new_index == nentries) { - ktsp->ks_index = 0; - } else { - ktsp->ks_index = new_index; - } - } - return ktep; -} diff --git a/sys/gnu/fs/xfs/FreeBSD/support/ktrace.h b/sys/gnu/fs/xfs/FreeBSD/support/ktrace.h deleted file mode 100644 index b566ef8..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/support/ktrace.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ - */ -#ifndef __XFS_SUPPORT_KTRACE_H__ -#define __XFS_SUPPORT_KTRACE_H__ - -#include <support/spin.h> - -/* - * Trace buffer entry structure. - */ -typedef struct ktrace_entry { - void *val[16]; -} ktrace_entry_t; - -/* - * Trace buffer header structure. - */ -typedef struct ktrace { - lock_t kt_lock; /* mutex to guard counters */ - int kt_nentries; /* number of entries in trace buf */ - int kt_index; /* current index in entries */ - int kt_rollover; - ktrace_entry_t *kt_entries; /* buffer of entries */ -} ktrace_t; - -/* - * Trace buffer snapshot structure. - */ -typedef struct ktrace_snap { - int ks_start; /* kt_index at time of snap */ - int ks_index; /* current index */ -} ktrace_snap_t; - - -#ifdef CONFIG_XFS_TRACE - -extern void ktrace_init(int zentries); -extern void ktrace_uninit(void); - -extern ktrace_t *ktrace_alloc(int, int); -extern void ktrace_free(ktrace_t *); - -extern void ktrace_enter( - ktrace_t *, - void *, - void *, - void *, - void *, - void *, - void *, - void *, - void *, - void *, - void *, - void *, - void *, - void *, - void *, - void *, - void *); - -extern ktrace_entry_t *ktrace_first(ktrace_t *, ktrace_snap_t *); -extern int ktrace_nentries(ktrace_t *); -extern ktrace_entry_t *ktrace_next(ktrace_t *, ktrace_snap_t *); -extern ktrace_entry_t *ktrace_skip(ktrace_t *, int, ktrace_snap_t *); - -#else -#define ktrace_init(x) do { } while (0) -#define ktrace_uninit() do { } while (0) -#endif /* CONFIG_XFS_TRACE */ - -#endif /* __XFS_SUPPORT_KTRACE_H__ */ diff --git a/sys/gnu/fs/xfs/FreeBSD/support/move.h b/sys/gnu/fs/xfs/FreeBSD/support/move.h deleted file mode 100644 index 856ec03..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/support/move.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ - */ - -#ifndef __XFS_SUPPORT_MOVE_H__ -#define __XFS_SUPPORT_MOVE_H__ - -#include <sys/uio.h> - -typedef struct iovec iovec_t; -typedef struct uio uio_t; - -static __inline__ int -uio_read(void *buf, int howmuch, struct uio *uiop) -{ - uiop->uio_rw = UIO_READ; - return uiomove(buf,howmuch,uiop); -} - -#endif /* __XFS_SUPPORT_MOVE_H__ */ diff --git a/sys/gnu/fs/xfs/FreeBSD/support/mrlock.c b/sys/gnu/fs/xfs/FreeBSD/support/mrlock.c deleted file mode 100644 index 5955f99..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/support/mrlock.c +++ /dev/null @@ -1,14 +0,0 @@ -#include <sys/param.h> -#include <sys/pcpu.h> -#include <support/debug.h> -#include <support/mrlock.h> - -int -ismrlocked(mrlock_t *mrp, int type) -{ - - sx_assert(mrp, SX_LOCKED); - if (type == MR_UPDATE) - return sx_xlocked(mrp); - return 1; -} diff --git a/sys/gnu/fs/xfs/FreeBSD/support/mrlock.h b/sys/gnu/fs/xfs/FreeBSD/support/mrlock.h deleted file mode 100644 index b41efc5..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/support/mrlock.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef __XFS_SUPPORT_MRLOCK_H__ -#define __XFS_SUPPORT_MRLOCK_H__ - -#include <sys/types.h> -#include <sys/systm.h> -#include <sys/lock.h> -#include <sys/sx.h> - -/* - * Implement mrlocks on FreeBSD that work for XFS. - * Map mrlock functions to corresponding equivalents in - * sx. - */ -typedef struct sx mrlock_t; - -#define MR_ACCESS 1 -#define MR_UPDATE 2 - -/* - * Compatibility defines, not really used - */ -#define MRLOCK_BARRIER 0x1 -#define MRLOCK_ALLOW_EQUAL_PRI 0x8 - -#define mrlock_init(lock, type, name, seq) sx_init(lock, name) -#define mrtryaccess(lock) sx_try_slock(lock) -#define mrtryupdate(lock) sx_try_xlock(lock) -#define mraccess(lock) sx_slock(lock) -#define mrupdate(lock) sx_xlock(lock) -#define mrdemote(lock) sx_downgrade(lock) -#define mrunlock(lock) sx_unlock(lock) - -#define mrfree(lock) do { \ - if (sx_xlocked(lock)) \ - sx_xunlock(lock); \ - sx_destroy(lock); \ -} while (0) - -int ismrlocked(mrlock_t *mrp, int type); - -#endif /* __XFS_SUPPORT_MRLOCK_H__ */ diff --git a/sys/gnu/fs/xfs/FreeBSD/support/mutex.h b/sys/gnu/fs/xfs/FreeBSD/support/mutex.h deleted file mode 100644 index d9b89b3..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/support/mutex.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef __XFS_SUPPORT_MUTEX_H__ -#define __XFS_SUPPORT_MUTEX_H__ - -#include <sys/param.h> -#include <sys/lock.h> -#include <sys/mutex.h> -#include <sys/sx.h> - -/* - * Map the mutex'es from IRIX to FreeBSD. Irix holds mutexes across - * sleeps, so on FreeBSD we have a choice of sema, sx or lockmgr - * to use as a underlining implemenation. Go with sx always locked - * in exclusive mode for now as it gets all the benefits of witness - * checking. - */ -typedef struct sx mutex_t; - -#define mutex_init(lock, type, name) sx_init(lock, name) -#define mutex_lock(lock, num) sx_xlock(lock) -#define mutex_trylock(lock) sx_try_xlock(lock) -#define mutex_unlock(lock) sx_xunlock(lock) -#define mutex_destroy(lock) sx_destroy(lock) - -/* - * Type for mutex_init() - */ -#define MUTEX_DEFAULT 0 - -#endif /* __XFS_SUPPORT_MUTEX_H__ */ diff --git a/sys/gnu/fs/xfs/FreeBSD/support/rwlock.h b/sys/gnu/fs/xfs/FreeBSD/support/rwlock.h deleted file mode 100644 index bfbec23..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/support/rwlock.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef __XFS_SUPPORT_RWLOCK_H__ -#define __XFS_SUPPORT_RWLOCK_H__ - -#include <sys/param.h> -#include <sys/lock.h> -#include <sys/mutex.h> -#include <sys/sx.h> - -typedef struct sx rwlock_t; -typedef int wait_queue_head_t; - -#define rwlock_init(lock) sx_init(lock, "rwlock") -#define rwlock_destroy(lock) sx_destroy(lock) -#define read_lock(lock) sx_slock(lock) -#define read_unlock(lock) sx_sunlock(lock) -#define write_lock(lock) sx_xlock(lock) -#define write_trylock(lock) sx_try_xlock(lock) -#define write_unlock(lock) sx_xunlock(lock) -#define rwlock_trypromote(lock) sx_try_upgrade(lock) -#define rwlock_demote(lock) sx_downgrade(lock) - - -#endif /* __XFS_SUPPORT_RWLOCK_H__ */ diff --git a/sys/gnu/fs/xfs/FreeBSD/support/rwsem.h b/sys/gnu/fs/xfs/FreeBSD/support/rwsem.h deleted file mode 100644 index bb97232..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/support/rwsem.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef __XFS_SUPPORT_RWSEM_H__ -#define __XFS_SUPPORT_RWSEM_H__ - -#include <sys/param.h> -#include <sys/lock.h> -#include <sys/mutex.h> -#include <sys/sx.h> - -#define rw_semaphore sx - -#define init_rwsem(sem) sx_init(sem, "rwsem") -#define free_rwsem(sem) sx_destroy(sem) -#define down_read(sem) sx_slock(sem) -#define down_read_trylock(sem) sx_try_slock(sem) -#define down_write(sem) sx_xlock(sem) -#define down_write_trylock(sem) sx_try_xlock(sem) -#define up_read(sem) sx_sunlock(sem) -#define up_write(sem) sx_xunlock(sem) -#define downgrade_write(sem) sx_downgrade(sem) - -#endif /* __XFS_SUPPORT_RWSEM_H__ */ diff --git a/sys/gnu/fs/xfs/FreeBSD/support/sema.h b/sys/gnu/fs/xfs/FreeBSD/support/sema.h deleted file mode 100644 index db7795b..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/support/sema.h +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef __XFS_SUPPORT_SEMA_H__ -#define __XFS_SUPPORT_SEMA_H__ - -#include <sys/sema.h> - -/* - * sema_t structure just maps to struct sema in FreeBSD kernel. - */ - -typedef struct sema sema_t; - -#define init_sema(sp, val, c, d) sema_init(sp, val, c) -#define initnsema(sp, val, name) sema_init(sp, val, name) -#define psema(sp, b) sema_wait(sp) -#define vsema(sp) sema_post(sp) -#define valusema(sp) sema_value(sp) -#define freesema(sp) sema_destroy(sp) -#define cpsema(sp) sema_trywait(sp) - -#endif /* __XFS_SUPPORT_SEMA_H__ */ diff --git a/sys/gnu/fs/xfs/FreeBSD/support/spin.h b/sys/gnu/fs/xfs/FreeBSD/support/spin.h deleted file mode 100644 index e337e32..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/support/spin.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef __XFS_SUPPORT_SPIN_H__ -#define __XFS_SUPPORT_SPIN_H__ - -#include <sys/param.h> -#include <sys/types.h> -#include <sys/lock.h> -#include <sys/mutex.h> - -#define SPLDECL(s) register_t s - -/* - * Map the spinlocks from IRIX to FreeBSD - */ -#define spinlock_init(lock, name) mtx_init(lock, name, NULL, MTX_DEF) -#define spinlock_destroy(lock) mtx_destroy(lock) - -/* - * Map lock_t from IRIX to FreeBSD mutexes - */ -typedef struct mtx lock_t; - -#define nested_spinunlock(lock) mtx_unlock(lock) -#define nested_spinlock(lock) mtx_lock(lock) -#define nested_spintrylock(lock) mtx_trylock(lock) - -#define spin_lock(lock) mtx_lock(lock) -#define spin_unlock(lock) mtx_unlock(lock) - -#if LOCK_DEBUG > 0 -#define mutex_spinlock(lock) (spin_lock(lock),0) -#else -static __inline register_t -mutex_spinlock(lock_t *lock) { mtx_lock(lock); return 0; } -#endif - -#define mutex_spinunlock(lock, s) \ - do { \ - spin_unlock(lock); \ - if (s != 0) {} \ - } while (0) - -#endif /* __XFS_SUPPORT_SPIN_H__ */ diff --git a/sys/gnu/fs/xfs/FreeBSD/support/support.h b/sys/gnu/fs/xfs/FreeBSD/support/support.h deleted file mode 100644 index d7804fa..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/support/support.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ - */ -#ifndef __XFS_SUPPORT_H__ -#define __XFS_SUPPORT_H__ - -#include <support/types.h> -#include <support/arch.h> -#include <support/kmem.h> -#include <support/mrlock.h> -#include <support/spin.h> -#include <support/sv.h> -#include <support/ktrace.h> -#include <support/mutex.h> -#include <support/sema.h> -#include <support/atomic.h> -#include <support/debug.h> -#include <support/uuid.h> -#include <support/time.h> - -#endif /* __XFS_SUPPORT_H__ */ diff --git a/sys/gnu/fs/xfs/FreeBSD/support/sv.h b/sys/gnu/fs/xfs/FreeBSD/support/sv.h deleted file mode 100644 index 1a378d2..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/support/sv.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef __XFS_SUPPORT_SV_H__ -#define __XFS_SUPPORT_SV_H__ - -#include <sys/condvar.h> - -/* - * Synchronisation variables - * - * parameters "pri", "svf" and "rts" are not (yet?) implemented - * - */ - -typedef struct cv sv_t; - -#define init_sv(sv,type,name,flag) cv_init(sv, name) -#define sv_init(sv,flag,name) cv_init(sv, name) -/* sv_wait should exit with lock unlocked */ -#define sv_wait(sv, pri, lock, spl) cv_wait_unlock(sv, lock) -#define sv_wait_sig(sv, pri, lock, spl) cv_wait_sig_nolock(sv, lock) -#define sv_signal(sv) cv_signal(sv) -#define sv_broadcast(sv) cv_broadcast(sv) -#define sv_destroy(sv) cv_destroy(sv) - -#define SV_FIFO 0x0 /* sv_t is FIFO type */ -#define SV_LIFO 0x2 /* sv_t is LIFO type */ -#define SV_PRIO 0x4 /* sv_t is PRIO type */ -#define SV_KEYED 0x6 /* sv_t is KEYED type */ -#define SV_DEFAULT SV_FIFO - -#endif /* __XFS_SUPPORT_SV_H__ */ diff --git a/sys/gnu/fs/xfs/FreeBSD/support/time.h b/sys/gnu/fs/xfs/FreeBSD/support/time.h deleted file mode 100644 index 9b3a974..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/support/time.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ - */ -#ifndef __XFS_SUPPORT_TIME_H__ -#define __XFS_SUPPORT_TIME_H__ - -#define delay(ticks) DELAY(ticks) - -#endif /* __XFS_SUPPORT_TIME_H__ */ diff --git a/sys/gnu/fs/xfs/FreeBSD/support/uuid.c b/sys/gnu/fs/xfs/FreeBSD/support/uuid.c deleted file mode 100644 index 55344c0..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/support/uuid.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ - */ - -#include <xfs_config.h> -#include <xfs_compat.h> -#include <xfs_types.h> -#include <xfs_arch.h> - -#include <support/uuid.h> -#include <support/kmem.h> -#include <support/debug.h> -#include <support/mutex.h> - -static mutex_t uuid_monitor; -static int uuid_table_size; -static uuid_t *uuid_table; - -void -uuid_init(void) -{ - mutex_init(&uuid_monitor, MUTEX_DEFAULT, "uuid_monitor"); -} - -void -uuid_cleanup(void) -{ - mutex_destroy(&uuid_monitor); -} - -/* - * uuid_getnodeuniq - obtain the node unique fields of a UUID. - * - * This is not in any way a standard or condoned UUID function; - * it just something that's needed for user-level file handles. - */ -void -uuid_getnodeuniq(uuid_t *uuid, int fsid [2]) -{ - char *uu = (char *)uuid; - - /* on IRIX, this function assumes big-endian fields within - * the uuid, so we use INT_GET to get the same result on - * little-endian systems - */ - - fsid[0] = (INT_GET(*(u_int16_t*)(uu+8), ARCH_CONVERT) << 16) + - INT_GET(*(u_int16_t*)(uu+4), ARCH_CONVERT); - fsid[1] = INT_GET(*(u_int32_t*)(uu ), ARCH_CONVERT); -} - -void -uuid_create_nil(uuid_t *uuid) -{ - memset(uuid, 0, sizeof(*uuid)); -} - -int -uuid_is_nil(uuid_t *uuid) -{ - int i; - char *cp = (char *)uuid; - - if (uuid == NULL) - return 0; - /* implied check of version number here... */ - for (i = 0; i < sizeof *uuid; i++) - if (*cp++) return 0; /* not nil */ - return 1; /* is nil */ -} - -int -uuid_equal(uuid_t *uuid1, uuid_t *uuid2) -{ - return memcmp(uuid1, uuid2, sizeof(uuid_t)) ? 0 : 1; -} - -/* - * Given a 128-bit uuid, return a 64-bit value by adding the top and bottom - * 64-bit words. NOTE: This function can not be changed EVER. Although - * brain-dead, some applications depend on this 64-bit value remaining - * persistent. Specifically, DMI vendors store the value as a persistent - * filehandle. - */ -__uint64_t -uuid_hash64(uuid_t *uuid) -{ - __uint64_t *sp = (__uint64_t *)uuid; - - return sp[0] + sp[1]; -} - -int -uuid_table_insert(uuid_t *uuid) -{ - int i, hole; - - mutex_lock(&uuid_monitor, PVFS); - for (i = 0, hole = -1; i < uuid_table_size; i++) { - if (uuid_is_nil(&uuid_table[i])) { - hole = i; - continue; - } - if (uuid_equal(uuid, &uuid_table[i])) { - mutex_unlock(&uuid_monitor); - return 0; - } - } - if (hole < 0) { - uuid_table = kmem_realloc(uuid_table, - (uuid_table_size + 1) * sizeof(*uuid_table), - uuid_table_size * sizeof(*uuid_table), - KM_SLEEP); - hole = uuid_table_size++; - } - uuid_table[hole] = *uuid; - mutex_unlock(&uuid_monitor); - return 1; -} - -void -uuid_table_remove(uuid_t *uuid) -{ - int i; - - mutex_lock(&uuid_monitor, PVFS); - for (i = 0; i < uuid_table_size; i++) { - if (uuid_is_nil(&uuid_table[i])) - continue; - if (!uuid_equal(uuid, &uuid_table[i])) - continue; - uuid_create_nil(&uuid_table[i]); - break; - } - ASSERT(i < uuid_table_size); - mutex_unlock(&uuid_monitor); -} diff --git a/sys/gnu/fs/xfs/FreeBSD/support/uuid.h b/sys/gnu/fs/xfs/FreeBSD/support/uuid.h deleted file mode 100644 index d8f389a..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/support/uuid.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ - */ -#ifndef __XFS_SUPPORT_UUID_H__ -#define __XFS_SUPPORT_UUID_H__ - -void uuid_init(void); -void uuid_cleanup(void); -void uuid_create_nil(uuid_t *uuid); -int uuid_is_nil(uuid_t *uuid); -int uuid_equal(uuid_t *uuid1, uuid_t *uuid2); -void uuid_getnodeuniq(uuid_t *uuid, int fsid [2]); -__uint64_t uuid_hash64(uuid_t *uuid); -int uuid_table_insert(uuid_t *uuid); -void uuid_table_remove(uuid_t *uuid); - -#endif /* __XFS_SUPPORT_UUID_H__ */ diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_buf.c b/sys/gnu/fs/xfs/FreeBSD/xfs_buf.c deleted file mode 100644 index b1821a8..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_buf.c +++ /dev/null @@ -1,334 +0,0 @@ -/* - * Copyright (c) 2001,2005 Russell Cattelan - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. - * - * $FreeBSD$ - */ - -#include "xfs.h" -#include "xfs_types.h" -#include "xfs_inum.h" -#include "xfs_log.h" -#include "xfs_trans.h" -#include "xfs_sb.h" -#include "xfs_ag.h" -#include "xfs_dir.h" -#include "xfs_dir2.h" -#include "xfs_dmapi.h" -#include "xfs_mount.h" -#include "xfs_clnt.h" -#include "xfs_mountops.h" - -#include <geom/geom.h> -#include <geom/geom_vfs.h> - -xfs_buf_t * -xfs_buf_read_flags(xfs_buftarg_t *target, xfs_daddr_t blkno, size_t len, int flags) -{ - struct buf *bp; - KASSERT((target != NULL), ("got NULL buftarg_t")); - - if (bread(target->specvp, blkno, BBTOB(len), NOCRED, &bp)) { - printf("bread failed specvp %p blkno %jd BBTOB(len) %ld\n", - target->specvp, (intmax_t)blkno, (long)BBTOB(len)); - bp = NULL; - } - - /* not really sure what B_MANAGED really does for us - * maybe we should drop this and just stick with a locked buf - */ - - if (flags & B_MANAGED) - bp->b_flags |= B_MANAGED; - xfs_buf_set_target(bp, target); - return (bp); -} - -xfs_buf_t * -xfs_buf_get_flags(xfs_buftarg_t *target, xfs_daddr_t blkno, size_t len, int flags) -{ - struct buf *bp = NULL; - KASSERT((target != NULL), ("got NULL buftarg_t")); - bp = getblk(target->specvp, blkno, BBTOB(len), 0, 0, 0); - if (bp != NULL) - xfs_buf_set_target(bp, target); - return (bp); -} - -xfs_buf_t* -xfs_buf_get_empty(size_t size, xfs_buftarg_t *target) -{ - struct buf *bp; - - bp = geteblk(0, 0); - if (bp != NULL) { - bp->b_bufsize = size; - bp->b_bcount = size; - - BUF_ASSERT_HELD(bp); - - xfs_buf_set_target(bp, target); - } - return (bp); -} - -xfs_buf_t* -xfs_buf_get_noaddr(size_t len, xfs_buftarg_t *target) -{ - struct buf *bp; - if (len >= MAXPHYS) - return (NULL); - - bp = geteblk(len, 0); - if (bp != NULL) { - BUF_ASSERT_HELD(bp); - - xfs_buf_set_target(bp, target); - } - return (bp); -} - -void -xfs_buf_free(xfs_buf_t *bp) -{ - bp->b_flags |= B_INVAL; - BUF_KERNPROC(bp); /* ugly hack #1 */ - if (bp->b_kvasize == 0) { - bp->b_saveaddr = bp->b_kvabase; /* ugly hack #2 */ - bp->b_data = bp->b_saveaddr; - bp->b_bcount = 0; - bp->b_bufsize = 0; - } - brelse(bp); -} - -void -xfs_buf_readahead( - xfs_buftarg_t *target, - xfs_daddr_t ioff, - size_t isize, - xfs_buf_flags_t flags) -{ - daddr_t rablkno; - int rabsize; - - rablkno = ioff; - rabsize = BBTOB(isize); - breada(target->specvp, &rablkno, &rabsize, 1, NOCRED); -} - -void -xfs_buf_set_target(xfs_buf_t *bp, xfs_buftarg_t *targ) -{ - bp->b_bufobj = &targ->specvp->v_bufobj; - bp->b_caller1 = targ; -} - -xfs_buftarg_t * -xfs_buf_get_target(xfs_buf_t *bp) -{ - return (xfs_buftarg_t *)bp->b_caller1; -} - -int -XFS_bwrite(xfs_buf_t *bp) -{ - int error; - if (bp->b_vp == NULL) { - error = xfs_buf_iorequest(bp); - - if ((bp->b_flags & B_ASYNC) == 0) { - error = bufwait(bp); -#if 0 - if (BUF_LOCKRECURSED(bp)) - BUF_UNLOCK(bp); - else - brelse(bp); -#endif - brelse(bp); - } - return (error); - } - error = bwrite(bp); - return (error); -} - -void -xfs_buf_pin(xfs_buf_t *bp) -{ - bpin(bp); -} - -void -xfs_buf_unpin(xfs_buf_t *bp) -{ - bunpin(bp); -} - -int -xfs_buf_ispin(xfs_buf_t *bp) -{ - return bp->b_pin_count; -} - -#if 0 -void -xfs_buf_wait_unpin( - xfs_buf_t *bp) -{ - bunpin_wait(bp); -} -#endif - -/* - * Move data into or out of a buffer. - */ -void -xfs_buf_iomove( - xfs_buf_t *bp, /* buffer to process */ - size_t boff, /* starting buffer offset */ - size_t bsize, /* length to copy */ - caddr_t data, /* data address */ - xfs_buf_rw_t mode) /* read/write/zero flag */ -{ - - printf("xfs_buf_iomove NI\n"); -#ifdef RMC - size_t bend, cpoff, csize; - struct page *page; - - bend = boff + bsize; - while (boff < bend) { - page = bp->b_pages[xfs_buf_btoct(boff + bp->b_offset)]; - cpoff = xfs_buf_poff(boff + bp->b_offset); - csize = min_t(size_t, - PAGE_CACHE_SIZE-cpoff, bp->b_count_desired-boff); - - ASSERT(((csize + cpoff) <= PAGE_CACHE_SIZE)); - - switch (mode) { - case XBRW_ZERO: - memset(page_address(page) + cpoff, 0, csize); - break; - case XBRW_READ: - memcpy(data, page_address(page) + cpoff, csize); - break; - case XBRW_WRITE: - memcpy(page_address(page) + cpoff, data, csize); - } - - boff += csize; - data += csize; - } -#endif -} - -/* - * Handling of buffer targets (buftargs). - */ - -/* - * Wait for any bufs with callbacks that have been submitted but - * have not yet returned... walk the hash list for the target. - */ -void -xfs_wait_buftarg( - xfs_buftarg_t *bp) -{ - printf("xfs_wait_buftarg(%p) NI\n", bp); -} - -int -xfs_flush_buftarg( - xfs_buftarg_t *btp, - int wait) -{ - int error = 0; - - error = vinvalbuf(btp->specvp, V_SAVE | V_NORMAL, 0, 0); - return error; -} - -void -xfs_free_buftarg( - xfs_buftarg_t *btp, - int external) -{ - xfs_flush_buftarg(btp, /* wait */ 0); - kmem_free(btp, sizeof(*btp)); -} - -int -xfs_readonly_buftarg( - xfs_buftarg_t *btp) -{ - struct g_consumer *cp; - - KASSERT(btp->specvp->v_bufobj.bo_ops == &xfs_bo_ops, - ("Bogus xfs_buftarg_t pointer")); - cp = btp->specvp->v_bufobj.bo_private; - return (cp->acw == 0); -} - -#if 0 -void -xfs_relse_buftarg( - xfs_buftarg_t *btp) -{ - printf("xfs_relse_buftargNI %p\n",btp); -} -#endif - -unsigned int -xfs_getsize_buftarg( - xfs_buftarg_t *btp) -{ - struct g_consumer *cp; - cp = btp->specvp->v_bufobj.bo_private; - return (cp->provider->sectorsize); -} - -int -xfs_setsize_buftarg( - xfs_buftarg_t *btp, - unsigned int blocksize, - unsigned int sectorsize) -{ - printf("xfs_setsize_buftarg NI %p\n",btp); - return 0; -} - -xfs_buftarg_t * -xfs_alloc_buftarg( - struct vnode *bdev, - int external) -{ - xfs_buftarg_t *btp; - - btp = kmem_zalloc(sizeof(*btp), KM_SLEEP); - - btp->dev = bdev->v_rdev; - btp->specvp = bdev; - return btp; -} diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_buf.h b/sys/gnu/fs/xfs/FreeBSD/xfs_buf.h deleted file mode 100644 index 34e579d..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_buf.h +++ /dev/null @@ -1,348 +0,0 @@ -/* - * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ - */ -#ifndef __XFS_BUF_H__ -#define __XFS_BUF_H__ - -#include <sys/bio.h> -#include <sys/buf.h> - -struct xfs_buf; -struct xfs_mount; -struct vnode; -typedef struct buf xfs_buf_t; -typedef uint32_t xfs_buf_flags_t; -#define xfs_buf buf - -extern struct buf_ops xfs_bo_ops; - -typedef enum { - XBRW_READ = 1, /* transfer into target memory */ - XBRW_WRITE = 2, /* transfer from target memory */ - XBRW_ZERO = 3, /* Zero target memory */ -} xfs_buf_rw_t; - -/* Buffer Read and Write Routines */ -extern void xfs_buf_ioend(xfs_buf_t *, int); -extern void xfs_buf_ioerror(xfs_buf_t *, int); -extern int xfs_buf_iostart(xfs_buf_t *, xfs_buf_flags_t); -extern int xfs_buf_iorequest(xfs_buf_t *); -extern int xfs_buf_iowait(xfs_buf_t *); -extern void xfs_buf_iomove(xfs_buf_t *, size_t, size_t, xfs_caddr_t, xfs_buf_rw_t); - -/* Pinning Buffer Storage in Memory */ -extern void xfs_buf_pin(xfs_buf_t *); -extern void xfs_buf_unpin(xfs_buf_t *); -extern int xfs_buf_ispin(xfs_buf_t *); - - -typedef void (*xfs_buf_iodone_t)(struct xfs_buf *); /* call-back function on I/O completion */ -typedef void (*xfs_buf_relse_t)(struct xfs_buf *); /* call-back function on I/O completion */ -typedef int (*xfs_buf_bdstrat_t)(struct xfs_buf *); - -typedef struct xfs_buftarg { - /* this probaby redundant info, but stick with linux conventions for now */ - unsigned int bt_bsize; - unsigned int bt_sshift; - size_t bt_smask; - struct cdev *dev; - struct vnode *specvp; -} xfs_buftarg_t; - - -/* Finding and Reading Buffers */ -extern void xfs_buf_readahead(xfs_buftarg_t *, xfs_off_t, size_t, xfs_buf_flags_t); -/* Misc buffer rountines */ -extern int xfs_readonly_buftarg(xfs_buftarg_t *); - -/* These are just for xfs_syncsub... it sets an internal variable - * then passes it to VOP_FLUSH_PAGES or adds the flags to a newly gotten buf_t - */ -#define XBF_DONT_BLOCK 0 - -#define XFS_B_ASYNC B_ASYNC -#define XFS_B_DELWRI B_DELWRI -#define XFS_B_READ BIO_READ -#define XFS_B_WRITE BIO_WRITE - -#define XFS_B_STALE B_INVAL -#define XFS_BUF_LOCK 0 -#define XFS_BUF_TRYLOCK 0 -#define XFS_BUF_MAPPED 0 -#define BUF_BUSY 0 - -#define XBF_ORDERED 0 - - /* debugging routines might need this */ -#define XFS_BUF_BFLAGS(x) ((x)->b_flags) -#define XFS_BUF_ZEROFLAGS(x) ((x)->b_flags = 0) -#define XFS_BUF_STALE(x) ((x)->b_flags |= (XFS_B_STALE|B_NOCACHE)) -#define XFS_BUF_UNSTALE(x) ((x)->b_flags &= ~(XFS_B_STALE|B_NOCACHE)) -#define XFS_BUF_ISSTALE(x) ((x)->b_flags & (XFS_B_STALE|B_NOCACHE)) -#define XFS_BUF_SUPER_STALE(x) {(x)->b_flags |= (XFS_B_STALE|B_NOCACHE); \ - (x)->b_flags &= ~(XFS_B_DELWRI|B_CACHE);} - -#define XFS_BUF_MANAGE B_MANAGED -#define XFS_BUF_UNMANAGE(x) ((x)->b_flags &= ~B_MANAGED) - -#define XFS_BUF_DELAYWRITE(x) ((x)->b_flags |= XFS_B_DELWRI) -#define XFS_BUF_UNDELAYWRITE(x) ((x)->b_flags &= ~XFS_B_DELWRI) -#define XFS_BUF_ISDELAYWRITE(x) ((x)->b_flags & XFS_B_DELWRI) - -#define XFS_BUF_ERROR(x,no) xfs_buf_set_error((x), (no)) -#define XFS_BUF_GETERROR(x) xfs_buf_get_error(x) -#define XFS_BUF_ISERROR(x) (((x)->b_ioflags & BIO_ERROR) != 0) - -void static __inline__ -xfs_buf_set_error(struct buf *bp, int err) -{ - bp->b_ioflags |= BIO_ERROR; - bp->b_error = err; -} - -int static __inline__ -xfs_buf_get_error(struct buf *bp) -{ - return XFS_BUF_ISERROR(bp) ? (bp->b_error ? bp->b_error : EIO) : 0; -} - -#define XFS_BUF_DONE(x) ((x)->b_flags |= B_CACHE) -#define XFS_BUF_UNDONE(x) ((x)->b_flags &= ~B_CACHE) -#define XFS_BUF_ISDONE(x) ((x)->b_flags & B_CACHE) - -#define XFS_BUF_BUSY(x) ((x)->b_flags |= BUF_BUSY) -#define XFS_BUF_UNBUSY(x) ((x)->b_flags &= ~BUF_BUSY) -#define XFS_BUF_ISBUSY(x) (1) - -#define XFS_BUF_ASYNC(x) ((x)->b_flags |= B_ASYNC) -#define XFS_BUF_UNASYNC(x) ((x)->b_flags &= ~B_ASYNC) -#define XFS_BUF_ISASYNC(x) ((x)->b_flags & B_ASYNC) - -#define XFS_BUF_ORDERED(bp) ((bp)->b_flags |= XBF_ORDERED) -#define XFS_BUF_UNORDERED(bp) ((bp)->b_flags &= ~XBF_ORDERED) -#define XFS_BUF_ISORDERED(bp) ((bp)->b_flags & XBF_ORDERED) - -#define XFS_BUF_FLUSH(x) ((x)->b_flags |= B_00800000) -#define XFS_BUF_UNFLUSH(x) ((x)->b_flags &= ~B_00800000) -#define XFS_BUF_ISFLUSH(x) ((x)->b_flags & B_00800000) - -#define XFS_BUF_SHUT(x) printf("XFS_BUF_SHUT not implemented yet\n") -#define XFS_BUF_UNSHUT(x) printf("XFS_BUF_UNSHUT not implemented yet\n") -#define XFS_BUF_ISSHUT(x) (0) - -#define XFS_BUF_HOLD(x) ((void)0) -#define XFS_BUF_UNHOLD(x) ((void)0) - -#define XFS_BUF_READ(x) ((x)->b_iocmd = BIO_READ) -#define XFS_BUF_UNREAD(x) ((x)->b_iocmd = 0) -#define XFS_BUF_ISREAD(x) ((x)->b_iocmd == BIO_READ) - -#define XFS_BUF_WRITE(x) ((x)->b_iocmd = BIO_WRITE) -#define XFS_BUF_UNWRITE(x) ((x)->b_iocmd = 0) -#define XFS_BUF_ISWRITE(x) ((x)->b_iocmd == BIO_WRITE) - -#define XFS_BUF_ISUNINITIAL(x) (0) -#define XFS_BUF_UNUNINITIAL(x) (0) - -#define XFS_BUF_IODONE_FUNC(x) (x)->b_iodone -#define XFS_BUF_SET_IODONE_FUNC(x, f) (x)->b_iodone = (f) -#define XFS_BUF_CLR_IODONE_FUNC(x) (x)->b_iodone = NULL - -#define XFS_BUF_SET_BDSTRAT_FUNC(x, f) do { if(f != NULL) {} } while(0) -#define XFS_BUF_CLR_BDSTRAT_FUNC(x) ((void)0) - -#define XFS_BUF_BP_ISMAPPED(bp) (1) - -#define XFS_BUF_FSPRIVATE(buf, type) \ - ((type)(buf)->b_fsprivate1) -#define XFS_BUF_SET_FSPRIVATE(buf, value) \ - (buf)->b_fsprivate1 = (void *)(value) -#define XFS_BUF_FSPRIVATE2(buf, type) \ - ((type)(buf)->b_fsprivate2) -#define XFS_BUF_SET_FSPRIVATE2(buf, value) \ - (buf)->b_fsprivate2 = (void *)(value) -#define XFS_BUF_FSPRIVATE3(buf, type) \ - ((type)(buf)->b_fsprivate3) -#define XFS_BUF_SET_FSPRIVATE3(buf, value) \ - (buf)->b_fsprivate3 = (void *)(value) -#define XFS_BUF_SET_START(buf) \ - printf("XFS_BUF_SET_START: %s:%d\n", __FILE__, __LINE__) - -#define XFS_BUF_SET_BRELSE_FUNC(buf, value) \ - do { \ - printf("XFS_BUF_SET_BRELSE_FUNC: %s:%d\n", \ - __FILE__, __LINE__); \ - if (value != NULL ) {} \ - } while(0) - -#define XFS_BUF_PTR(bp) (xfs_caddr_t)((bp)->b_data) - -static __inline xfs_caddr_t -xfs_buf_offset(xfs_buf_t *bp, size_t offset) -{ - return XFS_BUF_PTR(bp) + offset; -} - -#define XFS_BUF_SET_PTR(bp, val, count) \ - do { \ - (bp)->b_data = (val); \ - (bp)->b_bcount = (count); \ - } while(0) - -#define XFS_BUF_ADDR(bp) ((bp)->b_blkno) -#define XFS_BUF_SET_ADDR(bp, blk) \ - ((bp)->b_blkno = blk) -#define XFS_BUF_OFFSET(bp) ((bp)->b_offset) -#define XFS_BUF_SET_OFFSET(bp, off) \ - ((bp)->b_offset = off) -#define XFS_BUF_COUNT(bp) ((bp)->b_bcount) -#define XFS_BUF_SET_COUNT(bp, cnt) \ - ((bp)->b_bcount = cnt) -#define XFS_BUF_SIZE(bp) ((bp)->b_bufsize) -#define XFS_BUF_SET_SIZE(bp, cnt) \ - ((bp)->b_bufsize = cnt) -#define XFS_BUF_SET_VTYPE_REF(bp, type, ref) -#define XFS_BUF_SET_VTYPE(bp, type) -#define XFS_BUF_SET_REF(bp, ref) - -#define XFS_BUF_VALUSEMA(bp) (BUF_ISLOCKED(bp) ? 0 : 1) -#define XFS_BUF_CPSEMA(bp) \ - (BUF_LOCK(bp, LK_EXCLUSIVE|LK_CANRECURSE | LK_SLEEPFAIL, NULL) == 0) - -#define XFS_BUF_PSEMA(bp,x) BUF_LOCK(bp, LK_EXCLUSIVE|LK_CANRECURSE, NULL) -#define XFS_BUF_VSEMA(bp) BUF_UNLOCK(bp) - -#define XFS_BUF_V_IODONESEMA(bp) bdone(bp) - -/* setup the buffer target from a buftarg structure */ -#define XFS_BUF_SET_TARGET(bp, target) \ - xfs_buf_set_target(bp, target) - -void xfs_buf_set_target(xfs_buf_t *, xfs_buftarg_t *); -xfs_buftarg_t *xfs_buf_get_target(xfs_buf_t *); - -/* return the dev_t being used */ -#define XFS_BUF_TARGET(bp) xfs_buf_get_target(bp) -#define XFS_BUFTARG_NAME(targp) devtoname((targp)->dev) - -#define XFS_BUF_SET_VTYPE_REF(bp, type, ref) -#define XFS_BUF_SET_VTYPE(bp, type) -#define XFS_BUF_SET_REF(bp, ref) - -#define XFS_BUF_ISPINNED(bp) xfs_buf_ispin(bp) - -xfs_buf_t * -xfs_buf_read_flags(xfs_buftarg_t *, xfs_daddr_t, size_t, int); - -#define xfs_buf_read(target, blkno, len, flags) \ - xfs_buf_read_flags(target, blkno, len, \ - XFS_BUF_LOCK | XFS_BUF_MAPPED) - -xfs_buf_t * -xfs_buf_get_flags(xfs_buftarg_t *, xfs_daddr_t, size_t, int); - -#define xfs_buf_get(target, blkno, len, flags) \ - xfs_buf_get_flags(target, blkno, len, \ - XFS_BUF_LOCK | XFS_BUF_MAPPED) - -/* the return value is never used ... why does linux define this functions this way? */ -static inline int xfs_bawrite(void *mp, xfs_buf_t *bp) -{ - /* Ditto for xfs_bawrite - bp->b_fspriv3 = mp; - bp->b_strat = xfs_bdstrat_cb; - xfs_buf_delwri_dequeue(bp); - return xfs_buf_iostart(bp, XBF_WRITE | XBF_ASYNC | _XBF_RUN_QUEUES); - */ - bawrite(bp); - return 0; -} - -static inline int xfs_bdwrite(void *mp, xfs_buf_t *bp) -{ - /* this is for io shutdown checking need to do this at some point RMC */ - /* probably should just change xfs to call a buf write function */ -#if 0 /* RMC */ - bp->b_strat = xfs_bdstrat_cb; - bp->b_fspriv3 = mp; - return xfs_buf_iostart(bp, XBF_DELWRI | XBF_ASYNC); -#endif - bdwrite(bp); - return 0; -} - -#define xfs_bpin(bp) xfs_buf_pin(bp) -#define xfs_bunpin(bp) xfs_buf_unpin(bp) - -#define xfs_buf_relse(bp) brelse(bp) -#define xfs_bp_mapin(bp) bp_mapin(bp) -#define xfs_xfsd_list_evict(x) _xfs_xfsd_list_evict(x) -#define xfs_buftrace(x,y) CTR2(KTR_BUF, "%s bp %p flags %X", bp, bp->b_flags) -#define xfs_biodone(bp) bufdone_finish(bp) - -#define xfs_incore(xfs_buftarg,blkno,len,lockit) \ - incore(&xfs_buftarg->specvp->v_bufobj, blkno); - -#define xfs_biomove(bp, off, len, data, rw) \ - xfs_buf_iomove((bp), (off), (len), (data), \ - ((rw) == XFS_B_WRITE) ? XBRW_WRITE : XBRW_READ) - -#define xfs_biozero(bp, off, len) \ - xfs_buf_iomove((bp), (off), (len), NULL, XBRW_ZERO) - -/* already a function xfs_bwrite... fix this */ -#define XFS_bdwrite(bp) bdwrite(bp) -#define xfs_iowait(bp) bufwait(bp) - -#define XFS_bdstrat(bp) xfs_buf_iorequest(bp) - -#define xfs_baread(target, rablkno, ralen) \ - xfs_buf_readahead((target), (rablkno), (ralen), XBF_DONT_BLOCK) - -struct xfs_mount; - -int XFS_bwrite(xfs_buf_t *bp); -xfs_buf_t* xfs_buf_get_empty(size_t, xfs_buftarg_t *targ); -xfs_buf_t* xfs_buf_get_noaddr(size_t, xfs_buftarg_t *targ); -void xfs_buf_free(xfs_buf_t *); - -extern void xfs_bwait_unpin(xfs_buf_t *bp); -extern xfs_buftarg_t *xfs_alloc_buftarg(struct vnode *, int); -extern void xfs_free_buftarg(xfs_buftarg_t *, int); -extern void xfs_wait_buftarg(xfs_buftarg_t *); -extern int xfs_setsize_buftarg(xfs_buftarg_t *, unsigned int, unsigned int); -extern unsigned int xfs_getsize_buftarg(struct xfs_buftarg *); -extern int xfs_flush_buftarg(xfs_buftarg_t *, int); - -#define xfs_binval(buftarg) xfs_flush_buftarg(buftarg, 1) -#define XFS_bflush(buftarg) xfs_flush_buftarg(buftarg, 1) - -#endif diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_compat.h b/sys/gnu/fs/xfs/FreeBSD/xfs_compat.h deleted file mode 100644 index 55a03c9..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_compat.h +++ /dev/null @@ -1,173 +0,0 @@ -#ifndef __XFS_COMPAT_H__ -#define __XFS_COMPAT_H__ - -#include <sys/param.h> -#include <sys/libkern.h> -#include <sys/limits.h> -#include <sys/uuid.h> -#include <sys/conf.h> -#include <sys/sbuf.h> -#include <sys/stat.h> -#include <sys/ioccom.h> -#include <sys/fcntl.h> -#include <sys/dirent.h> -#include <sys/ktr.h> -#include <sys/kdb.h> - -#ifdef _KERNEL -#define __KERNEL__ -#endif - -#define printk printf - -#define MAJOR(x) major(x) -#define MINOR(x) minor(x) - -/* - * SYSV compatibility types missing in FreeBSD. - */ -typedef unsigned long ulong; -typedef unsigned int uint; -typedef unsigned short ushort; - -/* - * Additional type declarations for XFS. - */ -typedef signed char __s8; -typedef unsigned char __u8; -typedef signed short int __s16; -typedef unsigned short int __u16; -typedef signed int __s32; -typedef unsigned int __u32; -typedef signed long long int __s64; -typedef unsigned long long int __u64; - -/* linus now has sparse which expects big endian or little endian */ -typedef __u16 __be16; -typedef __u32 __be32; -typedef __u64 __be64; - -/* - * Linux types with direct FreeBSD conterparts - */ -typedef off_t loff_t; -typedef struct timespec timespec_t; -typedef struct uuid uuid_t; -typedef struct fid fid_t; -typedef dev_t os_dev_t; - -/* - * Linux block devices are device vnodes in FreeBSD. - */ -#define block_device vnode - -/* - * Get the current CPU ID. - */ -#define smp_processor_id() PCPU_GET(cpuid) - -/* - * FreeBSD does not have BITS_PER_LONG defined. - */ -#if defined(LONG_BIT) -#define BITS_PER_LONG LONG_BIT -#elif defined(__i386__) -#define BITS_PER_LONG 32 -#endif - -#define rol32(x, y) (((x)<<(y))|((x)>>(32-(y)))) -/* - * boolean_t is enum on Linux, int on FreeBSD. - * Provide value defines. - */ -#define B_FALSE 0 -#define B_TRUE 1 - -/* - * GCC 3.x static branch prediction hints - */ -#if __GNUC__ < 3 -#define __builtin_expect(x, expected_value) (x) -#endif - -#ifndef likely -#define likely(x) __builtin_expect((x), 1) -#endif - -#ifndef unlikely -#define unlikely(x) __builtin_expect((x), 0) -#endif - -/* - * ANSI and GCC extension keywords compatibity - */ -#ifndef inline -#define inline __inline__ -#endif - -#ifndef asm -#define asm __asm -#endif - -#ifndef typeof -#define typeof __typeof -#endif - -/* - * Miscellaneous limit constants - */ -#define MAX_LFS_FILESIZE 0x7fffffffffffffffLL - -/* - * Map simple functions to their FreeBSD kernel equivalents - */ -#ifndef copy_to_user -#define copy_to_user(dst, src, len) copyout((src), (dst), (len)) -#endif - -#ifndef copy_from_user -#define copy_from_user(dst, src, len) copyin((src), (dst), (len)) -#endif - -/* - * Map simple global vairables to FreeBSD kernel equivalents - */ -#if !defined(xfs_physmem) -#define xfs_physmem physmem -#endif - -#ifndef HZ -#define HZ hz -#endif - -/* - * These should be implemented properly for all architectures - * we want to support. - */ -#define get_unaligned(ptr) (*(ptr)) -#define put_unaligned(val, ptr) ((void)( *(ptr) = (val) )) - -/* - * Linux type-safe min/max macros. - */ -#define min_t(type,x,y) MIN((x),(y)) -#define max_t(type,x,y) MAX((x),(y)) - - -typedef struct mtx xfs_mutex_t; -/* - * Cedentials manipulation. - */ -#define current_fsuid(credp) (credp)->cr_uid -#define current_fsgid(credp) (credp)->cr_groups[0] - -#define PAGE_CACHE_SIZE PAGE_SIZE - -#define IS_ERR(err) (err) - -static inline unsigned long ffz(unsigned long val) -{ - return ffsl(~val); -} - -#endif /* __XFS_COMPAT_H__ */ diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_config.h b/sys/gnu/fs/xfs/FreeBSD/xfs_config.h deleted file mode 100644 index a115f54..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_config.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef __XFS_CONFIG_H__ -#define __XFS_CONFIG_H__ - -#define HAVE_FID 1 -/* - * Linux config variables, harcoded to values desirable for FreeBSD. - */ -#define CONFIG_SYSCTL 1 -#define CONFIG_LBD 1 -#define CONFIG_XFS_TRACE 0 - -/* - * Tracing. - */ -#if CONFIG_XFS_TRACE == 1 -#define XFS_ALLOC_TRACE 1 -#define XFS_ALLOC_TRACE 1 -#define XFS_ATTR_TRACE 1 -#define XFS_BLI_TRACE 1 -#define XFS_BMAP_TRACE 1 -#define XFS_BMBT_TRACE 1 -#define XFS_DIR_TRACE 1 -#define XFS_DIR2_TRACE 1 -#define XFS_DQUOT_TRACE 1 -#define XFS_ILOCK_TRACE 1 -#define XFS_LOG_TRACE 1 -#define XFS_RW_TRACE 1 -#endif - -/* - * XFS config defines. - */ -#define XFS_BIG_BLKNOS 1 -#define XFS_BIG_INUMS 0 - -#undef XFS_STATS_OFF - -#endif /* __XFS_CONFIG_H__ */ diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_cred.h b/sys/gnu/fs/xfs/FreeBSD/xfs_cred.h deleted file mode 100644 index bc59977..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_cred.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ - */ -#ifndef __XFS_CRED_H__ -#define __XFS_CRED_H__ - -#include <sys/ucred.h> -/* - * struct cred is struct ucred on FreeBSD - */ -typedef struct ucred cred_t; - -#define cred ucred - -#define capable(cap) (1) -#define capable_cred(cr, cap) (1) - -#endif /* __XFS_CRED_H__ */ diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_dmistubs.c b/sys/gnu/fs/xfs/FreeBSD/xfs_dmistubs.c deleted file mode 100644 index 8f0eda1..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_dmistubs.c +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ - */ - -#include "xfs.h" - -#include "xfs_types.h" -#include "xfs_inum.h" -#include "xfs_log.h" -#include "xfs_trans.h" -#include "xfs_sb.h" -#include "xfs_ag.h" -#include "xfs_dir.h" -#include "xfs_dir2.h" -#include "xfs_dmapi.h" -#include "xfs_mount.h" - -static int nopkg(void); - -static __inline int -nopkg() -{ - return (ENOSYS); -} - -int dmapi_init(void); -int -dmapi_init (void) -{ - return (0); -} - -void dmapi_uninit(void); -void -dmapi_uninit (void) -{ -} - -int dm_data_event(void); -int -dm_data_event (void) -{ - return nopkg(); -} - -int dm_namesp_event(void); -int -dm_namesp_event (void) -{ - return nopkg(); -} - -/* The following stubs are for routines needed for the X/Open - * version of DMAPI. - */ -int xfs_dm_mount(xfs_vfs_t *, xfs_vnode_t *, char *, char *); -int -xfs_dm_mount( - xfs_vfs_t *vfsp, - xfs_vnode_t *mvp, - char *dir_name, - char *fsname) -{ - return nopkg(); -} - -int -dm_send_destroy_event(bhv_desc_t *bdp, dm_right_t vp_right); -int -dm_send_destroy_event(bhv_desc_t *bdp, dm_right_t vp_right) -{ - return nopkg(); -} - -int -dm_send_mount_event(xfs_vfs_t *vfsp, dm_right_t vfsp_right, bhv_desc_t *bdp, - dm_right_t vp_right, bhv_desc_t *rootbdp, dm_right_t rootvp_right, - char *name1, char *name2); -int -dm_send_mount_event(xfs_vfs_t *vfsp, dm_right_t vfsp_right, bhv_desc_t *bdp, - dm_right_t vp_right, bhv_desc_t *rootbdp, dm_right_t rootvp_right, - char *name1, char *name2) -{ - return nopkg(); -} - - -int -dm_send_namesp_event(dm_eventtype_t event, bhv_desc_t *bdp1, - dm_right_t vp1_right, bhv_desc_t *bdp2, dm_right_t vp2_right, - char *name1, char *name2, mode_t mode, int retcode, int flags); -int -dm_send_namesp_event(dm_eventtype_t event, bhv_desc_t *bdp1, - dm_right_t vp1_right, bhv_desc_t *bdp2, dm_right_t vp2_right, - char *name1, char *name2, mode_t mode, int retcode, int flags) -{ - return nopkg(); -} - - -void -dm_send_unmount_event(xfs_vfs_t *vfsp, xfs_vnode_t *vp, dm_right_t vfsp_right, - mode_t mode, int retcode, int flags); -void -dm_send_unmount_event(xfs_vfs_t *vfsp, xfs_vnode_t *vp, dm_right_t vfsp_right, - mode_t mode, int retcode, int flags) -{ -} - - -int -dm_vp_to_handle (xfs_vnode_t *vp, xfs_handle_t *handlep); -int -dm_vp_to_handle (xfs_vnode_t *vp, xfs_handle_t *handlep) -{ - return nopkg(); -} diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_freebsd.h b/sys/gnu/fs/xfs/FreeBSD/xfs_freebsd.h deleted file mode 100644 index cc1d8df..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_freebsd.h +++ /dev/null @@ -1,350 +0,0 @@ -/* - * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ - */ -#ifndef __XFS_FREEBSD__ -#define __XFS_FREEBSD__ - -#include <xfs_config.h> -#include <xfs_compat.h> - -/* - * Some types are conditional depending on the target system. - * XFS_BIG_BLKNOS needs block layer disk addresses to be 64 bits. - * XFS_BIG_INUMS needs the VFS inode number to be 64 bits, as well - * as requiring XFS_BIG_BLKNOS to be set. - */ -#define XFS_BIG_BLKNOS 1 -#define XFS_BIG_INUMS 0 - -#include <xfs_types.h> -#include <xfs_arch.h> - -#include <support/atomic.h> -#include <support/kmem.h> -#include <support/mrlock.h> -#include <support/spin.h> -#include <support/sv.h> -#include <support/ktrace.h> -#include <support/mutex.h> -#include <support/rwsem.h> -#include <support/rwlock.h> -#include <support/sema.h> -#include <support/debug.h> -#include <support/move.h> -#include <support/uuid.h> -#include <support/time.h> - -#include <xfs_behavior.h> -#include <xfs_cred.h> -#include <xfs_vfs.h> -#include <xfs_vnode.h> -#include <xfs_stats.h> -#include <xfs_sysctl.h> -#include <xfs_iops.h> -#include <xfs_super.h> -#include <xfs_fs_subr.h> -#include <xfs_buf.h> -#include <xfs_frw.h> - -/* - * Feature macros (disable/enable) - */ -#undef HAVE_REFCACHE /* Do not use refcache. */ -#undef HAVE_SENDFILE /* sendfile(2) is available in FreeBSD. */ - -#ifndef EVMS_MAJOR -#define EVMS_MAJOR 117 -#endif - -#define restricted_chown xfs_params.restrict_chown.val -#define irix_sgid_inherit xfs_params.sgid_inherit.val -#define irix_symlink_mode xfs_params.symlink_mode.val -#define xfs_panic_mask xfs_params.panic_mask.val -#define xfs_error_level xfs_params.error_level.val -#define xfs_syncd_centisecs xfs_params.syncd_timer.val -#define xfs_probe_dmapi xfs_params.probe_dmapi.val -#define xfs_probe_ioops xfs_params.probe_ioops.val -#define xfs_probe_quota xfs_params.probe_quota.val -#define xfs_stats_clear xfs_params.stats_clear.val -#define xfs_inherit_sync xfs_params.inherit_sync.val -#define xfs_inherit_nodump xfs_params.inherit_nodump.val -#define xfs_inherit_noatime xfs_params.inherit_noatim.val -#define xfs_buf_timer_centisecs xfs_params.xfs_buf_timer.val -#define xfs_buf_age_centisecs xfs_params.xfs_buf_age.val -#define xfs_inherit_nosymlinks xfs_params.inherit_nosym.val -#define xfs_rotorstep xfs_params.rotorstep.val - -#define current_cpu() smp_processor_id() -#define current_pid() (curthread->td_proc->p_pid) - -#define NBPP PAGE_SIZE -#define DPPSHFT (PAGE_SHIFT - 9) -#define NDPP (1 << (PAGE_SHIFT - 9)) -#define dtop(DD) (((DD) + NDPP - 1) >> DPPSHFT) -#define dtopt(DD) ((DD) >> DPPSHFT) -#define dpoff(DD) ((DD) & (NDPP-1)) - -#define NBBY 8 /* number of bits per byte */ -#define NBPC PAGE_SIZE /* Number of bytes per click */ -#define BPCSHIFT PAGE_SHIFT /* LOG2(NBPC) if exact */ - -/* number of BB's per block device block */ -#define BLKDEV_BB BTOBB(BLKDEV_IOSIZE) - -/* bytes to clicks */ -#define btoct(x) ((__psunsigned_t)(x)>>BPCSHIFT) -#define btoc64(x) (((__uint64_t)(x)+(NBPC-1))>>BPCSHIFT) -#define btoct64(x) ((__uint64_t)(x)>>BPCSHIFT) -#define io_btoc(x) (((__psunsigned_t)(x)+(IO_NBPC-1))>>IO_BPCSHIFT) -#define io_btoct(x) ((__psunsigned_t)(x)>>IO_BPCSHIFT) - -/* off_t bytes to clicks */ -#define offtoc(x) (((__uint64_t)(x)+(NBPC-1))>>BPCSHIFT) -#define offtoct(x) ((xfs_off_t)(x)>>BPCSHIFT) - -/* clicks to off_t bytes */ -#define ctooff(x) ((xfs_off_t)(x)<<BPCSHIFT) - -/* clicks to bytes */ -#define btoct(x) ((__psunsigned_t)(x)>>BPCSHIFT) -#define ctob64(x) ((__uint64_t)(x)<<BPCSHIFT) -#define io_ctob(x) ((__psunsigned_t)(x)<<IO_BPCSHIFT) - -#ifndef CELL_CAPABLE -#define FSC_NOTIFY_NAME_CHANGED(vp) -#endif - -#ifndef ENOATTR -#define ENOATTR ENODATA /* Attribute not found */ -#endif - -/* Note: EWRONGFS never visible outside the kernel */ -#define EWRONGFS EINVAL /* Mount with wrong filesystem type */ - -/* - * XXX EFSCORRUPTED needs a real value in errno.h. asm-i386/errno.h won't - * return codes out of its known range in errno. - * XXX Also note: needs to be < 1000 and fairly unique on Linux (mustn't - * conflict with any code we use already or any code a driver may use) - * XXX Some options (currently we do #2): - * 1/ New error code ["Filesystem is corrupted", _after_ glibc updated] - * 2/ 990 ["Unknown error 990"] - * 3/ EUCLEAN ["Structure needs cleaning"] - * 4/ Convert EFSCORRUPTED to EIO [just prior to return into userspace] - */ -#define EFSCORRUPTED 990 /* Filesystem is corrupted */ - -#define SYNCHRONIZE() __compiler_membar() -#define __return_address __builtin_return_address(0) - -/* - * IRIX (BSD) quotactl makes use of separate commands for user/group, - * whereas on Linux the syscall encodes this information into the cmd - * field (see the QCMD macro in quota.h). These macros help keep the - * code portable - they are not visible from the syscall interface. - */ -#define Q_XSETGQLIM XQM_CMD(0x8) /* set groups disk limits */ -#define Q_XGETGQUOTA XQM_CMD(0x9) /* get groups disk limits */ - -/* IRIX uses a dynamic sizing algorithm (ndquot = 200 + numprocs*2) */ -/* we may well need to fine-tune this if it ever becomes an issue. */ -#define DQUOT_MAX_HEURISTIC 1024 /* NR_DQUOTS */ -#define ndquot DQUOT_MAX_HEURISTIC - -/* IRIX uses the current size of the name cache to guess a good value */ -/* - this isn't the same but is a good enough starting point for now. */ -#define DQUOT_HASH_HEURISTIC files_stat.nr_files - -/* IRIX inodes maintain the project ID also, zero this field on Linux */ -#define DEFAULT_PROJID 0 -#define dfltprid DEFAULT_PROJID - -#define FINVIS 0x0102 /* don't update timestamps - XFS */ - -#define howmany(x, y) (((x)+((y)-1))/(y)) -#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) - -#define xfs_sort(a,n,s,fn) qsort(a,n,s,fn) - - -static inline int xfs_itruncate_data(void *ip, xfs_off_t off) { - printf ("xfs_itruncate_data NI\n"); - return 0; -} - -/* - * Juggle IRIX device numbers - still used in ondisk structures - */ -#define XFS_DEV_BITSMAJOR 14 -#define XFS_DEV_BITSMINOR 18 -#define XFS_DEV_MAXMAJ 0x1ff -#define XFS_DEV_MAXMIN 0x3ffff -#define XFS_DEV_MAJOR(dev) ((int)(((unsigned)(dev)>>XFS_DEV_BITSMINOR) \ - & XFS_DEV_MAXMAJ)) -#define XFS_DEV_MINOR(dev) ((int)((dev)&XFS_DEV_MAXMIN)) -#define XFS_MKDEV(major,minor) ((xfs_dev_t)(((major)<<XFS_DEV_BITSMINOR) \ - | (minor&XFS_DEV_MAXMIN))) - -#define XFS_DEV_TO_KDEVT(dev) mk_kdev(XFS_DEV_MAJOR(dev),XFS_DEV_MINOR(dev)) - - -/* Produce a kernel stack trace */ - -static inline void xfs_stack_trace(void) -{ - kdb_backtrace(); -} - -#define xfs_statvfs_fsid(statp, mp) \ - ({ \ - (statp)->f_fsid.val[0] = /*dev2udev(mp->m_dev) */ 1; \ - (statp)->f_fsid.val[1] = 0; \ - }) - - -/* Move the kernel do_div definition off to one side */ - -#if defined __i386__ -/* For ia32 we need to pull some tricks to get past various versions - * of the compiler which do not like us using do_div in the middle - * of large functions. - */ -static inline __u32 xfs_do_div(void *a, __u32 b, int n) -{ - __u32 mod; - - switch (n) { - case 4: - mod = *(__u32 *)a % b; - *(__u32 *)a = *(__u32 *)a / b; - return mod; - case 8: - { - unsigned long __upper, __low, __high, __mod; - __u64 c = *(__u64 *)a; - __upper = __high = c >> 32; - __low = c; - if (__high) { - __upper = __high % (b); - __high = __high / (b); - } - asm("divl %2":"=a" (__low), "=d" (__mod):"rm" (b), "0" (__low), "1" (__upper)); - asm("":"=A" (c):"a" (__low),"d" (__high)); - *(__u64 *)a = c; - return __mod; - } - } - - /* NOTREACHED */ - return 0; -} - -/* Side effect free 64 bit mod operation */ -static inline __u32 xfs_do_mod(void *a, __u32 b, int n) -{ - switch (n) { - case 4: - return *(__u32 *)a % b; - case 8: - { - unsigned long __upper, __low, __high, __mod; - __u64 c = *(__u64 *)a; - __upper = __high = c >> 32; - __low = c; - if (__high) { - __upper = __high % (b); - __high = __high / (b); - } - asm("divl %2":"=a" (__low), "=d" (__mod):"rm" (b), "0" (__low), "1" (__upper)); - asm("":"=A" (c):"a" (__low),"d" (__high)); - return __mod; - } - } - - /* NOTREACHED */ - return 0; -} -#else - -#define do_div(n, base) ({\ - int __res; \ - __res = ((__u64)(n)) % (__u32)(base); \ - (n) = ((__u64)(n)) / (__u32)(base); \ - __res; }) - -static inline __u32 xfs_do_div(void *a, __u32 b, int n) -{ - __u32 mod; - - switch (n) { - case 4: - mod = *(__u32 *)a % b; - *(__u32 *)a = *(__u32 *)a / b; - return mod; - case 8: - mod = do_div(*(__u64 *)a, b); - return mod; - } - - /* NOTREACHED */ - return 0; -} - -/* Side effect free 64 bit mod operation */ -static inline __u32 xfs_do_mod(void *a, __u32 b, int n) -{ - switch (n) { - case 4: - return *(__u32 *)a % b; - case 8: - { - __u64 c = *(__u64 *)a; - return do_div(c, b); - } - } - - /* NOTREACHED */ - return 0; -} -#endif - -#undef do_div -#define do_div(a, b) xfs_do_div(&(a), (b), sizeof(a)) -#define do_mod(a, b) xfs_do_mod(&(a), (b), sizeof(a)) - -static inline __uint64_t roundup_64(__uint64_t x, __uint32_t y) -{ - x += y - 1; - do_div(x, y); - return(x * y); -} - -#endif /* __XFS_FREEBSD__ */ diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_freebsd_iget.c b/sys/gnu/fs/xfs/FreeBSD/xfs_freebsd_iget.c deleted file mode 100644 index e4e1e8d..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_freebsd_iget.c +++ /dev/null @@ -1,419 +0,0 @@ -/* - * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. - * Copyright (c) 2006 Russell Cattelan Digital Elves, Inc. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ - */ - -#include "xfs.h" - -#include "xfs_types.h" -#include "xfs_bit.h" -#include "xfs_inum.h" -#include "xfs_log.h" -#include "xfs_trans.h" -#include "xfs_sb.h" -#include "xfs_ag.h" -#include "xfs_dir.h" -#include "xfs_dir2.h" -#include "xfs_dmapi.h" -#include "xfs_mount.h" -#include "xfs_alloc_btree.h" -#include "xfs_bmap_btree.h" -#include "xfs_ialloc_btree.h" -#include "xfs_attr_sf.h" -#include "xfs_dir_sf.h" -#include "xfs_dir2_sf.h" -#include "xfs_dinode.h" -#include "xfs_inode.h" -#include "xfs_btree.h" -#include "xfs_ialloc.h" -#include "xfs_quota.h" -#include "xfs_utils.h" -#include "xfs_vnode.h" - -static int xfs_vn_allocate(xfs_mount_t *, xfs_inode_t *, struct xfs_vnode **); - -/* - * Look up an inode by number in the given file system. - * The inode is looked up in the hash table for the file system - * represented by the mount point parameter mp. Each bucket of - * the hash table is guarded by an individual semaphore. - * - * If the inode is found in the hash table, its corresponding vnode - * is obtained with a call to vn_get(). This call takes care of - * coordination with the reclamation of the inode and vnode. Note - * that the vmap structure is filled in while holding the hash lock. - * This gives us the state of the inode/vnode when we found it and - * is used for coordination in vn_get(). - * - * If it is not in core, read it in from the file system's device and - * add the inode into the hash table. - * - * The inode is locked according to the value of the lock_flags parameter. - * This flag parameter indicates how and if the inode's IO lock and inode lock - * should be taken. - * - * mp -- the mount point structure for the current file system. It points - * to the inode hash table. - * tp -- a pointer to the current transaction if there is one. This is - * simply passed through to the xfs_iread() call. - * ino -- the number of the inode desired. This is the unique identifier - * within the file system for the inode being requested. - * lock_flags -- flags indicating how to lock the inode. See the comment - * for xfs_ilock() for a list of valid values. - * bno -- the block number starting the buffer containing the inode, - * if known (as by bulkstat), else 0. - */ -int -xfs_iget( - xfs_mount_t *mp, - xfs_trans_t *tp, - xfs_ino_t ino, - uint flags, - uint lock_flags, - xfs_inode_t **ipp, - xfs_daddr_t bno) -{ - xfs_ihash_t *ih; - xfs_inode_t *ip; - xfs_inode_t *iq; - xfs_vnode_t *vp; - ulong version; - int error; - /* REFERENCED */ - int newnode; - xfs_chash_t *ch; - xfs_chashlist_t *chl, *chlnew; - vmap_t vmap; - SPLDECL(s); - - XFS_STATS_INC(xs_ig_attempts); - - ih = XFS_IHASH(mp, ino); - -again: - read_lock(&ih->ih_lock); - - for (ip = ih->ih_next; ip != NULL; ip = ip->i_next) { - if (ip->i_ino == ino) { - vp = XFS_ITOV(ip); - VMAP(vp, vmap); - /* - * Inode cache hit: if ip is not at the front of - * its hash chain, move it there now. - * Do this with the lock held for update, but - * do statistics after releasing the lock. - */ - if (ip->i_prevp != &ih->ih_next - && rwlock_trypromote(&ih->ih_lock)) { - - if ((iq = ip->i_next)) { - iq->i_prevp = ip->i_prevp; - } - *ip->i_prevp = iq; - iq = ih->ih_next; - iq->i_prevp = &ip->i_next; - ip->i_next = iq; - ip->i_prevp = &ih->ih_next; - ih->ih_next = ip; - write_unlock(&ih->ih_lock); - } else { - read_unlock(&ih->ih_lock); - } - - XFS_STATS_INC(xs_ig_found); - - /* - * Get a reference to the vnode/inode. - * vn_get() takes care of coordination with - * the file system inode release and reclaim - * functions. If it returns NULL, the inode - * has been reclaimed so just start the search - * over again. We probably won't find it, - * but we could be racing with another cpu - * looking for the same inode so we have to at - * least look. - */ - if (!(vp = vn_get(vp, &vmap))) { - XFS_STATS_INC(xs_ig_frecycle); - goto again; - } - - if (lock_flags != 0) { - ip->i_flags &= ~XFS_IRECLAIM; - xfs_ilock(ip, lock_flags); - } - - newnode = (ip->i_d.di_mode == 0); - if (newnode) { - xfs_iocore_inode_reinit(ip); - } - ip->i_flags &= ~XFS_ISTALE; - - vn_trace_exit(vp, "xfs_iget.found", - (inst_t *)__return_address); - goto return_ip; - } - } - - /* - * Inode cache miss: save the hash chain version stamp and unlock - * the chain, so we don't deadlock in vn_alloc. - */ - XFS_STATS_INC(xs_ig_missed); - - version = ih->ih_version; - - read_unlock(&ih->ih_lock); - - /* - * Read the disk inode attributes into a new inode structure and get - * a new vnode for it. This should also initialize i_ino and i_mount. - */ - error = xfs_iread(mp, tp, ino, &ip, bno); - if (error) { - return error; - } - - error = xfs_vn_allocate(mp, ip, &vp); - if (error) { - return error; - } - vn_trace_exit(vp, "xfs_iget.alloc", (inst_t *)__return_address); - - xfs_inode_lock_init(ip, vp); - xfs_iocore_inode_init(ip); - - if (lock_flags != 0) { - xfs_ilock(ip, lock_flags); - } - - /* - * Put ip on its hash chain, unless someone else hashed a duplicate - * after we released the hash lock. - */ - write_lock(&ih->ih_lock); - - if (ih->ih_version != version) { - for (iq = ih->ih_next; iq != NULL; iq = iq->i_next) { - if (iq->i_ino == ino) { - write_unlock(&ih->ih_lock); - xfs_idestroy(ip); - - XFS_STATS_INC(xs_ig_dup); - goto again; - } - } - } - - /* - * These values _must_ be set before releasing ihlock! - */ - ip->i_hash = ih; - if ((iq = ih->ih_next)) { - iq->i_prevp = &ip->i_next; - } - ip->i_next = iq; - ip->i_prevp = &ih->ih_next; - ih->ih_next = ip; - ip->i_udquot = ip->i_gdquot = NULL; - ih->ih_version++; - - write_unlock(&ih->ih_lock); - - /* - * put ip on its cluster's hash chain - */ - ASSERT(ip->i_chash == NULL && ip->i_cprev == NULL && - ip->i_cnext == NULL); - - chlnew = NULL; - ch = XFS_CHASH(mp, ip->i_blkno); - chlredo: - s = mutex_spinlock(&ch->ch_lock); - for (chl = ch->ch_list; chl != NULL; chl = chl->chl_next) { - if (chl->chl_blkno == ip->i_blkno) { - - /* insert this inode into the doubly-linked list - * where chl points */ - if ((iq = chl->chl_ip)) { - ip->i_cprev = iq->i_cprev; - iq->i_cprev->i_cnext = ip; - iq->i_cprev = ip; - ip->i_cnext = iq; - } else { - ip->i_cnext = ip; - ip->i_cprev = ip; - } - chl->chl_ip = ip; - ip->i_chash = chl; - break; - } - } - - /* no hash list found for this block; add a new hash list */ - if (chl == NULL) { - if (chlnew == NULL) { - mutex_spinunlock(&ch->ch_lock, s); - ASSERT(xfs_chashlist_zone != NULL); - chlnew = (xfs_chashlist_t *) - kmem_zone_alloc(xfs_chashlist_zone, - KM_SLEEP); - ASSERT(chlnew != NULL); - goto chlredo; - } else { - ip->i_cnext = ip; - ip->i_cprev = ip; - ip->i_chash = chlnew; - chlnew->chl_ip = ip; - chlnew->chl_blkno = ip->i_blkno; - chlnew->chl_next = ch->ch_list; - ch->ch_list = chlnew; - chlnew = NULL; - } - } else { - if (chlnew != NULL) { - kmem_zone_free(xfs_chashlist_zone, chlnew); - } - } - - mutex_spinunlock(&ch->ch_lock, s); - - /* - * Link ip to its mount and thread it on the mount's inode list. - */ - XFS_MOUNT_ILOCK(mp); - if ((iq = mp->m_inodes)) { - ASSERT(iq->i_mprev->i_mnext == iq); - ip->i_mprev = iq->i_mprev; - iq->i_mprev->i_mnext = ip; - iq->i_mprev = ip; - ip->i_mnext = iq; - } else { - ip->i_mnext = ip; - ip->i_mprev = ip; - } - mp->m_inodes = ip; - - XFS_MOUNT_IUNLOCK(mp); - - newnode = 1; - - return_ip: - ASSERT(ip->i_df.if_ext_max == - XFS_IFORK_DSIZE(ip) / sizeof(xfs_bmbt_rec_t)); - - ASSERT(((ip->i_d.di_flags & XFS_DIFLAG_REALTIME) != 0) == - ((ip->i_iocore.io_flags & XFS_IOCORE_RT) != 0)); - - *ipp = ip; - - /* - * If we have a real type for an on-disk inode, we can set ops(&unlock) - * now. If it's a new inode being created, xfs_ialloc will handle it. - */ - XVFS_INIT_VNODE(XFS_MTOVFS(mp), vp, XFS_ITOBHV(ip), 1); - - return 0; -} - -/* - * Special iput for brand-new inodes that are still locked - */ -void -xfs_iput_new(xfs_inode_t *ip, - uint lock_flags) -{ - xfs_vnode_t *vp = XFS_ITOV(ip); - - vn_trace_entry(vp, "xfs_iput_new", (inst_t *)__return_address); - - printf("xfs_iput_new: ip %p\n",ip); - - if ((ip->i_d.di_mode == 0)) { - ASSERT(!(ip->i_flags & XFS_IRECLAIMABLE)); - //vn_mark_bad(vp); - printf("xfs_iput_new: ip %p di_mode == 0\n",ip); - /* mabe call vgone here? RMC */ - } - if (lock_flags) - xfs_iunlock(ip, lock_flags); - - ASSERT_VOP_LOCKED(vp->v_vnode, "xfs_iput_new"); - vput(vp->v_vnode); -} - -extern struct vop_vector xfs_vnops; - -static int -xfs_vn_allocate(xfs_mount_t *mp, xfs_inode_t *ip, struct xfs_vnode **vpp) -{ - struct vnode *vp; - struct xfs_vnode *vdata; - int error; - - /* Use zone allocator here? */ - vdata = kmem_zalloc(sizeof(*vdata), KM_SLEEP); - - error = getnewvnode("xfs", XVFSTOMNT(XFS_MTOVFS(mp)), - &xfs_vnops, &vp); - if (error) { - kmem_free(vdata, sizeof(*vdata)); - return (error); - } - - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); - VN_LOCK_AREC(vp); - error = insmntque(vp, XVFSTOMNT(XFS_MTOVFS(mp))); - if (error != 0) { - kmem_free(vdata, sizeof(*vdata)); - return (error); - } - - vp->v_data = (void *)vdata; - vdata->v_number= 0; - vdata->v_inode = ip; - vdata->v_vfsp = XFS_MTOVFS(mp); - vdata->v_vnode = vp; - - vn_bhv_head_init(VN_BHV_HEAD(vdata), "vnode"); - - -#ifdef CONFIG_XFS_VNODE_TRACING - vp->v_trace = ktrace_alloc(VNODE_TRACE_SIZE, KM_SLEEP); -#endif /* CONFIG_XFS_VNODE_TRACING */ - - vn_trace_exit(vp, "vn_initialize", (inst_t *)__return_address); - - if (error == 0) - *vpp = vdata; - - return (error); -} diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_frw.c b/sys/gnu/fs/xfs/FreeBSD/xfs_frw.c deleted file mode 100644 index 557ef1a..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_frw.c +++ /dev/null @@ -1,891 +0,0 @@ -/* - * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include "xfs.h" -#include "xfs_fs.h" -#include "xfs_bit.h" -#include "xfs_log.h" -#include "xfs_inum.h" -#include "xfs_trans.h" -#include "xfs_sb.h" -#include "xfs_ag.h" -#include "xfs_dir.h" -#include "xfs_dir2.h" -#include "xfs_alloc.h" -#include "xfs_dmapi.h" -#include "xfs_quota.h" -#include "xfs_mount.h" -#include "xfs_bmap_btree.h" -#include "xfs_alloc_btree.h" -#include "xfs_ialloc_btree.h" -#include "xfs_dir_sf.h" -#include "xfs_dir2_sf.h" -#include "xfs_attr_sf.h" -#include "xfs_dinode.h" -#include "xfs_inode.h" -#include "xfs_bmap.h" -#include "xfs_btree.h" -#include "xfs_ialloc.h" -#include "xfs_rtalloc.h" -#include "xfs_error.h" -#include "xfs_itable.h" -#include "xfs_rw.h" -#include "xfs_acl.h" -#include "xfs_cap.h" -#include "xfs_mac.h" -#include "xfs_attr.h" -#include "xfs_inode_item.h" -#include "xfs_buf_item.h" -#include "xfs_utils.h" -#include "xfs_iomap.h" - -#if defined(XFS_RW_TRACE) -void -xfs_rw_enter_trace( - int tag, - xfs_iocore_t *io, - const char *buf, - size_t size, - loff_t offset, - int ioflags) -{ - xfs_inode_t *ip = XFS_IO_INODE(io); - - if (ip->i_rwtrace == NULL) - return; - ktrace_enter(ip->i_rwtrace, - (void *)(unsigned long)tag, - (void *)ip, - (void *)((unsigned long)((ip->i_d.di_size >> 32) & 0xffffffff)), - (void *)((unsigned long)(ip->i_d.di_size & 0xffffffff)), - (void *)(__psint_t)buf, - (void *)((unsigned long)size), - (void *)((unsigned long)((offset >> 32) & 0xffffffff)), - (void *)((unsigned long)(offset & 0xffffffff)), - (void *)((unsigned long)ioflags), - (void *)((unsigned long)((io->io_new_size >> 32) & 0xffffffff)), - (void *)((unsigned long)(io->io_new_size & 0xffffffff)), - (void *)NULL, - (void *)NULL, - (void *)NULL, - (void *)NULL, - (void *)NULL); -} - -void -xfs_inval_cached_trace( - xfs_iocore_t *io, - xfs_off_t offset, - xfs_off_t len, - xfs_off_t first, - xfs_off_t last) -{ - xfs_inode_t *ip = XFS_IO_INODE(io); - - if (ip->i_rwtrace == NULL) - return; - ktrace_enter(ip->i_rwtrace, - (void *)(__psint_t)XFS_INVAL_CACHED, - (void *)ip, - (void *)((unsigned long)((offset >> 32) & 0xffffffff)), - (void *)((unsigned long)(offset & 0xffffffff)), - (void *)((unsigned long)((len >> 32) & 0xffffffff)), - (void *)((unsigned long)(len & 0xffffffff)), - (void *)((unsigned long)((first >> 32) & 0xffffffff)), - (void *)((unsigned long)(first & 0xffffffff)), - (void *)((unsigned long)((last >> 32) & 0xffffffff)), - (void *)((unsigned long)(last & 0xffffffff)), - (void *)NULL, - (void *)NULL, - (void *)NULL, - (void *)NULL, - (void *)NULL, - (void *)NULL); -} -#endif - -/* - * xfs_iozero - * - * xfs_iozero clears the specified range of buffer supplied, - * and marks all the affected blocks as valid and modified. If - * an affected block is not allocated, it will be allocated. If - * an affected block is not completely overwritten, and is not - * valid before the operation, it will be read from disk before - * being partially zeroed. - */ -STATIC int -xfs_iozero( - xfs_vnode_t *vp, /* vnode */ - xfs_off_t pos, /* offset in file */ - size_t count, /* size of data to zero */ - xfs_off_t end_size) /* max file size to set */ -{ - int status; - status = 0; /* XXXKAN: */ -#ifdef XXXKAN - unsigned bytes; - struct page *page; - struct address_space *mapping; - char *kaddr; - - mapping = ip->i_mapping; - do { - unsigned long index, offset; - - offset = (pos & (PAGE_CACHE_SIZE -1)); /* Within page */ - index = pos >> PAGE_CACHE_SHIFT; - bytes = PAGE_CACHE_SIZE - offset; - if (bytes > count) - bytes = count; - - status = -ENOMEM; - page = grab_cache_page(mapping, index); - if (!page) - break; - - kaddr = kmap(page); - status = mapping->a_ops->prepare_write(NULL, page, offset, - offset + bytes); - if (status) { - goto unlock; - } - - memset((void *) (kaddr + offset), 0, bytes); - flush_dcache_page(page); - status = mapping->a_ops->commit_write(NULL, page, offset, - offset + bytes); - if (!status) { - pos += bytes; - count -= bytes; - if (pos > i_size_read(ip)) - i_size_write(ip, pos < end_size ? pos : end_size); - } - -unlock: - kunmap(page); - unlock_page(page); - page_cache_release(page); - if (status) - break; - } while (count); -#endif - return (-status); -} - -ssize_t /* bytes read, or (-) error */ -xfs_read( - bhv_desc_t *bdp, - uio_t *uio, - int ioflags, - cred_t *credp) -{ - ssize_t ret, size; - xfs_fsize_t n; - xfs_inode_t *ip; - xfs_mount_t *mp; - - ip = XFS_BHVTOI(bdp); - mp = ip->i_mount; - - XFS_STATS_INC(xs_read_calls); - - if (unlikely(ioflags & IO_ISDIRECT)) { - if (((__psint_t)buf & BBMASK) || - (uio->uio_offset & mp->m_blockmask) || - (uio->uio_resid & mp->m_blockmask)) { - if (uio->uio_offset >= ip->i_d.di_size) { - return (0); - } - return EINVAL; - } - } - - if (uio->uio_resid == 0) - return 0; - n = XFS_MAXIOFFSET(mp) - uio->uio_offset; - if (n <= 0) - return EFBIG; - - size = (n < uio->uio_resid)? n : uio->uio_resid; - - if (XFS_FORCED_SHUTDOWN(mp)) { - return EIO; - } - - xfs_ilock(ip, XFS_IOLOCK_SHARED); - -#ifdef XXX - if (DM_EVENT_ENABLED(BHV_TO_VNODE(bdp)->v_vfsp, ip, DM_EVENT_READ) && - !(ioflags & IO_INVIS)) { - int error; - vrwlock_t locktype = VRWLOCK_READ; - int dmflags = FILP_DELAY_FLAG(file) | DM_SEM_FLAG_RD(ioflags); - - error = XFS_SEND_DATA(mp, DM_EVENT_READ, BHV_TO_VNODE(bdp), - uio->uio_offset, size, dmflags, &locktype); - if (error) { - xfs_iunlock(ip, XFS_IOLOCK_SHARED); - return (error); - } - } -#endif - - ret = xfs_read_file(mp, ip, uio, ioflags); - - xfs_iunlock(ip, XFS_IOLOCK_SHARED); - - XFS_STATS_ADD(xs_read_bytes, ret); - - if (likely((ioflags & IO_INVIS) == 0)) { - xfs_ichgtime(ip, XFS_ICHGTIME_ACC); - } - - return ret; -} - -/* - * This routine is called to handle zeroing any space in the last - * block of the file that is beyond the EOF. We do this since the - * size is being increased without writing anything to that block - * and we don't want anyone to read the garbage on the disk. - */ -STATIC int /* error (positive) */ -xfs_zero_last_block( - xfs_vnode_t *vp, - xfs_iocore_t *io, - xfs_fsize_t isize, - xfs_fsize_t end_size) -{ - xfs_fileoff_t last_fsb; - xfs_mount_t *mp; - int nimaps; - int zero_offset; - int zero_len; - int error = 0; - xfs_bmbt_irec_t imap; - xfs_off_t loff; - - ASSERT(ismrlocked(io->io_lock, MR_UPDATE) != 0); - - mp = io->io_mount; - - zero_offset = XFS_B_FSB_OFFSET(mp, isize); - if (zero_offset == 0) { - /* - * There are no extra bytes in the last block on disk to - * zero, so return. - */ - return 0; - } - - last_fsb = XFS_B_TO_FSBT(mp, isize); - nimaps = 1; - error = XFS_BMAPI(mp, NULL, io, last_fsb, 1, 0, NULL, 0, &imap, - &nimaps, NULL, NULL); - if (error) { - return error; - } - ASSERT(nimaps > 0); - /* - * If the block underlying isize is just a hole, then there - * is nothing to zero. - */ - if (imap.br_startblock == HOLESTARTBLOCK) { - return 0; - } - /* - * Zero the part of the last block beyond the EOF, and write it - * out sync. We need to drop the ilock while we do this so we - * don't deadlock when the buffer cache calls back to us. - */ - XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL| XFS_EXTSIZE_RD); - loff = XFS_FSB_TO_B(mp, last_fsb); - - zero_len = mp->m_sb.sb_blocksize - zero_offset; - - error = xfs_iozero(vp, loff + zero_offset, zero_len, end_size); - - XFS_ILOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD); - ASSERT(error >= 0); - return error; -} - -/* - * Zero any on disk space between the current EOF and the new, - * larger EOF. This handles the normal case of zeroing the remainder - * of the last block in the file and the unusual case of zeroing blocks - * out beyond the size of the file. This second case only happens - * with fixed size extents and when the system crashes before the inode - * size was updated but after blocks were allocated. If fill is set, - * then any holes in the range are filled and zeroed. If not, the holes - * are left alone as holes. - */ - -int /* error (positive) */ -xfs_zero_eof( - xfs_vnode_t *vp, - xfs_iocore_t *io, - xfs_off_t offset, /* starting I/O offset */ - xfs_fsize_t isize, /* current inode size */ - xfs_fsize_t end_size) /* terminal inode size */ -{ - xfs_fileoff_t start_zero_fsb; - xfs_fileoff_t end_zero_fsb; - xfs_fileoff_t zero_count_fsb; - xfs_fileoff_t last_fsb; - xfs_extlen_t buf_len_fsb; - xfs_mount_t *mp; - int nimaps; - int error = 0; - xfs_bmbt_irec_t imap; - - ASSERT(ismrlocked(io->io_lock, MR_UPDATE)); - ASSERT(ismrlocked(io->io_iolock, MR_UPDATE)); - ASSERT(offset > isize); - - mp = io->io_mount; - - /* - * First handle zeroing the block on which isize resides. - * We only zero a part of that block so it is handled specially. - */ - error = xfs_zero_last_block(vp, io, isize, end_size); - if (error) { - ASSERT(ismrlocked(io->io_lock, MR_UPDATE)); - ASSERT(ismrlocked(io->io_iolock, MR_UPDATE)); - return error; - } - - /* - * Calculate the range between the new size and the old - * where blocks needing to be zeroed may exist. To get the - * block where the last byte in the file currently resides, - * we need to subtract one from the size and truncate back - * to a block boundary. We subtract 1 in case the size is - * exactly on a block boundary. - */ - last_fsb = isize ? XFS_B_TO_FSBT(mp, isize - 1) : (xfs_fileoff_t)-1; - start_zero_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)isize); - end_zero_fsb = XFS_B_TO_FSBT(mp, offset - 1); - ASSERT((xfs_sfiloff_t)last_fsb < (xfs_sfiloff_t)start_zero_fsb); - if (last_fsb == end_zero_fsb) { - /* - * The size was only incremented on its last block. - * We took care of that above, so just return. - */ - return 0; - } - - ASSERT(start_zero_fsb <= end_zero_fsb); - while (start_zero_fsb <= end_zero_fsb) { - nimaps = 1; - zero_count_fsb = end_zero_fsb - start_zero_fsb + 1; - error = XFS_BMAPI(mp, NULL, io, start_zero_fsb, zero_count_fsb, - 0, NULL, 0, &imap, &nimaps, NULL, NULL); - if (error) { - ASSERT(ismrlocked(io->io_lock, MR_UPDATE)); - ASSERT(ismrlocked(io->io_iolock, MR_UPDATE)); - return error; - } - ASSERT(nimaps > 0); - - if (imap.br_state == XFS_EXT_UNWRITTEN || - imap.br_startblock == HOLESTARTBLOCK) { - /* - * This loop handles initializing pages that were - * partially initialized by the code below this - * loop. It basically zeroes the part of the page - * that sits on a hole and sets the page as P_HOLE - * and calls remapf if it is a mapped file. - */ - start_zero_fsb = imap.br_startoff + imap.br_blockcount; - ASSERT(start_zero_fsb <= (end_zero_fsb + 1)); - continue; - } - - /* - * There are blocks in the range requested. - * Zero them a single write at a time. We actually - * don't zero the entire range returned if it is - * too big and simply loop around to get the rest. - * That is not the most efficient thing to do, but it - * is simple and this path should not be exercised often. - */ - buf_len_fsb = XFS_FILBLKS_MIN(imap.br_blockcount, - mp->m_writeio_blocks << 8); - /* - * Drop the inode lock while we're doing the I/O. - * We'll still have the iolock to protect us. - */ - XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD); - - error = xfs_iozero(vp, - XFS_FSB_TO_B(mp, start_zero_fsb), - XFS_FSB_TO_B(mp, buf_len_fsb), - end_size); - - if (error) { - goto out_lock; - } - - start_zero_fsb = imap.br_startoff + buf_len_fsb; - ASSERT(start_zero_fsb <= (end_zero_fsb + 1)); - - XFS_ILOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD); - } - - return 0; - -out_lock: - - XFS_ILOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD); - ASSERT(error >= 0); - return error; -} - -ssize_t /* bytes written, or (-) error */ -xfs_write( - bhv_desc_t *bdp, - uio_t *uio, - int ioflag, - cred_t *credp) -{ - xfs_inode_t *xip; - xfs_mount_t *mp; - ssize_t ret = 0; - int error = 0; - xfs_fsize_t isize, new_size; - xfs_fsize_t n, limit; - xfs_fsize_t size; - xfs_iocore_t *io; - xfs_vnode_t *vp; - int iolock; - //int eventsent = 0; - vrwlock_t locktype; - xfs_off_t offset_c; - xfs_off_t *offset; - xfs_off_t pos; - - XFS_STATS_INC(xs_write_calls); - - vp = BHV_TO_VNODE(bdp); - xip = XFS_BHVTOI(bdp); - - io = &xip->i_iocore; - mp = io->io_mount; - - if (XFS_FORCED_SHUTDOWN(xip->i_mount)) { - return EIO; - } - - size = uio->uio_resid; - pos = offset_c = uio->uio_offset; - offset = &offset_c; - - if (unlikely(ioflag & IO_ISDIRECT)) { - if (((__psint_t)buf & BBMASK) || - (*offset & mp->m_blockmask) || - (size & mp->m_blockmask)) { - return EINVAL; - } - iolock = XFS_IOLOCK_SHARED; - locktype = VRWLOCK_WRITE_DIRECT; - } else { - if (io->io_flags & XFS_IOCORE_RT) - return EINVAL; - iolock = XFS_IOLOCK_EXCL; - locktype = VRWLOCK_WRITE; - } - - iolock = XFS_IOLOCK_EXCL; - locktype = VRWLOCK_WRITE; - - xfs_ilock(xip, XFS_ILOCK_EXCL|iolock); - - isize = xip->i_d.di_size; - limit = XFS_MAXIOFFSET(mp); - - if (ioflag & O_APPEND) - *offset = isize; - -//start: - n = limit - *offset; - if (n <= 0) { - xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock); - return EFBIG; - } - if (n < size) - size = n; - - new_size = *offset + size; - if (new_size > isize) { - io->io_new_size = new_size; - } - -#ifdef RMC - /* probably be a long time before if ever that we do dmapi */ - if ((DM_EVENT_ENABLED(vp->v_vfsp, xip, DM_EVENT_WRITE) && - !(ioflags & IO_INVIS) && !eventsent)) { - loff_t savedsize = *offset; - int dmflags = FILP_DELAY_FLAG(file) | DM_SEM_FLAG_RD(ioflags); - - xfs_iunlock(xip, XFS_ILOCK_EXCL); - error = XFS_SEND_DATA(xip->i_mount, DM_EVENT_WRITE, vp, - *offset, size, - dmflags, &locktype); - if (error) { - if (iolock) xfs_iunlock(xip, iolock); - return -error; - } - xfs_ilock(xip, XFS_ILOCK_EXCL); - eventsent = 1; - - /* - * The iolock was dropped and reaquired in XFS_SEND_DATA - * so we have to recheck the size when appending. - * We will only "goto start;" once, since having sent the - * event prevents another call to XFS_SEND_DATA, which is - * what allows the size to change in the first place. - */ - if ((file->f_flags & O_APPEND) && - savedsize != xip->i_d.di_size) { - *offset = isize = xip->i_d.di_size; - goto start; - } - } -#endif - - /* - * If the offset is beyond the size of the file, we have a couple - * of things to do. First, if there is already space allocated - * we need to either create holes or zero the disk or ... - * - * If there is a page where the previous size lands, we need - * to zero it out up to the new size. - */ - - if (!(ioflag & IO_ISDIRECT) && (*offset > isize && isize)) { - error = xfs_zero_eof(BHV_TO_VNODE(bdp), io, *offset, - isize, *offset + size); - if (error) { - xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock); - return(-error); - } - } - xfs_iunlock(xip, XFS_ILOCK_EXCL); - -#if 0 - /* - * If we're writing the file then make sure to clear the - * setuid and setgid bits if the process is not being run - * by root. This keeps people from modifying setuid and - * setgid binaries. - */ - - if (((xip->i_d.di_mode & S_ISUID) || - ((xip->i_d.di_mode & (S_ISGID | S_IXGRP)) == - (S_ISGID | S_IXGRP))) && - !capable(CAP_FSETID)) { - error = xfs_write_clear_setuid(xip); - if (likely(!error)) - error = -remove_suid(file->f_dentry); - if (unlikely(error)) { - xfs_iunlock(xip, iolock); - goto out_unlock_mutex; - } - } -#endif - - -//retry: - if (unlikely(ioflag & IO_ISDIRECT)) { - -#ifdef RMC - xfs_off_t pos = *offset; - struct address_space *mapping = file->f_dentry->d_inode->i_mapping; - struct inode *inode = mapping->host; - - ret = precheck_file_write(file, inode, &size, &pos); - if (ret || size == 0) - goto error; - - xfs_inval_cached_pages(vp, io, pos, 1, 1); - inode->i_ctime = inode->i_mtime = CURRENT_TIME; - /* mark_inode_dirty_sync(inode); - we do this later */ - - xfs_rw_enter_trace(XFS_DIOWR_ENTER, io, buf, size, pos, ioflags); - ret = generic_file_direct_IO(WRITE, file, (char *)buf, size, pos); - xfs_inval_cached_pages(vp, io, pos, 1, 1); - if (ret > 0) - *offset += ret; -#endif - } else { - xfs_rw_enter_trace(XFS_WRITE_ENTER, io, buf, size, *offset, ioflags); - ret = xfs_write_file(xip,uio,ioflag); - } - - xfs_ichgtime(xip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); - - -//error: - if (ret <= 0) { - if (iolock) - xfs_rwunlock(bdp, locktype); - return ret; - } - - XFS_STATS_ADD(xs_write_bytes, ret); - - if (*offset > xip->i_d.di_size) { - xfs_ilock(xip, XFS_ILOCK_EXCL); - if (*offset > xip->i_d.di_size) { - printf("xfs_write look at doing more here %s:%d\n",__FILE__,__LINE__); -#ifdef RMC - struct inode *inode = LINVFS_GET_IP(vp); - i_size_write(inode, *offset); - mark_inode_dirty_sync(inode); -#endif - - xip->i_d.di_size = *offset; - xip->i_update_core = 1; - xip->i_update_size = 1; - } - xfs_iunlock(xip, XFS_ILOCK_EXCL); - } - - /* Handle various SYNC-type writes */ -#if 0 -// if ((file->f_flags & O_SYNC) || IS_SYNC(inode)) { -#endif - if (ioflag & IO_SYNC) { - /* - * If we're treating this as O_DSYNC and we have not updated the - * size, force the log. - */ - if (!(mp->m_flags & XFS_MOUNT_OSYNCISOSYNC) && - !(xip->i_update_size)) { - xfs_inode_log_item_t *iip = xip->i_itemp; - - /* - * If an allocation transaction occurred - * without extending the size, then we have to force - * the log up the proper point to ensure that the - * allocation is permanent. We can't count on - * the fact that buffered writes lock out direct I/O - * writes - the direct I/O write could have extended - * the size nontransactionally, then finished before - * we started. xfs_write_file will think that the file - * didn't grow but the update isn't safe unless the - * size change is logged. - * - * Force the log if we've committed a transaction - * against the inode or if someone else has and - * the commit record hasn't gone to disk (e.g. - * the inode is pinned). This guarantees that - * all changes affecting the inode are permanent - * when we return. - */ - if (iip && iip->ili_last_lsn) { - xfs_log_force(mp, iip->ili_last_lsn, - XFS_LOG_FORCE | XFS_LOG_SYNC); - } else if (xfs_ipincount(xip) > 0) { - xfs_log_force(mp, (xfs_lsn_t)0, - XFS_LOG_FORCE | XFS_LOG_SYNC); - } - - } else { - xfs_trans_t *tp; - - /* - * O_SYNC or O_DSYNC _with_ a size update are handled - * the same way. - * - * If the write was synchronous then we need to make - * sure that the inode modification time is permanent. - * We'll have updated the timestamp above, so here - * we use a synchronous transaction to log the inode. - * It's not fast, but it's necessary. - * - * If this a dsync write and the size got changed - * non-transactionally, then we need to ensure that - * the size change gets logged in a synchronous - * transaction. - */ - - tp = xfs_trans_alloc(mp, XFS_TRANS_WRITE_SYNC); - if ((error = xfs_trans_reserve(tp, 0, - XFS_SWRITE_LOG_RES(mp), - 0, 0, 0))) { - /* Transaction reserve failed */ - xfs_trans_cancel(tp, 0); - } else { - /* Transaction reserve successful */ - xfs_ilock(xip, XFS_ILOCK_EXCL); - xfs_trans_ijoin(tp, xip, XFS_ILOCK_EXCL); - xfs_trans_ihold(tp, xip); - xfs_trans_log_inode(tp, xip, XFS_ILOG_CORE); - xfs_trans_set_sync(tp); - error = xfs_trans_commit(tp, 0, NULL); - xfs_iunlock(xip, XFS_ILOCK_EXCL); - } - if (error) - goto out_unlock_internal; - } - - xfs_rwunlock(bdp, locktype); - return ret; - - } /* (ioflags & O_SYNC) */ - -out_unlock_internal: - xfs_rwunlock(bdp, locktype); -#if 0 -out_unlock_mutex: - if (need_i_mutex) - mutex_unlock(&inode->i_mutex); -#endif - //out_nounlocks: - return -error; -} - -/* - * Initiate IO on given buffer. - */ -int -xfs_buf_iorequest(struct xfs_buf *bp) -{ - bp->b_flags &= ~(B_INVAL|B_DONE); - bp->b_ioflags &= ~BIO_ERROR; - - if (bp->b_flags & B_ASYNC) - BUF_KERNPROC(bp); - - if (bp->b_vp == NULL) { - if (bp->b_iocmd == BIO_WRITE) { - bp->b_flags &= ~(B_DELWRI | B_DEFERRED); - bufobj_wref(bp->b_bufobj); - } - - bp->b_iooffset = (bp->b_blkno << BBSHIFT); - bstrategy(bp); - } else { - if (bp->b_iocmd == BIO_WRITE) { - /* Mark the buffer clean */ - bundirty(bp); - bufobj_wref(bp->b_bufobj); - vfs_busy_pages(bp, 1); - } else if (bp->b_iocmd == BIO_READ) { - vfs_busy_pages(bp, 0); - } - bp->b_iooffset = dbtob(bp->b_blkno); - bstrategy(bp); - } - return 0; -} - -/* - * All xfs metadata buffers except log state machine buffers - * get this attached as their b_bdstrat callback function. - * This is so that we can catch a buffer - * after prematurely unpinning it to forcibly shutdown the filesystem. - */ -int -xfs_bdstrat_cb(struct xfs_buf *bp) -{ - xfs_mount_t *mp; - - mp = XFS_BUF_FSPRIVATE3(bp, xfs_mount_t *); - if (!XFS_FORCED_SHUTDOWN(mp)) { - xfs_buf_iorequest(bp); - return 0; - } else { - xfs_buftrace("XFS__BDSTRAT IOERROR", bp); - /* - * Metadata write that didn't get logged but - * written delayed anyway. These aren't associated - * with a transaction, and can be ignored. - */ - if (XFS_BUF_IODONE_FUNC(bp) == NULL && - (XFS_BUF_ISREAD(bp)) == 0) - return (xfs_bioerror_relse(bp)); - else - return (xfs_bioerror(bp)); - } -} - - -int -xfs_bmap(bhv_desc_t *bdp, - xfs_off_t offset, - ssize_t count, - int flags, - xfs_iomap_t *iomapp, - int *niomaps) -{ - xfs_inode_t *ip = XFS_BHVTOI(bdp); - xfs_iocore_t *io = &ip->i_iocore; - - ASSERT((ip->i_d.di_mode & S_IFMT) == S_IFREG); - ASSERT(((ip->i_d.di_flags & XFS_DIFLAG_REALTIME) != 0) == - ((ip->i_iocore.io_flags & XFS_IOCORE_RT) != 0)); - - return xfs_iomap(io, offset, count, flags, iomapp, niomaps); -} - -/* - * Wrapper around bdstrat so that we can stop data - * from going to disk in case we are shutting down the filesystem. - * Typically user data goes thru this path; one of the exceptions - * is the superblock. - */ -int -xfsbdstrat( - struct xfs_mount *mp, - struct xfs_buf *bp) -{ - ASSERT(mp); - if (!XFS_FORCED_SHUTDOWN(mp)) { - - xfs_buf_iorequest(bp); - return 0; - } - - xfs_buftrace("XFSBDSTRAT IOERROR", bp); - return (xfs_bioerror_relse(bp)); -} - -/* - * If the underlying (data/log/rt) device is readonly, there are some - * operations that cannot proceed. - */ -int -xfs_dev_is_read_only( - xfs_mount_t *mp, - char *message) -{ - if (xfs_readonly_buftarg(mp->m_ddev_targp) || - xfs_readonly_buftarg(mp->m_logdev_targp) || - (mp->m_rtdev_targp && xfs_readonly_buftarg(mp->m_rtdev_targp))) { - cmn_err(CE_NOTE, - "XFS: %s required on read-only device.", message); - cmn_err(CE_NOTE, - "XFS: write access unavailable, cannot proceed."); - return EROFS; - } - return 0; -} diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_frw.h b/sys/gnu/fs/xfs/FreeBSD/xfs_frw.h deleted file mode 100644 index 78d93f9..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_frw.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ - */ -#ifndef __XFS_FRW_H__ -#define __XFS_FRW_H__ - -struct xfs_vnode; -struct bhv_desc; -struct xfs_mount; -struct xfs_iocore; -struct xfs_inode; -struct xfs_bmbt_irec; -struct xfs_buf; -struct xfs_iomap; - -#if defined(XFS_RW_TRACE) -/* - * Defines for the trace mechanisms in xfs_lrw.c. - */ -#define XFS_RW_KTRACE_SIZE 128 - -#define XFS_READ_ENTER 1 -#define XFS_WRITE_ENTER 2 -#define XFS_IOMAP_READ_ENTER 3 -#define XFS_IOMAP_WRITE_ENTER 4 -#define XFS_IOMAP_READ_MAP 5 -#define XFS_IOMAP_WRITE_MAP 6 -#define XFS_IOMAP_WRITE_NOSPACE 7 -#define XFS_ITRUNC_START 8 -#define XFS_ITRUNC_FINISH1 9 -#define XFS_ITRUNC_FINISH2 10 -#define XFS_CTRUNC1 11 -#define XFS_CTRUNC2 12 -#define XFS_CTRUNC3 13 -#define XFS_CTRUNC4 14 -#define XFS_CTRUNC5 15 -#define XFS_CTRUNC6 16 -#define XFS_BUNMAPI 17 -#define XFS_INVAL_CACHED 18 -#define XFS_DIORD_ENTER 19 -#define XFS_DIOWR_ENTER 20 -#define XFS_SENDFILE_ENTER 21 -#define XFS_WRITEPAGE_ENTER 22 -#define XFS_RELEASEPAGE_ENTER 23 -#define XFS_IOMAP_ALLOC_ENTER 24 -#define XFS_IOMAP_ALLOC_MAP 25 -#define XFS_IOMAP_UNWRITTEN 26 -extern void xfs_rw_enter_trace(int, struct xfs_iocore *, - const char *, size_t, loff_t, int); -extern void xfs_inval_cached_trace(struct xfs_iocore *, - xfs_off_t, xfs_off_t, xfs_off_t, xfs_off_t); -#else -#define xfs_rw_enter_trace(tag, io, buf, size, offset, ioflags) -#define xfs_inval_cached_trace(io, offset, len, first, last) -#endif - -/* - * Maximum count of bmaps used by read and write paths. - */ -#define XFS_MAX_RW_NBMAPS 4 - -extern int xfs_bmap(struct bhv_desc *, xfs_off_t, ssize_t, int, - struct xfs_iomap *, int *); -extern int xfsbdstrat(struct xfs_mount *, struct xfs_buf *); -extern int xfs_bdstrat_cb(struct xfs_buf *); - -extern int xfs_zero_eof(struct xfs_vnode *, struct xfs_iocore *, xfs_off_t, - xfs_fsize_t, xfs_fsize_t); -extern void xfs_inval_cached_pages(struct xfs_vnode*, struct xfs_iocore *, - xfs_off_t, int, int); -extern ssize_t xfs_read(bhv_desc_t *, uio_t *, int, cred_t *); -extern ssize_t xfs_write(bhv_desc_t *, uio_t *, int, cred_t *); -extern int xfs_dev_is_read_only(struct xfs_mount *, char *); - -extern int xfs_read_file(struct xfs_mount *mp, struct xfs_inode *ip, struct uio *uio, - int ioflag); -extern int xfs_write_file(struct xfs_inode *, struct uio *, int); -#endif /* __XFS_FRW_H__ */ diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_fs_subr.c b/sys/gnu/fs/xfs/FreeBSD/xfs_fs_subr.c deleted file mode 100644 index dec6e2f..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_fs_subr.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ - */ - -#include "xfs.h" - -/* - * Stub for no-op vnode operations that return error status. - */ -int -fs_noerr() -{ - return 0; -} - -/* - * Operation unsupported under this file system. - */ -int -fs_nosys() -{ - return ENOSYS; -} - -/* - * Stub for inactive, strategy, and read/write lock/unlock. Does nothing. - */ -/* ARGSUSED */ -void -fs_noval() -{ -} - -/* - * vnode pcache layer for vnode_tosspages. - * 'last' parameter unused but left in for IRIX compatibility - */ -void -fs_tosspages( - bhv_desc_t *bdp, - xfs_off_t first, - xfs_off_t last, - int fiopt) -{ -#ifdef XXXKAN - vnode_t *vp = BHV_TO_VNODE(bdp); - struct inode *ip = LINVFS_GET_IP(vp); - - if (VN_CACHED(vp)) - truncate_inode_pages(ip->i_mapping, first); -#endif -} - - -/* - * vnode pcache layer for vnode_flushinval_pages. - * 'last' parameter unused but left in for IRIX compatibility - */ -void -fs_flushinval_pages( - bhv_desc_t *bdp, - xfs_off_t first, - xfs_off_t last, - int fiopt) -{ -#ifdef XXXKAN - vnode_t *vp = BHV_TO_VNODE(bdp); - struct inode *ip = LINVFS_GET_IP(vp); - - if (VN_CACHED(vp)) { - filemap_fdatasync(ip->i_mapping); - fsync_inode_data_buffers(ip); - filemap_fdatawait(ip->i_mapping); - - truncate_inode_pages(ip->i_mapping, first); - } -#endif -} - -/* - * vnode pcache layer for vnode_flush_pages. - * 'last' parameter unused but left in for IRIX compatibility - */ -int -fs_flush_pages( - bhv_desc_t *bdp, - xfs_off_t first, - xfs_off_t last, - uint64_t flags, - int fiopt) -{ -#ifdef XXXKAN - vnode_t *vp = BHV_TO_VNODE(bdp); - struct inode *ip = LINVFS_GET_IP(vp); - - if (VN_CACHED(vp)) { - filemap_fdatasync(ip->i_mapping); - fsync_inode_data_buffers(ip); - filemap_fdatawait(ip->i_mapping); - } -#endif - return 0; -} diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_fs_subr.h b/sys/gnu/fs/xfs/FreeBSD/xfs_fs_subr.h deleted file mode 100644 index 198b8dd..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_fs_subr.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2000, 2002 Silicon Graphics, Inc. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ - */ -#ifndef __XFS_SUBR_H__ -#define __XFS_SUBR_H__ - -/* - * Utilities shared among file system implementations. - */ - -struct cred; - -extern int fs_noerr(void); -extern int fs_nosys(void); -extern int fs_nodev(void); -extern void fs_noval(void); -extern void fs_tosspages(bhv_desc_t *, xfs_off_t, xfs_off_t, int); -extern void fs_flushinval_pages(bhv_desc_t *, xfs_off_t, xfs_off_t, int); -extern int fs_flush_pages(bhv_desc_t *, xfs_off_t, xfs_off_t, uint64_t, int); - -#endif /* __XFS_FS_SUBR_H__ */ diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_globals.c b/sys/gnu/fs/xfs/FreeBSD/xfs_globals.c deleted file mode 100644 index 1d4ac81..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_globals.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ - */ - -/* - * This file contains globals needed by XFS that were normally defined - * somewhere else in IRIX. - */ - -#include "xfs.h" -#include "xfs_types.h" -#include "xfs_bmap_btree.h" -#include "xfs_bit.h" -#include "xfs_refcache.h" - -/* - * Tunable XFS parameters. xfs_params is required even when CONFIG_SYSCTL=n, - * other XFS code uses these values. - */ - -xfs_param_t xfs_params = { - /* MIN DFLT MAX */ -#ifdef HAVE_REFCACHE - .refcache_size = { 0, 128, XFS_REFCACHE_SIZE_MAX }, - .refcache_purge = { 0, 32, XFS_REFCACHE_SIZE_MAX }, -#endif - .restrict_chown = { 0, 1, 1 }, - .sgid_inherit = { 0, 0, 1 }, - .symlink_mode = { 0, 0, 1 }, - .panic_mask = { 0, 0, 127 }, - .error_level = { 0, 3, 11 }, - .syncd_timer = { 1*100, 30*100, 7200*100}, - .probe_dmapi = { 0, 0, 1 }, - .probe_ioops = { 0, 0, 1 }, - .probe_quota = { 0, 1, 1 }, - .stats_clear = { 0, 0, 1 }, - .inherit_sync = { 0, 1, 1 }, - .inherit_nodump = { 0, 1, 1 }, - .inherit_noatim = { 0, 1, 1 }, - .xfs_buf_timer = { 100/2, 1*100, 30*100 }, - .xfs_buf_age = { 1*100, 15*100, 7200*100}, - .inherit_nosym = { 0, 0, 1 }, - .rotorstep = { 1, 1, 255 }, -}; - -/* - * Global system credential structure. - */ -cred_t sys_cred_val, *sys_cred = &sys_cred_val; diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_ioctl.c b/sys/gnu/fs/xfs/FreeBSD/xfs_ioctl.c deleted file mode 100644 index ff5582c..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_ioctl.c +++ /dev/null @@ -1,1460 +0,0 @@ -/* - * Copyright (c) 2000-2005 Silicon Graphics, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include "xfs.h" -#include "xfs_fs.h" -#include "xfs_bit.h" -#include "xfs_log.h" -#include "xfs_inum.h" -#include "xfs_trans.h" -#include "xfs_sb.h" -#include "xfs_ag.h" -#include "xfs_dir.h" -#include "xfs_dir2.h" -#include "xfs_alloc.h" -#include "xfs_dmapi.h" -#include "xfs_mount.h" -#include "xfs_bmap_btree.h" -#include "xfs_alloc_btree.h" -#include "xfs_ialloc_btree.h" -#include "xfs_dir_sf.h" -#include "xfs_attr_sf.h" -#include "xfs_dir2_sf.h" -#include "xfs_dinode.h" -#include "xfs_inode.h" -#include "xfs_btree.h" -#include "xfs_ialloc.h" -#include "xfs_rtalloc.h" -#include "xfs_itable.h" -#include "xfs_error.h" -#include "xfs_rw.h" -#include "xfs_acl.h" -#include "xfs_cap.h" -#include "xfs_mac.h" -#include "xfs_attr.h" -#include "xfs_bmap.h" -#include "xfs_buf_item.h" -#include "xfs_utils.h" -#include "xfs_dfrag.h" -#include "xfs_fsops.h" - - -#include <sys/file.h> -#if 1 -/* - * ioctl commands that are used by Linux filesystems - */ -#define XFS_IOC_GETXFLAGS _IOR('f', 1, long) -#define XFS_IOC_SETXFLAGS _IOW('f', 2, long) -#define XFS_IOC_GETVERSION _IOR('v', 1, long) - -#undef copy_to_user -static __inline__ int -copy_to_user(void *dst, void *src, int len) { - memcpy(dst,src,len); - return 0; -} -#undef copy_from_user -static __inline__ int -copy_from_user(void *dst, void *src, int len) { - memcpy(dst,src,len); - return 0; -} - -/* - * xfs_find_handle maps from userspace xfs_fsop_handlereq structure to - * a file or fs handle. - * - * XFS_IOC_PATH_TO_FSHANDLE - * returns fs handle for a mount point or path within that mount point - * XFS_IOC_FD_TO_HANDLE - * returns full handle for a FD opened in user space - * XFS_IOC_PATH_TO_HANDLE - * returns full handle for a path - */ -STATIC int -xfs_find_handle( - unsigned int cmd, - void __user *arg) -{ -#ifdef RMC - int hsize; -#endif - xfs_handle_t handle; - xfs_fsop_handlereq_t hreq; -#ifdef RMC - struct inode *inode; - xfs_vnode_t *vp; -#endif - - if (copy_from_user(&hreq, arg, sizeof(hreq))) - return -XFS_ERROR(EFAULT); - - memset((char *)&handle, 0, sizeof(handle)); - - switch (cmd) { -#if 0 - case XFS_IOC_PATH_TO_FSHANDLE: - case XFS_IOC_PATH_TO_HANDLE: { - struct nameidata nd; - int error; - - NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, - UIO_USERSPACE, hreq.path, td); - error = namei(&nd); - if (error) - return error; - NDFREE(&nd, NDF_ONLY_PNBUF); - break; - } - - case XFS_IOC_FD_TO_HANDLE: { - struct file *file; - int error; - - error = getvnode(td->td_proc->p_fd, hreq.fd, &file); - if (error) - return error; - - error = vget(vp, LK_EXCLUSIVE, td); - if (error) { - fdrop(file); - return error; - } - fdrop(file); - break; - } -#endif - - default: - ASSERT(0); - return XFS_ERROR(EINVAL); - } - -#ifdef RMC - if (inode->i_sb->s_magic != XFS_SB_MAGIC) { - /* we're not in XFS anymore, Toto */ - iput(inode); - return XFS_ERROR(EINVAL); - } - - switch (inode->i_mode & S_IFMT) { - case S_IFREG: - case S_IFDIR: - case S_IFLNK: - break; - default: - iput(inode); - return XFS_ERROR(EBADF); - } - /* we need the vnode */ - vp = vn_from_inode(inode); - - /* now we can grab the fsid */ - memcpy(&handle.ha_fsid, vp->v_vfsp->vfs_altfsid, sizeof(xfs_fsid_t)); - hsize = sizeof(xfs_fsid_t); - - if (cmd != XFS_IOC_PATH_TO_FSHANDLE) { - xfs_inode_t *ip; - int lock_mode; - - /* need to get access to the xfs_inode to read the generation */ - ip = xfs_vtoi(vp); - ASSERT(ip); - lock_mode = xfs_ilock_map_shared(ip); - - /* fill in fid section of handle from inode */ - handle.ha_fid.xfs_fid_len = sizeof(xfs_fid_t) - - sizeof(handle.ha_fid.xfs_fid_len); - handle.ha_fid.xfs_fid_pad = 0; - handle.ha_fid.xfs_fid_gen = ip->i_d.di_gen; - handle.ha_fid.xfs_fid_ino = ip->i_ino; - - xfs_iunlock_map_shared(ip, lock_mode); - - hsize = XFS_HSIZE(handle); - } - - /* now copy our handle into the user buffer & write out the size */ - if (copy_to_user(hreq.ohandle, &handle, hsize) || - copy_to_user(hreq.ohandlen, &hsize, sizeof(__s32))) { - iput(inode); - return XFS_ERROR(EFAULT); - } - - iput(inode); -#endif - return 0; -} - - -/* - * Convert userspace handle data into vnode (and inode). - * We [ab]use the fact that all the fsop_handlereq ioctl calls - * have a data structure argument whose first component is always - * a xfs_fsop_handlereq_t, so we can cast to and from this type. - * This allows us to optimise the copy_from_user calls and gives - * a handy, shared routine. - * - * If no error, caller must always VN_RELE the returned vp. - */ -STATIC int -xfs_vget_fsop_handlereq( - xfs_mount_t *mp, - struct inode *parinode, /* parent inode pointer */ - xfs_fsop_handlereq_t *hreq, - xfs_vnode_t **vp, - struct inode **inode) -{ -#if 0 - void __user *hanp; - size_t hlen; - xfs_fid_t *xfid; - xfs_handle_t *handlep; - xfs_handle_t handle; - xfs_inode_t *ip; - struct inode *inodep; - xfs_vnode_t *vpp; - xfs_ino_t ino; - __u32 igen; - int error; - - /* - * Only allow handle opens under a directory. - */ - if (!S_ISDIR(parinode->i_mode)) - return XFS_ERROR(ENOTDIR); - - hanp = hreq->ihandle; - hlen = hreq->ihandlen; - handlep = &handle; - - if (hlen < sizeof(handlep->ha_fsid) || hlen > sizeof(*handlep)) - return XFS_ERROR(EINVAL); - if (copy_from_user(handlep, hanp, hlen)) - return XFS_ERROR(EFAULT); - if (hlen < sizeof(*handlep)) - memset(((char *)handlep) + hlen, 0, sizeof(*handlep) - hlen); - if (hlen > sizeof(handlep->ha_fsid)) { - if (handlep->ha_fid.xfs_fid_len != - (hlen - sizeof(handlep->ha_fsid) - - sizeof(handlep->ha_fid.xfs_fid_len)) - || handlep->ha_fid.xfs_fid_pad) - return XFS_ERROR(EINVAL); - } - - /* - * Crack the handle, obtain the inode # & generation # - */ - xfid = (struct xfs_fid *)&handlep->ha_fid; - if (xfid->xfs_fid_len == sizeof(*xfid) - sizeof(xfid->xfs_fid_len)) { - ino = xfid->xfs_fid_ino; - igen = xfid->xfs_fid_gen; - } else { - return XFS_ERROR(EINVAL); - } - - /* - * Get the XFS inode, building a vnode to go with it. - */ - error = xfs_iget(mp, NULL, ino, 0, XFS_ILOCK_SHARED, &ip, 0); - if (error) - return error; - if (ip == NULL) - return XFS_ERROR(EIO); - if (ip->i_d.di_mode == 0 || ip->i_d.di_gen != igen) { - xfs_iput_new(ip, XFS_ILOCK_SHARED); - return XFS_ERROR(ENOENT); - } - - vpp = XFS_ITOV(ip); - inodep = vn_to_inode(vpp); - xfs_iunlock(ip, XFS_ILOCK_SHARED); - - *vp = vpp; - *inode = inodep; -#endif - return 0; -} - -STATIC int -xfs_open_by_handle( - xfs_mount_t *mp, - void __user *arg, - struct file *parfilp, - struct inode *parinode) -{ - int new_fd = 0; -#if 0 - int error; - int permflag; - struct file *filp; - struct inode *inode; - struct dentry *dentry; - xfs_vnode_t *vp; - xfs_fsop_handlereq_t hreq; - - if (!capable(CAP_SYS_ADMIN)) - return -XFS_ERROR(EPERM); - if (copy_from_user(&hreq, arg, sizeof(xfs_fsop_handlereq_t))) - return XFS_ERROR(EFAULT); - - error = xfs_vget_fsop_handlereq(mp, parinode, &hreq, &vp, &inode); - if (error) - return error; - - /* Restrict xfs_open_by_handle to directories & regular files. */ - if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode))) { - iput(inode); - return XFS_ERROR(EINVAL); - } - -#if BITS_PER_LONG != 32 - hreq.oflags |= O_LARGEFILE; -#endif - /* Put open permission in namei format. */ - permflag = hreq.oflags; - if ((permflag+1) & O_ACCMODE) - permflag++; - if (permflag & O_TRUNC) - permflag |= 2; - - if ((!(permflag & O_APPEND) || (permflag & O_TRUNC)) && - (permflag & FMODE_WRITE) && IS_APPEND(inode)) { - iput(inode); - return XFS_ERROR(EPERM); - } - - if ((permflag & FMODE_WRITE) && IS_IMMUTABLE(inode)) { - iput(inode); - return XFS_ERROR(EACCES); - } - - /* Can't write directories. */ - if ( S_ISDIR(inode->i_mode) && (permflag & FMODE_WRITE)) { - iput(inode); - return XFS_ERROR(EISDIR); - } - - if ((new_fd = get_unused_fd()) < 0) { - iput(inode); - return new_fd; - } - - dentry = d_alloc_anon(inode); - if (dentry == NULL) { - iput(inode); - put_unused_fd(new_fd); - return XFS_ERROR(ENOMEM); - } - - /* Ensure umount returns EBUSY on umounts while this file is open. */ - mntget(parfilp->f_vfsmnt); - - /* Create file pointer. */ - filp = dentry_open(dentry, parfilp->f_vfsmnt, hreq.oflags); - if (IS_ERR(filp)) { - put_unused_fd(new_fd); - return -XFS_ERROR(-PTR_ERR(filp)); - } - if (inode->i_mode & S_IFREG) - filp->f_op = &xfs_invis_file_operations; - - fd_install(new_fd, filp); -#endif - return new_fd; -} - -STATIC int -xfs_readlink_by_handle( - xfs_mount_t *mp, - void __user *arg, - struct file *parfilp, - struct inode *parinode) -{ - int error; - struct iovec aiov; - struct uio auio; - struct inode *inode; - xfs_fsop_handlereq_t hreq; - xfs_vnode_t *vp = NULL; - __u32 olen; - - if (!capable(CAP_SYS_ADMIN)) - return -XFS_ERROR(EPERM); - if (copy_from_user(&hreq, arg, sizeof(xfs_fsop_handlereq_t))) - return -XFS_ERROR(EFAULT); - - error = xfs_vget_fsop_handlereq(mp, parinode, &hreq, &vp, &inode); - if (error) - return -error; - -#if 0 - /* Restrict this handle operation to symlinks only. */ - if (vp->v_type != VLNK) { - VN_RELE(vp); - return -XFS_ERROR(EINVAL); - } -#endif - - if (copy_from_user(&olen, hreq.ohandlen, sizeof(__u32))) { - VN_RELE(vp); - return -XFS_ERROR(EFAULT); - } - aiov.iov_len = olen; - aiov.iov_base = hreq.ohandle; - - auio.uio_iov = &aiov; - auio.uio_iovcnt = 1; - auio.uio_offset = 0; - auio.uio_segflg = UIO_USERSPACE; - auio.uio_resid = olen; - - XVOP_READLINK(vp, &auio, IO_INVIS, NULL, error); - - VN_RELE(vp); - return (olen - auio.uio_resid); -} - -STATIC int -xfs_fssetdm_by_handle( - xfs_mount_t *mp, - void __user *arg, - struct file *parfilp, - struct inode *parinode) -{ - int error = 0; -#if 0 - struct fsdmidata fsd; - xfs_fsop_setdm_handlereq_t dmhreq; - struct inode *inode; - bhv_desc_t *bdp; - xfs_vnode_t *vp; - - if (!capable(CAP_MKNOD)) - return XFS_ERROR(EPERM); - if (copy_from_user(&dmhreq, arg, sizeof(xfs_fsop_setdm_handlereq_t))) - return XFS_ERROR(EFAULT); - - error = xfs_vget_fsop_handlereq(mp, parinode, &dmhreq.hreq, &vp, &inode); - if (error) - return error; - - if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) { - VN_RELE(vp); - return XFS_ERROR(EPERM); - } - - if (copy_from_user(&fsd, dmhreq.data, sizeof(fsd))) { - VN_RELE(vp); - return XFS_ERROR(EFAULT); - } - - bdp = bhv_base_unlocked(VN_BHV_HEAD(vp)); - error = xfs_set_dmattrs(bdp, fsd.fsd_dmevmask, fsd.fsd_dmstate, NULL); - - VN_RELE(vp); - if (error) - return error; -#endif - return error; -} - -STATIC int -xfs_attrlist_by_handle( - xfs_mount_t *mp, - void __user *arg, - struct file *parfilp, - struct inode *parinode) -{ - int error = 0; -#if 0 - attrlist_cursor_kern_t *cursor; - xfs_fsop_attrlist_handlereq_t al_hreq; - struct inode *inode; - xfs_vnode_t *vp; - char *kbuf; - - if (!capable(CAP_SYS_ADMIN)) - return -XFS_ERROR(EPERM); - if (copy_from_user(&al_hreq, arg, sizeof(xfs_fsop_attrlist_handlereq_t))) - return -XFS_ERROR(EFAULT); - if (al_hreq.buflen > XATTR_LIST_MAX) - return -XFS_ERROR(EINVAL); - - error = xfs_vget_fsop_handlereq(mp, parinode, &al_hreq.hreq, - &vp, &inode); - if (error) - goto out; - - kbuf = kmalloc(al_hreq.buflen, GFP_KERNEL); - if (!kbuf) - goto out_vn_rele; - - cursor = (attrlist_cursor_kern_t *)&al_hreq.pos; - XVOP_ATTR_LIST(vp, kbuf, al_hreq.buflen, al_hreq.flags, - cursor, NULL, error); - if (error) - goto out_kfree; - - if (copy_to_user(al_hreq.buffer, kbuf, al_hreq.buflen)) - error = -EFAULT; - - out_kfree: - kfree(kbuf); - out_vn_rele: - VN_RELE(vp); - out: -#endif - return error; -} - -#if 0 -STATIC int -xfs_attrmulti_attr_get( - xfs_vnode_t *vp, - char *name, - char __user *ubuf, - __uint32_t *len, - __uint32_t flags) -{ - int error = EFAULT; - char *kbuf; - - if (*len > XATTR_SIZE_MAX) - return EINVAL; - kbuf = kmalloc(*len, GFP_KERNEL); - if (!kbuf) - return ENOMEM; - - XVOP_ATTR_GET(vp, name, kbuf, len, flags, NULL, error); - if (error) - goto out_kfree; - - if (copy_to_user(ubuf, kbuf, *len)) - error = EFAULT; - - out_kfree: - kfree(kbuf); - return error; -} -#endif - -#if 0 -STATIC int -xfs_attrmulti_attr_set( - xfs_vnode_t *vp, - char *name, - const char __user *ubuf, - __uint32_t len, - __uint32_t flags) -{ - int error = EFAULT; - char *kbuf; - - if (IS_RDONLY(&vp->v_inode)) - return -EROFS; - if (IS_IMMUTABLE(&vp->v_inode) || IS_APPEND(&vp->v_inode)) - return EPERM; - if (len > XATTR_SIZE_MAX) - return EINVAL; - - kbuf = kmalloc(len, GFP_KERNEL); - if (!kbuf) - return ENOMEM; - - if (copy_from_user(kbuf, ubuf, len)) - goto out_kfree; - - XVOP_ATTR_SET(vp, name, kbuf, len, flags, NULL, error); - - out_kfree: - kfree(kbuf); - return error; -} -#endif - -#if 0 -STATIC int -xfs_attrmulti_attr_remove( - xfs_vnode_t *vp, - char *name, - __uint32_t flags) -{ - int error; - - if (IS_RDONLY(&vp->v_inode)) - return -EROFS; - if (IS_IMMUTABLE(&vp->v_inode) || IS_APPEND(&vp->v_inode)) - return EPERM; - - XVOP_ATTR_REMOVE(vp, name, flags, NULL, error); - return error; -} -#endif - -STATIC int -xfs_attrmulti_by_handle( - xfs_mount_t *mp, - void __user *arg, - struct file *parfilp, - struct inode *parinode) -{ - int error = 0; -#if 0 - xfs_attr_multiop_t *ops; - xfs_fsop_attrmulti_handlereq_t am_hreq; - struct inode *inode; - xfs_vnode_t *vp; - unsigned int i, size; - char *attr_name; - - if (!capable(CAP_SYS_ADMIN)) - return -XFS_ERROR(EPERM); - if (copy_from_user(&am_hreq, arg, sizeof(xfs_fsop_attrmulti_handlereq_t))) - return -XFS_ERROR(EFAULT); - - error = xfs_vget_fsop_handlereq(mp, parinode, &am_hreq.hreq, &vp, &inode); - if (error) - goto out; - - error = E2BIG; - size = am_hreq.opcount * sizeof(attr_multiop_t); - if (!size || size > 16 * PAGE_SIZE) - goto out_vn_rele; - - error = ENOMEM; - ops = kmalloc(size, GFP_KERNEL); - if (!ops) - goto out_vn_rele; - - error = EFAULT; - if (copy_from_user(ops, am_hreq.ops, size)) - goto out_kfree_ops; - - attr_name = kmalloc(MAXNAMELEN, GFP_KERNEL); - if (!attr_name) - goto out_kfree_ops; - - - error = 0; - for (i = 0; i < am_hreq.opcount; i++) { - ops[i].am_error = strncpy_from_user(attr_name, - ops[i].am_attrname, MAXNAMELEN); - if (ops[i].am_error == 0 || ops[i].am_error == MAXNAMELEN) - error = -ERANGE; - if (ops[i].am_error < 0) - break; - - switch (ops[i].am_opcode) { - case ATTR_OP_GET: - ops[i].am_error = xfs_attrmulti_attr_get(vp, - attr_name, ops[i].am_attrvalue, - &ops[i].am_length, ops[i].am_flags); - break; - case ATTR_OP_SET: - ops[i].am_error = xfs_attrmulti_attr_set(vp, - attr_name, ops[i].am_attrvalue, - ops[i].am_length, ops[i].am_flags); - break; - case ATTR_OP_REMOVE: - ops[i].am_error = xfs_attrmulti_attr_remove(vp, - attr_name, ops[i].am_flags); - break; - default: - ops[i].am_error = EINVAL; - } - } - - if (copy_to_user(am_hreq.ops, ops, size)) - error = XFS_ERROR(EFAULT); - - kfree(attr_name); - out_kfree_ops: - kfree(ops); - out_vn_rele: - VN_RELE(vp); - out: -#endif - return error; -} - -/* prototypes for a few of the stack-hungry cases that have - * their own functions. Functions are defined after their use - * so gcc doesn't get fancy and inline them with -03 */ - -STATIC int -xfs_ioc_space( - bhv_desc_t *bdp, - xfs_vnode_t *vp, - struct file *filp, - int flags, - u_long cmd, - void __user *arg); - -STATIC int -xfs_ioc_bulkstat( - xfs_mount_t *mp, - unsigned int cmd, - void __user *arg); - -STATIC int -xfs_ioc_fsgeometry_v1( - xfs_mount_t *mp, - void __user *arg); - -STATIC int -xfs_ioc_fsgeometry( - xfs_mount_t *mp, - void __user *arg); - -STATIC int -xfs_ioc_xattr( - xfs_vnode_t *vp, - xfs_inode_t *ip, - struct file *filp, - unsigned int cmd, - void __user *arg); - -STATIC int -xfs_ioc_getbmap( - bhv_desc_t *bdp, - struct file *filp, - int flags, - unsigned int cmd, - void __user *arg); - -STATIC int -xfs_ioc_getbmapx( - bhv_desc_t *bdp, - void __user *arg); - -int -xfs_ioctl( - bhv_desc_t *bdp, - struct inode *inode, - struct file *filp, - int ioflags, - u_long cmd, - void *arg) -{ - int error; - xfs_vnode_t *vp; - xfs_inode_t *ip; - xfs_mount_t *mp; - -// vp = vn_from_inode(inode); - vp = BHV_TO_VNODE(bdp); - - printf("xfs_ioctl: bdp %p flags 0x%x cmd 0x%lx basecmd 0x%lx arg %p\n", - bdp, ioflags, cmd, - IOCBASECMD(cmd), - arg); - - - vn_trace_entry(vp, "xfs_ioctl", (inst_t *)__return_address); - - ip = XFS_BHVTOI(bdp); - mp = ip->i_mount; - - -#if 0 - if ((cmd << 24 >> 24) == (XFS_IOC_GETBMAPX << 24 >> 24)) { - cmd = XFS_IOC_GETBMAPX; - } -#endif - - - - switch (cmd) { - - case XFS_IOC_ALLOCSP: - case XFS_IOC_FREESP: - case XFS_IOC_RESVSP: - case XFS_IOC_UNRESVSP: - case XFS_IOC_ALLOCSP64: - case XFS_IOC_FREESP64: - case XFS_IOC_RESVSP64: - case XFS_IOC_UNRESVSP64: - /* - * Only allow the sys admin to reserve space unless - * unwritten extents are enabled. - */ - if (!XFS_SB_VERSION_HASEXTFLGBIT(&mp->m_sb) && - !capable(CAP_SYS_ADMIN)) - return -EPERM; - - return xfs_ioc_space(bdp, vp, filp, ioflags, cmd, arg); - - case XFS_IOC_DIOINFO: { - struct dioattr da; - xfs_buftarg_t *target = - (ip->i_d.di_flags & XFS_DIFLAG_REALTIME) ? - mp->m_rtdev_targp : mp->m_ddev_targp; - - da.d_mem = da.d_miniosz = 1 << target->bt_sshift; - da.d_maxiosz = INT_MAX & ~(da.d_miniosz - 1); - - if (copy_to_user(arg, &da, sizeof(da))) - return XFS_ERROR(EFAULT); - return 0; - } - - case XFS_IOC_FSBULKSTAT_SINGLE: - case XFS_IOC_FSBULKSTAT: - case XFS_IOC_FSINUMBERS: - return xfs_ioc_bulkstat(mp, cmd, arg); - - case XFS_IOC_FSGEOMETRY_V1: - return xfs_ioc_fsgeometry_v1(mp, arg); - - case XFS_IOC_FSGEOMETRY: - return xfs_ioc_fsgeometry(mp, arg); - - case XFS_IOC_GETVERSION: - case XFS_IOC_GETXFLAGS: - case XFS_IOC_SETXFLAGS: - case XFS_IOC_FSGETXATTR: - case XFS_IOC_FSSETXATTR: - case XFS_IOC_FSGETXATTRA: - return xfs_ioc_xattr(vp, ip, filp, cmd, arg); - - case XFS_IOC_FSSETDM: { - struct fsdmidata dmi; - - if (copy_from_user(&dmi, arg, sizeof(dmi))) - return XFS_ERROR(EFAULT); - - error = xfs_set_dmattrs(bdp, dmi.fsd_dmevmask, dmi.fsd_dmstate, - NULL); - return error; - } - - case XFS_IOC_GETBMAP: - case XFS_IOC_GETBMAPA: - return xfs_ioc_getbmap(bdp, filp, ioflags, cmd, arg); - - case XFS_IOC_GETBMAPX: - return xfs_ioc_getbmapx(bdp, arg); - - case XFS_IOC_FD_TO_HANDLE: - case XFS_IOC_PATH_TO_HANDLE: - case XFS_IOC_PATH_TO_FSHANDLE: - return xfs_find_handle(cmd, arg); - - case XFS_IOC_OPEN_BY_HANDLE: - return xfs_open_by_handle(mp, arg, filp, inode); - - case XFS_IOC_FSSETDM_BY_HANDLE: - return xfs_fssetdm_by_handle(mp, arg, filp, inode); - - case XFS_IOC_READLINK_BY_HANDLE: - return xfs_readlink_by_handle(mp, arg, filp, inode); - - case XFS_IOC_ATTRLIST_BY_HANDLE: - return xfs_attrlist_by_handle(mp, arg, filp, inode); - - case XFS_IOC_ATTRMULTI_BY_HANDLE: - return xfs_attrmulti_by_handle(mp, arg, filp, inode); - - case XFS_IOC_SWAPEXT: { - error = xfs_swapext((struct xfs_swapext __user *)arg); - return error; - } - - case XFS_IOC_FSCOUNTS: { - xfs_fsop_counts_t out; - - error = xfs_fs_counts(mp, &out); - if (error) - return error; - - if (copy_to_user(arg, &out, sizeof(out))) - return XFS_ERROR(EFAULT); - return 0; - } - - case XFS_IOC_SET_RESBLKS: { - xfs_fsop_resblks_t inout; - __uint64_t in; - - if (!capable(CAP_SYS_ADMIN)) - return EPERM; - - if (copy_from_user(&inout, arg, sizeof(inout))) - return XFS_ERROR(EFAULT); - - /* input parameter is passed in resblks field of structure */ - in = inout.resblks; - error = xfs_reserve_blocks(mp, &in, &inout); - if (error) - return error; - - if (copy_to_user(arg, &inout, sizeof(inout))) - return XFS_ERROR(EFAULT); - return 0; - } - - case XFS_IOC_GET_RESBLKS: { - xfs_fsop_resblks_t out; - - if (!capable(CAP_SYS_ADMIN)) - return EPERM; - - error = xfs_reserve_blocks(mp, NULL, &out); - if (error) - return error; - - if (copy_to_user(arg, &out, sizeof(out))) - return XFS_ERROR(EFAULT); - - return 0; - } - - case XFS_IOC_FSGROWFSDATA: { - xfs_growfs_data_t in; - - if (!capable(CAP_SYS_ADMIN)) - return EPERM; - - if (copy_from_user(&in, arg, sizeof(in))) - return XFS_ERROR(EFAULT); - - error = xfs_growfs_data(mp, &in); - return error; - } - - case XFS_IOC_FSGROWFSLOG: { - xfs_growfs_log_t in; - - if (!capable(CAP_SYS_ADMIN)) - return EPERM; - - if (copy_from_user(&in, arg, sizeof(in))) - return XFS_ERROR(EFAULT); - - error = xfs_growfs_log(mp, &in); - return error; - } - - case XFS_IOC_FSGROWFSRT: { - xfs_growfs_rt_t in; - - if (!capable(CAP_SYS_ADMIN)) - return EPERM; - - if (copy_from_user(&in, arg, sizeof(in))) - return XFS_ERROR(EFAULT); - - error = xfs_growfs_rt(mp, &in); - return error; - } -#if 0 - case XFS_IOC_FREEZE: - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - xfs_fs_freeze(mp); - return 0; - - case XFS_IOC_THAW: - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - xfs_fs_thaw(mp); - return 0; -#endif - - case XFS_IOC_GOINGDOWN: { - __uint32_t in; - - if (!capable(CAP_SYS_ADMIN)) - return EPERM; - - if (copy_from_user(&in, arg, sizeof(__uint32_t))) - return XFS_ERROR(EFAULT); - - error = xfs_fs_goingdown(mp, in); - return error; - } - - case XFS_IOC_ERROR_INJECTION: { - xfs_error_injection_t in; - - if (!capable(CAP_SYS_ADMIN)) - return EPERM; - - if (copy_from_user(&in, arg, sizeof(in))) - return XFS_ERROR(EFAULT); - - error = xfs_errortag_add(in.errtag, mp); - return error; - } - - case XFS_IOC_ERROR_CLEARALL: - if (!capable(CAP_SYS_ADMIN)) - return EPERM; - - error = xfs_errortag_clearall(mp); - return error; - - default: - return ENOTTY; - } -} - -STATIC int -xfs_ioc_space( - bhv_desc_t *bdp, - xfs_vnode_t *vp, - struct file *filp, - int ioflags, - u_long cmd, - void __user *arg) -{ - xfs_flock64_t bf; - int attr_flags = 0; - int error; - -#if 0 - if (vp->v_inode.i_flags & (S_IMMUTABLE|S_APPEND)) - return -XFS_ERROR(EPERM); - - if (!(filp->f_mode & FMODE_WRITE)) - return -XFS_ERROR(EBADF); -#endif - - if (!VN_ISREG(vp)) - return -XFS_ERROR(EINVAL); - - if (copy_from_user(&bf, arg, sizeof(bf))) - return -XFS_ERROR(EFAULT); - -#if 0 - if (filp->f_flags & (O_NDELAY|O_NONBLOCK)) - attr_flags |= ATTR_NONBLOCK; -#endif - if (ioflags & IO_INVIS) - attr_flags |= ATTR_DMI; - - error = xfs_change_file_space(bdp, cmd, - &bf, filp->f_offset, - NULL, attr_flags); - return -error; -} - -STATIC int -xfs_ioc_bulkstat( - xfs_mount_t *mp, - unsigned int cmd, - void __user *arg) -{ - xfs_fsop_bulkreq_t bulkreq; - int count; /* # of records returned */ - xfs_ino_t inlast; /* last inode number */ - int done; - int error; - - /* done = 1 if there are more stats to get and if bulkstat */ - /* should be called again (unused here, but used in dmapi) */ - -#if 0 - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; -#endif - - if (XFS_FORCED_SHUTDOWN(mp)) - return -XFS_ERROR(EIO); - - if (copy_from_user(&bulkreq, arg, sizeof(xfs_fsop_bulkreq_t))) - return -XFS_ERROR(EFAULT); - - if (copy_from_user(&inlast, bulkreq.lastip, sizeof(__s64))) - return -XFS_ERROR(EFAULT); - - if ((count = bulkreq.icount) <= 0) - return -XFS_ERROR(EINVAL); - - if (cmd == XFS_IOC_FSINUMBERS) - error = xfs_inumbers(mp, &inlast, &count, - bulkreq.ubuffer); - else if (cmd == XFS_IOC_FSBULKSTAT_SINGLE) - error = xfs_bulkstat_single(mp, &inlast, - bulkreq.ubuffer, &done); - else { /* XFS_IOC_FSBULKSTAT */ - if (count == 1 && inlast != 0) { - inlast++; - error = xfs_bulkstat_single(mp, &inlast, - bulkreq.ubuffer, &done); - } else { - error = xfs_bulkstat(mp, &inlast, &count, - (bulkstat_one_pf)xfs_bulkstat_one, NULL, - sizeof(xfs_bstat_t), bulkreq.ubuffer, - BULKSTAT_FG_QUICK, &done); - } - } - - if (error) - return -error; - - if (bulkreq.ocount != NULL) { - if (copy_to_user(bulkreq.lastip, &inlast, - sizeof(xfs_ino_t))) - return -XFS_ERROR(EFAULT); - - if (copy_to_user(bulkreq.ocount, &count, sizeof(count))) - return -XFS_ERROR(EFAULT); - } - - return 0; -} - -STATIC int -xfs_ioc_fsgeometry_v1( - xfs_mount_t *mp, - void __user *arg) -{ - xfs_fsop_geom_v1_t fsgeo; - int error; - - error = xfs_fs_geometry(mp, (xfs_fsop_geom_t *)&fsgeo, 3); - if (error) - return -error; - - if (copy_to_user(arg, &fsgeo, sizeof(fsgeo))) - return -XFS_ERROR(EFAULT); - return 0; -} - -STATIC int -xfs_ioc_fsgeometry( - xfs_mount_t *mp, - void __user *arg) -{ - xfs_fsop_geom_t fsgeo; - int error; - - error = xfs_fs_geometry(mp, &fsgeo, 4); - if (error) - goto error; - - printf ("xfs_ioc_fsgeometry: error? %d arg %p\n",error,arg); - -#if 0 - if (copy_to_user(arg, &fsgeo, sizeof(fsgeo))) - return XFS_ERROR(EFAULT); -#endif - memcpy(arg, &fsgeo, sizeof(fsgeo)); - - printf ("xfs_ioc_fsgeometry: error? %d arg %p\n",error,arg); -error: - return error; -} - -/* - * Linux extended inode flags interface. - */ -#define LINUX_XFLAG_SYNC 0x00000008 /* Synchronous updates */ -#define LINUX_XFLAG_IMMUTABLE 0x00000010 /* Immutable file */ -#define LINUX_XFLAG_APPEND 0x00000020 /* writes to file may only append */ -#define LINUX_XFLAG_NODUMP 0x00000040 /* do not dump file */ -#define LINUX_XFLAG_NOATIME 0x00000080 /* do not update atime */ - -STATIC unsigned int -xfs_merge_ioc_xflags( - unsigned int flags, - unsigned int start) -{ - unsigned int xflags = start; - - if (flags & LINUX_XFLAG_IMMUTABLE) - xflags |= XFS_XFLAG_IMMUTABLE; - else - xflags &= ~XFS_XFLAG_IMMUTABLE; - if (flags & LINUX_XFLAG_APPEND) - xflags |= XFS_XFLAG_APPEND; - else - xflags &= ~XFS_XFLAG_APPEND; - if (flags & LINUX_XFLAG_SYNC) - xflags |= XFS_XFLAG_SYNC; - else - xflags &= ~XFS_XFLAG_SYNC; - if (flags & LINUX_XFLAG_NOATIME) - xflags |= XFS_XFLAG_NOATIME; - else - xflags &= ~XFS_XFLAG_NOATIME; - if (flags & LINUX_XFLAG_NODUMP) - xflags |= XFS_XFLAG_NODUMP; - else - xflags &= ~XFS_XFLAG_NODUMP; - - return xflags; -} - -STATIC unsigned int -xfs_di2lxflags( - __uint16_t di_flags) -{ - unsigned int flags = 0; - - if (di_flags & XFS_DIFLAG_IMMUTABLE) - flags |= LINUX_XFLAG_IMMUTABLE; - if (di_flags & XFS_DIFLAG_APPEND) - flags |= LINUX_XFLAG_APPEND; - if (di_flags & XFS_DIFLAG_SYNC) - flags |= LINUX_XFLAG_SYNC; - if (di_flags & XFS_DIFLAG_NOATIME) - flags |= LINUX_XFLAG_NOATIME; - if (di_flags & XFS_DIFLAG_NODUMP) - flags |= LINUX_XFLAG_NODUMP; - return flags; -} - -STATIC int -xfs_ioc_xattr( - xfs_vnode_t *vp, - xfs_inode_t *ip, - struct file *filp, - unsigned int cmd, - void __user *arg) -{ - struct fsxattr fa; - struct xfs_vattr *vattr; - int error; - int attr_flags; - unsigned int flags; - - error = 0; - attr_flags = 0; - - vattr = kmem_alloc(sizeof(struct xfs_vattr), KM_SLEEP); - if (unlikely(!vattr)) - return ENOMEM; - - switch (cmd) { - case XFS_IOC_FSGETXATTR: { - vattr->va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | \ - XFS_AT_NEXTENTS | XFS_AT_PROJID; - XVOP_GETATTR(vp, vattr, 0, NULL, error); - if (unlikely(error)) { - break; - } - - fa.fsx_xflags = vattr->va_xflags; - fa.fsx_extsize = vattr->va_extsize; - fa.fsx_nextents = vattr->va_nextents; - fa.fsx_projid = vattr->va_projid; - - if (copy_to_user(arg, &fa, sizeof(fa))) { - error = EFAULT; - break; - } - break; - } - - case XFS_IOC_FSSETXATTR: { - if (copy_from_user(&fa, arg, sizeof(fa))) { - error = EFAULT; - break; - } - - attr_flags = 0; -#if 0 - if (filp->f_flags & (O_NDELAY|O_NONBLOCK)) - attr_flags |= ATTR_NONBLOCK; -#endif - - vattr->va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | XFS_AT_PROJID; - vattr->va_xflags = fa.fsx_xflags; - vattr->va_extsize = fa.fsx_extsize; - vattr->va_projid = fa.fsx_projid; - - XVOP_SETATTR(vp, vattr, attr_flags, NULL, error); -#if 0 - if (likely(!error)) - __vn_revalidate(vp, vattr); /* update flags */ -#endif - break; - } - - case XFS_IOC_FSGETXATTRA: { - vattr->va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | \ - XFS_AT_ANEXTENTS | XFS_AT_PROJID; - XVOP_GETATTR(vp, vattr, 0, NULL, error); - if (unlikely(error)) { - break; - } - - fa.fsx_xflags = vattr->va_xflags; - fa.fsx_extsize = vattr->va_extsize; - fa.fsx_nextents = vattr->va_anextents; - fa.fsx_projid = vattr->va_projid; - - if (copy_to_user(arg, &fa, sizeof(fa))) { - error = EFAULT; - break; - } - break; - } - - case XFS_IOC_GETXFLAGS: { - flags = xfs_di2lxflags(ip->i_d.di_flags); - if (copy_to_user(arg, &flags, sizeof(flags))) - error = EFAULT; - break; - } - - case XFS_IOC_SETXFLAGS: { - if (copy_from_user(&flags, arg, sizeof(flags))) { - error = EFAULT; - break; - } - - if (flags & ~(LINUX_XFLAG_IMMUTABLE | LINUX_XFLAG_APPEND | \ - LINUX_XFLAG_NOATIME | LINUX_XFLAG_NODUMP | \ - LINUX_XFLAG_SYNC)) { - error = EOPNOTSUPP; - break; - } - -#if 0 - attr_flags = 0; - if (filp->f_flags & (O_NDELAY|O_NONBLOCK)) - attr_flags |= ATTR_NONBLOCK; -#endif - - vattr->va_mask = XFS_AT_XFLAGS; - vattr->va_xflags = xfs_merge_ioc_xflags(flags, - xfs_ip2xflags(ip)); - - XVOP_SETATTR(vp, vattr, attr_flags, NULL, error); -#if 0 - if (likely(!error)) - __vn_revalidate(vp, vattr); /* update flags */ -#endif - break; - } - -#if 0 - case XFS_IOC_GETVERSION: { - flags = vn_to_inode(vp)->i_generation; - if (copy_to_user(arg, &flags, sizeof(flags))) - error = EFAULT; - break; - } -#endif - - default: - error = ENOTTY; - break; - } - - kmem_free(vattr,sizeof(struct xfs_vattr)); - return error; -} - -STATIC int -xfs_ioc_getbmap( - bhv_desc_t *bdp, - struct file *filp, - int ioflags, - unsigned int cmd, - void __user *arg) -{ - struct getbmap bm; - int iflags; - int error; - - if (copy_from_user(&bm, arg, sizeof(bm))) - return -XFS_ERROR(EFAULT); - - if (bm.bmv_count < 2) - return -XFS_ERROR(EINVAL); - - iflags = (cmd == XFS_IOC_GETBMAPA ? BMV_IF_ATTRFORK : 0); - if (ioflags & IO_INVIS) - iflags |= BMV_IF_NO_DMAPI_READ; - - error = xfs_getbmap(bdp, &bm, (struct getbmap __user *)arg+1, iflags); - if (error) - return -error; - - if (copy_to_user(arg, &bm, sizeof(bm))) - return -XFS_ERROR(EFAULT); - return 0; -} - -STATIC int -xfs_ioc_getbmapx( - bhv_desc_t *bdp, - void __user *arg) -{ - struct getbmapx bmx; - struct getbmap bm; - int iflags; - int error; - - printf("%s:%d\n",__FILE__,__LINE__); - if (copy_from_user(&bmx, arg, sizeof(bmx))) - return XFS_ERROR(EFAULT); - - printf("%s:%d\n",__FILE__,__LINE__); - if (bmx.bmv_count < 2) - return XFS_ERROR(EINVAL); - - /* - * Map input getbmapx structure to a getbmap - * structure for xfs_getbmap. - */ - GETBMAP_CONVERT(bmx, bm); - - iflags = bmx.bmv_iflags; - - if (iflags & (~BMV_IF_VALID)) - return XFS_ERROR(EINVAL); - - iflags |= BMV_IF_EXTENDED; - - printf("%s:%d arg+1 %p arg %p\n",__FILE__,__LINE__,(struct getbmapx __user *)arg+1,arg); - error = xfs_getbmap(bdp, &bm, (struct getbmapx __user *)arg+1, iflags); - if (error) - return error; - - printf("%s:%d\n",__FILE__,__LINE__); - GETBMAP_CONVERT(bm, bmx); - - printf("%s:%d\n",__FILE__,__LINE__); - if (copy_to_user(arg, &bmx, sizeof(bmx))) - return XFS_ERROR(EFAULT); - - printf("%s:%d\n",__FILE__,__LINE__); - return 0; -} - -#else - -int -xfs_ioctl( - bhv_desc_t *bdp, - struct inode *inode, - struct file *filp, - int ioflags, - u_long cmd, - unsigned long arg) -{ - return EINVAL; -} - -#endif diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_iops.h b/sys/gnu/fs/xfs/FreeBSD/xfs_iops.h deleted file mode 100644 index 8f585b6..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_iops.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ - */ -#ifndef __XFS_IOPS_H__ -#define __XFS_IOPS_H__ - -/* - * Extended system attributes. - * So far only POSIX ACLs are supported, but this will need to - * grow in time (capabilities, mandatory access control, etc). - */ -#define XFS_SYSTEM_NAMESPACE SYSTEM_POSIXACL - -/* - * Define a table of the namespaces XFS supports - */ -typedef int (*xattr_exists_t)(xfs_vnode_t *); - -typedef struct xattr_namespace { - char *name; - unsigned int namelen; - xattr_exists_t exists; -} xattr_namespace_t; - -#define SYSTEM_NAMES 0 -#define ROOT_NAMES 1 -#define USER_NAMES 2 -extern struct xattr_namespace *xfs_namespaces; - -extern int xfs_ioctl(struct bhv_desc *, struct inode *, struct file *, - int, u_long, void *); - -#endif /* __XFS_IOPS_H__ */ diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_mountops.c b/sys/gnu/fs/xfs/FreeBSD/xfs_mountops.c deleted file mode 100644 index 8597c6c..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_mountops.c +++ /dev/null @@ -1,500 +0,0 @@ -/* - * Copyright (c) 2001,2006 Alexander Kabaev, Russell Cattelan Digital Elves Inc. - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. - * - * $FreeBSD$ - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/kernel.h> -#include <sys/proc.h> -#include <sys/malloc.h> -#include <sys/vnode.h> -#include <sys/mount.h> -#include <sys/namei.h> - -#include <geom/geom.h> -#include <geom/geom_vfs.h> - -#include "xfs.h" -#include "xfs_types.h" -#include "xfs_bit.h" -#include "xfs_inum.h" -#include "xfs_log.h" -#include "xfs_trans.h" -#include "xfs_sb.h" -#include "xfs_ag.h" -#include "xfs_dir.h" -#include "xfs_dir2.h" -#include "xfs_dmapi.h" -#include "xfs_mount.h" -#include "xfs_alloc_btree.h" -#include "xfs_bmap_btree.h" -#include "xfs_ialloc_btree.h" -#include "xfs_btree.h" -#include "xfs_attr_sf.h" -#include "xfs_dir_sf.h" -#include "xfs_dir2_sf.h" -#include "xfs_dinode.h" -#include "xfs_ialloc.h" -#include "xfs_inode.h" -#include "xfs_alloc.h" -#include "xfs_rtalloc.h" -#include "xfs_bmap.h" -#include "xfs_error.h" -#include "xfs_rw.h" -#include "xfs_quota.h" -#include "xfs_fsops.h" -#include "xfs_clnt.h" - -#include <xfs_mountops.h> - -static MALLOC_DEFINE(M_XFSNODE, "XFS node", "XFS vnode private part"); - -static vfs_mount_t _xfs_mount; -static vfs_unmount_t _xfs_unmount; -static vfs_root_t _xfs_root; -static vfs_quotactl_t _xfs_quotactl; -static vfs_statfs_t _xfs_statfs; -static vfs_sync_t _xfs_sync; -static vfs_vget_t _xfs_vget; -static vfs_fhtovp_t _xfs_fhtovp; -static vfs_init_t _xfs_init; -static vfs_uninit_t _xfs_uninit; -static vfs_extattrctl_t _xfs_extattrctl; - -static b_strategy_t xfs_geom_strategy; - -static const char *xfs_opts[] = - { "from", "flags", "logbufs", "logbufsize", - "rtname", "logname", "iosizelog", "sunit", - "swidth", "export", - NULL }; - -static void -parse_int(struct mount *mp, const char *opt, int *val, int *error) -{ - char *tmp, *ep; - - tmp = vfs_getopts(mp->mnt_optnew, opt, error); - if (*error != 0) { - return; - } - if (tmp != NULL) { - *val = (int)strtol(tmp, &ep, 10); - if (*ep) { - *error = EINVAL; - return; - } - } -} - -static int -_xfs_param_copyin(struct mount *mp, struct thread *td) -{ - struct xfsmount *xmp = MNTTOXFS(mp); - struct xfs_mount_args *args = &xmp->m_args; - char *path; - char *fsname; - char *rtname; - char *logname; - int error; - - path = vfs_getopts(mp->mnt_optnew, "fspath", &error); - if (error) - return (error); - - bzero(args, sizeof(struct xfs_mount_args)); - args->logbufs = -1; - args->logbufsize = -1; - - parse_int(mp, "flags", &args->flags, &error); - if (error != 0 && error != ENOENT) - return error; - - args->flags |= XFSMNT_32BITINODES; - - parse_int(mp, "sunit", &args->sunit, &error); - if (error != 0 && error != ENOENT) - return error; - - parse_int(mp, "swidth", &args->swidth, &error); - if (error != 0 && error != ENOENT) - return error; - - parse_int(mp, "logbufs", &args->logbufs, &error); - if (error != 0 && error != ENOENT) - return error; - - parse_int(mp, "logbufsize", &args->logbufsize, &error); - if (error != 0 && error != ENOENT) - return error; - - fsname = vfs_getopts(mp->mnt_optnew, "from", &error); - if (error == 0 && fsname != NULL) { - strncpy(args->fsname, fsname, sizeof(args->fsname) - 1); - } - - logname = vfs_getopts(mp->mnt_optnew, "logname", &error); - if (error == 0 && logname != NULL) { - strncpy(args->logname, logname, sizeof(args->logname) - 1); - } - - rtname = vfs_getopts(mp->mnt_optnew, "rtname", &error); - if (error == 0 && rtname != NULL) { - strncpy(args->rtname, rtname, sizeof(args->rtname) - 1); - } - - strncpy(args->mtpt, path, sizeof(args->mtpt)); - - printf("fsname '%s' logname '%s' rtname '%s'\n" - "flags 0x%x sunit %d swidth %d logbufs %d logbufsize %d\n", - args->fsname, args->logname, args->rtname, args->flags, - args->sunit, args->swidth, args->logbufs, args->logbufsize); - - vfs_mountedfrom(mp, args->fsname); - - return (0); -} - -static int -_xfs_mount(struct mount *mp) -{ - struct xfsmount *xmp; - struct xfs_vnode *rootvp; - struct ucred *curcred; - struct vnode *rvp, *devvp; - struct cdev *ddev; - struct g_consumer *cp; - struct thread *td; - int error; - - td = curthread; - ddev = NULL; - cp = NULL; - - if (vfs_filteropt(mp->mnt_optnew, xfs_opts)) - return (EINVAL); - - if (mp->mnt_flag & MNT_UPDATE) - return (0); - if ((mp->mnt_flag & MNT_RDONLY) == 0) - return (EPERM); - - xmp = xfsmount_allocate(mp); - if (xmp == NULL) - return (ENOMEM); - - if((error = _xfs_param_copyin(mp, td)) != 0) - goto fail; - - curcred = td->td_ucred; - XVFS_MOUNT(XFSTOVFS(xmp), &xmp->m_args, curcred, error); - if (error) - goto fail; - - XVFS_ROOT(XFSTOVFS(xmp), &rootvp, error); - ddev = XFS_VFSTOM(XFSTOVFS(xmp))->m_ddev_targp->dev; - devvp = XFS_VFSTOM(XFSTOVFS(xmp))->m_ddev_targp->specvp; - if (error) - goto fail_unmount; - - if (ddev->si_iosize_max != 0) - mp->mnt_iosize_max = ddev->si_iosize_max; - if (mp->mnt_iosize_max > MAXPHYS) - mp->mnt_iosize_max = MAXPHYS; - - mp->mnt_flag |= MNT_LOCAL; - mp->mnt_stat.f_fsid.val[0] = dev2udev(ddev); - mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum; - - if ((error = VFS_STATFS(mp, &mp->mnt_stat)) != 0) - goto fail_unmount; - - rvp = rootvp->v_vnode; - rvp->v_vflag |= VV_ROOT; - VN_RELE(rootvp); - - return (0); - - fail_unmount: - XVFS_UNMOUNT(XFSTOVFS(xmp), 0, curcred, error); - - if (devvp != NULL) { - cp = devvp->v_bufobj.bo_private; - if (cp != NULL) { - DROP_GIANT(); - g_topology_lock(); - g_vfs_close(cp); - g_topology_unlock(); - PICKUP_GIANT(); - } - } - - fail: - if (xmp != NULL) - xfsmount_deallocate(xmp); - - return (error); -} - -/* - * Free reference to null layer - */ -static int -_xfs_unmount(mp, mntflags) - struct mount *mp; - int mntflags; -{ - struct vnode *devvp; - struct g_consumer *cp; - int error; - cp = NULL; - devvp = NULL; - - devvp = XFS_VFSTOM((MNTTOVFS(mp)))->m_ddev_targp->specvp; - if (devvp != NULL) - cp = devvp->v_bufobj.bo_private; - - XVFS_UNMOUNT(MNTTOVFS(mp), 0, curthread->td_ucred, error); - if (error == 0) { - if (cp != NULL) { - DROP_GIANT(); - g_topology_lock(); - g_vfs_close(cp); - g_topology_unlock(); - PICKUP_GIANT(); - } - } - return (error); -} - -static int -_xfs_root(mp, flags, vpp) - struct mount *mp; - int flags; - struct vnode **vpp; -{ - xfs_vnode_t *vp; - int error; - - XVFS_ROOT(MNTTOVFS(mp), &vp, error); - if (error == 0) { - *vpp = vp->v_vnode; - VOP_LOCK(*vpp, flags); - } - return (error); -} - -static int -_xfs_quotactl(mp, cmd, uid, arg) - struct mount *mp; - int cmd; - uid_t uid; - void *arg; -{ - printf("xfs_quotactl\n"); - return EOPNOTSUPP; -} - -static int -_xfs_statfs(mp, sbp) - struct mount *mp; - struct statfs *sbp; -{ - int error; - - XVFS_STATVFS(MNTTOVFS(mp), sbp, NULL, error); - if (error) - return error; - - /* Fix up the values XFS statvfs calls does not know about. */ - sbp->f_iosize = sbp->f_bsize; - - return (error); -} - -static int -_xfs_sync(mp, waitfor) - struct mount *mp; - int waitfor; -{ - int error; - int flags = SYNC_FSDATA|SYNC_ATTR|SYNC_REFCACHE; - - if (waitfor == MNT_WAIT) - flags |= SYNC_WAIT; - else if (waitfor == MNT_LAZY) - flags |= SYNC_BDFLUSH; - XVFS_SYNC(MNTTOVFS(mp), flags, curthread->td_ucred, error); - return (error); -} - -static int -_xfs_vget(mp, ino, flags, vpp) - struct mount *mp; - ino_t ino; - int flags; - struct vnode **vpp; -{ - xfs_vnode_t *vp = NULL; - int error; - - printf("XVFS_GET_VNODE(MNTTOVFS(mp), &vp, ino, error);\n"); - error = ENOSYS; - if (error == 0) - *vpp = vp->v_vnode; - return (error); -} - -static int -_xfs_fhtovp(mp, fidp, flags, vpp) - struct mount *mp; - struct fid *fidp; - int flags; - struct vnode **vpp; -{ - printf("xfs_fhtovp\n"); - return ENOSYS; -} - -static int -_xfs_extattrctl(struct mount *mp, int cm, - struct vnode *filename_v, - int attrnamespace, const char *attrname) -{ - printf("xfs_extattrctl\n"); - return ENOSYS; -} - -int -_xfs_init(vfsp) - struct vfsconf *vfsp; -{ - int error; - - error = init_xfs_fs(); - - return (error); -} - -int -_xfs_uninit(vfsp) - struct vfsconf *vfsp; -{ - exit_xfs_fs(); - return 0; -} - -static struct vfsops xfs_fsops = { - .vfs_mount = _xfs_mount, - .vfs_unmount = _xfs_unmount, - .vfs_root = _xfs_root, - .vfs_quotactl = _xfs_quotactl, - .vfs_statfs = _xfs_statfs, - .vfs_sync = _xfs_sync, - .vfs_vget = _xfs_vget, - .vfs_fhtovp = _xfs_fhtovp, - .vfs_init = _xfs_init, - .vfs_uninit = _xfs_uninit, - .vfs_extattrctl = _xfs_extattrctl, -}; - -VFS_SET(xfs_fsops, xfs, VFCF_READONLY); - -/* - * Copy GEOM VFS functions here to provide a conveniet place to - * track all XFS-related IO without being distracted by other - * filesystems which happen to be mounted on the machine at the - * same time. - */ - -static void -xfs_geom_biodone(struct bio *bip) -{ - struct buf *bp; - - if (bip->bio_error) { - printf("g_vfs_done():"); - g_print_bio(bip); - printf("error = %d\n", bip->bio_error); - } - bp = bip->bio_caller2; - bp->b_error = bip->bio_error; - bp->b_ioflags = bip->bio_flags; - if (bip->bio_error) - bp->b_ioflags |= BIO_ERROR; - bp->b_resid = bp->b_bcount - bip->bio_completed; - g_destroy_bio(bip); - mtx_lock(&Giant); - bufdone(bp); - mtx_unlock(&Giant); -} - -static void -xfs_geom_strategy(struct bufobj *bo, struct buf *bp) -{ - struct g_consumer *cp; - struct bio *bip; - - cp = bo->bo_private; - G_VALID_CONSUMER(cp); - - bip = g_alloc_bio(); - bip->bio_cmd = bp->b_iocmd; - bip->bio_offset = bp->b_iooffset; - bip->bio_data = bp->b_data; - bip->bio_done = xfs_geom_biodone; - bip->bio_caller2 = bp; - bip->bio_length = bp->b_bcount; - g_io_request(bip, cp); -} - -static int -xfs_geom_bufwrite(struct buf *bp) -{ - return bufwrite(bp); -} - -static int -xfs_geom_bufsync(struct bufobj *bo, int waitfor) -{ - - return (bufsync(bo, waitfor)); -} - -static void -xfs_geom_bufbdflush(struct bufobj *bo, struct buf *bp) -{ - bufbdflush(bo, bp); -} - -struct buf_ops xfs_bo_ops = { - .bop_name = "XFS", - .bop_write = xfs_geom_bufwrite, - .bop_strategy = xfs_geom_strategy, - .bop_sync = xfs_geom_bufsync, - .bop_bdflush = xfs_geom_bufbdflush, -}; diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_mountops.h b/sys/gnu/fs/xfs/FreeBSD/xfs_mountops.h deleted file mode 100644 index c8a766d..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_mountops.h +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * Copyright (c) 2001 Alexander Kabaev - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. - * - * $FreeBSD$ - */ -#ifndef _XFS_XFS_H_ -#define _XFS_XFS_H_ - -#define XFSFS_VMAJOR 0 -#define XFS_VMINOR 1 -#define XFS_VERSION ((XFS_VMAJOR << 16) | XFS_VMINOR) -#define XFS_NAME "xfs" - -#ifdef _KERNEL - -struct xfsmount { - struct xfs_mount_args m_args; /* Mount parameters */ - struct mount * m_mp; /* Back pointer */ - xfs_vfs_t m_vfs; /* SHOULD BE FIRST */ -}; - -#define XFSTOMNT(xmp) ((xmp)->m_mp) -#define XFSTOVFS(xmp) (&(xmp)->m_vfs) - -#define MNTTOXFS(mp) ((struct xfsmount *)((mp)->mnt_data)) -#define MNTTOVFS(mp) XFSTOVFS(MNTTOXFS(mp)) - -#define VFSTOMNT(vfsp) (vfsp)->vfs_mp -#define VFSTOXFS(vfsp) MNTTOXFS(VFSTOMNT(vfsp)) - -struct xfsmount *xfsmount_allocate(struct mount *mp); -void xfsmount_deallocate(struct xfsmount *xmp); - -#endif /* _KERNEL */ - -#endif /* _XFS_XFS_H*/ - diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_node.h b/sys/gnu/fs/xfs/FreeBSD/xfs_node.h deleted file mode 100644 index d8b613c..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_node.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef __XFS_NODE_H__ -#define __XFS_NODE_H__ - -/* - * Save one allocation on FreeBSD and always allocate both inode and - * xfs_vnode struct as a single memory block. - */ -struct xfs_node -{ - struct xfs_inode n_inode; - struct xfs_vnode n_vnode; -}; - -#define XFS_CAST_IP2VP(ip) (&((struct xfs_node *)(ip))->n_vnode) - -#endif /* __XFS_NODE_H__ */ diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_stats.c b/sys/gnu/fs/xfs/FreeBSD/xfs_stats.c deleted file mode 100644 index 40b3056..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_stats.c +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ - */ - -#include "xfs.h" - -struct xfsstats xfsstats; - -STATIC int -xfs_read_xfsstats( - char *buffer, - char **start, - off_t offset, - int count, - int *eof, - void *data) -{ - int i, j, len; - static struct xstats_entry { - char *desc; - int endpoint; - } xstats[] = { - { "extent_alloc", XFSSTAT_END_EXTENT_ALLOC }, - { "abt", XFSSTAT_END_ALLOC_BTREE }, - { "blk_map", XFSSTAT_END_BLOCK_MAPPING }, - { "bmbt", XFSSTAT_END_BLOCK_MAP_BTREE }, - { "dir", XFSSTAT_END_DIRECTORY_OPS }, - { "trans", XFSSTAT_END_TRANSACTIONS }, - { "ig", XFSSTAT_END_INODE_OPS }, - { "log", XFSSTAT_END_LOG_OPS }, - { "push_ail", XFSSTAT_END_TAIL_PUSHING }, - { "xstrat", XFSSTAT_END_WRITE_CONVERT }, - { "rw", XFSSTAT_END_READ_WRITE_OPS }, - { "attr", XFSSTAT_END_ATTRIBUTE_OPS }, - { "icluster", XFSSTAT_END_INODE_CLUSTER }, - { "vnodes", XFSSTAT_END_VNODE_OPS }, - }; - - for (i=j=len = 0; i < sizeof(xstats)/sizeof(struct xstats_entry); i++) { - len += sprintf(buffer + len, "%s", xstats[i].desc); - /* inner loop does each group */ - while (j < xstats[i].endpoint) { - len += sprintf(buffer + len, " %u", - *(((__u32*)&xfsstats) + j)); - j++; - } - buffer[len++] = '\n'; - } - /* extra precision counters */ - len += sprintf(buffer + len, "xpc %ju %ju %ju\n", - (uintmax_t)xfsstats.xs_xstrat_bytes, - (uintmax_t)xfsstats.xs_write_bytes, - (uintmax_t)xfsstats.xs_read_bytes); - - if (offset >= len) { - *start = buffer; - *eof = 1; - return 0; - } - *start = buffer + offset; - if ((len -= offset) > count) - return count; - *eof = 1; - - return len; -} - -void -xfs_init_procfs(void) -{ - if (&xfs_read_xfsstats != NULL); -} - -void -xfs_cleanup_procfs(void) -{ -} diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_stats.h b/sys/gnu/fs/xfs/FreeBSD/xfs_stats.h deleted file mode 100644 index 04ddc95..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_stats.h +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ - */ -#ifndef __XFS_STATS_H__ -#define __XFS_STATS_H__ - - -#if !defined(XFS_STATS_OFF) - -/* - * XFS global statistics - */ -struct xfsstats { -# define XFSSTAT_END_EXTENT_ALLOC 4 - __uint32_t xs_allocx; - __uint32_t xs_allocb; - __uint32_t xs_freex; - __uint32_t xs_freeb; -# define XFSSTAT_END_ALLOC_BTREE (XFSSTAT_END_EXTENT_ALLOC+4) - __uint32_t xs_abt_lookup; - __uint32_t xs_abt_compare; - __uint32_t xs_abt_insrec; - __uint32_t xs_abt_delrec; -# define XFSSTAT_END_BLOCK_MAPPING (XFSSTAT_END_ALLOC_BTREE+7) - __uint32_t xs_blk_mapr; - __uint32_t xs_blk_mapw; - __uint32_t xs_blk_unmap; - __uint32_t xs_add_exlist; - __uint32_t xs_del_exlist; - __uint32_t xs_look_exlist; - __uint32_t xs_cmp_exlist; -# define XFSSTAT_END_BLOCK_MAP_BTREE (XFSSTAT_END_BLOCK_MAPPING+4) - __uint32_t xs_bmbt_lookup; - __uint32_t xs_bmbt_compare; - __uint32_t xs_bmbt_insrec; - __uint32_t xs_bmbt_delrec; -# define XFSSTAT_END_DIRECTORY_OPS (XFSSTAT_END_BLOCK_MAP_BTREE+4) - __uint32_t xs_dir_lookup; - __uint32_t xs_dir_create; - __uint32_t xs_dir_remove; - __uint32_t xs_dir_getdents; -# define XFSSTAT_END_TRANSACTIONS (XFSSTAT_END_DIRECTORY_OPS+3) - __uint32_t xs_trans_sync; - __uint32_t xs_trans_async; - __uint32_t xs_trans_empty; -# define XFSSTAT_END_INODE_OPS (XFSSTAT_END_TRANSACTIONS+7) - __uint32_t xs_ig_attempts; - __uint32_t xs_ig_found; - __uint32_t xs_ig_frecycle; - __uint32_t xs_ig_missed; - __uint32_t xs_ig_dup; - __uint32_t xs_ig_reclaims; - __uint32_t xs_ig_attrchg; -# define XFSSTAT_END_LOG_OPS (XFSSTAT_END_INODE_OPS+5) - __uint32_t xs_log_writes; - __uint32_t xs_log_blocks; - __uint32_t xs_log_noiclogs; - __uint32_t xs_log_force; - __uint32_t xs_log_force_sleep; -# define XFSSTAT_END_TAIL_PUSHING (XFSSTAT_END_LOG_OPS+10) - __uint32_t xs_try_logspace; - __uint32_t xs_sleep_logspace; - __uint32_t xs_push_ail; - __uint32_t xs_push_ail_success; - __uint32_t xs_push_ail_pushbuf; - __uint32_t xs_push_ail_pinned; - __uint32_t xs_push_ail_locked; - __uint32_t xs_push_ail_flushing; - __uint32_t xs_push_ail_restarts; - __uint32_t xs_push_ail_flush; -# define XFSSTAT_END_WRITE_CONVERT (XFSSTAT_END_TAIL_PUSHING+2) - __uint32_t xs_xstrat_quick; - __uint32_t xs_xstrat_split; -# define XFSSTAT_END_READ_WRITE_OPS (XFSSTAT_END_WRITE_CONVERT+2) - __uint32_t xs_write_calls; - __uint32_t xs_read_calls; -# define XFSSTAT_END_ATTRIBUTE_OPS (XFSSTAT_END_READ_WRITE_OPS+4) - __uint32_t xs_attr_get; - __uint32_t xs_attr_set; - __uint32_t xs_attr_remove; - __uint32_t xs_attr_list; -# define XFSSTAT_END_INODE_CLUSTER (XFSSTAT_END_ATTRIBUTE_OPS+3) - __uint32_t xs_iflush_count; - __uint32_t xs_icluster_flushcnt; - __uint32_t xs_icluster_flushinode; -# define XFSSTAT_END_VNODE_OPS (XFSSTAT_END_INODE_CLUSTER+8) - __uint32_t vn_active; /* # vnodes not on free lists */ - __uint32_t vn_alloc; /* # times vn_alloc called */ - __uint32_t vn_get; /* # times vn_get called */ - __uint32_t vn_hold; /* # times vn_hold called */ - __uint32_t vn_rele; /* # times vn_rele called */ - __uint32_t vn_reclaim; /* # times vn_reclaim called */ - __uint32_t vn_remove; /* # times vn_remove called */ - __uint32_t vn_free; /* # times vn_free called */ -#define XFSSTAT_END_BUF (XFSSTAT_END_VNODE_OPS+9) - __uint32_t pb_get; - __uint32_t pb_create; - __uint32_t pb_get_locked; - __uint32_t pb_get_locked_waited; - __uint32_t pb_busy_locked; - __uint32_t pb_miss_locked; - __uint32_t pb_page_retries; - __uint32_t pb_page_found; - __uint32_t pb_get_read; -/* Extra precision counters */ - __uint64_t xs_xstrat_bytes; - __uint64_t xs_write_bytes; - __uint64_t xs_read_bytes; -}; - -extern struct xfsstats xfsstats; - -# define XFS_STATS_INC(count) ( xfsstats.count++ ) -# define XFS_STATS_DEC(count) ( xfsstats.count-- ) -# define XFS_STATS_ADD(count, inc) ( xfsstats.count += (inc) ) - -extern void xfs_init_procfs(void); -extern void xfs_cleanup_procfs(void); - - -#else /* !CONFIG_PROC_FS */ - -# define XFS_STATS_INC(count) -# define XFS_STATS_DEC(count) -# define XFS_STATS_ADD(count, inc) - -static __inline void xfs_init_procfs(void) { }; -static __inline void xfs_cleanup_procfs(void) { }; - -#endif /* !CONFIG_PROC_FS */ - -#endif /* __XFS_STATS_H__ */ - diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_super.c b/sys/gnu/fs/xfs/FreeBSD/xfs_super.c deleted file mode 100644 index 747a5da..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_super.c +++ /dev/null @@ -1,279 +0,0 @@ -/* - * Copyright (c) 2000-2005 Silicon Graphics, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include "xfs.h" -#include "xfs_bit.h" -#include "xfs_log.h" -#include "xfs_clnt.h" -#include "xfs_inum.h" -#include "xfs_trans.h" -#include "xfs_sb.h" -#include "xfs_ag.h" -#include "xfs_dir.h" -#include "xfs_dir2.h" -#include "xfs_alloc.h" -#include "xfs_dmapi.h" -#include "xfs_quota.h" -#include "xfs_mount.h" -#include "xfs_bmap_btree.h" -#include "xfs_alloc_btree.h" -#include "xfs_ialloc_btree.h" -#include "xfs_dir_sf.h" -#include "xfs_dir2_sf.h" -#include "xfs_attr_sf.h" -#include "xfs_dinode.h" -#include "xfs_inode.h" -#include "xfs_btree.h" -#include "xfs_ialloc.h" -#include "xfs_bmap.h" -#include "xfs_rtalloc.h" -#include "xfs_error.h" -#include "xfs_itable.h" -#include "xfs_rw.h" -#include "xfs_acl.h" -#include "xfs_cap.h" -#include "xfs_mac.h" -#include "xfs_attr.h" -#include "xfs_buf_item.h" -#include "xfs_utils.h" -#include "xfs_version.h" -#include "xfs_buf.h" - -#include <sys/priv.h> - -#include <geom/geom.h> -#include <geom/geom_vfs.h> - -extern struct vop_vector xfs_fifoops; -extern struct xfs_vnodeops xfs_vnodeops; - -__uint64_t -xfs_max_file_offset( - unsigned int blockshift) -{ - - return (OFF_MAX); -} - -void -xfs_initialize_vnode( - bhv_desc_t *bdp, - xfs_vnode_t *xvp, - bhv_desc_t *inode_bhv, - int unlock) -{ - xfs_inode_t *ip = XFS_BHVTOI(inode_bhv); - - if (!inode_bhv->bd_vobj) { - xvp->v_vfsp = bhvtovfs(bdp); - bhv_desc_init(inode_bhv, ip, xvp, &xfs_vnodeops); - bhv_insert(VN_BHV_HEAD(xvp), inode_bhv); - } - - /* - * XXX: Use VNON as an indication of freshly allocated vnode - * which need to be initialized and unlocked. - * This is _not_ like the same place in Linux version of - * routine. - */ - - if (xvp->v_vnode->v_type != VNON) - return; - - xvp->v_vnode->v_type = IFTOVT(ip->i_d.di_mode); - - if (xvp->v_vnode->v_type == VFIFO) - xvp->v_vnode->v_op = &xfs_fifoops; - - ASSERT_VOP_LOCKED(xvp->v_vnode, "xfs_initialize_vnode"); - - /* For new inodes we need to set the ops vectors, - * and unlock the inode. - */ - if (ip->i_d.di_mode != 0 && unlock) - VOP_UNLOCK(xvp->v_vnode, 0); -} - -#if 0 -struct vnode * -xfs_get_inode( - bhv_desc_t *bdp, - xfs_ino_t ino, - int flags) -{ - return NULL; -} -#endif - -/*ARGSUSED*/ -int -xfs_blkdev_get( - xfs_mount_t *mp, - const char *name, - struct vnode **bdevp) -{ - struct nameidata nd; - struct nameidata *ndp = &nd; - int error, ronly; - struct thread *td; - struct vnode *devvp; - struct g_consumer *cp; - struct g_provider *pp; - accmode_t accmode; - - td = curthread; - - NDINIT(ndp, LOOKUP, FOLLOW, UIO_SYSSPACE, name, td); - if ((error = namei(ndp)) != 0) - return (error); - NDFREE(ndp, NDF_ONLY_PNBUF); - devvp = ndp->ni_vp; - - if (!vn_isdisk(devvp, &error)) { - vrele(devvp); - return (error); - } - - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); - - ronly = ((XFS_MTOVFS(mp)->vfs_flag & VFS_RDONLY) != 0); - accmode = VREAD; - if (!ronly) - accmode |= VWRITE; - error = VOP_ACCESS(devvp, accmode, td->td_ucred, td); - if (error) - error = priv_check(td, PRIV_VFS_MOUNT_PERM); - if (error) { - vput(devvp); - return (error); - } - - DROP_GIANT(); - g_topology_lock(); - - /* - * XXX: Do not allow more than one consumer to open a device - * associated with a particular GEOM provider. - * This disables multiple read-only mounts of a device, - * but it gets rid of panics in bmemfree() when you try to - * mount the same device more than once. - * During mounting, XFS does a bread() of the superblock, but does - * not brelse() it. A subsequent mount of the same device - * will try to bread() the superblock, resulting in a panic in - * bremfree(), "buffer not on queue". - */ - pp = g_dev_getprovider(devvp->v_rdev); - if ((pp != NULL) && ((pp->acr | pp->acw | pp->ace ) != 0)) - error = EPERM; - else - error = g_vfs_open(devvp, &cp, "xfs", ronly ? 0 : 1); - - g_topology_unlock(); - PICKUP_GIANT(); - - if (error) { - vput(devvp); - return (error); - } - VOP_UNLOCK(devvp, 0); - - devvp->v_bufobj.bo_private = cp; - devvp->v_bufobj.bo_ops = &xfs_bo_ops; - - *bdevp = devvp; - return (0); -} - -void -xfs_blkdev_put( - struct vnode *devvp) -{ - struct g_consumer *cp; - - if (devvp == NULL) - return; - - vinvalbuf(devvp, V_SAVE, 0, 0); - - cp = devvp->v_bufobj.bo_private; - DROP_GIANT(); - g_topology_lock(); - g_wither_geom_close(cp->geom, ENXIO); - g_topology_unlock(); - PICKUP_GIANT(); - - vrele(devvp); -} - -void -xfs_mountfs_check_barriers(xfs_mount_t *mp) -{ - printf("xfs_mountfs_check_barriers NI\n"); -} - -void -xfs_flush_inode( - xfs_inode_t *ip) -{ - printf("xfs_flush_inode NI\n"); -} - -void -xfs_flush_device( - xfs_inode_t *ip) -{ - printf("xfs_flush_device NI\n"); - xfs_log_force(ip->i_mount, (xfs_lsn_t)0, XFS_LOG_FORCE|XFS_LOG_SYNC); -} - - -void -xfs_blkdev_issue_flush( - xfs_buftarg_t *buftarg) -{ - printf("xfs_blkdev_issue_flush NI\n"); -} - -int -init_xfs_fs( void ) -{ - static const char message[] = - XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled\n"; - - printf(message); - - vn_init(); - xfs_init(); - uuid_init(); -#ifdef RMC - vfs_initdmapi(); -#endif - vfs_initquota(); - - return 0; -} - -void -exit_xfs_fs(void) -{ - xfs_cleanup(); - vfs_exitquota(); -#ifdef RMC - vfs_exitdmapi(); -#endif -} - diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_super.h b/sys/gnu/fs/xfs/FreeBSD/xfs_super.h deleted file mode 100644 index 0180451..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_super.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2000-2005 Silicon Graphics, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#ifndef __XFS_SUPER_H__ -#define __XFS_SUPER_H__ - -#ifdef CONFIG_XFS_DMAPI -# define vfs_insertdmapi(vfs) vfs_insertops(vfsp, &xfs_dmops) -# define vfs_initdmapi() dmapi_init() -# define vfs_exitdmapi() dmapi_uninit() -#else -# define vfs_insertdmapi(vfs) do { } while (0) -# define vfs_initdmapi() do { } while (0) -# define vfs_exitdmapi() do { } while (0) -#endif - -#ifdef CONFIG_XFS_QUOTA -# define vfs_insertquota(vfs) vfs_insertops(vfsp, &xfs_qmops) -# define vfs_initquota() xfs_qm_init() -# define vfs_exitquota() xfs_qm_exit() -#else -# define vfs_insertquota(vfs) do { } while (0) -# define vfs_initquota() do { } while (0) -# define vfs_exitquota() do { } while (0) -#endif - -#ifdef CONFIG_XFS_POSIX_ACL -# define XFS_ACL_STRING "ACLs, " -# define set_posix_acl_flag(sb) ((sb)->s_flags |= MS_POSIXACL) -#else -# define XFS_ACL_STRING -# define set_posix_acl_flag(sb) do { } while (0) -#endif - -#ifdef CONFIG_XFS_SECURITY -# define XFS_SECURITY_STRING "security attributes, " -# define ENOSECURITY 0 -#else -# define XFS_SECURITY_STRING -# define ENOSECURITY EOPNOTSUPP -#endif - -#ifdef CONFIG_XFS_RT -# define XFS_REALTIME_STRING "realtime, " -#else -# define XFS_REALTIME_STRING -#endif - -#if XFS_BIG_BLKNOS -# if XFS_BIG_INUMS -# define XFS_BIGFS_STRING "large block/inode numbers, " -# else -# define XFS_BIGFS_STRING "large block numbers, " -# endif -#else -# define XFS_BIGFS_STRING -#endif - -#ifdef CONFIG_XFS_TRACE -# define XFS_TRACE_STRING "tracing, " -#else -# define XFS_TRACE_STRING -#endif - -#ifdef XFSDEBUG -# define XFS_DBG_STRING "debug" -#else -# define XFS_DBG_STRING "no debug" -#endif - -#define XFS_BUILD_OPTIONS XFS_ACL_STRING \ - XFS_SECURITY_STRING \ - XFS_REALTIME_STRING \ - XFS_BIGFS_STRING \ - XFS_TRACE_STRING \ - XFS_DBG_STRING /* DBG must be last */ - -struct xfs_inode; -struct xfs_mount; -struct xfs_buftarg; - -extern __uint64_t xfs_max_file_offset(unsigned int); - -extern void xfs_initialize_vnode(bhv_desc_t *, xfs_vnode_t *, bhv_desc_t *, int); - -extern void xfs_flush_inode(struct xfs_inode *); -extern void xfs_flush_device(struct xfs_inode *); - -extern int xfs_blkdev_get(struct xfs_mount *, const char *, - struct block_device **); -extern void xfs_blkdev_put(struct block_device *); -extern void xfs_blkdev_issue_flush(struct xfs_buftarg *); - -extern struct export_operations xfs_export_operations; - -extern int init_xfs_fs(void); -extern void exit_xfs_fs(void); - -#endif /* __XFS_SUPER_H__ */ diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_sysctl.c b/sys/gnu/fs/xfs/FreeBSD/xfs_sysctl.c deleted file mode 100644 index 9ba2d45..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_sysctl.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2001-2002 Silicon Graphics, Inc. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ - */ - -#include "xfs.h" - -void -xfs_sysctl_register(void) -{ -} - -void -xfs_sysctl_unregister(void) -{ -} diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_sysctl.h b/sys/gnu/fs/xfs/FreeBSD/xfs_sysctl.h deleted file mode 100644 index fa68ff0..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_sysctl.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2001-2005 Silicon Graphics, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#ifndef __XFS_SYSCTL_H__ -#define __XFS_SYSCTL_H__ - -/* - * Tunable xfs parameters - */ - -typedef struct xfs_sysctl_val { - int min; - int val; - int max; -} xfs_sysctl_val_t; - -typedef struct xfs_param { - xfs_sysctl_val_t refcache_size; /* Size of NFS reference cache. */ - xfs_sysctl_val_t refcache_purge;/* # of entries to purge each time. */ - xfs_sysctl_val_t restrict_chown;/* Root/non-root can give away files.*/ - xfs_sysctl_val_t sgid_inherit; /* Inherit S_ISGID if process' GID is - * not a member of parent dir GID. */ - xfs_sysctl_val_t symlink_mode; /* Link creat mode affected by umask */ - xfs_sysctl_val_t panic_mask; /* bitmask to cause panic on errors. */ - xfs_sysctl_val_t error_level; /* Degree of reporting for problems */ - xfs_sysctl_val_t syncd_timer; /* Interval between xfssyncd wakeups */ - xfs_sysctl_val_t stats_clear; /* Reset all XFS statistics to zero. */ - xfs_sysctl_val_t probe_dmapi; /* probe for DMAPI module on mount. */ - xfs_sysctl_val_t probe_ioops; /* probe for an IO module on mount. */ - xfs_sysctl_val_t probe_quota; /* probe for quota module on mount. */ - xfs_sysctl_val_t inherit_sync; /* Inherit the "sync" inode flag. */ - xfs_sysctl_val_t inherit_nodump;/* Inherit the "nodump" inode flag. */ - xfs_sysctl_val_t inherit_noatim;/* Inherit the "noatime" inode flag. */ - xfs_sysctl_val_t xfs_buf_timer; /* Interval between xfsbufd wakeups. */ - xfs_sysctl_val_t xfs_buf_age; /* Metadata buffer age before flush. */ - xfs_sysctl_val_t inherit_nosym; /* Inherit the "nosymlinks" flag. */ - xfs_sysctl_val_t rotorstep; /* inode32 AG rotoring control knob */ -} xfs_param_t; - -/* - * xfs_error_level: - * - * How much error reporting will be done when internal problems are - * encountered. These problems normally return an EFSCORRUPTED to their - * caller, with no other information reported. - * - * 0 No error reports - * 1 Report EFSCORRUPTED errors that will cause a filesystem shutdown - * 5 Report all EFSCORRUPTED errors (all of the above errors, plus any - * additional errors that are known to not cause shutdowns) - * - * xfs_panic_mask bit 0x8 turns the error reports into panics - */ - -enum { - /* XFS_REFCACHE_SIZE = 1 */ - /* XFS_REFCACHE_PURGE = 2 */ - XFS_RESTRICT_CHOWN = 3, - XFS_SGID_INHERIT = 4, - XFS_SYMLINK_MODE = 5, - XFS_PANIC_MASK = 6, - XFS_ERRLEVEL = 7, - XFS_SYNCD_TIMER = 8, - XFS_PROBE_DMAPI = 9, - XFS_PROBE_IOOPS = 10, - XFS_PROBE_QUOTA = 11, - XFS_STATS_CLEAR = 12, - XFS_INHERIT_SYNC = 13, - XFS_INHERIT_NODUMP = 14, - XFS_INHERIT_NOATIME = 15, - XFS_BUF_TIMER = 16, - XFS_BUF_AGE = 17, - /* XFS_IO_BYPASS = 18 */ - XFS_INHERIT_NOSYM = 19, - XFS_ROTORSTEP = 20, -}; - -extern xfs_param_t xfs_params; - -#ifdef CONFIG_SYSCTL -extern void xfs_sysctl_register(void); -extern void xfs_sysctl_unregister(void); -#else -# define xfs_sysctl_register() do { } while (0) -# define xfs_sysctl_unregister() do { } while (0) -#endif /* CONFIG_SYSCTL */ - -#endif /* __XFS_SYSCTL_H__ */ diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_version.h b/sys/gnu/fs/xfs/FreeBSD/xfs_version.h deleted file mode 100644 index 96f9639..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_version.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2001-2002 Silicon Graphics, Inc. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ - */ - -/* - * Dummy file that can contain a timestamp to put into the - * XFS init string, to help users keep track of what they're - * running - */ - -#ifndef __XFS_VERSION_H__ -#define __XFS_VERSION_H__ - -#define XFS_VERSION_STRING "SGI XFS" - -#endif /* __XFS_VERSION_H__ */ diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_vfs.c b/sys/gnu/fs/xfs/FreeBSD/xfs_vfs.c deleted file mode 100644 index ee405b5..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_vfs.c +++ /dev/null @@ -1,356 +0,0 @@ -/* - * Copyright (c) 2000-2005 Silicon Graphics, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include "xfs.h" -#include "xfs_fs.h" -#include "xfs_inum.h" -#include "xfs_log.h" -#include "xfs_clnt.h" -#include "xfs_trans.h" -#include "xfs_sb.h" -#include "xfs_ag.h" -#include "xfs_dir.h" -#include "xfs_dir2.h" -#include "xfs_imap.h" -#include "xfs_alloc.h" -#include "xfs_dmapi.h" -#include "xfs_mount.h" -#include "xfs_quota.h" - -#include "xfs_mountops.h" - -int -xvfs_mount( - struct bhv_desc *bdp, - struct xfs_mount_args *args, - struct cred *cr) -{ - struct bhv_desc *next = bdp; - - ASSERT(next); - while (! (bhvtovfsops(next))->xvfs_mount) - next = BHV_NEXT(next); - return ((*bhvtovfsops(next)->xvfs_mount)(next, args, cr)); -} - -int -xvfs_parseargs( - struct bhv_desc *bdp, - char *s, - struct xfs_mount_args *args, - int f) -{ - struct bhv_desc *next = bdp; - - ASSERT(next); - while (! (bhvtovfsops(next))->xvfs_parseargs) - next = BHV_NEXT(next); - return ((*bhvtovfsops(next)->xvfs_parseargs)(next, s, args, f)); -} - -int -xvfs_showargs( - struct bhv_desc *bdp, - struct sbuf *m) -{ - struct bhv_desc *next = bdp; - - ASSERT(next); - while (! (bhvtovfsops(next))->xvfs_showargs) - next = BHV_NEXT(next); - return ((*bhvtovfsops(next)->xvfs_showargs)(next, m)); -} - -int -xvfs_unmount( - struct bhv_desc *bdp, - int fl, - struct cred *cr) -{ - struct bhv_desc *next = bdp; - - ASSERT(next); - while (! (bhvtovfsops(next))->xvfs_unmount) - next = BHV_NEXT(next); - return ((*bhvtovfsops(next)->xvfs_unmount)(next, fl, cr)); -} - -int -xvfs_mntupdate( - struct bhv_desc *bdp, - int *fl, - struct xfs_mount_args *args) -{ - struct bhv_desc *next = bdp; - - ASSERT(next); - while (! (bhvtovfsops(next))->xvfs_mntupdate) - next = BHV_NEXT(next); - return ((*bhvtovfsops(next)->xvfs_mntupdate)(next, fl, args)); -} - -int -xvfs_root( - struct bhv_desc *bdp, - struct xfs_vnode **vpp) -{ - struct bhv_desc *next = bdp; - - ASSERT(next); - while (! (bhvtovfsops(next))->xvfs_root) - next = BHV_NEXT(next); - return ((*bhvtovfsops(next)->xvfs_root)(next, vpp)); -} - -int -xvfs_statvfs( - struct bhv_desc *bdp, - struct statfs *sp, - struct xfs_vnode *vp) -{ - struct bhv_desc *next = bdp; - - ASSERT(next); - while (! (bhvtovfsops(next))->xvfs_statvfs) - next = BHV_NEXT(next); - return ((*bhvtovfsops(next)->xvfs_statvfs)(next, sp, vp)); -} - -int -xvfs_sync( - struct bhv_desc *bdp, - int fl, - struct cred *cr) -{ - struct bhv_desc *next = bdp; - - ASSERT(next); - while (! (bhvtovfsops(next))->xvfs_sync) - next = BHV_NEXT(next); - return ((*bhvtovfsops(next)->xvfs_sync)(next, fl, cr)); -} - -int -xvfs_vget( - struct bhv_desc *bdp, - struct xfs_vnode **vpp, - struct fid *fidp) -{ - struct bhv_desc *next = bdp; - - ASSERT(next); - while (! (bhvtovfsops(next))->xvfs_vget) - next = BHV_NEXT(next); - return ((*bhvtovfsops(next)->xvfs_vget)(next, vpp, fidp)); -} - -int -xvfs_dmapiops( - struct bhv_desc *bdp, - caddr_t addr) -{ - struct bhv_desc *next = bdp; - - ASSERT(next); - while (! (bhvtovfsops(next))->xvfs_dmapiops) - next = BHV_NEXT(next); - return ((*bhvtovfsops(next)->xvfs_dmapiops)(next, addr)); -} - -int -xvfs_quotactl( - struct bhv_desc *bdp, - int cmd, - int id, - caddr_t addr) -{ - struct bhv_desc *next = bdp; - - ASSERT(next); - while (! (bhvtovfsops(next))->xvfs_quotactl) - next = BHV_NEXT(next); - return ((*bhvtovfsops(next)->xvfs_quotactl)(next, cmd, id, addr)); -} - -struct inode * -xvfs_get_inode( - struct bhv_desc *bdp, - xfs_ino_t ino, - int fl) -{ - struct bhv_desc *next = bdp; - - while (! (bhvtovfsops(next))->xvfs_get_inode) - next = BHV_NEXTNULL(next); - return ((*bhvtovfsops(next)->xvfs_get_inode)(next, ino, fl)); -} - -void -xvfs_init_vnode( - struct bhv_desc *bdp, - struct xfs_vnode *vp, - struct bhv_desc *bp, - int unlock) -{ - struct bhv_desc *next = bdp; - - ASSERT(next); - while (! (bhvtovfsops(next))->xvfs_init_vnode) - next = BHV_NEXT(next); - ((*bhvtovfsops(next)->xvfs_init_vnode)(next, vp, bp, unlock)); -} - -void -xvfs_force_shutdown( - struct bhv_desc *bdp, - int fl, - char *file, - int line) -{ - struct bhv_desc *next = bdp; - - ASSERT(next); - while (! (bhvtovfsops(next))->xvfs_force_shutdown) - next = BHV_NEXT(next); - ((*bhvtovfsops(next)->xvfs_force_shutdown)(next, fl, file, line)); -} - -xfs_vfs_t * -vfs_allocate(struct mount *mp) -{ - struct xfs_vfs *vfsp; - struct xfsmount *xmp; - - xmp = kmem_zalloc(sizeof(*xmp), KM_SLEEP); - vfsp = XFSTOVFS(xmp); - - bhv_head_init(VFS_BHVHEAD(vfsp), "vfs"); - - xmp->m_mp = mp; - mp->mnt_data = xmp; - vfsp->vfs_mp = mp; - - return vfsp; -} - -void -vfs_deallocate( - struct xfs_vfs *vfsp) -{ - struct xfsmount *xmp; - - bhv_head_destroy(VFS_BHVHEAD(vfsp)); - - xmp = VFSTOXFS(vfsp); - kmem_free(xmp, sizeof(*xmp)); -} - -/* - * Allocate and initialize a new XFS mount structure - */ -struct xfsmount * -xfsmount_allocate(struct mount *mp) -{ - xfs_vfs_t *vfsp; - - vfsp = vfs_allocate(mp); - - ASSERT(vfsp); - - if (mp->mnt_flag & MNT_RDONLY) - vfsp->vfs_flag |= VFS_RDONLY; - - bhv_insert_all_vfsops(vfsp); - return (VFSTOXFS(vfsp)); -} - -void -xfsmount_deallocate(struct xfsmount *xmp) -{ - xfs_vfs_t *vfsp; - - vfsp = XFSTOVFS(xmp); - bhv_remove_all_vfsops(vfsp, 1); - vfs_deallocate(vfsp); -} - - -void -vfs_insertops( - struct xfs_vfs *vfsp, - struct bhv_vfsops *vfsops) -{ - struct bhv_desc *bdp; - - bdp = kmem_alloc(sizeof(struct bhv_desc), KM_SLEEP); - bhv_desc_init(bdp, NULL, vfsp, vfsops); - bhv_insert(&vfsp->vfs_bh, bdp); -} - -void -vfs_insertbhv( - struct xfs_vfs *vfsp, - struct bhv_desc *bdp, - struct xvfsops *vfsops, - void *mount) -{ - bhv_desc_init(bdp, mount, vfsp, vfsops); - bhv_insert_initial(&vfsp->vfs_bh, bdp); -} - -void -bhv_remove_vfsops( - struct xfs_vfs *vfsp, - int pos) -{ - struct bhv_desc *bhv; - - bhv = bhv_lookup_range(&vfsp->vfs_bh, pos, pos); - if (bhv) { - bhv_remove(&vfsp->vfs_bh, bhv); - kmem_free(bhv, sizeof(*bhv)); - } -} - -void -bhv_remove_all_vfsops( - struct xfs_vfs *vfsp, - int freebase) -{ - struct xfs_mount *mp; - - bhv_remove_vfsops(vfsp, VFS_POSITION_QM); - bhv_remove_vfsops(vfsp, VFS_POSITION_DM); - bhv_remove_vfsops(vfsp, VFS_POSITION_IO); - if (!freebase) - return; - mp = XFS_BHVTOM(bhv_lookup(VFS_BHVHEAD(vfsp), &xfs_vfsops)); - VFS_REMOVEBHV(vfsp, &mp->m_bhv); - xfs_mount_free(mp, 0); -} - -void -bhv_insert_all_vfsops( - struct xfs_vfs *vfsp) -{ - struct xfs_mount *mp; - - mp = xfs_mount_init(); - vfs_insertbhv(vfsp, &mp->m_bhv, &xfs_vfsops, mp); - vfs_insertdmapi(vfsp); - vfs_insertquota(vfsp); -} diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_vfs.h b/sys/gnu/fs/xfs/FreeBSD/xfs_vfs.h deleted file mode 100644 index ada4849..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_vfs.h +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ - */ -#ifndef __XFS_VFS_H__ -#define __XFS_VFS_H__ - -#include <sys/mount.h> -#include "xfs_fs.h" - -struct fid; -struct cred; -struct xfs_vnode; -struct statfs; -struct sbuf; -struct xfs_mount_args; -struct mount; - -typedef struct statfs xfs_statfs_t; - -typedef struct xfs_vfs { - u_int vfs_flag; /* flags */ - xfs_fsid_t vfs_fsid; /* file system ID */ - xfs_fsid_t *vfs_altfsid; /* An ID fixed for life of FS */ - bhv_head_t vfs_bh; /* head of vfs behavior chain */ - struct mount *vfs_mp; /* FreeBSD mount struct */ -} xfs_vfs_t; - -#define MNTTOXVFS(mp) ((struct xfs_vfs*)(mp)->mnt_data) -#define XVFSTOMNT(vfs) ((vfs)->vfs_mp) - -#define vfs_fbhv vfs_bh.bh_first /* 1st on vfs behavior chain */ - -#define bhvtovfs(bdp) ( (struct xfs_vfs *)BHV_VOBJ(bdp) ) -#define bhvtovfsops(bdp) ( (struct xvfsops *)BHV_OPS(bdp) ) -#define VFS_BHVHEAD(vfs) ( &(vfs)->vfs_bh ) -#define VFS_REMOVEBHV(vfs, bdp) ( bhv_remove(VFS_BHVHEAD(vfs), bdp) ) - -#define VFS_POSITION_BASE BHV_POSITION_BASE /* chain bottom */ -#define VFS_POSITION_TOP BHV_POSITION_TOP /* chain top */ -#define VFS_POSITION_INVALID BHV_POSITION_INVALID /* invalid pos. num */ - -typedef enum { - VFS_BHV_UNKNOWN, /* not specified */ - VFS_BHV_XFS, /* xfs */ - VFS_BHV_DM, /* data migration */ - VFS_BHV_QM, /* quota manager */ - VFS_BHV_IO, /* IO path */ - VFS_BHV_END /* housekeeping end-of-range */ -} vfs_bhv_t; - -#define VFS_POSITION_XFS (BHV_POSITION_BASE) -#define VFS_POSITION_DM (VFS_POSITION_BASE+10) -#define VFS_POSITION_QM (VFS_POSITION_BASE+20) -#define VFS_POSITION_IO (VFS_POSITION_BASE+30) - -#define VFS_RDONLY 0x0001 /* read-only vfs */ -#define VFS_GRPID 0x0002 /* group-ID assigned from directory */ -#define VFS_DMI 0x0004 /* filesystem has the DMI enabled */ -#define VFS_32BITINODES 0x0008 /* do not use inums above 32 bits */ -#define VFS_END 0x0008 /* max flag */ - -#define SYNC_ATTR 0x0001 /* sync attributes */ -#define SYNC_CLOSE 0x0002 /* close file system down */ -#define SYNC_DELWRI 0x0004 /* look at delayed writes */ -#define SYNC_WAIT 0x0008 /* wait for i/o to complete */ -#define SYNC_BDFLUSH 0x0010 /* BDFLUSH is calling -- don't block */ -#define SYNC_FSDATA 0x0020 /* flush fs data (e.g. superblocks) */ -#define SYNC_REFCACHE 0x0040 /* prune some of the nfs ref cache */ -#define SYNC_REMOUNT 0x0080 /* remount readonly, no dummy LRs */ -#define SYNC_QUIESCE 0x0100 /* quiesce filesystem for a snapshot */ - -#define IGET_NOALLOC 0x0001 /* vfs_get_inode may return NULL */ - -typedef int (*xvfs_mount_t)(bhv_desc_t *, - struct xfs_mount_args *, struct cred *); -typedef int (*xvfs_parseargs_t)(bhv_desc_t *, char *, - struct xfs_mount_args *, int); -typedef int (*xvfs_showargs_t)(bhv_desc_t *, struct sbuf *); -typedef int (*xvfs_unmount_t)(bhv_desc_t *, int, struct cred *); -typedef int (*xvfs_mntupdate_t)(bhv_desc_t *, int *, - struct xfs_mount_args *); -typedef int (*xvfs_root_t)(bhv_desc_t *, struct xfs_vnode **); -typedef int (*xvfs_statvfs_t)(bhv_desc_t *, xfs_statfs_t *, struct xfs_vnode *); -typedef int (*xvfs_sync_t)(bhv_desc_t *, int, struct cred *); -typedef int (*xvfs_vget_t)(bhv_desc_t *, struct xfs_vnode **, struct fid *); -typedef int (*xvfs_dmapiops_t)(bhv_desc_t *, caddr_t); -typedef int (*xvfs_quotactl_t)(bhv_desc_t *, int, int, caddr_t); -typedef void (*xvfs_init_vnode_t)(bhv_desc_t *, - struct xfs_vnode *, bhv_desc_t *, int); -typedef void (*xvfs_force_shutdown_t)(bhv_desc_t *, int, char *, int); -typedef struct inode * (*xvfs_get_inode_t)(bhv_desc_t *, xfs_ino_t, int); -typedef void (*xvfs_freeze_t)(bhv_desc_t *); - -typedef struct xvfsops { - bhv_position_t xvfs_position; /* behavior chain position */ - xvfs_mount_t xvfs_mount; /* mount file system */ - xvfs_parseargs_t xvfs_parseargs; /* parse mount options */ - xvfs_showargs_t xvfs_showargs; /* unparse mount options */ - xvfs_unmount_t xvfs_unmount; /* unmount file system */ - xvfs_mntupdate_t xvfs_mntupdate; /* update file system options */ - xvfs_root_t xvfs_root; /* get root vnode */ - xvfs_statvfs_t xvfs_statvfs; /* file system statistics */ - xvfs_sync_t xvfs_sync; /* flush files */ - xvfs_vget_t xvfs_vget; /* get vnode from fid */ - xvfs_dmapiops_t xvfs_dmapiops; /* data migration */ - xvfs_quotactl_t xvfs_quotactl; /* disk quota */ - xvfs_get_inode_t xvfs_get_inode; /* bhv specific iget */ - xvfs_init_vnode_t xvfs_init_vnode; /* initialize a new vnode */ - xvfs_force_shutdown_t xvfs_force_shutdown; /* crash and burn */ - xvfs_freeze_t xvfs_freeze; /* freeze fs for snapshot */ -} xvfsops_t; - -/* - * VFS's. Operates on vfs structure pointers (starts at bhv head). - */ -#define VHEAD(v) ((v)->vfs_fbhv) -#define XVFS_MOUNT(v, ma,cr, rv) ((rv) = xvfs_mount(VHEAD(v), ma,cr)) -#define XVFS_PARSEARGS(v, o,ma,f, rv) ((rv) = xvfs_parseargs(VHEAD(v), o,ma,f)) -#define XVFS_SHOWARGS(v, m, rv) ((rv) = xvfs_showargs(VHEAD(v), m)) -#define XVFS_UNMOUNT(v, f, cr, rv) ((rv) = xvfs_unmount(VHEAD(v), f,cr)) -#define XVFS_MNTUPDATE(v, fl, args, rv) ((rv) = xvfs_mntupdate(VHEAD(v), fl, args)) -#define XVFS_ROOT(v, vpp, rv) ((rv) = xvfs_root(VHEAD(v), vpp)) -#define XVFS_STATVFS(v, sp,vp, rv) ((rv) = xvfs_statvfs(VHEAD(v), sp,vp)) -#define XVFS_SYNC(v, flag,cr, rv) ((rv) = xvfs_sync(VHEAD(v), flag,cr)) -#define XVFS_VGET(v, vpp,fidp, rv) ((rv) = xvfs_vget(VHEAD(v), vpp,fidp)) -#define XVFS_DMAPIOPS(v, p, rv) ((rv) = xvfs_dmapiops(VHEAD(v), p)) -#define XVFS_QUOTACTL(v, c,id,p, rv) ((rv) = xvfs_quotactl(VHEAD(v), c,id,p)) -#define XVFS_GET_INODE(v, ino, fl) ( xvfs_get_inode(VHEAD(v), ino,fl) ) -#define XVFS_INIT_VNODE(v, vp,b,ul) ( xvfs_init_vnode(VHEAD(v), vp,b,ul) ) -#define XVFS_FORCE_SHUTDOWN(v, fl,f,l) ( xvfs_force_shutdown(VHEAD(v), fl,f,l) ) - -/* - * PVFS's. Operates on behavior descriptor pointers. - */ -#define PVFS_MOUNT(b, ma,cr, rv) ((rv) = xvfs_mount(b, ma,cr)) -#define PVFS_PARSEARGS(b, o,ma,f, rv) ((rv) = xvfs_parseargs(b, o,ma,f)) -#define PVFS_SHOWARGS(b, m, rv) ((rv) = xvfs_showargs(b, m)) -#define PVFS_UNMOUNT(b, f,cr, rv) ((rv) = xvfs_unmount(b, f,cr)) -#define PVFS_MNTUPDATE(b, fl, args, rv) ((rv) = xvfs_mntupdate(b, fl, args)) -#define PVFS_ROOT(b, vpp, rv) ((rv) = xvfs_root(b, vpp)) -#define PVFS_STATVFS(b, sp,vp, rv) ((rv) = xvfs_statvfs(b, sp,vp)) -#define PVFS_SYNC(b, flag,cr, rv) ((rv) = xvfs_sync(b, flag,cr)) -#define PVFS_VGET(b, vpp,fidp, rv) ((rv) = xvfs_vget(b, vpp,fidp)) -#define PVFS_DMAPIOPS(b, p, rv) ((rv) = xvfs_dmapiops(b, p)) -#define PVFS_QUOTACTL(b, c,id,p, rv) ((rv) = xvfs_quotactl(b, c,id,p)) -#define PVFS_GET_INODE(b, ino,fl) ( xvfs_get_inode(b, ino,fl) ) -#define PVFS_INIT_VNODE(b, vp,b2,ul) ( xvfs_init_vnode(b, vp,b2,ul) ) -#define PVFS_FORCE_SHUTDOWN(b, fl,f,l) ( xvfs_force_shutdown(b, fl,f,l) ) - -extern int xvfs_mount(bhv_desc_t *, struct xfs_mount_args *, struct cred *); -extern int xvfs_parseargs(bhv_desc_t *, char *, struct xfs_mount_args *, int); -extern int xvfs_showargs(bhv_desc_t *, struct sbuf *); -extern int xvfs_unmount(bhv_desc_t *, int, struct cred *); -extern int xvfs_mntupdate(bhv_desc_t *, int *, struct xfs_mount_args *); -extern int xvfs_root(bhv_desc_t *, struct xfs_vnode **); -extern int xvfs_statvfs(bhv_desc_t *, xfs_statfs_t *, struct xfs_vnode *); -extern int xvfs_sync(bhv_desc_t *, int, struct cred *); -extern int xvfs_vget(bhv_desc_t *, struct xfs_vnode **, struct fid *); -extern int xvfs_dmapiops(bhv_desc_t *, caddr_t); -extern int xvfs_quotactl(bhv_desc_t *, int, int, caddr_t); -extern struct inode *xvfs_get_inode(bhv_desc_t *, xfs_ino_t, int); -extern void xvfs_init_vnode(bhv_desc_t *, struct xfs_vnode *, bhv_desc_t *, int); -extern void xvfs_force_shutdown(bhv_desc_t *, int, char *, int); - -#define XFS_DMOPS "xfs_dm_operations" /* Data Migration */ -#define XFS_QMOPS "xfs_qm_operations" /* Quota Manager */ -#define XFS_IOOPS "xfs_io_operations" /* I/O subsystem */ -#define XFS_DM_MODULE "xfs_dmapi" -#define XFS_QM_MODULE "xfs_quota" -#define XFS_IO_MODULE "xfs_ioops" - -typedef struct bhv_vfsops { - struct xvfsops bhv_common; - void * bhv_custom; -} bhv_vfsops_t; - -typedef struct bhv_module { - bhv_desc_t bm_desc; - const char * bm_name; - bhv_vfsops_t * bm_ops; -} bhv_module_t; - -#define vfs_bhv_lookup(v, id) ( bhv_lookup_range(&(v)->vfs_bh, (id), (id)) ) -#define vfs_bhv_custom(b) ( ((bhv_vfsops_t *)BHV_OPS(b))->bhv_custom ) -#define vfs_bhv_set_custom(b,o) ( (b)->bhv_custom = (void *)(o)) -#define vfs_bhv_clr_custom(b) ( (b)->bhv_custom = NULL ) - -extern xfs_vfs_t *vfs_allocate(struct mount *); -extern void vfs_deallocate(xfs_vfs_t *); -extern void vfs_insertops(xfs_vfs_t *, bhv_vfsops_t *); -extern void vfs_insertbhv(xfs_vfs_t *, bhv_desc_t *, xvfsops_t *, void *); - -#define bhv_lookup_module(n,m) ( (m) ? \ - inter_module_get_request(n, m) : \ - inter_module_get(n) ) -#define bhv_remove_module(n) inter_module_put(n) -#define bhv_module_init(n,m,op) inter_module_register(n,m,op) -#define bhv_module_exit(n) inter_module_unregister(n) - -extern void bhv_insert_all_vfsops(struct xfs_vfs *); -extern void bhv_remove_all_vfsops(struct xfs_vfs *, int); -extern void bhv_remove_vfsops(struct xfs_vfs *, int); - -#endif /* __XFS_VFS_H__ */ diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_vnode.c b/sys/gnu/fs/xfs/FreeBSD/xfs_vnode.c deleted file mode 100644 index 3b3f3e5..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_vnode.c +++ /dev/null @@ -1,272 +0,0 @@ -/* - * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ - */ - -#include "xfs.h" -#include "xfs_types.h" -#include "xfs_bit.h" -#include "xfs_inum.h" -#include "xfs_log.h" -#include "xfs_trans.h" -#include "xfs_trans_priv.h" -#include "xfs_sb.h" -#include "xfs_ag.h" -#include "xfs_dir.h" -#include "xfs_dir2.h" -#include "xfs_dmapi.h" -#include "xfs_mount.h" -#include "xfs_alloc_btree.h" -#include "xfs_bmap_btree.h" -#include "xfs_ialloc_btree.h" -#include "xfs_btree.h" -#include "xfs_imap.h" -#include "xfs_alloc.h" -#include "xfs_attr_sf.h" -#include "xfs_dir_sf.h" -#include "xfs_dir2_sf.h" -#include "xfs_dinode.h" -#include "xfs_ialloc.h" -#include "xfs_inode.h" -#include "xfs_inode_item.h" - -void -vn_init(void) -{ -} - -void -vn_iowait( - struct xfs_vnode *vp) -{ - printf("vn_iowait doing nothing on FreeBSD?\n"); -} - -struct xfs_vnode * -vn_initialize( - xfs_vnode_t *vp) -{ - XFS_STATS_INC(vn_active); - XFS_STATS_INC(vn_alloc); - - /* Initialize the first behavior and the behavior chain head. */ - vn_bhv_head_init(VN_BHV_HEAD(vp), "vnode"); - -#ifdef CONFIG_XFS_VNODE_TRACING - vp->v_trace = ktrace_alloc(VNODE_TRACE_SIZE, KM_SLEEP); -#endif /* CONFIG_XFS_VNODE_TRACING */ - - vn_trace_exit(vp, "vn_initialize", (inst_t *)__return_address); - return vp; -} - -/* - * Get a reference on a vnode. Need to drop vnode reference - * to accomodate for vhold by VMAP regardless of whether or - * not we were able to successfully grab the vnode. - */ -xfs_vnode_t * -vn_get( - struct xfs_vnode *xfs_vp, - vmap_t *vmap) -{ - struct vnode *vp; - int error; - - XFS_STATS_INC(vn_get); - - vp = vmap->v_vp; - - error = vget(vp, LK_EXCLUSIVE, curthread); - vdrop(vp); - if (error) - return (NULL); - - /* - * Drop the vnode returned by vget here. - * VOP_RECLAIM(9) should block on internal XFS locks so that - * the reclaiming scheme still remains consistent even if the - * vp is not locked. - */ - VOP_UNLOCK(vp, 0); - if (vp->v_data != xfs_vp) { - vput(vp); - return (NULL); - } - - vn_trace_exit(vp, "vn_get", (inst_t *)__return_address); - return xfs_vp; -} - -/* - * purge a vnode from the cache - * At this point the vnode is guaranteed to have no references (vn_count == 0) - * The caller has to make sure that there are no ways someone could - * get a handle (via vn_get) on the vnode (usually done via a mount/vfs lock). - */ -void -vn_purge(struct xfs_vnode *xfs_vp) -{ - struct vnode *vp; - - vn_trace_entry(vp, "vn_purge", (inst_t *)__return_address); - - vp = xfs_vp->v_vnode; - - vn_lock(vp, LK_EXCLUSIVE); - if (vp->v_holdcnt == 0) - vhold(vp); - vgone(vp); - VOP_UNLOCK(vp, 0); -} - -void xfs_ichgtime( - xfs_inode_t *ip, - int flags) -{ - timespec_t tv; - - vfs_timestamp(&tv); - if (flags & XFS_ICHGTIME_MOD) { - ip->i_d.di_mtime.t_sec = (__int32_t)tv.tv_sec; - ip->i_d.di_mtime.t_nsec = (__int32_t)tv.tv_nsec; - } - if (flags & XFS_ICHGTIME_ACC) { - ip->i_d.di_atime.t_sec = (__int32_t)tv.tv_sec; - ip->i_d.di_atime.t_nsec = (__int32_t)tv.tv_nsec; - } - if (flags & XFS_ICHGTIME_CHG) { - ip->i_d.di_ctime.t_sec = (__int32_t)tv.tv_sec; - ip->i_d.di_ctime.t_nsec = (__int32_t)tv.tv_nsec; - } - -//printf ("xfs_ichgtime NI\n"); - -} - - -/* - * Bring the atime in the XFS inode uptodate. - * Used before logging the inode to disk or when the Linux inode goes away. - */ - -/* - * It's unclear if we need this since this is for syncing the linux inode's atime - * to the xfs inode's atime. - * Since FreeBSD doesn't have atime in the vnode is there anything to really - * sync over? - * For now just make this a update atime call - */ - -void -xfs_synchronize_atime( - xfs_inode_t *ip) -{ -#if 0 - xfs_vnode_t *vp; -#endif - - timespec_t tv; - -/* vfs_timestamp looks at the system time accuracy variable */ - vfs_timestamp(&tv); -#if 0 - printf("xfs_synchronize_atime old (%d,%d) new (%d,%ld)\n", - ip->i_d.di_atime.t_sec, - ip->i_d.di_atime.t_nsec, - tv.tv_sec, - tv.tv_nsec); -#endif - - ip->i_d.di_atime.t_sec = (__int32_t)tv.tv_sec; - ip->i_d.di_atime.t_nsec = (__int32_t)tv.tv_nsec; -} - -#ifdef RMC -/* - * Extracting atime values in various formats - */ -void vn_atime_to_bstime(struct xfs_vnode *vp, xfs_bstime_t *bs_atime) -{ - bs_atime->tv_sec = vp->v_inode.i_atime.tv_sec; - bs_atime->tv_nsec = vp->v_inode.i_atime.tv_nsec; - printf("vn_atime_to_bstime NI\n"); -} -#endif - - -#ifdef CONFIG_XFS_VNODE_TRACING - -#define KTRACE_ENTER(vp, vk, s, line, ra) \ - ktrace_enter( (vp)->v_trace, \ -/* 0 */ (void *)(__psint_t)(vk), \ -/* 1 */ (void *)(s), \ -/* 2 */ (void *)(__psint_t) line, \ -/* 3 */ (void *)(vn_count(vp)), \ -/* 4 */ (void *)(ra), \ -/* 5 */ (void *)(__psunsigned_t)(vp)->v_flag, \ -/* 6 */ (void *)(__psint_t)smp_processor_id(), \ -/* 7 */ (void *)(__psint_t)(current->pid), \ -/* 8 */ (void *)__return_address, \ -/* 9 */ 0, 0, 0, 0, 0, 0, 0) - -/* - * Vnode tracing code. - */ -void -vn_trace_entry(xfs_vnode_t *vp, char *func, inst_t *ra) -{ - KTRACE_ENTER(vp, VNODE_KTRACE_ENTRY, func, 0, ra); -} - -void -vn_trace_exit(xfs_vnode_t *vp, char *func, inst_t *ra) -{ - KTRACE_ENTER(vp, VNODE_KTRACE_EXIT, func, 0, ra); -} - -void -vn_trace_hold(xfs_vnode_t *vp, char *file, int line, inst_t *ra) -{ - KTRACE_ENTER(vp, VNODE_KTRACE_HOLD, file, line, ra); -} - -void -vn_trace_ref(xfs_vnode_t *vp, char *file, int line, inst_t *ra) -{ - KTRACE_ENTER(vp, VNODE_KTRACE_REF, file, line, ra); -} - -void -vn_trace_rele(xfs_vnode_t *vp, char *file, int line, inst_t *ra) -{ - KTRACE_ENTER(vp, VNODE_KTRACE_RELE, file, line, ra); -} -#endif /* CONFIG_XFS_VNODE_TRACING */ diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_vnode.h b/sys/gnu/fs/xfs/FreeBSD/xfs_vnode.h deleted file mode 100644 index 1e02bb0..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_vnode.h +++ /dev/null @@ -1,673 +0,0 @@ -/* - * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ - * - * Portions Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ -#ifndef __XFS_VNODE_H__ -#define __XFS_VNODE_H__ - -#include <sys/vnode.h> -#include <sys/namei.h> - -struct xfs_iomap; -typedef struct componentname vname_t; -typedef bhv_head_t vn_bhv_head_t; - -/* - * MP locking protocols: - * v_flag, v_vfsp VN_LOCK/VN_UNLOCK - * v_type read-only or fs-dependent - */ -typedef struct xfs_vnode { - __u32 v_flag; /* vnode flags (see below) */ - struct xfs_vfs *v_vfsp; /* ptr to containing VFS */ - xfs_ino_t v_number; /* in-core vnode number */ - vn_bhv_head_t v_bh; /* behavior head */ - struct vnode *v_vnode; /* FreeBSD vnode */ - struct xfs_inode *v_inode; /* XFS inode */ -#ifdef XFS_VNODE_TRACE - struct ktrace *v_trace; /* trace header structure */ -#endif -} xfs_vnode_t; - - -/* vnode types */ -#define VN_ISLNK(vp) ((vp)->v_vnode->v_type & VLNK) -#define VN_ISREG(vp) ((vp)->v_vnode->v_type & VREG) -#define VN_ISDIR(vp) ((vp)->v_vnode->v_type & VDIR) -#define VN_ISCHR(vp) ((vp)->v_vnode->v_type & VCHR) -#define VN_ISBLK(vp) ((vp)->v_vnode->v_type & VBLK) -#define VN_BAD(vp) ((vp)->v_vnode->v_type & VBAD) - -#define v_fbhv v_bh.bh_first /* first behavior */ -#define v_fops v_bh.bh_first->bd_ops /* first behavior ops */ - -#define VNODE_POSITION_BASE BHV_POSITION_BASE /* chain bottom */ -#define VNODE_POSITION_TOP BHV_POSITION_TOP /* chain top */ -#define VNODE_POSITION_INVALID BHV_POSITION_INVALID /* invalid pos. num */ - -typedef enum { - VN_BHV_UNKNOWN, /* not specified */ - VN_BHV_XFS, /* xfs */ - VN_BHV_DM, /* data migration */ - VN_BHV_QM, /* quota manager */ - VN_BHV_IO, /* IO path */ - VN_BHV_END /* housekeeping end-of-range */ -} vn_bhv_t; - -#define VNODE_POSITION_XFS (VNODE_POSITION_BASE) -#define VNODE_POSITION_DM (VNODE_POSITION_BASE+10) -#define VNODE_POSITION_QM (VNODE_POSITION_BASE+20) -#define VNODE_POSITION_IO (VNODE_POSITION_BASE+30) - -#define VPTOXFSVP(vp) ((struct xfs_vnode *)(vp)->v_data) - -/* - * Macros for dealing with the behavior descriptor inside of the vnode. - */ -#define BHV_TO_VNODE(bdp) ((xfs_vnode_t *)BHV_VOBJ(bdp)) -#define BHV_TO_VNODE_NULL(bdp) ((xfs_vnode_t *)BHV_VOBJNULL(bdp)) - -#define VN_BHV_HEAD(vp) ((bhv_head_t *)(&((vp)->v_bh))) -#define vn_bhv_head_init(bhp,name) bhv_head_init(bhp,name) -#define vn_bhv_remove(bhp,bdp) bhv_remove(bhp,bdp) -#define vn_bhv_lookup(bhp,ops) bhv_lookup(bhp,ops) -#define vn_bhv_lookup_unlocked(bhp,ops) bhv_lookup_unlocked(bhp,ops) - -/* - * Vnode to Linux inode mapping. - */ -#define LINVFS_GET_VP(inode) ((xfs_vnode_t *)NULL) -#define LINVFS_GET_IP(vp) ((xfs_inode_t *)NULL) - -/* - * Vnode flags. - */ -#define VINACT 0x1 /* vnode is being inactivated */ -#define VRECLM 0x2 /* vnode is being reclaimed */ -#define VWAIT 0x4 /* waiting for VINACT/VRECLM to end */ -#define VMODIFIED 0x8 /* XFS inode state possibly differs */ - /* to the Linux inode state. */ - -/* - * Values for the VOP_RWLOCK and VOP_RWUNLOCK flags parameter. - */ -typedef enum vrwlock { - VRWLOCK_NONE, - VRWLOCK_READ, - VRWLOCK_WRITE, - VRWLOCK_WRITE_DIRECT, - VRWLOCK_TRY_READ, - VRWLOCK_TRY_WRITE -} vrwlock_t; - -/* - * Return values for VOP_INACTIVE. A return value of - * VN_INACTIVE_NOCACHE implies that the file system behavior - * has disassociated its state and bhv_desc_t from the vnode. - */ -#define VN_INACTIVE_CACHE 0 -#define VN_INACTIVE_NOCACHE 1 - -/* - * Values for the cmd code given to VOP_VNODE_CHANGE. - */ -typedef enum vchange { - VCHANGE_FLAGS_FRLOCKS = 0, - VCHANGE_FLAGS_ENF_LOCKING = 1, - VCHANGE_FLAGS_TRUNCATED = 2, - VCHANGE_FLAGS_PAGE_DIRTY = 3, - VCHANGE_FLAGS_IOEXCL_COUNT = 4 -} vchange_t; - -struct file_lock; -struct xfs_iomap_s; -struct xfs_vattr; -struct attrlist_cursor_kern; - -typedef int (*xfs_vop_open_t)(bhv_desc_t *, struct cred *); -typedef ssize_t (*xfs_vop_read_t)(bhv_desc_t *, uio_t *, int, struct cred *); -typedef ssize_t (*xfs_vop_write_t)(bhv_desc_t *, uio_t *, int, struct cred *); -typedef int (*xfs_vop_ioctl_t)(bhv_desc_t *, struct inode *, struct file *, - int, u_long, void *); -typedef int (*xfs_vop_getattr_t)(bhv_desc_t *, struct xfs_vattr *, int, - struct cred *); -typedef int (*xfs_vop_setattr_t)(bhv_desc_t *, struct xfs_vattr *, int, - struct cred *); -typedef int (*xfs_vop_access_t)(bhv_desc_t *, int, struct cred *); -typedef int (*xfs_vop_lookup_t)(bhv_desc_t *, vname_t *, xfs_vnode_t **, - int, xfs_vnode_t *, struct cred *); -typedef int (*xfs_vop_create_t)(bhv_desc_t *, vname_t *, struct xfs_vattr *, - xfs_vnode_t **, struct cred *); -typedef int (*xfs_vop_remove_t)(bhv_desc_t *, bhv_desc_t *, vname_t *, struct cred *); -typedef int (*xfs_vop_link_t)(bhv_desc_t *, xfs_vnode_t *, vname_t *, - struct cred *); -typedef int (*xfs_vop_rename_t)(bhv_desc_t *, vname_t *, xfs_vnode_t *, vname_t *, - struct cred *); -typedef int (*xfs_vop_mkdir_t)(bhv_desc_t *, vname_t *, struct xfs_vattr *, - xfs_vnode_t **, struct cred *); -typedef int (*xfs_vop_rmdir_t)(bhv_desc_t *, vname_t *, struct cred *); -typedef int (*xfs_vop_readdir_t)(bhv_desc_t *, struct uio *, struct cred *, - int *); -typedef int (*xfs_vop_symlink_t)(bhv_desc_t *, vname_t *, struct xfs_vattr *, - char *, xfs_vnode_t **, struct cred *); - -typedef int (*xfs_vop_readlink_t)(bhv_desc_t *, struct uio *, int, - struct cred *); -typedef int (*xfs_vop_fsync_t)(bhv_desc_t *, int, struct cred *, - xfs_off_t, xfs_off_t); -typedef int (*xfs_vop_inactive_t)(bhv_desc_t *, struct cred *); -typedef int (*xfs_vop_fid2_t)(bhv_desc_t *, struct fid *); -typedef int (*xfs_vop_release_t)(bhv_desc_t *); -typedef int (*xfs_vop_rwlock_t)(bhv_desc_t *, vrwlock_t); -typedef void (*xfs_vop_rwunlock_t)(bhv_desc_t *, vrwlock_t); -typedef int (*xfs_vop_frlock_t)(bhv_desc_t *, int, struct file_lock *,int, - xfs_off_t, struct cred *); -typedef int (*xfs_vop_bmap_t)(bhv_desc_t *, xfs_off_t, ssize_t, int, - struct xfs_iomap *, int *); -typedef int (*xfs_vop_reclaim_t)(bhv_desc_t *); -typedef int (*xfs_vop_attr_get_t)(bhv_desc_t *, const char *, char *, int *, int, - struct cred *); -typedef int (*xfs_vop_attr_set_t)(bhv_desc_t *, const char *, char *, int, int, - struct cred *); -typedef int (*xfs_vop_attr_remove_t)(bhv_desc_t *, const char *, int, struct cred *); -typedef int (*xfs_vop_attr_list_t)(bhv_desc_t *, char *, int, int, - struct attrlist_cursor_kern *, struct cred *); -typedef void (*xfs_vop_link_removed_t)(bhv_desc_t *, xfs_vnode_t *, int); -typedef void (*xfs_vop_vnode_change_t)(bhv_desc_t *, vchange_t, __psint_t); -typedef void (*xfs_vop_ptossvp_t)(bhv_desc_t *, xfs_off_t, xfs_off_t, int); -typedef void (*xfs_vop_pflushinvalvp_t)(bhv_desc_t *, xfs_off_t, xfs_off_t, int); -typedef int (*xfs_vop_pflushvp_t)(bhv_desc_t *, xfs_off_t, xfs_off_t, - uint64_t, int); -typedef int (*xfs_vop_iflush_t)(bhv_desc_t *, int); - - -typedef struct xfs_vnodeops { - bhv_position_t vn_position; /* position within behavior chain */ - xfs_vop_open_t vop_open; - xfs_vop_read_t vop_read; - xfs_vop_write_t vop_write; - xfs_vop_ioctl_t vop_ioctl; - xfs_vop_getattr_t vop_getattr; - xfs_vop_setattr_t vop_setattr; - xfs_vop_access_t vop_access; - xfs_vop_lookup_t vop_lookup; - xfs_vop_create_t vop_create; - xfs_vop_remove_t vop_remove; - xfs_vop_link_t vop_link; - xfs_vop_rename_t vop_rename; - xfs_vop_mkdir_t vop_mkdir; - xfs_vop_rmdir_t vop_rmdir; - xfs_vop_readdir_t vop_readdir; - xfs_vop_symlink_t vop_symlink; - xfs_vop_readlink_t vop_readlink; - xfs_vop_fsync_t vop_fsync; - xfs_vop_inactive_t vop_inactive; - xfs_vop_fid2_t vop_fid2; - xfs_vop_rwlock_t vop_rwlock; - xfs_vop_rwunlock_t vop_rwunlock; - xfs_vop_frlock_t vop_frlock; - xfs_vop_bmap_t vop_bmap; - xfs_vop_reclaim_t vop_reclaim; - xfs_vop_attr_get_t vop_attr_get; - xfs_vop_attr_set_t vop_attr_set; - xfs_vop_attr_remove_t vop_attr_remove; - xfs_vop_attr_list_t vop_attr_list; - xfs_vop_link_removed_t vop_link_removed; - xfs_vop_vnode_change_t vop_vnode_change; - xfs_vop_ptossvp_t vop_tosspages; - xfs_vop_pflushinvalvp_t vop_flushinval_pages; - xfs_vop_pflushvp_t vop_flush_pages; - xfs_vop_release_t vop_release; - xfs_vop_iflush_t vop_iflush; -} xfs_vnodeops_t; - -/* - * VOP's. - */ -#define _VOP_(op, vp) (*((xfs_vnodeops_t *)(vp)->v_fops)->op) - -#define XVOP_READ(vp,uio,ioflags,cr,rv) \ - rv = _VOP_(vop_read, vp)((vp)->v_fbhv,uio,ioflags,cr) -#define XVOP_WRITE(vp,file,uio,ioflags,cr,rv) \ - rv = _VOP_(vop_write, vp)((vp)->v_fbhv,uio,ioflags,cr) -#define XVOP_BMAP(vp,of,sz,rw,b,n,rv) \ - rv = _VOP_(vop_bmap, vp)((vp)->v_fbhv,of,sz,rw,b,n) -#define XVOP_OPEN(vp, cr, rv) \ - rv = _VOP_(vop_open, vp)((vp)->v_fbhv, cr) -#define XVOP_GETATTR(vp, vap, f, cr, rv) \ - rv = _VOP_(vop_getattr, vp)((vp)->v_fbhv, vap, f, cr) -#define XVOP_SETATTR(vp, vap, f, cr, rv) \ - rv = _VOP_(vop_setattr, vp)((vp)->v_fbhv, vap, f, cr) -#define XVOP_ACCESS(vp, accmode, cr, rv) \ - rv = _VOP_(vop_access, vp)((vp)->v_fbhv, accmode, cr) -#define XVOP_LOOKUP(vp,d,vpp,f,rdir,cr,rv) \ - rv = _VOP_(vop_lookup, vp)((vp)->v_fbhv,d,vpp,f,rdir,cr) -#define XVOP_CREATE(dvp,d,vap,vpp,cr,rv) \ - rv = _VOP_(vop_create, dvp)((dvp)->v_fbhv,d,vap,vpp,cr) -#define XVOP_REMOVE(dvp,d,cr,rv) \ - rv = _VOP_(vop_remove, dvp)((dvp)->v_fbhv,d,cr) -#define XVOP_LINK(tdvp,fvp,d,cr,rv) \ - rv = _VOP_(vop_link, tdvp)((tdvp)->v_fbhv,fvp,d,cr) -#define XVOP_RENAME(fvp,fnm,tdvp,tnm,cr,rv) \ - rv = _VOP_(vop_rename, fvp)((fvp)->v_fbhv,fnm,tdvp,tnm,cr) -#define XVOP_MKDIR(dp,d,vap,vpp,cr,rv) \ - rv = _VOP_(vop_mkdir, dp)((dp)->v_fbhv,d,vap,vpp,cr) -#define XVOP_RMDIR(dp,d,cr,rv) \ - rv = _VOP_(vop_rmdir, dp)((dp)->v_fbhv,d,cr) -#define XVOP_READDIR(vp,uiop,cr,eofp,rv) \ - rv = _VOP_(vop_readdir, vp)((vp)->v_fbhv,uiop,cr,eofp) -#define XVOP_SYMLINK(dvp,d,vap,tnm,vpp,cr,rv) \ - rv = _VOP_(vop_symlink, dvp) ((dvp)->v_fbhv,d,vap,tnm,vpp,cr) -#define XVOP_READLINK(vp,uiop,fl,cr,rv) \ - rv = _VOP_(vop_readlink, vp)((vp)->v_fbhv,uiop,fl,cr) - -#define XVOP_FSYNC(vp,f,cr,b,e,rv) \ - rv = _VOP_(vop_fsync, vp)((vp)->v_fbhv,f,cr,b,e) -#define XVOP_INACTIVE(vp, cr, rv) \ - rv = _VOP_(vop_inactive, vp)((vp)->v_fbhv, cr) -#define XVOP_RELEASE(vp, rv) \ - rv = _VOP_(vop_release, vp)((vp)->v_fbhv) -#define XVOP_FID2(vp, fidp, rv) \ - rv = _VOP_(vop_fid2, vp)((vp)->v_fbhv, fidp) -#define XVOP_RWLOCK(vp,i) \ - (void)_VOP_(vop_rwlock, vp)((vp)->v_fbhv, i) -#define XVOP_RWLOCK_TRY(vp,i) \ - _VOP_(vop_rwlock, vp)((vp)->v_fbhv, i) -#define XVOP_RWUNLOCK(vp,i) \ - (void)_VOP_(vop_rwunlock, vp)((vp)->v_fbhv, i) -#define XVOP_FRLOCK(vp,c,fl,flags,offset,fr,rv) \ - rv = _VOP_(vop_frlock, vp)((vp)->v_fbhv,c,fl,flags,offset,fr) -#define XVOP_RECLAIM(vp, rv) \ - rv = _VOP_(vop_reclaim, vp)((vp)->v_fbhv) -#define XVOP_ATTR_GET(vp, name, val, vallenp, fl, cred, rv) \ - rv = _VOP_(vop_attr_get, vp)((vp)->v_fbhv,name,val,vallenp,fl,cred) -#define XVOP_ATTR_SET(vp, name, val, vallen, fl, cred, rv) \ - rv = _VOP_(vop_attr_set, vp)((vp)->v_fbhv,name,val,vallen,fl,cred) -#define XVOP_ATTR_REMOVE(vp, name, flags, cred, rv) \ - rv = _VOP_(vop_attr_remove, vp)((vp)->v_fbhv,name,flags,cred) -#define XVOP_ATTR_LIST(vp, buf, buflen, fl, cursor, cred, rv) \ - rv = _VOP_(vop_attr_list, vp)((vp)->v_fbhv,buf,buflen,fl,cursor,cred) -#define XVOP_LINK_REMOVED(vp, dvp, linkzero) \ - (void)_VOP_(vop_link_removed, vp)((vp)->v_fbhv, dvp, linkzero) -#define XVOP_VNODE_CHANGE(vp, cmd, val) \ - (void)_VOP_(vop_vnode_change, vp)((vp)->v_fbhv,cmd,val) -/* - * These are page cache functions that now go thru VOPs. - * 'last' parameter is unused and left in for IRIX compatibility - */ -#define XVOP_TOSS_PAGES(vp, first, last, fiopt) \ - _VOP_(vop_tosspages, vp)((vp)->v_fbhv,first, last, fiopt) -/* - * 'last' parameter is unused and left in for IRIX compatibility - */ -#define XVOP_FLUSHINVAL_PAGES(vp, first, last, fiopt) \ - _VOP_(vop_flushinval_pages, vp)((vp)->v_fbhv,first,last,fiopt) -/* - * 'last' parameter is unused and left in for IRIX compatibility - */ -#define XVOP_FLUSH_PAGES(vp, first, last, flags, fiopt, rv) \ - rv = _VOP_(vop_flush_pages, vp)((vp)->v_fbhv,first,last,flags,fiopt) -#define XVOP_IOCTL(vp, inode, filp, fl, cmd, arg, rv) \ - rv = _VOP_(vop_ioctl, vp)((vp)->v_fbhv,inode,filp,fl,cmd,arg) -#define XVOP_IFLUSH(vp, flags, rv) \ - rv = _VOP_(vop_iflush, vp)((vp)->v_fbhv, flags) - -/* - * Flags for read/write calls - select values from FreeBSD IO_ flags - * or non-conflicting bits. - */ -#define IO_ISDIRECT IO_DIRECT /* bypass page cache */ -#define IO_INVIS 0x02000 /* don't update inode timestamps */ -/* #define IO_ISLOCKED 0x04000 don't do inode locking, strictly a CXFS thing */ - -/* - * Flags for VOP_IFLUSH call - */ -#define FLUSH_SYNC 1 /* wait for flush to complete */ -#define FLUSH_INODE 2 /* flush the inode itself */ -#define FLUSH_LOG 4 /* force the last log entry for - * this inode out to disk */ - -/* - * Flush/Invalidate options for VOP_TOSS_PAGES, VOP_FLUSHINVAL_PAGES and - * VOP_FLUSH_PAGES. - */ -#define FI_NONE 0 /* none */ -#define FI_REMAPF 1 /* Do a remapf prior to the operation */ -#define FI_REMAPF_LOCKED 2 /* Do a remapf prior to the operation. - Prevent VM access to the pages until - the operation completes. */ - -/* - * Vnode attributes. va_mask indicates those attributes the caller - * wants to set or extract. - */ -typedef struct xfs_vattr { - int va_mask; /* bit-mask of attributes present */ - mode_t va_mode; /* file access mode and type */ - nlink_t va_nlink; /* number of references to file */ - uid_t va_uid; /* owner user id */ - gid_t va_gid; /* owner group id */ - xfs_ino_t va_nodeid; /* file id */ - xfs_off_t va_size; /* file size in bytes */ - u_long va_blocksize; /* blocksize preferred for i/o */ - struct timespec va_atime; /* time of last access */ - struct timespec va_mtime; /* time of last modification */ - struct timespec va_ctime; /* time file changed */ - u_int va_gen; /* generation number of file */ - xfs_dev_t va_rdev; /* device the special file represents */ - __int64_t va_nblocks; /* number of blocks allocated */ - u_long va_xflags; /* random extended file flags */ - u_long va_extsize; /* file extent size */ - u_long va_nextents; /* number of extents in file */ - u_long va_anextents; /* number of attr extents in file */ - int va_projid; /* project id */ -} xfs_vattr_t; - -/* - * setattr or getattr attributes - */ -#define XFS_AT_TYPE 0x00000001 -#define XFS_AT_MODE 0x00000002 -#define XFS_AT_UID 0x00000004 -#define XFS_AT_GID 0x00000008 -#define XFS_AT_FSID 0x00000010 -#define XFS_AT_NODEID 0x00000020 -#define XFS_AT_NLINK 0x00000040 -#define XFS_AT_SIZE 0x00000080 -#define XFS_AT_ATIME 0x00000100 -#define XFS_AT_MTIME 0x00000200 -#define XFS_AT_CTIME 0x00000400 -#define XFS_AT_RDEV 0x00000800 -#define XFS_AT_BLKSIZE 0x00001000 -#define XFS_AT_NBLOCKS 0x00002000 -#define XFS_AT_VCODE 0x00004000 -#define XFS_AT_MAC 0x00008000 -#define XFS_AT_UPDATIME 0x00010000 -#define XFS_AT_UPDMTIME 0x00020000 -#define XFS_AT_UPDCTIME 0x00040000 -#define XFS_AT_ACL 0x00080000 -#define XFS_AT_CAP 0x00100000 -#define XFS_AT_INF 0x00200000 -#define XFS_AT_XFLAGS 0x00400000 -#define XFS_AT_EXTSIZE 0x00800000 -#define XFS_AT_NEXTENTS 0x01000000 -#define XFS_AT_ANEXTENTS 0x02000000 -#define XFS_AT_PROJID 0x04000000 -#define XFS_AT_SIZE_NOPERM 0x08000000 -#define XFS_AT_GENCOUNT 0x10000000 - -#define XFS_AT_ALL (XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\ - XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\ - XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME|XFS_AT_RDEV|\ - XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_VCODE|XFS_AT_MAC|\ - XFS_AT_ACL|XFS_AT_CAP|XFS_AT_INF|XFS_AT_XFLAGS|XFS_AT_EXTSIZE|\ - XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_PROJID|XFS_AT_GENCOUNT) - -#define XFS_AT_STAT (XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\ - XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\ - XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME|XFS_AT_RDEV|\ - XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_PROJID) - -#define XFS_AT_TIMES (XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME) - -#define XFS_AT_UPDTIMES (XFS_AT_UPDATIME|XFS_AT_UPDMTIME|XFS_AT_UPDCTIME) - -#define XFS_AT_NOSET (XFS_AT_NLINK|XFS_AT_RDEV|XFS_AT_FSID|XFS_AT_NODEID|\ - XFS_AT_TYPE|XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_VCODE|\ - XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_GENCOUNT) - -#ifndef __FreeBSD__ -/* - * Modes. - */ -#define VSUID S_ISUID /* set user id on execution */ -#define VSGID S_ISGID /* set group id on execution */ -#define VSVTX S_ISVTX /* save swapped text even after use */ -#define VREAD S_IRUSR /* read, write, execute permissions */ -#define VWRITE S_IWUSR -#define VEXEC S_IXUSR -#endif /* __FreeBSD__ */ - -#define MODEMASK ALLPERMS /* mode bits plus permission bits */ - -/* - * Check whether mandatory file locking is enabled. - */ -#define MANDLOCK(vp, mode) \ - ((vp)->v_vnode->v_type == VREG && ((mode) & (S_ISGID|(VEXEC>>3))) == S_ISGID) - -extern void vn_init(void); -extern int vn_wait(struct xfs_vnode *); -extern void vn_iowait(struct xfs_vnode *); -extern xfs_vnode_t *vn_initialize(struct xfs_vnode *); - -/* - * Acquiring and invalidating vnodes: - * - * if (vn_get(vp, version, 0)) - * ...; - * vn_purge(vp, version); - * - * vn_get and vn_purge must be called with vmap_t arguments, sampled - * while a lock that the vnode's VOP_RECLAIM function acquires is - * held, to ensure that the vnode sampled with the lock held isn't - * recycled (VOP_RECLAIMed) or deallocated between the release of the lock - * and the subsequent vn_get or vn_purge. - */ - -/* - * vnode_map structures _must_ match vn_epoch and vnode structure sizes. - */ -typedef struct vnode_map { - xfs_vfs_t *v_vfsp; - xfs_ino_t v_ino; - struct vnode *v_vp; -} vmap_t; - -#if 1 -#define VMAP(vp, vmap) {(vmap).v_vfsp = (vp)->v_vfsp; \ - (vmap).v_vp = (vp)->v_vnode; \ - (vmap).v_ino = (vp)->v_inode->i_ino;\ - vhold((vp)->v_vnode); \ - } -#endif - -extern void vn_purge(struct xfs_vnode *); -extern xfs_vnode_t *vn_get(struct xfs_vnode *, vmap_t *); -extern int vn_revalidate(struct xfs_vnode *); - -static inline int vn_count(struct xfs_vnode *vp) -{ - return vp->v_vnode->v_usecount; -} - -/* - * Vnode reference counting functions (and macros for compatibility). - */ -extern xfs_vnode_t *vn_hold(struct xfs_vnode *); -extern void vn_rele(struct xfs_vnode *); - -#if defined(XFS_VNODE_TRACE) -#define VN_HOLD(vp) \ - ((void)vref((vp)->v_vnode), \ - vn_trace_hold(vp, __FILE__, __LINE__, (inst_t *)__return_address)) -#define VN_RELE(vp) \ - (vn_trace_rele(vp, __FILE__, __LINE__, (inst_t *)__return_address), \ - vrele((vp)->v_vnode)) -#else -#define VN_HOLD(vp) vref((vp)->v_vnode) -#define VN_RELE(vp) vrele((vp)->v_vnode) -#endif - -/* - * Vname handling macros. - */ -#define VNAME(cnp) ((cnp)->cn_nameptr) -#define VNAMELEN(cnp) ((cnp)->cn_namelen) -#define VNAME_TO_VNODE(dentry) (printf("VNAME_TO_VNODE NI"), (xfs_vnode_t *)0) - -/* - * Vnode spinlock manipulation. - */ -#define VN_LOCK(vp) VI_LOCK(vp->v_vnode) -#define VN_UNLOCK(vp, s) VI_UNLOCK(vp->v_vnode) -#define VN_FLAGSET(vp,b) vn_flagset(vp,b) -#define VN_FLAGCLR(vp,b) vn_flagclr(vp,b) - -static __inline__ void vn_flagset(struct xfs_vnode *vp, __u32 flag) -{ - VN_LOCK(vp); - vp->v_flag |= flag; - VN_UNLOCK(vp, 0); -} - -static __inline__ void vn_flagclr(struct xfs_vnode *vp, __u32 flag) -{ - VN_LOCK(vp); - vp->v_flag &= ~flag; - VN_UNLOCK(vp, 0); -} - -/* - * Update modify/access/change times on the vnode - */ -#define VN_MTIMESET(vp, tvp) -#define VN_ATIMESET(vp, tvp) -#define VN_CTIMESET(vp, tvp) - -/* - * Some useful predicates. - */ -#define VN_MAPPED(vp) 0 -#define VN_CACHED(vp) 0 -#define VN_DIRTY(vp) 0 -#define VMODIFY(vp) VN_FLAGSET(vp, VMODIFIED) -#define VUNMODIFY(vp) VN_FLAGCLR(vp, VMODIFIED) - - -/* - * Flags to VOP_SETATTR/VOP_GETATTR. - */ -#define ATTR_UTIME 0x01 /* non-default utime(2) request */ -#define ATTR_DMI 0x08 /* invocation from a DMI function */ -#define ATTR_LAZY 0x80 /* set/get attributes lazily */ -#define ATTR_NONBLOCK 0x100 /* return EAGAIN if operation would block */ -#define ATTR_NOLOCK 0x200 /* Don't grab any conflicting locks */ -#define ATTR_NOSIZETOK 0x400 /* Don't get the SIZE token */ - -/* - * Flags to VOP_FSYNC and VOP_RECLAIM. - */ -#define FSYNC_NOWAIT 0 /* asynchronous flush */ -#define FSYNC_WAIT 0x1 /* synchronous fsync or forced reclaim */ -#define FSYNC_INVAL 0x2 /* flush and invalidate cached data */ -#define FSYNC_DATA 0x4 /* synchronous fsync of data only */ - - -static inline struct xfs_vnode *vn_grab(struct xfs_vnode *vp) -{ - printf("vn_grab NI\n"); -// struct inode *inode = igrab(vn_to_inode(vp)); -// return inode ? vn_from_inode(inode) : NULL; - return NULL; -} - -static inline void vn_atime_to_bstime(struct xfs_vnode *vp, xfs_bstime_t *bs_atime) -{ - printf("%s NI\n", __func__); -// bs_atime->tv_sec = vp->v_inode.i_atime.tv_sec; -// bs_atime->tv_nsec = vp->v_inode.i_atime.tv_nsec; -} - -static inline void vn_atime_to_timespec(struct xfs_vnode *vp, struct timespec *ts) -{ -// *ts = vp->v_vnode->va_atime; -} - -/* - * Tracking vnode activity. - */ -#if defined(XFS_VNODE_TRACE) - -#define VNODE_TRACE_SIZE 16 /* number of trace entries */ -#define VNODE_KTRACE_ENTRY 1 -#define VNODE_KTRACE_EXIT 2 -#define VNODE_KTRACE_HOLD 3 -#define VNODE_KTRACE_REF 4 -#define VNODE_KTRACE_RELE 5 - -extern void vn_trace_entry(struct xfs_vnode *, char *, inst_t *); -extern void vn_trace_exit(struct xfs_vnode *, char *, inst_t *); -extern void vn_trace_hold(struct xfs_vnode *, char *, int, inst_t *); -extern void vn_trace_ref(struct xfs_vnode *, char *, int, inst_t *); -extern void vn_trace_rele(struct xfs_vnode *, char *, int, inst_t *); - - - -#define VN_TRACE(vp) \ - vn_trace_ref(vp, __FILE__, __LINE__, (inst_t *)__return_address) -#else -#define vn_trace_entry(a,b,c) -#define vn_trace_exit(a,b,c) -#define vn_trace_hold(a,b,c,d) -#define vn_trace_ref(a,b,c,d) -#define vn_trace_rele(a,b,c,d) -#define VN_TRACE(vp) -#endif - -#endif /* __XFS_VNODE_H__ */ diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_vnops.c b/sys/gnu/fs/xfs/FreeBSD/xfs_vnops.c deleted file mode 100644 index 01aa0e5..0000000 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_vnops.c +++ /dev/null @@ -1,1680 +0,0 @@ -/* - * Copyright (c) 2001, Alexander Kabaev - * Copyright (c) 2006, Russell Cattelan Digital Elves Inc. - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. - * - * $FreeBSD$ - */ -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/namei.h> -#include <sys/kernel.h> -#include <sys/fcntl.h> -#include <sys/mount.h> -#include <sys/unistd.h> -#include <sys/vnode.h> -#include <sys/dirent.h> -#include <sys/ioccom.h> -#include <sys/malloc.h> -#include <sys/extattr.h> - -#include <vm/vm.h> -#include <vm/vm_extern.h> -#include <vm/vm_object.h> -#include <vm/vm_page.h> -#include <vm/vm_pager.h> -#include <vm/vnode_pager.h> - -#define NO_VFS_MACROS -#include "xfs.h" -#include "xfs_types.h" -#include "xfs_bit.h" -#include "xfs_inum.h" -#include "xfs_log.h" -#include "xfs_trans.h" -#include "xfs_trans_priv.h" -#include "xfs_sb.h" -#include "xfs_ag.h" -#include "xfs_dir.h" -#include "xfs_dir2.h" -#include "xfs_dmapi.h" -#include "xfs_mount.h" -#include "xfs_alloc_btree.h" -#include "xfs_bmap_btree.h" -#include "xfs_ialloc_btree.h" -#include "xfs_btree.h" -#include "xfs_imap.h" -#include "xfs_attr.h" -#include "xfs_attr_sf.h" -#include "xfs_dir_sf.h" -#include "xfs_dir2_sf.h" -#include "xfs_dinode.h" -#include "xfs_ialloc.h" -#include "xfs_alloc.h" -#include "xfs_inode.h" -#include "xfs_inode_item.h" -#include "xfs_acl.h" -#include "xfs_cap.h" -#include "xfs_mac.h" -#include "xfs_iomap.h" -#include "xfs_clnt.h" -#include "xfs_mountops.h" - -/* - * Prototypes for XFS vnode operations. - */ -static vop_access_t _xfs_access; -static vop_advlock_t _xfs_advlock; -static vop_bmap_t _xfs_bmap; -static vop_cachedlookup_t _xfs_cachedlookup; -static vop_close_t _xfs_close; -static vop_create_t _xfs_create; -static vop_deleteextattr_t _xfs_deleteextattr; -static vop_fsync_t _xfs_fsync; -static vop_getattr_t _xfs_getattr; -static vop_getextattr_t _xfs_getextattr; -static vop_inactive_t _xfs_inactive; -static vop_ioctl_t _xfs_ioctl; -static vop_link_t _xfs_link; -static vop_listextattr_t _xfs_listextattr; -static vop_mkdir_t _xfs_mkdir; -static vop_mknod_t _xfs_mknod; -static vop_open_t _xfs_open; -static vop_read_t _xfs_read; -static vop_readdir_t _xfs_readdir; -static vop_readlink_t _xfs_readlink; -static vop_reclaim_t _xfs_reclaim; -static vop_remove_t _xfs_remove; -static vop_rename_t _xfs_rename; -static vop_rmdir_t _xfs_rmdir; -static vop_setattr_t _xfs_setattr; -static vop_setextattr_t _xfs_setextattr; -static vop_strategy_t _xfs_strategy; -static vop_symlink_t _xfs_symlink; -static vop_write_t _xfs_write; -static vop_vptofh_t _xfs_vptofh; - -struct vop_vector xfs_vnops = { - .vop_default = &default_vnodeops, - .vop_access = _xfs_access, - .vop_advlock = _xfs_advlock, - .vop_bmap = _xfs_bmap, - .vop_cachedlookup = _xfs_cachedlookup, - .vop_close = _xfs_close, - .vop_create = _xfs_create, - .vop_deleteextattr = _xfs_deleteextattr, - .vop_fsync = _xfs_fsync, - .vop_getattr = _xfs_getattr, - .vop_getextattr = _xfs_getextattr, - .vop_inactive = _xfs_inactive, - .vop_ioctl = _xfs_ioctl, - .vop_link = _xfs_link, - .vop_listextattr = _xfs_listextattr, - .vop_lookup = vfs_cache_lookup, - .vop_mkdir = _xfs_mkdir, - .vop_mknod = _xfs_mknod, - .vop_open = _xfs_open, - .vop_read = _xfs_read, - .vop_readdir = _xfs_readdir, - .vop_readlink = _xfs_readlink, - .vop_reclaim = _xfs_reclaim, - .vop_remove = _xfs_remove, - .vop_rename = _xfs_rename, - .vop_rmdir = _xfs_rmdir, - .vop_setattr = _xfs_setattr, - .vop_setextattr = _xfs_setextattr, - .vop_strategy = _xfs_strategy, - .vop_symlink = _xfs_symlink, - .vop_write = _xfs_write, - .vop_vptofh = _xfs_vptofh, -}; - -/* - * FIFO's specific operations. - */ - -static vop_close_t _xfsfifo_close; -static vop_read_t _xfsfifo_read; -static vop_kqfilter_t _xfsfifo_kqfilter; -static vop_write_t _xfsfifo_write; - -struct vop_vector xfs_fifoops = { - .vop_default = &fifo_specops, - .vop_access = _xfs_access, - .vop_close = _xfsfifo_close, - .vop_fsync = _xfs_fsync, - .vop_getattr = _xfs_getattr, - .vop_inactive = _xfs_inactive, - .vop_kqfilter = _xfsfifo_kqfilter, - .vop_read = _xfsfifo_read, - .vop_reclaim = _xfs_reclaim, - .vop_setattr = _xfs_setattr, - .vop_write = _xfsfifo_write, - .vop_vptofh = _xfs_vptofh, -}; - -static int -_xfs_access( - struct vop_access_args /* { - struct vnode *a_vp; - accmode_t a_accmode; - struct ucred *a_cred; - struct thread *a_td; - } */ *ap) -{ - int error; - - XVOP_ACCESS(VPTOXFSVP(ap->a_vp), ap->a_accmode, ap->a_cred, error); - return (error); -} - -static int -_xfs_open( - struct vop_open_args /* { - struct vnode *a_vp; - int a_mode; - struct ucred *a_cred; - struct thread *a_td; - struct file *a_fp; - } */ *ap) -{ - int error; - - XVOP_OPEN(VPTOXFSVP(ap->a_vp), ap->a_cred, error); - if (error == 0) - vnode_create_vobject(ap->a_vp, 0, ap->a_td); - return (error); -} - -static int -_xfs_close( - struct vop_close_args /* { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - int a_fflag; - struct ucred *a_cred; - struct thread *a_td; - } */ *ap) -{ - int error = 0; - /* XVOP_CLOSE(VPTOXFSVP(ap->a_vp), NULL, error); */ - return (error); -} - -static int -_xfs_getattr( - struct vop_getattr_args /* { - struct vnode *a_vp; - struct vattr *a_vap; - struct ucred *a_cred; - } */ *ap) -{ - struct vnode *vp = ap->a_vp; - struct vattr *vap = ap->a_vap; - struct mount *mp; - xfs_vattr_t va; - int error; - /* extract the xfs vnode from the private data */ - //xfs_vnode_t *xvp = (xfs_vnode_t *)vp->v_data; - - memset(&va,0,sizeof(xfs_vattr_t)); - va.va_mask = XFS_AT_STAT|XFS_AT_GENCOUNT|XFS_AT_XFLAGS; - - XVOP_GETATTR(VPTOXFSVP(vp), &va, 0, ap->a_cred, error); - if (error) - return (error); - - mp = vp->v_mount; - - vap->va_type = IFTOVT(((xfs_vnode_t *)vp->v_data)->v_inode->i_d.di_mode); - vap->va_mode = va.va_mode; - vap->va_nlink = va.va_nlink; - vap->va_uid = va.va_uid; - vap->va_gid = va.va_gid; - vap->va_fsid = mp->mnt_stat.f_fsid.val[0]; - vap->va_fileid = va.va_nodeid; - vap->va_size = va.va_size; - vap->va_blocksize = va.va_blocksize; - vap->va_atime = va.va_atime; - vap->va_mtime = va.va_mtime; - vap->va_ctime = va.va_ctime; - vap->va_gen = va.va_gen; - vap->va_rdev = va.va_rdev; - vap->va_bytes = (va.va_nblocks << BBSHIFT); - - /* XFS now supports devices that have block sizes - * other than 512 so BBSHIFT will work for now - * but need to get this value from the super block - */ - - /* - * Fields with no direct equivalent in XFS - */ - vap->va_filerev = 0; - vap->va_flags = 0; - - return (0); -} - -static int -_xfs_setattr( - struct vop_setattr_args /* { - struct vnode *a_vp; - struct vattr *a_vap; - struct ucred *a_cred; - } */ *ap) -{ - struct vnode *vp = ap->a_vp; - struct vattr *vap = ap->a_vap; - xfs_vattr_t va; - int error; - - /* - * Check for unsettable attributes. - */ -#ifdef RMC - if ((vap->va_type != VNON) || (vap->va_nlink != VNOVAL) || - (vap->va_fsid != VNOVAL) || (vap->va_fileid != VNOVAL) || - (vap->va_blocksize != VNOVAL) || (vap->va_rdev != VNOVAL) || - ((int)vap->va_bytes != VNOVAL) || (vap->va_gen != VNOVAL)) - return (EINVAL); -#endif - - memset(&va, 0, sizeof(va)); - - if (vap->va_uid != (uid_t)VNOVAL) { - va.va_mask |= XFS_AT_UID; - va.va_uid = vap->va_uid; - } - if (vap->va_gid != (gid_t)VNOVAL) { - va.va_mask |= XFS_AT_GID; - va.va_gid = vap->va_gid; - } - if (vap->va_size != VNOVAL) { - va.va_mask |= XFS_AT_SIZE; - va.va_size = vap->va_size; - } - if (vap->va_atime.tv_sec != VNOVAL) { - va.va_mask |= XFS_AT_ATIME; - va.va_atime = vap->va_atime; - } - if (vap->va_mtime.tv_sec != VNOVAL) { - va.va_mask |= XFS_AT_MTIME; - va.va_mtime = vap->va_mtime; - } - if (vap->va_ctime.tv_sec != VNOVAL) { - va.va_mask |= XFS_AT_CTIME; - va.va_ctime = vap->va_ctime; - } - if (vap->va_mode != (mode_t)VNOVAL) { - va.va_mask |= XFS_AT_MODE; - va.va_mode = vap->va_mode; - } - - XVOP_SETATTR(VPTOXFSVP(vp), &va, 0, ap->a_cred, error); - return (error); -} - -static int -_xfs_inactive( - struct vop_inactive_args /* { - struct vnode *a_vp; - struct thread *a_td; - } */ *ap) -{ - struct vnode *vp = ap->a_vp; - struct thread *td = ap->a_td; - int error; - - XVOP_INACTIVE(VPTOXFSVP(vp), td->td_ucred, error); - return (error); -} - -static int -_xfs_read( - struct vop_read_args /* { - struct vnode *a_vp; - struct uio *a_uio; - int a_ioflag; - struct ucred *a_cred; - } */ *ap) -{ - struct vnode *vp = ap->a_vp; - struct uio *uio = ap->a_uio; - int error; - - switch (vp->v_type) { - case VREG: - break; - case VDIR: - return (EISDIR); - default: - return (EPERM); - }; - - XVOP_READ(VPTOXFSVP(vp), uio, ap->a_ioflag, ap->a_cred, error); - return error; -} - -int -xfs_read_file(xfs_mount_t *mp, xfs_inode_t *ip, struct uio *uio, int ioflag) -{ - xfs_fileoff_t lbn, nextlbn; - xfs_fsize_t bytesinfile; - long size, xfersize, blkoffset; - struct buf *bp; - struct vnode *vp; - int error, orig_resid; - int seqcount; - - seqcount = ioflag >> IO_SEQSHIFT; - - orig_resid = uio->uio_resid; - if (orig_resid <= 0) - return (0); - - vp = XFS_ITOV(ip)->v_vnode; - - /* - * Ok so we couldn't do it all in one vm trick... - * so cycle around trying smaller bites.. - */ - for (error = 0, bp = NULL; uio->uio_resid > 0; bp = NULL) { - if ((bytesinfile = ip->i_d.di_size - uio->uio_offset) <= 0) - break; - - lbn = XFS_B_TO_FSBT(mp, uio->uio_offset); - nextlbn = lbn + 1; - - /* - * size of buffer. The buffer representing the - * end of the file is rounded up to the size of - * the block type ( fragment or full block, - * depending ). - */ - size = mp->m_sb.sb_blocksize; - blkoffset = XFS_B_FSB_OFFSET(mp, uio->uio_offset); - - /* - * The amount we want to transfer in this iteration is - * one FS block less the amount of the data before - * our startpoint (duh!) - */ - xfersize = mp->m_sb.sb_blocksize - blkoffset; - - /* - * But if we actually want less than the block, - * or the file doesn't have a whole block more of data, - * then use the lesser number. - */ - if (uio->uio_resid < xfersize) - xfersize = uio->uio_resid; - if (bytesinfile < xfersize) - xfersize = bytesinfile; - - if (XFS_FSB_TO_B(mp, nextlbn) >= ip->i_d.di_size ) { - /* - * Don't do readahead if this is the end of the file. - */ - error = bread(vp, lbn, size, NOCRED, &bp); - } else if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERR) == 0) { - /* - * Otherwise if we are allowed to cluster, - * grab as much as we can. - * - * XXX This may not be a win if we are not - * doing sequential access. - */ - error = cluster_read(vp, ip->i_d.di_size, lbn, - size, NOCRED, uio->uio_resid, seqcount, &bp); - } else if (seqcount > 1) { - /* - * If we are NOT allowed to cluster, then - * if we appear to be acting sequentially, - * fire off a request for a readahead - * as well as a read. Note that the 4th and 5th - * arguments point to arrays of the size specified in - * the 6th argument. - */ - int nextsize = mp->m_sb.sb_blocksize; - error = breadn(vp, lbn, - size, &nextlbn, &nextsize, 1, NOCRED, &bp); - } else { - /* - * Failing all of the above, just read what the - * user asked for. Interestingly, the same as - * the first option above. - */ - error = bread(vp, lbn, size, NOCRED, &bp); - } - if (error) { - brelse(bp); - bp = NULL; - break; - } - - /* - * If IO_DIRECT then set B_DIRECT for the buffer. This - * will cause us to attempt to release the buffer later on - * and will cause the buffer cache to attempt to free the - * underlying pages. - */ - if (ioflag & IO_DIRECT) - bp->b_flags |= B_DIRECT; - - /* - * We should only get non-zero b_resid when an I/O error - * has occurred, which should cause us to break above. - * However, if the short read did not cause an error, - * then we want to ensure that we do not uiomove bad - * or uninitialized data. - */ - size -= bp->b_resid; - if (size < xfersize) { - if (size == 0) - break; - xfersize = size; - } - - /* - * otherwise use the general form - */ - error = uiomove((char *)bp->b_data + blkoffset, - (int)xfersize, uio); - - if (error) - break; - - if (ioflag & (IO_VMIO|IO_DIRECT) ) { - /* - * If there are no dependencies, and it's VMIO, - * then we don't need the buf, mark it available - * for freeing. The VM has the data. - */ - bp->b_flags |= B_RELBUF; - brelse(bp); - } else { - /* - * Otherwise let whoever - * made the request take care of - * freeing it. We just queue - * it onto another list. - */ - bqrelse(bp); - } - } - - /* - * This can only happen in the case of an error - * because the loop above resets bp to NULL on each iteration - * and on normal completion has not set a new value into it. - * so it must have come from a 'break' statement - */ - if (bp != NULL) { - if (ioflag & (IO_VMIO|IO_DIRECT)) { - bp->b_flags |= B_RELBUF; - brelse(bp); - } else - bqrelse(bp); - } - - return (error); -} - -static int -_xfs_write(struct vop_write_args /* { - struct vnode *a_vp; - struct uio *a_uio; - int a_ioflag; - struct ucred *a_cred; - } */ *ap) -{ - struct vnode *vp = ap->a_vp; - struct uio *uio = ap->a_uio; - int ioflag = ap->a_ioflag; - int error; - - xfs_vnode_t *xvp = (xfs_vnode_t *)vp->v_data; - - error = xfs_write(xvp->v_bh.bh_first, uio, ioflag, ap->a_cred); - - if (error < 0) { - printf("Xfs_write got error %d\n",error); - return -error; - } - return 0; -} - - -int -xfs_write_file(xfs_inode_t *xip, struct uio *uio, int ioflag) -{ - struct buf *bp; - //struct thread *td; - daddr_t lbn; - off_t osize = 0; - off_t offset= 0; - int blkoffset, error, resid, xfersize; - int fsblocksize; - int seqcount; - xfs_iomap_t iomap; - int maps = 1; - - xfs_vnode_t *xvp = XFS_ITOV(xip); - struct vnode *vp = xvp->v_vnode; - - xfs_mount_t *mp = (&xip->i_iocore)->io_mount; - - seqcount = ioflag >> IO_SEQSHIFT; - - memset(&iomap,0,sizeof(xfs_iomap_t)); - - /* - * Maybe this should be above the vnode op call, but so long as - * file servers have no limits, I don't think it matters. - */ -#if 0 - td = uio->uio_td; - if (vn_rlimit_fsize(vp, uio, uio->uio_td)) - return (EFBIG); -#endif - - resid = uio->uio_resid; - offset = uio->uio_offset; - osize = xip->i_d.di_size; - - /* xfs bmap wants bytes for both offset and size */ - XVOP_BMAP(xvp, - uio->uio_offset, - uio->uio_resid, - BMAPI_WRITE|BMAPI_DIRECT, - &iomap, &maps, error); - if(error) { - printf("XVOP_BMAP failed\n"); - goto error; - } - - for (error = 0; uio->uio_resid > 0;) { - - lbn = XFS_B_TO_FSBT(mp, offset); - blkoffset = XFS_B_FSB_OFFSET(mp, offset); - xfersize = mp->m_sb.sb_blocksize - blkoffset; - fsblocksize = mp->m_sb.sb_blocksize; - - if (uio->uio_resid < xfersize) - xfersize = uio->uio_resid; - - /* - * getblk sets buf by blkno * bo->bo_bsize - * bo_bsize is set from the mnt point fsize - * so we call getblk in the case using fsblocks - * not basic blocks - */ - - bp = getblk(vp, lbn, fsblocksize, 0, 0, 0); - if(!bp) { - printf("getblk failed\n"); - error = EINVAL; - break; - } - - if (!(bp->b_flags & B_CACHE) && fsblocksize > xfersize) - vfs_bio_clrbuf(bp); - - if (offset + xfersize > xip->i_d.di_size) { - xip->i_d.di_size = offset + xfersize; - vnode_pager_setsize(vp, offset + fsblocksize); - } - - /* move the offset for the next itteration of the loop */ - offset += xfersize; - - error = uiomove((char *)bp->b_data + blkoffset, xfersize, uio); - - if ((ioflag & IO_VMIO) && - (LIST_FIRST(&bp->b_dep) == NULL)) /* in ext2fs? */ - bp->b_flags |= B_RELBUF; - - /* force to full direct for now */ - bp->b_flags |= B_DIRECT; - /* and sync ... the delay path is not pushing data out */ - ioflag |= IO_SYNC; - - if (ioflag & IO_SYNC) { - (void)bwrite(bp); - } else if (0 /* RMC xfersize + blkoffset == fs->s_frag_size */) { - if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERW) == 0) { - bp->b_flags |= B_CLUSTEROK; - cluster_write(vp, bp, osize, seqcount); - } else { - bawrite(bp); - } - } else { - bp->b_flags |= B_CLUSTEROK; - bdwrite(bp); - } - if (error || xfersize == 0) - break; - } - /* - * If we successfully wrote any data, and we are not the superuser - * we clear the setuid and setgid bits as a precaution against - * tampering. - */ -#if 0 - if (resid > uio->uio_resid && ap->a_cred && ap->a_cred->cr_uid != 0) - ip->i_mode &= ~(ISUID | ISGID); -#endif - if (error) { - if (ioflag & IO_UNIT) { -#if 0 - (void)ext2_truncate(vp, osize, - ioflag & IO_SYNC, ap->a_cred, uio->uio_td); -#endif - uio->uio_offset -= resid - uio->uio_resid; - uio->uio_resid = resid; - } - } else if (resid > uio->uio_resid && (ioflag & IO_SYNC)) { - /* Update the vnode here? */ - } - -error: - return error; -} - -static int -_xfs_create( - struct vop_create_args /* { - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - struct vattr *a_vap; - } */ *ap) -{ - struct vnode *dvp = ap->a_dvp; - struct vattr *vap = ap->a_vap; - struct thread *td = curthread; - struct ucred *credp = td->td_ucred; - struct componentname *cnp = ap->a_cnp; - xfs_vnode_t *xvp; - xfs_vattr_t va; - int error; - - memset(&va, 0, sizeof (va)); - va.va_mask |= XFS_AT_MODE; - va.va_mode = vap->va_mode; - va.va_mask |= XFS_AT_TYPE; - va.va_mode |= VTTOIF(vap->va_type); - - xvp = NULL; - XVOP_CREATE(VPTOXFSVP(dvp), cnp, &va, &xvp, credp, error); - - if (error == 0) { - *ap->a_vpp = xvp->v_vnode; - VOP_LOCK(xvp->v_vnode, LK_EXCLUSIVE); - } - - return (error); -} - -extern int xfs_remove(bhv_desc_t *, bhv_desc_t *, vname_t *, cred_t *); - -static int -_xfs_remove( - struct vop_remove_args /* { - struct vnodeop_desc *a_desc; - struct vnode * a_dvp; - struct vnode * a_vp; - struct componentname * a_cnp; - } */ *ap) -{ - struct vnode *vp = ap->a_vp; - struct thread *td = curthread; - struct ucred *credp = td->td_ucred; - /* - struct vnode *dvp = ap->a_dvp; - struct componentname *cnp = ap->a_cnp; - */ - int error; - - if (vp->v_type == VDIR || vp->v_usecount != 1) - return (EPERM); - - error = xfs_remove(VPTOXFSVP(ap->a_dvp)->v_bh.bh_first, - VPTOXFSVP(ap->a_vp)->v_bh.bh_first, - ap->a_cnp,credp); - - cache_purge(vp); - return error; -} - -static int -_xfs_rename( - struct vop_rename_args /* { - struct vnode *a_fdvp; - struct vnode *a_fvp; - struct componentname *a_fcnp; - struct vnode *a_tdvp; - struct vnode *a_tvp; - struct componentname *a_tcnp; - } */ *ap) -{ - struct vnode *fvp = ap->a_fvp; - struct vnode *tvp = ap->a_tvp; - struct vnode *fdvp = ap->a_fdvp; - struct vnode *tdvp = ap->a_tdvp; -/* struct componentname *tcnp = ap->a_tcnp; */ -/* struct componentname *fcnp = ap->a_fcnp;*/ - int error = EPERM; - - if (error) - goto out; - - /* Check for cross-device rename */ - if ((fvp->v_mount != tdvp->v_mount) || - (tvp && (fvp->v_mount != tvp->v_mount))) { - error = EXDEV; - goto out; - } - - if (tvp && tvp->v_usecount > 1) { - error = EBUSY; - goto out; - } - - if (fvp->v_type == VDIR) { - if (tvp != NULL && tvp->v_type == VDIR) - cache_purge(tdvp); - cache_purge(fdvp); - } -out: - if (tdvp == tvp) - vrele(tdvp); - else - vput(tdvp); - if (tvp) - vput(tvp); - vrele(fdvp); - vrele(fvp); - vgone(fvp); - if (tvp) - vgone(tvp); - return (error); -} - -static int -_xfs_link( - struct vop_link_args /* { - struct vnode *a_tdvp; - struct vnode *a_vp; - struct componentname *a_cnp; - } */ *ap) -{ - xfs_vnode_t *tdvp, *vp; - int error; - - tdvp = VPTOXFSVP(ap->a_tdvp); - vp = VPTOXFSVP(ap->a_vp); - XVOP_LINK(tdvp, vp, ap->a_cnp, NULL, error); - return (error); -} - -static int -_xfs_symlink( - struct vop_symlink_args /* { - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - struct vattr *a_vap; - char *a_target; - } */ *ap) -{ - struct thread *td = curthread; - struct ucred *credp = td->td_ucred; - xfs_vnode_t *xvp; - xfs_vattr_t va; - int error; - - memset(&va, 0, sizeof (va)); - - va.va_mask |= XFS_AT_MODE; - va.va_mode = ap->a_vap->va_mode | S_IFLNK; - va.va_mask |= XFS_AT_TYPE; - - XVOP_SYMLINK(VPTOXFSVP(ap->a_dvp), ap->a_cnp, &va, ap->a_target, - &xvp, credp, error); - - if (error == 0) { - *ap->a_vpp = xvp->v_vnode; - VOP_LOCK(xvp->v_vnode, LK_EXCLUSIVE); - } - - return (error); -} - -static int -_xfs_mknod( - struct vop_mknod_args /* { - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - struct vattr *a_vap; - } */ *ap) -{ - struct vnode *dvp = ap->a_dvp; - struct vattr *vap = ap->a_vap; - struct thread *td = curthread; - struct ucred *credp = td->td_ucred; - struct componentname *cnp = ap->a_cnp; - xfs_vnode_t *xvp; - xfs_vattr_t va; - int error; - - memset(&va, 0, sizeof (va)); - va.va_mask |= XFS_AT_MODE; - va.va_mode = vap->va_mode | S_IFIFO; - va.va_mask |= XFS_AT_TYPE; - va.va_mask |= XFS_AT_RDEV; - va.va_rdev = vap->va_rdev; - - xvp = NULL; - XVOP_CREATE(VPTOXFSVP(dvp), cnp, &va, &xvp, credp, error); - - if (error == 0) { - *ap->a_vpp = xvp->v_vnode; - VOP_LOCK(xvp->v_vnode, LK_EXCLUSIVE); - } - - return (error); -} - -static int -_xfs_mkdir( - struct vop_mkdir_args /* { - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - struct vattr *a_vap; - } */ *ap) -{ - struct vnode *dvp = ap->a_dvp; - struct vattr *vap = ap->a_vap; - struct thread *td = curthread; - struct ucred *credp = td->td_ucred; - struct componentname *cnp = ap->a_cnp; - xfs_vnode_t *xvp; - xfs_vattr_t va; - int error; - - memset(&va, 0, sizeof (va)); - va.va_mask |= XFS_AT_MODE; - va.va_mode = vap->va_mode | S_IFDIR; - va.va_mask |= XFS_AT_TYPE; - - xvp = NULL; - XVOP_MKDIR(VPTOXFSVP(dvp), cnp, &va, &xvp, credp, error); - - if (error == 0) { - *ap->a_vpp = xvp->v_vnode; - VOP_LOCK(xvp->v_vnode, LK_EXCLUSIVE); - } - - return (error); -} - -static int -_xfs_rmdir( - struct vop_rmdir_args /* { - struct vnode *a_dvp; - struct vnode *a_vp; - struct componentname *a_cnp; - } */ *ap) -{ - struct vnode *vp = ap->a_vp; - struct vnode *dvp = ap->a_dvp; -/* struct componentname *cnp = ap->a_cnp; */ - int error; - - if (dvp == vp) - return (EINVAL); - - error = EPERM; - - return (error); -} - -static int -_xfs_readdir( - struct vop_readdir_args /* { - struct vnode *a_vp; - struct uio *a_uio; - struct ucred *a_cred; - int *a_eofflag; - int *a_ncookies; - u_long **a_cookies; - } */ *ap) -{ - struct vnode *vp = ap->a_vp; - struct uio *uio = ap->a_uio; - int error; - off_t off; - int eof = 0; - - if (vp->v_type != VDIR) - return (EPERM); - if (ap->a_ncookies) { - return (EOPNOTSUPP); - } - - error = 0; - while (!eof){ - off = (int)uio->uio_offset; - - XVOP_READDIR(VPTOXFSVP(vp), uio, NULL, &eof, error); - if ((uio->uio_offset == off) || error) { - break; - } - } - - if (ap->a_eofflag) - *ap->a_eofflag = (eof != 0); - - return (error); -} - - -static int -_xfs_readlink( - struct vop_readlink_args /* { - struct vnode *a_vp; - struct uio *a_uio; - struct ucred *a_cred; - } */ *ap) -{ - struct vnode *vp = ap->a_vp; - struct uio *uio = ap->a_uio; - struct ucred *cred = ap->a_cred; - int error; - - XVOP_READLINK(VPTOXFSVP(vp), uio, 0, cred, error); - return (error); -} - -static int -_xfs_fsync( - struct vop_fsync_args /* { - struct vnode * a_vp; - int a_waitfor; - struct thread * a_td; - } */ *ap) -{ - xfs_vnode_t *vp = VPTOXFSVP(ap->a_vp); - int flags = FSYNC_DATA; - int error; - - if (ap->a_waitfor == MNT_WAIT) - flags |= FSYNC_WAIT; - XVOP_FSYNC(vp, flags, ap->a_td->td_ucred, (xfs_off_t)0, (xfs_off_t)-1, error); - - return (error); -} - -static int -_xfs_bmap( - struct vop_bmap_args /* { - struct vnode *a_vp; - daddr_t a_bn; - struct bufobj **a_bop; - daddr_t *a_bnp; - int *a_runp; - int *a_runb; - } */ *ap) -{ - xfs_iomap_t iomap; - xfs_off_t offset; - ssize_t size; - struct mount *mp; - struct xfs_mount *xmp; - struct xfs_vnode *xvp; - int error, maxrun, retbm; - - mp = ap->a_vp->v_mount; - xmp = XFS_VFSTOM(MNTTOVFS(mp)); - if (ap->a_bop != NULL) - *ap->a_bop = &xmp->m_ddev_targp->specvp->v_bufobj; - if (ap->a_bnp == NULL) - return (0); - - xvp = VPTOXFSVP(ap->a_vp); - retbm = 1; - - offset = XFS_FSB_TO_B(xmp, ap->a_bn); - size = XFS_FSB_TO_B(xmp, 1); - XVOP_BMAP(xvp, offset, size, BMAPI_READ, &iomap, &retbm, error); - if (error) - return (error); - if (retbm == 0 || iomap.iomap_bn == IOMAP_DADDR_NULL) { - *ap->a_bnp = (daddr_t)-1; - if (ap->a_runb) - *ap->a_runb = 0; - if (ap->a_runp) - *ap->a_runp = 0; - } else { - *ap->a_bnp = iomap.iomap_bn + btodb(iomap.iomap_delta); - maxrun = mp->mnt_iosize_max / mp->mnt_stat.f_iosize - 1; - if (ap->a_runb) { - *ap->a_runb = XFS_B_TO_FSB(xmp, iomap.iomap_delta); - if (*ap->a_runb > maxrun) - *ap->a_runb = maxrun; - } - if (ap->a_runp) { - *ap->a_runp = - XFS_B_TO_FSB(xmp, iomap.iomap_bsize - - iomap.iomap_delta - size); - if (*ap->a_runp > maxrun) - *ap->a_runp = maxrun; - } - } - return (0); -} - -static int -_xfs_strategy( - struct vop_strategy_args /* { - struct vnode *a_vp; - struct buf *a_bp; - } */ *ap) -{ - daddr_t blkno; - struct buf *bp; - struct bufobj *bo; - struct vnode *vp; - struct xfs_mount *xmp; - int error; - - bp = ap->a_bp; - vp = ap->a_vp; - - KASSERT(ap->a_vp == ap->a_bp->b_vp, ("%s(%p != %p)", - __func__, ap->a_vp, ap->a_bp->b_vp)); - if (bp->b_blkno == bp->b_lblkno) { - error = VOP_BMAP(vp, bp->b_lblkno, NULL, &blkno, NULL, NULL); - bp->b_blkno = blkno; - bp->b_iooffset = (blkno << BBSHIFT); - if (error) { - bp->b_error = error; - bp->b_ioflags |= BIO_ERROR; - bufdone(bp); - return (0); - } - if ((long)bp->b_blkno == -1) - vfs_bio_clrbuf(bp); - } - if ((long)bp->b_blkno == -1) { - bufdone(bp); - return (0); - } - - xmp = XFS_VFSTOM(MNTTOVFS(vp->v_mount)); - bo = &xmp->m_ddev_targp->specvp->v_bufobj; - bo->bo_ops->bop_strategy(bo, bp); - return (0); -} - -int -_xfs_ioctl( - struct vop_ioctl_args /* { - struct vnode *a_vp; - u_long a_command; - caddr_t a_data; - int fflag; - struct ucred *cred; - struct thread *a_td; - } */ *ap) -{ -/* struct vnode *vp = ap->a_vp; */ -/* struct thread *p = ap->a_td; */ -/* struct file *fp; */ - int error; - - xfs_vnode_t *xvp = VPTOXFSVP(ap->a_vp); - - printf("_xfs_ioctl cmd 0x%lx data %p\n",ap->a_command,ap->a_data); - -// XVOP_IOCTL(xvp,(void *)NULL,(void *)NULL,ap->a_fflag,ap->a_command,ap->a_data,error); - error = xfs_ioctl(xvp->v_bh.bh_first,NULL,NULL,ap->a_fflag,ap->a_command,ap->a_data); - - return error; -} - -int -_xfs_advlock( - struct vop_advlock_args /* { - struct vnode *a_vp; - caddr_t a_id; - int a_op; - struct flock *a_fl; - int a_flags; - } */ *ap) -{ -/* struct vnode *vp = ap->a_vp;*/ - struct flock *fl = ap->a_fl; -/* caddr_t id = (caddr_t)1 */ /* ap->a_id */; -/* int flags = ap->a_flags; */ - off_t start, end, size; - int error/* , lkop */; - - /*KAN: temp */ - return (EOPNOTSUPP); - - size = 0; - error = 0; - switch (fl->l_whence) { - case SEEK_SET: - case SEEK_CUR: - start = fl->l_start; - break; - case SEEK_END: - start = fl->l_start + size; - default: - return (EINVAL); - } - if (start < 0) - return (EINVAL); - if (fl->l_len == 0) - end = -1; - else { - end = start + fl->l_len - 1; - if (end < start) - return (EINVAL); - } -#ifdef notyet - switch (ap->a_op) { - case F_SETLK: - error = lf_advlock(ap, &vp->v_lockf, size); - break; - case F_UNLCK: - lf_advlock(ap, &vp->v_lockf, size); - break; - case F_GETLK: - error = lf_advlock(ap, &vp->v_lockf, size); - break; - default: - return (EINVAL); - } -#endif - return (error); -} - -static int -_xfs_cachedlookup( - struct vop_cachedlookup_args /* { - struct vnode * a_dvp; - struct vnode ** a_vpp; - struct componentname * a_cnp; - } */ *ap) -{ - struct vnode *dvp, *tvp; - struct xfs_vnode *cvp; - int islastcn; - int error; - struct vnode **vpp = ap->a_vpp; - struct componentname *cnp = ap->a_cnp; - struct ucred *cred = cnp->cn_cred; - int flags = cnp->cn_flags; - int nameiop = cnp->cn_nameiop; - struct thread *td = cnp->cn_thread; - - char *pname = cnp->cn_nameptr; - int namelen = cnp->cn_namelen; - - *vpp = NULL; - dvp = ap->a_dvp; - islastcn = flags & ISLASTCN; - - XVOP_LOOKUP(VPTOXFSVP(dvp), cnp, &cvp, 0, NULL, cred, error); - - if (error == ENOENT) { - if ((nameiop == CREATE || nameiop == RENAME || - nameiop == DELETE) && islastcn) - { - error = VOP_ACCESS(dvp, VWRITE, cred, td); - if (error) - return (error); - cnp->cn_flags |= SAVENAME; - return (EJUSTRETURN); - } - if ((cnp->cn_flags & MAKEENTRY) && nameiop != CREATE) - cache_enter(dvp, *vpp, cnp); - return (error); - } - if (error) - return (error); - - tvp = cvp->v_vnode; - - if (nameiop == DELETE && islastcn) { - if ((error = vn_lock(tvp, LK_EXCLUSIVE))) { - vrele(tvp); - goto err_out; - } - *vpp = tvp; - - /* Directory should be writable for deletes. */ - error = VOP_ACCESS(dvp, VWRITE, cred, td); - if (error) - goto err_out; - - /* XXXKAN: Permission checks for sticky dirs? */ - return (0); - } - - if (nameiop == RENAME && islastcn) { - if ((error = vn_lock(tvp, LK_EXCLUSIVE))) { - vrele(tvp); - goto err_out; - } - *vpp = tvp; - - if ((error = VOP_ACCESS(dvp, VWRITE, cred, td))) - goto err_out; - return (0); - } - - if (flags & ISDOTDOT) { - VOP_UNLOCK(dvp, 0); - error = vn_lock(tvp, cnp->cn_lkflags); - if (error) { - vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY); - vrele(tvp); - goto err_out; - } - *vpp = tvp; - } else if (namelen == 1 && pname[0] == '.') { - *vpp = tvp; - KASSERT(tvp == dvp, ("not same directory")); - } else { - if ((error = vn_lock(tvp, cnp->cn_lkflags))) { - vrele(tvp); - goto err_out; - } - *vpp = tvp; - } - - if (cnp->cn_flags & MAKEENTRY) - cache_enter(dvp, *vpp, cnp); - return (0); - -err_out: - if (*vpp != 0) - vput(*vpp); - return (error); -} - -static int -_xfs_reclaim( - struct vop_reclaim_args /* { - struct vnode *a_vp; - struct thread *a_td; - } */ *ap) -{ - - struct vnode *vp = ap->a_vp; - struct xfs_vnode *xfs_vp = VPTOXFSVP(vp); - int error; - - XVOP_RECLAIM(xfs_vp, error); - kmem_free(xfs_vp, sizeof(*xfs_vp)); - vp->v_data = NULL; - return (error); -} - -static int -_xfs_kqfilter( - struct vop_kqfilter_args /* { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct knote *a_kn; - } */ *ap) -{ - return (0); -} - -struct xfs_inode * -xfs_vtoi(struct xfs_vnode *xvp) -{ - return(XFS_BHVTOI(xvp->v_fbhv)); -} - -/* - * Read wrapper for fifos. - */ -static int -_xfsfifo_read( - struct vop_read_args /* { - struct vnode *a_vp; - struct uio *a_uio; - int a_ioflag; - struct ucred *a_cred; - } */ *ap) -{ - int error, resid; - struct xfs_inode *ip; - struct uio *uio; - - uio = ap->a_uio; - resid = uio->uio_resid; - error = fifo_specops.vop_read(ap); - ip = xfs_vtoi(VPTOXFSVP(ap->a_vp)); - if ((ap->a_vp->v_mount->mnt_flag & MNT_NOATIME) == 0 && ip != NULL && - (uio->uio_resid != resid || (error == 0 && resid != 0))) - xfs_ichgtime(ip, XFS_ICHGTIME_ACC); - return (error); -} - -/* - * Write wrapper for fifos. - */ -static int -_xfsfifo_write( - struct vop_write_args /* { - struct vnode *a_vp; - struct uio *a_uio; - int a_ioflag; - struct ucred *a_cred; - } */ *ap) -{ - int error, resid; - struct uio *uio; - struct xfs_inode *ip; - - uio = ap->a_uio; - resid = uio->uio_resid; - error = fifo_specops.vop_write(ap); - ip = xfs_vtoi(VPTOXFSVP(ap->a_vp)); - if (ip != NULL && (uio->uio_resid != resid || - (error == 0 && resid != 0))) - xfs_ichgtime(ip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); - return (error); -} - -/* - * Close wrapper for fifos. - * - * Update the times on the inode then do device close. - */ -static int -_xfsfifo_close( - struct vop_close_args /* { - struct vnode *a_vp; - int a_fflag; - struct ucred *a_cred; - struct thread *a_td; - } */ *ap) -{ - - return (fifo_specops.vop_close(ap)); -} - -/* - * Kqfilter wrapper for fifos. - * - * Fall through to ufs kqfilter routines if needed - */ -static int -_xfsfifo_kqfilter( - struct vop_kqfilter_args /* { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct knote *a_kn; - } */ *ap) -{ - int error; - - error = fifo_specops.vop_kqfilter(ap); - if (error) - error = _xfs_kqfilter(ap); - return (error); -} - -static int -_xfs_getextattr( - struct vop_getextattr_args /* { - struct vnode *a_vp; - int a_attrnamespace; - const char *a_name; - struct uio *a_uio; - size_t *a_size; - struct ucred *a_cred; - struct thread *a_td; - } */ *ap) -{ - int error; - char *value; - int size; - - error = extattr_check_cred(ap->a_vp, ap->a_attrnamespace, - ap->a_cred, ap->a_td, VREAD); - if (error) - return (error); - - size = ATTR_MAX_VALUELEN; - value = (char *)kmem_zalloc(size, KM_SLEEP); - if (value == NULL) - return (ENOMEM); - - XVOP_ATTR_GET(VPTOXFSVP(ap->a_vp), ap->a_name, value, &size, 1, - ap->a_cred, error); - - if (ap->a_uio != NULL) { - if (ap->a_uio->uio_iov->iov_len < size) - error = ERANGE; - else - uiomove(value, size, ap->a_uio); - } - - if (ap->a_size != NULL) - *ap->a_size = size; - - kmem_free(value, ATTR_MAX_VALUELEN); - return (error); -} - -static int -_xfs_listextattr( - struct vop_listextattr_args /* { - struct vnode *a_vp; - int a_attrnamespace; - struct uio *a_uio; - size_t *a_size; - struct ucred *a_cred; - struct thread *a_td; - } */ *ap) -{ - int error; - char *buf = NULL; - int buf_len = 0; - attrlist_cursor_kern_t cursor = { 0 }; - int i; - char name_len; - int attrnames_len = 0; - int xfs_flags = ATTR_KERNAMELS; - - error = extattr_check_cred(ap->a_vp, ap->a_attrnamespace, - ap->a_cred, ap->a_td, VREAD); - if (error) - return (error); - - if (ap->a_attrnamespace & EXTATTR_NAMESPACE_USER) - xfs_flags |= ATTR_KERNORMALS; - - if (ap->a_attrnamespace & EXTATTR_NAMESPACE_SYSTEM) - xfs_flags |= ATTR_KERNROOTLS; - - if (ap->a_uio == NULL || ap->a_uio->uio_iov[0].iov_base == NULL) { - xfs_flags |= ATTR_KERNOVAL; - buf_len = 0; - } else { - buf = ap->a_uio->uio_iov[0].iov_base; - buf_len = ap->a_uio->uio_iov[0].iov_len; - } - - XVOP_ATTR_LIST(VPTOXFSVP(ap->a_vp), buf, buf_len, xfs_flags, - &cursor, ap->a_cred, error); - if (error < 0) { - attrnames_len = -error; - error = 0; - } - if (buf == NULL) - goto done; - - /* - * extattr_list expects a list of names. Each list - * entry consists of one byte for the name length, followed - * by the name (not null terminated) - */ - name_len=0; - for(i=attrnames_len-1; i > 0 ; --i) { - buf[i] = buf[i-1]; - if (buf[i]) - ++name_len; - else { - buf[i] = name_len; - name_len = 0; - } - } - buf[0] = name_len; - - if (ap->a_uio != NULL) - ap->a_uio->uio_resid -= attrnames_len; - -done: - if (ap->a_size != NULL) - *ap->a_size = attrnames_len; - - return (error); -} - -static int -_xfs_setextattr(struct vop_setextattr_args *ap) -/* -vop_setextattr { - IN struct vnode *a_vp; - IN int a_attrnamespace; - IN const char *a_name; - INOUT struct uio *a_uio; - IN struct ucred *a_cred; - IN struct thread *a_td; -}; -*/ -{ - char *val; - size_t vallen; - int error, xfs_flags; - - if (ap->a_vp->v_type == VCHR) - return (EOPNOTSUPP); - - if (ap->a_uio == NULL) - return (EINVAL); - vallen = ap->a_uio->uio_resid; - if (vallen > ATTR_MAX_VALUELEN) - return (EOVERFLOW); - - if (ap->a_name[0] == '\0') - return (EINVAL); - - error = extattr_check_cred(ap->a_vp, ap->a_attrnamespace, - ap->a_cred, ap->a_td, VWRITE); - if (error) - return (error); - - xfs_flags = 0; - if (ap->a_attrnamespace & EXTATTR_NAMESPACE_USER) - xfs_flags |= ATTR_KERNORMALS; - if (ap->a_attrnamespace & EXTATTR_NAMESPACE_SYSTEM) - xfs_flags |= ATTR_KERNROOTLS; - - val = (char *)kmem_zalloc(vallen, KM_SLEEP); - if (val == NULL) - return (ENOMEM); - error = uiomove(val, (int)vallen, ap->a_uio); - if (error) - goto err_out; - - XVOP_ATTR_SET(VPTOXFSVP(ap->a_vp), ap->a_name, val, vallen, xfs_flags, - ap->a_cred, error); -err_out: - kmem_free(val, vallen); - return(error); -} - -static int -_xfs_deleteextattr(struct vop_deleteextattr_args *ap) -/* -vop_deleteextattr { - IN struct vnode *a_vp; - IN int a_attrnamespace; - IN const char *a_name; - IN struct ucred *a_cred; - IN struct thread *a_td; -}; -*/ -{ - int error, xfs_flags; - - if (ap->a_vp->v_type == VCHR) - return (EOPNOTSUPP); - - if (ap->a_name[0] == '\0') - return (EINVAL); - - error = extattr_check_cred(ap->a_vp, ap->a_attrnamespace, - ap->a_cred, ap->a_td, VWRITE); - if (error) - return (error); - - xfs_flags = 0; - if (ap->a_attrnamespace & EXTATTR_NAMESPACE_USER) - xfs_flags |= ATTR_KERNORMALS; - if (ap->a_attrnamespace & EXTATTR_NAMESPACE_SYSTEM) - xfs_flags |= ATTR_KERNROOTLS; - - XVOP_ATTR_REMOVE(VPTOXFSVP(ap->a_vp), ap->a_name, xfs_flags, - ap->a_cred, error); - return (error); -} - -static int -_xfs_vptofh(struct vop_vptofh_args *ap) -/* -vop_vptofh { - IN struct vnode *a_vp; - IN struct fid *a_fhp; -}; -*/ -{ - printf("xfs_vptofh"); - return ENOSYS; -} |