Remove libkern, leave just header.
Boot stuff dependencies from NetBSD. Patch by Antoine Leca. Relocated to src/sys. The port is using the same libminc.a as usual MINIX services (and does not use NetBSD libkern); the headers imported from NetBSD sys/ tree have been kept to a minimum (still numbers higher than 30 though.) Note the peculiar way to use libraries (libsa, libi386, etc.): the source code is shared, but each component builds its own copy of the library, with its own set of preprocessor defines.
This commit is contained in:
91
sys/sys/boot_flag.h
Normal file
91
sys/sys/boot_flag.h
Normal file
@@ -0,0 +1,91 @@
|
||||
/* $NetBSD: boot_flag.h,v 1.7 2008/04/29 19:16:08 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, 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 NETBSD FOUNDATION, INC. 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 FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_BOOT_FLAG_H_
|
||||
#define _SYS_BOOT_FLAG_H_
|
||||
|
||||
#include <sys/reboot.h>
|
||||
|
||||
/*
|
||||
* Recognize standard boot arguments. If the flag is known, appropriate
|
||||
* value is or'ed to retval, otherwise retval is left intact.
|
||||
* Note that not all ports use all flags recognized here. This list is mere
|
||||
* concatenation of all non-conflicting standard boot flags. Individual ports
|
||||
* might use also other flags (see e.g. alpha).
|
||||
*/
|
||||
#define BOOT_FLAG(arg, retval) do { \
|
||||
switch (arg) { \
|
||||
case '1': /* machine dependent flag */ \
|
||||
(retval) |= RB_MD1; \
|
||||
break; \
|
||||
case '2': /* machine dependent flag */ \
|
||||
(retval) |= RB_MD2; \
|
||||
break; \
|
||||
case '3': /* machine dependent flag */ \
|
||||
(retval) |= RB_MD3; \
|
||||
break; \
|
||||
case '4': /* machine dependent flag */ \
|
||||
(retval) |= RB_MD4; \
|
||||
break; \
|
||||
case 'a': /* ask for file name to boot from */ \
|
||||
(retval) |= RB_ASKNAME; \
|
||||
break; \
|
||||
case 'b': /* always halt, never reboot */ \
|
||||
(retval) |= RB_HALT; \
|
||||
break; \
|
||||
case 'c': /* userconf */ \
|
||||
(retval) |= RB_USERCONF; \
|
||||
break; \
|
||||
case 'd': /* break into the kernel debugger ASAP (if compiled in) */ \
|
||||
(retval) |= RB_KDB; \
|
||||
break; \
|
||||
case 'm': /* mini root present in memory */ \
|
||||
(retval) |= RB_MINIROOT; \
|
||||
break; \
|
||||
case 'q': /* boot quietly */ \
|
||||
(retval) |= AB_QUIET; \
|
||||
break; \
|
||||
case 's': /* boot to single user */ \
|
||||
(retval) |= RB_SINGLE; \
|
||||
break; \
|
||||
case 'v': /* boot verbosely */ \
|
||||
(retval) |= AB_VERBOSE; \
|
||||
break; \
|
||||
case 'x': /* boot with debugging messages */ \
|
||||
(retval) |= AB_DEBUG; \
|
||||
break; \
|
||||
case 'z': /* boot silently */ \
|
||||
(retval) |= AB_SILENT; \
|
||||
break; \
|
||||
default: /* something else, do nothing */ \
|
||||
break; \
|
||||
} /* switch */ \
|
||||
\
|
||||
} while (/* CONSTCOND */ 0)
|
||||
|
||||
#endif /* _SYS_BOOT_FLAG_H_ */
|
||||
62
sys/sys/condvar.h
Normal file
62
sys/sys/condvar.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/* $NetBSD: condvar.h,v 1.12 2009/12/05 22:38:19 pooka Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Andrew Doran.
|
||||
*
|
||||
* 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 NETBSD FOUNDATION, INC. 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 FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_CONDVAR_H_
|
||||
#define _SYS_CONDVAR_H_
|
||||
|
||||
#include <sys/mutex.h>
|
||||
|
||||
typedef struct kcondvar {
|
||||
void *cv_opaque[3];
|
||||
} kcondvar_t;
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
void cv_init(kcondvar_t *, const char *);
|
||||
void cv_destroy(kcondvar_t *);
|
||||
|
||||
void cv_wait(kcondvar_t *, kmutex_t *);
|
||||
int cv_wait_sig(kcondvar_t *, kmutex_t *);
|
||||
int cv_timedwait(kcondvar_t *, kmutex_t *, int);
|
||||
int cv_timedwait_sig(kcondvar_t *, kmutex_t *, int);
|
||||
|
||||
void cv_signal(kcondvar_t *);
|
||||
void cv_broadcast(kcondvar_t *);
|
||||
|
||||
bool cv_has_waiters(kcondvar_t *);
|
||||
bool cv_is_valid(kcondvar_t *);
|
||||
|
||||
/* The "lightning bolt", awoken once per second by the clock interrupt. */
|
||||
extern kcondvar_t lbolt;
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* _SYS_CONDVAR_H_ */
|
||||
476
sys/sys/disklabel.h
Normal file
476
sys/sys/disklabel.h
Normal file
@@ -0,0 +1,476 @@
|
||||
/* $NetBSD: disklabel.h,v 1.112 2012/01/16 18:47:58 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987, 1988, 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.
|
||||
*
|
||||
* @(#)disklabel.h 8.2 (Berkeley) 7/10/94
|
||||
*/
|
||||
|
||||
#ifndef _SYS_DISKLABEL_H_
|
||||
#define _SYS_DISKLABEL_H_
|
||||
|
||||
/*
|
||||
* We need <machine/types.h> for __HAVE_OLD_DISKLABEL
|
||||
*/
|
||||
#ifndef _LOCORE
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Each disk has a label which includes information about the hardware
|
||||
* disk geometry, filesystem partitions, and drive specific information.
|
||||
* The location of the label, as well as the number of partitions the
|
||||
* label can describe and the number of the "whole disk" (raw)
|
||||
* paritition are machine dependent.
|
||||
*/
|
||||
#if HAVE_NBTOOL_CONFIG_H
|
||||
#include <nbinclude/machine/disklabel.h>
|
||||
#else
|
||||
#include <machine/disklabel.h>
|
||||
#endif /* HAVE_NBTOOL_CONFIG_H */
|
||||
|
||||
/*
|
||||
* The absolute maximum number of disk partitions allowed.
|
||||
* This is the maximum value of MAXPARTITIONS for which 'struct disklabel'
|
||||
* is <= DEV_BSIZE bytes long. If MAXPARTITIONS is greater than this, beware.
|
||||
*/
|
||||
#define MAXMAXPARTITIONS 22
|
||||
#if MAXPARTITIONS > MAXMAXPARTITIONS
|
||||
#warning beware: MAXPARTITIONS bigger than MAXMAXPARTITIONS
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Ports can switch their MAXPARTITIONS once, as follows:
|
||||
*
|
||||
* - define OLDMAXPARTITIONS in <machine/disklabel.h> as the old number
|
||||
* - define MAXPARTITIONS as the new number
|
||||
* - define DISKUNIT, DISKPART and DISKMINOR macros in <machine/disklabel.h>
|
||||
* as appropriate for the port (see the i386 one for an example).
|
||||
* - define __HAVE_OLD_DISKLABEL in <machine/types.h>
|
||||
*/
|
||||
|
||||
#if defined(_KERNEL) && defined(__HAVE_OLD_DISKLABEL) && \
|
||||
(MAXPARTITIONS < OLDMAXPARTITIONS)
|
||||
#error "can only grow disklabel size"
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Translate between device numbers and major/disk unit/disk partition.
|
||||
*/
|
||||
#ifndef __HAVE_OLD_DISKLABEL
|
||||
#if !HAVE_NBTOOL_CONFIG_H
|
||||
#define DISKUNIT(dev) (minor(dev) / MAXPARTITIONS)
|
||||
#define DISKPART(dev) (minor(dev) % MAXPARTITIONS)
|
||||
#define DISKMINOR(unit, part) \
|
||||
(((unit) * MAXPARTITIONS) + (part))
|
||||
#endif /* !HAVE_NBTOOL_CONFIG_H */
|
||||
#endif
|
||||
#define MAKEDISKDEV(maj, unit, part) \
|
||||
(makedev((maj), DISKMINOR((unit), (part))))
|
||||
|
||||
#define DISKMAGIC ((uint32_t)0x82564557) /* The disk magic number */
|
||||
|
||||
#ifndef _LOCORE
|
||||
struct disklabel {
|
||||
uint32_t d_magic; /* the magic number */
|
||||
uint16_t d_type; /* drive type */
|
||||
uint16_t d_subtype; /* controller/d_type specific */
|
||||
char d_typename[16]; /* type name, e.g. "eagle" */
|
||||
|
||||
/*
|
||||
* d_packname contains the pack identifier and is returned when
|
||||
* the disklabel is read off the disk or in-core copy.
|
||||
* d_boot0 and d_boot1 are the (optional) names of the
|
||||
* primary (block 0) and secondary (block 1-15) bootstraps
|
||||
* as found in /usr/mdec. These are returned when using
|
||||
* getdiskbyname(3) to retrieve the values from /etc/disktab.
|
||||
*/
|
||||
union {
|
||||
char un_d_packname[16]; /* pack identifier */
|
||||
struct {
|
||||
char *un_d_boot0; /* primary bootstrap name */
|
||||
char *un_d_boot1; /* secondary bootstrap name */
|
||||
} un_b;
|
||||
uint64_t un_d_pad; /* force 8 byte alignment */
|
||||
} d_un;
|
||||
#define d_packname d_un.un_d_packname
|
||||
#define d_boot0 d_un.un_b.un_d_boot0
|
||||
#define d_boot1 d_un.un_b.un_d_boot1
|
||||
|
||||
/* disk geometry: */
|
||||
uint32_t d_secsize; /* # of bytes per sector */
|
||||
uint32_t d_nsectors; /* # of data sectors per track */
|
||||
uint32_t d_ntracks; /* # of tracks per cylinder */
|
||||
uint32_t d_ncylinders; /* # of data cylinders per unit */
|
||||
uint32_t d_secpercyl; /* # of data sectors per cylinder */
|
||||
uint32_t d_secperunit; /* # of data sectors per unit */
|
||||
|
||||
/*
|
||||
* Spares (bad sector replacements) below are not counted in
|
||||
* d_nsectors or d_secpercyl. Spare sectors are assumed to
|
||||
* be physical sectors which occupy space at the end of each
|
||||
* track and/or cylinder.
|
||||
*/
|
||||
uint16_t d_sparespertrack; /* # of spare sectors per track */
|
||||
uint16_t d_sparespercyl; /* # of spare sectors per cylinder */
|
||||
/*
|
||||
* Alternative cylinders include maintenance, replacement,
|
||||
* configuration description areas, etc.
|
||||
*/
|
||||
uint32_t d_acylinders; /* # of alt. cylinders per unit */
|
||||
|
||||
/* hardware characteristics: */
|
||||
/*
|
||||
* d_interleave, d_trackskew and d_cylskew describe perturbations
|
||||
* in the media format used to compensate for a slow controller.
|
||||
* Interleave is physical sector interleave, set up by the
|
||||
* formatter or controller when formatting. When interleaving is
|
||||
* in use, logically adjacent sectors are not physically
|
||||
* contiguous, but instead are separated by some number of
|
||||
* sectors. It is specified as the ratio of physical sectors
|
||||
* traversed per logical sector. Thus an interleave of 1:1
|
||||
* implies contiguous layout, while 2:1 implies that logical
|
||||
* sector 0 is separated by one sector from logical sector 1.
|
||||
* d_trackskew is the offset of sector 0 on track N relative to
|
||||
* sector 0 on track N-1 on the same cylinder. Finally, d_cylskew
|
||||
* is the offset of sector 0 on cylinder N relative to sector 0
|
||||
* on cylinder N-1.
|
||||
*/
|
||||
uint16_t d_rpm; /* rotational speed */
|
||||
uint16_t d_interleave; /* hardware sector interleave */
|
||||
uint16_t d_trackskew; /* sector 0 skew, per track */
|
||||
uint16_t d_cylskew; /* sector 0 skew, per cylinder */
|
||||
uint32_t d_headswitch; /* head switch time, usec */
|
||||
uint32_t d_trkseek; /* track-to-track seek, usec */
|
||||
uint32_t d_flags; /* generic flags */
|
||||
#define NDDATA 5
|
||||
uint32_t d_drivedata[NDDATA]; /* drive-type specific information */
|
||||
#define NSPARE 5
|
||||
uint32_t d_spare[NSPARE]; /* reserved for future use */
|
||||
uint32_t d_magic2; /* the magic number (again) */
|
||||
uint16_t d_checksum; /* xor of data incl. partitions */
|
||||
|
||||
/* filesystem and partition information: */
|
||||
uint16_t d_npartitions; /* number of partitions in following */
|
||||
uint32_t d_bbsize; /* size of boot area at sn0, bytes */
|
||||
uint32_t d_sbsize; /* max size of fs superblock, bytes */
|
||||
struct partition { /* the partition table */
|
||||
uint32_t p_size; /* number of sectors in partition */
|
||||
uint32_t p_offset; /* starting sector */
|
||||
union {
|
||||
uint32_t fsize; /* FFS, ADOS:
|
||||
filesystem basic fragment size */
|
||||
uint32_t cdsession; /* ISO9660: session offset */
|
||||
} __partition_u2;
|
||||
#define p_fsize __partition_u2.fsize
|
||||
#define p_cdsession __partition_u2.cdsession
|
||||
uint8_t p_fstype; /* filesystem type, see below */
|
||||
uint8_t p_frag; /* filesystem fragments per block */
|
||||
union {
|
||||
uint16_t cpg; /* UFS: FS cylinders per group */
|
||||
uint16_t sgs; /* LFS: FS segment shift */
|
||||
} __partition_u1;
|
||||
#define p_cpg __partition_u1.cpg
|
||||
#define p_sgs __partition_u1.sgs
|
||||
} d_partitions[MAXPARTITIONS]; /* actually may be more */
|
||||
};
|
||||
|
||||
#if defined(__HAVE_OLD_DISKLABEL) && !HAVE_NBTOOL_CONFIG_H
|
||||
/*
|
||||
* Same as above, but with OLDMAXPARTITIONS partitions. For use in
|
||||
* the old DIOC* ioctl calls.
|
||||
*/
|
||||
struct olddisklabel {
|
||||
uint32_t d_magic;
|
||||
uint16_t d_type;
|
||||
uint16_t d_subtype;
|
||||
char d_typename[16];
|
||||
union {
|
||||
char un_d_packname[16];
|
||||
struct {
|
||||
char *un_d_boot0;
|
||||
char *un_d_boot1;
|
||||
} un_b;
|
||||
} d_un;
|
||||
uint32_t d_secsize;
|
||||
uint32_t d_nsectors;
|
||||
uint32_t d_ntracks;
|
||||
uint32_t d_ncylinders;
|
||||
uint32_t d_secpercyl;
|
||||
uint32_t d_secperunit;
|
||||
uint16_t d_sparespertrack;
|
||||
uint16_t d_sparespercyl;
|
||||
uint32_t d_acylinders;
|
||||
uint16_t d_rpm;
|
||||
uint16_t d_interleave;
|
||||
uint16_t d_trackskew;
|
||||
uint16_t d_cylskew;
|
||||
uint32_t d_headswitch;
|
||||
uint32_t d_trkseek;
|
||||
uint32_t d_flags;
|
||||
uint32_t d_drivedata[NDDATA];
|
||||
uint32_t d_spare[NSPARE];
|
||||
uint32_t d_magic2;
|
||||
uint16_t d_checksum;
|
||||
uint16_t d_npartitions;
|
||||
uint32_t d_bbsize;
|
||||
uint32_t d_sbsize;
|
||||
struct opartition {
|
||||
uint32_t p_size;
|
||||
uint32_t p_offset;
|
||||
union {
|
||||
uint32_t fsize;
|
||||
uint32_t cdsession;
|
||||
} __partition_u2;
|
||||
uint8_t p_fstype;
|
||||
uint8_t p_frag;
|
||||
union {
|
||||
uint16_t cpg;
|
||||
uint16_t sgs;
|
||||
} __partition_u1;
|
||||
} d_partitions[OLDMAXPARTITIONS];
|
||||
};
|
||||
#endif /* __HAVE_OLD_DISKLABEL */
|
||||
#else /* _LOCORE */
|
||||
/*
|
||||
* offsets for asm boot files.
|
||||
*/
|
||||
.set d_secsize,40
|
||||
.set d_nsectors,44
|
||||
.set d_ntracks,48
|
||||
.set d_ncylinders,52
|
||||
.set d_secpercyl,56
|
||||
.set d_secperunit,60
|
||||
.set d_end_,276 /* size of disk label */
|
||||
#endif /* _LOCORE */
|
||||
|
||||
/*
|
||||
* We normally use C99 initialisers (just in case the lists below are out
|
||||
* of sequence, or have gaps), but lint doesn't grok them.
|
||||
* Maybe some host compilers don't either, but many have for quite some time.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#define ARRAY_INIT(element,value) [element]=value
|
||||
#else
|
||||
#define ARRAY_INIT(element,value) value
|
||||
#endif
|
||||
|
||||
/* Use pre-processor magic to get all the parameters one one line... */
|
||||
|
||||
/* d_type values: */
|
||||
#define DKTYPE_DEFN(x) \
|
||||
x(UNKNOWN, 0, "unknown") \
|
||||
x(SMD, 1, "SMD") /* SMD, XSMD; VAX hp/up */ \
|
||||
x(MSCP, 2, "MSCP") /* MSCP */ \
|
||||
x(DEC, 3, "old DEC") /* other DEC (rk, rl) */ \
|
||||
x(SCSI, 4, "SCSI") /* SCSI */ \
|
||||
x(ESDI, 5, "ESDI") /* ESDI interface */ \
|
||||
x(ST506, 6, "ST506") /* ST506 etc. */ \
|
||||
x(HPIB, 7, "HP-IB") /* CS/80 on HP-IB */ \
|
||||
x(HPFL, 8, "HP-FL") /* HP Fiber-link */ \
|
||||
x(TYPE_9, 9, "type 9") \
|
||||
x(FLOPPY, 10, "floppy") /* floppy */ \
|
||||
x(CCD, 11, "ccd") /* concatenated disk device */ \
|
||||
x(VND, 12, "vnd") /* uvnode pseudo-disk */ \
|
||||
x(ATAPI, 13, "ATAPI") /* ATAPI */ \
|
||||
x(RAID, 14, "RAID") /* RAIDframe */ \
|
||||
x(LD, 15, "ld") /* logical disk */ \
|
||||
x(JFS2, 16, "jfs") /* IBM JFS2 */ \
|
||||
x(CGD, 17, "cgd") /* cryptographic pseudo-disk */ \
|
||||
x(VINUM, 18, "vinum") /* vinum volume */ \
|
||||
x(FLASH, 19, "flash") /* flash memory devices */ \
|
||||
x(DM, 20, "dm") /* device-mapper pseudo-disk devices */\
|
||||
x(RUMPD, 21, "rumpd") /* rump virtual disk */ \
|
||||
|
||||
#ifndef _LOCORE
|
||||
#define DKTYPE_NUMS(tag, number, name) __CONCAT(DTYPE_,tag=number),
|
||||
#ifndef DKTYPE_ENUMNAME
|
||||
#define DKTYPE_ENUMNAME
|
||||
#endif
|
||||
enum DKTYPE_ENUMNAME { DKTYPE_DEFN(DKTYPE_NUMS) DKMAXTYPES };
|
||||
#undef DKTYPE_NUMS
|
||||
#endif
|
||||
|
||||
#ifdef DKTYPENAMES
|
||||
#define DKTYPE_NAMES(tag, number, name) ARRAY_INIT(number,name),
|
||||
static const char *const dktypenames[] = { DKTYPE_DEFN(DKTYPE_NAMES) NULL };
|
||||
#undef DKTYPE_NAMES
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Partition type names, numbers, label-names, fsck prog, and mount prog
|
||||
*/
|
||||
#define FSTYPE_DEFN(x) \
|
||||
x(UNUSED, 0, "unused", NULL, NULL) /* unused */ \
|
||||
x(SWAP, 1, "swap", NULL, NULL) /* swap */ \
|
||||
x(V6, 2, "Version 6", NULL, NULL) /* Sixth Edition */ \
|
||||
x(V7, 3, "Version 7", "v7fs", "v7fs") /* Seventh Edition */ \
|
||||
x(SYSV, 4, "System V", NULL, NULL) /* System V */ \
|
||||
x(V71K, 5, "4.1BSD", NULL, NULL) /* V7, 1K blocks (4.1, 2.9) */ \
|
||||
x(V8, 6, "Eighth Edition",NULL, NULL) /* Eighth Edition, 4K blocks */ \
|
||||
x(BSDFFS, 7, "4.2BSD", "ffs", "ffs") /* 4.2BSD fast file system */ \
|
||||
x(MSDOS, 8, "MSDOS", "msdos", "msdos") /* MSDOS file system */ \
|
||||
x(BSDLFS, 9, "4.4LFS", "lfs", "lfs") /* 4.4BSD log-structured FS */ \
|
||||
x(OTHER, 10, "unknown", NULL, NULL) /* in use, unknown/unsupported */\
|
||||
x(HPFS, 11, "HPFS", NULL, NULL) /* OS/2 high-performance FS */ \
|
||||
x(ISO9660, 12, "ISO9660", NULL, "cd9660")/* ISO 9660, normally CD-ROM */ \
|
||||
x(BOOT, 13, "boot", NULL, NULL) /* bootstrap code in partition */\
|
||||
x(ADOS, 14, "ADOS", NULL, "ados") /* AmigaDOS fast file system */ \
|
||||
x(HFS, 15, "HFS", NULL, NULL) /* Macintosh HFS */ \
|
||||
x(FILECORE,16, "FILECORE", NULL, "filecore")/* Acorn Filecore FS */ \
|
||||
x(EX2FS, 17, "Linux Ext2","ext2fs","ext2fs")/* Linux Extended 2 FS */ \
|
||||
x(NTFS, 18, "NTFS", NULL, "ntfs") /* Windows/NT file system */ \
|
||||
x(RAID, 19, "RAID", NULL, NULL) /* RAIDframe component */ \
|
||||
x(CCD, 20, "ccd", NULL, NULL) /* concatenated disk component */\
|
||||
x(JFS2, 21, "jfs", NULL, NULL) /* IBM JFS2 */ \
|
||||
x(APPLEUFS,22, "Apple UFS", "ffs", "ffs") /* Apple UFS */ \
|
||||
/* XXX this is not the same as FreeBSD. How to solve? */ \
|
||||
x(VINUM, 23, "vinum", NULL, NULL) /* Vinum */ \
|
||||
x(UDF, 24, "UDF", NULL, "udf") /* UDF */ \
|
||||
x(SYSVBFS, 25, "SysVBFS", NULL, "sysvbfs")/* System V boot file system */ \
|
||||
x(EFS, 26, "EFS", NULL, "efs") /* SGI's Extent Filesystem */ \
|
||||
x(NILFS, 27, "NiLFS", NULL, "nilfs") /* NTT's NiLFS(2) */ \
|
||||
x(CGD, 28, "cgd", NULL, NULL) /* Cryptographic disk */ \
|
||||
x(MINIXFS3,29, "MINIX FSv3", NULL, NULL) /* MINIX file system v3 */
|
||||
|
||||
|
||||
#ifndef _LOCORE
|
||||
#define FS_TYPENUMS(tag, number, name, fsck, mount) __CONCAT(FS_,tag=number),
|
||||
#ifndef FSTYPE_ENUMNAME
|
||||
#define FSTYPE_ENUMNAME
|
||||
#endif
|
||||
enum FSTYPE_ENUMNAME { FSTYPE_DEFN(FS_TYPENUMS) FSMAXTYPES };
|
||||
#undef FS_TYPENUMS
|
||||
#endif
|
||||
|
||||
#ifdef FSTYPENAMES
|
||||
#define FS_TYPENAMES(tag, number, name, fsck, mount) ARRAY_INIT(number,name),
|
||||
static const char *const fstypenames[] = { FSTYPE_DEFN(FS_TYPENAMES) NULL };
|
||||
#undef FS_TYPENAMES
|
||||
#endif
|
||||
|
||||
#ifdef FSCKNAMES
|
||||
/* These are the names MOUNT_XXX from <sys/mount.h> */
|
||||
#define FS_FSCKNAMES(tag, number, name, fsck, mount) ARRAY_INIT(number,fsck),
|
||||
static const char *const fscknames[] = { FSTYPE_DEFN(FS_FSCKNAMES) NULL };
|
||||
#undef FS_FSCKNAMES
|
||||
#define FSMAXNAMES FSMAXTYPES
|
||||
#endif
|
||||
|
||||
#ifdef MOUNTNAMES
|
||||
/* These are the names MOUNT_XXX from <sys/mount.h> */
|
||||
#define FS_MOUNTNAMES(tag, number, name, fsck, mount) ARRAY_INIT(number,mount),
|
||||
static const char *const mountnames[] = { FSTYPE_DEFN(FS_MOUNTNAMES) NULL };
|
||||
#undef FS_MOUNTNAMES
|
||||
#define FSMAXMOUNTNAMES FSMAXTYPES
|
||||
#endif
|
||||
|
||||
/*
|
||||
* flags shared by various drives:
|
||||
*/
|
||||
#define D_REMOVABLE 0x01 /* removable media */
|
||||
#define D_ECC 0x02 /* supports ECC */
|
||||
#define D_BADSECT 0x04 /* supports bad sector forw. */
|
||||
#define D_RAMDISK 0x08 /* disk emulator */
|
||||
#define D_CHAIN 0x10 /* can do back-back transfers */
|
||||
#define D_SCSI_MMC 0x20 /* SCSI MMC sessioned media */
|
||||
|
||||
/*
|
||||
* Drive data for SMD.
|
||||
*/
|
||||
#define d_smdflags d_drivedata[0]
|
||||
#define D_SSE 0x1 /* supports skip sectoring */
|
||||
#define d_mindist d_drivedata[1]
|
||||
#define d_maxdist d_drivedata[2]
|
||||
#define d_sdist d_drivedata[3]
|
||||
|
||||
/*
|
||||
* Drive data for ST506.
|
||||
*/
|
||||
#define d_precompcyl d_drivedata[0]
|
||||
#define d_gap3 d_drivedata[1] /* used only when formatting */
|
||||
|
||||
/*
|
||||
* Drive data for SCSI.
|
||||
*/
|
||||
#define d_blind d_drivedata[0]
|
||||
|
||||
#ifndef _LOCORE
|
||||
/*
|
||||
* Structure used to perform a format or other raw operation,
|
||||
* returning data and/or register values. Register identification
|
||||
* and format are device- and driver-dependent. Currently unused.
|
||||
*/
|
||||
struct format_op {
|
||||
char *df_buf;
|
||||
int df_count; /* value-result */
|
||||
daddr_t df_startblk;
|
||||
int df_reg[8]; /* result */
|
||||
};
|
||||
|
||||
#ifdef _KERNEL
|
||||
/*
|
||||
* Structure used internally to retrieve information about a partition
|
||||
* on a disk.
|
||||
*/
|
||||
struct partinfo {
|
||||
struct disklabel *disklab;
|
||||
struct partition *part;
|
||||
};
|
||||
|
||||
struct disk;
|
||||
|
||||
int disk_read_sectors(void (*)(struct buf *), const struct disklabel *,
|
||||
struct buf *, unsigned int, int);
|
||||
void diskerr(const struct buf *, const char *, const char *, int,
|
||||
int, const struct disklabel *);
|
||||
u_int dkcksum(struct disklabel *);
|
||||
u_int dkcksum_sized(struct disklabel *, size_t);
|
||||
int setdisklabel(struct disklabel *, struct disklabel *, u_long,
|
||||
struct cpu_disklabel *);
|
||||
const char *readdisklabel(dev_t, void (*)(struct buf *),
|
||||
struct disklabel *, struct cpu_disklabel *);
|
||||
int writedisklabel(dev_t, void (*)(struct buf *), struct disklabel *,
|
||||
struct cpu_disklabel *);
|
||||
const char *convertdisklabel(struct disklabel *, void (*)(struct buf *),
|
||||
struct buf *, uint32_t);
|
||||
int bounds_check_with_label(struct disk *, struct buf *, int);
|
||||
int bounds_check_with_mediasize(struct buf *, int, uint64_t);
|
||||
const char *getfstypename(int);
|
||||
#endif
|
||||
#endif /* _LOCORE */
|
||||
|
||||
#if !defined(_KERNEL) && !defined(_LOCORE)
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* !_SYS_DISKLABEL_H_ */
|
||||
298
sys/sys/exec.h
Normal file
298
sys/sys/exec.h
Normal file
@@ -0,0 +1,298 @@
|
||||
/* $NetBSD: exec.h,v 1.133 2011/03/04 22:25:32 joerg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* (c) UNIX System Laboratories, Inc.
|
||||
* All or some portions of this file are derived from material licensed
|
||||
* to the University of California by American Telephone and Telegraph
|
||||
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
|
||||
* the permission of UNIX System Laboratories, Inc.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @(#)exec.h 8.4 (Berkeley) 2/19/95
|
||||
*/
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993 Theo de Raadt. 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 ``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 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.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1994 Christopher G. Demetriou
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @(#)exec.h 8.4 (Berkeley) 2/19/95
|
||||
*/
|
||||
|
||||
#ifndef _SYS_EXEC_H_
|
||||
#define _SYS_EXEC_H_
|
||||
|
||||
struct pathbuf; /* from namei.h */
|
||||
|
||||
|
||||
/*
|
||||
* The following structure is found at the top of the user stack of each
|
||||
* user process. The ps program uses it to locate argv and environment
|
||||
* strings. Programs that wish ps to display other information may modify
|
||||
* it; normally ps_argvstr points to argv[0], and ps_nargvstr is the same
|
||||
* as the program's argc. The fields ps_envstr and ps_nenvstr are the
|
||||
* equivalent for the environment.
|
||||
*/
|
||||
struct ps_strings {
|
||||
char **ps_argvstr; /* first of 0 or more argument strings */
|
||||
int ps_nargvstr; /* the number of argument strings */
|
||||
char **ps_envstr; /* first of 0 or more environment strings */
|
||||
int ps_nenvstr; /* the number of environment strings */
|
||||
};
|
||||
|
||||
#ifdef _KERNEL
|
||||
struct ps_strings32 {
|
||||
uint32_t ps_argvstr; /* first of 0 or more argument strings */
|
||||
int32_t ps_nargvstr; /* the number of argument strings */
|
||||
uint32_t ps_envstr; /* first of 0 or more environment strings */
|
||||
int32_t ps_nenvstr; /* the number of environment strings */
|
||||
};
|
||||
#endif
|
||||
|
||||
/*
|
||||
* the following structures allow execve() to put together processes
|
||||
* in a more extensible and cleaner way.
|
||||
*
|
||||
* the exec_package struct defines an executable being execve()'d.
|
||||
* it contains the header, the vmspace-building commands, the vnode
|
||||
* information, and the arguments associated with the newly-execve'd
|
||||
* process.
|
||||
*
|
||||
* the exec_vmcmd struct defines a command description to be used
|
||||
* in creating the new process's vmspace.
|
||||
*/
|
||||
|
||||
#include <sys/uio.h>
|
||||
|
||||
struct lwp;
|
||||
struct proc;
|
||||
struct exec_package;
|
||||
struct vnode;
|
||||
|
||||
typedef int (*exec_makecmds_fcn)(struct lwp *, struct exec_package *);
|
||||
|
||||
struct execsw {
|
||||
u_int es_hdrsz; /* size of header for this format */
|
||||
exec_makecmds_fcn es_makecmds; /* function to setup vmcmds */
|
||||
union { /* probe function */
|
||||
int (*elf_probe_func)(struct lwp *,
|
||||
struct exec_package *, void *, char *, vaddr_t *);
|
||||
int (*ecoff_probe_func)(struct lwp *, struct exec_package *);
|
||||
int (*mach_probe_func)(const char **);
|
||||
} u;
|
||||
struct emul *es_emul; /* os emulation */
|
||||
int es_prio; /* entry priority */
|
||||
int es_arglen; /* Extra argument size in words */
|
||||
/* Copy arguments on the new stack */
|
||||
int (*es_copyargs)(struct lwp *, struct exec_package *,
|
||||
struct ps_strings *, char **, void *);
|
||||
/* Set registers before execution */
|
||||
void (*es_setregs)(struct lwp *, struct exec_package *, vaddr_t);
|
||||
/* Dump core */
|
||||
int (*es_coredump)(struct lwp *, void *);
|
||||
int (*es_setup_stack)(struct lwp *, struct exec_package *);
|
||||
};
|
||||
|
||||
#define EXECSW_PRIO_ANY 0x000 /* default, no preference */
|
||||
#define EXECSW_PRIO_FIRST 0x001 /* this should be among first */
|
||||
#define EXECSW_PRIO_LAST 0x002 /* this should be among last */
|
||||
|
||||
/* exec vmspace-creation command set; see below */
|
||||
struct exec_vmcmd_set {
|
||||
u_int evs_cnt;
|
||||
u_int evs_used;
|
||||
struct exec_vmcmd *evs_cmds;
|
||||
};
|
||||
|
||||
#define EXEC_DEFAULT_VMCMD_SETSIZE 9 /* # of cmds in set to start */
|
||||
|
||||
struct exec_package {
|
||||
const char *ep_name; /* file's name */
|
||||
const char *ep_kname; /* kernel-side copy of file's name */
|
||||
char *ep_resolvedname; /* fully resolved path from namei */
|
||||
void *ep_hdr; /* file's exec header */
|
||||
u_int ep_hdrlen; /* length of ep_hdr */
|
||||
u_int ep_hdrvalid; /* bytes of ep_hdr that are valid */
|
||||
struct exec_vmcmd_set ep_vmcmds; /* vmcmds used to build vmspace */
|
||||
struct vnode *ep_vp; /* executable's vnode */
|
||||
struct vattr *ep_vap; /* executable's attributes */
|
||||
vaddr_t ep_taddr; /* process's text address */
|
||||
vsize_t ep_tsize; /* size of process's text */
|
||||
vaddr_t ep_daddr; /* process's data(+bss) address */
|
||||
vsize_t ep_dsize; /* size of process's data(+bss) */
|
||||
vaddr_t ep_maxsaddr; /* proc's max stack addr ("top") */
|
||||
vaddr_t ep_minsaddr; /* proc's min stack addr ("bottom") */
|
||||
vsize_t ep_ssize; /* size of process's stack */
|
||||
vaddr_t ep_entry; /* process's entry point */
|
||||
vaddr_t ep_vm_minaddr; /* bottom of process address space */
|
||||
vaddr_t ep_vm_maxaddr; /* top of process address space */
|
||||
u_int ep_flags; /* flags; see below. */
|
||||
size_t ep_fa_len; /* byte size of ep_fa */
|
||||
struct exec_fakearg {
|
||||
char *fa_arg;
|
||||
size_t fa_len;
|
||||
} *ep_fa; /* a fake args vector for scripts */
|
||||
int ep_fd; /* a file descriptor we're holding */
|
||||
void *ep_emul_arg; /* emulation argument */
|
||||
const struct execsw *ep_esch;/* execsw entry */
|
||||
struct vnode *ep_emul_root; /* base of emulation filesystem */
|
||||
struct vnode *ep_interp; /* vnode of (elf) interpeter */
|
||||
uint32_t ep_pax_flags; /* pax flags */
|
||||
char *ep_path; /* absolute path of executable */
|
||||
};
|
||||
#define EXEC_INDIR 0x0001 /* script handling already done */
|
||||
#define EXEC_HASFD 0x0002 /* holding a shell script */
|
||||
#define EXEC_HASARGL 0x0004 /* has fake args vector */
|
||||
#define EXEC_SKIPARG 0x0008 /* don't copy user-supplied argv[0] */
|
||||
#define EXEC_DESTR 0x0010 /* destructive ops performed */
|
||||
#define EXEC_32 0x0020 /* 32-bit binary emulation */
|
||||
#define EXEC_FORCEAUX 0x0040 /* always use ELF AUX vector */
|
||||
|
||||
struct exec_vmcmd {
|
||||
int (*ev_proc)(struct lwp *, struct exec_vmcmd *);
|
||||
/* procedure to run for region of vmspace */
|
||||
vsize_t ev_len; /* length of the segment to map */
|
||||
vaddr_t ev_addr; /* address in the vmspace to place it at */
|
||||
struct vnode *ev_vp; /* vnode pointer for the file w/the data */
|
||||
vsize_t ev_offset; /* offset in the file for the data */
|
||||
u_int ev_prot; /* protections for segment */
|
||||
int ev_flags;
|
||||
#define VMCMD_RELATIVE 0x0001 /* ev_addr is relative to base entry */
|
||||
#define VMCMD_BASE 0x0002 /* marks a base entry */
|
||||
#define VMCMD_FIXED 0x0004 /* entry must be mapped at ev_addr */
|
||||
#define VMCMD_STACK 0x0008 /* entry is for a stack */
|
||||
};
|
||||
|
||||
#ifdef _KERNEL
|
||||
/*
|
||||
* funtions used either by execve() or the various CPU-dependent execve()
|
||||
* hooks.
|
||||
*/
|
||||
void kill_vmcmd (struct exec_vmcmd **);
|
||||
int exec_makecmds (struct lwp *, struct exec_package *);
|
||||
int exec_runcmds (struct lwp *, struct exec_package *);
|
||||
void vmcmdset_extend (struct exec_vmcmd_set *);
|
||||
void kill_vmcmds (struct exec_vmcmd_set *);
|
||||
int vmcmd_map_pagedvn (struct lwp *, struct exec_vmcmd *);
|
||||
int vmcmd_map_readvn (struct lwp *, struct exec_vmcmd *);
|
||||
int vmcmd_readvn (struct lwp *, struct exec_vmcmd *);
|
||||
int vmcmd_map_zero (struct lwp *, struct exec_vmcmd *);
|
||||
int copyargs (struct lwp *, struct exec_package *,
|
||||
struct ps_strings *, char **, void *);
|
||||
int copyin_psstrings (struct proc *, struct ps_strings *);
|
||||
int copy_procargs (struct proc *, int, size_t *,
|
||||
int (*)(void *, const void *, size_t, size_t), void *);
|
||||
void setregs (struct lwp *, struct exec_package *, vaddr_t);
|
||||
int check_veriexec (struct lwp *, struct vnode *,
|
||||
struct exec_package *, int);
|
||||
int check_exec (struct lwp *, struct exec_package *,
|
||||
struct pathbuf *);
|
||||
int exec_init (int);
|
||||
int exec_read_from (struct lwp *, struct vnode *, u_long off,
|
||||
void *, size_t);
|
||||
int exec_setup_stack (struct lwp *, struct exec_package *);
|
||||
|
||||
int coredump_write (void *, enum uio_seg, const void *, size_t);
|
||||
/*
|
||||
* Machine dependent functions
|
||||
*/
|
||||
struct core;
|
||||
struct core32;
|
||||
int cpu_coredump(struct lwp *, void *, struct core *);
|
||||
int cpu_coredump32(struct lwp *, void *, struct core32 *);
|
||||
|
||||
int exec_add(struct execsw *, int);
|
||||
int exec_remove(struct execsw *, int);
|
||||
|
||||
void new_vmcmd(struct exec_vmcmd_set *,
|
||||
int (*)(struct lwp *, struct exec_vmcmd *),
|
||||
vsize_t, vaddr_t, struct vnode *, u_long, u_int, int);
|
||||
#define NEW_VMCMD(evsp,lwp,len,addr,vp,offset,prot) \
|
||||
new_vmcmd(evsp,lwp,len,addr,vp,offset,prot,0)
|
||||
#define NEW_VMCMD2(evsp,lwp,len,addr,vp,offset,prot,flags) \
|
||||
new_vmcmd(evsp,lwp,len,addr,vp,offset,prot,flags)
|
||||
|
||||
typedef int (*execve_fetch_element_t)(char * const *, size_t, char **);
|
||||
int execve1(struct lwp *, const char *, char * const *, char * const *,
|
||||
execve_fetch_element_t);
|
||||
|
||||
extern int maxexec;
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* !_SYS_EXEC_H_ */
|
||||
466
sys/sys/mount.h
Normal file
466
sys/sys/mount.h
Normal file
@@ -0,0 +1,466 @@
|
||||
/* $NetBSD: mount.h,v 1.201 2011/10/12 23:04:22 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1991, 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.
|
||||
*
|
||||
* @(#)mount.h 8.21 (Berkeley) 5/20/95
|
||||
*/
|
||||
|
||||
#ifndef _SYS_MOUNT_H_
|
||||
#define _SYS_MOUNT_H_
|
||||
|
||||
#ifndef _KERNEL
|
||||
#include <sys/featuretest.h>
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
#include <sys/stat.h>
|
||||
#endif /* _NETBSD_SOURCE */
|
||||
#endif
|
||||
|
||||
#ifndef _STANDALONE
|
||||
#include <sys/param.h> /* precautionary upon removal from ucred.h */
|
||||
#include <sys/time.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/ucred.h>
|
||||
#include <sys/fstypes.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/rwlock.h>
|
||||
#include <sys/statvfs.h>
|
||||
#include <sys/specificdata.h>
|
||||
#include <sys/condvar.h>
|
||||
#endif /* !_STANDALONE */
|
||||
|
||||
/*
|
||||
* file system statistics
|
||||
*/
|
||||
|
||||
#define MNAMELEN 90 /* length of buffer for returned name */
|
||||
|
||||
/*
|
||||
* File system types.
|
||||
*/
|
||||
#define MOUNT_FFS "ffs" /* UNIX "Fast" Filesystem */
|
||||
#define MOUNT_UFS MOUNT_FFS /* for compatibility */
|
||||
#define MOUNT_NFS "nfs" /* Network Filesystem */
|
||||
#define MOUNT_MFS "mfs" /* Memory Filesystem */
|
||||
#define MOUNT_MSDOS "msdos" /* MSDOS Filesystem */
|
||||
#define MOUNT_LFS "lfs" /* Log-based Filesystem */
|
||||
#define MOUNT_FDESC "fdesc" /* File Descriptor Filesystem */
|
||||
#define MOUNT_NULL "null" /* Minimal Filesystem Layer */
|
||||
#define MOUNT_OVERLAY "overlay" /* Minimal Overlay Filesystem Layer */
|
||||
#define MOUNT_UMAP "umap" /* User/Group Identifier Remapping Filesystem */
|
||||
#define MOUNT_KERNFS "kernfs" /* Kernel Information Filesystem */
|
||||
#define MOUNT_PROCFS "procfs" /* /proc Filesystem */
|
||||
#define MOUNT_AFS "afs" /* Andrew Filesystem */
|
||||
#define MOUNT_CD9660 "cd9660" /* ISO9660 (aka CDROM) Filesystem */
|
||||
#define MOUNT_UNION "union" /* Union (translucent) Filesystem */
|
||||
#define MOUNT_ADOSFS "adosfs" /* AmigaDOS Filesystem */
|
||||
#define MOUNT_EXT2FS "ext2fs" /* Second Extended Filesystem */
|
||||
#define MOUNT_CFS "coda" /* Coda Filesystem */
|
||||
#define MOUNT_CODA MOUNT_CFS /* Coda Filesystem */
|
||||
#define MOUNT_FILECORE "filecore" /* Acorn Filecore Filesystem */
|
||||
#define MOUNT_NTFS "ntfs" /* Windows/NT Filesystem */
|
||||
#define MOUNT_SMBFS "smbfs" /* CIFS (SMB) */
|
||||
#define MOUNT_PTYFS "ptyfs" /* Pseudo tty filesystem */
|
||||
#define MOUNT_TMPFS "tmpfs" /* Efficient memory file-system */
|
||||
#define MOUNT_UDF "udf" /* UDF CD/DVD filesystem */
|
||||
#define MOUNT_SYSVBFS "sysvbfs" /* System V Boot Filesystem */
|
||||
#define MOUNT_PUFFS "puffs" /* Pass-to-Userspace filesystem */
|
||||
#define MOUNT_HFS "hfs" /* Apple HFS+ Filesystem */
|
||||
#define MOUNT_EFS "efs" /* SGI's Extent Filesystem */
|
||||
#define MOUNT_ZFS "zfs" /* Sun ZFS */
|
||||
#define MOUNT_NILFS "nilfs" /* NTT's NiLFS(2) logging file system */
|
||||
#define MOUNT_RUMPFS "rumpfs" /* rump virtual file system */
|
||||
#define MOUNT_V7FS "v7fs" /* 7th Edition of Unix Filesystem */
|
||||
|
||||
#ifndef _STANDALONE
|
||||
|
||||
struct vnode;
|
||||
|
||||
/*
|
||||
* Structure per mounted file system. Each mounted file system has an
|
||||
* array of operations and an instance record. The file systems are
|
||||
* put on a doubly linked list.
|
||||
*/
|
||||
struct mount {
|
||||
CIRCLEQ_ENTRY(mount) mnt_list; /* mount list */
|
||||
TAILQ_HEAD(, vnode) mnt_vnodelist; /* list of vnodes this mount */
|
||||
struct vfsops *mnt_op; /* operations on fs */
|
||||
struct vnode *mnt_vnodecovered; /* vnode we mounted on */
|
||||
struct vnode *mnt_syncer; /* syncer vnode */
|
||||
void *mnt_transinfo; /* for FS-internal use */
|
||||
void *mnt_data; /* private data */
|
||||
krwlock_t mnt_unmounting; /* to prevent new activity */
|
||||
kmutex_t mnt_renamelock; /* per-fs rename lock */
|
||||
int mnt_refcnt; /* ref count on this structure */
|
||||
int mnt_recursecnt; /* count of write locks */
|
||||
int mnt_flag; /* flags */
|
||||
int mnt_iflag; /* internal flags */
|
||||
int mnt_fs_bshift; /* offset shift for lblkno */
|
||||
int mnt_dev_bshift; /* shift for device sectors */
|
||||
struct statvfs mnt_stat; /* cache of filesystem stats */
|
||||
specificdata_reference
|
||||
mnt_specdataref; /* subsystem specific data */
|
||||
kmutex_t mnt_updating; /* to serialize updates */
|
||||
struct wapbl_ops
|
||||
*mnt_wapbl_op; /* logging ops */
|
||||
struct wapbl *mnt_wapbl; /* log info */
|
||||
struct wapbl_replay
|
||||
*mnt_wapbl_replay; /* replay support XXX: what? */
|
||||
uint64_t mnt_gen;
|
||||
};
|
||||
|
||||
/*
|
||||
* Sysctl CTL_VFS definitions.
|
||||
*
|
||||
* Second level identifier specifies which filesystem. Second level
|
||||
* identifier VFS_GENERIC returns information about all filesystems.
|
||||
*
|
||||
* Note the slightly non-flat nature of these sysctl numbers. Oh for
|
||||
* a better sysctl interface.
|
||||
*/
|
||||
#define VFS_GENERIC 0 /* generic filesystem information */
|
||||
#define VFS_MAXTYPENUM 1 /* int: highest defined fs type */
|
||||
#define VFS_CONF 2 /* struct: vfsconf for filesystem given
|
||||
as next argument */
|
||||
#define VFS_USERMOUNT 3 /* enable/disable fs mnt by non-root */
|
||||
#define VFS_MAGICLINKS 4 /* expand 'magic' symlinks */
|
||||
#define VFSGEN_MAXID 5 /* number of valid vfs.generic ids */
|
||||
|
||||
/*
|
||||
* USE THE SAME NAMES AS MOUNT_*!
|
||||
*
|
||||
* Only need to add new entry here if the filesystem actually supports
|
||||
* sysctl(2).
|
||||
*/
|
||||
#define CTL_VFS_NAMES { \
|
||||
{ "generic", CTLTYPE_NODE }, \
|
||||
{ MOUNT_FFS, CTLTYPE_NODE }, \
|
||||
{ MOUNT_NFS, CTLTYPE_NODE }, \
|
||||
{ MOUNT_MFS, CTLTYPE_NODE }, \
|
||||
{ MOUNT_MSDOS, CTLTYPE_NODE }, \
|
||||
{ MOUNT_LFS, CTLTYPE_NODE }, \
|
||||
{ 0, 0 }, /* MOUNT_LOFS */ \
|
||||
{ MOUNT_FDESC, CTLTYPE_NODE }, \
|
||||
{ MOUNT_NULL, CTLTYPE_NODE }, \
|
||||
{ MOUNT_UMAP, CTLTYPE_NODE }, \
|
||||
{ MOUNT_KERNFS, CTLTYPE_NODE }, \
|
||||
{ MOUNT_PROCFS, CTLTYPE_NODE }, \
|
||||
{ MOUNT_AFS, CTLTYPE_NODE }, \
|
||||
{ MOUNT_CD9660, CTLTYPE_NODE }, \
|
||||
{ MOUNT_UNION, CTLTYPE_NODE }, \
|
||||
{ MOUNT_ADOSFS, CTLTYPE_NODE }, \
|
||||
{ MOUNT_EXT2FS, CTLTYPE_NODE }, \
|
||||
{ MOUNT_CODA, CTLTYPE_NODE }, \
|
||||
{ MOUNT_FILECORE, CTLTYPE_NODE }, \
|
||||
{ MOUNT_NTFS, CTLTYPE_NODE }, \
|
||||
}
|
||||
|
||||
#define VFS_MAXID 20 /* number of valid vfs ids */
|
||||
|
||||
#define CTL_VFSGENCTL_NAMES { \
|
||||
{ 0, 0 }, \
|
||||
{ "maxtypenum", CTLTYPE_INT }, \
|
||||
{ "conf", CTLTYPE_NODE }, /* Special */ \
|
||||
{ "usermount", CTLTYPE_INT }, \
|
||||
{ "magiclinks", CTLTYPE_INT }, \
|
||||
}
|
||||
|
||||
#if defined(_KERNEL)
|
||||
#include <prop/proplib.h>
|
||||
#if __STDC__
|
||||
struct nameidata;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Operations supported on mounted file system.
|
||||
*/
|
||||
|
||||
struct vfsops {
|
||||
const char *vfs_name;
|
||||
size_t vfs_min_mount_data;
|
||||
int (*vfs_mount) (struct mount *, const char *, void *,
|
||||
size_t *);
|
||||
int (*vfs_start) (struct mount *, int);
|
||||
int (*vfs_unmount) (struct mount *, int);
|
||||
int (*vfs_root) (struct mount *, struct vnode **);
|
||||
int (*vfs_quotactl) (struct mount *, prop_dictionary_t);
|
||||
int (*vfs_statvfs) (struct mount *, struct statvfs *);
|
||||
int (*vfs_sync) (struct mount *, int, struct kauth_cred *);
|
||||
int (*vfs_vget) (struct mount *, ino_t, struct vnode **);
|
||||
int (*vfs_fhtovp) (struct mount *, struct fid *,
|
||||
struct vnode **);
|
||||
int (*vfs_vptofh) (struct vnode *, struct fid *, size_t *);
|
||||
void (*vfs_init) (void);
|
||||
void (*vfs_reinit) (void);
|
||||
void (*vfs_done) (void);
|
||||
int (*vfs_mountroot)(void);
|
||||
int (*vfs_snapshot) (struct mount *, struct vnode *,
|
||||
struct timespec *);
|
||||
int (*vfs_extattrctl) (struct mount *, int,
|
||||
struct vnode *, int, const char *);
|
||||
int (*vfs_suspendctl) (struct mount *, int);
|
||||
int (*vfs_renamelock_enter)(struct mount *);
|
||||
void (*vfs_renamelock_exit)(struct mount *);
|
||||
int (*vfs_fsync) (struct vnode *, int);
|
||||
const struct vnodeopv_desc * const *vfs_opv_descs;
|
||||
int vfs_refcount;
|
||||
LIST_ENTRY(vfsops) vfs_list;
|
||||
};
|
||||
|
||||
/* XXX vget is actually file system internal. */
|
||||
#define VFS_VGET(MP, INO, VPP) (*(MP)->mnt_op->vfs_vget)(MP, INO, VPP)
|
||||
|
||||
#define VFS_RENAMELOCK_ENTER(MP) (*(MP)->mnt_op->vfs_renamelock_enter)(MP)
|
||||
#define VFS_RENAMELOCK_EXIT(MP) (*(MP)->mnt_op->vfs_renamelock_exit)(MP)
|
||||
#define VFS_FSYNC(MP, VP, FLG) (*(MP)->mnt_op->vfs_fsync)(VP, FLG)
|
||||
|
||||
int VFS_MOUNT(struct mount *, const char *, void *, size_t *);
|
||||
int VFS_START(struct mount *, int);
|
||||
int VFS_UNMOUNT(struct mount *, int);
|
||||
int VFS_ROOT(struct mount *, struct vnode **);
|
||||
int VFS_QUOTACTL(struct mount *, prop_dictionary_t);
|
||||
int VFS_STATVFS(struct mount *, struct statvfs *);
|
||||
int VFS_SYNC(struct mount *, int, struct kauth_cred *);
|
||||
int VFS_FHTOVP(struct mount *, struct fid *, struct vnode **);
|
||||
int VFS_VPTOFH(struct vnode *, struct fid *, size_t *);
|
||||
int VFS_SNAPSHOT(struct mount *, struct vnode *, struct timespec *);
|
||||
int VFS_EXTATTRCTL(struct mount *, int, struct vnode *, int, const char *);
|
||||
int VFS_SUSPENDCTL(struct mount *, int);
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#ifdef _KERNEL
|
||||
#if __STDC__
|
||||
struct mbuf;
|
||||
struct vnodeopv_desc;
|
||||
struct kauth_cred;
|
||||
#endif
|
||||
|
||||
#define VFS_MAX_MOUNT_DATA 8192
|
||||
|
||||
#define VFS_PROTOS(fsname) \
|
||||
int fsname##_mount(struct mount *, const char *, void *, \
|
||||
size_t *); \
|
||||
int fsname##_start(struct mount *, int); \
|
||||
int fsname##_unmount(struct mount *, int); \
|
||||
int fsname##_root(struct mount *, struct vnode **); \
|
||||
int fsname##_quotactl(struct mount *, prop_dictionary_t); \
|
||||
int fsname##_statvfs(struct mount *, struct statvfs *); \
|
||||
int fsname##_sync(struct mount *, int, struct kauth_cred *); \
|
||||
int fsname##_vget(struct mount *, ino_t, struct vnode **); \
|
||||
int fsname##_fhtovp(struct mount *, struct fid *, struct vnode **); \
|
||||
int fsname##_vptofh(struct vnode *, struct fid *, size_t *); \
|
||||
void fsname##_init(void); \
|
||||
void fsname##_reinit(void); \
|
||||
void fsname##_done(void); \
|
||||
int fsname##_mountroot(void); \
|
||||
int fsname##_snapshot(struct mount *, struct vnode *, \
|
||||
struct timespec *); \
|
||||
int fsname##_extattrctl(struct mount *, int, struct vnode *, int, \
|
||||
const char *); \
|
||||
int fsname##_suspendctl(struct mount *, int)
|
||||
|
||||
/*
|
||||
* This operations vector is so wapbl can be wrapped into a filesystem lkm.
|
||||
* XXX Eventually, we want to move this functionality
|
||||
* down into the filesystems themselves so that this isn't needed.
|
||||
*/
|
||||
struct wapbl_ops {
|
||||
void (*wo_wapbl_discard)(struct wapbl *);
|
||||
int (*wo_wapbl_replay_isopen)(struct wapbl_replay *);
|
||||
int (*wo_wapbl_replay_can_read)(struct wapbl_replay *, daddr_t, long);
|
||||
int (*wo_wapbl_replay_read)(struct wapbl_replay *, void *, daddr_t, long);
|
||||
void (*wo_wapbl_add_buf)(struct wapbl *, struct buf *);
|
||||
void (*wo_wapbl_remove_buf)(struct wapbl *, struct buf *);
|
||||
void (*wo_wapbl_resize_buf)(struct wapbl *, struct buf *, long, long);
|
||||
int (*wo_wapbl_begin)(struct wapbl *, const char *, int);
|
||||
void (*wo_wapbl_end)(struct wapbl *);
|
||||
void (*wo_wapbl_junlock_assert)(struct wapbl *);
|
||||
void (*wo_wapbl_biodone)(struct buf *);
|
||||
};
|
||||
#define WAPBL_DISCARD(MP) \
|
||||
(*(MP)->mnt_wapbl_op->wo_wapbl_discard)((MP)->mnt_wapbl)
|
||||
#define WAPBL_REPLAY_ISOPEN(MP) \
|
||||
(*(MP)->mnt_wapbl_op->wo_wapbl_replay_isopen)((MP)->mnt_wapbl_replay)
|
||||
#define WAPBL_REPLAY_CAN_READ(MP, BLK, LEN) \
|
||||
(*(MP)->mnt_wapbl_op->wo_wapbl_replay_can_read)((MP)->mnt_wapbl_replay, \
|
||||
(BLK), (LEN))
|
||||
#define WAPBL_REPLAY_READ(MP, DATA, BLK, LEN) \
|
||||
(*(MP)->mnt_wapbl_op->wo_wapbl_replay_read)((MP)->mnt_wapbl_replay, \
|
||||
(DATA), (BLK), (LEN))
|
||||
#define WAPBL_ADD_BUF(MP, BP) \
|
||||
(*(MP)->mnt_wapbl_op->wo_wapbl_add_buf)((MP)->mnt_wapbl, (BP))
|
||||
#define WAPBL_REMOVE_BUF(MP, BP) \
|
||||
(*(MP)->mnt_wapbl_op->wo_wapbl_remove_buf)((MP)->mnt_wapbl, (BP))
|
||||
#define WAPBL_RESIZE_BUF(MP, BP, OLDSZ, OLDCNT) \
|
||||
(*(MP)->mnt_wapbl_op->wo_wapbl_resize_buf)((MP)->mnt_wapbl, (BP), \
|
||||
(OLDSZ), (OLDCNT))
|
||||
#define WAPBL_BEGIN(MP) \
|
||||
(*(MP)->mnt_wapbl_op->wo_wapbl_begin)((MP)->mnt_wapbl, \
|
||||
__FILE__, __LINE__)
|
||||
#define WAPBL_END(MP) \
|
||||
(*(MP)->mnt_wapbl_op->wo_wapbl_end)((MP)->mnt_wapbl)
|
||||
#define WAPBL_JUNLOCK_ASSERT(MP) \
|
||||
(*(MP)->mnt_wapbl_op->wo_wapbl_junlock_assert)((MP)->mnt_wapbl)
|
||||
|
||||
struct vfs_hooks {
|
||||
LIST_ENTRY(vfs_hooks) vfs_hooks_list;
|
||||
void (*vh_unmount)(struct mount *);
|
||||
int (*vh_reexport)(struct mount *, const char *, void *);
|
||||
void (*vh_future_expansion_1)(void);
|
||||
void (*vh_future_expansion_2)(void);
|
||||
void (*vh_future_expansion_3)(void);
|
||||
void (*vh_future_expansion_4)(void);
|
||||
void (*vh_future_expansion_5)(void);
|
||||
};
|
||||
|
||||
void vfs_hooks_init(void);
|
||||
int vfs_hooks_attach(struct vfs_hooks *);
|
||||
int vfs_hooks_detach(struct vfs_hooks *);
|
||||
void vfs_hooks_unmount(struct mount *);
|
||||
int vfs_hooks_reexport(struct mount *, const char *, void *);
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
/*
|
||||
* Export arguments for local filesystem mount calls.
|
||||
*
|
||||
* This structure is deprecated and is only provided for compatibility
|
||||
* reasons with old binary utilities; several file systems expose an
|
||||
* instance of this structure in their mount arguments structure, thus
|
||||
* needing a padding in place of the old values. This definition cannot
|
||||
* change in the future due to this reason.
|
||||
* XXX: This should be moved to the compat subtree but cannot be done
|
||||
* until we can move the mount args structures themselves.
|
||||
*
|
||||
* The current export_args structure can be found in nfs/nfs.h.
|
||||
*/
|
||||
struct export_args30 {
|
||||
int ex_flags; /* export related flags */
|
||||
uid_t ex_root; /* mapping for root uid */
|
||||
struct uucred ex_anon; /* mapping for anonymous user */
|
||||
struct sockaddr *ex_addr; /* net address to which exported */
|
||||
int ex_addrlen; /* and the net address length */
|
||||
struct sockaddr *ex_mask; /* mask of valid bits in saddr */
|
||||
int ex_masklen; /* and the smask length */
|
||||
char *ex_indexfile; /* index file for WebNFS URLs */
|
||||
};
|
||||
|
||||
struct mnt_export_args30 {
|
||||
const char *fspec; /* Always NULL */
|
||||
struct export_args30 eargs;
|
||||
};
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
/*
|
||||
* exported VFS interface (see vfssubr(9))
|
||||
*/
|
||||
struct mount *vfs_getvfs(fsid_t *); /* return vfs given fsid */
|
||||
int vfs_composefh(struct vnode *, fhandle_t *, size_t *);
|
||||
int vfs_composefh_alloc(struct vnode *, fhandle_t **);
|
||||
void vfs_composefh_free(fhandle_t *);
|
||||
int vfs_fhtovp(fhandle_t *, struct vnode **);
|
||||
int vfs_mountedon(struct vnode *);/* is a vfs mounted on vp */
|
||||
int vfs_mountroot(void);
|
||||
void vfs_shutdown(void); /* unmount and sync file systems */
|
||||
void vfs_sync_all(struct lwp *);
|
||||
bool vfs_unmountall(struct lwp *); /* unmount file systems */
|
||||
bool vfs_unmountall1(struct lwp *, bool, bool);
|
||||
bool vfs_unmount_forceone(struct lwp *);
|
||||
int vfs_busy(struct mount *, struct mount **);
|
||||
int vfs_rootmountalloc(const char *, const char *, struct mount **);
|
||||
void vfs_unbusy(struct mount *, bool, struct mount **);
|
||||
int vfs_attach(struct vfsops *);
|
||||
int vfs_detach(struct vfsops *);
|
||||
void vfs_reinit(void);
|
||||
struct vfsops *vfs_getopsbyname(const char *);
|
||||
void vfs_delref(struct vfsops *);
|
||||
void vfs_destroy(struct mount *);
|
||||
void vfs_scrubvnlist(struct mount *);
|
||||
struct mount *vfs_mountalloc(struct vfsops *, struct vnode *);
|
||||
int vfs_stdextattrctl(struct mount *, int, struct vnode *,
|
||||
int, const char *);
|
||||
void vfs_insmntque(struct vnode *, struct mount *);
|
||||
|
||||
extern CIRCLEQ_HEAD(mntlist, mount) mountlist; /* mounted filesystem list */
|
||||
extern struct vfsops *vfssw[]; /* filesystem type table */
|
||||
extern int nvfssw;
|
||||
extern kmutex_t mountlist_lock;
|
||||
extern kmutex_t vfs_list_lock;
|
||||
|
||||
void vfs_mount_sysinit(void);
|
||||
long makefstype(const char *);
|
||||
int mount_domount(struct lwp *, struct vnode **, struct vfsops *,
|
||||
const char *, int, void *, size_t *);
|
||||
int dounmount(struct mount *, int, struct lwp *);
|
||||
int do_sys_mount(struct lwp *, struct vfsops *, const char *, const char *,
|
||||
int, void *, enum uio_seg, size_t, register_t *);
|
||||
void vfsinit(void);
|
||||
void vfs_opv_init(const struct vnodeopv_desc * const *);
|
||||
void vfs_opv_free(const struct vnodeopv_desc * const *);
|
||||
#ifdef DEBUG
|
||||
void vfs_bufstats(void);
|
||||
#endif
|
||||
|
||||
int mount_specific_key_create(specificdata_key_t *, specificdata_dtor_t);
|
||||
void mount_specific_key_delete(specificdata_key_t);
|
||||
void mount_initspecific(struct mount *);
|
||||
void mount_finispecific(struct mount *);
|
||||
void * mount_getspecific(struct mount *, specificdata_key_t);
|
||||
void mount_setspecific(struct mount *, specificdata_key_t, void *);
|
||||
|
||||
int usermount_common_policy(struct mount *, u_long);
|
||||
|
||||
LIST_HEAD(vfs_list_head, vfsops);
|
||||
extern struct vfs_list_head vfs_list;
|
||||
|
||||
#else /* _KERNEL */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
#if !defined(__LIBC12_SOURCE__) && !defined(_STANDALONE)
|
||||
int getfh(const char *, void *, size_t *)
|
||||
__RENAME(__getfh30);
|
||||
#endif
|
||||
|
||||
int unmount(const char *, int);
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
#ifndef __LIBC12_SOURCE__
|
||||
int mount(const char *, const char *, int, void *, size_t) __RENAME(__mount50);
|
||||
int fhopen(const void *, size_t, int) __RENAME(__fhopen40);
|
||||
int fhstat(const void *, size_t, struct stat *) __RENAME(__fhstat50);
|
||||
#endif
|
||||
#endif /* _NETBSD_SOURCE */
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _KERNEL */
|
||||
#endif /* !_STANDALONE */
|
||||
|
||||
#endif /* !_SYS_MOUNT_H_ */
|
||||
216
sys/sys/mutex.h
Normal file
216
sys/sys/mutex.h
Normal file
@@ -0,0 +1,216 @@
|
||||
/* $NetBSD: mutex.h,v 1.20 2010/02/08 09:54:27 skrll Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe and Andrew Doran.
|
||||
*
|
||||
* 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 NETBSD FOUNDATION, INC. 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 FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_MUTEX_H_
|
||||
#define _SYS_MUTEX_H_
|
||||
|
||||
/*
|
||||
* There are 2 types of mutexes:
|
||||
*
|
||||
* * Adaptive -- If the lock is already held, the thread attempting
|
||||
* to acquire the lock determines if the thread that holds it is
|
||||
* currently running. If so, it spins, else it sleeps.
|
||||
*
|
||||
* * Spin -- If the lock is already held, the thread attempting to
|
||||
* acquire the lock spins. The IPL will be raised on entry.
|
||||
*
|
||||
* Machine dependent code must provide the following:
|
||||
*
|
||||
* struct mutex
|
||||
* The actual mutex structure. This structure is mostly
|
||||
* opaque to machine-independent code; most access are done
|
||||
* through macros. However, machine-independent code must
|
||||
* be able to access the following members:
|
||||
*
|
||||
* uintptr_t mtx_owner
|
||||
* ipl_cookie_t mtx_ipl
|
||||
* __cpu_simple_lock_t mtx_lock
|
||||
*
|
||||
* If an architecture can be considered 'simple' (no interlock required in
|
||||
* the MP case, or no MP) it need only define __HAVE_SIMPLE_MUTEXES and
|
||||
* provide the following:
|
||||
*
|
||||
* struct mutex
|
||||
*
|
||||
* [additionally:]
|
||||
* volatile integer mtx_id
|
||||
*
|
||||
* MUTEX_RECEIVE(mtx)
|
||||
* Post a load fence after acquiring the mutex, if necessary.
|
||||
*
|
||||
* MUTEX_GIVE(mtx)
|
||||
* Post a load/store fence after releasing the mutex, if
|
||||
* necessary.
|
||||
*
|
||||
* MUTEX_CAS(ptr, old, new)
|
||||
* Perform an atomic "compare and swap" operation and
|
||||
* evaluate to true or false according to the success
|
||||
*
|
||||
* Otherwise, the following must be defined:
|
||||
*
|
||||
* MUTEX_INITIALIZE_SPIN(mtx, dodebug, minipl)
|
||||
* Initialize a spin mutex.
|
||||
*
|
||||
* MUTEX_INITIALIZE_ADAPTIVE(mtx, dodebug)
|
||||
* Initialize an adaptive mutex.
|
||||
*
|
||||
* MUTEX_DESTROY(mtx)
|
||||
* Tear down a mutex.
|
||||
*
|
||||
* MUTEX_ADAPTIVE_P(mtx)
|
||||
* Evaluates to true if the mutex is an adaptive mutex.
|
||||
*
|
||||
* MUTEX_SPIN_P(mtx)
|
||||
* Evaluates to true if the mutex is a spin mutex.
|
||||
*
|
||||
* MUTEX_OWNER(owner)
|
||||
* Returns the owner of the adaptive mutex (LWP address).
|
||||
*
|
||||
* MUTEX_OWNED(owner)
|
||||
* Returns non-zero if an adaptive mutex is currently
|
||||
* held by an LWP.
|
||||
*
|
||||
* MUTEX_HAS_WAITERS(mtx)
|
||||
* Returns true if the mutex has waiters.
|
||||
*
|
||||
* MUTEX_SET_WAITERS(mtx)
|
||||
* Mark the mutex has having waiters.
|
||||
*
|
||||
* MUTEX_ACQUIRE(mtx, owner)
|
||||
* Try to acquire an adaptive mutex such that:
|
||||
* if (lock held OR waiters)
|
||||
* return 0;
|
||||
* else
|
||||
* return 1;
|
||||
* Must be MP/interrupt atomic.
|
||||
*
|
||||
* MUTEX_RELEASE(mtx)
|
||||
* Release the lock and clear the "has waiters" indication.
|
||||
* Must be interrupt atomic, need not be MP safe.
|
||||
*
|
||||
* MUTEX_DEBUG_P(mtx)
|
||||
* Evaluates to true if the mutex is initialized with
|
||||
* dodebug==true. Only used in the LOCKDEBUG case.
|
||||
*
|
||||
* Machine dependent code may optionally provide stubs for the following
|
||||
* functions to implement the easy (unlocked / no waiters) cases. If
|
||||
* these stubs are provided, __HAVE_MUTEX_STUBS should be defined.
|
||||
*
|
||||
* mutex_enter()
|
||||
* mutex_exit()
|
||||
*
|
||||
* Two additional stubs may be implemented that handle only the spinlock
|
||||
* case, primarily for the scheduler. __HAVE_SPIN_MUTEX_STUBS should be
|
||||
* defined if these are provided:
|
||||
*
|
||||
* mutex_spin_enter()
|
||||
* mutex_spin_exit()
|
||||
*/
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_lockdebug.h"
|
||||
#endif
|
||||
|
||||
#if !defined(_KERNEL)
|
||||
#include <sys/types.h>
|
||||
#include <sys/inttypes.h>
|
||||
#endif
|
||||
|
||||
typedef enum kmutex_type_t {
|
||||
MUTEX_SPIN = 0, /* To get a spin mutex at IPL_NONE */
|
||||
MUTEX_ADAPTIVE = 1, /* For porting code written for Solaris */
|
||||
MUTEX_DEFAULT = 2, /* The only native, endorsed type */
|
||||
MUTEX_DRIVER = 3, /* For porting code written for Solaris */
|
||||
MUTEX_NODEBUG = 4 /* Disables LOCKDEBUG; use with care */
|
||||
} kmutex_type_t;
|
||||
|
||||
typedef struct kmutex kmutex_t;
|
||||
|
||||
#if defined(__MUTEX_PRIVATE)
|
||||
|
||||
#define MUTEX_THREAD ((uintptr_t)-16L)
|
||||
|
||||
#define MUTEX_BIT_SPIN 0x01
|
||||
#define MUTEX_BIT_WAITERS 0x02
|
||||
|
||||
#if defined(LOCKDEBUG)
|
||||
#define MUTEX_BIT_NODEBUG 0x04 /* LOCKDEBUG disabled */
|
||||
#else
|
||||
#define MUTEX_BIT_NODEBUG 0x00 /* do nothing */
|
||||
#endif /* LOCKDEBUG */
|
||||
|
||||
#define MUTEX_SPIN_IPL(mtx) ((mtx)->mtx_ipl)
|
||||
#define MUTEX_SPIN_OLDSPL(ci) ((ci)->ci_mtx_oldspl)
|
||||
|
||||
void mutex_vector_enter(kmutex_t *);
|
||||
void mutex_vector_exit(kmutex_t *);
|
||||
void mutex_spin_retry(kmutex_t *);
|
||||
void mutex_wakeup(kmutex_t *);
|
||||
|
||||
#endif /* __MUTEX_PRIVATE */
|
||||
|
||||
#ifdef _KERNEL
|
||||
#include <sys/intr.h>
|
||||
#endif
|
||||
|
||||
#include <machine/mutex.h>
|
||||
|
||||
/*
|
||||
* Return true if no spin mutexes are held by the current CPU.
|
||||
*/
|
||||
#ifndef MUTEX_NO_SPIN_ACTIVE_P
|
||||
#define MUTEX_NO_SPIN_ACTIVE_P(ci) ((ci)->ci_mtx_count == 0)
|
||||
#endif
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
void mutex_init(kmutex_t *, kmutex_type_t, int);
|
||||
void mutex_destroy(kmutex_t *);
|
||||
|
||||
void mutex_enter(kmutex_t *);
|
||||
void mutex_exit(kmutex_t *);
|
||||
|
||||
void mutex_spin_enter(kmutex_t *);
|
||||
void mutex_spin_exit(kmutex_t *);
|
||||
|
||||
int mutex_tryenter(kmutex_t *);
|
||||
|
||||
int mutex_owned(kmutex_t *);
|
||||
lwp_t *mutex_owner(kmutex_t *);
|
||||
|
||||
void mutex_obj_init(void);
|
||||
kmutex_t *mutex_obj_alloc(kmutex_type_t, int);
|
||||
void mutex_obj_hold(kmutex_t *);
|
||||
bool mutex_obj_free(kmutex_t *);
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* _SYS_MUTEX_H_ */
|
||||
124
sys/sys/reboot.h
Normal file
124
sys/sys/reboot.h
Normal file
@@ -0,0 +1,124 @@
|
||||
/* $NetBSD: reboot.h,v 1.25 2007/12/25 18:33:48 perry Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1988, 1993, 1994
|
||||
* 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.
|
||||
*
|
||||
* @(#)reboot.h 8.3 (Berkeley) 12/13/94
|
||||
*/
|
||||
|
||||
#ifndef _SYS_REBOOT_H_
|
||||
#define _SYS_REBOOT_H_
|
||||
|
||||
/*
|
||||
* Arguments to reboot system call. These are passed to the boot program,
|
||||
* and then on to init.
|
||||
*/
|
||||
#define RB_AUTOBOOT 0 /* flags for system auto-booting itself */
|
||||
|
||||
#define RB_ASKNAME 0x00000001 /* ask for file name to reboot from */
|
||||
#define RB_SINGLE 0x00000002 /* reboot to single user only */
|
||||
#define RB_NOSYNC 0x00000004 /* dont sync before reboot */
|
||||
#define RB_HALT 0x00000008 /* don't reboot, just halt */
|
||||
#define RB_INITNAME 0x00000010 /* name given for /etc/init (unused) */
|
||||
#define __RB_UNUSED1 0x00000020 /* was RB_DFLTROOT, obsolete */
|
||||
#define RB_KDB 0x00000040 /* give control to kernel debugger */
|
||||
#define RB_RDONLY 0x00000080 /* mount root fs read-only */
|
||||
#define RB_DUMP 0x00000100 /* dump kernel memory before reboot */
|
||||
#define RB_MINIROOT 0x00000200 /* mini-root present in memory */
|
||||
#define RB_STRING 0x00000400 /* use provided bootstr */
|
||||
#define RB_POWERDOWN (RB_HALT|0x800) /* turn power off (or at least halt) */
|
||||
#define RB_USERCONF 0x00001000 /* change configured devices */
|
||||
|
||||
/*
|
||||
* Extra autoboot flags (passed by boot prog to kernel). See also
|
||||
* macros bootverbose, bootquiet in <sys/systm.h>.
|
||||
*/
|
||||
#define AB_NORMAL 0x00000000 /* boot normally (default) */
|
||||
#define AB_QUIET 0x00010000 /* boot quietly */
|
||||
#define AB_VERBOSE 0x00020000 /* boot verbosely */
|
||||
#define AB_SILENT 0x00040000 /* boot silently */
|
||||
#define AB_DEBUG 0x00080000 /* boot with debug messages */
|
||||
|
||||
/*
|
||||
* The top 4 bits are architecture specific and are used to
|
||||
* pass information between the bootblocks and the machine
|
||||
* initialization code.
|
||||
*/
|
||||
#define RB_MD1 0x10000000
|
||||
#define RB_MD2 0x20000000
|
||||
#define RB_MD3 0x40000000
|
||||
#define RB_MD4 0x80000000
|
||||
|
||||
/*
|
||||
* Constants for converting boot-style device number to type,
|
||||
* adaptor (uba, mba, etc), unit number and partition number.
|
||||
* Type (== major device number) is in the low byte
|
||||
* for backward compatibility. Except for that of the "magic
|
||||
* number", each mask applies to the shifted value.
|
||||
* Format:
|
||||
* (4) (4) (4) (4) (8) (8)
|
||||
* --------------------------------
|
||||
* |MA | AD| CT| UN| PART | TYPE |
|
||||
* --------------------------------
|
||||
*/
|
||||
#define B_ADAPTORSHIFT 24
|
||||
#define B_ADAPTORMASK 0x0f
|
||||
#define B_ADAPTOR(val) (((val) >> B_ADAPTORSHIFT) & B_ADAPTORMASK)
|
||||
#define B_CONTROLLERSHIFT 20
|
||||
#define B_CONTROLLERMASK 0xf
|
||||
#define B_CONTROLLER(val) (((val)>>B_CONTROLLERSHIFT) & B_CONTROLLERMASK)
|
||||
#define B_UNITSHIFT 16
|
||||
#define B_UNITMASK 0xf
|
||||
#define B_UNIT(val) (((val) >> B_UNITSHIFT) & B_UNITMASK)
|
||||
#define B_PARTITIONSHIFT 8
|
||||
#define B_PARTITIONMASK 0xff
|
||||
#define B_PARTITION(val) (((val) >> B_PARTITIONSHIFT) & B_PARTITIONMASK)
|
||||
#define B_TYPESHIFT 0
|
||||
#define B_TYPEMASK 0xff
|
||||
#define B_TYPE(val) (((val) >> B_TYPESHIFT) & B_TYPEMASK)
|
||||
|
||||
#define B_MAGICMASK 0xf0000000
|
||||
#define B_DEVMAGIC 0xa0000000
|
||||
|
||||
#define MAKEBOOTDEV(type, adaptor, controller, unit, partition) \
|
||||
(((type) << B_TYPESHIFT) | ((adaptor) << B_ADAPTORSHIFT) | \
|
||||
((controller) << B_CONTROLLERSHIFT) | ((unit) << B_UNITSHIFT) | \
|
||||
((partition) << B_PARTITIONSHIFT) | B_DEVMAGIC)
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
void cpu_reboot(int, char *)
|
||||
__dead;
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* !_SYS_REBOOT_H_ */
|
||||
121
sys/sys/rwlock.h
Normal file
121
sys/sys/rwlock.h
Normal file
@@ -0,0 +1,121 @@
|
||||
/* $NetBSD: rwlock.h,v 1.10 2010/02/08 09:54:27 skrll Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002, 2006, 2007, 2008 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe and Andrew Doran.
|
||||
*
|
||||
* 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 NETBSD FOUNDATION, INC. 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 FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_RWLOCK_H_
|
||||
#define _SYS_RWLOCK_H_
|
||||
|
||||
/*
|
||||
* The rwlock provides exclusive access when held as a "writer",
|
||||
* and shared access when held as a "reader".
|
||||
*
|
||||
* Architectures may optionally provide stubs for the following functions to
|
||||
* implement the easy (unlocked, no waiters) cases. If these stubs are
|
||||
* provided, __HAVE_RW_STUBS should be defined.
|
||||
*
|
||||
* rw_enter()
|
||||
* rw_exit()
|
||||
* rw_tryenter()
|
||||
*/
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_lockdebug.h"
|
||||
#endif
|
||||
|
||||
#if !defined(_KERNEL)
|
||||
#include <sys/types.h>
|
||||
#include <sys/inttypes.h>
|
||||
#endif
|
||||
|
||||
typedef enum krw_t {
|
||||
RW_READER = 0,
|
||||
RW_WRITER = 1
|
||||
} krw_t;
|
||||
|
||||
typedef struct krwlock krwlock_t;
|
||||
|
||||
#ifdef __RWLOCK_PRIVATE
|
||||
/*
|
||||
* Bits in the owner field of the lock that indicate lock state. If the
|
||||
* WRITE_LOCKED bit is clear, then the owner field is actually a count of
|
||||
* the number of readers. The rw_owner field is laid out like so:
|
||||
*
|
||||
* N 4 3 2 1 0
|
||||
* +---------------------------------------------------------+
|
||||
* | owner or read count | nodbug | wrlock | wrwant | wait |
|
||||
* +---------------------------------------------------------+
|
||||
*/
|
||||
#define RW_HAS_WAITERS 0x01UL /* lock has waiters */
|
||||
#define RW_WRITE_WANTED 0x02UL /* >= 1 waiter is a writer */
|
||||
#define RW_WRITE_LOCKED 0x04UL /* lock is currently write locked */
|
||||
#if defined(LOCKDEBUG)
|
||||
#define RW_NODEBUG 0x08UL /* LOCKDEBUG disabled */
|
||||
#else
|
||||
#define RW_NODEBUG 0x00UL /* do nothing */
|
||||
#endif /* LOCKDEBUG */
|
||||
|
||||
#define RW_READ_COUNT_SHIFT 4
|
||||
#define RW_READ_INCR (1UL << RW_READ_COUNT_SHIFT)
|
||||
#define RW_THREAD ((uintptr_t)-RW_READ_INCR)
|
||||
#define RW_OWNER(rw) ((rw)->rw_owner & RW_THREAD)
|
||||
#define RW_COUNT(rw) ((rw)->rw_owner & RW_THREAD)
|
||||
#define RW_FLAGS(rw) ((rw)->rw_owner & ~RW_THREAD)
|
||||
|
||||
void rw_vector_enter(krwlock_t *, const krw_t);
|
||||
void rw_vector_exit(krwlock_t *);
|
||||
int rw_vector_tryenter(krwlock_t *, const krw_t);
|
||||
#endif /* __RWLOCK_PRIVATE */
|
||||
|
||||
#include <machine/rwlock.h>
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
void rw_init(krwlock_t *);
|
||||
void rw_destroy(krwlock_t *);
|
||||
|
||||
int rw_tryenter(krwlock_t *, const krw_t);
|
||||
int rw_tryupgrade(krwlock_t *);
|
||||
void rw_downgrade(krwlock_t *);
|
||||
|
||||
int rw_read_held(krwlock_t *);
|
||||
int rw_write_held(krwlock_t *);
|
||||
int rw_lock_held(krwlock_t *);
|
||||
|
||||
void rw_enter(krwlock_t *, const krw_t);
|
||||
void rw_exit(krwlock_t *);
|
||||
|
||||
void rw_obj_init(void);
|
||||
krwlock_t *rw_obj_alloc(void);
|
||||
void rw_obj_hold(krwlock_t *);
|
||||
bool rw_obj_free(krwlock_t *);
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* _SYS_RWLOCK_H_ */
|
||||
196
sys/sys/stat.h
Normal file
196
sys/sys/stat.h
Normal file
@@ -0,0 +1,196 @@
|
||||
#ifndef _SYS_STAT_H_
|
||||
#define _SYS_STAT_H_
|
||||
|
||||
#include <sys/featuretest.h>
|
||||
#include <sys/types.h> /* XXX */
|
||||
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
|
||||
struct stat {
|
||||
big_dev_t st_dev; /* inode's device */
|
||||
big_mode_t st_mode; /* inode protection mode */
|
||||
big_ino_t st_ino; /* inode's number */
|
||||
big_nlink_t st_nlink; /* number of hard links */
|
||||
big_uid_t st_uid; /* user ID of the file's owner */
|
||||
big_gid_t st_gid; /* group ID of the file's group */
|
||||
big_dev_t st_rdev; /* device type */
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
struct timespec st_atimespec;/* time of last access */
|
||||
struct timespec st_mtimespec;/* time of last data modification */
|
||||
struct timespec st_ctimespec;/* time of last file status change */
|
||||
struct timespec st_birthtimespec; /* time of creation */
|
||||
#else
|
||||
time_t st_atime; /* time of last access */
|
||||
long st_atimensec; /* nsec of last access */
|
||||
time_t st_mtime; /* time of last data modification */
|
||||
long st_mtimensec; /* nsec of last data modification */
|
||||
time_t st_ctime; /* time of last file status change */
|
||||
long st_ctimensec; /* nsec of last file status change */
|
||||
time_t st_birthtime; /* time of creation */
|
||||
long st_birthtimensec; /* nsec of time of creation */
|
||||
#endif
|
||||
big_off_t st_size; /* file size, in bytes */
|
||||
blkcnt_t st_blocks; /* blocks allocated for file */
|
||||
blksize_t st_blksize; /* optimal blocksize for I/O */
|
||||
u32_t st_flags; /* user defined flags for file */
|
||||
u32_t st_gen; /* file generation number */
|
||||
u32_t st_spare[2];
|
||||
};
|
||||
|
||||
|
||||
struct minix_prev_stat {
|
||||
short st_dev; /* major/minor device number */
|
||||
ino_t st_ino; /* i-node number */
|
||||
mode_t st_mode; /* file mode, protection bits, etc. */
|
||||
nlink_t st_nlink; /* # links; */
|
||||
short st_uid; /* uid of the file's owner */
|
||||
short int st_gid; /* gid; TEMPORARY HACK: should be gid_t */
|
||||
short st_rdev;
|
||||
off_t st_size; /* file size */
|
||||
time_t st_atime; /* time of last access */
|
||||
time_t st_mtime; /* time of last data modification */
|
||||
time_t st_ctime; /* time of last file status change */
|
||||
};
|
||||
|
||||
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
/* XXX after updating stat struct we don't want to update all the code */
|
||||
#define st_atime st_atimespec.tv_sec
|
||||
#define st_mtime st_mtimespec.tv_sec
|
||||
#define st_ctime st_ctimespec.tv_sec
|
||||
#define st_birthtime st_birthtimespec.tv_sec
|
||||
#define st_atimensec st_atimespec.tv_nsec
|
||||
#define st_mtimensec st_mtimespec.tv_nsec
|
||||
#define st_ctimensec st_ctimespec.tv_nsec
|
||||
#define st_birthtimensec st_birthtimespec.tv_nsec
|
||||
#endif
|
||||
|
||||
|
||||
#define S_ISUID 0004000 /* set user id on execution */
|
||||
#define S_ISGID 0002000 /* set group id on execution */
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
#define S_ISTXT 0001000 /* sticky bit */
|
||||
#endif
|
||||
|
||||
#define S_IRWXU 0000700 /* RWX mask for owner */
|
||||
#define S_IRUSR 0000400 /* R for owner */
|
||||
#define S_IWUSR 0000200 /* W for owner */
|
||||
#define S_IXUSR 0000100 /* X for owner */
|
||||
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
#define S_IREAD S_IRUSR
|
||||
#define S_IWRITE S_IWUSR
|
||||
#define S_IEXEC S_IXUSR
|
||||
#endif
|
||||
|
||||
#define S_IRWXG 0000070 /* RWX mask for group */
|
||||
#define S_IRGRP 0000040 /* R for group */
|
||||
#define S_IWGRP 0000020 /* W for group */
|
||||
#define S_IXGRP 0000010 /* X for group */
|
||||
|
||||
#define S_IRWXO 0000007 /* RWX mask for other */
|
||||
#define S_IROTH 0000004 /* R for other */
|
||||
#define S_IWOTH 0000002 /* W for other */
|
||||
#define S_IXOTH 0000001 /* X for other */
|
||||
|
||||
#define _S_IFMT 0170000 /* type of file mask */
|
||||
#define _S_IFIFO 0010000 /* named pipe (fifo) */
|
||||
#define _S_IFCHR 0020000 /* character special */
|
||||
#define _S_IFDIR 0040000 /* directory */
|
||||
#define _S_IFBLK 0060000 /* block special */
|
||||
#define _S_IFREG 0100000 /* regular */
|
||||
#define _S_IFLNK 0120000 /* symbolic link */
|
||||
#define _S_IFSOCK 0140000 /* socket */
|
||||
#define _S_ISVTX 0001000 /* save swapped text even after use */
|
||||
|
||||
#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
|
||||
#define S_IFMT _S_IFMT
|
||||
#define S_IFIFO _S_IFIFO
|
||||
#define S_IFCHR _S_IFCHR
|
||||
#define S_IFDIR _S_IFDIR
|
||||
#define S_IFBLK _S_IFBLK
|
||||
#define S_IFREG _S_IFREG
|
||||
#define S_IFLNK _S_IFLNK
|
||||
#define S_ISVTX _S_ISVTX
|
||||
#endif
|
||||
#if ((_XOPEN_SOURCE - 0) >= 600) || defined(_NETBSD_SOURCE)
|
||||
#define S_IFSOCK _S_IFSOCK
|
||||
#endif
|
||||
|
||||
#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) /* directory */
|
||||
#define S_ISCHR(m) (((m) & _S_IFMT) == _S_IFCHR) /* char special */
|
||||
#define S_ISBLK(m) (((m) & _S_IFMT) == _S_IFBLK) /* block special */
|
||||
#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG) /* regular file */
|
||||
#define S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO) /* fifo */
|
||||
#if ((_POSIX_C_SOURCE - 0) >= 200112L) || defined(_XOPEN_SOURCE) || \
|
||||
defined(_NETBSD_SOURCE)
|
||||
#define S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK) /* symbolic link */
|
||||
#endif
|
||||
#if ((_POSIX_C_SOURCE - 0) >= 200112L) || ((_XOPEN_SOURCE - 0) >= 600) || \
|
||||
defined(_NETBSD_SOURCE)
|
||||
#define S_ISSOCK(m) (((m) & _S_IFMT) == _S_IFSOCK) /* socket */
|
||||
#endif
|
||||
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
|
||||
/* 7777 */
|
||||
#define ALLPERMS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
|
||||
/* 0666 */
|
||||
#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
|
||||
|
||||
#define S_BLKSIZE 512 /* block size used in the stat struct */
|
||||
|
||||
/*
|
||||
* Definitions of flags stored in file flags word.
|
||||
*
|
||||
* Super-user and owner changeable flags.
|
||||
*/
|
||||
#define UF_SETTABLE 0x0000ffff /* mask of owner changeable flags */
|
||||
#define UF_NODUMP 0x00000001 /* do not dump file */
|
||||
#define UF_IMMUTABLE 0x00000002 /* file may not be changed */
|
||||
#define UF_APPEND 0x00000004 /* writes to file may only append */
|
||||
#define UF_OPAQUE 0x00000008 /* directory is opaque wrt. union */
|
||||
|
||||
/*
|
||||
* Super-user changeable flags.
|
||||
*/
|
||||
#define SF_SETTABLE 0xffff0000 /* mask of superuser changeable flags */
|
||||
#define SF_ARCHIVED 0x00010000 /* file is archived */
|
||||
#define SF_IMMUTABLE 0x00020000 /* file may not be changed */
|
||||
#define SF_APPEND 0x00040000 /* writes to file may only append */
|
||||
|
||||
#endif /* _NETBSD_SOURCE */
|
||||
|
||||
#if defined(__minix)
|
||||
#include <machine/vmparam.h>
|
||||
/* Convenient constant to use when st_blocksize field is required. */
|
||||
#define MINIX_ST_BLKSIZE PAGE_SIZE
|
||||
#endif
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#if !defined(_KERNEL) && !defined(_STANDALONE)
|
||||
|
||||
__BEGIN_DECLS
|
||||
int chmod(const char *, mode_t);
|
||||
int mkdir(const char *, mode_t);
|
||||
int mkfifo(const char *, mode_t);
|
||||
#ifndef __LIBC12_SOURCE__
|
||||
int stat(const char *, struct stat *) __RENAME(__stat50);
|
||||
int fstat(int, struct stat *) __RENAME(__fstat50);
|
||||
#endif
|
||||
mode_t umask(mode_t);
|
||||
#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
|
||||
int fchmod(int, mode_t);
|
||||
#ifndef __LIBC12_SOURCE__
|
||||
int lstat(const char *, struct stat *) __RENAME(__lstat50);
|
||||
int mknod(const char *, mode_t, dev_t) __RENAME(__mknod50);
|
||||
#endif
|
||||
#endif /* defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) */
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_KERNEL && !_STANDALONE */
|
||||
#endif /* !_SYS_STAT_H_ */
|
||||
1
sys/sys/stdarg.h
Normal file
1
sys/sys/stdarg.h
Normal file
@@ -0,0 +1 @@
|
||||
#include <stdarg.h>
|
||||
Reference in New Issue
Block a user