From cd4a96ffa13420e6d145cb61d90aca9bb1fedfcf Mon Sep 17 00:00:00 2001 From: Giovanni Merlino Date: Fri, 5 Jan 2018 01:21:49 +0100 Subject: [PATCH 1/7] Darwin (macOS) port for the udffsck tool --- configure.ac | 7 + include/bswap.h | 10 + include/mntent.h | 141 ++++++++++ include/sys/isa_defs.h | 216 +++++++++++++++ include/sys/vfs.h | 595 +++++++++++++++++++++++++++++++++++++++++ libudffs/extent.c | 4 +- udffsck/Makefile.am | 4 + udffsck/options.c | 4 +- 8 files changed, 979 insertions(+), 2 deletions(-) create mode 100644 include/mntent.h create mode 100644 include/sys/isa_defs.h create mode 100644 include/sys/vfs.h diff --git a/configure.ac b/configure.ac index 1f479b2f..0d90f85f 100644 --- a/configure.ac +++ b/configure.ac @@ -25,6 +25,12 @@ AC_SYS_LARGEFILE dnl Checks for library functions. AC_SUBST(LTLIBOBJS) +dnl Enable Darwin extensions (AC_USE_SYSTEM_EXTENSIONS does not enable +dnl them in 2.63) +AC_CANONICAL_HOST +AS_CASE([$host_os], + [darwin*], [CPPFLAGS="${CPPFLAGS} -D_DARWIN_C_SOURCE"]) + AC_CONFIG_FILES(Makefile libudffs/Makefile mkudffs/Makefile cdrwtool/Makefile pktsetup/Makefile udffsck/Makefile wrudf/Makefile doc/Makefile) AC_ARG_ENABLE(debug, @@ -38,6 +44,7 @@ esac], [debug=false]) AM_CONDITIONAL(DEBUG, test x"$debug" = x"true") +AM_CONDITIONAL(HAVE_DARWIN, test "${SYS}" = "darwin") AC_ARG_ENABLE(tests, AS_HELP_STRING([--enable-tests], diff --git a/include/bswap.h b/include/bswap.h index 00627faf..b6b54e12 100644 --- a/include/bswap.h +++ b/include/bswap.h @@ -23,6 +23,11 @@ #ifndef __BSWAP_H #define __BSWAP_H +#ifndef HAVE_SYS_ISA_DEFS_H +#include "sys/isa_defs.h" +#define HAVE_SYS_ISA_DEFS_H +#endif + #include "config.h" #include @@ -42,6 +47,11 @@ #endif #endif +/* macOS (Intel) */ +#ifdef __APPLE__ +#define __BYTE_ORDER __LITTLE_ENDIAN +#endif /* __APPLE__ */ + #define constant_swab16(x) \ ((uint16_t)((((uint16_t)(x) & 0x00FFU) << 8) | \ (((uint16_t)(x) & 0xFF00U) >> 8))) diff --git a/include/mntent.h b/include/mntent.h new file mode 100644 index 00000000..ee35c056 --- /dev/null +++ b/include/mntent.h @@ -0,0 +1,141 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T + * All Rights Reserved + */ + +#ifndef _SYS_MNTENT_H +#define _SYS_MNTENT_H + +#pragma ident "%Z%%M% %I% %E% SMI" + +#ifdef __cplusplus +extern "C" { +#endif + +#define MNTTAB "/etc/mnttab" +#define VFSTAB "/etc/vfstab" +#define MNTMAXSTR 128 + +#define MNTTYPE_ZFS "zfs" /* ZFS file system */ +#define MNTTYPE_UFS "ufs" /* Unix file system */ +#define MNTTYPE_NFS "nfs" /* NFS file system */ +#define MNTTYPE_NFS3 "nfs3" /* NFS Version 3 file system */ +#define MNTTYPE_NFS4 "nfs4" /* NFS Version 4 file system */ +#define MNTTYPE_CACHEFS "cachefs" /* Cache File System */ +#define MNTTYPE_PCFS "pcfs" /* PC (MSDOS) file system */ +#define MNTTYPE_PC MNTTYPE_PCFS /* Deprecated name; use MNTTYPE_PCFS */ +#define MNTTYPE_LOFS "lofs" /* Loop back file system */ +#define MNTTYPE_LO MNTTYPE_LOFS /* Deprecated name; use MNTTYPE_LOFS */ +#define MNTTYPE_HSFS "hsfs" /* High Sierra (9660) file system */ +#define MNTTYPE_SWAP "swap" /* Swap file system */ +#define MNTTYPE_TMPFS "tmpfs" /* Tmp volatile file system */ +#define MNTTYPE_AUTOFS "autofs" /* Automounter ``file'' system */ +#define MNTTYPE_MNTFS "mntfs" /* In-kernel mnttab */ +#define MNTTYPE_DEV "dev" /* /dev file system */ +#define MNTTYPE_CTFS "ctfs" /* Contract file system */ +#define MNTTYPE_OBJFS "objfs" /* Kernel object file system */ +#define MNTTYPE_SHAREFS "sharefs" /* Kernel sharetab file system */ + + +#define MNTOPT_RO "ro" /* Read only */ +#define MNTOPT_RW "rw" /* Read/write */ +#define MNTOPT_RQ "rq" /* Read/write with quotas */ +#define MNTOPT_QUOTA "quota" /* Check quotas */ +#define MNTOPT_NOQUOTA "noquota" /* Don't check quotas */ +#define MNTOPT_ONERROR "onerror" /* action to taken on error */ +#define MNTOPT_SOFT "soft" /* Soft mount */ +#define MNTOPT_SEMISOFT "semisoft" /* partial soft, uncommited interface */ +#define MNTOPT_HARD "hard" /* Hard mount */ +#define MNTOPT_SUID "suid" /* Both setuid and devices allowed */ +#define MNTOPT_NOSUID "nosuid" /* Neither setuid nor devices allowed */ +#define MNTOPT_DEVICES "devices" /* Device-special allowed */ +#define MNTOPT_NODEVICES "nodevices" /* Device-special disallowed */ +#define MNTOPT_SETUID "setuid" /* Set uid allowed */ +#define MNTOPT_NOSETUID "nosetuid" /* Set uid not allowed */ +#define MNTOPT_GRPID "grpid" /* SysV-compatible gid on create */ +#define MNTOPT_REMOUNT "remount" /* Change mount options */ +#define MNTOPT_NOSUB "nosub" /* Disallow mounts on subdirs */ +#define MNTOPT_MULTI "multi" /* Do multi-component lookup */ +#define MNTOPT_INTR "intr" /* Allow NFS ops to be interrupted */ +#define MNTOPT_NOINTR "nointr" /* Don't allow interrupted ops */ +#define MNTOPT_PORT "port" /* NFS server IP port number */ +#define MNTOPT_SECURE "secure" /* Secure (AUTH_DES) mounting */ +#define MNTOPT_RSIZE "rsize" /* Max NFS read size (bytes) */ +#define MNTOPT_WSIZE "wsize" /* Max NFS write size (bytes) */ +#define MNTOPT_TIMEO "timeo" /* NFS timeout (1/10 sec) */ +#define MNTOPT_RETRANS "retrans" /* Max retransmissions (soft mnts) */ +#define MNTOPT_ACTIMEO "actimeo" /* Attr cache timeout (sec) */ +#define MNTOPT_ACREGMIN "acregmin" /* Min attr cache timeout (files) */ +#define MNTOPT_ACREGMAX "acregmax" /* Max attr cache timeout (files) */ +#define MNTOPT_ACDIRMIN "acdirmin" /* Min attr cache timeout (dirs) */ +#define MNTOPT_ACDIRMAX "acdirmax" /* Max attr cache timeout (dirs) */ +#define MNTOPT_NOAC "noac" /* Don't cache attributes at all */ +#define MNTOPT_NOCTO "nocto" /* No close-to-open consistency */ +#define MNTOPT_BG "bg" /* Do mount retries in background */ +#define MNTOPT_FG "fg" /* Do mount retries in foreground */ +#define MNTOPT_RETRY "retry" /* Number of mount retries */ +#define MNTOPT_DEV "dev" /* Device id of mounted fs */ +#define MNTOPT_POSIX "posix" /* Get static pathconf for mount */ +#define MNTOPT_MAP "map" /* Automount map */ +#define MNTOPT_DIRECT "direct" /* Automount direct map mount */ +#define MNTOPT_INDIRECT "indirect" /* Automount indirect map mount */ +#define MNTOPT_LLOCK "llock" /* Local locking (no lock manager) */ +#define MNTOPT_IGNORE "ignore" /* Ignore this entry */ +#define MNTOPT_VERS "vers" /* protocol version number indicator */ +#define MNTOPT_PROTO "proto" /* protocol network_id indicator */ +#define MNTOPT_SEC "sec" /* Security flavor indicator */ +#define MNTOPT_SYNCDIR "syncdir" /* Synchronous local directory ops */ +#define MNTOPT_NOSETSEC "nosec" /* Do no allow setting sec attrs */ +#define MNTOPT_NOPRINT "noprint" /* Do not print messages */ +#define MNTOPT_LARGEFILES "largefiles" /* allow large files */ +#define MNTOPT_NOLARGEFILES "nolargefiles" /* don't allow large files */ +#define MNTOPT_FORCEDIRECTIO "forcedirectio" /* Force DirectIO on all files */ +#define MNTOPT_NOFORCEDIRECTIO "noforcedirectio" /* No Force DirectIO */ +#define MNTOPT_DISABLEDIRECTIO "disabledirectio" /* Disable DirectIO ioctls */ +#define MNTOPT_PUBLIC "public" /* Use NFS public file handlee */ +#define MNTOPT_LOGGING "logging" /* enable logging */ +#define MNTOPT_NOLOGGING "nologging" /* disable logging */ +#define MNTOPT_ATIME "atime" /* update atime for files */ +#define MNTOPT_NOATIME "noatime" /* do not update atime for files */ +#define MNTOPT_GLOBAL "global" /* Cluster-wide global mount */ +#define MNTOPT_NOGLOBAL "noglobal" /* Mount local to single node */ +#define MNTOPT_DFRATIME "dfratime" /* Deferred access time updates */ +#define MNTOPT_NODFRATIME "nodfratime" /* No Deferred access time updates */ +#define MNTOPT_NBMAND "nbmand" /* allow non-blocking mandatory locks */ +#define MNTOPT_NONBMAND "nonbmand" /* deny non-blocking mandatory locks */ +#define MNTOPT_XATTR "xattr" /* enable extended attributes */ +#define MNTOPT_NOXATTR "noxattr" /* disable extended attributes */ +#define MNTOPT_EXEC "exec" /* enable executables */ +#define MNTOPT_NOEXEC "noexec" /* disable executables */ +#define MNTOPT_RESTRICT "restrict" /* restricted autofs mount */ +#define MNTOPT_BROWSE "browse" /* browsable autofs mount */ +#define MNTOPT_NOBROWSE "nobrowse" /* non-browsable autofs mount */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MNTENT_H */ diff --git a/include/sys/isa_defs.h b/include/sys/isa_defs.h new file mode 100644 index 00000000..a5bea039 --- /dev/null +++ b/include/sys/isa_defs.h @@ -0,0 +1,216 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_ISA_DEFS_H +#define _SYS_ISA_DEFS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* x86_64 arch specific defines */ +#if defined(__x86_64) || defined(__x86_64__) + +#if !defined(__x86_64) +#define __x86_64 +#endif + +#if !defined(__amd64) +#define __amd64 +#endif + +#if !defined(__x86) +#define __x86 +#endif + +#if !defined(_LP64) +#define _LP64 +#endif + +#if !defined(_LITTLE_ENDIAN) +#define _LITTLE_ENDIAN +#endif + +#define _SUNOS_VTOC_16 + +/* i386 arch specific defines */ +#elif defined(__i386) || defined(__i386__) + +#if !defined(__i386) +#define __i386 +#endif + +#if !defined(__x86) +#define __x86 +#endif + +#if !defined(_ILP32) +#define _ILP32 +#endif + +#if !defined(_LITTLE_ENDIAN) +#define _LITTLE_ENDIAN +#endif + +#define _SUNOS_VTOC_16 + +/* powerpc arch specific defines */ +#elif defined(__powerpc) || defined(__powerpc__) || defined(__powerpc64__) + +#if !defined(__powerpc) +#define __powerpc +#endif + +#if !defined(__powerpc__) +#define __powerpc__ +#endif + +#if defined(__powerpc64__) +#if !defined(_LP64) +#define _LP64 +#endif +#else +#if !defined(_ILP32) +#define _ILP32 +#endif +#endif + +#define _SUNOS_VTOC_16 + +/* arm arch specific defines */ +#elif defined(__arm) || defined(__arm__) || defined(__aarch64__) + +#if !defined(__arm) +#define __arm +#endif + +#if !defined(__arm__) +#define __arm__ +#endif + +#if defined(__aarch64__) +#if !defined(_LP64) +#define _LP64 +#endif +#else +#if !defined(_ILP32) +#define _ILP32 +#endif +#endif + +#if defined(__ARMEL__) || defined(__AARCH64EL__) +#define _LITTLE_ENDIAN +#else +#define _BIG_ENDIAN +#endif + +#define _SUNOS_VTOC_16 + +/* sparc arch specific defines */ +#elif defined(__sparc) || defined(__sparc__) + +#if !defined(__sparc) +#define __sparc +#endif + +#if !defined(__sparc__) +#define __sparc__ +#endif + +#define _BIG_ENDIAN +#define _SUNOS_VTOC_16 + +#if defined(__arch64__) +#if !defined(_LP64) +#define _LP64 +#endif +#else +#if !defined(_ILP32) +#define _ILP32 +#endif +#endif + +/* s390 arch specific defines */ +#elif defined(__s390__) +#if defined(__s390x__) +#if !defined(_LP64) +#define _LP64 +#endif +#else +#if !defined(_ILP32) +#define _ILP32 +#endif +#endif + +#define _BIG_ENDIAN +#define _SUNOS_VTOC_16 + +/* MIPS arch specific defines */ +#elif defined(__mips__) + +#if defined(__MIPSEB__) +#define _BIG_ENDIAN +#elif defined(__MIPSEL__) +#define _LITTLE_ENDIAN +#else +#error MIPS no endian specified +#endif + +#ifndef _LP64 +#define _ILP32 +#endif + +#define _SUNOS_VTOC_16 + +#else +/* + * Currently supported: + * x86_64, i386, arm, powerpc, s390, sparc, and mips + */ +#error "Unsupported ISA type" +#endif + +#if defined(_ILP32) && defined(_LP64) +#error "Both _ILP32 and _LP64 are defined" +#endif + +#if !defined(_ILP32) && !defined(_LP64) +#error "Neither _ILP32 or _LP64 are defined" +#endif + +#if defined(_LITTLE_ENDIAN) && defined(_BIG_ENDIAN) +#error "Both _LITTLE_ENDIAN and _BIG_ENDIAN are defined" +#endif + +#if !defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN) +#error "Neither _LITTLE_ENDIAN nor _BIG_ENDIAN are defined" +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_ISA_DEFS_H */ diff --git a/include/sys/vfs.h b/include/sys/vfs.h new file mode 100644 index 00000000..7b9bbabc --- /dev/null +++ b/include/sys/vfs.h @@ -0,0 +1,595 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + * Portions Copyright 2007 Apple Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_VFS_H +#define _SYS_VFS_H + +#pragma ident "%Z%%M% %I% %E% SMI" + +#ifdef __APPLE__ +/* + * In Darwin, VFS is defined by "sys/mount.h" + */ +#include + +typedef struct mount vfs_t; + +#define LK_NOWAIT 0x00000010 /* do not sleep to await lock */ + +#define vn_vfswlock(vp) (0) + +#define vn_vfsunlock(vp) + +#define VFS_HOLD(vfsp) + +#define VFS_RELE(vfsp) + +#else + +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Data associated with mounted file systems. + */ + +/* + * Operations vector. This is used internal to the kernel; file systems + * supply their list of operations via vfs_setfsops(). + */ + +typedef struct vfsops vfsops_t; + +/* + * File system identifier. Should be unique (at least per machine). + */ +typedef struct { + int val[2]; /* file system id type */ +} fsid_t; + +/* + * File identifier. Should be unique per filesystem on a single + * machine. This is typically called by a stateless file server + * in order to generate "file handles". + * + * Do not change the definition of struct fid ... fid_t without + * letting the CacheFS group know about it! They will have to do at + * least two things, in the same change that changes this structure: + * 1. change CFSVERSION in usr/src/uts/common/sys/fs/cachefs_fs.h + * 2. put the old version # in the canupgrade array + * in cachfs_upgrade() in usr/src/cmd/fs.d/cachefs/fsck/fsck.c + * This is necessary because CacheFS stores FIDs on disk. + * + * Many underlying file systems cast a struct fid into other + * file system dependent structures which may require 4 byte alignment. + * Because a fid starts with a short it may not be 4 byte aligned, the + * fid_pad will force the alignment. + */ +#define MAXFIDSZ 64 +#define OLD_MAXFIDSZ 16 + +typedef struct fid { + union { + long fid_pad; + struct { + ushort_t len; /* length of data in bytes */ + char data[MAXFIDSZ]; /* data (variable len) */ + } _fid; + } un; +} fid_t; + +#ifdef _SYSCALL32 +/* + * Solaris 64 - use old-style cache format with 32-bit aligned fid for on-disk + * struct compatibility. + */ +typedef struct fid32 { + union { + int32_t fid_pad; + struct { + uint16_t len; /* length of data in bytes */ + char data[MAXFIDSZ]; /* data (variable len) */ + } _fid; + } un; +} fid32_t; +#else /* not _SYSCALL32 */ +#define fid32 fid +typedef fid_t fid32_t; +#endif /* _SYSCALL32 */ + +#define fid_len un._fid.len +#define fid_data un._fid.data + +/* + * Structure defining a mount option for a filesystem. + * option names are found in mntent.h + */ +typedef struct mntopt { + char *mo_name; /* option name */ + char **mo_cancel; /* list of options cancelled by this one */ + char *mo_arg; /* argument string for this option */ + int mo_flags; /* flags for this mount option */ + void *mo_data; /* filesystem specific data */ +} mntopt_t; + +/* + * Flags that apply to mount options + */ + +#define MO_SET 0x01 /* option is set */ +#define MO_NODISPLAY 0x02 /* option not listed in mnttab */ +#define MO_HASVALUE 0x04 /* option takes a value */ +#define MO_IGNORE 0x08 /* option ignored by parser */ +#define MO_DEFAULT MO_SET /* option is on by default */ +#define MO_TAG 0x10 /* flags a tag set by user program */ +#define MO_EMPTY 0x20 /* empty space in option table */ + +#define VFS_NOFORCEOPT 0x01 /* honor MO_IGNORE (don't set option) */ +#define VFS_DISPLAY 0x02 /* Turn off MO_NODISPLAY bit for opt */ +#define VFS_NODISPLAY 0x04 /* Turn on MO_NODISPLAY bit for opt */ +#define VFS_CREATEOPT 0x08 /* Create the opt if it's not there */ + +/* + * Structure holding mount option strings for the mounted file system. + */ +typedef struct mntopts { + uint_t mo_count; /* number of entries in table */ + mntopt_t *mo_list; /* list of mount options */ +} mntopts_t; + +/* + * The kstat structures associated with the vopstats are kept in an + * AVL tree. This is to avoid the case where a file system does not + * use a unique fsid_t for each vfs (e.g., namefs). In order to do + * this, we need a structure that the AVL tree can use that also + * references the kstat. + * Note that the vks_fsid is generated from the value reported by + * VFS_STATVFS(). + */ +typedef struct vskstat_anchor { + avl_node_t vsk_node; /* Required for use by AVL routines */ + kstat_t *vsk_ksp; /* kstat structure for vopstats */ + ulong_t vsk_fsid; /* fsid associated w/this FS */ +} vsk_anchor_t; + +extern avl_tree_t vskstat_tree; +extern kmutex_t vskstat_tree_lock; + +/* + * Structure per mounted file system. Each mounted file system has + * an array of operations and an instance record. + * + * The file systems are kept on a doubly linked circular list headed by + * "rootvfs". + * File system implementations should not access this list; + * it's intended for use only in the kernel's vfs layer. + * + * Each zone also has its own list of mounts, containing filesystems mounted + * somewhere within the filesystem tree rooted at the zone's rootpath. The + * list is doubly linked to match the global list. + * + * mnttab locking: the in-kernel mnttab uses the vfs_mntpt, vfs_resource and + * vfs_mntopts fields in the vfs_t. mntpt and resource are refstr_ts that + * are set at mount time and can only be modified during a remount. + * It is safe to read these fields if you can prevent a remount on the vfs, + * or through the convenience funcs vfs_getmntpoint() and vfs_getresource(). + * The mntopts field may only be accessed through the provided convenience + * functions, as it is protected by the vfs list lock. Modifying a mount + * option requires grabbing the vfs list write lock, which can be a very + * high latency lock. + */ +struct zone; /* from zone.h */ +struct fem_head; /* from fem.h */ + +/* + * Private vfs data, NOT to be used by a file system implementation. + */ +typedef struct vfs_impl { + struct fem_head *vi_femhead; /* fs monitoring */ + /* + * Support for statistics on the vnode operations + */ + vsk_anchor_t *vi_vskap; /* anchor for vopstats' kstat */ + vopstats_t *vi_fstypevsp; /* ptr to per-fstype vopstats */ + vopstats_t vi_vopstats; /* per-mount vnode op stats */ +} vfs_impl_t; + +typedef struct vfs { + struct vfs *vfs_next; /* next VFS in VFS list */ + struct vfs *vfs_prev; /* prev VFS in VFS list */ + +/* vfs_op should not be used directly. Accessor functions are provided */ + vfsops_t *vfs_op; /* operations on VFS */ + + struct vnode *vfs_vnodecovered; /* vnode mounted on */ + uint_t vfs_flag; /* flags */ + uint_t vfs_bsize; /* native block size */ + int vfs_fstype; /* file system type index */ + fsid_t vfs_fsid; /* file system id */ + void *vfs_data; /* private data */ + dev_t vfs_dev; /* device of mounted VFS */ + ulong_t vfs_bcount; /* I/O count (accounting) */ + struct vfs *vfs_list; /* sync list pointer */ + struct vfs *vfs_hash; /* hash list pointer */ + ksema_t vfs_reflock; /* mount/unmount/sync lock */ + uint_t vfs_count; /* vfs reference count */ + mntopts_t vfs_mntopts; /* options mounted with */ + refstr_t *vfs_resource; /* mounted resource name */ + refstr_t *vfs_mntpt; /* mount point name */ + time_t vfs_mtime; /* time we were mounted */ + vfs_impl_t *vfs_implp; /* impl specific data */ + /* + * Zones support. Note that the zone that "owns" the mount isn't + * necessarily the same as the zone in which the zone is visible. + * That is, vfs_zone and (vfs_zone_next|vfs_zone_prev) may refer to + * different zones. + */ + struct zone *vfs_zone; /* zone that owns the mount */ + struct vfs *vfs_zone_next; /* next VFS visible in zone */ + struct vfs *vfs_zone_prev; /* prev VFS visible in zone */ +} vfs_t; + +#define vfs_femhead vfs_implp->vi_femhead +#define vfs_vskap vfs_implp->vi_vskap +#define vfs_fstypevsp vfs_implp->vi_fstypevsp +#define vfs_vopstats vfs_implp->vi_vopstats + +/* + * VFS flags. + */ +#define VFS_RDONLY 0x01 /* read-only vfs */ +#define VFS_NOMNTTAB 0x02 /* vfs not seen in mnttab */ +#define VFS_NOSETUID 0x08 /* setuid disallowed */ +#define VFS_REMOUNT 0x10 /* modify mount options only */ +#define VFS_NOTRUNC 0x20 /* does not truncate long file names */ +#define VFS_UNLINKABLE 0x40 /* unlink(2) can be applied to root */ +#define VFS_PXFS 0x80 /* clustering: global fs proxy vfs */ +#define VFS_UNMOUNTED 0x100 /* file system has been unmounted */ +#define VFS_NBMAND 0x200 /* allow non-blocking mandatory locks */ +#define VFS_XATTR 0x400 /* fs supports extended attributes */ +#define VFS_NODEVICES 0x800 /* device-special files disallowed */ +#define VFS_NOEXEC 0x1000 /* executables disallowed */ +#define VFS_STATS 0x2000 /* file system can collect stats */ +#define VFS_XID 0x4000 /* file system supports extended ids */ + +#define VFS_NORESOURCE "unspecified_resource" +#define VFS_NOMNTPT "unspecified_mountpoint" + +/* + * Argument structure for mount(2). + * + * Flags are defined in . + * + * Note that if the MS_SYSSPACE bit is set in flags, the pointer fields in + * this structure are to be interpreted as kernel addresses. File systems + * should be prepared for this possibility. + */ +struct mounta { + char *spec; + char *dir; + int flags; + char *fstype; + char *dataptr; + int datalen; + char *optptr; + int optlen; +}; + +/* + * Reasons for calling the vfs_mountroot() operation. + */ +enum whymountroot { ROOT_INIT, ROOT_REMOUNT, ROOT_UNMOUNT}; +typedef enum whymountroot whymountroot_t; + +/* + * Reasons for calling the VFS_VNSTATE(): + */ +enum vntrans { + VNTRANS_EXISTS, + VNTRANS_IDLED, + VNTRANS_RECLAIMED, + VNTRANS_DESTROYED +}; +typedef enum vntrans vntrans_t; + +/* + * VFS_OPS defines all the vfs operations. It is used to define + * the vfsops structure (below) and the fs_func_p union (vfs_opreg.h). + */ +#define VFS_OPS \ + int (*vfs_mount)(vfs_t *, vnode_t *, struct mounta *, cred_t *); \ + int (*vfs_unmount)(vfs_t *, int, cred_t *); \ + int (*vfs_root)(vfs_t *, vnode_t **); \ + int (*vfs_statvfs)(vfs_t *, statvfs64_t *); \ + int (*vfs_sync)(vfs_t *, short, cred_t *); \ + int (*vfs_vget)(vfs_t *, vnode_t **, fid_t *); \ + int (*vfs_mountroot)(vfs_t *, enum whymountroot); \ + void (*vfs_freevfs)(vfs_t *); \ + int (*vfs_vnstate)(vfs_t *, vnode_t *, vntrans_t) /* NB: No ";" */ + +/* + * Operations supported on virtual file system. + */ +struct vfsops { + VFS_OPS; /* Signature of all vfs operations (vfsops) */ +}; + +extern int fsop_mount(vfs_t *, vnode_t *, struct mounta *, cred_t *); +extern int fsop_unmount(vfs_t *, int, cred_t *); +extern int fsop_root(vfs_t *, vnode_t **); +extern int fsop_statfs(vfs_t *, statvfs64_t *); +extern int fsop_sync(vfs_t *, short, cred_t *); +extern int fsop_vget(vfs_t *, vnode_t **, fid_t *); +extern int fsop_mountroot(vfs_t *, enum whymountroot); +extern void fsop_freefs(vfs_t *); +extern int fsop_sync_by_kind(int, short, cred_t *); +extern int fsop_vnstate(vfs_t *, vnode_t *, vntrans_t); + +#define VFS_MOUNT(vfsp, mvp, uap, cr) fsop_mount(vfsp, mvp, uap, cr) +#define VFS_UNMOUNT(vfsp, flag, cr) fsop_unmount(vfsp, flag, cr) +#define VFS_ROOT(vfsp, vpp) fsop_root(vfsp, vpp) +#define VFS_STATVFS(vfsp, sp) fsop_statfs(vfsp, sp) +#define VFS_SYNC(vfsp, flag, cr) fsop_sync(vfsp, flag, cr) +#define VFS_VGET(vfsp, vpp, fidp) fsop_vget(vfsp, vpp, fidp) +#define VFS_MOUNTROOT(vfsp, init) fsop_mountroot(vfsp, init) +#define VFS_FREEVFS(vfsp) fsop_freefs(vfsp) +#define VFS_VNSTATE(vfsp, vn, ns) fsop_vnstate(vfsp, vn, ns) + +#define VFSNAME_MOUNT "mount" +#define VFSNAME_UNMOUNT "unmount" +#define VFSNAME_ROOT "root" +#define VFSNAME_STATVFS "statvfs" +#define VFSNAME_SYNC "sync" +#define VFSNAME_VGET "vget" +#define VFSNAME_MOUNTROOT "mountroot" +#define VFSNAME_FREEVFS "freevfs" +#define VFSNAME_VNSTATE "vnstate" +/* + * Filesystem type switch table. + */ + +typedef struct vfssw { + char *vsw_name; /* type name -- max len _ST_FSTYPSZ */ + int (*vsw_init) (int, char *); + /* init routine (for non-loadable fs only) */ + int vsw_flag; /* flags */ + mntopts_t vsw_optproto; /* mount options table prototype */ + uint_t vsw_count; /* count of references */ + kmutex_t vsw_lock; /* lock to protect vsw_count */ + vfsops_t vsw_vfsops; /* filesystem operations vector */ +} vfssw_t; + +/* + * Filesystem type definition record. All file systems must export a record + * of this type through their modlfs structure. + */ + +typedef struct vfsdef_v3 { + int def_version; /* structure version, must be first */ + char *name; /* filesystem type name */ + int (*init) (int, char *); /* init routine */ + int flags; /* filesystem flags */ + mntopts_t *optproto; /* mount options table prototype */ +} vfsdef_v3; + +typedef struct vfsdef_v3 vfsdef_t; + +enum { + VFSDEF_VERSION = 3 +}; + +/* + * flags for vfssw and vfsdef + */ +#define VSW_HASPROTO 0x01 /* struct has a mount options prototype */ +#define VSW_CANRWRO 0x02 /* file system can transition from rw to ro */ +#define VSW_CANREMOUNT 0x04 /* file system supports remounts */ +#define VSW_NOTZONESAFE 0x08 /* zone_enter(2) should fail for these files */ +#define VSW_VOLATILEDEV 0x10 /* vfs_dev can change each time fs is mounted */ +#define VSW_STATS 0x20 /* file system can collect stats */ +#define VSW_XID 0x40 /* file system supports extended ids */ + +#define VSW_INSTALLED 0x8000 /* this vsw is associated with a file system */ + +#if defined(_KERNEL) +/* + * Public operations. + */ +struct umounta; +struct statvfsa; +struct fstatvfsa; + +void vfs_freevfsops(vfsops_t *); +int vfs_freevfsops_by_type(int); +void vfs_setops(vfs_t *, vfsops_t *); +vfsops_t *vfs_getops(vfs_t *vfsp); +int vfs_matchops(vfs_t *, vfsops_t *); +int vfs_can_sync(vfs_t *vfsp); +void vfs_init(vfs_t *vfsp, vfsops_t *, void *); +void vfsimpl_setup(vfs_t *vfsp); +void vfsimpl_teardown(vfs_t *vfsp); +void vn_exists(vnode_t *); +void vn_idle(vnode_t *); +void vn_reclaim(vnode_t *); +void vn_invalid(vnode_t *); + +int rootconf(void); +int svm_rootconf(void); +int domount(char *, struct mounta *, vnode_t *, struct cred *, + struct vfs **); +int dounmount(struct vfs *, int, cred_t *); +int vfs_lock(struct vfs *); +int vfs_rlock(struct vfs *); +void vfs_lock_wait(struct vfs *); +void vfs_rlock_wait(struct vfs *); +void vfs_unlock(struct vfs *); +int vfs_lock_held(struct vfs *); +struct _kthread *vfs_lock_owner(struct vfs *); +void sync(void); +void vfs_sync(int); +void vfs_mountroot(void); +void vfs_add(vnode_t *, struct vfs *, int); +void vfs_remove(struct vfs *); + +/* The following functions are not for general use by filesystems */ + +void vfs_createopttbl(mntopts_t *, const char *); +void vfs_copyopttbl(const mntopts_t *, mntopts_t *); +void vfs_mergeopttbl(const mntopts_t *, const mntopts_t *, mntopts_t *); +void vfs_freeopttbl(mntopts_t *); +void vfs_parsemntopts(mntopts_t *, char *, int); +int vfs_buildoptionstr(const mntopts_t *, char *, int); +struct mntopt *vfs_hasopt(const mntopts_t *, const char *); +void vfs_mnttab_modtimeupd(void); + +void vfs_clearmntopt(struct vfs *, const char *); +void vfs_setmntopt(struct vfs *, const char *, const char *, int); +void vfs_setresource(struct vfs *, const char *); +void vfs_setmntpoint(struct vfs *, const char *); +refstr_t *vfs_getresource(const struct vfs *); +refstr_t *vfs_getmntpoint(const struct vfs *); +int vfs_optionisset(const struct vfs *, const char *, char **); +int vfs_settag(uint_t, uint_t, const char *, const char *, cred_t *); +int vfs_clrtag(uint_t, uint_t, const char *, const char *, cred_t *); +void vfs_syncall(void); +void vfs_syncprogress(void); +void vfsinit(void); +void vfs_unmountall(void); +void vfs_make_fsid(fsid_t *, dev_t, int); +void vfs_addmip(dev_t, struct vfs *); +void vfs_delmip(struct vfs *); +int vfs_devismounted(dev_t); +int vfs_devmounting(dev_t, struct vfs *); +int vfs_opsinuse(vfsops_t *); +struct vfs *getvfs(fsid_t *); +struct vfs *vfs_dev2vfsp(dev_t); +struct vfs *vfs_mntpoint2vfsp(const char *); +struct vfssw *allocate_vfssw(char *); +struct vfssw *vfs_getvfssw(char *); +struct vfssw *vfs_getvfsswbyname(char *); +struct vfssw *vfs_getvfsswbyvfsops(vfsops_t *); +void vfs_refvfssw(struct vfssw *); +void vfs_unrefvfssw(struct vfssw *); +uint_t vf_to_stf(uint_t); +void vfs_mnttab_modtime(timespec_t *); +void vfs_mnttab_poll(timespec_t *, struct pollhead **); + +void vfs_list_lock(void); +void vfs_list_read_lock(void); +void vfs_list_unlock(void); +void vfs_list_add(struct vfs *); +void vfs_list_remove(struct vfs *); +void vfs_hold(vfs_t *vfsp); +void vfs_rele(vfs_t *vfsp); +void fs_freevfs(vfs_t *); +void vfs_root_redev(vfs_t *vfsp, dev_t ndev, int fstype); + +int vfs_zone_change_safe(vfs_t *); + +#define VFSHASH(maj, min) (((int)((maj)+(min))) & (vfshsz - 1)) +#define VFS_ON_LIST(vfsp) \ + ((vfsp)->vfs_next != (vfsp) && (vfsp)->vfs_next != NULL) + +/* + * Globals. + */ + +extern struct vfssw vfssw[]; /* table of filesystem types */ +extern krwlock_t vfssw_lock; +extern char rootfstype[]; /* name of root fstype */ +extern const int nfstype; /* # of elements in vfssw array */ +extern vfsops_t *EIO_vfsops; /* operations for vfs being torn-down */ + +/* + * The following variables are private to the the kernel's vfs layer. File + * system implementations should not access them. + */ +extern struct vfs *rootvfs; /* ptr to root vfs structure */ +typedef struct { + struct vfs *rvfs_head; /* head vfs in chain */ + kmutex_t rvfs_lock; /* mutex protecting this chain */ + uint32_t rvfs_len; /* length of this chain */ +} rvfs_t; +extern rvfs_t *rvfs_list; +extern int vfshsz; /* # of elements in rvfs_head array */ +extern const mntopts_t vfs_mntopts; /* globally recognized options */ + +#endif /* defined(_KERNEL) */ + +#define VFS_HOLD(vfsp) { \ + vfs_hold(vfsp); \ +} + +#define VFS_RELE(vfsp) { \ + vfs_rele(vfsp); \ +} + +#define VFS_INIT(vfsp, op, data) { \ + vfs_init((vfsp), (op), (data)); \ + vfsimpl_setup((vfsp)); \ +} + + +#define VFS_INSTALLED(vfsswp) (((vfsswp)->vsw_flag & VSW_INSTALLED) != 0) +#define ALLOCATED_VFSSW(vswp) ((vswp)->vsw_name[0] != '\0') +#define RLOCK_VFSSW() (rw_enter(&vfssw_lock, RW_READER)) +#define RUNLOCK_VFSSW() (rw_exit(&vfssw_lock)) +#define WLOCK_VFSSW() (rw_enter(&vfssw_lock, RW_WRITER)) +#define WUNLOCK_VFSSW() (rw_exit(&vfssw_lock)) +#define VFSSW_LOCKED() (RW_LOCK_HELD(&vfssw_lock)) +#define VFSSW_WRITE_LOCKED() (RW_WRITE_HELD(&vfssw_lock)) +/* + * VFS_SYNC flags. + */ +#define SYNC_ATTR 0x01 /* sync attributes only */ +#define SYNC_CLOSE 0x02 /* close open file */ +#define SYNC_ALL 0x04 /* force to sync all fs */ + +#ifdef __cplusplus +} +#endif + +#endif /* __APPLE__ */ + +#endif /* _SYS_VFS_H */ diff --git a/libudffs/extent.c b/libudffs/extent.c index dea05a49..8b211aa8 100644 --- a/libudffs/extent.c +++ b/libudffs/extent.c @@ -27,7 +27,9 @@ #include "config.h" -#include +#ifndef __clang__ +# include +#endif #include #include #include diff --git a/udffsck/Makefile.am b/udffsck/Makefile.am index a7bfa6cc..83a8abb4 100644 --- a/udffsck/Makefile.am +++ b/udffsck/Makefile.am @@ -3,6 +3,10 @@ sbin_PROGRAMS = udffsck udffsck_LDADD = $(top_builddir)/libudffs/libudffs.la udffsck_SOURCES = main.c utils.c utils.h udffsck.c udffsck.h options.c options.h log.c log.h ../include/ecma_167.h ../include/osta_udf.h ../mkudffs/mkudffs.h ../mkudffs/defaults.h ../mkudffs/file.h ../libudffs/crc.c ../include/libudffs.h ../include/udf_endian.h +if HAVE_DARWIN +SET_FEATURES = -D_DARWIN_C_SOURCE +endif + AM_CFLAGS = -I$(top_srcdir)/include AM_LDFLAGS = -lm -ldl #-Wl,--no-as-needed diff --git a/udffsck/options.c b/udffsck/options.c index fe2b6019..d1655b5c 100644 --- a/udffsck/options.c +++ b/udffsck/options.c @@ -20,7 +20,9 @@ #include #include -#include +#ifndef __clang__ +# include +#endif #include "libudffs.h" #include "options.h" From 220348d84645e353596a8201ee99f11e4854d257 Mon Sep 17 00:00:00 2001 From: Giovanni Merlino Date: Fri, 5 Jan 2018 12:35:46 +0100 Subject: [PATCH 2/7] fixed (unneeded) CDDL files inclusion, added (initial) Travis directives for macOS --- .travis.yml | 9 + include/bswap.h | 10 +- include/mntent.h | 141 ---------- include/sys/isa_defs.h | 216 --------------- include/sys/vfs.h | 595 ----------------------------------------- udffsck/main.c | 9 + 6 files changed, 22 insertions(+), 958 deletions(-) delete mode 100644 include/mntent.h delete mode 100644 include/sys/isa_defs.h delete mode 100644 include/sys/vfs.h diff --git a/.travis.yml b/.travis.yml index 2d5d74f2..56e5e7c8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,12 @@ language: c +matrix: + include: + - os: linux + - os: osx + allow_failures: + - os: osx + compiler: - gcc - clang @@ -48,6 +55,8 @@ addons: &addons # branch_pattern: master before_script: + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install automake libtool cmake wget; fi - cd .. - mkdir cmocka - cd cmocka diff --git a/include/bswap.h b/include/bswap.h index b6b54e12..5d1fc997 100644 --- a/include/bswap.h +++ b/include/bswap.h @@ -23,16 +23,14 @@ #ifndef __BSWAP_H #define __BSWAP_H -#ifndef HAVE_SYS_ISA_DEFS_H -#include "sys/isa_defs.h" -#define HAVE_SYS_ISA_DEFS_H -#endif - #include "config.h" #include #include +#if defined(HAVE_MACHINE_ENDIAN_H) +#include +#endif #ifdef HAVE_SYS_ISA_DEFS_H #define __LITTLE_ENDIAN 1234 #define __BIG_ENDIAN 4321 @@ -49,7 +47,7 @@ /* macOS (Intel) */ #ifdef __APPLE__ -#define __BYTE_ORDER __LITTLE_ENDIAN +#define __BYTE_ORDER BYTE_ORDER #endif /* __APPLE__ */ #define constant_swab16(x) \ diff --git a/include/mntent.h b/include/mntent.h deleted file mode 100644 index ee35c056..00000000 --- a/include/mntent.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T - * All Rights Reserved - */ - -#ifndef _SYS_MNTENT_H -#define _SYS_MNTENT_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#ifdef __cplusplus -extern "C" { -#endif - -#define MNTTAB "/etc/mnttab" -#define VFSTAB "/etc/vfstab" -#define MNTMAXSTR 128 - -#define MNTTYPE_ZFS "zfs" /* ZFS file system */ -#define MNTTYPE_UFS "ufs" /* Unix file system */ -#define MNTTYPE_NFS "nfs" /* NFS file system */ -#define MNTTYPE_NFS3 "nfs3" /* NFS Version 3 file system */ -#define MNTTYPE_NFS4 "nfs4" /* NFS Version 4 file system */ -#define MNTTYPE_CACHEFS "cachefs" /* Cache File System */ -#define MNTTYPE_PCFS "pcfs" /* PC (MSDOS) file system */ -#define MNTTYPE_PC MNTTYPE_PCFS /* Deprecated name; use MNTTYPE_PCFS */ -#define MNTTYPE_LOFS "lofs" /* Loop back file system */ -#define MNTTYPE_LO MNTTYPE_LOFS /* Deprecated name; use MNTTYPE_LOFS */ -#define MNTTYPE_HSFS "hsfs" /* High Sierra (9660) file system */ -#define MNTTYPE_SWAP "swap" /* Swap file system */ -#define MNTTYPE_TMPFS "tmpfs" /* Tmp volatile file system */ -#define MNTTYPE_AUTOFS "autofs" /* Automounter ``file'' system */ -#define MNTTYPE_MNTFS "mntfs" /* In-kernel mnttab */ -#define MNTTYPE_DEV "dev" /* /dev file system */ -#define MNTTYPE_CTFS "ctfs" /* Contract file system */ -#define MNTTYPE_OBJFS "objfs" /* Kernel object file system */ -#define MNTTYPE_SHAREFS "sharefs" /* Kernel sharetab file system */ - - -#define MNTOPT_RO "ro" /* Read only */ -#define MNTOPT_RW "rw" /* Read/write */ -#define MNTOPT_RQ "rq" /* Read/write with quotas */ -#define MNTOPT_QUOTA "quota" /* Check quotas */ -#define MNTOPT_NOQUOTA "noquota" /* Don't check quotas */ -#define MNTOPT_ONERROR "onerror" /* action to taken on error */ -#define MNTOPT_SOFT "soft" /* Soft mount */ -#define MNTOPT_SEMISOFT "semisoft" /* partial soft, uncommited interface */ -#define MNTOPT_HARD "hard" /* Hard mount */ -#define MNTOPT_SUID "suid" /* Both setuid and devices allowed */ -#define MNTOPT_NOSUID "nosuid" /* Neither setuid nor devices allowed */ -#define MNTOPT_DEVICES "devices" /* Device-special allowed */ -#define MNTOPT_NODEVICES "nodevices" /* Device-special disallowed */ -#define MNTOPT_SETUID "setuid" /* Set uid allowed */ -#define MNTOPT_NOSETUID "nosetuid" /* Set uid not allowed */ -#define MNTOPT_GRPID "grpid" /* SysV-compatible gid on create */ -#define MNTOPT_REMOUNT "remount" /* Change mount options */ -#define MNTOPT_NOSUB "nosub" /* Disallow mounts on subdirs */ -#define MNTOPT_MULTI "multi" /* Do multi-component lookup */ -#define MNTOPT_INTR "intr" /* Allow NFS ops to be interrupted */ -#define MNTOPT_NOINTR "nointr" /* Don't allow interrupted ops */ -#define MNTOPT_PORT "port" /* NFS server IP port number */ -#define MNTOPT_SECURE "secure" /* Secure (AUTH_DES) mounting */ -#define MNTOPT_RSIZE "rsize" /* Max NFS read size (bytes) */ -#define MNTOPT_WSIZE "wsize" /* Max NFS write size (bytes) */ -#define MNTOPT_TIMEO "timeo" /* NFS timeout (1/10 sec) */ -#define MNTOPT_RETRANS "retrans" /* Max retransmissions (soft mnts) */ -#define MNTOPT_ACTIMEO "actimeo" /* Attr cache timeout (sec) */ -#define MNTOPT_ACREGMIN "acregmin" /* Min attr cache timeout (files) */ -#define MNTOPT_ACREGMAX "acregmax" /* Max attr cache timeout (files) */ -#define MNTOPT_ACDIRMIN "acdirmin" /* Min attr cache timeout (dirs) */ -#define MNTOPT_ACDIRMAX "acdirmax" /* Max attr cache timeout (dirs) */ -#define MNTOPT_NOAC "noac" /* Don't cache attributes at all */ -#define MNTOPT_NOCTO "nocto" /* No close-to-open consistency */ -#define MNTOPT_BG "bg" /* Do mount retries in background */ -#define MNTOPT_FG "fg" /* Do mount retries in foreground */ -#define MNTOPT_RETRY "retry" /* Number of mount retries */ -#define MNTOPT_DEV "dev" /* Device id of mounted fs */ -#define MNTOPT_POSIX "posix" /* Get static pathconf for mount */ -#define MNTOPT_MAP "map" /* Automount map */ -#define MNTOPT_DIRECT "direct" /* Automount direct map mount */ -#define MNTOPT_INDIRECT "indirect" /* Automount indirect map mount */ -#define MNTOPT_LLOCK "llock" /* Local locking (no lock manager) */ -#define MNTOPT_IGNORE "ignore" /* Ignore this entry */ -#define MNTOPT_VERS "vers" /* protocol version number indicator */ -#define MNTOPT_PROTO "proto" /* protocol network_id indicator */ -#define MNTOPT_SEC "sec" /* Security flavor indicator */ -#define MNTOPT_SYNCDIR "syncdir" /* Synchronous local directory ops */ -#define MNTOPT_NOSETSEC "nosec" /* Do no allow setting sec attrs */ -#define MNTOPT_NOPRINT "noprint" /* Do not print messages */ -#define MNTOPT_LARGEFILES "largefiles" /* allow large files */ -#define MNTOPT_NOLARGEFILES "nolargefiles" /* don't allow large files */ -#define MNTOPT_FORCEDIRECTIO "forcedirectio" /* Force DirectIO on all files */ -#define MNTOPT_NOFORCEDIRECTIO "noforcedirectio" /* No Force DirectIO */ -#define MNTOPT_DISABLEDIRECTIO "disabledirectio" /* Disable DirectIO ioctls */ -#define MNTOPT_PUBLIC "public" /* Use NFS public file handlee */ -#define MNTOPT_LOGGING "logging" /* enable logging */ -#define MNTOPT_NOLOGGING "nologging" /* disable logging */ -#define MNTOPT_ATIME "atime" /* update atime for files */ -#define MNTOPT_NOATIME "noatime" /* do not update atime for files */ -#define MNTOPT_GLOBAL "global" /* Cluster-wide global mount */ -#define MNTOPT_NOGLOBAL "noglobal" /* Mount local to single node */ -#define MNTOPT_DFRATIME "dfratime" /* Deferred access time updates */ -#define MNTOPT_NODFRATIME "nodfratime" /* No Deferred access time updates */ -#define MNTOPT_NBMAND "nbmand" /* allow non-blocking mandatory locks */ -#define MNTOPT_NONBMAND "nonbmand" /* deny non-blocking mandatory locks */ -#define MNTOPT_XATTR "xattr" /* enable extended attributes */ -#define MNTOPT_NOXATTR "noxattr" /* disable extended attributes */ -#define MNTOPT_EXEC "exec" /* enable executables */ -#define MNTOPT_NOEXEC "noexec" /* disable executables */ -#define MNTOPT_RESTRICT "restrict" /* restricted autofs mount */ -#define MNTOPT_BROWSE "browse" /* browsable autofs mount */ -#define MNTOPT_NOBROWSE "nobrowse" /* non-browsable autofs mount */ - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_MNTENT_H */ diff --git a/include/sys/isa_defs.h b/include/sys/isa_defs.h deleted file mode 100644 index a5bea039..00000000 --- a/include/sys/isa_defs.h +++ /dev/null @@ -1,216 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ - -/* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _SYS_ISA_DEFS_H -#define _SYS_ISA_DEFS_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* x86_64 arch specific defines */ -#if defined(__x86_64) || defined(__x86_64__) - -#if !defined(__x86_64) -#define __x86_64 -#endif - -#if !defined(__amd64) -#define __amd64 -#endif - -#if !defined(__x86) -#define __x86 -#endif - -#if !defined(_LP64) -#define _LP64 -#endif - -#if !defined(_LITTLE_ENDIAN) -#define _LITTLE_ENDIAN -#endif - -#define _SUNOS_VTOC_16 - -/* i386 arch specific defines */ -#elif defined(__i386) || defined(__i386__) - -#if !defined(__i386) -#define __i386 -#endif - -#if !defined(__x86) -#define __x86 -#endif - -#if !defined(_ILP32) -#define _ILP32 -#endif - -#if !defined(_LITTLE_ENDIAN) -#define _LITTLE_ENDIAN -#endif - -#define _SUNOS_VTOC_16 - -/* powerpc arch specific defines */ -#elif defined(__powerpc) || defined(__powerpc__) || defined(__powerpc64__) - -#if !defined(__powerpc) -#define __powerpc -#endif - -#if !defined(__powerpc__) -#define __powerpc__ -#endif - -#if defined(__powerpc64__) -#if !defined(_LP64) -#define _LP64 -#endif -#else -#if !defined(_ILP32) -#define _ILP32 -#endif -#endif - -#define _SUNOS_VTOC_16 - -/* arm arch specific defines */ -#elif defined(__arm) || defined(__arm__) || defined(__aarch64__) - -#if !defined(__arm) -#define __arm -#endif - -#if !defined(__arm__) -#define __arm__ -#endif - -#if defined(__aarch64__) -#if !defined(_LP64) -#define _LP64 -#endif -#else -#if !defined(_ILP32) -#define _ILP32 -#endif -#endif - -#if defined(__ARMEL__) || defined(__AARCH64EL__) -#define _LITTLE_ENDIAN -#else -#define _BIG_ENDIAN -#endif - -#define _SUNOS_VTOC_16 - -/* sparc arch specific defines */ -#elif defined(__sparc) || defined(__sparc__) - -#if !defined(__sparc) -#define __sparc -#endif - -#if !defined(__sparc__) -#define __sparc__ -#endif - -#define _BIG_ENDIAN -#define _SUNOS_VTOC_16 - -#if defined(__arch64__) -#if !defined(_LP64) -#define _LP64 -#endif -#else -#if !defined(_ILP32) -#define _ILP32 -#endif -#endif - -/* s390 arch specific defines */ -#elif defined(__s390__) -#if defined(__s390x__) -#if !defined(_LP64) -#define _LP64 -#endif -#else -#if !defined(_ILP32) -#define _ILP32 -#endif -#endif - -#define _BIG_ENDIAN -#define _SUNOS_VTOC_16 - -/* MIPS arch specific defines */ -#elif defined(__mips__) - -#if defined(__MIPSEB__) -#define _BIG_ENDIAN -#elif defined(__MIPSEL__) -#define _LITTLE_ENDIAN -#else -#error MIPS no endian specified -#endif - -#ifndef _LP64 -#define _ILP32 -#endif - -#define _SUNOS_VTOC_16 - -#else -/* - * Currently supported: - * x86_64, i386, arm, powerpc, s390, sparc, and mips - */ -#error "Unsupported ISA type" -#endif - -#if defined(_ILP32) && defined(_LP64) -#error "Both _ILP32 and _LP64 are defined" -#endif - -#if !defined(_ILP32) && !defined(_LP64) -#error "Neither _ILP32 or _LP64 are defined" -#endif - -#if defined(_LITTLE_ENDIAN) && defined(_BIG_ENDIAN) -#error "Both _LITTLE_ENDIAN and _BIG_ENDIAN are defined" -#endif - -#if !defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN) -#error "Neither _LITTLE_ENDIAN nor _BIG_ENDIAN are defined" -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_ISA_DEFS_H */ diff --git a/include/sys/vfs.h b/include/sys/vfs.h deleted file mode 100644 index 7b9bbabc..00000000 --- a/include/sys/vfs.h +++ /dev/null @@ -1,595 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -/* - * Portions of this source code were derived from Berkeley 4.3 BSD - * under license from the Regents of the University of California. - * Portions Copyright 2007 Apple Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _SYS_VFS_H -#define _SYS_VFS_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#ifdef __APPLE__ -/* - * In Darwin, VFS is defined by "sys/mount.h" - */ -#include - -typedef struct mount vfs_t; - -#define LK_NOWAIT 0x00000010 /* do not sleep to await lock */ - -#define vn_vfswlock(vp) (0) - -#define vn_vfsunlock(vp) - -#define VFS_HOLD(vfsp) - -#define VFS_RELE(vfsp) - -#else - -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Data associated with mounted file systems. - */ - -/* - * Operations vector. This is used internal to the kernel; file systems - * supply their list of operations via vfs_setfsops(). - */ - -typedef struct vfsops vfsops_t; - -/* - * File system identifier. Should be unique (at least per machine). - */ -typedef struct { - int val[2]; /* file system id type */ -} fsid_t; - -/* - * File identifier. Should be unique per filesystem on a single - * machine. This is typically called by a stateless file server - * in order to generate "file handles". - * - * Do not change the definition of struct fid ... fid_t without - * letting the CacheFS group know about it! They will have to do at - * least two things, in the same change that changes this structure: - * 1. change CFSVERSION in usr/src/uts/common/sys/fs/cachefs_fs.h - * 2. put the old version # in the canupgrade array - * in cachfs_upgrade() in usr/src/cmd/fs.d/cachefs/fsck/fsck.c - * This is necessary because CacheFS stores FIDs on disk. - * - * Many underlying file systems cast a struct fid into other - * file system dependent structures which may require 4 byte alignment. - * Because a fid starts with a short it may not be 4 byte aligned, the - * fid_pad will force the alignment. - */ -#define MAXFIDSZ 64 -#define OLD_MAXFIDSZ 16 - -typedef struct fid { - union { - long fid_pad; - struct { - ushort_t len; /* length of data in bytes */ - char data[MAXFIDSZ]; /* data (variable len) */ - } _fid; - } un; -} fid_t; - -#ifdef _SYSCALL32 -/* - * Solaris 64 - use old-style cache format with 32-bit aligned fid for on-disk - * struct compatibility. - */ -typedef struct fid32 { - union { - int32_t fid_pad; - struct { - uint16_t len; /* length of data in bytes */ - char data[MAXFIDSZ]; /* data (variable len) */ - } _fid; - } un; -} fid32_t; -#else /* not _SYSCALL32 */ -#define fid32 fid -typedef fid_t fid32_t; -#endif /* _SYSCALL32 */ - -#define fid_len un._fid.len -#define fid_data un._fid.data - -/* - * Structure defining a mount option for a filesystem. - * option names are found in mntent.h - */ -typedef struct mntopt { - char *mo_name; /* option name */ - char **mo_cancel; /* list of options cancelled by this one */ - char *mo_arg; /* argument string for this option */ - int mo_flags; /* flags for this mount option */ - void *mo_data; /* filesystem specific data */ -} mntopt_t; - -/* - * Flags that apply to mount options - */ - -#define MO_SET 0x01 /* option is set */ -#define MO_NODISPLAY 0x02 /* option not listed in mnttab */ -#define MO_HASVALUE 0x04 /* option takes a value */ -#define MO_IGNORE 0x08 /* option ignored by parser */ -#define MO_DEFAULT MO_SET /* option is on by default */ -#define MO_TAG 0x10 /* flags a tag set by user program */ -#define MO_EMPTY 0x20 /* empty space in option table */ - -#define VFS_NOFORCEOPT 0x01 /* honor MO_IGNORE (don't set option) */ -#define VFS_DISPLAY 0x02 /* Turn off MO_NODISPLAY bit for opt */ -#define VFS_NODISPLAY 0x04 /* Turn on MO_NODISPLAY bit for opt */ -#define VFS_CREATEOPT 0x08 /* Create the opt if it's not there */ - -/* - * Structure holding mount option strings for the mounted file system. - */ -typedef struct mntopts { - uint_t mo_count; /* number of entries in table */ - mntopt_t *mo_list; /* list of mount options */ -} mntopts_t; - -/* - * The kstat structures associated with the vopstats are kept in an - * AVL tree. This is to avoid the case where a file system does not - * use a unique fsid_t for each vfs (e.g., namefs). In order to do - * this, we need a structure that the AVL tree can use that also - * references the kstat. - * Note that the vks_fsid is generated from the value reported by - * VFS_STATVFS(). - */ -typedef struct vskstat_anchor { - avl_node_t vsk_node; /* Required for use by AVL routines */ - kstat_t *vsk_ksp; /* kstat structure for vopstats */ - ulong_t vsk_fsid; /* fsid associated w/this FS */ -} vsk_anchor_t; - -extern avl_tree_t vskstat_tree; -extern kmutex_t vskstat_tree_lock; - -/* - * Structure per mounted file system. Each mounted file system has - * an array of operations and an instance record. - * - * The file systems are kept on a doubly linked circular list headed by - * "rootvfs". - * File system implementations should not access this list; - * it's intended for use only in the kernel's vfs layer. - * - * Each zone also has its own list of mounts, containing filesystems mounted - * somewhere within the filesystem tree rooted at the zone's rootpath. The - * list is doubly linked to match the global list. - * - * mnttab locking: the in-kernel mnttab uses the vfs_mntpt, vfs_resource and - * vfs_mntopts fields in the vfs_t. mntpt and resource are refstr_ts that - * are set at mount time and can only be modified during a remount. - * It is safe to read these fields if you can prevent a remount on the vfs, - * or through the convenience funcs vfs_getmntpoint() and vfs_getresource(). - * The mntopts field may only be accessed through the provided convenience - * functions, as it is protected by the vfs list lock. Modifying a mount - * option requires grabbing the vfs list write lock, which can be a very - * high latency lock. - */ -struct zone; /* from zone.h */ -struct fem_head; /* from fem.h */ - -/* - * Private vfs data, NOT to be used by a file system implementation. - */ -typedef struct vfs_impl { - struct fem_head *vi_femhead; /* fs monitoring */ - /* - * Support for statistics on the vnode operations - */ - vsk_anchor_t *vi_vskap; /* anchor for vopstats' kstat */ - vopstats_t *vi_fstypevsp; /* ptr to per-fstype vopstats */ - vopstats_t vi_vopstats; /* per-mount vnode op stats */ -} vfs_impl_t; - -typedef struct vfs { - struct vfs *vfs_next; /* next VFS in VFS list */ - struct vfs *vfs_prev; /* prev VFS in VFS list */ - -/* vfs_op should not be used directly. Accessor functions are provided */ - vfsops_t *vfs_op; /* operations on VFS */ - - struct vnode *vfs_vnodecovered; /* vnode mounted on */ - uint_t vfs_flag; /* flags */ - uint_t vfs_bsize; /* native block size */ - int vfs_fstype; /* file system type index */ - fsid_t vfs_fsid; /* file system id */ - void *vfs_data; /* private data */ - dev_t vfs_dev; /* device of mounted VFS */ - ulong_t vfs_bcount; /* I/O count (accounting) */ - struct vfs *vfs_list; /* sync list pointer */ - struct vfs *vfs_hash; /* hash list pointer */ - ksema_t vfs_reflock; /* mount/unmount/sync lock */ - uint_t vfs_count; /* vfs reference count */ - mntopts_t vfs_mntopts; /* options mounted with */ - refstr_t *vfs_resource; /* mounted resource name */ - refstr_t *vfs_mntpt; /* mount point name */ - time_t vfs_mtime; /* time we were mounted */ - vfs_impl_t *vfs_implp; /* impl specific data */ - /* - * Zones support. Note that the zone that "owns" the mount isn't - * necessarily the same as the zone in which the zone is visible. - * That is, vfs_zone and (vfs_zone_next|vfs_zone_prev) may refer to - * different zones. - */ - struct zone *vfs_zone; /* zone that owns the mount */ - struct vfs *vfs_zone_next; /* next VFS visible in zone */ - struct vfs *vfs_zone_prev; /* prev VFS visible in zone */ -} vfs_t; - -#define vfs_femhead vfs_implp->vi_femhead -#define vfs_vskap vfs_implp->vi_vskap -#define vfs_fstypevsp vfs_implp->vi_fstypevsp -#define vfs_vopstats vfs_implp->vi_vopstats - -/* - * VFS flags. - */ -#define VFS_RDONLY 0x01 /* read-only vfs */ -#define VFS_NOMNTTAB 0x02 /* vfs not seen in mnttab */ -#define VFS_NOSETUID 0x08 /* setuid disallowed */ -#define VFS_REMOUNT 0x10 /* modify mount options only */ -#define VFS_NOTRUNC 0x20 /* does not truncate long file names */ -#define VFS_UNLINKABLE 0x40 /* unlink(2) can be applied to root */ -#define VFS_PXFS 0x80 /* clustering: global fs proxy vfs */ -#define VFS_UNMOUNTED 0x100 /* file system has been unmounted */ -#define VFS_NBMAND 0x200 /* allow non-blocking mandatory locks */ -#define VFS_XATTR 0x400 /* fs supports extended attributes */ -#define VFS_NODEVICES 0x800 /* device-special files disallowed */ -#define VFS_NOEXEC 0x1000 /* executables disallowed */ -#define VFS_STATS 0x2000 /* file system can collect stats */ -#define VFS_XID 0x4000 /* file system supports extended ids */ - -#define VFS_NORESOURCE "unspecified_resource" -#define VFS_NOMNTPT "unspecified_mountpoint" - -/* - * Argument structure for mount(2). - * - * Flags are defined in . - * - * Note that if the MS_SYSSPACE bit is set in flags, the pointer fields in - * this structure are to be interpreted as kernel addresses. File systems - * should be prepared for this possibility. - */ -struct mounta { - char *spec; - char *dir; - int flags; - char *fstype; - char *dataptr; - int datalen; - char *optptr; - int optlen; -}; - -/* - * Reasons for calling the vfs_mountroot() operation. - */ -enum whymountroot { ROOT_INIT, ROOT_REMOUNT, ROOT_UNMOUNT}; -typedef enum whymountroot whymountroot_t; - -/* - * Reasons for calling the VFS_VNSTATE(): - */ -enum vntrans { - VNTRANS_EXISTS, - VNTRANS_IDLED, - VNTRANS_RECLAIMED, - VNTRANS_DESTROYED -}; -typedef enum vntrans vntrans_t; - -/* - * VFS_OPS defines all the vfs operations. It is used to define - * the vfsops structure (below) and the fs_func_p union (vfs_opreg.h). - */ -#define VFS_OPS \ - int (*vfs_mount)(vfs_t *, vnode_t *, struct mounta *, cred_t *); \ - int (*vfs_unmount)(vfs_t *, int, cred_t *); \ - int (*vfs_root)(vfs_t *, vnode_t **); \ - int (*vfs_statvfs)(vfs_t *, statvfs64_t *); \ - int (*vfs_sync)(vfs_t *, short, cred_t *); \ - int (*vfs_vget)(vfs_t *, vnode_t **, fid_t *); \ - int (*vfs_mountroot)(vfs_t *, enum whymountroot); \ - void (*vfs_freevfs)(vfs_t *); \ - int (*vfs_vnstate)(vfs_t *, vnode_t *, vntrans_t) /* NB: No ";" */ - -/* - * Operations supported on virtual file system. - */ -struct vfsops { - VFS_OPS; /* Signature of all vfs operations (vfsops) */ -}; - -extern int fsop_mount(vfs_t *, vnode_t *, struct mounta *, cred_t *); -extern int fsop_unmount(vfs_t *, int, cred_t *); -extern int fsop_root(vfs_t *, vnode_t **); -extern int fsop_statfs(vfs_t *, statvfs64_t *); -extern int fsop_sync(vfs_t *, short, cred_t *); -extern int fsop_vget(vfs_t *, vnode_t **, fid_t *); -extern int fsop_mountroot(vfs_t *, enum whymountroot); -extern void fsop_freefs(vfs_t *); -extern int fsop_sync_by_kind(int, short, cred_t *); -extern int fsop_vnstate(vfs_t *, vnode_t *, vntrans_t); - -#define VFS_MOUNT(vfsp, mvp, uap, cr) fsop_mount(vfsp, mvp, uap, cr) -#define VFS_UNMOUNT(vfsp, flag, cr) fsop_unmount(vfsp, flag, cr) -#define VFS_ROOT(vfsp, vpp) fsop_root(vfsp, vpp) -#define VFS_STATVFS(vfsp, sp) fsop_statfs(vfsp, sp) -#define VFS_SYNC(vfsp, flag, cr) fsop_sync(vfsp, flag, cr) -#define VFS_VGET(vfsp, vpp, fidp) fsop_vget(vfsp, vpp, fidp) -#define VFS_MOUNTROOT(vfsp, init) fsop_mountroot(vfsp, init) -#define VFS_FREEVFS(vfsp) fsop_freefs(vfsp) -#define VFS_VNSTATE(vfsp, vn, ns) fsop_vnstate(vfsp, vn, ns) - -#define VFSNAME_MOUNT "mount" -#define VFSNAME_UNMOUNT "unmount" -#define VFSNAME_ROOT "root" -#define VFSNAME_STATVFS "statvfs" -#define VFSNAME_SYNC "sync" -#define VFSNAME_VGET "vget" -#define VFSNAME_MOUNTROOT "mountroot" -#define VFSNAME_FREEVFS "freevfs" -#define VFSNAME_VNSTATE "vnstate" -/* - * Filesystem type switch table. - */ - -typedef struct vfssw { - char *vsw_name; /* type name -- max len _ST_FSTYPSZ */ - int (*vsw_init) (int, char *); - /* init routine (for non-loadable fs only) */ - int vsw_flag; /* flags */ - mntopts_t vsw_optproto; /* mount options table prototype */ - uint_t vsw_count; /* count of references */ - kmutex_t vsw_lock; /* lock to protect vsw_count */ - vfsops_t vsw_vfsops; /* filesystem operations vector */ -} vfssw_t; - -/* - * Filesystem type definition record. All file systems must export a record - * of this type through their modlfs structure. - */ - -typedef struct vfsdef_v3 { - int def_version; /* structure version, must be first */ - char *name; /* filesystem type name */ - int (*init) (int, char *); /* init routine */ - int flags; /* filesystem flags */ - mntopts_t *optproto; /* mount options table prototype */ -} vfsdef_v3; - -typedef struct vfsdef_v3 vfsdef_t; - -enum { - VFSDEF_VERSION = 3 -}; - -/* - * flags for vfssw and vfsdef - */ -#define VSW_HASPROTO 0x01 /* struct has a mount options prototype */ -#define VSW_CANRWRO 0x02 /* file system can transition from rw to ro */ -#define VSW_CANREMOUNT 0x04 /* file system supports remounts */ -#define VSW_NOTZONESAFE 0x08 /* zone_enter(2) should fail for these files */ -#define VSW_VOLATILEDEV 0x10 /* vfs_dev can change each time fs is mounted */ -#define VSW_STATS 0x20 /* file system can collect stats */ -#define VSW_XID 0x40 /* file system supports extended ids */ - -#define VSW_INSTALLED 0x8000 /* this vsw is associated with a file system */ - -#if defined(_KERNEL) -/* - * Public operations. - */ -struct umounta; -struct statvfsa; -struct fstatvfsa; - -void vfs_freevfsops(vfsops_t *); -int vfs_freevfsops_by_type(int); -void vfs_setops(vfs_t *, vfsops_t *); -vfsops_t *vfs_getops(vfs_t *vfsp); -int vfs_matchops(vfs_t *, vfsops_t *); -int vfs_can_sync(vfs_t *vfsp); -void vfs_init(vfs_t *vfsp, vfsops_t *, void *); -void vfsimpl_setup(vfs_t *vfsp); -void vfsimpl_teardown(vfs_t *vfsp); -void vn_exists(vnode_t *); -void vn_idle(vnode_t *); -void vn_reclaim(vnode_t *); -void vn_invalid(vnode_t *); - -int rootconf(void); -int svm_rootconf(void); -int domount(char *, struct mounta *, vnode_t *, struct cred *, - struct vfs **); -int dounmount(struct vfs *, int, cred_t *); -int vfs_lock(struct vfs *); -int vfs_rlock(struct vfs *); -void vfs_lock_wait(struct vfs *); -void vfs_rlock_wait(struct vfs *); -void vfs_unlock(struct vfs *); -int vfs_lock_held(struct vfs *); -struct _kthread *vfs_lock_owner(struct vfs *); -void sync(void); -void vfs_sync(int); -void vfs_mountroot(void); -void vfs_add(vnode_t *, struct vfs *, int); -void vfs_remove(struct vfs *); - -/* The following functions are not for general use by filesystems */ - -void vfs_createopttbl(mntopts_t *, const char *); -void vfs_copyopttbl(const mntopts_t *, mntopts_t *); -void vfs_mergeopttbl(const mntopts_t *, const mntopts_t *, mntopts_t *); -void vfs_freeopttbl(mntopts_t *); -void vfs_parsemntopts(mntopts_t *, char *, int); -int vfs_buildoptionstr(const mntopts_t *, char *, int); -struct mntopt *vfs_hasopt(const mntopts_t *, const char *); -void vfs_mnttab_modtimeupd(void); - -void vfs_clearmntopt(struct vfs *, const char *); -void vfs_setmntopt(struct vfs *, const char *, const char *, int); -void vfs_setresource(struct vfs *, const char *); -void vfs_setmntpoint(struct vfs *, const char *); -refstr_t *vfs_getresource(const struct vfs *); -refstr_t *vfs_getmntpoint(const struct vfs *); -int vfs_optionisset(const struct vfs *, const char *, char **); -int vfs_settag(uint_t, uint_t, const char *, const char *, cred_t *); -int vfs_clrtag(uint_t, uint_t, const char *, const char *, cred_t *); -void vfs_syncall(void); -void vfs_syncprogress(void); -void vfsinit(void); -void vfs_unmountall(void); -void vfs_make_fsid(fsid_t *, dev_t, int); -void vfs_addmip(dev_t, struct vfs *); -void vfs_delmip(struct vfs *); -int vfs_devismounted(dev_t); -int vfs_devmounting(dev_t, struct vfs *); -int vfs_opsinuse(vfsops_t *); -struct vfs *getvfs(fsid_t *); -struct vfs *vfs_dev2vfsp(dev_t); -struct vfs *vfs_mntpoint2vfsp(const char *); -struct vfssw *allocate_vfssw(char *); -struct vfssw *vfs_getvfssw(char *); -struct vfssw *vfs_getvfsswbyname(char *); -struct vfssw *vfs_getvfsswbyvfsops(vfsops_t *); -void vfs_refvfssw(struct vfssw *); -void vfs_unrefvfssw(struct vfssw *); -uint_t vf_to_stf(uint_t); -void vfs_mnttab_modtime(timespec_t *); -void vfs_mnttab_poll(timespec_t *, struct pollhead **); - -void vfs_list_lock(void); -void vfs_list_read_lock(void); -void vfs_list_unlock(void); -void vfs_list_add(struct vfs *); -void vfs_list_remove(struct vfs *); -void vfs_hold(vfs_t *vfsp); -void vfs_rele(vfs_t *vfsp); -void fs_freevfs(vfs_t *); -void vfs_root_redev(vfs_t *vfsp, dev_t ndev, int fstype); - -int vfs_zone_change_safe(vfs_t *); - -#define VFSHASH(maj, min) (((int)((maj)+(min))) & (vfshsz - 1)) -#define VFS_ON_LIST(vfsp) \ - ((vfsp)->vfs_next != (vfsp) && (vfsp)->vfs_next != NULL) - -/* - * Globals. - */ - -extern struct vfssw vfssw[]; /* table of filesystem types */ -extern krwlock_t vfssw_lock; -extern char rootfstype[]; /* name of root fstype */ -extern const int nfstype; /* # of elements in vfssw array */ -extern vfsops_t *EIO_vfsops; /* operations for vfs being torn-down */ - -/* - * The following variables are private to the the kernel's vfs layer. File - * system implementations should not access them. - */ -extern struct vfs *rootvfs; /* ptr to root vfs structure */ -typedef struct { - struct vfs *rvfs_head; /* head vfs in chain */ - kmutex_t rvfs_lock; /* mutex protecting this chain */ - uint32_t rvfs_len; /* length of this chain */ -} rvfs_t; -extern rvfs_t *rvfs_list; -extern int vfshsz; /* # of elements in rvfs_head array */ -extern const mntopts_t vfs_mntopts; /* globally recognized options */ - -#endif /* defined(_KERNEL) */ - -#define VFS_HOLD(vfsp) { \ - vfs_hold(vfsp); \ -} - -#define VFS_RELE(vfsp) { \ - vfs_rele(vfsp); \ -} - -#define VFS_INIT(vfsp, op, data) { \ - vfs_init((vfsp), (op), (data)); \ - vfsimpl_setup((vfsp)); \ -} - - -#define VFS_INSTALLED(vfsswp) (((vfsswp)->vsw_flag & VSW_INSTALLED) != 0) -#define ALLOCATED_VFSSW(vswp) ((vswp)->vsw_name[0] != '\0') -#define RLOCK_VFSSW() (rw_enter(&vfssw_lock, RW_READER)) -#define RUNLOCK_VFSSW() (rw_exit(&vfssw_lock)) -#define WLOCK_VFSSW() (rw_enter(&vfssw_lock, RW_WRITER)) -#define WUNLOCK_VFSSW() (rw_exit(&vfssw_lock)) -#define VFSSW_LOCKED() (RW_LOCK_HELD(&vfssw_lock)) -#define VFSSW_WRITE_LOCKED() (RW_WRITE_HELD(&vfssw_lock)) -/* - * VFS_SYNC flags. - */ -#define SYNC_ATTR 0x01 /* sync attributes only */ -#define SYNC_CLOSE 0x02 /* close open file */ -#define SYNC_ALL 0x04 /* force to sync all fs */ - -#ifdef __cplusplus -} -#endif - -#endif /* __APPLE__ */ - -#endif /* _SYS_VFS_H */ diff --git a/udffsck/main.c b/udffsck/main.c index 5f7a6807..446ed264 100644 --- a/udffsck/main.c +++ b/udffsck/main.c @@ -34,10 +34,19 @@ #include #include #include +#ifdef __APPLE__ +//#include +#include +#else #include #include +#endif #include +#ifdef __APPLE__ +#include +#else #include +#endif #include #include From 0b52d34f5a5eab0c07d26b954dac3a5f3331b2f7 Mon Sep 17 00:00:00 2001 From: Giovanni Merlino Date: Fri, 5 Jan 2018 13:03:34 +0100 Subject: [PATCH 3/7] fix for endianness checks on macOS, fix for Travis badge --- README.md | 2 +- include/bswap.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f3bed68a..2fa20f77 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ -[![Build Status](https://travis-ci.org/argorain/udftools.svg?branch=master)](https://travis-ci.org/argorain/udftools) +[![Build Status](https://travis-ci.org/gmerlino/udftools.svg?branch=master)](https://travis-ci.org/gmerlino/udftools) Linux tools for UDF filesystems and DVD/CD-R(W) drives diff --git a/include/bswap.h b/include/bswap.h index 5d1fc997..d0a3c4f6 100644 --- a/include/bswap.h +++ b/include/bswap.h @@ -47,6 +47,8 @@ /* macOS (Intel) */ #ifdef __APPLE__ +#define __LITTLE_ENDIAN LITTLE_ENDIAN +#define __BIG_ENDIAN BIG_ENDIAN #define __BYTE_ORDER BYTE_ORDER #endif /* __APPLE__ */ From 9bf524e3ff06dcf185488f1929adc4883a4025a5 Mon Sep 17 00:00:00 2001 From: Giovanni Merlino Date: Fri, 5 Jan 2018 14:37:52 +0100 Subject: [PATCH 4/7] fixed wrong assumptions on Travis environment (e.g., installed Homebrew formulas) under macOS --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 56e5e7c8..fdfec075 100644 --- a/.travis.yml +++ b/.travis.yml @@ -56,7 +56,8 @@ addons: &addons before_script: - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install automake libtool cmake wget; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install automake libtool; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew upgrade cmake wget; fi - cd .. - mkdir cmocka - cd cmocka From 9e5e8da8ad302b1817c1f80380b396c011019007 Mon Sep 17 00:00:00 2001 From: Giovanni Merlino Date: Fri, 5 Jan 2018 15:01:59 +0100 Subject: [PATCH 5/7] fixed missing libtoolize error with a symlink --- .travis.yml | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index fdfec075..e472537a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,5 @@ language: c -matrix: - include: - - os: linux - - os: osx - allow_failures: - - os: osx - -compiler: - - gcc - - clang - # - tcc - dist: - trusty # - precise @@ -38,9 +26,15 @@ addons: &addons # - tcc # - tcc:i386 -#matrix: -# include: -# - compiler: gcc +matrix: + include: + - os: linux + compiler: gcc + compiler: clang + - os: osx + compiler: clang + allow_failures: + - os: osx # env: # - secure: "rH+rQS0W+0U3C/W/uRqJ8E5A3KrlbWaDRpZtdT1/SO0kEMnmuG2b0UvoadcIKOEXNHnQeZ3kPQbG2Wjfo/D6up0mXGZLXAvaJZozagxdfF2QPHSpvj2NDRLM71+UaKK/ksq3auPq+o3Y74FZOc4oBr7kPpr01H0pK8/2lljxS2daINRgFfcsaRhKNshtvHBn/KLgbwa5vEB/jadKBKM+mgAYE1sFv8P3yZ3+MzxygpurJ6enU6/9JITF5QgB11ybivYCbqoEf+IhzxgsmELz0zgL+PCVzTvrrNzpCT1UZJ35vWht5Yf7/AmK3sI/rMJm7TYswFKAc7NUbn80oIw6opp7sW1oFqMEHnHNLMNSljg8BwUrbH+y6+yV7sRfG6djCTYUYGYY9ZC2Ef4r3s3ZrRwHuBujZx/DOnFj0nd0AuvETNPkMWD1996bvSQ+WkfZ4JdW335/G61GdQv7kMTutWLKrlDquqxKM1AsoP1d99vCBzpEfRKyZjDUUSmnjdvZ/QgIDidGzH3vYFO81N39HjgKZlxH+oCuoX2ak3A6BrOT7t6mgEXnGM4H9vWhoKb7hseadBsR7YnbFSRmF2FDihEoIJ/BCPykGSZWzxTF94zC3WURI1C3HL0sAHGg3M620FgFj3M4Xkf0CPsmdsjwsnZg6TgVkYwAaKKP0HI2MFs=" # addons: @@ -57,6 +51,7 @@ addons: &addons before_script: - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install automake libtool; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ln -s /usr/local/bin/glibtoolize /usr/local/bin/libtoolize; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew upgrade cmake wget; fi - cd .. - mkdir cmocka From 3295d18736d4a48dfc10a92721809a11f8d83e29 Mon Sep 17 00:00:00 2001 From: Giovanni Merlino Date: Fri, 5 Jan 2018 16:01:31 +0100 Subject: [PATCH 6/7] skipping top-level make due to (incomplete) port, possibly this one should fix macOS compilation of fsck under Travis --- .travis.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.travis.yml b/.travis.yml index e472537a..cfc61f24 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,8 +31,20 @@ matrix: - os: linux compiler: gcc compiler: clang + script: + - if [ -n "$COVERITY_SCAN_TOKEN" ]; then exit 0; fi + - ./autogen.sh $TESTS + - ./configure $TESTS + - make + - if [ -n "$TESTS" ]; then ./udffsck/travis-tests.sh $TESTLEVEL; fi - os: osx compiler: clang + script: + - if [ -n "$COVERITY_SCAN_TOKEN" ]; then exit 0; fi + - ./autogen.sh $TESTS + - ./configure $TESTS + - cd libudffs && make + - cd ../udffsck && make allow_failures: - os: osx # env: From 36dccbf969f707a11dcff85f0cae86851cc3de2f Mon Sep 17 00:00:00 2001 From: Giovanni Merlino Date: Fri, 5 Jan 2018 16:29:11 +0100 Subject: [PATCH 7/7] fixed (full) compilation of udftools (modifications outside fsck folder not pushed here, for clean fsck PR) --- include/bswap.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/bswap.h b/include/bswap.h index d0a3c4f6..bf6d1718 100644 --- a/include/bswap.h +++ b/include/bswap.h @@ -45,11 +45,16 @@ #endif #endif -/* macOS (Intel) */ +/* macOS */ #ifdef __APPLE__ #define __LITTLE_ENDIAN LITTLE_ENDIAN #define __BIG_ENDIAN BIG_ENDIAN #define __BYTE_ORDER BYTE_ORDER +#if __BYTE_ORDER == BIG_ENDIAN +#define __BIG_ENDIAN_BITFIELD +#elif __BYTE_ORDER == LITTLE_ENDIAN +#define __LITTLE_ENDIAN_BITFIELD +#endif #endif /* __APPLE__ */ #define constant_swab16(x) \