imported code harmonisation
. common/include/arch/i386 is not actually an imported sys/arch/i386/include but leftover Minix files; remove and move to include/ . move include/ufs to sys/ufs, where it came from, now that we have a sys/ hierarchy . move mdocml/ to external/bsd/, now we have that . single sys/arch/i386/stand/ import for boot stuff
This commit is contained in:
@@ -25,19 +25,6 @@ INCS= a.out.h aio.h ar.h assert.h atomic.h \
|
||||
ttyent.h tzfile.h ucontext.h ulimit.h unistd.h util.h utime.h utmp.h \
|
||||
utmpx.h uuid.h varargs.h vis.h wchar.h wctype.h wordexp.h
|
||||
|
||||
INCS += ufs/chfs/chfs.h ufs/chfs/chfs_args.h ufs/chfs/chfs_inode.h \
|
||||
ufs/chfs/chfs_pool.h ufs/chfs/debug.h ufs/chfs/ebh.h \
|
||||
ufs/chfs/ebh_media.h ufs/chfs/ebh_misc.h ufs/chfs/media.h \
|
||||
ufs/ext2fs/ext2fs.h ufs/ext2fs/ext2fs_dinode.h \
|
||||
ufs/ext2fs/ext2fs_dir.h ufs/ext2fs/ext2fs_extern.h \
|
||||
ufs/ffs/ffs_extern.h ufs/ffs/fs.h ufs/lfs/lfs.h \
|
||||
ufs/lfs/lfs_extern.h ufs/mfs/mfs_extern.h ufs/mfs/mfsnode.h \
|
||||
ufs/ufs/dinode.h ufs/ufs/dir.h ufs/ufs/dirhash.h \
|
||||
ufs/ufs/extattr.h ufs/ufs/inode.h ufs/ufs/quota.h \
|
||||
ufs/ufs/quota1.h ufs/ufs/quota2.h ufs/ufs/ufs_bswap.h \
|
||||
ufs/ufs/ufs_extern.h ufs/ufs/ufs_quota.h ufs/ufs/ufs_wapbl.h \
|
||||
ufs/ufs/ufsmount.h \
|
||||
|
||||
.else
|
||||
INCS= a.out.h aio.h ar.h assert.h atomic.h \
|
||||
bitstring.h bm.h cdbr.h cdbw.h complex.h cpio.h ctype.h \
|
||||
|
||||
@@ -9,8 +9,12 @@ INCS= ansi.h asm.h bswap.h byte_swap.h cdefs.h \
|
||||
int_mwgwtypes.h int_types.h limits.h \
|
||||
math.h mcontext.h npx.h param.h profile.h \
|
||||
setjmp.h signal.h stdarg.h types.h \
|
||||
vmparam.h wchar_limits.h
|
||||
vmparam.h wchar_limits.h \
|
||||
archtypes.h bios.h cmos.h cpu.h diskparm.h fpu.h int86.h \
|
||||
interrupt.h memory.h multiboot.h partition.h \
|
||||
pci.h pci_amd.h pci_intel.h pci_sis.h pci_via.h \
|
||||
ports.h stackframe.h vm.h elf.h elf_machdep.h mutex.h \
|
||||
disklabel.h
|
||||
|
||||
|
||||
.include "${MINIXSRCDIR}/common/include/arch/i386/Makefile.inc"
|
||||
.include <bsd.kinc.mk>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
.include <bsd.own.mk>
|
||||
.PATH: ${MINIXSRCDIR}/common/include/arch/i386
|
||||
|
||||
INCS+= archtypes.h bios.h cmos.h cpu.h diskparm.h fpu.h int86.h \
|
||||
interrupt.h memory.h multiboot.h partition.h \
|
||||
pci.h pci_amd.h pci_intel.h pci_sis.h pci_via.h \
|
||||
ports.h stackframe.h vm.h elf.h elf_machdep.h mutex.h \
|
||||
disklabel.h
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
|
||||
#ifndef _I386_TYPES_H
|
||||
#define _I386_TYPES_H
|
||||
|
||||
#include <minix/sys_config.h>
|
||||
#include <machine/stackframe.h>
|
||||
#include <machine/fpu.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
struct segdesc_s { /* segment descriptor for protected mode */
|
||||
u16_t limit_low;
|
||||
u16_t base_low;
|
||||
u8_t base_middle;
|
||||
u8_t access; /* |P|DL|1|X|E|R|A| */
|
||||
u8_t granularity; /* |G|X|0|A|LIMT| */
|
||||
u8_t base_high;
|
||||
};
|
||||
|
||||
#define LDT_SIZE 2 /* CS and DS */
|
||||
|
||||
/* Fixed local descriptors. */
|
||||
#define CS_LDT_INDEX 0 /* process CS */
|
||||
#define DS_LDT_INDEX 1 /* process DS=ES=FS=GS=SS */
|
||||
|
||||
typedef struct segframe {
|
||||
reg_t p_ldt_sel; /* selector in gdt with ldt base and limit */
|
||||
reg_t p_cr3; /* page table root */
|
||||
u32_t *p_cr3_v;
|
||||
struct segdesc_s p_ldt[LDT_SIZE]; /* CS, DS and remote */
|
||||
} segframe_t;
|
||||
|
||||
/* fpu_state_s is used in kernel proc table.
|
||||
* Any changes in this structure requires changes in sconst.h,
|
||||
* since this structure is used in proc structure. */
|
||||
struct fpu_state_s {
|
||||
union fpu_state_u *fpu_save_area_p; /* 16-aligned fpu_save_area */
|
||||
/* fpu_image includes 512 bytes of image itself and
|
||||
* additional 15 bytes required for manual 16-byte alignment. */
|
||||
char fpu_image[527];
|
||||
};
|
||||
|
||||
#define INMEMORY(p) (!p->p_seg.p_cr3 || get_cpulocal_var(ptproc) == p)
|
||||
|
||||
typedef u32_t atomic_t; /* access to an aligned 32bit value is atomic on i386 */
|
||||
|
||||
#endif /* #ifndef _I386_TYPES_H */
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
/* Definitions of several known BIOS addresses. The addresses listed here
|
||||
* are found in three memory areas that have been defined in <ibm/memory.h>.
|
||||
* - the BIOS interrupt vectors
|
||||
* - the BIOS data area
|
||||
* - the motherboard BIOS memory
|
||||
*
|
||||
* Created: March 2005, Jorrit N. Herder
|
||||
*/
|
||||
|
||||
#ifndef _BIOS_H
|
||||
#define _BIOS_H
|
||||
|
||||
/* PART I --
|
||||
* The BIOS interrupt vector table (IVT) area (1024 B as of address 0x0000).
|
||||
* Although this area holds 256 interrupt vectors (with jump addresses), some
|
||||
* vectors actually contain important BIOS data. Some addresses are below.
|
||||
*/
|
||||
#define BIOS_EQUIP_CHECK_ADDR 0x0044
|
||||
#define BIOS_EQUIP_CHECK_SIZE 4L
|
||||
|
||||
#define BIOS_VIDEO_PARAMS_ADDR 0x0074
|
||||
#define BIOS_VIDEO_PARAMS_SIZE 4L
|
||||
|
||||
#define BIOS_FLOP_PARAMS_ADDR 0x0078
|
||||
#define BIOS_FLOP_PARAMS_SIZE 4L
|
||||
|
||||
#define BIOS_HD0_PARAMS_ADDR 0x0104 /* disk 0 parameters */
|
||||
#define BIOS_HD0_PARAMS_SIZE 4L
|
||||
|
||||
#define BIOS_HD1_PARAMS_ADDR 0x0118 /* disk 1 parameters */
|
||||
#define BIOS_HD1_PARAMS_SIZE 4L
|
||||
|
||||
/* PART I --
|
||||
* Addresses in the BIOS data area (256 B as of address 0x0400). The addresses
|
||||
* listed below are the most important ones, and the ones that are currently
|
||||
* used. Other addresses may be defined below when new features are added.
|
||||
*/
|
||||
|
||||
/* Serial ports (COM1-COM4). */
|
||||
#define COM1_IO_PORT_ADDR 0x400 /* COM1 port address */
|
||||
#define COM1_IO_PORT_SIZE 2L
|
||||
#define COM2_IO_PORT_ADDR 0x402 /* COM2 port address */
|
||||
#define COM2_IO_PORT_SIZE 2L
|
||||
#define COM3_IO_PORT_ADDR 0x404 /* COM3 port address */
|
||||
#define COM3_IO_PORT_SIZE 2L
|
||||
#define COM4_IO_PORT_ADDR 0x406 /* COM4 port address */
|
||||
#define COM4_IO_PORT_SIZE 2L
|
||||
|
||||
/* Parallel ports (LPT1-LPT4). */
|
||||
#define LPT1_IO_PORT_ADDR 0x408 /* LPT1 port address */
|
||||
#define LPT1_IO_PORT_SIZE 2L
|
||||
#define LPT2_IO_PORT_ADDR 0x40A /* LPT2 port address */
|
||||
#define LPT2_IO_PORT_SIZE 2L
|
||||
#define LPT3_IO_PORT_ADDR 0x40C /* LPT3 port address */
|
||||
#define LPT3_IO_PORT_SIZE 2L
|
||||
#define LPT4_IO_PORT_ADDR 0x40E /* LPT4 port (except on PS/2) */
|
||||
#define LPT4_IO_PORT_SIZE 2L
|
||||
|
||||
/* Video controller (VDU). */
|
||||
#define VDU_SCREEN_COLS_ADDR 0x44A /* VDU nr of screen columns */
|
||||
#define VDU_SCREEN_COLS_SIZE 2L
|
||||
|
||||
/* Base I/O port address for active 6845 CRT controller. */
|
||||
#define VDU_CRT_BASE_ADDR 0x463 /* 3B4h = mono, 3D4h = color */
|
||||
#define VDU_CRT_BASE_SIZE 2L
|
||||
|
||||
/* Soft reset flags to control shutdown. */
|
||||
#define SOFT_RESET_FLAG_ADDR 0x472 /* soft reset flag on Ctl-Alt-Del */
|
||||
#define SOFT_RESET_FLAG_SIZE 2L
|
||||
#define STOP_MEM_CHECK 0x1234 /* bypass memory tests & CRT init */
|
||||
#define PRESERVE_MEMORY 0x4321 /* preserve memory */
|
||||
#define SYSTEM_SUSPEND 0x5678 /* system suspend */
|
||||
#define MANUFACTURER_TEST 0x9ABC /* manufacturer test */
|
||||
#define CONVERTIBLE_POST 0xABCD /* convertible POST loop */
|
||||
/* ... many other values are used during POST */
|
||||
|
||||
/* Hard disk parameters. (Also see BIOS interrupt vector table above.) */
|
||||
#define NR_HD_DRIVES_ADDR 0x475 /* number of hard disk drives */
|
||||
#define NR_HD_DRIVES_SIZE 1L
|
||||
|
||||
/* Parallel ports (LPT1-LPT4) timeout values. */
|
||||
#define LPT1_TIMEOUT_ADDR 0x478 /* time-out value for LPT1 */
|
||||
#define LPT1_TIMEOUT_SIZE 1L
|
||||
#define LPT2_TIMEOUT_ADDR 0x479 /* time-out value for LPT2 */
|
||||
#define LPT2_TIMEOUT_SIZE 1L
|
||||
#define LPT3_TIMEOUT_ADDR 0x47A /* time-out value for LPT3 */
|
||||
#define LPT3_TIMEOUT_SIZE 1L
|
||||
#define LPT4_TIMEOUT_ADDR 0x47B /* time-out for LPT4 (except PS/2) */
|
||||
#define LPT4_TIMEOUT_SIZE 1L
|
||||
|
||||
/* Serial ports (COM1-COM4) timeout values. */
|
||||
#define COM1_TIMEOUT_ADDR 0x47C /* time-out value for COM1 */
|
||||
#define COM1_TIMEOUT_SIZE 1L
|
||||
#define COM2_TIMEOUT_ADDR 0x47D /* time-out value for COM2 */
|
||||
#define COM2_TIMEOUT_SIZE 1L
|
||||
#define COM3_TIMEOUT_ADDR 0x47E /* time-out value for COM3 */
|
||||
#define COM3_TIMEOUT_SIZE 1L
|
||||
#define COM4_TIMEOUT_ADDR 0x47F /* time-out value for COM4 */
|
||||
#define COM4_TIMEOUT_SIZE 1L
|
||||
|
||||
/* Video controller (VDU). */
|
||||
#define VDU_SCREEN_ROWS_ADDR 0x484 /* screen rows (less 1, EGA+)*/
|
||||
#define VDU_SCREEN_ROWS_SIZE 1L
|
||||
#define VDU_FONTLINES_ADDR 0x485 /* point height of char matrix */
|
||||
#define VDU_FONTLINES_SIZE 2L
|
||||
|
||||
/* Video controller (VDU). */
|
||||
#define VDU_VIDEO_MODE_ADDR 0x49A /* current video mode */
|
||||
#define VDU_VIDEO_MODE_SIZE 1L
|
||||
|
||||
/* PART III --
|
||||
* The motherboard BIOS memory contains some known values that are currently
|
||||
* in use. Other sections in the upper memory area (UMA) addresses vary in
|
||||
* size and locus and are not further defined here. A rough map is given in
|
||||
* <ibm/memory.h>.
|
||||
*/
|
||||
|
||||
/* Machine ID (we're interested in PS/2 and AT models). */
|
||||
#define MACHINE_ID_ADDR 0xFFFFE /* BIOS machine ID byte */
|
||||
#define MACHINE_ID_SIZE 1L
|
||||
#define PS_386_MACHINE 0xF8 /* ID byte for PS/2 modela 70/80 */
|
||||
#define PC_AT_MACHINE 0xFC /* PC/AT, PC/XT286, PS/2 models 50/60 */
|
||||
|
||||
#endif /* _BIOS_H */
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
ibm/cmos.h
|
||||
|
||||
Created: Dec 1998 by Philip Homburg <philip@cs.vu.nl>
|
||||
|
||||
Definitions for the CMOS/realtime clock. Based on the datasheet for the
|
||||
Dallas DS12887, compatible with the Motorola MC146818
|
||||
*/
|
||||
|
||||
#define RTC_INDEX 0x70 /* Bit 7 = NMI enable (1) / disable (0)
|
||||
* bits 0..6 index
|
||||
*/
|
||||
#define RTC_IO 0x71 /* Data register,
|
||||
* Note: the operation following a write to
|
||||
* RTC_INDEX should an access (read or write)
|
||||
* to RTC_IO
|
||||
*/
|
||||
|
||||
#define RTC_SEC 0x0 /* Seconds register */
|
||||
#define RTC_SEC_ALRM 0x1 /* Seconds register for alarm */
|
||||
#define RTC_MIN 0x2 /* Minutes register */
|
||||
#define RTC_MIN_ALRM 0x3 /* Minutes register for alarm */
|
||||
#define RTC_HOUR 0x4 /* Hours register */
|
||||
#define RTC_HOUR_ALRM 0x5 /* Hours register for alarm */
|
||||
#define RTC_WDAY 0x6 /* Day of the week, 1..7, Sunday = 1 */
|
||||
#define RTC_MDAY 0x7 /* Day of the month, 1..31 */
|
||||
#define RTC_MONTH 0x8 /* Month, 1..12 */
|
||||
#define RTC_YEAR 0x9 /* Year, 0..99 */
|
||||
#define RTC_REG_A 0xA
|
||||
#define RTC_A_UIP 0x80 /* Update in progress. When clear,
|
||||
* no update will occur for 244
|
||||
* micro seconds.
|
||||
*/
|
||||
#define RTC_A_DV 0x70 /* Divider bits, valid values are: */
|
||||
#define RTC_A_DV_OK 0x20 /* Normal */
|
||||
#define RTC_A_DV_STOP 0x70 /* Stop, a re-start starts
|
||||
* halfway through a cycle,
|
||||
* i.e. the update occurs after
|
||||
* 500ms.
|
||||
*/
|
||||
#define RTC_A_RS 0x0F /* Int. freq */
|
||||
/* 0 None
|
||||
* 1 256 Hz
|
||||
* 2 128 Hz
|
||||
* 3 8192 Hz
|
||||
* 4 4096 Hz
|
||||
* 5 2048 Hz
|
||||
* 6 1024 Hz
|
||||
* 7 512 Hz
|
||||
* 8 256 Hz
|
||||
* 9 128 Hz
|
||||
* 10 64 Hz
|
||||
* 11 32 Hz
|
||||
* 12 16 Hz
|
||||
* 13 8 Hz
|
||||
* 14 4 Hz
|
||||
* 15 2 Hz
|
||||
*/
|
||||
#define RTC_A_RS_DEF 6 /* Default freq. */
|
||||
#define RTC_REG_B 0xB
|
||||
#define RTC_B_SET 0x80 /* Inhibit updates */
|
||||
#define RTC_B_PIE 0x40 /* Enable periodic interrupts */
|
||||
#define RTC_B_AIE 0x20 /* Enable alarm interrupts */
|
||||
#define RTC_B_UIE 0x10 /* Enable update ended interrupts */
|
||||
#define RTC_B_SQWE 0x08 /* Enable square wave output */
|
||||
#define RTC_B_DM_BCD 0x04 /* Data is in BCD (otherwise binary) */
|
||||
#define RTC_B_24 0x02 /* Count hours in 24-hour mode */
|
||||
#define RTC_B_DSE 0x01 /* Automatic (wrong) daylight savings
|
||||
* updates
|
||||
*/
|
||||
#define RTC_REG_C 0xC
|
||||
|
||||
/* Contents of the general purpose CMOS RAM (source IBM reference manual) */
|
||||
#define CMOS_STATUS 0xE
|
||||
#define CS_LOST_POWER 0x80 /* Chip lost power */
|
||||
#define CS_BAD_CHKSUM 0x40 /* Checksum is incorrect */
|
||||
#define CS_BAD_CONFIG 0x20 /* Bad configuration info */
|
||||
#define CS_BAD_MEMSIZE 0x10 /* Wrong memory size of CMOS */
|
||||
#define CS_BAD_HD 0x08 /* Harddisk failed */
|
||||
#define CS_BAD_TIME 0x04 /* CMOS time is invalid */
|
||||
/* bits 0 and 1 are reserved */
|
||||
|
||||
/*
|
||||
* $PchId: cmos.h,v 1.1 1998/12/16 09:14:21 philip Exp $
|
||||
*/
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef _IBM_CPU_H
|
||||
#define _IBM_CPU_H 1
|
||||
|
||||
#define X86_FLAG_C (1L << 0) /* S Carry */
|
||||
#define X86_FLAG_P (1L << 2) /* S Parity */
|
||||
#define X86_FLAG_A (1L << 4) /* S Aux. carry */
|
||||
#define X86_FLAG_Z (1L << 6) /* S Zero */
|
||||
#define X86_FLAG_S (1L << 7) /* S Sign */
|
||||
|
||||
#define X86_FLAG_T (1L << 8) /* X Trap */
|
||||
#define X86_FLAG_I (1L << 9) /* X Interrupt */
|
||||
#define X86_FLAG_D (1L << 10) /* C Direction */
|
||||
#define X86_FLAG_O (1L << 11) /* S Overflow */
|
||||
|
||||
/* User flags are S (Status) and C (Control) flags. */
|
||||
#define X86_FLAGS_USER (X86_FLAG_C | X86_FLAG_P | X86_FLAG_A | X86_FLAG_Z | \
|
||||
X86_FLAG_S | X86_FLAG_D | X86_FLAG_O)
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: disklabel.h,v 1.15 2009/11/23 13:40:10 pooka Exp $ */
|
||||
/* $NetBSD: disklabel.h,v 1.16 2011/08/30 12:39:55 bouyer Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Christopher G. Demetriou
|
||||
@@ -33,6 +33,7 @@
|
||||
#ifndef _I386_DISKLABEL_H_
|
||||
#define _I386_DISKLABEL_H_
|
||||
|
||||
#define LABELUSESMBR 1 /* use MBR partitionning */
|
||||
#define LABELSECTOR 1 /* sector containing label */
|
||||
#define LABELOFFSET 0 /* offset of label in sector */
|
||||
#define MAXPARTITIONS 16 /* number of partitions */
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/* PC (and AT) BIOS structure to hold disk parameters. Under Minix, it is
|
||||
* used mainly for formatting.
|
||||
*/
|
||||
|
||||
#ifndef _DISKPARM_H
|
||||
#define _DISKPARM_H
|
||||
struct disk_parameter_s {
|
||||
char spec1;
|
||||
char spec2;
|
||||
char motor_turnoff_sec;
|
||||
char sector_size_code;
|
||||
char sectors_per_cylinder;
|
||||
char gap_length;
|
||||
char dtl;
|
||||
char gap_length_for_format;
|
||||
char fill_byte_for_format;
|
||||
char head_settle_msec;
|
||||
char motor_start_eigth_sec;
|
||||
};
|
||||
#endif /* _DISKPARM_H */
|
||||
@@ -0,0 +1,116 @@
|
||||
/*-
|
||||
* Copyright (c) 1996-1997 John D. Polstra.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _MACHINE_ELF_H_
|
||||
#define _MACHINE_ELF_H_ 1
|
||||
|
||||
/*
|
||||
* ELF definitions for the i386 architecture.
|
||||
*/
|
||||
|
||||
#include <sys/elf32.h> /* Definitions common to all 32 bit architectures. */
|
||||
#if defined(__ELF_WORD_SIZE) && __ELF_WORD_SIZE == 64
|
||||
#include <sys/elf64.h> /* Definitions common to all 64 bit architectures. */
|
||||
#endif
|
||||
|
||||
#ifndef __ELF_WORD_SIZE
|
||||
#define __ELF_WORD_SIZE 32 /* Used by <sys/elf_generic.h> */
|
||||
#endif
|
||||
|
||||
#include <sys/elf_generic.h>
|
||||
|
||||
#define ELF_ARCH EM_386
|
||||
|
||||
#define ELF_MACHINE_OK(x) ((x) == EM_386 || (x) == EM_486)
|
||||
|
||||
/*
|
||||
* Auxiliary vector entries for passing information to the interpreter.
|
||||
*
|
||||
* The i386 supplement to the SVR4 ABI specification names this "auxv_t",
|
||||
* but POSIX lays claim to all symbols ending with "_t".
|
||||
*/
|
||||
|
||||
typedef struct { /* Auxiliary vector entry on initial stack */
|
||||
int a_type; /* Entry type. */
|
||||
union {
|
||||
long a_val; /* Integer value. */
|
||||
void *a_ptr; /* Address. */
|
||||
void (*a_fcn)(void); /* Function pointer (not used). */
|
||||
} a_un;
|
||||
} Elf32_Auxinfo;
|
||||
|
||||
#if __ELF_WORD_SIZE == 64
|
||||
/* Fake for amd64 loader support */
|
||||
typedef struct {
|
||||
int fake;
|
||||
} Elf64_Auxinfo;
|
||||
#endif
|
||||
|
||||
__ElfType(Auxinfo);
|
||||
|
||||
/* Values for a_type. */
|
||||
#define AT_NULL 0 /* Terminates the vector. */
|
||||
#define AT_IGNORE 1 /* Ignored entry. */
|
||||
#define AT_EXECFD 2 /* File descriptor of program to load. */
|
||||
#define AT_PHDR 3 /* Program header of program already loaded. */
|
||||
#define AT_PHENT 4 /* Size of each program header entry. */
|
||||
#define AT_PHNUM 5 /* Number of program header entries. */
|
||||
#define AT_PAGESZ 6 /* Page size in bytes. */
|
||||
#define AT_BASE 7 /* Interpreter's base address. */
|
||||
#define AT_FLAGS 8 /* Flags (unused for i386). */
|
||||
#define AT_ENTRY 9 /* Where interpreter should transfer control. */
|
||||
#define AT_NOTELF 10 /* Program is not ELF ?? */
|
||||
#define AT_UID 11 /* Real uid. */
|
||||
#define AT_EUID 12 /* Effective uid. */
|
||||
#define AT_GID 13 /* Real gid. */
|
||||
#define AT_EGID 14 /* Effective gid. */
|
||||
#define AT_EXECPATH 15 /* Path to the executable. */
|
||||
#define AT_CANARY 16 /* Canary for SSP. */
|
||||
#define AT_CANARYLEN 17 /* Length of the canary. */
|
||||
#define AT_OSRELDATE 18 /* OSRELDATE. */
|
||||
#define AT_NCPUS 19 /* Number of CPUs. */
|
||||
#define AT_PAGESIZES 20 /* Pagesizes. */
|
||||
#define AT_PAGESIZESLEN 21 /* Number of pagesizes. */
|
||||
|
||||
#define AT_COUNT 22 /* Count of defined aux entry types. */
|
||||
|
||||
/*
|
||||
* Relocation types.
|
||||
*/
|
||||
|
||||
#define R_386_COUNT 38 /* Count of defined relocation types. */
|
||||
|
||||
/* Define "machine" characteristics */
|
||||
#define ELF_TARG_CLASS ELFCLASS32
|
||||
#define ELF_TARG_DATA ELFDATA2LSB
|
||||
#define ELF_TARG_MACH EM_386
|
||||
#define ELF_TARG_VER 1
|
||||
|
||||
#define ET_DYN_LOAD_ADDR 0x01001000
|
||||
|
||||
#endif /* !_MACHINE_ELF_H_ */
|
||||
@@ -0,0 +1,63 @@
|
||||
/* $NetBSD: elf_machdep.h,v 1.10 2009/05/30 05:56:52 skrll Exp $ */
|
||||
|
||||
#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB
|
||||
#define ELF32_MACHDEP_ID_CASES \
|
||||
case EM_386: \
|
||||
case EM_486: \
|
||||
break;
|
||||
|
||||
#define ELF64_MACHDEP_ENDIANNESS XXX /* break compilation */
|
||||
#define ELF64_MACHDEP_ID_CASES \
|
||||
/* no 64-bit ELF machine types supported */
|
||||
|
||||
#define ELF32_MACHDEP_ID EM_386
|
||||
|
||||
#define ARCH_ELFSIZE 32 /* MD native binary size */
|
||||
|
||||
/* i386 relocations */
|
||||
#define R_386_NONE 0
|
||||
#define R_386_32 1
|
||||
#define R_386_PC32 2
|
||||
#define R_386_GOT32 3
|
||||
#define R_386_PLT32 4
|
||||
#define R_386_COPY 5
|
||||
#define R_386_GLOB_DAT 6
|
||||
#define R_386_JMP_SLOT 7
|
||||
#define R_386_RELATIVE 8
|
||||
#define R_386_GOTOFF 9
|
||||
#define R_386_GOTPC 10
|
||||
|
||||
/* TLS relocations */
|
||||
#define R_386_TLS_TPOFF 14
|
||||
#define R_386_TLS_IE 15
|
||||
#define R_386_TLS_GOTIE 16
|
||||
#define R_386_TLS_LE 17
|
||||
#define R_386_TLS_GD 18
|
||||
#define R_386_TLS_LDM 19
|
||||
|
||||
/* The following relocations are GNU extensions. */
|
||||
#define R_386_16 20
|
||||
#define R_386_PC16 21
|
||||
#define R_386_8 22
|
||||
#define R_386_PC8 23
|
||||
|
||||
/* More TLS relocations */
|
||||
#define R_386_TLS_GD_32 24
|
||||
#define R_386_TLS_GD_PUSH 25
|
||||
#define R_386_TLS_GD_CALL 26
|
||||
#define R_386_TLS_GD_POP 27
|
||||
#define R_386_TLS_LDM_32 28
|
||||
#define R_386_TLS_LDM_PUSH 29
|
||||
#define R_386_TLS_LDM_CALL 30
|
||||
#define R_386_TLS_LDM_POP 31
|
||||
#define R_386_TLS_LDO_32 32
|
||||
#define R_386_TLS_IE_32 33
|
||||
#define R_386_TLS_LE_32 34
|
||||
#define R_386_TLS_DTPMOD32 35
|
||||
#define R_386_TLS_DTPOFF32 36
|
||||
#define R_386_TLS_TPOFF32 37
|
||||
#define R_386_TLS_GOTDESC 39
|
||||
#define R_386_TLS_DESC_CALL 40
|
||||
#define R_386_TLS_DESC 41
|
||||
|
||||
#define R_TYPE(name) __CONCAT(R_386_,name)
|
||||
@@ -0,0 +1,50 @@
|
||||
#ifndef FPU_H
|
||||
#define FPU_H
|
||||
|
||||
/* x87 FPU state, MMX Technolodgy.
|
||||
* 108 bytes.*/
|
||||
struct fpu_regs_s {
|
||||
u16_t fp_control; /* control */
|
||||
u16_t fp_unused_1;
|
||||
u16_t fp_status; /* status */
|
||||
u16_t fp_unused_2;
|
||||
u16_t fp_tag; /* register tags */
|
||||
u16_t fp_unused_3;
|
||||
u32_t fp_eip; /* eip at failed instruction */
|
||||
u16_t fp_cs; /* cs at failed instruction */
|
||||
u16_t fp_opcode; /* opcode of failed instruction */
|
||||
u32_t fp_dp; /* data address */
|
||||
u16_t fp_ds; /* data segment */
|
||||
u16_t fp_unused_4;
|
||||
u16_t fp_st_regs[8][5]; /* 8 80-bit FP registers */
|
||||
};
|
||||
|
||||
/* x87 FPU, MMX Technolodgy and SSE state.
|
||||
* 512 bytes (if you need size use FPU_XFP_SIZE). */
|
||||
struct xfp_save {
|
||||
u16_t fp_control; /* control */
|
||||
u16_t fp_status; /* status */
|
||||
u16_t fp_tag; /* register tags */
|
||||
u16_t fp_opcode; /* opcode of failed instruction */
|
||||
u32_t fp_eip; /* eip at failed instruction */
|
||||
u16_t fp_cs; /* cs at failed instruction */
|
||||
u16_t fp_unused_1;
|
||||
u32_t fp_dp; /* data address */
|
||||
u16_t fp_ds; /* data segment */
|
||||
u16_t fp_unused_2;
|
||||
u32_t fp_mxcsr; /* MXCSR */
|
||||
u32_t fp_mxcsr_mask; /* MXCSR_MASK */
|
||||
u16_t fp_st_regs[8][8]; /* 128 bytes for ST/MM regs */
|
||||
u32_t fp_xreg_word[32]; /* space for 8 128-bit XMM registers */
|
||||
u32_t fp_padding[56];
|
||||
};
|
||||
|
||||
/* Size of xfp_save structure. */
|
||||
#define FPU_XFP_SIZE 512
|
||||
|
||||
union fpu_state_u {
|
||||
struct fpu_regs_s fpu_regs;
|
||||
struct xfp_save xfp_regs;
|
||||
};
|
||||
|
||||
#endif /* #ifndef FPU_H */
|
||||
@@ -0,0 +1,61 @@
|
||||
/* int86.h - 8086 interrupt types Author: Kees J. Bot
|
||||
* 3 May 2000
|
||||
*/
|
||||
|
||||
/* Registers used in an PC real mode call for BIOS or DOS services. A
|
||||
* driver is called through the vector if the interrupt number is zero.
|
||||
*/
|
||||
union reg86 {
|
||||
struct l {
|
||||
u32_t ef; /* 32 bit flags (output only) */
|
||||
u32_t vec; /* Driver vector (input only) */
|
||||
u32_t _ds_es[1];
|
||||
u32_t eax; /* 32 bit general registers */
|
||||
u32_t ebx;
|
||||
u32_t ecx;
|
||||
u32_t edx;
|
||||
u32_t esi;
|
||||
u32_t edi;
|
||||
u32_t ebp;
|
||||
} l;
|
||||
struct w {
|
||||
u16_t f, _ef[1]; /* 16 bit flags (output only) */
|
||||
u16_t off, seg; /* Driver vector (input only) */
|
||||
u16_t ds, es; /* DS and ES real mode segment regs */
|
||||
u16_t ax, _eax[1]; /* 16 bit general registers */
|
||||
u16_t bx, _ebx[1];
|
||||
u16_t cx, _ecx[1];
|
||||
u16_t dx, _edx[1];
|
||||
u16_t si, _esi[1];
|
||||
u16_t di, _edi[1];
|
||||
u16_t bp, _ebp[1];
|
||||
} w;
|
||||
struct b {
|
||||
u8_t intno, _intno[3]; /* Interrupt number (input only) */
|
||||
u8_t _vec[4];
|
||||
u8_t _ds_es[4];
|
||||
u8_t al, ah, _eax[2]; /* 8 bit general registers */
|
||||
u8_t bl, bh, _ebx[2];
|
||||
u8_t cl, ch, _ecx[2];
|
||||
u8_t dl, dh, _edx[2];
|
||||
u8_t _esi[4];
|
||||
u8_t _edi[4];
|
||||
u8_t _ebp[4];
|
||||
} b;
|
||||
};
|
||||
|
||||
struct reg86u { union reg86 u; }; /* Better for forward declarations */
|
||||
|
||||
/* Parameters passed on ioctls to the memory task. */
|
||||
|
||||
struct mio_int86 { /* MIOCINT86 */
|
||||
union reg86 reg86; /* x86 registers as above */
|
||||
u16_t off, seg; /* Address of kernel buffer */
|
||||
void *buf; /* User data buffer */
|
||||
size_t len; /* Size of user buffer */
|
||||
};
|
||||
|
||||
struct mio_ldt86 { /* MIOCGLDT86, MIOCSLDT86 */
|
||||
size_t idx; /* Index in process' LDT */
|
||||
u16_t entry[4]; /* One LDT entry to get or set. */
|
||||
};
|
||||
@@ -0,0 +1,66 @@
|
||||
/* Interrupt numbers and hardware vectors. */
|
||||
|
||||
#ifndef _INTERRUPT_H
|
||||
#define _INTERRUPT_H
|
||||
|
||||
#if (CHIP == INTEL)
|
||||
|
||||
/* 8259A interrupt controller ports. */
|
||||
#define INT_CTL 0x20 /* I/O port for interrupt controller */
|
||||
#define INT_CTLMASK 0x21 /* setting bits in this port disables ints */
|
||||
#define INT2_CTL 0xA0 /* I/O port for second interrupt controller */
|
||||
#define INT2_CTLMASK 0xA1 /* setting bits in this port disables ints */
|
||||
|
||||
/* Magic numbers for interrupt controller. */
|
||||
#define END_OF_INT 0x20 /* code used to re-enable after an interrupt */
|
||||
|
||||
/* Interrupt vectors defined/reserved by processor. */
|
||||
#define DIVIDE_VECTOR 0 /* divide error */
|
||||
#define DEBUG_VECTOR 1 /* single step (trace) */
|
||||
#define NMI_VECTOR 2 /* non-maskable interrupt */
|
||||
#define BREAKPOINT_VECTOR 3 /* software breakpoint */
|
||||
#define OVERFLOW_VECTOR 4 /* from INTO */
|
||||
|
||||
/* Fixed system call vector. */
|
||||
#define KERN_CALL_VECTOR 32 /* system calls are made with int SYSVEC */
|
||||
#define IPC_VECTOR 33 /* interrupt vector for ipc */
|
||||
|
||||
/* Suitable irq bases for hardware interrupts. Reprogram the 8259(s) from
|
||||
* the PC BIOS defaults since the BIOS doesn't respect all the processor's
|
||||
* reserved vectors (0 to 31).
|
||||
*/
|
||||
#define BIOS_IRQ0_VEC 0x08 /* base of IRQ0-7 vectors used by BIOS */
|
||||
#define BIOS_IRQ8_VEC 0x70 /* base of IRQ8-15 vectors used by BIOS */
|
||||
#define IRQ0_VECTOR 0x50 /* nice vectors to relocate IRQ0-7 to */
|
||||
#define IRQ8_VECTOR 0x70 /* no need to move IRQ8-15 */
|
||||
|
||||
/* Hardware interrupt numbers. */
|
||||
#ifndef USE_APIC
|
||||
#define NR_IRQ_VECTORS 16
|
||||
#else
|
||||
#define NR_IRQ_VECTORS 64
|
||||
#endif
|
||||
#define CLOCK_IRQ 0
|
||||
#define KEYBOARD_IRQ 1
|
||||
#define CASCADE_IRQ 2 /* cascade enable for 2nd AT controller */
|
||||
#define ETHER_IRQ 3 /* default ethernet interrupt vector */
|
||||
#define SECONDARY_IRQ 3 /* RS232 interrupt vector for port 2 */
|
||||
#define RS232_IRQ 4 /* RS232 interrupt vector for port 1 */
|
||||
#define XT_WINI_IRQ 5 /* xt winchester */
|
||||
#define FLOPPY_IRQ 6 /* floppy disk */
|
||||
#define PRINTER_IRQ 7
|
||||
#define SPURIOUS_IRQ 7
|
||||
#define CMOS_CLOCK_IRQ 8
|
||||
#define KBD_AUX_IRQ 12 /* AUX (PS/2 mouse) port in kbd controller */
|
||||
#define AT_WINI_0_IRQ 14 /* at winchester controller 0 */
|
||||
#define AT_WINI_1_IRQ 15 /* at winchester controller 1 */
|
||||
|
||||
/* Interrupt number to hardware vector. */
|
||||
#define BIOS_VECTOR(irq) \
|
||||
(((irq) < 8 ? BIOS_IRQ0_VEC : BIOS_IRQ8_VEC) + ((irq) & 0x07))
|
||||
#define VECTOR(irq) \
|
||||
(((irq) < 8 ? IRQ0_VECTOR : IRQ8_VECTOR) + ((irq) & 0x07))
|
||||
|
||||
#endif /* (CHIP == INTEL) */
|
||||
|
||||
#endif /* _INTERRUPT_H */
|
||||
@@ -0,0 +1,171 @@
|
||||
/* Physical memory layout on IBM compatible PCs. Only the major, fixed memory
|
||||
* areas are detailed here. Known addresses of the BIOS data area are defined
|
||||
* in <ibm/bios.h>. The map upper memory area (UMA) is only roughly defined
|
||||
* since the UMA sections may vary in size and locus.
|
||||
*
|
||||
* Created: March 2005, Jorrit N. Herder
|
||||
*/
|
||||
|
||||
/* I/O-mapped peripherals. I/O addresses are different from memory addresses
|
||||
* due to the I/O signal on the ISA bus. Individual I/O ports are defined by
|
||||
* the drivers that use them or looked up with help of the BIOS.
|
||||
*/
|
||||
#define IO_MEMORY_BEGIN 0x0000
|
||||
#define IO_MEMORY_END 0xFFFF
|
||||
|
||||
|
||||
/* Physical memory layout. Design decisions made for the earliest PCs, caused
|
||||
* memory to be broken broken into the following four basic pieces:
|
||||
* - Conventional or base memory: first 640 KB (incl. BIOS data, see below);
|
||||
* The top of conventional memory is often used by the BIOS to store data.
|
||||
* - Upper Memory Area (UMA): upper 384 KB of the first megabyte of memory;
|
||||
* - High Memory Area (HMA): ~ first 64 KB of the second megabyte of memory;
|
||||
* - Extended Memory: all the memory above first megabyte of memory.
|
||||
* The high memory area overlaps with the first 64 KB of extended memory, but
|
||||
* is different from the rest of extended memory because it can be accessed
|
||||
* when the processor is in real mode.
|
||||
*/
|
||||
#define BASE_MEM_BEGIN 0x000000
|
||||
#define BASE_MEM_TOP 0x090000
|
||||
#define BASE_MEM_END 0x09FFFF
|
||||
|
||||
#define UPPER_MEM_BEGIN 0x0A0000
|
||||
#define UPPER_MEM_END 0x0FFFFF
|
||||
|
||||
#define HIGH_MEM_BEGIN 0x100000
|
||||
#define HIGH_MEM_END 0x10FFEF
|
||||
|
||||
#define EXTENDED_MEM_BEGIN 0x100000
|
||||
#define EXTENDED_MEM_END ((unsigned) -1)
|
||||
|
||||
|
||||
/* The logical memory map of the first 1.5 MB is as follows (hexadecimals):
|
||||
*
|
||||
* offset [size] (id) = memory usage
|
||||
* ------------------------------------------------------------------------
|
||||
* 000000 [00400] (I) = Real-Mode Interrupt Vector Table (1024 B)
|
||||
* 000400 [00100] (B) = BIOS Data Area (256 B)
|
||||
* 000800 [00066] (W) = 80286 Loadall workspace
|
||||
* 010000 [10000] (c) = Real-Mode Compatibility Segment (64 KB)
|
||||
* 020000 [70000] (.) = Program-accessible memory (free)
|
||||
* 090000 [10000] (E) = BIOS Extension
|
||||
* 0A0000 [10000] (G) = Graphics Mode Video RAM
|
||||
* 0B0000 [08000] (M) = Monochrome Text Mode Video RAM
|
||||
* 0B8000 [08000] (C) = Color Text Mode Video RAM
|
||||
* 0C0000 [08000] (V) = Video ROM BIOS (would be "a" in PS/2)
|
||||
* 0C8000 [18000] (a) = Adapter ROM + special-purpose RAM (free UMA space)
|
||||
* 0E0000 [10000] (r) = PS/2 Motherboard ROM BIOS (free UMA in non-PS/2)
|
||||
* 0F0000 [06000] (R) = Motherboard ROM BIOS
|
||||
* 0F6000 [08000] (b) = IBM Cassette BASIC ROM ("R" in IBM compatibles)
|
||||
* 0FD000 [02000] (R) = Motherboard ROM BIOS
|
||||
* 100000 [.....] (.) = Extended memory, program-accessible (free)
|
||||
* 100000 [0FFEF] (h) = High Memory Area (HMA)
|
||||
*
|
||||
*
|
||||
* Conventional (Base) Memory:
|
||||
*
|
||||
* : [~~~~~16 KB~~~~][~~~~~16 KB~~~~][~~~~~16 KB~~~~][~~~~~16 KB~~~~]
|
||||
* : 0---1---2---3---4---5---6---7---8---9---A---B---C---D---E---F---
|
||||
* 000000: IBW.............................................................
|
||||
* 010000: cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
|
||||
* 020000: ................................................................
|
||||
* 030000: ................................................................
|
||||
* 040000: ................................................................
|
||||
* 050000: ................................................................
|
||||
* 060000: ................................................................
|
||||
* 070000: ................................................................
|
||||
* 080000: ................................................................
|
||||
* 090000: EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
|
||||
*
|
||||
* Upper Memory Area (UMA):
|
||||
*
|
||||
* : 0---1---2---3---4---5---6---7---8---9---A---B---C---D---E---F---
|
||||
* 0A0000: GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
|
||||
* 0B0000: MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
|
||||
* 0C0000: VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
* 0D0000: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
* 0E0000: rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
|
||||
* 0F0000: RRRRRRRRRRRRRRRRRRRRRRRRbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbRRRRRRRR
|
||||
*
|
||||
* Extended Memory:
|
||||
*
|
||||
* : 0---1---2---3---4---5---6---7---8---9---A---B---C---D---E---F---
|
||||
* 100000: hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh.
|
||||
* 110000: ................................................................
|
||||
* 120000: ................................................................
|
||||
* 130000: ................................................................
|
||||
* 140000: ................................................................
|
||||
* 150000: ................................................................
|
||||
* 160000: ................................................................
|
||||
* 170000: ................................................................
|
||||
*
|
||||
* Source: The logical memory map was partly taken from the book "Upgrading
|
||||
* & Repairing PCs Eight Edition", Macmillan Computer Publishing.
|
||||
*/
|
||||
|
||||
|
||||
/* The bottom part of conventional or base memory is occupied by BIOS data.
|
||||
* The BIOS memory can be distinguished in two parts:
|
||||
* o The first the first 1024 bytes of addressable memory contains the BIOS
|
||||
* real-mode interrupt vector table (IVT). The table is used to access BIOS
|
||||
* hardware services in real-mode by loading a interrupt vector and issuing
|
||||
* an INT instruction. Some vectors contain BIOS data that can be retrieved
|
||||
* directly and are useful in protected-mode as well.
|
||||
* o The BIOS data area is located directly above the interrupt vectors. It
|
||||
* comprises 256 bytes of memory. These data are used by the device drivers
|
||||
* to retrieve hardware details, such as I/O ports to be used.
|
||||
*/
|
||||
#define BIOS_MEM_BEGIN 0x00000 /* all BIOS memory */
|
||||
#define BIOS_MEM_END 0x004FF
|
||||
#define BIOS_IVT_BEGIN 0x00000 /* BIOS interrupt vectors */
|
||||
#define BIOS_IVT_END 0x003FF
|
||||
#define BIOS_DATA_BEGIN 0x00400 /* BIOS data area */
|
||||
#define BIOS_DATA_END 0x004FF
|
||||
|
||||
/* The base memory is followed by 384 KB reserved memory located at the top of
|
||||
* the first MB of physical memory. This memory is known as the upper memory
|
||||
* area (UMA). It is used for memory-mapped peripherals, such as video RAM,
|
||||
* adapter BIOS (adapter ROM and special purpose RAM), and the motherboard
|
||||
* BIOS (I/O system, Power-On Self Test, bootstrap loader). The upper memory
|
||||
* can roughly be distinguished in three parts:
|
||||
*
|
||||
* o The first 128K of the upper memory area (A0000-BFFFF) is reserved for use
|
||||
* by memory-mapped video adapters. Hence, it is also called Video RAM. The
|
||||
* display driver can directly write to this memory and request the hardware
|
||||
* to show the data on the screen.
|
||||
*/
|
||||
#define UMA_VIDEO_RAM_BEGIN 0xA0000 /* video RAM */
|
||||
#define UMA_VIDEO_RAM_END 0xBFFFF
|
||||
#define UMA_GRAPHICS_RAM_BEGIN 0xA0000 /* graphics RAM */
|
||||
#define UMA_GRAPHICS_RAM_END 0xAFFFF
|
||||
#define UMA_MONO_TEXT_BEGIN 0xB0000 /* monochrome text */
|
||||
#define UMA_MONO_TEXT_END 0xB7FFF
|
||||
#define UMA_COLOR_TEXT_BEGIN 0xB8000 /* color text */
|
||||
#define UMA_COLOR_TEXT_END 0xBFFFF
|
||||
|
||||
/* o The next 128K (the memory range C0000-DFFFF) is reserved for the adapter
|
||||
* BIOS that resides in the ROM on some adapter boards. Most VGA-compatible
|
||||
* video adapters use the first 32 KB of this area for their on-board BIOS.
|
||||
* The rest can be used by any other adapters. The IDE controller often
|
||||
* occupies the second 32 KB.
|
||||
*/
|
||||
#define UMA_ADAPTER_BIOS_BEGIN 0xC0000 /* adapter BIOS */
|
||||
#define UMA_ADAPTER_BIOS_END 0xDFFFF
|
||||
#define UMA_VIDEO_BIOS_BEGIN 0xC0000 /* video adapter */
|
||||
#define UMA_VIDEO_BIOS_END 0xC7FFF
|
||||
#define UMA_IDE_HD_BIOS_BEGIN 0xC8000 /* IDE hard disk */
|
||||
#define UMA_IDE_HD_BIOS_END 0xCBFFF
|
||||
|
||||
/* o The last 128K of the upper memory area (E0000-FFFFF) is reserved for
|
||||
* motherboard BIOS (Basic I/O System). The POST (Power-On Self Test) and
|
||||
* bootstrap loader also reside in this space. The memory falls apart in
|
||||
* two areas: Plug & Play BIOS data and the system BIOS data.
|
||||
*/
|
||||
#define UMA_MB_BIOS_BEGIN 0xE0000 /* motherboard BIOS */
|
||||
#define UMA_MB_BIOS_END 0xFFFFF
|
||||
#define UMA_PNP_ESCD_BIOS_BEGIN 0xE0000 /* PnP extended data */
|
||||
#define UMA_PNP_ESCD_BIOS_END 0xEFFFF
|
||||
#define UMA_SYSTEM_BIOS_BEGIN 0xF0000 /* system BIOS */
|
||||
#define UMA_SYSTEM_BIOS_END 0xFFFFF
|
||||
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
#ifndef __MULTIBOOT_H__
|
||||
#define __MULTIBOOT_H__
|
||||
|
||||
#define MULTIBOOT_HEADER_MAGIC 0x1BADB002
|
||||
|
||||
#define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002
|
||||
|
||||
/* Must pass memory information to OS. */
|
||||
#define MULTIBOOT_PAGE_ALIGN 0x00000001
|
||||
|
||||
#define MULTIBOOT_MEMORY_INFO 0x00000002
|
||||
|
||||
#define MULTIBOOT_VIDEO_MODE 0x00000004
|
||||
|
||||
#define MULTIBOOT_AOUT_KLUDGE 0x00010000
|
||||
|
||||
#define MULTIBOOT_FLAGS (MULTIBOOT_MEMORY_INFO | MULTIBOOT_PAGE_ALIGN)
|
||||
|
||||
/* consts used for Multiboot pre-init */
|
||||
|
||||
#define MULTIBOOT_VIDEO_MODE_EGA 1
|
||||
|
||||
#define MULTIBOOT_VIDEO_BUFFER 0xB8000
|
||||
|
||||
/* Usable lower memory chunk has a upper bound */
|
||||
#define MULTIBOOT_LOWER_MEM_MAX 0x7f800
|
||||
|
||||
#define MULTIBOOT_CONSOLE_LINES 25
|
||||
#define MULTIBOOT_CONSOLE_COLS 80
|
||||
|
||||
|
||||
#define MULTIBOOT_STACK_SIZE 4096
|
||||
#define MULTIBOOT_PARAM_BUF_SIZE 1024
|
||||
|
||||
/* Flags to be set in the ’flags’ member of the multiboot info structure. */
|
||||
|
||||
#define MULTIBOOT_INFO_MEMORY 0x00000001
|
||||
|
||||
/* Is there a boot device set? */
|
||||
#define MULTIBOOT_INFO_BOOTDEV 0x00000002
|
||||
|
||||
/* Is the command-line defined? */
|
||||
#define MULTIBOOT_INFO_CMDLINE 0x00000004
|
||||
|
||||
/* Are there modules to do something with? */
|
||||
#define MULTIBOOT_INFO_MODS 0x00000008
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#include <minix/types.h>
|
||||
/* The symbol table for a.out. */
|
||||
struct multiboot_aout_symbol_table
|
||||
{
|
||||
u32_t tabsize;
|
||||
u32_t strsize;
|
||||
u32_t addr;
|
||||
u32_t reserved;
|
||||
};
|
||||
/* The section header table for ELF. */
|
||||
struct multiboot_elf_section_header_table
|
||||
{
|
||||
u32_t num;
|
||||
u32_t size;
|
||||
u32_t addr;
|
||||
u32_t shndx;
|
||||
};
|
||||
|
||||
typedef struct multiboot_elf_section_header_table multiboot_elf_section_header_table_t;
|
||||
typedef struct multiboot_aout_symbol_table multiboot_aout_symbol_table_t;
|
||||
|
||||
struct multiboot_info
|
||||
{
|
||||
/* Multiboot info version number */
|
||||
u32_t flags;
|
||||
/* Available memory from BIOS */
|
||||
u32_t mem_lower;
|
||||
u32_t mem_upper;
|
||||
/* "root" partition */
|
||||
u32_t boot_device;
|
||||
/* Kernel command line */
|
||||
u32_t cmdline;
|
||||
/* Boot-Module list */
|
||||
u32_t mods_count;
|
||||
u32_t mods_addr;
|
||||
union
|
||||
{
|
||||
multiboot_aout_symbol_table_t aout_sym;
|
||||
multiboot_elf_section_header_table_t elf_sec;
|
||||
} u;
|
||||
/* Memory Mapping buffer */
|
||||
u32_t mmap_length;
|
||||
u32_t mmap_addr;
|
||||
/* Drive Info buffer */
|
||||
u32_t drives_length;
|
||||
u32_t drives_addr;
|
||||
/* ROM configuration table */
|
||||
u32_t config_table;
|
||||
/* Boot Loader Name */
|
||||
u32_t boot_loader_name;
|
||||
/* APM table */
|
||||
u32_t apm_table;
|
||||
/* Video */
|
||||
u32_t vbe_control_info;
|
||||
u32_t vbe_mode_info;
|
||||
u16_t vbe_mode;
|
||||
u16_t vbe_interface_seg;
|
||||
u16_t vbe_interface_off;
|
||||
u16_t vbe_interface_len;
|
||||
};
|
||||
typedef struct multiboot_info multiboot_info_t;
|
||||
|
||||
struct multiboot_mod_list
|
||||
{
|
||||
/* Memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */
|
||||
u32_t mod_start;
|
||||
u32_t mod_end;
|
||||
/* Module command line */
|
||||
u32_t cmdline;
|
||||
/* Pad struct to 16 bytes (must be zero) */
|
||||
u32_t pad;
|
||||
};
|
||||
typedef struct multiboot_mod_list multiboot_module_t;
|
||||
|
||||
/* Buffer for multiboot parameters */
|
||||
extern char multiboot_param_buf[];
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __MULTIBOOT_H__ */
|
||||
@@ -0,0 +1,3 @@
|
||||
/* $NetBSD: mutex.h,v 1.2 2007/02/09 21:55:05 ad Exp $ */
|
||||
|
||||
#include <x86/mutex.h>
|
||||
@@ -0,0 +1,26 @@
|
||||
/* Description of entry in partition table. */
|
||||
#ifndef _PARTITION_H
|
||||
#define _PARTITION_H
|
||||
|
||||
struct part_entry {
|
||||
unsigned char bootind; /* boot indicator 0/ACTIVE_FLAG */
|
||||
unsigned char start_head; /* head value for first sector */
|
||||
unsigned char start_sec; /* sector value + cyl bits for first sector */
|
||||
unsigned char start_cyl; /* track value for first sector */
|
||||
unsigned char sysind; /* system indicator */
|
||||
unsigned char last_head; /* head value for last sector */
|
||||
unsigned char last_sec; /* sector value + cyl bits for last sector */
|
||||
unsigned char last_cyl; /* track value for last sector */
|
||||
unsigned long lowsec; /* logical first sector */
|
||||
unsigned long size; /* size of partition in sectors */
|
||||
};
|
||||
|
||||
#define ACTIVE_FLAG 0x80 /* value for active in bootind field (hd0) */
|
||||
#define NR_PARTITIONS 4 /* number of entries in partition table */
|
||||
#define PART_TABLE_OFF 0x1BE /* offset of partition table in boot sector */
|
||||
|
||||
/* Partition types. */
|
||||
#define NO_PART 0x00 /* unused entry */
|
||||
#define MINIX_PART 0x81 /* Minix partition type */
|
||||
|
||||
#endif /* _PARTITION_H */
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
pci.h
|
||||
|
||||
Created: Jan 2000 by Philip Homburg <philip@cs.vu.nl>
|
||||
*/
|
||||
|
||||
/* Header type 00, normal PCI devices */
|
||||
#define PCI_VID 0x00 /* Vendor ID, 16-bit */
|
||||
#define PCI_DID 0x02 /* Device ID, 16-bit */
|
||||
#define PCI_CR 0x04 /* Command Register, 16-bit */
|
||||
#define PCI_CR_MAST_EN 0x0004 /* Enable Busmaster Access */
|
||||
#define PCI_CR_MEM_EN 0x0002 /* Enable Mem Cycles */
|
||||
#define PCI_CR_IO_EN 0x0001 /* Enable I/O Cycles */
|
||||
#define PCI_SR 0x06 /* PCI status, 16-bit */
|
||||
#define PSR_SSE 0x4000 /* Signaled System Error */
|
||||
#define PSR_RMAS 0x2000 /* Received Master Abort Status */
|
||||
#define PSR_RTAS 0x1000 /* Received Target Abort Status */
|
||||
#define PSR_CAPPTR 0x0010 /* Capabilities list */
|
||||
#define PCI_REV 0x08 /* Revision ID */
|
||||
#define PCI_PIFR 0x09 /* Prog. Interface Register */
|
||||
#define PCI_SCR 0x0A /* Sub-Class Register */
|
||||
#define PCI_BCR 0x0B /* Base-Class Register */
|
||||
#define PCI_CLS 0x0C /* Cache Line Size */
|
||||
#define PCI_LT 0x0D /* Latency Timer */
|
||||
#define PCI_HEADT 0x0E /* Header type, 8-bit */
|
||||
#define PHT_MASK 0x7F /* Header type mask */
|
||||
#define PHT_NORMAL 0x00
|
||||
#define PHT_BRIDGE 0x01
|
||||
#define PHT_CARDBUS 0x02
|
||||
#define PHT_MULTIFUNC 0x80 /* Multiple functions */
|
||||
#define PCI_BIST 0x0F /* Built-in Self Test */
|
||||
#define PCI_BAR 0x10 /* Base Address Register */
|
||||
#define PCI_BAR_IO 0x00000001 /* Reg. refers to I/O space */
|
||||
#define PCI_BAR_TYPE 0x00000006 /* Memory BAR type */
|
||||
#define PCI_TYPE_32 0x00000000 /* 32-bit BAR */
|
||||
#define PCI_TYPE_32_1M 0x00000002 /* 32-bit below 1MB (legacy) */
|
||||
#define PCI_TYPE_64 0x00000004 /* 64-bit BAR */
|
||||
#define PCI_BAR_PREFETCH 0x00000008 /* Memory is prefetchable */
|
||||
#define PCI_BAR_IO_MASK 0xFFFFFFFC /* I/O address mask */
|
||||
#define PCI_BAR_MEM_MASK 0xFFFFFFF0 /* Memory address mask */
|
||||
#define PCI_BAR_2 0x14 /* Base Address Register */
|
||||
#define PCI_BAR_3 0x18 /* Base Address Register */
|
||||
#define PCI_BAR_4 0x1C /* Base Address Register */
|
||||
#define PCI_BAR_5 0x20 /* Base Address Register */
|
||||
#define PCI_BAR_6 0x24 /* Base Address Register */
|
||||
#define PCI_CBCISPTR 0x28 /* Cardbus CIS Pointer */
|
||||
#define PCI_SUBVID 0x2C /* Subsystem Vendor ID */
|
||||
#define PCI_SUBDID 0x2E /* Subsystem Device ID */
|
||||
#define PCI_EXPROM 0x30 /* Expansion ROM Base Address */
|
||||
#define PCI_CAPPTR 0x34 /* Capabilities Pointer */
|
||||
#define PCI_CP_MASK 0xfc /* Lower 2 bits should be ignored */
|
||||
#define PCI_ILR 0x3C /* Interrupt Line Register */
|
||||
#define PCI_ILR_UNKNOWN 0xFF /* IRQ is unassigned or unknown */
|
||||
#define PCI_IPR 0x3D /* Interrupt Pin Register */
|
||||
#define PCI_MINGNT 0x3E /* Min Grant */
|
||||
#define PCI_MAXLAT 0x3F /* Max Latency */
|
||||
|
||||
/* Header type 01, PCI-to-PCI bridge devices */
|
||||
/* The following registers are in common with type 00:
|
||||
* PCI_VID, PCI_DID, PCI_CR, PCI_SR, PCI_REV, PCI_PIFR, PCI_SCR, PCI_BCR,
|
||||
* PCI_CLS, PCI_LT, PCI_HEADT, PCI_BIST, PCI_BAR, PCI_BAR2, PCI_CAPPTR,
|
||||
* PCI_ILR, PCI_IPR.
|
||||
*/
|
||||
#define PPB_PRIMBN 0x18 /* Primary Bus Number */
|
||||
#define PPB_SECBN 0x19 /* Secondary Bus Number */
|
||||
#define PPB_SUBORDBN 0x1A /* Subordinate Bus Number */
|
||||
#define PPB_SECBLT 0x1B /* Secondary Bus Latency Timer */
|
||||
#define PPB_IOBASE 0x1C /* I/O Base */
|
||||
#define PPB_IOB_MASK 0xf0
|
||||
#define PPB_IOLIMIT 0x1D /* I/O Limit */
|
||||
#define PPB_IOL_MASK 0xf0
|
||||
#define PPB_SSTS 0x1E /* Secondary Status Register */
|
||||
#define PPB_MEMBASE 0x20 /* Memory Base */
|
||||
#define PPB_MEMB_MASK 0xfff0
|
||||
#define PPB_MEMLIMIT 0x22 /* Memory Limit */
|
||||
#define PPB_MEML_MASK 0xfff0
|
||||
#define PPB_PFMEMBASE 0x24 /* Prefetchable Memory Base */
|
||||
#define PPB_PFMEMB_MASK 0xfff0
|
||||
#define PPB_PFMEMLIMIT 0x26 /* Prefetchable Memory Limit */
|
||||
#define PPB_PFMEML_MASK 0xfff0
|
||||
#define PPB_PFMBU32 0x28 /* Prefetchable Memory Base Upper 32 */
|
||||
#define PPB_PFMLU32 0x2C /* Prefetchable Memory Limit Upper 32 */
|
||||
#define PPB_IOBASEU16 0x30 /* I/O Base Upper 16 */
|
||||
#define PPB_IOLIMITU16 0x32 /* I/O Limit Upper 16 */
|
||||
#define PPB_EXPROM 0x38 /* Expansion ROM Base Address */
|
||||
#define PPB_BRIDGECTRL 0x3E /* Bridge Control */
|
||||
#define PPB_BC_CRST 0x40 /* Assert reset line */
|
||||
|
||||
/* Header type 02, Cardbus bridge devices */
|
||||
/* The following registers are in common with type 00:
|
||||
* PCI_VID, PCI_DID, PCI_CR, PCI_SR, PCI_REV, PCI_PIFR, PCI_SCR, PCI_BCR,
|
||||
* PCI_CLS, PCI_LT, PCI_HEADT, PCI_BIST, PCI_BAR, PCI_ILR, PCI_IPR.
|
||||
*/
|
||||
/* The following registers are in common with type 01:
|
||||
* PPB_PRIMBN, PPB_SECBN, PPB_SUBORDBN, PPB_SECBLT.
|
||||
*/
|
||||
#define CBB_CAPPTR 0x14 /* Capability Pointer */
|
||||
#define CBB_SSTS 0x16 /* Secondary Status Register */
|
||||
#define CBB_MEMBASE_0 0x1C /* Memory Base 0 */
|
||||
#define CBB_MEMLIMIT_0 0x20 /* Memory Limit 0 */
|
||||
#define CBB_MEML_MASK 0xfffff000
|
||||
#define CBB_MEMBASE_1 0x24 /* Memory Base 1 */
|
||||
#define CBB_MEMLIMIT_1 0x28 /* Memory Limit 1 */
|
||||
#define CBB_IOBASE_0 0x2C /* I/O Base 0 */
|
||||
#define CBB_IOLIMIT_0 0x30 /* I/O Limit 0 */
|
||||
#define CBB_IOL_MASK 0xfffffffc
|
||||
#define CBB_IOBASE_1 0x34 /* I/O Base 1 */
|
||||
#define CBB_IOLIMIT_1 0x38 /* I/O Limit 1 */
|
||||
#define CBB_BRIDGECTRL 0x3E /* Bridge Control */
|
||||
#define CBB_BC_INTEXCA 0x80 /* Interrupt are routed to ExCAs */
|
||||
#define CBB_BC_CRST 0x40 /* Assert reset line */
|
||||
|
||||
#define CAP_TYPE 0x00 /* Type field in capability */
|
||||
#define CAP_NEXT 0x01 /* Next field in capability */
|
||||
|
||||
#define PCI_BCR_MASS_STORAGE 0x01 /* Mass Storage class */
|
||||
#define PCI_MS_IDE 0x01 /* IDE storage class */
|
||||
#define PCI_IDE_PRI_NATIVE 0x01 /* Primary channel is
|
||||
* in native mode.
|
||||
*/
|
||||
#define PCI_IDE_SEC_NATIVE 0x04 /* Secondary channel is
|
||||
* in native mode.
|
||||
*/
|
||||
|
||||
/* Device type values as ([PCI_BCR] << 16) | ([PCI_SCR] << 8) | [PCI_PIFR] */
|
||||
#define PCI_T3_VGA_OLD 0x000100 /* OLD VGA class code */
|
||||
#define PCI_T3_RAID 0x010400 /* RAID controller */
|
||||
#define PCI_T3_AHCI 0x010601 /* AHCI controller */
|
||||
#define PCI_T3_VGA 0x030000 /* VGA-compatible video card */
|
||||
#define PCI_T3_ISA 0x060100 /* ISA bridge */
|
||||
#define PCI_T3_PCI2PCI 0x060400 /* PCI-to-PCI Bridge device */
|
||||
#define PCI_T3_PCI2PCI_SUBTR 0x060401 /* Subtr. PCI-to-PCI Bridge */
|
||||
#define PCI_T3_CARDBUS 0x060700 /* Bardbus Bridge */
|
||||
|
||||
#define NO_VID 0xffff /* No PCI card present */
|
||||
|
||||
/* Capabilities */
|
||||
#define CAP_T_SECURE_DEV 0x0f /* (AMD) Secure device
|
||||
* capability
|
||||
*/
|
||||
#define CAP_SD_INFO 2 /* Offset from CAP ptr */
|
||||
#define CAP_SD_SUBTYPE_MASK 0x0f /* Mask for subtype */
|
||||
#define CAP_T_SD_DEV 0 /* AMD DEV */
|
||||
|
||||
/*
|
||||
* $PchId: pci.h,v 1.4 2001/12/06 20:21:22 philip Exp $
|
||||
*/
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
pci_amd.h
|
||||
|
||||
Created: Nov 2001 by Philip Homburg <philip@cs.vu.nl>
|
||||
*/
|
||||
|
||||
#define AMD_ISABR_FUNC 3 /* Registers are in function 3 */
|
||||
#define AMD_ISABR_PCIIRQ_LEV 0x54
|
||||
#define AMD_PCILEV_INTA 0x1
|
||||
#define AMD_PCILEV_INTB 0x2
|
||||
#define AMD_PCILEV_INTC 4x2
|
||||
#define AMD_PCILEV_INTD 4x8
|
||||
#define AMD_ISABR_PCIIRQ_ROUTE 0x56
|
||||
#define AMD_PCIIRQ_INTA_MASK 0x000F
|
||||
#define AMD_PCIIRQ_INTB_MASK 0x00F0
|
||||
#define AMD_PCIIRQ_INTC_MASK 0x0F00
|
||||
#define AMD_PCIIRQ_INTD_MASK 0xF000
|
||||
|
||||
/*
|
||||
* $PchId: pci_amd.h,v 1.1 2001/11/09 19:57:37 philip Exp $
|
||||
*/
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
pci_intel.h
|
||||
|
||||
Created: Jan 2000 by Philip Homburg <philip@cs.vu.nl>
|
||||
*/
|
||||
|
||||
#define PCII_CONFADD 0xCF8
|
||||
#define PCIIC_CODE 0x80000000
|
||||
#define PCIIC_BUSNUM_MASK 0xff0000
|
||||
#define PCIIC_BUSNUM_SHIFT 16
|
||||
#define PCIIC_DEVNUM_MASK 0xf800
|
||||
#define PCIIC_DEVNUM_SHIFT 11
|
||||
#define PCIIC_FUNCNUM_MASK 0x700
|
||||
#define PCIIC_FUNCNUM_SHIFT 8
|
||||
#define PCIIC_REGNUM_MASK 0xfc
|
||||
#define PCIIC_REGNUM_SHIFT 2
|
||||
#define PCII_CONFDATA 0xCFC
|
||||
|
||||
#define PCII_SELREG_(bus, dev, func, reg) \
|
||||
(PCIIC_CODE | \
|
||||
(((bus) << PCIIC_BUSNUM_SHIFT) & PCIIC_BUSNUM_MASK) | \
|
||||
(((dev) << PCIIC_DEVNUM_SHIFT) & PCIIC_DEVNUM_MASK) | \
|
||||
(((func) << PCIIC_FUNCNUM_SHIFT) & PCIIC_FUNCNUM_MASK) | \
|
||||
((((reg)/4) << PCIIC_REGNUM_SHIFT) & PCIIC_REGNUM_MASK))
|
||||
#define PCII_UNSEL (0)
|
||||
|
||||
#define PCII_RREG8_(bus, dev, func, reg) \
|
||||
(pci_outl(PCII_CONFADD, PCII_SELREG_(bus, dev, func, reg)), \
|
||||
pci_inb(PCII_CONFDATA+((reg)&3)))
|
||||
#define PCII_RREG16_(bus, dev, func, reg) \
|
||||
(pci_outl(PCII_CONFADD, PCII_SELREG_(bus, dev, func, reg)), \
|
||||
pci_inw(PCII_CONFDATA+((reg)&2)))
|
||||
#define PCII_RREG32_(bus, dev, func, reg) \
|
||||
(pci_outl(PCII_CONFADD, PCII_SELREG_(bus, dev, func, reg)), \
|
||||
pci_inl(PCII_CONFDATA))
|
||||
|
||||
#define PCII_WREG8_(bus, dev, func, reg, val) \
|
||||
(pci_outl(PCII_CONFADD, PCII_SELREG_(bus, dev, func, reg)), \
|
||||
pci_outb(PCII_CONFDATA+((reg)&3), (val)))
|
||||
#define PCII_WREG16_(bus, dev, func, reg, val) \
|
||||
(pci_outl(PCII_CONFADD, PCII_SELREG_(bus, dev, func, reg)), \
|
||||
pci_outw(PCII_CONFDATA+((reg)&2), (val)))
|
||||
#define PCII_WREG32_(bus, dev, func, reg, val) \
|
||||
(pci_outl(PCII_CONFADD, PCII_SELREG_(bus, dev, func, reg)), \
|
||||
pci_outl(PCII_CONFDATA, (val)))
|
||||
|
||||
/* PIIX configuration registers */
|
||||
#define PIIX_PIRQRCA 0x60
|
||||
#define PIIX_IRQ_DI 0x80
|
||||
#define PIIX_IRQ_MASK 0x0F
|
||||
|
||||
/* PIIX extensions to the PIC */
|
||||
#define PIIX_ELCR1 0x4D0
|
||||
#define PIIX_ELCR2 0x4D1
|
||||
|
||||
/*
|
||||
* $PchId: pci_intel.h,v 1.1 2000/08/12 11:20:17 philip Exp $
|
||||
*/
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
pci_sis.h
|
||||
|
||||
Created: Nov 2001 by Philip Homburg <philip@cs.vu.nl>
|
||||
*/
|
||||
|
||||
/* Constants are taken from pci-irq.c in the Linux kernel source */
|
||||
#define SIS_ISABR_IRQ_A 0x41 /* IRQA routing */
|
||||
#define SIS_ISABR_IRQ_B 0x42 /* IRQB routing */
|
||||
#define SIS_ISABR_IRQ_C 0x43 /* IRQC routing */
|
||||
#define SIS_ISABR_IRQ_D 0x44 /* IRQD routing */
|
||||
#define SIS_IRQ_DISABLED 0x80
|
||||
#define SIS_IRQ_MASK 0x0F
|
||||
|
||||
/*
|
||||
* $PchId: pci_sis.h,v 1.1 2001/12/06 20:22:52 philip Exp $
|
||||
*/
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
pci_via.h
|
||||
|
||||
Created: Jun 2001 by Philip Homburg <philip@cs.vu.nl>
|
||||
*/
|
||||
|
||||
#define VIA_ISABR_EL 0x54 /* Edge or level triggered */
|
||||
#define VIA_ISABR_EL_INTA 0x08 /* Edge (1) or level (0) */
|
||||
#define VIA_ISABR_EL_INTB 0x04
|
||||
#define VIA_ISABR_EL_INTC 0x02
|
||||
#define VIA_ISABR_EL_INTD 0x01
|
||||
|
||||
#define VIA_ISABR_IRQ_R1 0x55 /* IRQ routing 1 */
|
||||
#define VIA_ISABR_IRQ_INTD 0xf0 /* routing for INTD */
|
||||
#define VIA_ISABR_IRQ_INT0 0x0f /* routing for INT0 */
|
||||
#define VIA_ISABR_IRQ_R2 0x56 /* IRQ routing 2 */
|
||||
#define VIA_ISABR_IRQ_INTA 0xf0 /* routing for INTA */
|
||||
#define VIA_ISABR_IRQ_INTB 0x0f /* routing for INTB */
|
||||
#define VIA_ISABR_IRQ_R3 0x57 /* IRQ routing 3 */
|
||||
#define VIA_ISABR_IRQ_INTC 0xf0 /* routing for INTC */
|
||||
#define VIA_ISABR_IRQ_INT1 0x0f /* routing for INT1 */
|
||||
#define VIA_ISABR_IRQ_R4 0x58 /* IRQ routing 4 */
|
||||
#define VIA_ISABR_IRQ_INT2 0x0f /* routing for INT2 */
|
||||
|
||||
/*
|
||||
* $PchId: pci_via.h,v 1.1 2001/06/20 15:50:25 philip Exp $
|
||||
*/
|
||||
@@ -0,0 +1,17 @@
|
||||
/* Addresses and magic numbers for miscellaneous ports. */
|
||||
|
||||
#ifndef _PORTS_H
|
||||
#define _PORTS_H
|
||||
|
||||
#if (CHIP == INTEL)
|
||||
|
||||
/* Miscellaneous ports. */
|
||||
#define PCR 0x65 /* Planar Control Register */
|
||||
#define PORT_B 0x61 /* I/O port for 8255 port B (kbd, beeper...) */
|
||||
#define TIMER0 0x40 /* I/O port for timer channel 0 */
|
||||
#define TIMER2 0x42 /* I/O port for timer channel 2 */
|
||||
#define TIMER_MODE 0x43 /* I/O port for timer mode control */
|
||||
|
||||
#endif /* (CHIP == INTEL) */
|
||||
|
||||
#endif /* _PORTS_H */
|
||||
@@ -0,0 +1,36 @@
|
||||
#ifndef STACK_FRAME_H
|
||||
#define STACK_FRAME_H
|
||||
|
||||
typedef unsigned reg_t; /* machine register */
|
||||
typedef reg_t segdesc_t;
|
||||
|
||||
/* The stack frame layout is determined by the software, but for efficiency
|
||||
* it is laid out so the assembly code to use it is as simple as possible.
|
||||
* 80286 protected mode and all real modes use the same frame, built with
|
||||
* 16-bit registers. Real mode lacks an automatic stack switch, so little
|
||||
* is lost by using the 286 frame for it. The 386 frame differs only in
|
||||
* having 32-bit registers and more segment registers. The same names are
|
||||
* used for the larger registers to avoid differences in the code.
|
||||
*/
|
||||
struct stackframe_s {
|
||||
u16_t gs; /* last item pushed by save */
|
||||
u16_t fs; /* ^ */
|
||||
u16_t es; /* | */
|
||||
u16_t ds; /* | */
|
||||
reg_t di; /* di through cx are not accessed in C */
|
||||
reg_t si; /* order is to match pusha/popa */
|
||||
reg_t fp; /* bp */
|
||||
reg_t st; /* hole for another copy of sp */
|
||||
reg_t bx; /* | */
|
||||
reg_t dx; /* | */
|
||||
reg_t cx; /* | */
|
||||
reg_t retreg; /* ax and above are all pushed by save */
|
||||
reg_t retadr; /* return address for assembly code save() */
|
||||
reg_t pc; /* ^ last item pushed by interrupt */
|
||||
reg_t cs; /* | */
|
||||
reg_t psw; /* | */
|
||||
reg_t sp; /* | */
|
||||
reg_t ss; /* these are pushed by CPU during interrupt */
|
||||
};
|
||||
|
||||
#endif /* #ifndef STACK_FRAME_H */
|
||||
@@ -0,0 +1,98 @@
|
||||
#ifndef __SYS_VM_386_H__
|
||||
#define __SYS_VM_386_H__
|
||||
/*
|
||||
i386/vm.h
|
||||
*/
|
||||
|
||||
#define I386_PAGE_SIZE 4096
|
||||
#define I386_BIG_PAGE_SIZE (I386_PAGE_SIZE*I386_VM_PT_ENTRIES)
|
||||
|
||||
/* i386 paging constants */
|
||||
#define I386_VM_PRESENT 0x001 /* Page is present */
|
||||
#define I386_VM_WRITE 0x002 /* Read/write access allowed */
|
||||
#define I386_VM_USER 0x004 /* User access allowed */
|
||||
#define I386_VM_PWT 0x008 /* Write through */
|
||||
#define I386_VM_PCD 0x010 /* Cache disable */
|
||||
#define I386_VM_ACC 0x020 /* Accessed */
|
||||
#define I386_VM_ADDR_MASK 0xFFFFF000 /* physical address */
|
||||
#define I386_VM_ADDR_MASK_4MB 0xFFC00000 /* physical address */
|
||||
#define I386_VM_OFFSET_MASK_4MB 0x003FFFFF /* physical address */
|
||||
|
||||
/* Page directory specific flags. */
|
||||
#define I386_VM_BIGPAGE 0x080 /* 4MB page */
|
||||
|
||||
/* Page table specific flags. */
|
||||
#define I386_VM_DIRTY (1L<< 6) /* Dirty */
|
||||
#define I386_VM_PS (1L<< 7) /* Page size. */
|
||||
#define I386_VM_GLOBAL (1L<< 8) /* Global. */
|
||||
#define I386_VM_PTAVAIL1 (1L<< 9) /* Available for use. */
|
||||
#define I386_VM_PTAVAIL2 (1L<<10) /* Available for use. */
|
||||
#define I386_VM_PTAVAIL3 (1L<<11) /* Available for use. */
|
||||
|
||||
#define I386_VM_PT_ENT_SIZE 4 /* Size of a page table entry */
|
||||
#define I386_VM_DIR_ENTRIES 1024 /* Number of entries in a page dir */
|
||||
#define I386_VM_DIR_ENT_SHIFT 22 /* Shift to get entry in page dir. */
|
||||
#define I386_VM_PT_ENT_SHIFT 12 /* Shift to get entry in page table */
|
||||
#define I386_VM_PT_ENT_MASK 0x3FF /* Mask to get entry in page table */
|
||||
#define I386_VM_PT_ENTRIES 1024 /* Number of entries in a page table */
|
||||
#define I386_VM_PFA_SHIFT 22 /* Page frame address shift */
|
||||
|
||||
/* CR0 bits */
|
||||
#define I386_CR0_PE 0x00000001 /* Protected mode */
|
||||
#define I386_CR0_MP 0x00000002 /* Monitor Coprocessor */
|
||||
#define I386_CR0_EM 0x00000004 /* Emulate */
|
||||
#define I386_CR0_TS 0x00000008 /* Task Switched */
|
||||
#define I386_CR0_ET 0x00000010 /* Extension Type */
|
||||
#define I386_CR0_WP 0x00010000 /* Enable paging */
|
||||
#define I386_CR0_PG 0x80000000 /* Enable paging */
|
||||
|
||||
/* some CR4 bits */
|
||||
#define I386_CR4_VME 0x00000001 /* Virtual 8086 */
|
||||
#define I386_CR4_PVI 0x00000002 /* Virtual ints */
|
||||
#define I386_CR4_TSD 0x00000004 /* RDTSC privileged */
|
||||
#define I386_CR4_DE 0x00000008 /* Debugging extensions */
|
||||
#define I386_CR4_PSE 0x00000010 /* Page size extensions */
|
||||
#define I386_CR4_PAE 0x00000020 /* Physical addr extens. */
|
||||
#define I386_CR4_MCE 0x00000040 /* Machine check enable */
|
||||
#define I386_CR4_PGE 0x00000080 /* Global page flag enable */
|
||||
|
||||
/* i386 paging 'functions' */
|
||||
#define I386_VM_PTE(v) (((v) >> I386_VM_PT_ENT_SHIFT) & I386_VM_PT_ENT_MASK)
|
||||
#define I386_VM_PDE(v) ( (v) >> I386_VM_DIR_ENT_SHIFT)
|
||||
#define I386_VM_PFA(e) ( (e) & I386_VM_ADDR_MASK)
|
||||
#define I386_VM_PAGE(v) ( (v) >> I386_VM_PFA_SHIFT)
|
||||
|
||||
/* i386 pagefault error code bits */
|
||||
#define I386_VM_PFE_P 0x01 /* Pagefault caused by non-present page.
|
||||
* (otherwise protection violation.)
|
||||
*/
|
||||
#define I386_VM_PFE_W 0x02 /* Caused by write (otherwise read) */
|
||||
#define I386_VM_PFE_U 0x04 /* CPU in user mode (otherwise supervisor) */
|
||||
|
||||
/* CPUID flags */
|
||||
#define CPUID1_EDX_FPU (1L) /* FPU presence */
|
||||
#define CPUID1_EDX_PSE (1L << 3) /* Page Size Extension */
|
||||
#define CPUID1_EDX_PGE (1L << 13) /* Page Global (bit) Enable */
|
||||
#define CPUID1_EDX_APIC_ON_CHIP (1L << 9) /* APIC is present on the chip */
|
||||
#define CPUID1_EDX_TSC (1L << 4) /* Timestamp counter present */
|
||||
#define CPUID1_EDX_HTT (1L << 28) /* Supports HTT */
|
||||
#define CPUID1_EDX_FXSR (1L << 24)
|
||||
#define CPUID1_EDX_SSE (1L << 25)
|
||||
#define CPUID1_EDX_SSE2 (1L << 26)
|
||||
#define CPUID1_ECX_SSE3 (1L)
|
||||
#define CPUID1_ECX_SSSE3 (1L << 9)
|
||||
#define CPUID1_ECX_SSE4_1 (1L << 19)
|
||||
#define CPUID1_ECX_SSE4_2 (1L << 20)
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#include <minix/type.h>
|
||||
|
||||
/* structure used by VM to pass data to the kernel while enabling paging */
|
||||
struct vm_ep_data {
|
||||
struct mem_map * mem_map;
|
||||
vir_bytes data_seg_limit;
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* __SYS_VM_386_H__ */
|
||||
@@ -1,768 +0,0 @@
|
||||
/* $NetBSD: chfs.h,v 1.4 2011/11/28 12:50:07 ahoka Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2010 Department of Software Engineering,
|
||||
* University of Szeged, Hungary
|
||||
* Copyright (C) 2009 Ferenc Havasi <havasi@inf.u-szeged.hu>
|
||||
* Copyright (C) 2009 Zoltan Sogor <weth@inf.u-szeged.hu>
|
||||
* Copyright (C) 2009 David Tengeri <dtengeri@inf.u-szeged.hu>
|
||||
* Copyright (C) 2009 Tamas Toth <ttoth@inf.u-szeged.hu>
|
||||
* Copyright (C) 2010 Adam Hoka <ahoka@NetBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by the Department of Software Engineering, University of Szeged, Hungary
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __CHFS_H__
|
||||
#define __CHFS_H__
|
||||
|
||||
#if 0
|
||||
#define DBG_MSG
|
||||
#define DBG_MSG_GC
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/tree.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/kmem.h>
|
||||
#include <sys/endian.h>
|
||||
#include <sys/rwlock.h>
|
||||
#include <sys/condvar.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/kthread.h>
|
||||
#include <sys/rbtree.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/hash.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/dirent.h>
|
||||
|
||||
#include <ufs/ufs/quota.h>
|
||||
#include <ufs/ufs/ufsmount.h>
|
||||
#include <ufs/ufs/dir.h>
|
||||
|
||||
/* XXX shouldnt be defined here, but needed by chfs_inode.h */
|
||||
TAILQ_HEAD(chfs_dirent_list, chfs_dirent);
|
||||
|
||||
#include "chfs_pool.h"
|
||||
#include "ebh.h"
|
||||
#include "media.h"
|
||||
#include "chfs_inode.h"
|
||||
|
||||
#ifndef MOUNT_CHFS
|
||||
#define MOUNT_CHFS "chfs"
|
||||
#endif
|
||||
|
||||
#define CHFS_ROOTINO ROOTINO /* ROOTINO == 2 */
|
||||
|
||||
enum {
|
||||
VNO_STATE_UNCHECKED, /* CRC checks not yet done */
|
||||
VNO_STATE_CHECKING, /* CRC checks in progress */
|
||||
VNO_STATE_PRESENT, /* In core */
|
||||
VNO_STATE_CHECKEDABSENT,/* Checked, cleared again */
|
||||
VNO_STATE_GC, /* GCing a 'pristine' node */
|
||||
VNO_STATE_READING, /* In read_inode() */
|
||||
VNO_STATE_CLEARING /* In clear_inode() */
|
||||
};
|
||||
|
||||
#define VNODECACHE_SIZE 128
|
||||
|
||||
#define MAX_READ_FREE(chmp) (((chmp)->chm_ebh)->eb_size / 8)
|
||||
/* an eraseblock will be clean if its dirty size is smaller than this */
|
||||
#define MAX_DIRTY_TO_CLEAN 255
|
||||
#define VERY_DIRTY(chmp, size) ((size) >= (((chmp)->chm_ebh)->eb_size / 2))
|
||||
|
||||
#define CHFS_PAD(x) (((x)+3)&~3)
|
||||
|
||||
enum {
|
||||
CHFS_NODE_OK = 0,
|
||||
CHFS_NODE_BADMAGIC,
|
||||
CHFS_NODE_BADCRC,
|
||||
CHFS_NODE_BADNAMECRC
|
||||
};
|
||||
|
||||
enum {
|
||||
CHFS_BLK_STATE_FREE = 100,
|
||||
CHFS_BLK_STATE_CLEAN,
|
||||
CHFS_BLK_STATE_PARTDIRTY,
|
||||
CHFS_BLK_STATE_ALLDIRTY
|
||||
};
|
||||
|
||||
extern struct pool chfs_inode_pool;
|
||||
extern const struct genfs_ops chfs_genfsops;
|
||||
|
||||
/**
|
||||
* struct chfs_node_ref - a reference to a node
|
||||
* @lnr: logical identifier of the eraseblock where the node is
|
||||
* @offset: offset int hte eraseblock where the node starts
|
||||
* @next: used at data and dirent nodes, it points to the next data node which
|
||||
* belongs to the same vnode
|
||||
*/
|
||||
struct chfs_node_ref
|
||||
{
|
||||
struct chfs_node_ref *nref_next;
|
||||
uint32_t nref_lnr;
|
||||
uint32_t nref_offset;
|
||||
};
|
||||
|
||||
/* Constants for allocating node refs */
|
||||
#define REFS_BLOCK_LEN (255/sizeof(struct chfs_node_ref))
|
||||
#define REF_EMPTY_NODE (UINT_MAX)
|
||||
#define REF_LINK_TO_NEXT (UINT_MAX - 1)
|
||||
|
||||
enum {
|
||||
CHFS_NORMAL_NODE_MASK,
|
||||
CHFS_UNCHECKED_NODE_MASK,
|
||||
CHFS_OBSOLETE_NODE_MASK,
|
||||
CHFS_PRISTINE_NODE_MASK
|
||||
};
|
||||
|
||||
#define CHFS_REF_FLAGS(ref) ((ref)->nref_offset & 3)
|
||||
#define CHFS_REF_OBSOLETE(ref) (((ref)->nref_offset & 3) == CHFS_OBSOLETE_NODE_MASK)
|
||||
#define CHFS_MARK_REF_NORMAL(ref) \
|
||||
do { \
|
||||
(ref)->nref_offset = CHFS_GET_OFS((ref)->nref_offset) | CHFS_NORMAL_NODE_MASK; \
|
||||
} while(0)
|
||||
|
||||
#define CHFS_GET_OFS(ofs) (ofs & ~ 3)
|
||||
|
||||
static inline struct chfs_node_ref *
|
||||
node_next(struct chfs_node_ref *nref)
|
||||
{
|
||||
//dbg("node next: %u : %u\n", nref->nref_lnr, nref->nref_offset);
|
||||
nref++;
|
||||
//dbg("nref++: %u : %u\n", nref->nref_lnr, nref->nref_offset);
|
||||
|
||||
if (nref->nref_lnr == REF_LINK_TO_NEXT) {
|
||||
//dbg("link to next\n");
|
||||
nref = nref->nref_next;
|
||||
if (!nref)
|
||||
return nref;
|
||||
}
|
||||
|
||||
if (nref->nref_lnr == REF_EMPTY_NODE) {
|
||||
//dbg("empty\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return nref;
|
||||
}
|
||||
|
||||
/**
|
||||
* struct chfs_dirent - full representation of a directory entry
|
||||
*/
|
||||
struct chfs_dirent
|
||||
{
|
||||
struct chfs_node_ref *nref;
|
||||
// struct chfs_dirent *next;
|
||||
TAILQ_ENTRY(chfs_dirent) fds;
|
||||
uint64_t version;
|
||||
ino_t vno;
|
||||
uint32_t nhash;
|
||||
enum vtype type;
|
||||
uint8_t nsize;
|
||||
uint8_t name[0];
|
||||
|
||||
/* used by chfs_alloc_dirent and free counterpart */
|
||||
// size_t alloc_size;
|
||||
};
|
||||
|
||||
struct chfs_tmp_dnode {
|
||||
struct chfs_full_dnode *node;
|
||||
uint64_t version;
|
||||
uint32_t data_crc;
|
||||
//uint32_t partial_crc;
|
||||
//uint16_t csize;
|
||||
uint16_t overlapped;
|
||||
struct chfs_tmp_dnode *next;
|
||||
};
|
||||
|
||||
struct chfs_tmp_dnode_info {
|
||||
struct rb_node rb_node;
|
||||
struct chfs_tmp_dnode *tmpnode;
|
||||
};
|
||||
|
||||
struct chfs_readinode_info {
|
||||
struct rb_tree tdi_root;
|
||||
struct chfs_tmp_dnode_info *mdata_tn;
|
||||
uint64_t highest_version;
|
||||
struct chfs_node_ref *latest_ref;
|
||||
};
|
||||
|
||||
struct chfs_full_dnode {
|
||||
struct chfs_node_ref *nref;
|
||||
uint64_t ofs;
|
||||
uint32_t size;
|
||||
uint32_t frags;
|
||||
};
|
||||
|
||||
struct chfs_node_frag {
|
||||
struct rb_node rb_node;
|
||||
struct chfs_full_dnode *node;
|
||||
uint32_t size;
|
||||
uint64_t ofs;
|
||||
};
|
||||
|
||||
static inline struct chfs_node_frag *
|
||||
frag_first(struct rb_tree *tree)
|
||||
{
|
||||
struct chfs_node_frag *frag;
|
||||
|
||||
frag = (struct chfs_node_frag *)RB_TREE_MIN(tree);
|
||||
|
||||
return frag;
|
||||
}
|
||||
|
||||
static inline struct chfs_node_frag *
|
||||
frag_last(struct rb_tree *tree)
|
||||
{
|
||||
struct chfs_node_frag *frag;
|
||||
|
||||
frag = (struct chfs_node_frag *)RB_TREE_MAX(tree);
|
||||
|
||||
return frag;
|
||||
}
|
||||
|
||||
#define frag_next(tree, frag) (struct chfs_node_frag *)rb_tree_iterate(tree, frag, RB_DIR_RIGHT)
|
||||
#define frag_prev(tree, frag) (struct chfs_node_frag *)rb_tree_iterate(tree, frag, RB_DIR_LEFT)
|
||||
|
||||
|
||||
/* XXX hack
|
||||
#ifndef CHFS_FRAG_TREE
|
||||
#define CHFS_FRAG_TREE
|
||||
RB_HEAD(chfs_frag_tree, chfs_node_frag);
|
||||
#endif
|
||||
*/
|
||||
|
||||
/* for prototypes, properly defined in chfs_inode.h */
|
||||
//struct chfs_inode_ext;
|
||||
|
||||
/**
|
||||
* struct chfs_vnode_cache - in memory representation of a vnode
|
||||
* @v: pointer to the vnode info node
|
||||
* @dnode: pointer to the list of data nodes
|
||||
* @dirents: pointer to the list of directory entries
|
||||
* @vno_version: used only during scan, holds the current version number of
|
||||
* chfs_flash_vnode
|
||||
* @scan_dirents: used only during scan, holds the full representation of
|
||||
* directory entries of this vnode
|
||||
* @pvno: parent vnode number
|
||||
* @nlink: number of links to this vnode
|
||||
*/
|
||||
struct chfs_vnode_cache {
|
||||
// struct chfs_dirent *scan_dirents;
|
||||
void *p;
|
||||
struct chfs_dirent_list scan_dirents;
|
||||
|
||||
struct chfs_node_ref *v;
|
||||
struct chfs_node_ref *dnode;
|
||||
struct chfs_node_ref *dirents;
|
||||
|
||||
uint64_t *vno_version;
|
||||
uint64_t highest_version;
|
||||
|
||||
uint8_t flags;
|
||||
uint16_t state;
|
||||
ino_t vno;
|
||||
ino_t pvno;
|
||||
struct chfs_vnode_cache* next;
|
||||
uint32_t nlink;
|
||||
};
|
||||
|
||||
struct chfs_eraseblock
|
||||
{
|
||||
uint32_t lnr;
|
||||
|
||||
TAILQ_ENTRY(chfs_eraseblock) queue;
|
||||
//uint32_t bad_count;
|
||||
uint32_t unchecked_size;
|
||||
uint32_t used_size;
|
||||
uint32_t dirty_size;
|
||||
uint32_t free_size;
|
||||
uint32_t wasted_size;
|
||||
|
||||
struct chfs_node_ref *first_node;
|
||||
struct chfs_node_ref *last_node;
|
||||
|
||||
/* Next block to be garbage collected */
|
||||
struct chfs_node_ref *gc_node;
|
||||
};
|
||||
|
||||
TAILQ_HEAD(chfs_eraseblock_queue, chfs_eraseblock);
|
||||
|
||||
#define ALLOC_NORMAL 0
|
||||
#define ALLOC_DELETION 1
|
||||
#define ALLOC_GC 2
|
||||
|
||||
struct garbage_collector_thread {
|
||||
lwp_t *gcth_thread;
|
||||
kcondvar_t gcth_wakeup;
|
||||
bool gcth_running;
|
||||
};
|
||||
|
||||
#define CHFS_MP_FLAG_SCANNING 2
|
||||
#define CHFS_MP_FLAG_BUILDING 4
|
||||
|
||||
/**
|
||||
* struct chfs_mount - CHFS main descriptor structure
|
||||
* @ebh: eraseblock handler
|
||||
* @fl_index: index of flash device in the flash layer
|
||||
* @fs_version: filesystem version descriptor
|
||||
* @gbl_version: global version number
|
||||
* @max_vno: max vnode id
|
||||
* @chm_lock_mountfields:
|
||||
* @vnocache_hash: hash table of vnode caches
|
||||
* @vnocache_lock:
|
||||
* @blocks: array of eraseblocks on flash
|
||||
* @chm_root: used to protect all fields
|
||||
* @free_size: free size on the flash
|
||||
* @dirty_size: dirtied size on flash
|
||||
* @unchecked_size: size of unchecked data on flash
|
||||
* @free_queue: queue of free eraseblocks
|
||||
* @clean_queue: queue of clean eraseblocks
|
||||
* @dirty_queue: queue of dirty eraseblocks
|
||||
* @very_dirty_queue: queue of very dirty eraseblocks
|
||||
* @erase_pending_queue: queue of eraseblocks waiting for erasing
|
||||
* @erasable_pending_wbuf_queue: queue of eraseblocks waiting for erasing and
|
||||
* have data to write to them
|
||||
* @nextblock: next eraseblock to write to
|
||||
* @nr_free_blocks: number of free blocks on the free_queue
|
||||
* @nr_erasable_blocks: number of blocks that can be erased and are on the
|
||||
* erasable_queue
|
||||
*/
|
||||
struct chfs_mount {
|
||||
struct mount *chm_fsmp;
|
||||
struct chfs_ebh *chm_ebh;
|
||||
int chm_fs_version;
|
||||
uint64_t chm_gbl_version;
|
||||
ino_t chm_max_vno;
|
||||
ino_t chm_checked_vno;
|
||||
unsigned int chm_flags;
|
||||
|
||||
/* chm_lock_mountfields:
|
||||
* Used to protect all the following fields. */
|
||||
kmutex_t chm_lock_mountfields;
|
||||
|
||||
struct chfs_vnode_cache **chm_vnocache_hash;
|
||||
/* chm_lock_vnocache:
|
||||
* Used to protect the vnode cache.
|
||||
* If you have to lock chm_lock_mountfields and also chm_lock_vnocache,
|
||||
* you must lock chm_lock_mountfields first. */
|
||||
kmutex_t chm_lock_vnocache;
|
||||
|
||||
struct chfs_eraseblock *chm_blocks;
|
||||
|
||||
struct chfs_node *chm_root;
|
||||
|
||||
uint32_t chm_free_size;
|
||||
uint32_t chm_dirty_size;
|
||||
uint32_t chm_unchecked_size;
|
||||
uint32_t chm_used_size;
|
||||
uint32_t chm_wasted_size;
|
||||
/* chm_lock_sizes:
|
||||
* Used to protect the (free, used, etc.) sizes of the FS
|
||||
* (and also the sizes of each eraseblock).
|
||||
* If you have to lock chm_lock_mountfields and also chm_lock_sizes,
|
||||
* you must lock chm_lock_mountfields first. */
|
||||
kmutex_t chm_lock_sizes;
|
||||
|
||||
struct chfs_eraseblock_queue chm_free_queue;
|
||||
struct chfs_eraseblock_queue chm_clean_queue;
|
||||
struct chfs_eraseblock_queue chm_dirty_queue;
|
||||
struct chfs_eraseblock_queue chm_very_dirty_queue;
|
||||
struct chfs_eraseblock_queue chm_erasable_pending_wbuf_queue;
|
||||
struct chfs_eraseblock_queue chm_erase_pending_queue;
|
||||
|
||||
uint8_t chm_resv_blocks_deletion;
|
||||
uint8_t chm_resv_blocks_write;
|
||||
uint8_t chm_resv_blocks_gctrigger;
|
||||
uint8_t chm_resv_blocks_gcmerge;
|
||||
uint8_t chm_nospc_dirty;
|
||||
|
||||
uint8_t chm_vdirty_blocks_gctrigger;
|
||||
|
||||
struct chfs_eraseblock *chm_nextblock;
|
||||
|
||||
struct garbage_collector_thread chm_gc_thread;
|
||||
struct chfs_eraseblock *chm_gcblock;
|
||||
|
||||
int chm_nr_free_blocks;
|
||||
int chm_nr_erasable_blocks;
|
||||
|
||||
int32_t chm_fs_bmask;
|
||||
int32_t chm_fs_bsize;
|
||||
int32_t chm_fs_qbmask;
|
||||
int32_t chm_fs_bshift;
|
||||
int32_t chm_fs_fmask;
|
||||
int64_t chm_fs_qfmask;
|
||||
|
||||
/* TODO will we use these? */
|
||||
unsigned int chm_pages_max;
|
||||
unsigned int chm_pages_used;
|
||||
unsigned int chm_nodes_max;
|
||||
unsigned int chm_nodes_cnt;
|
||||
struct chfs_pool chm_dirent_pool;
|
||||
struct chfs_pool chm_node_pool;
|
||||
struct chfs_str_pool chm_str_pool;
|
||||
/**/
|
||||
|
||||
size_t chm_wbuf_pagesize;
|
||||
unsigned char* chm_wbuf;
|
||||
size_t chm_wbuf_ofs;
|
||||
size_t chm_wbuf_len;
|
||||
/* chm_lock_wbuf:
|
||||
* Used to protect the write buffer.
|
||||
* If you have to lock chm_lock_mountfields and also chm_lock_wbuf,
|
||||
* you must lock chm_lock_mountfields first. */
|
||||
krwlock_t chm_lock_wbuf;
|
||||
};
|
||||
|
||||
/*
|
||||
* TODO we should move here all of these from the bottom of the file
|
||||
* Macros/functions to convert from generic data structures to chfs
|
||||
* specific ones.
|
||||
*/
|
||||
|
||||
#define CHFS_OFFSET_DOT 0
|
||||
#define CHFS_OFFSET_DOTDOT 1
|
||||
#define CHFS_OFFSET_EOF 2
|
||||
#define CHFS_OFFSET_FIRST 3
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/* chfs_build.c */
|
||||
void chfs_calc_trigger_levels(struct chfs_mount *);
|
||||
int chfs_build_filesystem(struct chfs_mount *);
|
||||
void chfs_build_set_vnodecache_nlink(struct chfs_mount *,
|
||||
struct chfs_vnode_cache *);
|
||||
void chfs_build_remove_unlinked_vnode(struct chfs_mount *,
|
||||
struct chfs_vnode_cache *, struct chfs_dirent_list *);
|
||||
|
||||
/* chfs_scan.c */
|
||||
int chfs_scan_eraseblock(struct chfs_mount *, struct chfs_eraseblock *);
|
||||
struct chfs_vnode_cache *chfs_scan_make_vnode_cache(struct chfs_mount *,
|
||||
ino_t);
|
||||
int chfs_scan_check_node_hdr(struct chfs_flash_node_hdr *);
|
||||
int chfs_scan_check_vnode(struct chfs_mount *,
|
||||
struct chfs_eraseblock *, void *, off_t);
|
||||
int chfs_scan_mark_dirent_obsolete(struct chfs_mount *,
|
||||
struct chfs_vnode_cache *, struct chfs_dirent *);
|
||||
void chfs_add_fd_to_list(struct chfs_mount *,
|
||||
struct chfs_dirent *, struct chfs_vnode_cache *);
|
||||
int chfs_scan_check_dirent_node(struct chfs_mount *,
|
||||
struct chfs_eraseblock *, void *, off_t);
|
||||
int chfs_scan_check_data_node(struct chfs_mount *,
|
||||
struct chfs_eraseblock *, void *, off_t);
|
||||
int chfs_scan_classify_cheb(struct chfs_mount *,
|
||||
struct chfs_eraseblock *);
|
||||
|
||||
/* chfs_nodeops.c */
|
||||
int chfs_update_eb_dirty(struct chfs_mount *,
|
||||
struct chfs_eraseblock *, uint32_t);
|
||||
void chfs_add_node_to_list(struct chfs_mount *, struct chfs_vnode_cache *,
|
||||
struct chfs_node_ref *, struct chfs_node_ref **);
|
||||
void chfs_add_fd_to_inode(struct chfs_mount *,
|
||||
struct chfs_inode *, struct chfs_dirent *);
|
||||
void chfs_add_vnode_ref_to_vc(struct chfs_mount *, struct chfs_vnode_cache *,
|
||||
struct chfs_node_ref *);
|
||||
struct chfs_node_ref* chfs_nref_next(struct chfs_node_ref *);
|
||||
int chfs_nref_len(struct chfs_mount *,
|
||||
struct chfs_eraseblock *, struct chfs_node_ref *);
|
||||
int chfs_close_eraseblock(struct chfs_mount *,
|
||||
struct chfs_eraseblock *);
|
||||
int chfs_reserve_space_normal(struct chfs_mount *, uint32_t, int);
|
||||
int chfs_reserve_space_gc(struct chfs_mount *, uint32_t);
|
||||
int chfs_reserve_space(struct chfs_mount *, uint32_t);
|
||||
void chfs_mark_node_obsolete(struct chfs_mount *, struct chfs_node_ref *);
|
||||
|
||||
static inline struct chfs_vnode_cache *
|
||||
chfs_nref_to_vc(struct chfs_node_ref *nref)
|
||||
{
|
||||
while (nref->nref_next) {
|
||||
nref = nref->nref_next;
|
||||
//dbg("lnr: %u, ofs: %u\n", nref->nref_lnr, nref->nref_offset);
|
||||
//dbg("vno: %llu\n", ((struct chfs_vnode_cache *)(nref))->vno);
|
||||
//dbg("scan_dirents: %p\n", ((struct chfs_vnode_cache *)(nref))->scan_dirents);
|
||||
if (nref->nref_lnr == REF_LINK_TO_NEXT) {
|
||||
dbg("Link to next!\n");
|
||||
} else if (nref->nref_lnr == REF_EMPTY_NODE) {
|
||||
dbg("Empty!\n");
|
||||
}
|
||||
}
|
||||
//dbg("vno: %llu\n", ((struct chfs_vnode_cache *)(nref))->vno);
|
||||
|
||||
//dbg("NREF_TO_VC: GET IT\n");
|
||||
//dbg("nref_next: %p, lnr: %u, ofs: %u\n", nref->nref_next, nref->nref_lnr, nref->nref_offset);
|
||||
struct chfs_vnode_cache *vc = (struct chfs_vnode_cache *) nref;
|
||||
dbg("vno: %ju, pvno: %ju, hv: %ju, nlink: %u\n", (intmax_t )vc->vno,
|
||||
(intmax_t )vc->pvno, (intmax_t )vc->highest_version, vc->nlink);
|
||||
//return ((struct chfs_vnode_cache *)nref);
|
||||
return vc;
|
||||
}
|
||||
|
||||
|
||||
/* chfs_malloc.c */
|
||||
int chfs_alloc_pool_caches(void);
|
||||
void chfs_destroy_pool_caches(void);
|
||||
struct chfs_vnode_cache* chfs_vnode_cache_alloc(ino_t);
|
||||
void chfs_vnode_cache_free(struct chfs_vnode_cache *);
|
||||
struct chfs_node_ref* chfs_alloc_node_ref(
|
||||
struct chfs_eraseblock *);
|
||||
void chfs_free_node_refs(struct chfs_eraseblock *);
|
||||
struct chfs_dirent* chfs_alloc_dirent(int);
|
||||
void chfs_free_dirent(struct chfs_dirent *);
|
||||
struct chfs_flash_vnode* chfs_alloc_flash_vnode(void);
|
||||
void chfs_free_flash_vnode(struct chfs_flash_vnode *);
|
||||
struct chfs_flash_dirent_node* chfs_alloc_flash_dirent(void);
|
||||
void chfs_free_flash_dirent(struct chfs_flash_dirent_node *);
|
||||
struct chfs_flash_data_node* chfs_alloc_flash_dnode(void);
|
||||
void chfs_free_flash_dnode(struct chfs_flash_data_node *);
|
||||
struct chfs_node_frag* chfs_alloc_node_frag(void);
|
||||
void chfs_free_node_frag(struct chfs_node_frag *);
|
||||
struct chfs_node_ref* chfs_alloc_refblock(void);
|
||||
void chfs_free_refblock(struct chfs_node_ref *);
|
||||
struct chfs_full_dnode* chfs_alloc_full_dnode(void);
|
||||
void chfs_free_full_dnode(struct chfs_full_dnode *);
|
||||
struct chfs_tmp_dnode * chfs_alloc_tmp_dnode(void);
|
||||
void chfs_free_tmp_dnode(struct chfs_tmp_dnode *);
|
||||
struct chfs_tmp_dnode_info * chfs_alloc_tmp_dnode_info(void);
|
||||
void chfs_free_tmp_dnode_info(struct chfs_tmp_dnode_info *);
|
||||
|
||||
/* chfs_readinode.c */
|
||||
int chfs_read_inode(struct chfs_mount *, struct chfs_inode *);
|
||||
int chfs_read_inode_internal(struct chfs_mount *, struct chfs_inode *);
|
||||
void chfs_kill_fragtree(struct rb_tree *);
|
||||
uint32_t chfs_truncate_fragtree(struct chfs_mount *,
|
||||
struct rb_tree *, uint32_t);
|
||||
int chfs_add_full_dnode_to_inode(struct chfs_mount *,
|
||||
struct chfs_inode *,
|
||||
struct chfs_full_dnode *);
|
||||
int chfs_read_data(struct chfs_mount*, struct vnode *,
|
||||
struct buf *);
|
||||
|
||||
/* chfs_erase.c */
|
||||
int chfs_remap_leb(struct chfs_mount *);
|
||||
|
||||
/* chfs_ihash.c */
|
||||
void chfs_ihashinit(void);
|
||||
void chfs_ihashreinit(void);
|
||||
void chfs_ihashdone(void);
|
||||
struct vnode *chfs_ihashlookup(dev_t, ino_t);
|
||||
struct vnode *chfs_ihashget(dev_t, ino_t, int);
|
||||
void chfs_ihashins(struct chfs_inode *);
|
||||
void chfs_ihashrem(struct chfs_inode *);
|
||||
|
||||
extern kmutex_t chfs_ihash_lock;
|
||||
extern kmutex_t chfs_hashlock;
|
||||
|
||||
/* chfs_gc.c */
|
||||
void chfs_gc_trigger(struct chfs_mount *);
|
||||
int chfs_gc_thread_should_wake(struct chfs_mount *);
|
||||
void chfs_gc_thread(void *);
|
||||
void chfs_gc_thread_start(struct chfs_mount *);
|
||||
void chfs_gc_thread_stop(struct chfs_mount *);
|
||||
int chfs_gcollect_pass(struct chfs_mount *);
|
||||
|
||||
/* chfs_vfsops.c*/
|
||||
int chfs_gop_alloc(struct vnode *, off_t, off_t, int, kauth_cred_t);
|
||||
int chfs_mountfs(struct vnode *, struct mount *);
|
||||
|
||||
/* chfs_vnops.c */
|
||||
extern int (**chfs_vnodeop_p)(void *);
|
||||
extern int (**chfs_specop_p)(void *);
|
||||
extern int (**chfs_fifoop_p)(void *);
|
||||
int chfs_lookup(void *);
|
||||
int chfs_create(void *);
|
||||
int chfs_mknod(void *);
|
||||
int chfs_open(void *);
|
||||
int chfs_close(void *);
|
||||
int chfs_access(void *);
|
||||
int chfs_getattr(void *);
|
||||
int chfs_setattr(void *);
|
||||
int chfs_chown(struct vnode *, uid_t, gid_t, kauth_cred_t);
|
||||
int chfs_chmod(struct vnode *, int, kauth_cred_t);
|
||||
int chfs_read(void *);
|
||||
int chfs_write(void *);
|
||||
int chfs_fsync(void *);
|
||||
int chfs_remove(void *);
|
||||
int chfs_link(void *);
|
||||
int chfs_rename(void *);
|
||||
int chfs_mkdir(void *);
|
||||
int chfs_rmdir(void *);
|
||||
int chfs_symlink(void *);
|
||||
int chfs_readdir(void *);
|
||||
int chfs_readlink(void *);
|
||||
int chfs_inactive(void *);
|
||||
int chfs_reclaim(void *);
|
||||
int chfs_advlock(void *);
|
||||
int chfs_strategy(void *);
|
||||
int chfs_bmap(void *);
|
||||
|
||||
/* chfs_vnode.c */
|
||||
struct vnode *chfs_vnode_lookup(struct chfs_mount *, ino_t);
|
||||
int chfs_readvnode(struct mount *, ino_t, struct vnode **);
|
||||
int chfs_readdirent(struct mount *, struct chfs_node_ref *,
|
||||
struct chfs_inode *);
|
||||
int chfs_makeinode(int, struct vnode *, struct vnode **,
|
||||
struct componentname *, int );
|
||||
void chfs_set_vnode_size(struct vnode *, size_t);
|
||||
void chfs_change_size_free(struct chfs_mount *,
|
||||
struct chfs_eraseblock *, int);
|
||||
void chfs_change_size_dirty(struct chfs_mount *,
|
||||
struct chfs_eraseblock *, int);
|
||||
void chfs_change_size_unchecked(struct chfs_mount *,
|
||||
struct chfs_eraseblock *, int);
|
||||
void chfs_change_size_used(struct chfs_mount *,
|
||||
struct chfs_eraseblock *, int);
|
||||
void chfs_change_size_wasted(struct chfs_mount *,
|
||||
struct chfs_eraseblock *, int);
|
||||
|
||||
/* chfs_vnode_cache.c */
|
||||
struct chfs_vnode_cache **chfs_vnocache_hash_init(void);
|
||||
void chfs_vnocache_hash_destroy(struct chfs_vnode_cache **);
|
||||
void chfs_vnode_cache_set_state(struct chfs_mount *,
|
||||
struct chfs_vnode_cache *, int);
|
||||
struct chfs_vnode_cache* chfs_vnode_cache_get(struct chfs_mount *, ino_t);
|
||||
void chfs_vnode_cache_add(struct chfs_mount *, struct chfs_vnode_cache *);
|
||||
void chfs_vnode_cache_remove(struct chfs_mount *, struct chfs_vnode_cache *);
|
||||
|
||||
/* chfs_wbuf.c */
|
||||
int chfs_write_wbuf(struct chfs_mount*,
|
||||
const struct iovec *, long, off_t, size_t *);
|
||||
int chfs_flush_pending_wbuf(struct chfs_mount *);
|
||||
|
||||
/* chfs_write.c */
|
||||
int chfs_write_flash_vnode(struct chfs_mount *, struct chfs_inode *, int);
|
||||
int chfs_write_flash_dirent(struct chfs_mount *, struct chfs_inode *,
|
||||
struct chfs_inode *, struct chfs_dirent *, ino_t, int);
|
||||
int chfs_write_flash_dnode(struct chfs_mount *, struct vnode *,
|
||||
struct buf *, struct chfs_full_dnode *);
|
||||
int chfs_do_link(struct chfs_inode *,
|
||||
struct chfs_inode *, const char *, int, enum vtype);
|
||||
int chfs_do_unlink(struct chfs_inode *,
|
||||
struct chfs_inode *, const char *, int);
|
||||
|
||||
/* chfs_subr.c */
|
||||
size_t chfs_mem_info(bool);
|
||||
struct chfs_dirent * chfs_dir_lookup(struct chfs_inode *,
|
||||
struct componentname *);
|
||||
int chfs_filldir (struct uio *, ino_t, const char *, int, enum vtype);
|
||||
int chfs_chsize(struct vnode *, u_quad_t, kauth_cred_t);
|
||||
int chfs_chflags(struct vnode *, int, kauth_cred_t);
|
||||
void chfs_itimes(struct chfs_inode *, const struct timespec *,
|
||||
const struct timespec *, const struct timespec *);
|
||||
int chfs_update(struct vnode *, const struct timespec *,
|
||||
const struct timespec *, int);
|
||||
//int chfs_truncate(struct vnode *, off_t);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/* Some inline functions temporarily placed here */
|
||||
static inline int
|
||||
chfs_map_leb(struct chfs_mount *chmp, int lnr)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = ebh_map_leb(chmp->chm_ebh, lnr);
|
||||
if (err)
|
||||
chfs_err("unmap leb %d failed, error: %d\n",lnr, err);
|
||||
|
||||
return err;
|
||||
|
||||
}
|
||||
|
||||
static inline int
|
||||
chfs_unmap_leb(struct chfs_mount *chmp, int lnr)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = ebh_unmap_leb(chmp->chm_ebh, lnr);
|
||||
if (err)
|
||||
chfs_err("unmap leb %d failed, error: %d\n",lnr, err);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static inline int
|
||||
chfs_read_leb(struct chfs_mount *chmp, int lnr, char *buf,
|
||||
int offset, int len, size_t *retlen)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = ebh_read_leb(chmp->chm_ebh, lnr, buf, offset, len, retlen);
|
||||
if (err)
|
||||
chfs_err("read leb %d:%d failed, error: %d\n",
|
||||
lnr, offset, err);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static inline int chfs_write_leb(struct chfs_mount *chmp, int lnr, char *buf,
|
||||
int offset, int len, size_t *retlen)
|
||||
{
|
||||
int err;
|
||||
err = ebh_write_leb(chmp->chm_ebh, lnr, buf, offset, len, retlen);
|
||||
if (err)
|
||||
chfs_err("write leb %d:%d failed, error: %d\n",
|
||||
lnr, offset, err);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* Code from dummyfs.h */
|
||||
/******************************************************************************/
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
#define CHFS_PAGES_RESERVED (4 * 1024 * 1024 / PAGE_SIZE)
|
||||
|
||||
static __inline size_t
|
||||
CHFS_PAGES_MAX(struct chfs_mount *chmp)
|
||||
{
|
||||
size_t freepages;
|
||||
|
||||
freepages = chfs_mem_info(false);
|
||||
if (freepages < CHFS_PAGES_RESERVED)
|
||||
freepages = 0;
|
||||
else
|
||||
freepages -= CHFS_PAGES_RESERVED;
|
||||
|
||||
return MIN(chmp->chm_pages_max, freepages + chmp->chm_pages_used);
|
||||
}
|
||||
|
||||
#define CHFS_ITIMES(ip, acc, mod, cre) \
|
||||
while ((ip)->iflag & (IN_ACCESS | IN_CHANGE | IN_UPDATE | IN_MODIFY)) \
|
||||
chfs_itimes(ip, acc, mod, cre)
|
||||
|
||||
/* used for KASSERTs */
|
||||
#define IMPLIES(a, b) (!(a) || (b))
|
||||
#define IFF(a, b) (IMPLIES(a, b) && IMPLIES(b, a))
|
||||
|
||||
#endif /* __CHFS_H__ */
|
||||
@@ -1,53 +0,0 @@
|
||||
/* $NetBSD: chfs_args.h,v 1.1 2011/11/24 15:51:31 ahoka Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2010 Department of Software Engineering,
|
||||
* University of Szeged, Hungary
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by the Department of Software Engineering, University of Szeged, Hungary
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _FS_CHFS_CHFS_ARGS_H_
|
||||
#define _FS_CHFS_CHFS_ARGS_H_
|
||||
|
||||
#define CHFS_ARGS_VERSION 1
|
||||
|
||||
/**
|
||||
* struct chfs_args - arguments needed when mounting filesystem
|
||||
* @fl_index: index of the flash device in the flash layer
|
||||
*/
|
||||
struct chfs_args {
|
||||
//int ca_version;
|
||||
char *fspec;
|
||||
int fl_index;
|
||||
|
||||
/* Root node attributes. */
|
||||
/*uid_t ca_root_uid;
|
||||
gid_t ca_root_gid;
|
||||
mode_t ca_root_mode;*/
|
||||
};
|
||||
|
||||
#endif /* _FS_CHFS_CHFS_ARGS_H_ */
|
||||
@@ -1,136 +0,0 @@
|
||||
/* $NetBSD: chfs_inode.h,v 1.1 2011/11/24 15:51:31 ahoka Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2010 Department of Software Engineering,
|
||||
* University of Szeged, Hungary
|
||||
* Copyright (C) 2010 Tamas Toth <ttoth@inf.u-szeged.hu>
|
||||
* Copyright (C) 2010 Adam Hoka <ahoka@NetBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by the Department of Software Engineering, University of Szeged, Hungary
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __CHFS_INODE_H__
|
||||
#define __CHFS_INODE_H__
|
||||
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/stat.h>
|
||||
#include <ufs/ufs/ufsmount.h>
|
||||
#include <miscfs/genfs/genfs_node.h>
|
||||
|
||||
struct chfs_inode
|
||||
{
|
||||
kmutex_t inode_lock; /* lock the fields of chfs_inode */
|
||||
|
||||
LIST_ENTRY(chfs_inode) hash_entry; /* Hash chain. */
|
||||
|
||||
struct ufsmount *ump; /* ufs mount - TODO we should remove it */
|
||||
struct chfs_mount *chmp; /* chfs mount point - TODO we should remove it */
|
||||
|
||||
struct vnode *vp; /* vnode associated with this inode */
|
||||
ino_t ino; /* vnode identifier number */
|
||||
|
||||
struct vnode *devvp; /* vnode for block I/O */
|
||||
dev_t dev; /* device associated with the inode */
|
||||
|
||||
struct chfs_vnode_cache *chvc; /* vnode cache of this node */
|
||||
|
||||
struct chfs_dirent *fd; /* full dirent of this node */
|
||||
// struct chfs_dirent *dents; /* directory entries */
|
||||
struct chfs_dirent_list dents;
|
||||
|
||||
struct rb_tree fragtree; /* fragtree of inode */
|
||||
|
||||
uint64_t version; /* version number */
|
||||
//uint64_t highest_version; /* highest vers. num. (used at data nodes) */
|
||||
|
||||
uint32_t mode; /* mode */
|
||||
//int16_t nlink; /* link count */
|
||||
uint64_t size; /* file byte count */
|
||||
uint64_t write_size; /* increasing while write the file out to the flash */
|
||||
uint32_t uid; /* file owner */
|
||||
uint32_t gid; /* file group */
|
||||
uint32_t atime; /* access time */
|
||||
uint32_t mtime; /* modify time */
|
||||
uint32_t ctime; /* creation time */
|
||||
|
||||
uint32_t iflag; /* flags, see below */
|
||||
uint32_t flags; /* status flags (chflags) */
|
||||
|
||||
dev_t rdev; /* used if type is VCHR or VBLK or VFIFO*/
|
||||
char *target; /* used if type is VLNK */
|
||||
};
|
||||
|
||||
/* These flags are kept in chfs_inode->iflag. */
|
||||
#define IN_ACCESS 0x0001 /* Access time update request. */
|
||||
#define IN_CHANGE 0x0002 /* Inode change time update request. */
|
||||
#define IN_UPDATE 0x0004 /* Inode was written to; update mtime. */
|
||||
#define IN_MODIFY 0x2000 /* Modification time update request. */
|
||||
#define IN_MODIFIED 0x0008 /* Inode has been modified. */
|
||||
#define IN_ACCESSED 0x0010 /* Inode has been accessed. */
|
||||
#define IN_RENAME 0x0020 /* Inode is being renamed. */
|
||||
#define IN_SHLOCK 0x0040 /* File has shared lock. */
|
||||
#define IN_EXLOCK 0x0080 /* File has exclusive lock. */
|
||||
#define IN_CLEANING 0x0100 /* LFS: file is being cleaned */
|
||||
#define IN_ADIROP 0x0200 /* LFS: dirop in progress */
|
||||
#define IN_SPACECOUNTED 0x0400 /* Blocks to be freed in free count. */
|
||||
#define IN_PAGING 0x1000 /* LFS: file is on paging queue */
|
||||
|
||||
|
||||
#ifdef VTOI
|
||||
# undef VTOI
|
||||
#endif
|
||||
#ifdef ITOV
|
||||
# undef ITOV
|
||||
#endif
|
||||
|
||||
#define VTOI(vp) ((struct chfs_inode *)(vp)->v_data)
|
||||
#define ITOV(ip) ((ip)->vp)
|
||||
|
||||
/* copied from ufs_dinode.h */
|
||||
#define NDADDR 12 /* Direct addresses in inode. */
|
||||
|
||||
#define ROOTINO ((ino_t)2)
|
||||
|
||||
/* File permissions. */
|
||||
#define IEXEC 0000100 /* Executable. */
|
||||
#define IWRITE 0000200 /* Writable. */
|
||||
#define IREAD 0000400 /* Readable. */
|
||||
#define ISVTX 0001000 /* Sticky bit. */
|
||||
#define ISGID 0002000 /* Set-gid. */
|
||||
#define ISUID 0004000 /* Set-uid. */
|
||||
|
||||
/* File types. */
|
||||
#define IFMT 0170000 /* Mask of file type. */
|
||||
#define IFIFO 0010000 /* Named pipe (fifo). */
|
||||
#define IFCHR 0020000 /* Character device. */
|
||||
#define IFDIR 0040000 /* Directory file. */
|
||||
#define IFBLK 0060000 /* Block device. */
|
||||
#define IFREG 0100000 /* Regular file. */
|
||||
#define IFLNK 0120000 /* Symbolic link. */
|
||||
#define IFSOCK 0140000 /* UNIX domain socket. */
|
||||
#define IFWHT 0160000 /* Whiteout. */
|
||||
|
||||
#endif /* __CHFS_INODE_H__ */
|
||||
@@ -1,84 +0,0 @@
|
||||
/* $NetBSD: chfs_pool.h,v 1.1 2011/11/24 15:51:31 ahoka Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2010 Department of Software Engineering,
|
||||
* University of Szeged, Hungary
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by the Department of Software Engineering, University of Szeged, Hungary
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _FS_CHFS_CHFS_POOL_H_
|
||||
#define _FS_CHFS_CHFS_POOL_H_
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
struct chfs_pool {
|
||||
struct pool chp_pool;
|
||||
struct chfs_mount * chp_mount;
|
||||
char chp_name[64];
|
||||
};
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
struct chfs_str_pool {
|
||||
struct chfs_pool chsp_pool_16;
|
||||
struct chfs_pool chsp_pool_32;
|
||||
struct chfs_pool chsp_pool_64;
|
||||
struct chfs_pool chsp_pool_128;
|
||||
struct chfs_pool chsp_pool_256;
|
||||
struct chfs_pool chsp_pool_512;
|
||||
struct chfs_pool chsp_pool_1024;
|
||||
};
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
#ifdef _KERNEL
|
||||
|
||||
/*
|
||||
* Convenience functions and macros to manipulate a chfs_pool.
|
||||
*/
|
||||
|
||||
void chfs_pool_init(struct chfs_pool *chpp, size_t size,
|
||||
const char *what, struct chfs_mount *chmp);
|
||||
void chfs_pool_destroy(struct chfs_pool *chpp);
|
||||
|
||||
#define CHFS_POOL_GET(chpp, flags) pool_get((struct pool *)(chpp), flags)
|
||||
#define CHFS_POOL_PUT(chpp, v) pool_put((struct pool *)(chpp), v)
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* Functions to manipulate a chfs_str_pool.
|
||||
*/
|
||||
|
||||
void chfs_str_pool_init(struct chfs_str_pool *, struct chfs_mount *);
|
||||
void chfs_str_pool_destroy(struct chfs_str_pool *);
|
||||
char * chfs_str_pool_get(struct chfs_str_pool *, size_t, int);
|
||||
void chfs_str_pool_put(struct chfs_str_pool *, char *, size_t);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _FS_CHFS_CHFS_POOL_H_ */
|
||||
@@ -1,97 +0,0 @@
|
||||
/* $NetBSD: debug.h,v 1.1 2011/11/24 15:51:32 ahoka Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2010 Department of Software Engineering,
|
||||
* University of Szeged, Hungary
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by the Department of Software Engineering, University of Szeged, Hungary
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* XipFFS -- Xip Flash File System
|
||||
*
|
||||
* Copyright (C) 2009 Ferenc Havasi <havasi@inf.u-szeged.hu>,
|
||||
* Zoltan Sogor <weth@inf.u-szeged.hu>,
|
||||
* ...
|
||||
* University of Szeged, Hungary
|
||||
*
|
||||
*
|
||||
* For licensing information, see the file 'LICENCE' in this directory.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __CHFS_DEBUG_H__
|
||||
#define __CHFS_DEBUG_H__
|
||||
|
||||
#define CHFS_ERROR_PREFIX "[CHFS ERROR]"
|
||||
#define CHFS_WARNING_PREFIX "[CHFS WARNING]"
|
||||
#define CHFS_NOTICE_PREFIX "[CHFS NOTICE]"
|
||||
#define CHFS_DBG_PREFIX "[CHFS DBG]"
|
||||
#define CHFS_DBG2_PREFIX "[CHFS DBG2]"
|
||||
#define CHFS_DBG_EBH_PREFIX "[CHFS DBG EBH]"
|
||||
#define CHFS_DBG_GC_PREFIX "[CHFS_GC DBG]"
|
||||
|
||||
#define unlikely(x) __builtin_expect ((x), 0)
|
||||
|
||||
|
||||
|
||||
#define debug_msg(pref, fmt, ...) \
|
||||
do { \
|
||||
printf(pref \
|
||||
" %s: " fmt, __FUNCTION__ , ##__VA_ARGS__); \
|
||||
} while(0)
|
||||
|
||||
#define chfs_assert(expr) do { \
|
||||
if (unlikely(!(expr))) { \
|
||||
printf("CHFS assert failed in %s at %u\n", \
|
||||
__func__, __LINE__); \
|
||||
/*dump_stack();*/ \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#ifdef DBG_MSG
|
||||
#define chfs_err(fmt, ...) debug_msg(CHFS_ERROR_PREFIX, fmt, ##__VA_ARGS__)
|
||||
#define chfs_warn(fmt, ...) debug_msg(CHFS_WARNING_PREFIX, fmt, ##__VA_ARGS__)
|
||||
#define chfs_noti(fmt, ...) debug_msg(CHFS_NOTICE_PREFIX, fmt, ##__VA_ARGS__)
|
||||
#define dbg(fmt, ...) debug_msg(CHFS_DBG_PREFIX, fmt, ##__VA_ARGS__)
|
||||
#define dbg2(fmt, ...) debug_msg(CHFS_DBG2_PREFIX(fmt, ##__VA_ARGS__)
|
||||
#define dbg_ebh(fmt, ...) debug_msg(CHFS_DBG_EBH_PREFIX, fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
#define chfs_err(fmt, ...) debug_msg(CHFS_ERROR_PREFIX, fmt, ##__VA_ARGS__)
|
||||
#define chfs_warn(fmt, ...) debug_msg(CHFS_WARNING_PREFIX, fmt, ##__VA_ARGS__)
|
||||
#define chfs_noti(fmt, ...) debug_msg(CHFS_NOTICE_PREFIX, fmt, ##__VA_ARGS__)
|
||||
#define dbg(fmt, ...)
|
||||
#define dbg2(fmt, ...)
|
||||
#define dbg_ebh(fmt, ...)
|
||||
#endif
|
||||
|
||||
#ifdef DBG_MSG_GC
|
||||
#define dbg_gc(fmt, ...) debug_msg(CHFS_DBG_GC_PREFIX, fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
#define dbg_gc(fmt, ...)
|
||||
#endif
|
||||
|
||||
#endif /* __CHFS_DEBUG_H__ */
|
||||
@@ -1,318 +0,0 @@
|
||||
/* $NetBSD: ebh.h,v 1.1 2011/11/24 15:51:32 ahoka Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2010 Department of Software Engineering,
|
||||
* University of Szeged, Hungary
|
||||
* Copyright (c) 2010 David Tengeri <dtengeri@inf.u-szeged.hu>
|
||||
* Copyright (c) 2010 Adam Hoka <ahoka@NetBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by the Department of Software Engineering, University of Szeged, Hungary
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ebh.h
|
||||
*
|
||||
* Created on: 2009.11.03.
|
||||
* Author: dtengeri
|
||||
*/
|
||||
|
||||
#ifndef EBH_H_
|
||||
#define EBH_H_
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/tree.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/kmem.h>
|
||||
#include <sys/endian.h>
|
||||
#include <sys/rwlock.h>
|
||||
#include <sys/condvar.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/kthread.h>
|
||||
|
||||
#include <dev/flash/flash.h>
|
||||
#include <ufs/chfs/ebh_media.h>
|
||||
#include <ufs/chfs/debug.h>
|
||||
#include <ufs/chfs/ebh_misc.h>
|
||||
|
||||
/* Maximum retries when getting new PEB before exit with failure */
|
||||
#define CHFS_MAX_GET_PEB_RETRIES 2
|
||||
|
||||
/**
|
||||
* LEB status
|
||||
*
|
||||
*/
|
||||
enum {
|
||||
EBH_LEB_UNMAPPED = -1,
|
||||
EBH_LEB_MAPPED,
|
||||
EBH_LEB_DIRTY,
|
||||
EBH_LEB_INVALID,
|
||||
EBH_LEB_ERASE,
|
||||
EBH_LEB_ERASED,
|
||||
EBH_LEB_FREE,
|
||||
};
|
||||
|
||||
/**
|
||||
* EB header status
|
||||
*/
|
||||
enum {
|
||||
EBHDR_LEB_OK = 0,
|
||||
EBHDR_LEB_DIRTY,
|
||||
EBHDR_LEB_INVALIDATED,
|
||||
EBHDR_LEB_BADMAGIC,
|
||||
EBHDR_LEB_BADCRC,
|
||||
EBHDR_LEB_FREE,
|
||||
EBHDR_LEB_NO_HDR,
|
||||
};
|
||||
|
||||
struct chfs_ebh;
|
||||
|
||||
/**
|
||||
* struct chfs_ltree_entry - an netry in the lock tree
|
||||
* @rb: RB-node of the tree
|
||||
* @lnr: logical eraseblock number
|
||||
* @users: counts the tasks that are using or want to use the eraseblock
|
||||
* @mutex: read/write mutex to lock the eraseblock
|
||||
*/
|
||||
struct chfs_ltree_entry {
|
||||
RB_ENTRY(chfs_ltree_entry) rb;
|
||||
int lnr;
|
||||
int users;
|
||||
krwlock_t mutex;
|
||||
};
|
||||
|
||||
/* Generate structure for Lock tree's red-black tree */
|
||||
RB_HEAD(ltree_rbtree, chfs_ltree_entry);
|
||||
|
||||
|
||||
/**
|
||||
* struct chfs_scan_leb - scanning infomration about a physical eraseblock
|
||||
* @erase_cnt: erase counter
|
||||
* @pebnr: physical eraseblock number
|
||||
* @info: the status of the PEB's eraseblock header when NOR serial when NAND
|
||||
* @u.list: link in one of the eraseblock list
|
||||
* @u.rb: link in the used RB-tree of chfs_scan_info
|
||||
*/
|
||||
struct chfs_scan_leb {
|
||||
int erase_cnt;
|
||||
int pebnr;
|
||||
int lnr;
|
||||
uint64_t info;
|
||||
union {
|
||||
TAILQ_ENTRY(chfs_scan_leb) queue;
|
||||
RB_ENTRY(chfs_scan_leb) rb;
|
||||
} u;
|
||||
};
|
||||
|
||||
TAILQ_HEAD(scan_leb_queue, chfs_scan_leb);
|
||||
RB_HEAD(scan_leb_used_rbtree, chfs_scan_leb);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* struct chfs_scan_info - chfs scanning information
|
||||
* @corrupted: queue of corrupted physical eraseblocks
|
||||
* @free: queue of free physical eraseblocks
|
||||
* @erase: queue of the physical eraseblocks signed to erase
|
||||
* @erased: queue of physical eraseblocks that contain no header
|
||||
* @used: RB-tree of used PEBs describing by chfs_scan_leb
|
||||
* @sum_of_ec: summary of erase counters
|
||||
* @num_of_eb: number of free and used eraseblocks
|
||||
* @bad_peb_cnt: counter of bad eraseblocks
|
||||
*
|
||||
* This structure contains information about the scanning for further
|
||||
* processing.
|
||||
*/
|
||||
struct chfs_scan_info {
|
||||
struct scan_leb_queue corrupted;
|
||||
struct scan_leb_queue free;
|
||||
struct scan_leb_queue erase;
|
||||
struct scan_leb_queue erased;
|
||||
struct scan_leb_used_rbtree used;
|
||||
uint64_t sum_of_ec;
|
||||
int num_of_eb;
|
||||
int bad_peb_cnt;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct chfs_peb - PEB information for erasing and wear leveling
|
||||
* @erase_cnt: erase counter of the physical eraseblock
|
||||
* @pebnr: physical eraseblock number
|
||||
* @u.queue: link to the queue of the PEBs waiting for erase
|
||||
* @u.rb: link to the RB-tree to the free PEBs
|
||||
*/
|
||||
struct chfs_peb {
|
||||
int erase_cnt;
|
||||
int pebnr;
|
||||
union {
|
||||
TAILQ_ENTRY(chfs_peb) queue;
|
||||
RB_ENTRY(chfs_peb) rb;
|
||||
} u;
|
||||
};
|
||||
|
||||
/* Generate queue and rb-tree structures. */
|
||||
TAILQ_HEAD(peb_queue, chfs_peb);
|
||||
RB_HEAD(peb_free_rbtree, chfs_peb);
|
||||
RB_HEAD(peb_in_use_rbtree, chfs_peb);
|
||||
|
||||
/**
|
||||
* struct chfs_eb_hdr - in-memory representation of eraseblock headers
|
||||
* @ec_hdr: erase counter header ob eraseblock
|
||||
* @u.nor_hdr: eraseblock header on NOR flash
|
||||
* @u.nand_hdr: eraseblock header on NAND flash
|
||||
*/
|
||||
struct chfs_eb_hdr {
|
||||
struct chfs_eb_ec_hdr ec_hdr;
|
||||
union {
|
||||
struct chfs_nor_eb_hdr nor_hdr;
|
||||
struct chfs_nand_eb_hdr nand_hdr;
|
||||
} u;
|
||||
};
|
||||
|
||||
/*
|
||||
* struct chfs_ebh_ops - collection of operations which
|
||||
* depends on flash type
|
||||
* *************************************************************************** *
|
||||
* Direct flash operations:
|
||||
*
|
||||
* @read_eb_hdr: read eraseblock header from media
|
||||
* @write_eb_hdr: write eraseblock header to media
|
||||
* @check_eb_hdr: validates eraseblock header
|
||||
* @mark_eb_hdr_dirty_flash: marks eraseblock dirty on flash
|
||||
* @invalidate_eb_hdr: invalidates eraseblock header
|
||||
* @mark_eb_hdr_free: marks eraseblock header free (after erase)
|
||||
* *************************************************************************** *
|
||||
* Scanning operations:
|
||||
*
|
||||
* @process_eb: process an eraseblock information at scan
|
||||
* *************************************************************************** *
|
||||
* Misc operations:
|
||||
*
|
||||
* @create_eb_hdr: creates an eraseblock header based on flash type
|
||||
* @calc_data_offs: calculates where the data starts
|
||||
*/
|
||||
struct chfs_ebh_ops {
|
||||
int (*read_eb_hdr)(struct chfs_ebh *ebh, int pebnr,
|
||||
struct chfs_eb_hdr *ebhdr);
|
||||
int (*write_eb_hdr)(struct chfs_ebh *ebh, int pebnr,
|
||||
struct chfs_eb_hdr *ebhdr);
|
||||
int (*check_eb_hdr)(struct chfs_ebh *ebh, void *buf);
|
||||
int (*mark_eb_hdr_dirty_flash)(struct chfs_ebh *ebh, int pebnr, int lid);
|
||||
int (*invalidate_eb_hdr)(struct chfs_ebh *ebh, int pebnr);
|
||||
int (*mark_eb_hdr_free)(struct chfs_ebh *ebh, int pebnr, int ec);
|
||||
|
||||
int (*process_eb)(struct chfs_ebh *ebh, struct chfs_scan_info *si,
|
||||
int pebnr, struct chfs_eb_hdr *ebhdr);
|
||||
|
||||
int (*create_eb_hdr)(struct chfs_eb_hdr *ebhdr, int lnr);
|
||||
int (*calc_data_offs)(struct chfs_ebh *ebh, int pebnr, int offset);
|
||||
};
|
||||
|
||||
/**
|
||||
* struct erase_thread - background thread for erasing
|
||||
* @thread: pointer to thread structure
|
||||
* @wakeup: conditional variable for sleeping if there isn't any job to do
|
||||
* @running: flag to signal a thread shutdown
|
||||
*/
|
||||
struct erase_thread {
|
||||
lwp_t *eth_thread;
|
||||
kcondvar_t eth_wakeup;
|
||||
bool eth_running;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* struct chfs_ebh - eraseblock handler descriptor
|
||||
* @mtd: mtd device descriptor
|
||||
* @eb_size: eraseblock size
|
||||
* @peb_nr: number of PEBs
|
||||
* @lmap: LEB to PEB mapping
|
||||
* @layout_map: the LEBs layout (NOT USED YET)
|
||||
* @ltree: the lock tree
|
||||
* @ltree_lock: protects the tree
|
||||
* @alc_mutex: serializes "atomic LEB change" operation
|
||||
* @free: RB-tree of the free easeblocks
|
||||
* @in_use: RB-tree of PEBs are in use
|
||||
* @to_erase: list of the PEBs waiting for erase
|
||||
* @fully_erased: list of PEBs that have been erased but don't have header
|
||||
* @erase_lock: list and tree lock for fully_erased and to_erase lists and
|
||||
* for the free RB-tree
|
||||
* @bg_erase: background thread for eraseing PEBs.
|
||||
* @ops: collection of operations which depends on flash type
|
||||
* @max_serial: max serial number of eraseblocks, only used on NAND
|
||||
*/
|
||||
struct chfs_ebh {
|
||||
struct peb_free_rbtree free;
|
||||
struct peb_in_use_rbtree in_use;
|
||||
struct peb_queue to_erase;
|
||||
struct peb_queue fully_erased;
|
||||
struct erase_thread bg_erase;
|
||||
device_t flash_dev;
|
||||
const struct flash_interface *flash_if;
|
||||
struct chfs_ebh_ops *ops;
|
||||
uint64_t *max_serial;
|
||||
int *lmap;
|
||||
//int *layout_map;
|
||||
struct ltree_rbtree ltree;
|
||||
//struct mutex alc_mutex;
|
||||
kmutex_t ltree_lock;
|
||||
kmutex_t alc_mutex;
|
||||
kmutex_t erase_lock;
|
||||
size_t eb_size;
|
||||
size_t peb_nr;
|
||||
flash_size_t flash_size;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct chfs_erase_info_priv - private information for erase
|
||||
* @ebh: eraseblock handler
|
||||
* @peb: physical eraseblock information
|
||||
*/
|
||||
struct chfs_erase_info_priv {
|
||||
struct chfs_ebh *ebh;
|
||||
struct chfs_peb *peb;
|
||||
};
|
||||
|
||||
/* ebh.c */
|
||||
|
||||
int ebh_open(struct chfs_ebh *ebh, dev_t dev);
|
||||
int ebh_close(struct chfs_ebh *ebh);
|
||||
int ebh_read_leb(struct chfs_ebh *ebh, int lnr, char *buf,
|
||||
uint32_t offset, size_t len, size_t *retlen);
|
||||
int ebh_write_leb(struct chfs_ebh *ebh, int lnr, char *buf,
|
||||
uint32_t offset, size_t len, size_t *retlen);
|
||||
int ebh_erase_leb(struct chfs_ebh *ebh, int lnr);
|
||||
int ebh_map_leb(struct chfs_ebh *ebh, int lnr);
|
||||
int ebh_unmap_leb(struct chfs_ebh *ebh, int lnr);
|
||||
int ebh_is_mapped(struct chfs_ebh *ebh, int lnr);
|
||||
int ebh_change_leb(struct chfs_ebh *ebh, int lnr, char *buf,
|
||||
size_t len, size_t *retlen);
|
||||
|
||||
|
||||
#endif /* EBH_H_ */
|
||||
@@ -1,116 +0,0 @@
|
||||
/* $NetBSD: ebh_media.h,v 1.1 2011/11/24 15:51:32 ahoka Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2010 Department of Software Engineering,
|
||||
* University of Szeged, Hungary
|
||||
* Copyright (C) 2009 Ferenc Havasi <havasi@inf.u-szeged.hu>
|
||||
* Copyright (C) 2009 Zoltan Sogor <weth@inf.u-szeged.hu>
|
||||
* Copyright (C) 2009 David Tengeri <dtengeri@inf.u-szeged.hu>
|
||||
* Copyright (C) 2010 Adam Hoka <ahoka@NetBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by the Department of Software Engineering, University of Szeged, Hungary
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef EBH_MEDIA_H_
|
||||
#define EBH_MEDIA_H_
|
||||
|
||||
#ifndef _LE_TYPES
|
||||
#define _LE_TYPES
|
||||
typedef uint16_t le16;
|
||||
typedef uint32_t le32;
|
||||
typedef uint64_t le64;
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
/* EBH specific structures */
|
||||
/*****************************************************************************/
|
||||
#define CHFS_MAGIC_BITMASK 0x53454452
|
||||
|
||||
#define CHFS_LID_NOT_DIRTY_BIT 0x80000000
|
||||
#define CHFS_LID_DIRTY_BIT_MASK 0x7fffffff
|
||||
|
||||
/* sizeof(crc) + sizeof(lid) */
|
||||
#define CHFS_INVALIDATE_SIZE 8
|
||||
|
||||
/* Size of magic + crc_ec + erase_cnt */
|
||||
#define CHFS_EB_EC_HDR_SIZE sizeof(struct chfs_eb_ec_hdr)
|
||||
/* Size of NOR eraseblock header */
|
||||
#define CHFS_EB_HDR_NOR_SIZE sizeof(struct chfs_nor_eb_hdr)
|
||||
/* Size of NAND eraseblock header */
|
||||
#define CHFS_EB_HDR_NAND_SIZE sizeof(struct chfs_nand_eb_hdr)
|
||||
|
||||
/*
|
||||
* chfs_eb_ec_hdr - erase counter header of eraseblock
|
||||
* @magic: filesystem magic
|
||||
* @crc_ec: CRC32 sum of erase counter
|
||||
* @erase_cnt: erase counter
|
||||
*
|
||||
* This structure holds the erasablock description information.
|
||||
* This will be written to the beginning of the eraseblock.
|
||||
*
|
||||
*/
|
||||
struct chfs_eb_ec_hdr {
|
||||
le32 magic;
|
||||
le32 crc_ec;
|
||||
le32 erase_cnt;
|
||||
} __packed;
|
||||
|
||||
/**
|
||||
* struct chfs_nor_eb_hdr - eraseblock header on NOR flash
|
||||
* @crc: CRC32 sum
|
||||
* @lid: logical identifier
|
||||
*
|
||||
* @lid contains the logical block reference but only the first 31 bit (0-30) is
|
||||
* used. The 32th bit is for marking a lid dirty (marked for recovery purposes).
|
||||
* If a new eraseblock is succesfully assigned with the same lid then the lid of
|
||||
* the old one is zeroed. If power failure happened during this operation then
|
||||
* the recovery detects that there is two eraseblock with the same lid, but one
|
||||
* of them is marked (the old one).
|
||||
*
|
||||
* Invalidated eraseblock header means that the @crc and @lid is set to 0.
|
||||
*/
|
||||
struct chfs_nor_eb_hdr {
|
||||
le32 crc;
|
||||
le32 lid;
|
||||
} __packed;
|
||||
|
||||
/**
|
||||
* struct chfs_nand_eb_hdr - eraseblock header on NAND flash
|
||||
* @crc: CRC32 sum
|
||||
* @lid: logical identifier
|
||||
* @serial: layout of the lid
|
||||
*
|
||||
* @serial is an unique number. Every eraseblock header on NAND flash has its
|
||||
* own serial. If there are two eraseblock on the flash referencing to the same
|
||||
* logical eraseblock, the one with bigger serial is the newer.
|
||||
*/
|
||||
struct chfs_nand_eb_hdr {
|
||||
le32 crc;
|
||||
le32 lid;
|
||||
le64 serial;
|
||||
} __packed;
|
||||
|
||||
#endif /* EBH_MEDIA_H_ */
|
||||
@@ -1,88 +0,0 @@
|
||||
/* $NetBSD: ebh_misc.h,v 1.1 2011/11/24 15:51:32 ahoka Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2010 Department of Software Engineering,
|
||||
* University of Szeged, Hungary
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by the Department of Software Engineering, University of Szeged, Hungary
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef EBH_MISC_H_
|
||||
#define EBH_MISC_H_
|
||||
|
||||
/******************************************************************************/
|
||||
/* EBH specific functions */
|
||||
/******************************************************************************/
|
||||
|
||||
#define CHFS_GET_MEMBER_POS(type, member) \
|
||||
((unsigned long)(&((type *)0)->member))
|
||||
|
||||
#define CHFS_GET_LID(lid) (le32toh(lid) & CHFS_LID_DIRTY_BIT_MASK)
|
||||
|
||||
/**
|
||||
* EBH_TREE_DESTROY - destroys an RB-tree and frees the memory of its elements.
|
||||
* @name - the RB-tree structure's name
|
||||
* @head - pointer to the RB-tree's head
|
||||
* @type - type of the elements
|
||||
*/
|
||||
#define EBH_TREE_DESTROY(name, head, type) \
|
||||
{ \
|
||||
type *var, *nxt; \
|
||||
for (var = RB_MIN(name, head); var != NULL; var = nxt) { \
|
||||
nxt = RB_NEXT(name, head, var); \
|
||||
RB_REMOVE(name, head, var); \
|
||||
kmem_free(var, sizeof(type)); \
|
||||
} \
|
||||
}
|
||||
|
||||
/* XXX HACK! we need a clean solution for destroying mutexes in trees */
|
||||
#define EBH_TREE_DESTROY_MUTEX(name, head, type) \
|
||||
{ \
|
||||
type *var, *nxt; \
|
||||
for (var = RB_MIN(name, head); var != NULL; var = nxt) { \
|
||||
nxt = RB_NEXT(name, head, var); \
|
||||
RB_REMOVE(name, head, var); \
|
||||
rw_destroy(&var->mutex); \
|
||||
kmem_free(var, sizeof(type)); \
|
||||
} \
|
||||
}
|
||||
|
||||
/**
|
||||
* EBH_QUEUE_DESTROY - destroys a TAILQ and frees the memory of its elements.
|
||||
* @head: pointer to the head of the queue
|
||||
* @type: type of the elements
|
||||
* @entry: name of TAILQ_ENTRY
|
||||
*/
|
||||
#define EBH_QUEUE_DESTROY(head, type, entry) \
|
||||
{ \
|
||||
type *var; \
|
||||
while ((var = TAILQ_FIRST(head))) { \
|
||||
TAILQ_REMOVE(head, var, entry); \
|
||||
kmem_free(var, sizeof(type)); \
|
||||
} \
|
||||
}
|
||||
|
||||
#endif /* EBH_MISC_H_ */
|
||||
@@ -1,200 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 2010 Department of Software Engineering,
|
||||
* University of Szeged, Hungary
|
||||
* Copyright (C) 2009 Ferenc Havasi <havasi@inf.u-szeged.hu>
|
||||
* Copyright (C) 2009 Zoltan Sogor <weth@inf.u-szeged.hu>
|
||||
* Copyright (C) 2009 David Tengeri <dtengeri@inf.u-szeged.hu>
|
||||
* Copyright (C) 2010 Adam Hoka <ahoka@NetBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by the Department of Software Engineering, University of Szeged, Hungary
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __CHFS_MEDIA_H__
|
||||
#define __CHFS_MEDIA_H__
|
||||
|
||||
#ifndef _LE_TYPES
|
||||
#define _LE_TYPES
|
||||
typedef uint16_t le16;
|
||||
typedef uint32_t le32;
|
||||
typedef uint64_t le64;
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
/* File system specific structures */
|
||||
/*****************************************************************************/
|
||||
|
||||
enum {
|
||||
CHFS_NODETYPE_VNODE = 1,
|
||||
CHFS_NODETYPE_DATA,
|
||||
CHFS_NODETYPE_DIRENT,
|
||||
CHFS_NODETYPE_PADDING,
|
||||
};
|
||||
|
||||
//#define CHFS_NODE_HDR_SIZE 12 /* magic + type + length + hdr_crc */
|
||||
#define CHFS_NODE_HDR_SIZE sizeof(struct chfs_flash_node_hdr)
|
||||
|
||||
/* Max size we have to read to get all info.
|
||||
* It is max size of chfs_flash_dirent_node with max name length.
|
||||
*/
|
||||
#define CHFS_MAX_NODE_SIZE 299
|
||||
|
||||
/* This will identify CHfs nodes */
|
||||
#define CHFS_FS_MAGIC_BITMASK 0x4AF1
|
||||
|
||||
/**
|
||||
* struct chfs_flash_node_hdr - node header, its members are same for
|
||||
* all nodes, used at scan
|
||||
* @magic: filesystem magic
|
||||
* @type: node type
|
||||
* @length: length of node
|
||||
* @hdr_crc: crc of the first 3 members
|
||||
*/
|
||||
struct chfs_flash_node_hdr
|
||||
{
|
||||
le16 magic;
|
||||
le16 type;
|
||||
le32 length;
|
||||
le32 hdr_crc;
|
||||
} __packed;
|
||||
|
||||
/**
|
||||
* struct chfs_flash_vnode - vnode informations stored on flash
|
||||
* @magic: filesystem magic
|
||||
* @type: node type (CHFS_NODETYPE_VNODE)
|
||||
* @length: length of node
|
||||
* @hdr_crc: crc of the first 3 members
|
||||
* @vno: vnode identifier id
|
||||
* @version: vnode's version number
|
||||
* @uid: owner of the file
|
||||
* @gid: group of file
|
||||
* @mode: permissions for vnode
|
||||
* @dn_size: size of written out data nodes
|
||||
* @atime: last access times
|
||||
* @mtime: last modification time
|
||||
* @ctime: change time
|
||||
* @dsize: size of the node's data
|
||||
* @node_crc: crc of full node
|
||||
*/
|
||||
struct chfs_flash_vnode
|
||||
{
|
||||
le16 magic; /*0 */
|
||||
le16 type; /*2 */
|
||||
le32 length; /*4 */
|
||||
le32 hdr_crc; /*8 */
|
||||
le64 vno; /*12*/
|
||||
le64 version; /*20*/
|
||||
le32 uid; /*28*/
|
||||
le32 gid; /*32*/
|
||||
le32 mode; /*36*/
|
||||
le32 dn_size; /*40*/
|
||||
le32 atime; /*44*/
|
||||
le32 mtime; /*48*/
|
||||
le32 ctime; /*52*/
|
||||
le32 dsize; /*56*/
|
||||
le32 node_crc; /*60*/
|
||||
} __packed;
|
||||
|
||||
/**
|
||||
* struct chfs_flash_data_node - node informations of data stored on flash
|
||||
* @magic: filesystem magic
|
||||
* @type: node type (CHFS_NODETYPE_DATA)
|
||||
* @length: length of node with data
|
||||
* @hdr_crc: crc of the first 3 members
|
||||
* @vno: vnode identifier id
|
||||
* @version: vnode's version number
|
||||
* @offset: offset in the file where write begins
|
||||
* @data_length: length of data
|
||||
* @data_crc: crc of data
|
||||
* @node_crc: crc of full node
|
||||
* @data: array of data
|
||||
*/
|
||||
struct chfs_flash_data_node
|
||||
{
|
||||
le16 magic;
|
||||
le16 type;
|
||||
le32 length;
|
||||
le32 hdr_crc;
|
||||
le64 vno;
|
||||
le64 version;
|
||||
le64 offset;
|
||||
le32 data_length;
|
||||
le32 data_crc;
|
||||
le32 node_crc;
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
|
||||
/**
|
||||
* struct chfs_flash_dirent_node - vnode informations stored on flash
|
||||
* @magic: filesystem magic
|
||||
* @type: node type (CHFS_NODETYPE_DIRENT)
|
||||
* @length: length of node
|
||||
* @hdr_crc: crc of the first 3 members
|
||||
* @vno: vnode identifier id
|
||||
* @pvno: vnode identifier id of parent vnode
|
||||
* @version: vnode's version number
|
||||
* @mctime:
|
||||
* @nsize: length of name
|
||||
* @dtype: file type
|
||||
* @unused: just for padding
|
||||
* @name_crc: crc of name
|
||||
* @node_crc: crc of full node
|
||||
* @name: name of the directory entry
|
||||
*/
|
||||
struct chfs_flash_dirent_node
|
||||
{
|
||||
le16 magic;
|
||||
le16 type;
|
||||
le32 length;
|
||||
le32 hdr_crc;
|
||||
le64 vno;
|
||||
le64 pvno;
|
||||
le64 version;
|
||||
le32 mctime;
|
||||
uint8_t nsize;
|
||||
uint8_t dtype;
|
||||
uint8_t unused[2];
|
||||
le32 name_crc;
|
||||
le32 node_crc;
|
||||
uint8_t name[0];
|
||||
} __packed;
|
||||
|
||||
/**
|
||||
* struct chfs_flash_padding_node - node informations of data stored on
|
||||
* flash
|
||||
* @magic: filesystem magic
|
||||
* @type: node type (CHFS_NODETYPE_PADDING)
|
||||
* @length: length of node
|
||||
* @hdr_crc: crc of the first 3 members
|
||||
*/
|
||||
struct chfs_flash_padding_node
|
||||
{
|
||||
le16 magic;
|
||||
le16 type;
|
||||
le32 length;
|
||||
le32 hdr_crc;
|
||||
} __packed;
|
||||
|
||||
#endif /* __CHFS_MEDIA_H__ */
|
||||
@@ -1,372 +0,0 @@
|
||||
/* $NetBSD: ext2fs.h,v 1.29 2009/11/27 11:16:54 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 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.
|
||||
*
|
||||
* @(#)fs.h 8.10 (Berkeley) 10/27/94
|
||||
* Modified for ext2fs by Manuel Bouyer.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 Manuel Bouyer.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @(#)fs.h 8.10 (Berkeley) 10/27/94
|
||||
* Modified for ext2fs by Manuel Bouyer.
|
||||
*/
|
||||
|
||||
#ifndef _UFS_EXT2FS_EXT2FS_H_
|
||||
#define _UFS_EXT2FS_EXT2FS_H_
|
||||
|
||||
#include <sys/bswap.h>
|
||||
|
||||
/*
|
||||
* Each disk drive contains some number of file systems.
|
||||
* A file system consists of a number of cylinder groups.
|
||||
* Each cylinder group has inodes and data.
|
||||
*
|
||||
* A file system is described by its super-block, which in turn
|
||||
* describes the cylinder groups. The super-block is critical
|
||||
* data and is replicated in each cylinder group to protect against
|
||||
* catastrophic loss. This is done at `newfs' time and the critical
|
||||
* super-block data does not change, so the copies need not be
|
||||
* referenced further unless disaster strikes.
|
||||
*
|
||||
* The first boot and super blocks are given in absolute disk addresses.
|
||||
* The byte-offset forms are preferred, as they don't imply a sector size.
|
||||
*/
|
||||
#define BBSIZE 1024
|
||||
#define SBSIZE 1024
|
||||
#define BBOFF ((off_t)(0))
|
||||
#define SBOFF ((off_t)(BBOFF + BBSIZE))
|
||||
#define BBLOCK ((daddr_t)(0))
|
||||
#define SBLOCK ((daddr_t)(BBLOCK + BBSIZE / DEV_BSIZE))
|
||||
|
||||
/*
|
||||
* Addresses stored in inodes are capable of addressing blocks
|
||||
* XXX
|
||||
*/
|
||||
|
||||
/*
|
||||
* MINBSIZE is the smallest allowable block size.
|
||||
* MINBSIZE must be big enough to hold a cylinder group block,
|
||||
* thus changes to (struct cg) must keep its size within MINBSIZE.
|
||||
* Note that super blocks are always of size SBSIZE,
|
||||
* and that both SBSIZE and MAXBSIZE must be >= MINBSIZE.
|
||||
*/
|
||||
#define LOG_MINBSIZE 10
|
||||
#define MINBSIZE (1 << LOG_MINBSIZE)
|
||||
|
||||
/*
|
||||
* The path name on which the file system is mounted is maintained
|
||||
* in fs_fsmnt. MAXMNTLEN defines the amount of space allocated in
|
||||
* the super block for this name.
|
||||
*/
|
||||
#define MAXMNTLEN 512
|
||||
|
||||
/*
|
||||
* MINFREE gives the minimum acceptable percentage of file system
|
||||
* blocks which may be free. If the freelist drops below this level
|
||||
* only the superuser may continue to allocate blocks. This may
|
||||
* be set to 0 if no reserve of free blocks is deemed necessary,
|
||||
* however throughput drops by fifty percent if the file system
|
||||
* is run at between 95% and 100% full; thus the minimum default
|
||||
* value of fs_minfree is 5%. However, to get good clustering
|
||||
* performance, 10% is a better choice. hence we use 10% as our
|
||||
* default value. With 10% free space, fragmentation is not a
|
||||
* problem, so we choose to optimize for time.
|
||||
*/
|
||||
#define MINFREE 5
|
||||
|
||||
/*
|
||||
* Super block for an ext2fs file system.
|
||||
*/
|
||||
struct ext2fs {
|
||||
uint32_t e2fs_icount; /* Inode count */
|
||||
uint32_t e2fs_bcount; /* blocks count */
|
||||
uint32_t e2fs_rbcount; /* reserved blocks count */
|
||||
uint32_t e2fs_fbcount; /* free blocks count */
|
||||
uint32_t e2fs_ficount; /* free inodes count */
|
||||
uint32_t e2fs_first_dblock; /* first data block */
|
||||
uint32_t e2fs_log_bsize; /* block size = 1024*(2^e2fs_log_bsize) */
|
||||
uint32_t e2fs_fsize; /* fragment size */
|
||||
uint32_t e2fs_bpg; /* blocks per group */
|
||||
uint32_t e2fs_fpg; /* frags per group */
|
||||
uint32_t e2fs_ipg; /* inodes per group */
|
||||
uint32_t e2fs_mtime; /* mount time */
|
||||
uint32_t e2fs_wtime; /* write time */
|
||||
uint16_t e2fs_mnt_count; /* mount count */
|
||||
uint16_t e2fs_max_mnt_count; /* max mount count */
|
||||
uint16_t e2fs_magic; /* magic number */
|
||||
uint16_t e2fs_state; /* file system state */
|
||||
uint16_t e2fs_beh; /* behavior on errors */
|
||||
uint16_t e2fs_minrev; /* minor revision level */
|
||||
uint32_t e2fs_lastfsck; /* time of last fsck */
|
||||
uint32_t e2fs_fsckintv; /* max time between fscks */
|
||||
uint32_t e2fs_creator; /* creator OS */
|
||||
uint32_t e2fs_rev; /* revision level */
|
||||
uint16_t e2fs_ruid; /* default uid for reserved blocks */
|
||||
uint16_t e2fs_rgid; /* default gid for reserved blocks */
|
||||
/* EXT2_DYNAMIC_REV superblocks */
|
||||
uint32_t e2fs_first_ino; /* first non-reserved inode */
|
||||
uint16_t e2fs_inode_size; /* size of inode structure */
|
||||
uint16_t e2fs_block_group_nr; /* block grp number of this sblk*/
|
||||
uint32_t e2fs_features_compat; /* compatible feature set */
|
||||
uint32_t e2fs_features_incompat; /* incompatible feature set */
|
||||
uint32_t e2fs_features_rocompat; /* RO-compatible feature set */
|
||||
uint8_t e2fs_uuid[16]; /* 128-bit uuid for volume */
|
||||
char e2fs_vname[16]; /* volume name */
|
||||
char e2fs_fsmnt[64]; /* name mounted on */
|
||||
uint32_t e2fs_algo; /* For compression */
|
||||
uint8_t e2fs_prealloc; /* # of blocks to preallocate */
|
||||
uint8_t e2fs_dir_prealloc; /* # of blocks to preallocate for dir */
|
||||
uint16_t e2fs_reserved_ngdb; /* # of reserved gd blocks for resize */
|
||||
uint32_t reserved2[204];
|
||||
};
|
||||
|
||||
|
||||
/* in-memory data for ext2fs */
|
||||
struct m_ext2fs {
|
||||
struct ext2fs e2fs;
|
||||
u_char e2fs_fsmnt[MAXMNTLEN]; /* name mounted on */
|
||||
int8_t e2fs_ronly; /* mounted read-only flag */
|
||||
int8_t e2fs_fmod; /* super block modified flag */
|
||||
int32_t e2fs_bsize; /* block size */
|
||||
int32_t e2fs_bshift; /* ``lblkno'' calc of logical blkno */
|
||||
int32_t e2fs_bmask; /* ``blkoff'' calc of blk offsets */
|
||||
int64_t e2fs_qbmask; /* ~fs_bmask - for use with quad size */
|
||||
int32_t e2fs_fsbtodb; /* fsbtodb and dbtofsb shift constant */
|
||||
int32_t e2fs_ncg; /* number of cylinder groups */
|
||||
int32_t e2fs_ngdb; /* number of group descriptor block */
|
||||
int32_t e2fs_ipb; /* number of inodes per block */
|
||||
int32_t e2fs_itpg; /* number of inode table per group */
|
||||
struct ext2_gd *e2fs_gd; /* group descripors */
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Filesystem identification
|
||||
*/
|
||||
#define E2FS_MAGIC 0xef53 /* the ext2fs magic number */
|
||||
#define E2FS_REV0 0 /* GOOD_OLD revision */
|
||||
#define E2FS_REV1 1 /* Support compat/incompat features */
|
||||
|
||||
/* compatible/incompatible features */
|
||||
#define EXT2F_COMPAT_PREALLOC 0x0001
|
||||
#define EXT2F_COMPAT_HASJOURNAL 0x0004
|
||||
#define EXT2F_COMPAT_RESIZE 0x0010
|
||||
|
||||
#define EXT2F_ROCOMPAT_SPARSESUPER 0x0001
|
||||
#define EXT2F_ROCOMPAT_LARGEFILE 0x0002
|
||||
#define EXT2F_ROCOMPAT_BTREE_DIR 0x0004
|
||||
|
||||
#define EXT2F_INCOMPAT_COMP 0x0001
|
||||
#define EXT2F_INCOMPAT_FTYPE 0x0002
|
||||
|
||||
/*
|
||||
* Features supported in this implementation
|
||||
*
|
||||
* We support the following REV1 features:
|
||||
* - EXT2F_ROCOMPAT_SPARSESUPER
|
||||
* superblock backups stored only in cg_has_sb(bno) groups
|
||||
* - EXT2F_ROCOMPAT_LARGEFILE
|
||||
* use e2di_dacl in struct ext2fs_dinode to store
|
||||
* upper 32bit of size for >2GB files
|
||||
* - EXT2F_INCOMPAT_FTYPE
|
||||
* store file type to e2d_type in struct ext2fs_direct
|
||||
* (on REV0 e2d_namlen is uint16_t and no e2d_type, like ffs)
|
||||
*/
|
||||
#define EXT2F_COMPAT_SUPP 0x0000
|
||||
#define EXT2F_ROCOMPAT_SUPP (EXT2F_ROCOMPAT_SPARSESUPER \
|
||||
| EXT2F_ROCOMPAT_LARGEFILE)
|
||||
#define EXT2F_INCOMPAT_SUPP EXT2F_INCOMPAT_FTYPE
|
||||
|
||||
/*
|
||||
* Definitions of behavior on errors
|
||||
*/
|
||||
#define E2FS_BEH_CONTINUE 1 /* continue operation */
|
||||
#define E2FS_BEH_READONLY 2 /* remount fs read only */
|
||||
#define E2FS_BEH_PANIC 3 /* cause panic */
|
||||
#define E2FS_BEH_DEFAULT E2FS_BEH_CONTINUE
|
||||
|
||||
/*
|
||||
* OS identification
|
||||
*/
|
||||
#define E2FS_OS_LINUX 0
|
||||
#define E2FS_OS_HURD 1
|
||||
#define E2FS_OS_MASIX 2
|
||||
#define E2FS_OS_FREEBSD 3
|
||||
#define E2FS_OS_LITES 4
|
||||
|
||||
/*
|
||||
* Filesystem clean flags
|
||||
*/
|
||||
#define E2FS_ISCLEAN 0x01
|
||||
#define E2FS_ERRORS 0x02
|
||||
|
||||
/* ext2 file system block group descriptor */
|
||||
|
||||
struct ext2_gd {
|
||||
uint32_t ext2bgd_b_bitmap; /* blocks bitmap block */
|
||||
uint32_t ext2bgd_i_bitmap; /* inodes bitmap block */
|
||||
uint32_t ext2bgd_i_tables; /* inodes table block */
|
||||
uint16_t ext2bgd_nbfree; /* number of free blocks */
|
||||
uint16_t ext2bgd_nifree; /* number of free inodes */
|
||||
uint16_t ext2bgd_ndirs; /* number of directories */
|
||||
uint16_t reserved;
|
||||
uint32_t reserved2[3];
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* If the EXT2F_ROCOMPAT_SPARSESUPER flag is set, the cylinder group has a
|
||||
* copy of the super and cylinder group descriptors blocks only if it's
|
||||
* 1, a power of 3, 5 or 7
|
||||
*/
|
||||
|
||||
static __inline int cg_has_sb(int) __unused;
|
||||
static __inline int
|
||||
cg_has_sb(int i)
|
||||
{
|
||||
int a3, a5, a7;
|
||||
|
||||
if (i == 0 || i == 1)
|
||||
return 1;
|
||||
for (a3 = 3, a5 = 5, a7 = 7;
|
||||
a3 <= i || a5 <= i || a7 <= i;
|
||||
a3 *= 3, a5 *= 5, a7 *= 7)
|
||||
if (i == a3 || i == a5 || i == a7)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* EXT2FS metadatas are stored in little-endian byte order. These macros
|
||||
* helps reading theses metadatas
|
||||
*/
|
||||
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
# define h2fs16(x) (x)
|
||||
# define h2fs32(x) (x)
|
||||
# define h2fs64(x) (x)
|
||||
# define fs2h16(x) (x)
|
||||
# define fs2h32(x) (x)
|
||||
# define fs2h64(x) (x)
|
||||
# define e2fs_sbload(old, new) memcpy((new), (old), SBSIZE);
|
||||
# define e2fs_cgload(old, new, size) memcpy((new), (old), (size));
|
||||
# define e2fs_sbsave(old, new) memcpy((new), (old), SBSIZE);
|
||||
# define e2fs_cgsave(old, new, size) memcpy((new), (old), (size));
|
||||
#else
|
||||
void e2fs_sb_bswap(struct ext2fs *, struct ext2fs *);
|
||||
void e2fs_cg_bswap(struct ext2_gd *, struct ext2_gd *, int);
|
||||
# define h2fs16(x) bswap16(x)
|
||||
# define h2fs32(x) bswap32(x)
|
||||
# define h2fs64(x) bswap64(x)
|
||||
# define fs2h16(x) bswap16(x)
|
||||
# define fs2h32(x) bswap32(x)
|
||||
# define fs2h64(x) bswap64(x)
|
||||
# define e2fs_sbload(old, new) e2fs_sb_bswap((old), (new))
|
||||
# define e2fs_cgload(old, new, size) e2fs_cg_bswap((old), (new), (size));
|
||||
# define e2fs_sbsave(old, new) e2fs_sb_bswap((old), (new))
|
||||
# define e2fs_cgsave(old, new, size) e2fs_cg_bswap((old), (new), (size));
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Turn file system block numbers into disk block addresses.
|
||||
* This maps file system blocks to device size blocks.
|
||||
*/
|
||||
#define fsbtodb(fs, b) ((b) << (fs)->e2fs_fsbtodb)
|
||||
#define dbtofsb(fs, b) ((b) >> (fs)->e2fs_fsbtodb)
|
||||
|
||||
/*
|
||||
* Macros for handling inode numbers:
|
||||
* inode number to file system block offset.
|
||||
* inode number to cylinder group number.
|
||||
* inode number to file system block address.
|
||||
*/
|
||||
#define ino_to_cg(fs, x) (((x) - 1) / (fs)->e2fs.e2fs_ipg)
|
||||
#define ino_to_fsba(fs, x) \
|
||||
((fs)->e2fs_gd[ino_to_cg((fs), (x))].ext2bgd_i_tables + \
|
||||
(((x) - 1) % (fs)->e2fs.e2fs_ipg) / (fs)->e2fs_ipb)
|
||||
#define ino_to_fsbo(fs, x) (((x) - 1) % (fs)->e2fs_ipb)
|
||||
|
||||
/*
|
||||
* Give cylinder group number for a file system block.
|
||||
* Give cylinder group block number for a file system block.
|
||||
*/
|
||||
#define dtog(fs, d) (((d) - (fs)->e2fs.e2fs_first_dblock) / (fs)->e2fs.e2fs_fpg)
|
||||
#define dtogd(fs, d) \
|
||||
(((d) - (fs)->e2fs.e2fs_first_dblock) % (fs)->e2fs.e2fs_fpg)
|
||||
|
||||
/*
|
||||
* The following macros optimize certain frequently calculated
|
||||
* quantities by using shifts and masks in place of divisions
|
||||
* modulos and multiplications.
|
||||
*/
|
||||
#define blkoff(fs, loc) /* calculates (loc % fs->e2fs_bsize) */ \
|
||||
((loc) & (fs)->e2fs_qbmask)
|
||||
#define lblktosize(fs, blk) /* calculates (blk * fs->e2fs_bsize) */ \
|
||||
((blk) << (fs)->e2fs_bshift)
|
||||
#define lblkno(fs, loc) /* calculates (loc / fs->e2fs_bsize) */ \
|
||||
((loc) >> (fs)->e2fs_bshift)
|
||||
#define blkroundup(fs, size) /* calculates roundup(size, fs->e2fs_bsize) */ \
|
||||
(((size) + (fs)->e2fs_qbmask) & (fs)->e2fs_bmask)
|
||||
#define fragroundup(fs, size) /* calculates roundup(size, fs->e2fs_bsize) */ \
|
||||
(((size) + (fs)->e2fs_qbmask) & (fs)->e2fs_bmask)
|
||||
/*
|
||||
* Determine the number of available frags given a
|
||||
* percentage to hold in reserve.
|
||||
*/
|
||||
#define freespace(fs) \
|
||||
((fs)->e2fs.e2fs_fbcount - (fs)->e2fs.e2fs_rbcount)
|
||||
|
||||
/*
|
||||
* Number of indirects in a file system block.
|
||||
*/
|
||||
#define NINDIR(fs) ((fs)->e2fs_bsize / sizeof(uint32_t))
|
||||
|
||||
#endif /* !_UFS_EXT2FS_EXT2FS_H_ */
|
||||
@@ -1,186 +0,0 @@
|
||||
/* $NetBSD: ext2fs_dinode.h,v 1.22 2009/11/27 11:16:54 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1989, 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.
|
||||
*
|
||||
* @(#)dinode.h 8.6 (Berkeley) 9/13/94
|
||||
* Modified for ext2fs by Manuel Bouyer.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 Manuel Bouyer.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @(#)dinode.h 8.6 (Berkeley) 9/13/94
|
||||
* Modified for ext2fs by Manuel Bouyer.
|
||||
*/
|
||||
|
||||
#ifndef _UFS_EXT2FS_EXT2FS_DINODE_H_
|
||||
#define _UFS_EXT2FS_EXT2FS_DINODE_H_
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
/*
|
||||
* The root inode is the root of the file system. Inode 0 can't be used for
|
||||
* normal purposes and bad blocks are normally linked to inode 1, thus
|
||||
* the root inode is 2.
|
||||
* Inode 3 to 10 are reserved in ext2fs.
|
||||
*/
|
||||
#define EXT2_BADBLKINO ((ino_t)1)
|
||||
#define EXT2_ROOTINO ((ino_t)2)
|
||||
#define EXT2_ACLIDXINO ((ino_t)3)
|
||||
#define EXT2_ACLDATAINO ((ino_t)4)
|
||||
#define EXT2_BOOTLOADERINO ((ino_t)5)
|
||||
#define EXT2_UNDELDIRINO ((ino_t)6)
|
||||
#define EXT2_RESIZEINO ((ino_t)7)
|
||||
#define EXT2_JOURNALINO ((ino_t)8)
|
||||
#define EXT2_FIRSTINO ((ino_t)11)
|
||||
|
||||
/*
|
||||
* A dinode contains all the meta-data associated with a UFS file.
|
||||
* This structure defines the on-disk format of a dinode. Since
|
||||
* this structure describes an on-disk structure, all its fields
|
||||
* are defined by types with precise widths.
|
||||
*/
|
||||
|
||||
#define NDADDR 12 /* Direct addresses in inode. */
|
||||
#define NIADDR 3 /* Indirect addresses in inode. */
|
||||
|
||||
#define EXT2_MAXSYMLINKLEN ((NDADDR+NIADDR) * sizeof (uint32_t))
|
||||
|
||||
struct ext2fs_dinode {
|
||||
uint16_t e2di_mode; /* 0: IFMT, permissions; see below. */
|
||||
uint16_t e2di_uid; /* 2: Owner UID */
|
||||
uint32_t e2di_size; /* 4: Size (in bytes) */
|
||||
uint32_t e2di_atime; /* 8: Acces time */
|
||||
uint32_t e2di_ctime; /* 12: Create time */
|
||||
uint32_t e2di_mtime; /* 16: Modification time */
|
||||
uint32_t e2di_dtime; /* 20: Deletion time */
|
||||
uint16_t e2di_gid; /* 24: Owner GID */
|
||||
uint16_t e2di_nlink; /* 26: File link count */
|
||||
uint32_t e2di_nblock; /* 28: Blocks count */
|
||||
uint32_t e2di_flags; /* 32: Status flags (chflags) */
|
||||
uint32_t e2di_linux_reserved1; /* 36 */
|
||||
uint32_t e2di_blocks[NDADDR+NIADDR]; /* 40: disk blocks */
|
||||
uint32_t e2di_gen; /* 100: generation number */
|
||||
uint32_t e2di_facl; /* 104: file ACL (not implemented) */
|
||||
uint32_t e2di_dacl; /* 108: dir ACL (not implemented) */
|
||||
uint32_t e2di_faddr; /* 112: fragment address */
|
||||
uint8_t e2di_nfrag; /* 116: fragment number */
|
||||
uint8_t e2di_fsize; /* 117: fragment size */
|
||||
uint16_t e2di_linux_reserved2; /* 118 */
|
||||
uint16_t e2di_uid_high; /* 120: Owner UID top 16 bits */
|
||||
uint16_t e2di_gid_high; /* 122: Owner GID top 16 bits */
|
||||
uint32_t e2di_linux_reserved3; /* 124 */
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define E2MAXSYMLINKLEN ((NDADDR + NIADDR) * sizeof(uint32_t))
|
||||
|
||||
/* File permissions. */
|
||||
#define EXT2_IEXEC 0000100 /* Executable. */
|
||||
#define EXT2_IWRITE 0000200 /* Writable. */
|
||||
#define EXT2_IREAD 0000400 /* Readable. */
|
||||
#define EXT2_ISVTX 0001000 /* Sticky bit. */
|
||||
#define EXT2_ISGID 0002000 /* Set-gid. */
|
||||
#define EXT2_ISUID 0004000 /* Set-uid. */
|
||||
|
||||
/* File types. */
|
||||
#define EXT2_IFMT 0170000 /* Mask of file type. */
|
||||
#define EXT2_IFIFO 0010000 /* Named pipe (fifo). */
|
||||
#define EXT2_IFCHR 0020000 /* Character device. */
|
||||
#define EXT2_IFDIR 0040000 /* Directory file. */
|
||||
#define EXT2_IFBLK 0060000 /* Block device. */
|
||||
#define EXT2_IFREG 0100000 /* Regular file. */
|
||||
#define EXT2_IFLNK 0120000 /* Symbolic link. */
|
||||
#define EXT2_IFSOCK 0140000 /* UNIX domain socket. */
|
||||
|
||||
/* file flags */
|
||||
#define EXT2_SECRM 0x00000001 /* Secure deletion */
|
||||
#define EXT2_UNRM 0x00000002 /* Undelete */
|
||||
#define EXT2_COMPR 0x00000004 /* Compress file */
|
||||
#define EXT2_SYNC 0x00000008 /* Synchronous updates */
|
||||
#define EXT2_IMMUTABLE 0x00000010 /* Immutable file */
|
||||
#define EXT2_APPEND 0x00000020 /* writes to file may only append */
|
||||
#define EXT2_NODUMP 0x00000040 /* do not dump file */
|
||||
|
||||
/* Size of on-disk inode. */
|
||||
#define EXT2_REV0_DINODE_SIZE sizeof(struct ext2fs_dinode)
|
||||
#define EXT2_DINODE_SIZE(fs) ((fs)->e2fs.e2fs_rev > E2FS_REV0 ? \
|
||||
(fs)->e2fs.e2fs_inode_size : \
|
||||
EXT2_REV0_DINODE_SIZE)
|
||||
|
||||
/*
|
||||
* The e2di_blocks fields may be overlaid with other information for
|
||||
* file types that do not have associated disk storage. Block
|
||||
* and character devices overlay the first data block with their
|
||||
* dev_t value. Short symbolic links place their path in the
|
||||
* di_db area.
|
||||
*/
|
||||
|
||||
#define e2di_rdev e2di_blocks[0]
|
||||
#define e2di_shortlink e2di_blocks
|
||||
|
||||
/* e2fs needs byte swapping on big-endian systems */
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
# define e2fs_iload(old, new) \
|
||||
memcpy((new),(old),sizeof(struct ext2fs_dinode))
|
||||
# define e2fs_isave(old, new) \
|
||||
memcpy((new),(old),sizeof(struct ext2fs_dinode))
|
||||
#else
|
||||
void e2fs_i_bswap(struct ext2fs_dinode *, struct ext2fs_dinode *);
|
||||
# define e2fs_iload(old, new) e2fs_i_bswap((old), (new))
|
||||
# define e2fs_isave(old, new) e2fs_i_bswap((old), (new))
|
||||
#endif
|
||||
|
||||
#endif /* !_UFS_EXT2FS_EXT2FS_DINODE_H_ */
|
||||
@@ -1,180 +0,0 @@
|
||||
/* $NetBSD: ext2fs_dir.h,v 1.18 2009/10/19 18:41:17 bouyer Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 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.
|
||||
*
|
||||
* @(#)dir.h 8.4 (Berkeley) 8/10/94
|
||||
* Modified for ext2fs by Manuel Bouyer.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 Manuel Bouyer.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @(#)dir.h 8.4 (Berkeley) 8/10/94
|
||||
* Modified for ext2fs by Manuel Bouyer.
|
||||
*/
|
||||
|
||||
#ifndef _UFS_EXT2FS_EXT2FS_DIR_H_
|
||||
#define _UFS_EXT2FS_EXT2FS_DIR_H_
|
||||
|
||||
/*
|
||||
* Theoretically, directories can be more than 2Gb in length, however, in
|
||||
* practice this seems unlikely. So, we define the type doff_t as a 32-bit
|
||||
* quantity to keep down the cost of doing lookup on a 32-bit machine.
|
||||
*/
|
||||
#define doff_t int32_t
|
||||
#define EXT2FS_MAXDIRSIZE INT32_MAX
|
||||
|
||||
/*
|
||||
* A directory consists of some number of blocks of e2fs_bsize bytes.
|
||||
*
|
||||
* Each block contains some number of directory entry
|
||||
* structures, which are of variable length. Each directory entry has
|
||||
* a struct direct at the front of it, containing its inode number,
|
||||
* the length of the entry, and the length of the name contained in
|
||||
* the entry. These are followed by the name padded to a 4 byte boundary
|
||||
* with null bytes. All names are guaranteed null terminated.
|
||||
* The maximum length of a name in a directory is EXT2FS_MAXNAMLEN.
|
||||
*
|
||||
* The macro EXT2FS_DIRSIZ(fmt, dp) gives the amount of space required to
|
||||
* represent a directory entry. Free space in a directory is represented by
|
||||
* entries which have dp->e2d_reclen > DIRSIZ(fmt, dp). All d2fs_bsize bytes
|
||||
* in a directory block are claimed by the directory entries. This
|
||||
* usually results in the last entry in a directory having a large
|
||||
* dp->e2d_reclen. When entries are deleted from a directory, the
|
||||
* space is returned to the previous entry in the same directory
|
||||
* block by increasing its dp->e2d_reclen. If the first entry of
|
||||
* a directory block is free, then its dp->e2d_ino is set to 0.
|
||||
* Entries other than the first in a directory do not normally have
|
||||
* dp->e2d_ino set to 0.
|
||||
* Ext2 rev 0 has a 16 bits e2d_namlen. For Ext2 vev 1 this has been split
|
||||
* into a 8 bits e2d_namlen and 8 bits e2d_type (looks like ffs, isnt't it ? :)
|
||||
* It's safe to use this for rev 0 as well because all ext2 are little-endian.
|
||||
*/
|
||||
|
||||
#define EXT2FS_MAXNAMLEN 255
|
||||
|
||||
struct ext2fs_direct {
|
||||
uint32_t e2d_ino; /* inode number of entry */
|
||||
uint16_t e2d_reclen; /* length of this record */
|
||||
uint8_t e2d_namlen; /* length of string in d_name */
|
||||
uint8_t e2d_type; /* file type */
|
||||
char e2d_name[EXT2FS_MAXNAMLEN];/* name with length<=EXT2FS_MAXNAMLEN */
|
||||
};
|
||||
|
||||
/* Ext2 directory file types (not the same as FFS. Sigh.) */
|
||||
#define EXT2_FT_UNKNOWN 0
|
||||
#define EXT2_FT_REG_FILE 1
|
||||
#define EXT2_FT_DIR 2
|
||||
#define EXT2_FT_CHRDEV 3
|
||||
#define EXT2_FT_BLKDEV 4
|
||||
#define EXT2_FT_FIFO 5
|
||||
#define EXT2_FT_SOCK 6
|
||||
#define EXT2_FT_SYMLINK 7
|
||||
|
||||
#define EXT2_FT_MAX 8
|
||||
|
||||
#define E2IFTODT(mode) (((mode) & 0170000) >> 12)
|
||||
|
||||
static __inline uint8_t inot2ext2dt(uint16_t) __unused;
|
||||
static __inline uint8_t
|
||||
inot2ext2dt(uint16_t type)
|
||||
{
|
||||
|
||||
switch (type) {
|
||||
case E2IFTODT(EXT2_IFIFO):
|
||||
return EXT2_FT_FIFO;
|
||||
case E2IFTODT(EXT2_IFCHR):
|
||||
return EXT2_FT_CHRDEV;
|
||||
case E2IFTODT(EXT2_IFDIR):
|
||||
return EXT2_FT_DIR;
|
||||
case E2IFTODT(EXT2_IFBLK):
|
||||
return EXT2_FT_BLKDEV;
|
||||
case E2IFTODT(EXT2_IFREG):
|
||||
return EXT2_FT_REG_FILE;
|
||||
case E2IFTODT(EXT2_IFLNK):
|
||||
return EXT2_FT_SYMLINK;
|
||||
case E2IFTODT(EXT2_IFSOCK):
|
||||
return EXT2_FT_SOCK;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The EXT2FS_DIRSIZ macro gives the minimum record length which will hold
|
||||
* the directory entryfor a name len "len" (without the terminating null byte).
|
||||
* This requires the amount of space in struct direct
|
||||
* without the d_name field, plus enough space for the name without a
|
||||
* terminating null byte, rounded up to a 4 byte boundary.
|
||||
*/
|
||||
#define EXT2FS_DIRSIZ(len) roundup2(8 + len, 4)
|
||||
|
||||
/*
|
||||
* Template for manipulating directories. Should use struct direct's,
|
||||
* but the name field is EXT2FS_MAXNAMLEN - 1, and this just won't do.
|
||||
*/
|
||||
struct ext2fs_dirtemplate {
|
||||
uint32_t dot_ino;
|
||||
int16_t dot_reclen;
|
||||
uint8_t dot_namlen;
|
||||
uint8_t dot_type;
|
||||
char dot_name[4]; /* must be multiple of 4 */
|
||||
uint32_t dotdot_ino;
|
||||
int16_t dotdot_reclen;
|
||||
uint8_t dotdot_namlen;
|
||||
uint8_t dotdot_type;
|
||||
char dotdot_name[4]; /* ditto */
|
||||
};
|
||||
|
||||
#endif /* !_UFS_EXT2FS_EXT2FS_DIR_H_ */
|
||||
@@ -1,179 +0,0 @@
|
||||
/* $NetBSD: ext2fs_extern.h,v 1.43 2011/07/12 16:59:48 dholland Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 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.
|
||||
*
|
||||
* @(#)ffs_extern.h 8.3 (Berkeley) 4/16/94
|
||||
* Modified for ext2fs by Manuel Bouyer.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 Manuel Bouyer.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @(#)ffs_extern.h 8.3 (Berkeley) 4/16/94
|
||||
* Modified for ext2fs by Manuel Bouyer.
|
||||
*/
|
||||
|
||||
#ifndef _UFS_EXT2FS_EXT2FS_EXTERN_H_
|
||||
#define _UFS_EXT2FS_EXT2FS_EXTERN_H_
|
||||
|
||||
struct buf;
|
||||
struct fid;
|
||||
struct m_ext2fs;
|
||||
struct inode;
|
||||
struct mount;
|
||||
struct nameidata;
|
||||
struct lwp;
|
||||
struct proc;
|
||||
struct statvfs;
|
||||
struct timeval;
|
||||
struct ufsmount;
|
||||
struct uio;
|
||||
struct vnode;
|
||||
struct mbuf;
|
||||
struct componentname;
|
||||
|
||||
extern struct pool ext2fs_inode_pool; /* memory pool for inodes */
|
||||
extern struct pool ext2fs_dinode_pool; /* memory pool for dinodes */
|
||||
|
||||
#define EXT2FS_ITIMES(ip, acc, mod, cre) \
|
||||
while ((ip)->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE | IN_MODIFY)) \
|
||||
ext2fs_itimes(ip, acc, mod, cre)
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* ext2fs_alloc.c */
|
||||
int ext2fs_alloc(struct inode *, daddr_t, daddr_t , kauth_cred_t,
|
||||
daddr_t *);
|
||||
int ext2fs_realloccg(struct inode *, daddr_t, daddr_t, int, int ,
|
||||
kauth_cred_t, struct buf **);
|
||||
int ext2fs_valloc(struct vnode *, int, kauth_cred_t, struct vnode **);
|
||||
/* XXX ondisk32 */
|
||||
daddr_t ext2fs_blkpref(struct inode *, daddr_t, int, int32_t *);
|
||||
void ext2fs_blkfree(struct inode *, daddr_t);
|
||||
int ext2fs_vfree(struct vnode *, ino_t, int);
|
||||
|
||||
/* ext2fs_balloc.c */
|
||||
int ext2fs_balloc(struct inode *, daddr_t, int, kauth_cred_t,
|
||||
struct buf **, int);
|
||||
int ext2fs_gop_alloc(struct vnode *, off_t, off_t, int, kauth_cred_t);
|
||||
|
||||
/* ext2fs_bmap.c */
|
||||
int ext2fs_bmap(void *);
|
||||
|
||||
/* ext2fs_inode.c */
|
||||
u_int64_t ext2fs_size(struct inode *);
|
||||
int ext2fs_setsize(struct inode *, u_int64_t);
|
||||
int ext2fs_update(struct vnode *, const struct timespec *,
|
||||
const struct timespec *, int);
|
||||
int ext2fs_truncate(struct vnode *, off_t, int, kauth_cred_t);
|
||||
int ext2fs_inactive(void *);
|
||||
|
||||
/* ext2fs_lookup.c */
|
||||
int ext2fs_readdir(void *);
|
||||
int ext2fs_lookup(void *);
|
||||
int ext2fs_direnter(struct inode *, struct vnode *,
|
||||
const struct ufs_lookup_results *,
|
||||
struct componentname *);
|
||||
int ext2fs_dirremove(struct vnode *, const struct ufs_lookup_results *,
|
||||
struct componentname *);
|
||||
int ext2fs_dirrewrite(struct inode *, const struct ufs_lookup_results *,
|
||||
struct inode *, struct componentname *);
|
||||
int ext2fs_dirempty(struct inode *, ino_t, kauth_cred_t);
|
||||
int ext2fs_checkpath(struct inode *, struct inode *, kauth_cred_t);
|
||||
|
||||
/* ext2fs_subr.c */
|
||||
int ext2fs_blkatoff(struct vnode *, off_t, char **, struct buf **);
|
||||
void ext2fs_fragacct(struct m_ext2fs *, int, int32_t[], int);
|
||||
void ext2fs_itimes(struct inode *, const struct timespec *,
|
||||
const struct timespec *, const struct timespec *);
|
||||
|
||||
/* ext2fs_vfsops.c */
|
||||
VFS_PROTOS(ext2fs);
|
||||
int ext2fs_reload(struct mount *, kauth_cred_t, struct lwp *);
|
||||
int ext2fs_mountfs(struct vnode *, struct mount *);
|
||||
int ext2fs_flushfiles(struct mount *, int);
|
||||
int ext2fs_sbupdate(struct ufsmount *, int);
|
||||
int ext2fs_cgupdate(struct ufsmount *, int);
|
||||
void ext2fs_set_inode_guid(struct inode *);
|
||||
|
||||
/* ext2fs_readwrite.c */
|
||||
int ext2fs_read(void *);
|
||||
int ext2fs_write(void *);
|
||||
|
||||
/* ext2fs_vnops.c */
|
||||
int ext2fs_create(void *);
|
||||
int ext2fs_mknod(void *);
|
||||
int ext2fs_open(void *);
|
||||
int ext2fs_access(void *);
|
||||
int ext2fs_getattr(void *);
|
||||
int ext2fs_setattr(void *);
|
||||
int ext2fs_remove(void *);
|
||||
int ext2fs_link(void *);
|
||||
int ext2fs_rename(void *);
|
||||
int ext2fs_mkdir(void *);
|
||||
int ext2fs_rmdir(void *);
|
||||
int ext2fs_symlink(void *);
|
||||
int ext2fs_readlink(void *);
|
||||
int ext2fs_advlock(void *);
|
||||
int ext2fs_fsync(void *);
|
||||
int ext2fs_vinit(struct mount *, int (**specops)(void *),
|
||||
int (**fifoops)(void *), struct vnode **);
|
||||
int ext2fs_makeinode(int, struct vnode *, struct vnode **,
|
||||
struct componentname *cnp);
|
||||
int ext2fs_reclaim(void *);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#define IS_EXT2_VNODE(vp) (vp->v_tag == VT_EXT2FS)
|
||||
|
||||
extern int (**ext2fs_vnodeop_p)(void *);
|
||||
extern int (**ext2fs_specop_p)(void *);
|
||||
extern int (**ext2fs_fifoop_p)(void *);
|
||||
|
||||
#endif /* !_UFS_EXT2FS_EXT2FS_EXTERN_H_ */
|
||||
@@ -1,211 +0,0 @@
|
||||
/* $NetBSD: ffs_extern.h,v 1.78 2011/06/17 14:23:52 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 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.
|
||||
*
|
||||
* @(#)ffs_extern.h 8.6 (Berkeley) 3/30/95
|
||||
*/
|
||||
|
||||
#ifndef _UFS_FFS_FFS_EXTERN_H_
|
||||
#define _UFS_FFS_FFS_EXTERN_H_
|
||||
|
||||
/*
|
||||
* Sysctl values for the fast filesystem.
|
||||
*/
|
||||
#define FFS_CLUSTERREAD 1 /* cluster reading enabled */
|
||||
#define FFS_CLUSTERWRITE 2 /* cluster writing enabled */
|
||||
#define FFS_REALLOCBLKS 3 /* block reallocation enabled */
|
||||
#define FFS_ASYNCFREE 4 /* asynchronous block freeing enabled */
|
||||
#define FFS_LOG_CHANGEOPT 5 /* log optimalization strategy change */
|
||||
#define FFS_EXTATTR_AUTOCREATE 6 /* size for backing file autocreation */
|
||||
#define FFS_MAXID 7 /* number of valid ffs ids */
|
||||
|
||||
struct buf;
|
||||
struct fid;
|
||||
struct fs;
|
||||
struct inode;
|
||||
struct ufs1_dinode;
|
||||
struct ufs2_dinode;
|
||||
struct mount;
|
||||
struct nameidata;
|
||||
struct lwp;
|
||||
struct statvfs;
|
||||
struct timeval;
|
||||
struct timespec;
|
||||
struct ufsmount;
|
||||
struct uio;
|
||||
struct vnode;
|
||||
struct mbuf;
|
||||
struct cg;
|
||||
|
||||
#if defined(_KERNEL)
|
||||
|
||||
#include <sys/pool.h>
|
||||
|
||||
#define FFS_NOBLK ((daddr_t)-1)
|
||||
|
||||
#define FFS_ITIMES(ip, acc, mod, cre) \
|
||||
while ((ip)->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE | IN_MODIFY)) \
|
||||
ffs_itimes(ip, acc, mod, cre)
|
||||
|
||||
extern pool_cache_t ffs_inode_cache; /* memory pool for inodes */
|
||||
extern pool_cache_t ffs_dinode1_cache; /* memory pool for UFS1 dinodes */
|
||||
extern pool_cache_t ffs_dinode2_cache; /* memory pool for UFS2 dinodes */
|
||||
|
||||
#endif /* defined(_KERNEL) */
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#if defined(_KERNEL)
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/wapbl.h>
|
||||
|
||||
/* ffs_alloc.c */
|
||||
int ffs_alloc(struct inode *, daddr_t, daddr_t , int, int, kauth_cred_t,
|
||||
daddr_t *);
|
||||
int ffs_realloccg(struct inode *, daddr_t, daddr_t, int, int ,
|
||||
kauth_cred_t, struct buf **, daddr_t *);
|
||||
int ffs_valloc(struct vnode *, int, kauth_cred_t, struct vnode **);
|
||||
daddr_t ffs_blkpref_ufs1(struct inode *, daddr_t, int, int, int32_t *);
|
||||
daddr_t ffs_blkpref_ufs2(struct inode *, daddr_t, int, int, int64_t *);
|
||||
int ffs_blkalloc(struct inode *, daddr_t, long);
|
||||
int ffs_blkalloc_ump(struct ufsmount *, daddr_t, long);
|
||||
void ffs_blkfree(struct fs *, struct vnode *, daddr_t, long, ino_t);
|
||||
void ffs_blkfree_snap(struct fs *, struct vnode *, daddr_t, long, ino_t);
|
||||
int ffs_vfree(struct vnode *, ino_t, int);
|
||||
int ffs_checkfreefile(struct fs *, struct vnode *, ino_t);
|
||||
int ffs_freefile(struct mount *, ino_t, int);
|
||||
int ffs_freefile_snap(struct fs *, struct vnode *, ino_t, int);
|
||||
|
||||
/* ffs_balloc.c */
|
||||
int ffs_balloc(struct vnode *, off_t, int, kauth_cred_t, int,
|
||||
struct buf **);
|
||||
|
||||
/* ffs_inode.c */
|
||||
int ffs_update(struct vnode *, const struct timespec *,
|
||||
const struct timespec *, int);
|
||||
int ffs_truncate(struct vnode *, off_t, int, kauth_cred_t);
|
||||
|
||||
/* ffs_vfsops.c */
|
||||
VFS_PROTOS(ffs);
|
||||
|
||||
int ffs_reload(struct mount *, kauth_cred_t, struct lwp *);
|
||||
int ffs_mountfs(struct vnode *, struct mount *, struct lwp *);
|
||||
int ffs_flushfiles(struct mount *, int, struct lwp *);
|
||||
int ffs_sbupdate(struct ufsmount *, int);
|
||||
int ffs_cgupdate(struct ufsmount *, int);
|
||||
|
||||
/* ffs_vnops.c */
|
||||
int ffs_read(void *);
|
||||
int ffs_write(void *);
|
||||
int ffs_fsync(void *);
|
||||
int ffs_spec_fsync(void *);
|
||||
int ffs_reclaim(void *);
|
||||
int ffs_getpages(void *);
|
||||
void ffs_gop_size(struct vnode *, off_t, off_t *, int);
|
||||
int ffs_openextattr(void *);
|
||||
int ffs_closeextattr(void *);
|
||||
int ffs_getextattr(void *);
|
||||
int ffs_setextattr(void *);
|
||||
int ffs_listextattr(void *);
|
||||
int ffs_deleteextattr(void *);
|
||||
int ffs_lock(void *);
|
||||
int ffs_unlock(void *);
|
||||
int ffs_islocked(void *);
|
||||
int ffs_full_fsync(struct vnode *, int);
|
||||
|
||||
/*
|
||||
* Snapshot function prototypes.
|
||||
*/
|
||||
int ffs_snapshot_init(struct ufsmount *);
|
||||
void ffs_snapshot_fini(struct ufsmount *);
|
||||
int ffs_snapblkfree(struct fs *, struct vnode *, daddr_t, long, ino_t);
|
||||
void ffs_snapremove(struct vnode *);
|
||||
int ffs_snapshot(struct mount *, struct vnode *, struct timespec *);
|
||||
void ffs_snapshot_mount(struct mount *);
|
||||
void ffs_snapshot_unmount(struct mount *);
|
||||
void ffs_snapgone(struct inode *);
|
||||
int ffs_snapshot_read(struct vnode *, struct uio *, int);
|
||||
|
||||
/* Write Ahead Physical Block Logging */
|
||||
void ffs_wapbl_verify_inodes(struct mount *, const char *);
|
||||
void ffs_wapbl_replay_finish(struct mount *);
|
||||
int ffs_wapbl_start(struct mount *);
|
||||
int ffs_wapbl_stop(struct mount *, int);
|
||||
int ffs_wapbl_replay_start(struct mount *, struct fs *, struct vnode *);
|
||||
void ffs_wapbl_blkalloc(struct fs *, struct vnode *, daddr_t, int);
|
||||
|
||||
void ffs_wapbl_sync_metadata(struct mount *, daddr_t *, int *, int);
|
||||
void ffs_wapbl_abort_sync_metadata(struct mount *, daddr_t *, int *, int);
|
||||
|
||||
extern int (**ffs_vnodeop_p)(void *);
|
||||
extern int (**ffs_specop_p)(void *);
|
||||
extern int (**ffs_fifoop_p)(void *);
|
||||
|
||||
#endif /* defined(_KERNEL) */
|
||||
|
||||
/* ffs_appleufs.c */
|
||||
struct appleufslabel;
|
||||
u_int16_t ffs_appleufs_cksum(const struct appleufslabel *);
|
||||
int ffs_appleufs_validate(const char*, const struct appleufslabel *,
|
||||
struct appleufslabel *);
|
||||
void ffs_appleufs_set(struct appleufslabel *, const char *, time_t,
|
||||
uint64_t);
|
||||
|
||||
/* ffs_bswap.c */
|
||||
void ffs_sb_swap(struct fs*, struct fs *);
|
||||
void ffs_dinode1_swap(struct ufs1_dinode *, struct ufs1_dinode *);
|
||||
void ffs_dinode2_swap(struct ufs2_dinode *, struct ufs2_dinode *);
|
||||
struct csum;
|
||||
void ffs_csum_swap(struct csum *, struct csum *, int);
|
||||
struct csum_total;
|
||||
void ffs_csumtotal_swap(struct csum_total *, struct csum_total *);
|
||||
void ffs_cg_swap(struct cg *, struct cg *, struct fs *);
|
||||
|
||||
/* ffs_subr.c */
|
||||
#if defined(_KERNEL)
|
||||
void ffs_load_inode(struct buf *, struct inode *, struct fs *, ino_t);
|
||||
int ffs_getblk(struct vnode *, daddr_t, daddr_t, int, bool, buf_t **);
|
||||
#endif /* defined(_KERNEL) */
|
||||
void ffs_fragacct(struct fs *, int, int32_t[], int, int);
|
||||
int ffs_isblock(struct fs *, u_char *, int32_t);
|
||||
int ffs_isfreeblock(struct fs *, u_char *, int32_t);
|
||||
void ffs_clrblock(struct fs *, u_char *, int32_t);
|
||||
void ffs_setblock(struct fs *, u_char *, int32_t);
|
||||
void ffs_itimes(struct inode *, const struct timespec *,
|
||||
const struct timespec *, const struct timespec *);
|
||||
void ffs_clusteracct(struct fs *, struct cg *, int32_t, int);
|
||||
|
||||
/* ffs_quota2.c */
|
||||
int ffs_quota2_mount(struct mount *);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_UFS_FFS_FFS_EXTERN_H_ */
|
||||
@@ -1,752 +0,0 @@
|
||||
/* $NetBSD: fs.h,v 1.56 2011/03/06 17:08:38 bouyer Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 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.
|
||||
*
|
||||
* @(#)fs.h 8.13 (Berkeley) 3/21/95
|
||||
*/
|
||||
|
||||
/*
|
||||
* NOTE: COORDINATE ON-DISK FORMAT CHANGES WITH THE FREEBSD PROJECT.
|
||||
*/
|
||||
|
||||
#ifndef _UFS_FFS_FS_H_
|
||||
#define _UFS_FFS_FS_H_
|
||||
|
||||
/*
|
||||
* Each disk drive contains some number of file systems.
|
||||
* A file system consists of a number of cylinder groups.
|
||||
* Each cylinder group has inodes and data.
|
||||
*
|
||||
* A file system is described by its super-block, which in turn
|
||||
* describes the cylinder groups. The super-block is critical
|
||||
* data and is replicated in each cylinder group to protect against
|
||||
* catastrophic loss. This is done at `newfs' time and the critical
|
||||
* super-block data does not change, so the copies need not be
|
||||
* referenced further unless disaster strikes.
|
||||
*
|
||||
* For file system fs, the offsets of the various blocks of interest
|
||||
* are given in the super block as:
|
||||
* [fs->fs_sblkno] Super-block
|
||||
* [fs->fs_cblkno] Cylinder group block
|
||||
* [fs->fs_iblkno] Inode blocks
|
||||
* [fs->fs_dblkno] Data blocks
|
||||
* The beginning of cylinder group cg in fs, is given by
|
||||
* the ``cgbase(fs, cg)'' macro.
|
||||
*
|
||||
* Depending on the architecture and the media, the superblock may
|
||||
* reside in any one of four places. For tiny media where every block
|
||||
* counts, it is placed at the very front of the partition. Historically,
|
||||
* UFS1 placed it 8K from the front to leave room for the disk label and
|
||||
* a small bootstrap. For UFS2 it got moved to 64K from the front to leave
|
||||
* room for the disk label and a bigger bootstrap, and for really piggy
|
||||
* systems we check at 256K from the front if the first three fail. In
|
||||
* all cases the size of the superblock will be SBLOCKSIZE. All values are
|
||||
* given in byte-offset form, so they do not imply a sector size. The
|
||||
* SBLOCKSEARCH specifies the order in which the locations should be searched.
|
||||
*
|
||||
* Unfortunately the UFS2/FFSv2 change was done without adequate consideration
|
||||
* of backward compatibility. In particular 'newfs' for a FFSv2 partition
|
||||
* must overwrite any old FFSv1 superblock at 8k, and preferrably as many
|
||||
* of the alternates as it can find - otherwise attempting to mount on a
|
||||
* system that only supports FFSv1 is likely to succeed!.
|
||||
* For a small FFSv1 filesystem, an old FFSv2 superblock can be left on
|
||||
* the disk, and a system that tries to find an FFSv2 filesystem in preference
|
||||
* to and FFSv1 one (as NetBSD does) can mount the old FFSv2 filesystem.
|
||||
* As a added bonus, the 'first alternate' superblock of a FFSv1 filesystem
|
||||
* with 64k blocks is at 64k - just where the code looks first when playing
|
||||
* 'hunt the superblock'.
|
||||
*
|
||||
* The ffsv2 superblock layout (which might contain an ffsv1 filesystem)
|
||||
* can be detected by checking for sb->fs_old_flags & FS_FLAGS_UPDATED.
|
||||
* This is the default superblock type for NetBSD since ffsv2 support was added.
|
||||
*/
|
||||
#define BBSIZE 8192
|
||||
#define BBOFF ((off_t)(0))
|
||||
#define BBLOCK ((daddr_t)(0))
|
||||
|
||||
#define SBLOCK_FLOPPY 0
|
||||
#define SBLOCK_UFS1 8192
|
||||
#define SBLOCK_UFS2 65536
|
||||
#define SBLOCK_PIGGY 262144
|
||||
#define SBLOCKSIZE 8192
|
||||
/*
|
||||
* NB: Do not, under any circumstances, look for an ffsv1 filesystem at
|
||||
* SBLOCK_UFS2. Doing so will find the wrong superblock for filesystems
|
||||
* with a 64k block size.
|
||||
*/
|
||||
#define SBLOCKSEARCH \
|
||||
{ SBLOCK_UFS2, SBLOCK_UFS1, SBLOCK_FLOPPY, SBLOCK_PIGGY, -1 }
|
||||
|
||||
/*
|
||||
* Max number of fragments per block. This value is NOT tweakable.
|
||||
*/
|
||||
#define MAXFRAG 8
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Addresses stored in inodes are capable of addressing fragments
|
||||
* of `blocks'. File system blocks of at most size MAXBSIZE can
|
||||
* be optionally broken into 2, 4, or 8 pieces, each of which is
|
||||
* addressable; these pieces may be DEV_BSIZE, or some multiple of
|
||||
* a DEV_BSIZE unit.
|
||||
*
|
||||
* Large files consist of exclusively large data blocks. To avoid
|
||||
* undue wasted disk space, the last data block of a small file may be
|
||||
* allocated as only as many fragments of a large block as are
|
||||
* necessary. The file system format retains only a single pointer
|
||||
* to such a fragment, which is a piece of a single large block that
|
||||
* has been divided. The size of such a fragment is determinable from
|
||||
* information in the inode, using the ``blksize(fs, ip, lbn)'' macro.
|
||||
*
|
||||
* The file system records space availability at the fragment level;
|
||||
* to determine block availability, aligned fragments are examined.
|
||||
*/
|
||||
|
||||
/*
|
||||
* MINBSIZE is the smallest allowable block size.
|
||||
* In order to insure that it is possible to create files of size
|
||||
* 2^32 with only two levels of indirection, MINBSIZE is set to 4096.
|
||||
* MINBSIZE must be big enough to hold a cylinder group block,
|
||||
* thus changes to (struct cg) must keep its size within MINBSIZE.
|
||||
* Note that super blocks are always of size SBSIZE,
|
||||
* and that both SBSIZE and MAXBSIZE must be >= MINBSIZE.
|
||||
*/
|
||||
#define MINBSIZE 4096
|
||||
|
||||
/*
|
||||
* The path name on which the file system is mounted is maintained
|
||||
* in fs_fsmnt. MAXMNTLEN defines the amount of space allocated in
|
||||
* the super block for this name.
|
||||
*/
|
||||
#define MAXMNTLEN 468
|
||||
|
||||
/*
|
||||
* The volume name for this filesystem is maintained in fs_volname.
|
||||
* MAXVOLLEN defines the length of the buffer allocated.
|
||||
* This space used to be part of of fs_fsmnt.
|
||||
*/
|
||||
#define MAXVOLLEN 32
|
||||
|
||||
/*
|
||||
* There is a 128-byte region in the superblock reserved for in-core
|
||||
* pointers to summary information. Originally this included an array
|
||||
* of pointers to blocks of struct csum; now there are just four
|
||||
* pointers and the remaining space is padded with fs_ocsp[].
|
||||
* NOCSPTRS determines the size of this padding. One pointer (fs_csp)
|
||||
* is taken away to point to a contiguous array of struct csum for
|
||||
* all cylinder groups; a second (fs_maxcluster) points to an array
|
||||
* of cluster sizes that is computed as cylinder groups are inspected;
|
||||
* the third (fs_contigdirs) points to an array that tracks the
|
||||
* creation of new directories; and the fourth (fs_active) is used
|
||||
* by snapshots.
|
||||
*/
|
||||
#define NOCSPTRS ((128 / sizeof(void *)) - 4)
|
||||
|
||||
/*
|
||||
* A summary of contiguous blocks of various sizes is maintained
|
||||
* in each cylinder group. Normally this is set by the initial
|
||||
* value of fs_maxcontig. To conserve space, a maximum summary size
|
||||
* is set by FS_MAXCONTIG.
|
||||
*/
|
||||
#define FS_MAXCONTIG 16
|
||||
|
||||
/*
|
||||
* The maximum number of snapshot nodes that can be associated
|
||||
* with each filesystem. This limit affects only the number of
|
||||
* snapshot files that can be recorded within the superblock so
|
||||
* that they can be found when the filesystem is mounted. However,
|
||||
* maintaining too many will slow the filesystem performance, so
|
||||
* having this limit is a good idea.
|
||||
*/
|
||||
#define FSMAXSNAP 20
|
||||
|
||||
/*
|
||||
* Used to identify special blocks in snapshots:
|
||||
*
|
||||
* BLK_NOCOPY - A block that was unallocated at the time the snapshot
|
||||
* was taken, hence does not need to be copied when written.
|
||||
* BLK_SNAP - A block held by another snapshot that is not needed by this
|
||||
* snapshot. When the other snapshot is freed, the BLK_SNAP entries
|
||||
* are converted to BLK_NOCOPY. These are needed to allow fsck to
|
||||
* identify blocks that are in use by other snapshots (which are
|
||||
* expunged from this snapshot).
|
||||
*/
|
||||
#define BLK_NOCOPY ((daddr_t)(1))
|
||||
#define BLK_SNAP ((daddr_t)(2))
|
||||
|
||||
/*
|
||||
* MINFREE gives the minimum acceptable percentage of file system
|
||||
* blocks which may be free. If the freelist drops below this level
|
||||
* only the superuser may continue to allocate blocks. This may
|
||||
* be set to 0 if no reserve of free blocks is deemed necessary,
|
||||
* however throughput drops by fifty percent if the file system
|
||||
* is run at between 95% and 100% full; thus the minimum default
|
||||
* value of fs_minfree is 5%. However, to get good clustering
|
||||
* performance, 10% is a better choice. This value is used only
|
||||
* when creating a file system and can be overriden from the
|
||||
* command line. By default we choose to optimize for time.
|
||||
*/
|
||||
#define MINFREE 5
|
||||
#define DEFAULTOPT FS_OPTTIME
|
||||
|
||||
/*
|
||||
* Grigoriy Orlov <gluk@ptci.ru> has done some extensive work to fine
|
||||
* tune the layout preferences for directories within a filesystem.
|
||||
* His algorithm can be tuned by adjusting the following parameters
|
||||
* which tell the system the average file size and the average number
|
||||
* of files per directory. These defaults are well selected for typical
|
||||
* filesystems, but may need to be tuned for odd cases like filesystems
|
||||
* being used for squid caches or news spools.
|
||||
*/
|
||||
#define AVFILESIZ 16384 /* expected average file size */
|
||||
#define AFPDIR 64 /* expected number of files per directory */
|
||||
|
||||
/*
|
||||
* Per cylinder group information; summarized in blocks allocated
|
||||
* from first cylinder group data blocks. These blocks have to be
|
||||
* read in from fs_csaddr (size fs_cssize) in addition to the
|
||||
* super block.
|
||||
*/
|
||||
struct csum {
|
||||
int32_t cs_ndir; /* number of directories */
|
||||
int32_t cs_nbfree; /* number of free blocks */
|
||||
int32_t cs_nifree; /* number of free inodes */
|
||||
int32_t cs_nffree; /* number of free frags */
|
||||
};
|
||||
|
||||
struct csum_total {
|
||||
int64_t cs_ndir; /* number of directories */
|
||||
int64_t cs_nbfree; /* number of free blocks */
|
||||
int64_t cs_nifree; /* number of free inodes */
|
||||
int64_t cs_nffree; /* number of free frags */
|
||||
int64_t cs_spare[4]; /* future expansion */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Super block for an FFS file system in memory.
|
||||
*/
|
||||
struct fs {
|
||||
int32_t fs_firstfield; /* historic file system linked list, */
|
||||
int32_t fs_unused_1; /* used for incore super blocks */
|
||||
int32_t fs_sblkno; /* addr of super-block in filesys */
|
||||
int32_t fs_cblkno; /* offset of cyl-block in filesys */
|
||||
int32_t fs_iblkno; /* offset of inode-blocks in filesys */
|
||||
int32_t fs_dblkno; /* offset of first data after cg */
|
||||
int32_t fs_old_cgoffset; /* cylinder group offset in cylinder */
|
||||
int32_t fs_old_cgmask; /* used to calc mod fs_ntrak */
|
||||
int32_t fs_old_time; /* last time written */
|
||||
int32_t fs_old_size; /* number of blocks in fs */
|
||||
int32_t fs_old_dsize; /* number of data blocks in fs */
|
||||
int32_t fs_ncg; /* number of cylinder groups */
|
||||
int32_t fs_bsize; /* size of basic blocks in fs */
|
||||
int32_t fs_fsize; /* size of frag blocks in fs */
|
||||
int32_t fs_frag; /* number of frags in a block in fs */
|
||||
/* these are configuration parameters */
|
||||
int32_t fs_minfree; /* minimum percentage of free blocks */
|
||||
int32_t fs_old_rotdelay; /* num of ms for optimal next block */
|
||||
int32_t fs_old_rps; /* disk revolutions per second */
|
||||
/* these fields can be computed from the others */
|
||||
int32_t fs_bmask; /* ``blkoff'' calc of blk offsets */
|
||||
int32_t fs_fmask; /* ``fragoff'' calc of frag offsets */
|
||||
int32_t fs_bshift; /* ``lblkno'' calc of logical blkno */
|
||||
int32_t fs_fshift; /* ``numfrags'' calc number of frags */
|
||||
/* these are configuration parameters */
|
||||
int32_t fs_maxcontig; /* max number of contiguous blks */
|
||||
int32_t fs_maxbpg; /* max number of blks per cyl group */
|
||||
/* these fields can be computed from the others */
|
||||
int32_t fs_fragshift; /* block to frag shift */
|
||||
int32_t fs_fsbtodb; /* fsbtodb and dbtofsb shift constant */
|
||||
int32_t fs_sbsize; /* actual size of super block */
|
||||
int32_t fs_spare1[2]; /* old fs_csmask */
|
||||
/* old fs_csshift */
|
||||
int32_t fs_nindir; /* value of NINDIR */
|
||||
int32_t fs_inopb; /* value of INOPB */
|
||||
int32_t fs_old_nspf; /* value of NSPF */
|
||||
/* yet another configuration parameter */
|
||||
int32_t fs_optim; /* optimization preference, see below */
|
||||
/* these fields are derived from the hardware */
|
||||
int32_t fs_old_npsect; /* # sectors/track including spares */
|
||||
int32_t fs_old_interleave; /* hardware sector interleave */
|
||||
int32_t fs_old_trackskew; /* sector 0 skew, per track */
|
||||
/* fs_id takes the space of the unused fs_headswitch and fs_trkseek fields */
|
||||
int32_t fs_id[2]; /* unique file system id */
|
||||
/* sizes determined by number of cylinder groups and their sizes */
|
||||
int32_t fs_old_csaddr; /* blk addr of cyl grp summary area */
|
||||
int32_t fs_cssize; /* size of cyl grp summary area */
|
||||
int32_t fs_cgsize; /* cylinder group size */
|
||||
/* these fields are derived from the hardware */
|
||||
int32_t fs_spare2; /* old fs_ntrak */
|
||||
int32_t fs_old_nsect; /* sectors per track */
|
||||
int32_t fs_old_spc; /* sectors per cylinder */
|
||||
int32_t fs_old_ncyl; /* cylinders in file system */
|
||||
int32_t fs_old_cpg; /* cylinders per group */
|
||||
int32_t fs_ipg; /* inodes per group */
|
||||
int32_t fs_fpg; /* blocks per group * fs_frag */
|
||||
/* this data must be re-computed after crashes */
|
||||
struct csum fs_old_cstotal; /* cylinder summary information */
|
||||
/* these fields are cleared at mount time */
|
||||
int8_t fs_fmod; /* super block modified flag */
|
||||
uint8_t fs_clean; /* file system is clean flag */
|
||||
int8_t fs_ronly; /* mounted read-only flag */
|
||||
uint8_t fs_old_flags; /* see FS_ flags below */
|
||||
u_char fs_fsmnt[MAXMNTLEN]; /* name mounted on */
|
||||
u_char fs_volname[MAXVOLLEN]; /* volume name */
|
||||
uint64_t fs_swuid; /* system-wide uid */
|
||||
int32_t fs_pad;
|
||||
/* these fields retain the current block allocation info */
|
||||
int32_t fs_cgrotor; /* last cg searched (UNUSED) */
|
||||
void *fs_ocsp[NOCSPTRS]; /* padding; was list of fs_cs buffers */
|
||||
u_int8_t *fs_contigdirs; /* # of contiguously allocated dirs */
|
||||
struct csum *fs_csp; /* cg summary info buffer for fs_cs */
|
||||
int32_t *fs_maxcluster; /* max cluster in each cyl group */
|
||||
u_char *fs_active; /* used by snapshots to track fs */
|
||||
int32_t fs_old_cpc; /* cyl per cycle in postbl */
|
||||
/* this area is otherwise allocated unless fs_old_flags & FS_FLAGS_UPDATED */
|
||||
int32_t fs_maxbsize; /* maximum blocking factor permitted */
|
||||
uint8_t fs_journal_version; /* journal format version */
|
||||
uint8_t fs_journal_location; /* journal location type */
|
||||
uint8_t fs_journal_reserved[2];/* reserved for future use */
|
||||
uint32_t fs_journal_flags; /* journal flags */
|
||||
uint64_t fs_journallocs[4]; /* location info for journal */
|
||||
uint32_t fs_quota_magic; /* see quota2.h */
|
||||
uint8_t fs_quota_flags; /* see quota2.h */
|
||||
uint8_t fs_quota_reserved[3];
|
||||
uint64_t fs_quotafile[2]; /* pointer to quota inodes */
|
||||
int64_t fs_sparecon64[9]; /* reserved for future use */
|
||||
int64_t fs_sblockloc; /* byte offset of standard superblock */
|
||||
struct csum_total fs_cstotal; /* cylinder summary information */
|
||||
int64_t fs_time; /* last time written */
|
||||
int64_t fs_size; /* number of blocks in fs */
|
||||
int64_t fs_dsize; /* number of data blocks in fs */
|
||||
int64_t fs_csaddr; /* blk addr of cyl grp summary area */
|
||||
int64_t fs_pendingblocks; /* blocks in process of being freed */
|
||||
int32_t fs_pendinginodes; /* inodes in process of being freed */
|
||||
int32_t fs_snapinum[FSMAXSNAP];/* list of snapshot inode numbers */
|
||||
/* back to stuff that has been around a while */
|
||||
int32_t fs_avgfilesize; /* expected average file size */
|
||||
int32_t fs_avgfpdir; /* expected # of files per directory */
|
||||
int32_t fs_save_cgsize; /* save real cg size to use fs_bsize */
|
||||
int32_t fs_sparecon32[26]; /* reserved for future constants */
|
||||
uint32_t fs_flags; /* see FS_ flags below */
|
||||
/* back to stuff that has been around a while (again) */
|
||||
int32_t fs_contigsumsize; /* size of cluster summary array */
|
||||
int32_t fs_maxsymlinklen; /* max length of an internal symlink */
|
||||
int32_t fs_old_inodefmt; /* format of on-disk inodes */
|
||||
u_int64_t fs_maxfilesize; /* maximum representable file size */
|
||||
int64_t fs_qbmask; /* ~fs_bmask for use with 64-bit size */
|
||||
int64_t fs_qfmask; /* ~fs_fmask for use with 64-bit size */
|
||||
int32_t fs_state; /* validate fs_clean field (UNUSED) */
|
||||
int32_t fs_old_postblformat; /* format of positional layout tables */
|
||||
int32_t fs_old_nrpos; /* number of rotational positions */
|
||||
int32_t fs_spare5[2]; /* old fs_postbloff */
|
||||
/* old fs_rotbloff */
|
||||
int32_t fs_magic; /* magic number */
|
||||
};
|
||||
|
||||
#define fs_old_postbloff fs_spare5[0]
|
||||
#define fs_old_rotbloff fs_spare5[1]
|
||||
#define fs_old_postbl_start fs_maxbsize
|
||||
#define fs_old_headswitch fs_id[0]
|
||||
#define fs_old_trkseek fs_id[1]
|
||||
#define fs_old_csmask fs_spare1[0]
|
||||
#define fs_old_csshift fs_spare1[1]
|
||||
|
||||
#define FS_42POSTBLFMT -1 /* 4.2BSD rotational table format */
|
||||
#define FS_DYNAMICPOSTBLFMT 1 /* dynamic rotational table format */
|
||||
|
||||
#define old_fs_postbl(fs_, cylno, opostblsave) \
|
||||
((((fs_)->fs_old_postblformat == FS_42POSTBLFMT) || \
|
||||
((fs_)->fs_old_postbloff == offsetof(struct fs, fs_old_postbl_start))) \
|
||||
? ((int16_t *)(opostblsave) + (cylno) * (fs_)->fs_old_nrpos) \
|
||||
: ((int16_t *)((uint8_t *)(fs_) + \
|
||||
(fs_)->fs_old_postbloff) + (cylno) * (fs_)->fs_old_nrpos))
|
||||
#define old_fs_rotbl(fs) \
|
||||
(((fs)->fs_old_postblformat == FS_42POSTBLFMT) \
|
||||
? ((uint8_t *)(&(fs)->fs_magic+1)) \
|
||||
: ((uint8_t *)((uint8_t *)(fs) + (fs)->fs_old_rotbloff)))
|
||||
|
||||
/*
|
||||
* File system identification
|
||||
*/
|
||||
#define FS_UFS1_MAGIC 0x011954 /* UFS1 fast file system magic number */
|
||||
#define FS_UFS2_MAGIC 0x19540119 /* UFS2 fast file system magic number */
|
||||
#define FS_UFS1_MAGIC_SWAPPED 0x54190100
|
||||
#define FS_UFS2_MAGIC_SWAPPED 0x19015419
|
||||
#define FS_OKAY 0x7c269d38 /* superblock checksum */
|
||||
#define FS_42INODEFMT -1 /* 4.2BSD inode format */
|
||||
#define FS_44INODEFMT 2 /* 4.4BSD inode format */
|
||||
|
||||
/*
|
||||
* File system clean flags
|
||||
*/
|
||||
#define FS_ISCLEAN 0x01
|
||||
#define FS_WASCLEAN 0x02
|
||||
|
||||
/*
|
||||
* Preference for optimization.
|
||||
*/
|
||||
#define FS_OPTTIME 0 /* minimize allocation time */
|
||||
#define FS_OPTSPACE 1 /* minimize disk fragmentation */
|
||||
|
||||
/*
|
||||
* File system flags
|
||||
*/
|
||||
#define FS_UNCLEAN 0x001 /* file system not clean at mount (unused) */
|
||||
#define FS_DOSOFTDEP 0x002 /* file system using soft dependencies */
|
||||
#define FS_NEEDSFSCK 0x004 /* needs sync fsck (FreeBSD compat, unused) */
|
||||
#define FS_INDEXDIRS 0x008 /* kernel supports indexed directories */
|
||||
#define FS_ACLS 0x010 /* file system has ACLs enabled */
|
||||
#define FS_MULTILABEL 0x020 /* file system is MAC multi-label */
|
||||
#define FS_GJOURNAL 0x40 /* gjournaled file system */
|
||||
#define FS_FLAGS_UPDATED 0x80 /* flags have been moved to new location */
|
||||
#define FS_DOWAPBL 0x100 /* Write ahead physical block logging */
|
||||
#define FS_DOQUOTA2 0x200 /* in-filesystem quotas */
|
||||
|
||||
/* File system flags that are ok for NetBSD if set in fs_flags */
|
||||
#define FS_KNOWN_FLAGS (FS_DOSOFTDEP | FS_DOWAPBL | FS_DOQUOTA2)
|
||||
|
||||
/*
|
||||
* File system internal flags, also in fs_flags.
|
||||
* (Pick highest number to avoid conflicts with others)
|
||||
*/
|
||||
#define FS_SWAPPED 0x80000000 /* file system is endian swapped */
|
||||
#define FS_INTERNAL 0x80000000 /* mask for internal flags */
|
||||
|
||||
/*
|
||||
* Macros to access bits in the fs_active array.
|
||||
*/
|
||||
#define ACTIVECG_SET(fs, cg) \
|
||||
do { \
|
||||
if ((fs)->fs_active != NULL) \
|
||||
setbit((fs)->fs_active, (cg)); \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
#define ACTIVECG_CLR(fs, cg) \
|
||||
do { \
|
||||
if ((fs)->fs_active != NULL) \
|
||||
clrbit((fs)->fs_active, (cg)); \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
#define ACTIVECG_ISSET(fs, cg) \
|
||||
((fs)->fs_active != NULL && isset((fs)->fs_active, (cg)))
|
||||
|
||||
/*
|
||||
* The size of a cylinder group is calculated by CGSIZE. The maximum size
|
||||
* is limited by the fact that cylinder groups are at most one block.
|
||||
* Its size is derived from the size of the maps maintained in the
|
||||
* cylinder group and the (struct cg) size.
|
||||
*/
|
||||
#define CGSIZE_IF(fs, ipg, fpg) \
|
||||
/* base cg */ (sizeof(struct cg) + sizeof(int32_t) + \
|
||||
/* old btotoff */ (fs)->fs_old_cpg * sizeof(int32_t) + \
|
||||
/* old boff */ (fs)->fs_old_cpg * sizeof(u_int16_t) + \
|
||||
/* inode map */ howmany((ipg), NBBY) + \
|
||||
/* block map */ howmany((fpg), NBBY) +\
|
||||
/* if present */ ((fs)->fs_contigsumsize <= 0 ? 0 : \
|
||||
/* cluster sum */ (fs)->fs_contigsumsize * sizeof(int32_t) + \
|
||||
/* cluster map */ howmany(fragstoblks(fs, (fpg)), NBBY)))
|
||||
|
||||
#define CGSIZE(fs) CGSIZE_IF((fs), (fs)->fs_ipg, (fs)->fs_fpg)
|
||||
|
||||
/*
|
||||
* The minimal number of cylinder groups that should be created.
|
||||
*/
|
||||
#define MINCYLGRPS 4
|
||||
|
||||
|
||||
/*
|
||||
* Convert cylinder group to base address of its global summary info.
|
||||
*/
|
||||
#define fs_cs(fs, indx) fs_csp[indx]
|
||||
|
||||
/*
|
||||
* Cylinder group block for a file system.
|
||||
*/
|
||||
#define CG_MAGIC 0x090255
|
||||
struct cg {
|
||||
int32_t cg_firstfield; /* historic cyl groups linked list */
|
||||
int32_t cg_magic; /* magic number */
|
||||
int32_t cg_old_time; /* time last written */
|
||||
int32_t cg_cgx; /* we are the cgx'th cylinder group */
|
||||
int16_t cg_old_ncyl; /* number of cyl's this cg */
|
||||
int16_t cg_old_niblk; /* number of inode blocks this cg */
|
||||
int32_t cg_ndblk; /* number of data blocks this cg */
|
||||
struct csum cg_cs; /* cylinder summary information */
|
||||
int32_t cg_rotor; /* position of last used block */
|
||||
int32_t cg_frotor; /* position of last used frag */
|
||||
int32_t cg_irotor; /* position of last used inode */
|
||||
int32_t cg_frsum[MAXFRAG]; /* counts of available frags */
|
||||
int32_t cg_old_btotoff; /* (int32) block totals per cylinder */
|
||||
int32_t cg_old_boff; /* (u_int16) free block positions */
|
||||
int32_t cg_iusedoff; /* (u_int8) used inode map */
|
||||
int32_t cg_freeoff; /* (u_int8) free block map */
|
||||
int32_t cg_nextfreeoff; /* (u_int8) next available space */
|
||||
int32_t cg_clustersumoff; /* (u_int32) counts of avail clusters */
|
||||
int32_t cg_clusteroff; /* (u_int8) free cluster map */
|
||||
int32_t cg_nclusterblks; /* number of clusters this cg */
|
||||
int32_t cg_niblk; /* number of inode blocks this cg */
|
||||
int32_t cg_initediblk; /* last initialized inode */
|
||||
int32_t cg_sparecon32[3]; /* reserved for future use */
|
||||
int64_t cg_time; /* time last written */
|
||||
int64_t cg_sparecon64[3]; /* reserved for future use */
|
||||
u_int8_t cg_space[1]; /* space for cylinder group maps */
|
||||
/* actually longer */
|
||||
};
|
||||
|
||||
/*
|
||||
* The following structure is defined
|
||||
* for compatibility with old file systems.
|
||||
*/
|
||||
struct ocg {
|
||||
int32_t cg_firstfield; /* historic linked list of cyl groups */
|
||||
int32_t cg_unused_1; /* used for incore cyl groups */
|
||||
int32_t cg_time; /* time last written */
|
||||
int32_t cg_cgx; /* we are the cgx'th cylinder group */
|
||||
int16_t cg_ncyl; /* number of cyl's this cg */
|
||||
int16_t cg_niblk; /* number of inode blocks this cg */
|
||||
int32_t cg_ndblk; /* number of data blocks this cg */
|
||||
struct csum cg_cs; /* cylinder summary information */
|
||||
int32_t cg_rotor; /* position of last used block */
|
||||
int32_t cg_frotor; /* position of last used frag */
|
||||
int32_t cg_irotor; /* position of last used inode */
|
||||
int32_t cg_frsum[8]; /* counts of available frags */
|
||||
int32_t cg_btot[32]; /* block totals per cylinder */
|
||||
int16_t cg_b[32][8]; /* positions of free blocks */
|
||||
u_int8_t cg_iused[256]; /* used inode map */
|
||||
int32_t cg_magic; /* magic number */
|
||||
u_int8_t cg_free[1]; /* free block map */
|
||||
/* actually longer */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Macros for access to cylinder group array structures.
|
||||
*/
|
||||
#define old_cg_blktot_old(cgp, ns) \
|
||||
(((struct ocg *)(cgp))->cg_btot)
|
||||
#define old_cg_blks_old(fs, cgp, cylno, ns) \
|
||||
(((struct ocg *)(cgp))->cg_b[cylno])
|
||||
|
||||
#define old_cg_blktot_new(cgp, ns) \
|
||||
((int32_t *)((u_int8_t *)(cgp) + \
|
||||
ufs_rw32((cgp)->cg_old_btotoff, (ns))))
|
||||
#define old_cg_blks_new(fs, cgp, cylno, ns) \
|
||||
((int16_t *)((u_int8_t *)(cgp) + \
|
||||
ufs_rw32((cgp)->cg_old_boff, (ns))) + (cylno) * (fs)->fs_old_nrpos)
|
||||
|
||||
#define old_cg_blktot(cgp, ns) \
|
||||
((ufs_rw32((cgp)->cg_magic, (ns)) != CG_MAGIC) ? \
|
||||
old_cg_blktot_old(cgp, ns) : old_cg_blktot_new(cgp, ns))
|
||||
#define old_cg_blks(fs, cgp, cylno, ns) \
|
||||
((ufs_rw32((cgp)->cg_magic, (ns)) != CG_MAGIC) ? \
|
||||
old_cg_blks_old(fs, cgp, cylno, ns) : old_cg_blks_new(fs, cgp, cylno, ns))
|
||||
|
||||
#define cg_inosused_new(cgp, ns) \
|
||||
((u_int8_t *)((u_int8_t *)(cgp) + \
|
||||
ufs_rw32((cgp)->cg_iusedoff, (ns))))
|
||||
#define cg_blksfree_new(cgp, ns) \
|
||||
((u_int8_t *)((u_int8_t *)(cgp) + \
|
||||
ufs_rw32((cgp)->cg_freeoff, (ns))))
|
||||
#define cg_chkmagic_new(cgp, ns) \
|
||||
(ufs_rw32((cgp)->cg_magic, (ns)) == CG_MAGIC)
|
||||
|
||||
#define cg_inosused_old(cgp, ns) \
|
||||
(((struct ocg *)(cgp))->cg_iused)
|
||||
#define cg_blksfree_old(cgp, ns) \
|
||||
(((struct ocg *)(cgp))->cg_free)
|
||||
#define cg_chkmagic_old(cgp, ns) \
|
||||
(ufs_rw32(((struct ocg *)(cgp))->cg_magic, (ns)) == CG_MAGIC)
|
||||
|
||||
#define cg_inosused(cgp, ns) \
|
||||
((ufs_rw32((cgp)->cg_magic, (ns)) != CG_MAGIC) ? \
|
||||
cg_inosused_old(cgp, ns) : cg_inosused_new(cgp, ns))
|
||||
#define cg_blksfree(cgp, ns) \
|
||||
((ufs_rw32((cgp)->cg_magic, (ns)) != CG_MAGIC) ? \
|
||||
cg_blksfree_old(cgp, ns) : cg_blksfree_new(cgp, ns))
|
||||
#define cg_chkmagic(cgp, ns) \
|
||||
(cg_chkmagic_new(cgp, ns) || cg_chkmagic_old(cgp, ns))
|
||||
|
||||
#define cg_clustersfree(cgp, ns) \
|
||||
((u_int8_t *)((u_int8_t *)(cgp) + \
|
||||
ufs_rw32((cgp)->cg_clusteroff, (ns))))
|
||||
#define cg_clustersum(cgp, ns) \
|
||||
((int32_t *)((u_int8_t *)(cgp) + \
|
||||
ufs_rw32((cgp)->cg_clustersumoff, (ns))))
|
||||
|
||||
|
||||
/*
|
||||
* Turn file system block numbers into disk block addresses.
|
||||
* This maps file system blocks to device size blocks.
|
||||
*/
|
||||
#if defined (_KERNEL)
|
||||
#define fsbtodb(fs, b) ((b) << ((fs)->fs_fshift - DEV_BSHIFT))
|
||||
#define dbtofsb(fs, b) ((b) >> ((fs)->fs_fshift - DEV_BSHIFT))
|
||||
#else
|
||||
#define fsbtodb(fs, b) ((b) << (fs)->fs_fsbtodb)
|
||||
#define dbtofsb(fs, b) ((b) >> (fs)->fs_fsbtodb)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Cylinder group macros to locate things in cylinder groups.
|
||||
* They calc file system addresses of cylinder group data structures.
|
||||
*/
|
||||
#define cgbase(fs, c) (((daddr_t)(fs)->fs_fpg) * (c))
|
||||
#define cgstart_ufs1(fs, c) \
|
||||
(cgbase(fs, c) + (fs)->fs_old_cgoffset * ((c) & ~((fs)->fs_old_cgmask)))
|
||||
#define cgstart_ufs2(fs, c) cgbase((fs), (c))
|
||||
#define cgstart(fs, c) ((fs)->fs_magic == FS_UFS2_MAGIC \
|
||||
? cgstart_ufs2((fs), (c)) : cgstart_ufs1((fs), (c)))
|
||||
#define cgdmin(fs, c) (cgstart(fs, c) + (fs)->fs_dblkno) /* 1st data */
|
||||
#define cgimin(fs, c) (cgstart(fs, c) + (fs)->fs_iblkno) /* inode blk */
|
||||
#define cgsblock(fs, c) (cgstart(fs, c) + (fs)->fs_sblkno) /* super blk */
|
||||
#define cgtod(fs, c) (cgstart(fs, c) + (fs)->fs_cblkno) /* cg block */
|
||||
|
||||
/*
|
||||
* Macros for handling inode numbers:
|
||||
* inode number to file system block offset.
|
||||
* inode number to cylinder group number.
|
||||
* inode number to file system block address.
|
||||
*/
|
||||
#define ino_to_cg(fs, x) ((x) / (fs)->fs_ipg)
|
||||
#define ino_to_fsba(fs, x) \
|
||||
((daddr_t)(cgimin(fs, ino_to_cg(fs, x)) + \
|
||||
(blkstofrags((fs), (((x) % (fs)->fs_ipg) / INOPB(fs))))))
|
||||
#define ino_to_fsbo(fs, x) ((x) % INOPB(fs))
|
||||
|
||||
/*
|
||||
* Give cylinder group number for a file system block.
|
||||
* Give cylinder group block number for a file system block.
|
||||
*/
|
||||
#define dtog(fs, d) ((d) / (fs)->fs_fpg)
|
||||
#define dtogd(fs, d) ((d) % (fs)->fs_fpg)
|
||||
|
||||
/*
|
||||
* Extract the bits for a block from a map.
|
||||
* Compute the cylinder and rotational position of a cyl block addr.
|
||||
*/
|
||||
#define blkmap(fs, map, loc) \
|
||||
(((map)[(loc) / NBBY] >> ((loc) % NBBY)) & (0xff >> (NBBY - (fs)->fs_frag)))
|
||||
#define old_cbtocylno(fs, bno) \
|
||||
(fsbtodb(fs, bno) / (fs)->fs_old_spc)
|
||||
#define old_cbtorpos(fs, bno) \
|
||||
((fs)->fs_old_nrpos <= 1 ? 0 : \
|
||||
(fsbtodb(fs, bno) % (fs)->fs_old_spc / (fs)->fs_old_nsect * (fs)->fs_old_trackskew + \
|
||||
fsbtodb(fs, bno) % (fs)->fs_old_spc % (fs)->fs_old_nsect * (fs)->fs_old_interleave) % \
|
||||
(fs)->fs_old_nsect * (fs)->fs_old_nrpos / (fs)->fs_old_npsect)
|
||||
|
||||
/*
|
||||
* The following macros optimize certain frequently calculated
|
||||
* quantities by using shifts and masks in place of divisions
|
||||
* modulos and multiplications.
|
||||
*/
|
||||
#define blkoff(fs, loc) /* calculates (loc % fs->fs_bsize) */ \
|
||||
((loc) & (fs)->fs_qbmask)
|
||||
#define fragoff(fs, loc) /* calculates (loc % fs->fs_fsize) */ \
|
||||
((loc) & (fs)->fs_qfmask)
|
||||
#define lfragtosize(fs, frag) /* calculates ((off_t)frag * fs->fs_fsize) */ \
|
||||
(((off_t)(frag)) << (fs)->fs_fshift)
|
||||
#define lblktosize(fs, blk) /* calculates ((off_t)blk * fs->fs_bsize) */ \
|
||||
(((off_t)(blk)) << (fs)->fs_bshift)
|
||||
#define lblkno(fs, loc) /* calculates (loc / fs->fs_bsize) */ \
|
||||
((loc) >> (fs)->fs_bshift)
|
||||
#define numfrags(fs, loc) /* calculates (loc / fs->fs_fsize) */ \
|
||||
((loc) >> (fs)->fs_fshift)
|
||||
#define blkroundup(fs, size) /* calculates roundup(size, fs->fs_bsize) */ \
|
||||
(((size) + (fs)->fs_qbmask) & (fs)->fs_bmask)
|
||||
#define fragroundup(fs, size) /* calculates roundup(size, fs->fs_fsize) */ \
|
||||
(((size) + (fs)->fs_qfmask) & (fs)->fs_fmask)
|
||||
#define fragstoblks(fs, frags) /* calculates (frags / fs->fs_frag) */ \
|
||||
((frags) >> (fs)->fs_fragshift)
|
||||
#define blkstofrags(fs, blks) /* calculates (blks * fs->fs_frag) */ \
|
||||
((blks) << (fs)->fs_fragshift)
|
||||
#define fragnum(fs, fsb) /* calculates (fsb % fs->fs_frag) */ \
|
||||
((fsb) & ((fs)->fs_frag - 1))
|
||||
#define blknum(fs, fsb) /* calculates rounddown(fsb, fs->fs_frag) */ \
|
||||
((fsb) &~ ((fs)->fs_frag - 1))
|
||||
|
||||
/*
|
||||
* Determine the number of available frags given a
|
||||
* percentage to hold in reserve.
|
||||
*/
|
||||
#define freespace(fs, percentreserved) \
|
||||
(blkstofrags((fs), (fs)->fs_cstotal.cs_nbfree) + \
|
||||
(fs)->fs_cstotal.cs_nffree - \
|
||||
(((off_t)((fs)->fs_dsize)) * (percentreserved) / 100))
|
||||
|
||||
/*
|
||||
* Determining the size of a file block in the file system.
|
||||
*/
|
||||
#define blksize(fs, ip, lbn) \
|
||||
(((lbn) >= NDADDR || (ip)->i_size >= lblktosize(fs, (lbn) + 1)) \
|
||||
? (fs)->fs_bsize \
|
||||
: (fragroundup(fs, blkoff(fs, (ip)->i_size))))
|
||||
|
||||
#define sblksize(fs, size, lbn) \
|
||||
(((lbn) >= NDADDR || (size) >= ((lbn) + 1) << (fs)->fs_bshift) \
|
||||
? (fs)->fs_bsize \
|
||||
: (fragroundup(fs, blkoff(fs, (size)))))
|
||||
|
||||
|
||||
/*
|
||||
* Number of inodes in a secondary storage block/fragment.
|
||||
*/
|
||||
#define INOPB(fs) ((fs)->fs_inopb)
|
||||
#define INOPF(fs) ((fs)->fs_inopb >> (fs)->fs_fragshift)
|
||||
|
||||
/*
|
||||
* Number of indirects in a file system block.
|
||||
*/
|
||||
#define NINDIR(fs) ((fs)->fs_nindir)
|
||||
|
||||
/*
|
||||
* Apple UFS Label:
|
||||
* We check for this to decide to use APPLEUFS_DIRBLKSIZ
|
||||
*/
|
||||
#define APPLEUFS_LABEL_MAGIC 0x4c41424c /* LABL */
|
||||
#define APPLEUFS_LABEL_SIZE 1024
|
||||
#define APPLEUFS_LABEL_OFFSET (BBSIZE - APPLEUFS_LABEL_SIZE) /* located at 7k */
|
||||
#define APPLEUFS_LABEL_VERSION 1
|
||||
#define APPLEUFS_MAX_LABEL_NAME 512
|
||||
|
||||
struct appleufslabel {
|
||||
u_int32_t ul_magic;
|
||||
u_int16_t ul_checksum;
|
||||
u_int16_t ul_unused0;
|
||||
u_int32_t ul_version;
|
||||
u_int32_t ul_time;
|
||||
u_int16_t ul_namelen;
|
||||
u_char ul_name[APPLEUFS_MAX_LABEL_NAME]; /* Warning: may not be null terminated */
|
||||
u_int16_t ul_unused1;
|
||||
u_int64_t ul_uuid; /* Note this is only 4 byte aligned */
|
||||
u_char ul_reserved[24];
|
||||
u_char ul_unused[460];
|
||||
} __packed;
|
||||
|
||||
|
||||
#endif /* !_UFS_FFS_FS_H_ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,287 +0,0 @@
|
||||
/* $NetBSD: lfs_extern.h,v 1.96 2008/06/28 01:34:05 rumble Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Konrad E. Schroder <perseant@hhhh.org>.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
/*-
|
||||
* Copyright (c) 1991, 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.
|
||||
*
|
||||
* @(#)lfs_extern.h 8.6 (Berkeley) 5/8/95
|
||||
*/
|
||||
|
||||
#ifndef _UFS_LFS_LFS_EXTERN_H_
|
||||
#define _UFS_LFS_LFS_EXTERN_H_
|
||||
|
||||
#ifdef _KERNEL
|
||||
#include <sys/mallocvar.h>
|
||||
|
||||
MALLOC_DECLARE(M_SEGMENT);
|
||||
#endif
|
||||
|
||||
/* Copied from ext2fs for ITIMES. XXX This is a bogus use of v_tag. */
|
||||
#define IS_LFS_VNODE(vp) (vp->v_tag == VT_LFS)
|
||||
|
||||
/*
|
||||
* Sysctl values for LFS.
|
||||
*/
|
||||
#define LFS_WRITEINDIR 1 /* flush indirect blocks on non-checkpoint writes */
|
||||
#define LFS_CLEAN_VNHEAD 2 /* put prev unrefed cleaned vnodes on head of free list */
|
||||
#define LFS_DOSTATS 3
|
||||
#define LFS_MAXPAGES 4
|
||||
#define LFS_FS_PAGETRIP 5
|
||||
#define LFS_STATS 6
|
||||
#define LFS_DO_RFW 7
|
||||
#define LFS_DEBUGLOG 8
|
||||
#define LFS_IGNORE_LAZY_SYNC 9
|
||||
#define LFS_MAXID 10
|
||||
|
||||
struct fid;
|
||||
struct mount;
|
||||
struct nameidata;
|
||||
struct proc;
|
||||
struct statvfs;
|
||||
struct timeval;
|
||||
struct inode;
|
||||
struct uio;
|
||||
struct mbuf;
|
||||
struct ufs1_dinode;
|
||||
struct buf;
|
||||
struct vnode;
|
||||
struct dlfs;
|
||||
struct lfs;
|
||||
struct segment;
|
||||
struct block_info;
|
||||
|
||||
#if defined(_KERNEL)
|
||||
|
||||
extern int lfs_allclean_wakeup;
|
||||
extern struct pool lfs_inode_pool; /* memory pool for inodes */
|
||||
extern struct pool lfs_dinode_pool; /* memory pool for dinodes */
|
||||
extern struct pool lfs_inoext_pool; /* memory pool for inode extension */
|
||||
extern struct pool lfs_lbnentry_pool; /* memory pool for balloc accounting */
|
||||
|
||||
extern int locked_queue_count;
|
||||
extern long locked_queue_bytes;
|
||||
extern int lfs_subsys_pages;
|
||||
extern int lfs_dirvcount;
|
||||
extern kmutex_t lfs_lock;
|
||||
extern int lfs_debug_log_subsys[];
|
||||
extern kcondvar_t lfs_writing_cv;
|
||||
extern kcondvar_t locked_queue_cv;
|
||||
|
||||
__BEGIN_DECLS
|
||||
/* lfs_alloc.c */
|
||||
void lfs_vcreate(struct mount *, ino_t, struct vnode *);
|
||||
int lfs_valloc(struct vnode *, int, kauth_cred_t, struct vnode **);
|
||||
int lfs_vfree(struct vnode *, ino_t, int);
|
||||
void lfs_order_freelist(struct lfs *);
|
||||
int lfs_extend_ifile(struct lfs *, kauth_cred_t);
|
||||
int lfs_ialloc(struct lfs *, struct vnode *, ino_t, int, struct vnode **);
|
||||
void lfs_orphan(struct lfs *, ino_t);
|
||||
|
||||
/* lfs_balloc.c */
|
||||
int lfs_balloc(struct vnode *, off_t, int, kauth_cred_t, int, struct buf **);
|
||||
void lfs_register_block(struct vnode *, daddr_t);
|
||||
void lfs_deregister_block(struct vnode *, daddr_t);
|
||||
void lfs_deregister_all(struct vnode *);
|
||||
|
||||
/* lfs_bio.c */
|
||||
int lfs_availwait(struct lfs *, int);
|
||||
int lfs_bwrite_ext(struct buf *, int);
|
||||
int lfs_fits(struct lfs *, int);
|
||||
void lfs_flush_fs(struct lfs *, int);
|
||||
void lfs_flush(struct lfs *, int, int);
|
||||
int lfs_check(struct vnode *, daddr_t, int);
|
||||
void lfs_freebuf(struct lfs *, struct buf *);
|
||||
struct buf *lfs_newbuf(struct lfs *, struct vnode *, daddr_t, size_t, int);
|
||||
void lfs_countlocked(int *, long *, const char *);
|
||||
int lfs_reserve(struct lfs *, struct vnode *, struct vnode *, int);
|
||||
|
||||
/* lfs_debug.c */
|
||||
#ifdef DEBUG
|
||||
int lfs_bwrite_log(struct buf *, const char *, int);
|
||||
void lfs_dumplog(void);
|
||||
void lfs_dump_super(struct lfs *);
|
||||
void lfs_dump_dinode(struct ufs1_dinode *);
|
||||
void lfs_check_bpp(struct lfs *, struct segment *, char *, int);
|
||||
void lfs_check_segsum(struct lfs *, struct segment *, char *, int);
|
||||
void lfs_debug_log(int, const char *, ...);
|
||||
#endif /* DEBUG */
|
||||
|
||||
/* lfs_inode.c */
|
||||
int lfs_update(struct vnode *, const struct timespec *, const struct timespec *,
|
||||
int);
|
||||
int lfs_truncate(struct vnode *, off_t, int, kauth_cred_t);
|
||||
struct ufs1_dinode *lfs_ifind(struct lfs *, ino_t, struct buf *);
|
||||
void lfs_finalize_ino_seguse(struct lfs *, struct inode *);
|
||||
void lfs_finalize_fs_seguse(struct lfs *);
|
||||
|
||||
/* lfs_rfw.c */
|
||||
int lfs_rf_valloc(struct lfs *, ino_t, int, struct lwp *, struct vnode **);
|
||||
void lfs_roll_forward(struct lfs *, struct mount *, struct lwp *);
|
||||
|
||||
/* lfs_segment.c */
|
||||
void lfs_imtime(struct lfs *);
|
||||
int lfs_vflush(struct vnode *);
|
||||
int lfs_segwrite(struct mount *, int);
|
||||
int lfs_writefile(struct lfs *, struct segment *, struct vnode *);
|
||||
int lfs_writeinode(struct lfs *, struct segment *, struct inode *);
|
||||
int lfs_gatherblock(struct segment *, struct buf *, kmutex_t *);
|
||||
int lfs_gather(struct lfs *, struct segment *, struct vnode *, int (*match )(struct lfs *, struct buf *));
|
||||
void lfs_update_single(struct lfs *, struct segment *, struct vnode *,
|
||||
daddr_t, int32_t, int);
|
||||
void lfs_updatemeta(struct segment *);
|
||||
int lfs_rewind(struct lfs *, int);
|
||||
void lfs_unset_inval_all(struct lfs *);
|
||||
int lfs_initseg(struct lfs *);
|
||||
int lfs_writeseg(struct lfs *, struct segment *);
|
||||
void lfs_writesuper(struct lfs *, daddr_t);
|
||||
int lfs_match_data(struct lfs *, struct buf *);
|
||||
int lfs_match_indir(struct lfs *, struct buf *);
|
||||
int lfs_match_dindir(struct lfs *, struct buf *);
|
||||
int lfs_match_tindir(struct lfs *, struct buf *);
|
||||
void lfs_callback(struct buf *);
|
||||
int lfs_vref(struct vnode *);
|
||||
void lfs_vunref(struct vnode *);
|
||||
void lfs_vunref_head(struct vnode *);
|
||||
void lfs_acquire_finfo(struct lfs *fs, ino_t, int);
|
||||
void lfs_release_finfo(struct lfs *fs);
|
||||
|
||||
/* lfs_subr.c */
|
||||
void lfs_setup_resblks(struct lfs *);
|
||||
void lfs_pad_check(unsigned char *, int, char *, int);
|
||||
void lfs_free_resblks(struct lfs *);
|
||||
void *lfs_malloc(struct lfs *, size_t, int);
|
||||
void lfs_free(struct lfs *, void *, int);
|
||||
int lfs_seglock(struct lfs *, unsigned long);
|
||||
void lfs_segunlock(struct lfs *);
|
||||
void lfs_segunlock_relock(struct lfs *);
|
||||
int lfs_writer_enter(struct lfs *, const char *);
|
||||
void lfs_writer_leave(struct lfs *);
|
||||
void lfs_wakeup_cleaner(struct lfs *);
|
||||
|
||||
/* lfs_syscalls.c */
|
||||
int lfs_fastvget(struct mount *, ino_t, daddr_t, struct vnode **, struct ufs1_dinode *);
|
||||
struct buf *lfs_fakebuf(struct lfs *, struct vnode *, int, size_t, void *);
|
||||
int lfs_do_segclean(struct lfs *, unsigned long);
|
||||
int lfs_segwait(fsid_t *, struct timeval *);
|
||||
int lfs_bmapv(struct proc *, fsid_t *, struct block_info *, int);
|
||||
int lfs_markv(struct proc *, fsid_t *, struct block_info *, int);
|
||||
|
||||
/* lfs_vfsops.c */
|
||||
void lfs_init(void);
|
||||
void lfs_reinit(void);
|
||||
void lfs_done(void);
|
||||
int lfs_mountroot(void);
|
||||
int lfs_mount(struct mount *, const char *, void *, size_t *);
|
||||
int lfs_unmount(struct mount *, int);
|
||||
int lfs_statvfs(struct mount *, struct statvfs *);
|
||||
int lfs_sync(struct mount *, int, kauth_cred_t);
|
||||
int lfs_vget(struct mount *, ino_t, struct vnode **);
|
||||
int lfs_fhtovp(struct mount *, struct fid *, struct vnode **);
|
||||
int lfs_vptofh(struct vnode *, struct fid *, size_t *);
|
||||
void lfs_vinit(struct mount *, struct vnode **);
|
||||
int lfs_resize_fs(struct lfs *, int);
|
||||
|
||||
/* lfs_vnops.c */
|
||||
void lfs_mark_vnode(struct vnode *);
|
||||
void lfs_unmark_vnode(struct vnode *);
|
||||
int lfs_gop_alloc(struct vnode *, off_t, off_t, int, kauth_cred_t);
|
||||
void lfs_gop_size(struct vnode *, off_t, off_t *, int);
|
||||
int lfs_putpages_ext(void *, int);
|
||||
int lfs_gatherpages(struct vnode *);
|
||||
void lfs_flush_dirops(struct lfs *);
|
||||
void lfs_flush_pchain(struct lfs *);
|
||||
|
||||
int lfs_bwrite (void *);
|
||||
int lfs_fsync (void *);
|
||||
int lfs_symlink (void *);
|
||||
int lfs_mknod (void *);
|
||||
int lfs_create (void *);
|
||||
int lfs_mkdir (void *);
|
||||
int lfs_read (void *);
|
||||
int lfs_remove (void *);
|
||||
int lfs_rmdir (void *);
|
||||
int lfs_link (void *);
|
||||
int lfs_mmap (void *);
|
||||
int lfs_rename (void *);
|
||||
int lfs_getattr (void *);
|
||||
int lfs_setattr (void *);
|
||||
int lfs_close (void *);
|
||||
int lfsspec_close(void *);
|
||||
int lfsfifo_close(void *);
|
||||
int lfs_fcntl (void *);
|
||||
int lfs_inactive (void *);
|
||||
int lfs_reclaim (void *);
|
||||
int lfs_strategy (void *);
|
||||
int lfs_write (void *);
|
||||
int lfs_getpages (void *);
|
||||
int lfs_putpages (void *);
|
||||
|
||||
extern int lfs_mount_type;
|
||||
extern int (**lfs_vnodeop_p)(void *);
|
||||
extern int (**lfs_specop_p)(void *);
|
||||
extern int (**lfs_fifoop_p)(void *);
|
||||
extern const struct genfs_ops lfs_genfsops;
|
||||
|
||||
#endif /* defined(_KERNEL) */
|
||||
|
||||
/* lfs_cksum.c */
|
||||
u_int32_t cksum(void *, size_t);
|
||||
u_int32_t lfs_cksum_part(void *, size_t, u_int32_t);
|
||||
#define lfs_cksum_fold(sum) (sum)
|
||||
u_int32_t lfs_sb_cksum(struct dlfs *);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_UFS_LFS_LFS_EXTERN_H_ */
|
||||
@@ -1,79 +0,0 @@
|
||||
/* $NetBSD: mfs_extern.h,v 1.31 2010/03/02 17:20:02 pooka Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* @(#)mfs_extern.h 8.4 (Berkeley) 3/30/95
|
||||
*/
|
||||
|
||||
#ifndef _UFS_MFS_MFS_EXTERN_H_
|
||||
#define _UFS_MFS_MFS_EXTERN_H_
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/mallocvar.h>
|
||||
|
||||
struct buf;
|
||||
struct mount;
|
||||
struct nameidata;
|
||||
struct proc;
|
||||
struct statvfs;
|
||||
struct vnode;
|
||||
|
||||
__BEGIN_DECLS
|
||||
#define mfs_ioctl genfs_enoioctl
|
||||
|
||||
/* mfs_vfsops.c */
|
||||
VFS_PROTOS(mfs);
|
||||
|
||||
int mfs_initminiroot(void *);
|
||||
|
||||
/* mfs_vnops.c */
|
||||
int mfs_open(void *);
|
||||
int mfs_strategy(void *);
|
||||
void mfs_doio(struct buf *, void *);
|
||||
int mfs_bmap(void *);
|
||||
int mfs_close(void *);
|
||||
int mfs_inactive(void *);
|
||||
int mfs_reclaim(void *);
|
||||
int mfs_print(void *);
|
||||
int mfs_fsync(void *);
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
#include <sys/mutex.h>
|
||||
|
||||
extern kmutex_t mfs_lock;
|
||||
extern void *mfs_rootbase;
|
||||
extern u_long mfs_rootsize;
|
||||
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_UFS_MFS_MFS_EXTERN_H_ */
|
||||
@@ -1,91 +0,0 @@
|
||||
/* $NetBSD: mfsnode.h,v 1.21 2008/03/26 14:19:43 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)mfsnode.h 8.3 (Berkeley) 5/19/95
|
||||
*/
|
||||
|
||||
#ifndef _UFS_MFS_MFSNODE_H_
|
||||
#define _UFS_MFS_MFSNODE_H_
|
||||
|
||||
/*
|
||||
* This structure defines the control data for the memory based file system.
|
||||
*/
|
||||
|
||||
struct mfsnode {
|
||||
struct vnode *mfs_vnode; /* vnode associated with this mfsnode */
|
||||
void *mfs_baseoff; /* base of file system in memory */
|
||||
long mfs_size; /* size of memory file system */
|
||||
struct proc *mfs_proc; /* supporting process */
|
||||
int mfs_shutdown; /* shutdown this mfsnode */
|
||||
#if defined(_KERNEL)
|
||||
kcondvar_t mfs_cv; /* notifier */
|
||||
int mfs_refcnt; /* number of references */
|
||||
struct bufq_state *mfs_buflist;/* list of I/O requests */
|
||||
#endif /* defined(_KERNEL) */
|
||||
};
|
||||
|
||||
#if defined(_KERNEL)
|
||||
/*
|
||||
* Convert between mfsnode pointers and vnode pointers
|
||||
*/
|
||||
#define VTOMFS(vp) ((struct mfsnode *)(vp)->v_data)
|
||||
#define MFSTOV(mfsp) ((mfsp)->mfs_vnode)
|
||||
|
||||
/* Prototypes for MFS operations on vnodes. */
|
||||
#define mfs_lookup genfs_badop
|
||||
#define mfs_create genfs_badop
|
||||
#define mfs_mknod genfs_badop
|
||||
#define mfs_access genfs_badop
|
||||
#define mfs_getattr genfs_badop
|
||||
#define mfs_setattr genfs_badop
|
||||
#define mfs_read genfs_badop
|
||||
#define mfs_write genfs_badop
|
||||
#define mfs_poll genfs_badop
|
||||
#define mfs_mmap genfs_badop
|
||||
#define mfs_seek genfs_badop
|
||||
#define mfs_remove genfs_badop
|
||||
#define mfs_link genfs_badop
|
||||
#define mfs_rename genfs_badop
|
||||
#define mfs_mkdir genfs_badop
|
||||
#define mfs_rmdir genfs_badop
|
||||
#define mfs_symlink genfs_badop
|
||||
#define mfs_readdir genfs_badop
|
||||
#define mfs_readlink genfs_badop
|
||||
#define mfs_abortop genfs_badop
|
||||
#define mfs_islocked genfs_noislocked
|
||||
#define mfs_pathconf genfs_badop
|
||||
#define mfs_advlock genfs_badop
|
||||
#define mfs_bwrite vn_bwrite
|
||||
#define mfs_revoke genfs_revoke
|
||||
#define mfs_putpages genfs_null_putpages
|
||||
|
||||
#endif /* defined(_KERNEL) */
|
||||
|
||||
#endif /* !_UFS_MFS_MFSNODE_H_ */
|
||||
@@ -1,180 +0,0 @@
|
||||
/* $NetBSD: dinode.h,v 1.21 2009/06/28 09:26:18 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002 Networks Associates Technology, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software was developed for the FreeBSD Project by Marshall
|
||||
* Kirk McKusick and Network Associates Laboratories, the Security
|
||||
* Research Division of Network Associates, Inc. under DARPA/SPAWAR
|
||||
* contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS
|
||||
* research program
|
||||
*
|
||||
* Copyright (c) 1982, 1989, 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.
|
||||
*
|
||||
* @(#)dinode.h 8.9 (Berkeley) 3/29/95
|
||||
*/
|
||||
|
||||
/*
|
||||
* NOTE: COORDINATE ON-DISK FORMAT CHANGES WITH THE FREEBSD PROJECT.
|
||||
*/
|
||||
|
||||
#ifndef _UFS_UFS_DINODE_H_
|
||||
#define _UFS_UFS_DINODE_H_
|
||||
|
||||
/*
|
||||
* The root inode is the root of the file system. Inode 0 can't be used for
|
||||
* normal purposes and historically bad blocks were linked to inode 1, thus
|
||||
* the root inode is 2. (Inode 1 is no longer used for this purpose, however
|
||||
* numerous dump tapes make this assumption, so we are stuck with it).
|
||||
*/
|
||||
#define ROOTINO ((ino_t)2)
|
||||
|
||||
/*
|
||||
* The Whiteout inode# is a dummy non-zero inode number which will
|
||||
* never be allocated to a real file. It is used as a place holder
|
||||
* in the directory entry which has been tagged as a DT_W entry.
|
||||
* See the comments about ROOTINO above.
|
||||
*/
|
||||
#define WINO ((ino_t)1)
|
||||
|
||||
/*
|
||||
* A dinode contains all the meta-data associated with a UFS file.
|
||||
* This structure defines the on-disk format of a dinode. Since
|
||||
* this structure describes an on-disk structure, all its fields
|
||||
* are defined by types with precise widths.
|
||||
*/
|
||||
|
||||
#define NXADDR 2
|
||||
#define NDADDR 12 /* Direct addresses in inode. */
|
||||
#define NIADDR 3 /* Indirect addresses in inode. */
|
||||
|
||||
struct ufs1_dinode {
|
||||
u_int16_t di_mode; /* 0: IFMT, permissions; see below. */
|
||||
int16_t di_nlink; /* 2: File link count. */
|
||||
union {
|
||||
u_int16_t oldids[2]; /* 4: Ffs: old user and group ids. */
|
||||
u_int32_t inumber; /* 4: Lfs: inode number. */
|
||||
} di_u;
|
||||
u_int64_t di_size; /* 8: File byte count. */
|
||||
int32_t di_atime; /* 16: Last access time. */
|
||||
int32_t di_atimensec; /* 20: Last access time. */
|
||||
int32_t di_mtime; /* 24: Last modified time. */
|
||||
int32_t di_mtimensec; /* 28: Last modified time. */
|
||||
int32_t di_ctime; /* 32: Last inode change time. */
|
||||
int32_t di_ctimensec; /* 36: Last inode change time. */
|
||||
int32_t di_db[NDADDR]; /* 40: Direct disk blocks. */
|
||||
int32_t di_ib[NIADDR]; /* 88: Indirect disk blocks. */
|
||||
u_int32_t di_flags; /* 100: Status flags (chflags). */
|
||||
u_int32_t di_blocks; /* 104: Blocks actually held. */
|
||||
int32_t di_gen; /* 108: Generation number. */
|
||||
u_int32_t di_uid; /* 112: File owner. */
|
||||
u_int32_t di_gid; /* 116: File group. */
|
||||
u_int64_t di_modrev; /* 120: i_modrev for NFSv4 */
|
||||
};
|
||||
|
||||
struct ufs2_dinode {
|
||||
u_int16_t di_mode; /* 0: IFMT, permissions; see below. */
|
||||
int16_t di_nlink; /* 2: File link count. */
|
||||
u_int32_t di_uid; /* 4: File owner. */
|
||||
u_int32_t di_gid; /* 8: File group. */
|
||||
u_int32_t di_blksize; /* 12: Inode blocksize. */
|
||||
u_int64_t di_size; /* 16: File byte count. */
|
||||
u_int64_t di_blocks; /* 24: Bytes actually held. */
|
||||
int64_t di_atime; /* 32: Last access time. */
|
||||
int64_t di_mtime; /* 40: Last modified time. */
|
||||
int64_t di_ctime; /* 48: Last inode change time. */
|
||||
int64_t di_birthtime; /* 56: Inode creation time. */
|
||||
int32_t di_mtimensec; /* 64: Last modified time. */
|
||||
int32_t di_atimensec; /* 68: Last access time. */
|
||||
int32_t di_ctimensec; /* 72: Last inode change time. */
|
||||
int32_t di_birthnsec; /* 76: Inode creation time. */
|
||||
int32_t di_gen; /* 80: Generation number. */
|
||||
u_int32_t di_kernflags; /* 84: Kernel flags. */
|
||||
u_int32_t di_flags; /* 88: Status flags (chflags). */
|
||||
int32_t di_extsize; /* 92: External attributes block. */
|
||||
int64_t di_extb[NXADDR];/* 96: External attributes block. */
|
||||
int64_t di_db[NDADDR]; /* 112: Direct disk blocks. */
|
||||
int64_t di_ib[NIADDR]; /* 208: Indirect disk blocks. */
|
||||
u_int64_t di_modrev; /* 232: i_modrev for NFSv4 */
|
||||
int64_t di_spare[2]; /* 240: Reserved; currently unused */
|
||||
};
|
||||
|
||||
/*
|
||||
* The di_db fields may be overlaid with other information for
|
||||
* file types that do not have associated disk storage. Block
|
||||
* and character devices overlay the first data block with their
|
||||
* dev_t value. Short symbolic links place their path in the
|
||||
* di_db area.
|
||||
*/
|
||||
#define di_inumber di_u.inumber
|
||||
#define di_ogid di_u.oldids[1]
|
||||
#define di_ouid di_u.oldids[0]
|
||||
#define di_rdev di_db[0]
|
||||
#define MAXSYMLINKLEN_UFS1 ((NDADDR + NIADDR) * sizeof(int32_t))
|
||||
#define MAXSYMLINKLEN_UFS2 ((NDADDR + NIADDR) * sizeof(int64_t))
|
||||
|
||||
#define MAXSYMLINKLEN(ip) \
|
||||
((ip)->i_ump->um_fstype == UFS1) ? \
|
||||
MAXSYMLINKLEN_UFS1 : MAXSYMLINKLEN_UFS2
|
||||
|
||||
/* NeXT used to keep short symlinks in the inode even when using
|
||||
* FS_42INODEFMT. In that case fs->fs_maxsymlinklen is probably -1,
|
||||
* but short symlinks were stored in inodes shorter than this:
|
||||
*/
|
||||
#define APPLEUFS_MAXSYMLINKLEN 60
|
||||
|
||||
/* File permissions. */
|
||||
#define IEXEC 0000100 /* Executable. */
|
||||
#define IWRITE 0000200 /* Writable. */
|
||||
#define IREAD 0000400 /* Readable. */
|
||||
#define ISVTX 0001000 /* Sticky bit. */
|
||||
#define ISGID 0002000 /* Set-gid. */
|
||||
#define ISUID 0004000 /* Set-uid. */
|
||||
|
||||
/* File types. */
|
||||
#define IFMT 0170000 /* Mask of file type. */
|
||||
#define IFIFO 0010000 /* Named pipe (fifo). */
|
||||
#define IFCHR 0020000 /* Character device. */
|
||||
#define IFDIR 0040000 /* Directory file. */
|
||||
#define IFBLK 0060000 /* Block device. */
|
||||
#define IFREG 0100000 /* Regular file. */
|
||||
#define IFLNK 0120000 /* Symbolic link. */
|
||||
#define IFSOCK 0140000 /* UNIX domain socket. */
|
||||
#define IFWHT 0160000 /* Whiteout. */
|
||||
|
||||
/* Size of the on-disk inode. */
|
||||
#define DINODE1_SIZE (sizeof(struct ufs1_dinode)) /* 128 */
|
||||
#define DINODE2_SIZE (sizeof(struct ufs2_dinode))
|
||||
|
||||
#endif /* !_UFS_UFS_DINODE_H_ */
|
||||
@@ -1,160 +0,0 @@
|
||||
/* $NetBSD: dir.h,v 1.21 2009/07/22 04:49:19 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 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.
|
||||
*
|
||||
* @(#)dir.h 8.5 (Berkeley) 4/27/95
|
||||
*/
|
||||
|
||||
#ifndef _UFS_UFS_DIR_H_
|
||||
#define _UFS_UFS_DIR_H_
|
||||
|
||||
/*
|
||||
* Theoretically, directories can be more than 2Gb in length; however, in
|
||||
* practice this seems unlikely. So, we define the type doff_t as a 32-bit
|
||||
* quantity to keep down the cost of doing lookup on a 32-bit machine.
|
||||
*/
|
||||
#define doff_t int32_t
|
||||
#define MAXDIRSIZE (0x7fffffff)
|
||||
|
||||
/*
|
||||
* A directory consists of some number of blocks of DIRBLKSIZ
|
||||
* bytes, where DIRBLKSIZ is chosen such that it can be transferred
|
||||
* to disk in a single atomic operation (e.g. 512 bytes on most machines).
|
||||
*
|
||||
* Each DIRBLKSIZ byte block contains some number of directory entry
|
||||
* structures, which are of variable length. Each directory entry has
|
||||
* a struct direct at the front of it, containing its inode number,
|
||||
* the length of the entry, and the length of the name contained in
|
||||
* the entry. These are followed by the name padded to a 4 byte boundary.
|
||||
* All names are guaranteed null terminated.
|
||||
* The maximum length of a name in a directory is FFS_MAXNAMLEN.
|
||||
*
|
||||
* The macro DIRSIZ(fmt, dp) gives the amount of space required to represent
|
||||
* a directory entry. Free space in a directory is represented by
|
||||
* entries which have dp->d_reclen > DIRSIZ(fmt, dp). All DIRBLKSIZ bytes
|
||||
* in a directory block are claimed by the directory entries. This
|
||||
* usually results in the last entry in a directory having a large
|
||||
* dp->d_reclen. When entries are deleted from a directory, the
|
||||
* space is returned to the previous entry in the same directory
|
||||
* block by increasing its dp->d_reclen. If the first entry of
|
||||
* a directory block is free, then its dp->d_ino is set to 0.
|
||||
* Entries other than the first in a directory do not normally have
|
||||
* dp->d_ino set to 0.
|
||||
*/
|
||||
#undef DIRBLKSIZ
|
||||
#define DIRBLKSIZ DEV_BSIZE
|
||||
#define FFS_MAXNAMLEN 255
|
||||
#define APPLEUFS_DIRBLKSIZ 1024
|
||||
|
||||
#define d_ino d_fileno
|
||||
struct direct {
|
||||
u_int32_t d_fileno; /* inode number of entry */
|
||||
u_int16_t d_reclen; /* length of this record */
|
||||
u_int8_t d_type; /* file type, see below */
|
||||
u_int8_t d_namlen; /* length of string in d_name */
|
||||
char d_name[FFS_MAXNAMLEN + 1];/* name with length <= FFS_MAXNAMLEN */
|
||||
};
|
||||
|
||||
/*
|
||||
* File types
|
||||
*/
|
||||
#define DT_UNKNOWN 0
|
||||
#define DT_FIFO 1
|
||||
#define DT_CHR 2
|
||||
#define DT_DIR 4
|
||||
#define DT_BLK 6
|
||||
#define DT_REG 8
|
||||
#define DT_LNK 10
|
||||
#define DT_SOCK 12
|
||||
#define DT_WHT 14
|
||||
|
||||
/*
|
||||
* Convert between stat structure types and directory types.
|
||||
*/
|
||||
#define IFTODT(mode) (((mode) & 0170000) >> 12)
|
||||
#define DTTOIF(dirtype) ((dirtype) << 12)
|
||||
|
||||
/*
|
||||
* The DIRSIZ macro gives the minimum record length which will hold
|
||||
* the directory entry. This requires the amount of space in struct direct
|
||||
* without the d_name field, plus enough space for the name with a terminating
|
||||
* null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
|
||||
*/
|
||||
#define DIRECTSIZ(namlen) \
|
||||
((sizeof(struct direct) - (FFS_MAXNAMLEN+1)) + (((namlen)+1 + 3) &~ 3))
|
||||
|
||||
#if (BYTE_ORDER == LITTLE_ENDIAN)
|
||||
#define DIRSIZ(oldfmt, dp, needswap) \
|
||||
(((oldfmt) && !(needswap)) ? \
|
||||
DIRECTSIZ((dp)->d_type) : DIRECTSIZ((dp)->d_namlen))
|
||||
#else
|
||||
#define DIRSIZ(oldfmt, dp, needswap) \
|
||||
(((oldfmt) && (needswap)) ? \
|
||||
DIRECTSIZ((dp)->d_type) : DIRECTSIZ((dp)->d_namlen))
|
||||
#endif
|
||||
|
||||
#define OLDDIRFMT 1
|
||||
#define NEWDIRFMT 0
|
||||
|
||||
/*
|
||||
* Template for manipulating directories. Should use struct direct's,
|
||||
* but the name field is FFS_MAXNAMLEN - 1, and this just won't do.
|
||||
*/
|
||||
struct dirtemplate {
|
||||
u_int32_t dot_ino;
|
||||
int16_t dot_reclen;
|
||||
u_int8_t dot_type;
|
||||
u_int8_t dot_namlen;
|
||||
char dot_name[4]; /* must be multiple of 4 */
|
||||
u_int32_t dotdot_ino;
|
||||
int16_t dotdot_reclen;
|
||||
u_int8_t dotdot_type;
|
||||
u_int8_t dotdot_namlen;
|
||||
char dotdot_name[4]; /* ditto */
|
||||
};
|
||||
|
||||
/*
|
||||
* This is the old format of directories, sanz type element.
|
||||
*/
|
||||
struct odirtemplate {
|
||||
u_int32_t dot_ino;
|
||||
int16_t dot_reclen;
|
||||
u_int16_t dot_namlen;
|
||||
char dot_name[4]; /* must be multiple of 4 */
|
||||
u_int32_t dotdot_ino;
|
||||
int16_t dotdot_reclen;
|
||||
u_int16_t dotdot_namlen;
|
||||
char dotdot_name[4]; /* ditto */
|
||||
};
|
||||
#endif /* !_UFS_UFS_DIR_H_ */
|
||||
@@ -1,129 +0,0 @@
|
||||
/* $NetBSD: dirhash.h,v 1.6 2008/06/04 11:33:19 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 Ian Dowse. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD: src/sys/ufs/ufs/dirhash.h,v 1.2.2.2 2004/12/08 11:54:13 dwmalone Exp $
|
||||
*/
|
||||
|
||||
#ifndef _UFS_UFS_DIRHASH_H_
|
||||
#define _UFS_UFS_DIRHASH_H_
|
||||
|
||||
/*
|
||||
* For fast operations on large directories, we maintain a hash
|
||||
* that maps the file name to the offset of the directory entry within
|
||||
* the directory file.
|
||||
*
|
||||
* The hashing uses a dumb spillover to the next free slot on
|
||||
* collisions, so we must keep the utilisation low to avoid
|
||||
* long linear searches. Deleted entries that are not the last
|
||||
* in a chain must be marked DIRHASH_DEL.
|
||||
*
|
||||
* We also maintain information about free space in each block
|
||||
* to speed up creations.
|
||||
*/
|
||||
#define DIRHASH_EMPTY (-1) /* entry unused */
|
||||
#define DIRHASH_DEL (-2) /* deleted entry; may be part of chain */
|
||||
|
||||
#define DIRALIGN 4
|
||||
#define DH_NFSTATS (DIRECTSIZ(FFS_MAXNAMLEN + 1) / DIRALIGN)
|
||||
/* max DIRALIGN words in a directory entry */
|
||||
|
||||
/*
|
||||
* Dirhash uses a score mechanism to achieve a hybrid between a
|
||||
* least-recently-used and a least-often-used algorithm for entry
|
||||
* recycling. The score is incremented when a directory is used, and
|
||||
* decremented when the directory is a candidate for recycling. When
|
||||
* the score reaches zero, the hash is recycled. Hashes are linked
|
||||
* together on a TAILQ list, and hashes with higher scores filter
|
||||
* towards the tail (most recently used) end of the list.
|
||||
*
|
||||
* New hash entries are given an inital score of DH_SCOREINIT and are
|
||||
* placed at the most-recently-used end of the list. This helps a lot
|
||||
* in the worst-case case scenario where every directory access is
|
||||
* to a directory that is not hashed (i.e. the working set of hash
|
||||
* candidates is much larger than the configured memry limit). In this
|
||||
* case it limits the number of hash builds to 1/DH_SCOREINIT of the
|
||||
* number of accesses.
|
||||
*/
|
||||
#define DH_SCOREINIT 8 /* initial dh_score when dirhash built */
|
||||
#define DH_SCOREMAX 64 /* max dh_score value */
|
||||
|
||||
/*
|
||||
* The main hash table has 2 levels. It is an array of pointers to
|
||||
* blocks of DH_NBLKOFF offsets.
|
||||
*/
|
||||
#define DH_BLKOFFSHIFT 8
|
||||
#define DH_NBLKOFF (1 << DH_BLKOFFSHIFT)
|
||||
#define DH_BLKOFFMASK (DH_NBLKOFF - 1)
|
||||
|
||||
#define DH_ENTRY(dh, slot) \
|
||||
((dh)->dh_hash[(slot) >> DH_BLKOFFSHIFT][(slot) & DH_BLKOFFMASK])
|
||||
|
||||
struct dirhash {
|
||||
kmutex_t dh_lock; /* protects all fields except dh_list */
|
||||
|
||||
doff_t **dh_hash; /* the hash array (2-level) */
|
||||
size_t dh_hashsz;
|
||||
int dh_narrays; /* number of entries in dh_hash */
|
||||
int dh_hlen; /* total slots in the 2-level hash array */
|
||||
int dh_hused; /* entries in use */
|
||||
|
||||
u_int8_t *dh_blkfree; /* free DIRALIGN words in each dir block */
|
||||
size_t dh_blkfreesz;
|
||||
int dh_nblk; /* size of dh_blkfree array */
|
||||
int dh_dirblks; /* number of DIRBLKSIZ blocks in dir */
|
||||
int dh_firstfree[DH_NFSTATS + 1]; /* first blk with N words free */
|
||||
|
||||
int dh_seqopt; /* sequential access optimisation enabled */
|
||||
doff_t dh_seqoff; /* sequential access optimisation offset */
|
||||
|
||||
int dh_score; /* access count for this dirhash */
|
||||
|
||||
int dh_onlist; /* true if on the ufsdirhash_list chain */
|
||||
|
||||
/* Protected by ufsdirhash_lock. */
|
||||
TAILQ_ENTRY(dirhash) dh_list; /* chain of all dirhashes */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Dirhash functions.
|
||||
*/
|
||||
int ufsdirhash_build(struct inode *);
|
||||
doff_t ufsdirhash_findfree(struct inode *, int, int *);
|
||||
doff_t ufsdirhash_enduseful(struct inode *);
|
||||
int ufsdirhash_lookup(struct inode *, const char *, int, doff_t *,
|
||||
struct buf **, doff_t *);
|
||||
void ufsdirhash_newblk(struct inode *, doff_t);
|
||||
void ufsdirhash_add(struct inode *, struct direct *, doff_t);
|
||||
void ufsdirhash_remove(struct inode *, struct direct *, doff_t);
|
||||
void ufsdirhash_move(struct inode *, struct direct *, doff_t, doff_t);
|
||||
void ufsdirhash_dirtrunc(struct inode *, doff_t);
|
||||
void ufsdirhash_free(struct inode *);
|
||||
void ufsdirhash_checkblock(struct inode *, char *, doff_t);
|
||||
void ufsdirhash_init(void);
|
||||
void ufsdirhash_done(void);
|
||||
|
||||
#endif /* !_UFS_UFS_DIRHASH_H_ */
|
||||
@@ -1,128 +0,0 @@
|
||||
/* $NetBSD: extattr.h,v 1.10 2011/10/09 21:15:34 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999-2001 Robert N. M. Watson
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software was developed by Robert Watson for the TrustedBSD Project.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD: src/sys/ufs/ufs/extattr.h,v 1.20 2005/01/31 08:16:45 imp Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* Support for file system extended attributes on the UFS1 file system.
|
||||
* Developed by the TrustedBSD Project.
|
||||
*/
|
||||
|
||||
#ifndef _UFS_UFS_EXTATTR_H_
|
||||
#define _UFS_UFS_EXTATTR_H_
|
||||
|
||||
#define UFS_EXTATTR_MAGIC 0x00b5d5ec
|
||||
#define UFS_EXTATTR_VERSION 0x00000003
|
||||
#define UFS_EXTATTR_FSROOTSUBDIR ".attribute"
|
||||
#define UFS_EXTATTR_SUBDIR_SYSTEM "system"
|
||||
#define UFS_EXTATTR_SUBDIR_USER "user"
|
||||
#define UFS_EXTATTR_MAXEXTATTRNAME 65 /* including null */
|
||||
|
||||
#define UFS_EXTATTR_ATTR_FLAG_INUSE 0x00000001 /* attr has been set */
|
||||
#define UFS_EXTATTR_PERM_KERNEL 0x00000000
|
||||
#define UFS_EXTATTR_PERM_ROOT 0x00000001
|
||||
#define UFS_EXTATTR_PERM_OWNER 0x00000002
|
||||
#define UFS_EXTATTR_PERM_ANYONE 0x00000003
|
||||
|
||||
#define UFS_EXTATTR_UEPM_INITIALIZED 0x00000001
|
||||
#define UFS_EXTATTR_UEPM_STARTED 0x00000002
|
||||
|
||||
#define UFS_EXTATTR_CMD_START EXTATTR_CMD_START
|
||||
#define UFS_EXTATTR_CMD_STOP EXTATTR_CMD_STOP
|
||||
#define UFS_EXTATTR_CMD_ENABLE 0x00000003
|
||||
#define UFS_EXTATTR_CMD_DISABLE 0x00000004
|
||||
|
||||
struct ufs_extattr_fileheader {
|
||||
uint32_t uef_magic; /* magic number for sanity checking */
|
||||
uint32_t uef_version; /* version of attribute file */
|
||||
uint32_t uef_size; /* size of attributes, w/o header */
|
||||
};
|
||||
|
||||
struct ufs_extattr_header {
|
||||
uint32_t ueh_flags; /* flags for attribute */
|
||||
uint32_t ueh_len; /* local defined length; <= uef_size */
|
||||
uint32_t ueh_i_gen; /* generation number for sanity */
|
||||
/* data follows the header */
|
||||
};
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
#ifdef MALLOC_DECLARE
|
||||
MALLOC_DECLARE(M_EXTATTR);
|
||||
#endif
|
||||
|
||||
struct vnode;
|
||||
LIST_HEAD(ufs_extattr_list_head, ufs_extattr_list_entry);
|
||||
struct ufs_extattr_list_entry {
|
||||
LIST_ENTRY(ufs_extattr_list_entry) uele_entries;
|
||||
struct ufs_extattr_fileheader uele_fileheader;
|
||||
int uele_attrnamespace;
|
||||
char uele_attrname[UFS_EXTATTR_MAXEXTATTRNAME];
|
||||
struct vnode *uele_backing_vnode;
|
||||
int uele_flags;
|
||||
};
|
||||
|
||||
/* uele_flags */
|
||||
#define UELE_F_NEEDSWAP 0x01 /* needs byte swap */
|
||||
|
||||
#define UELE_NEEDSWAP(uele) ((uele)->uele_flags & UELE_F_NEEDSWAP)
|
||||
|
||||
struct lock;
|
||||
struct ufs_extattr_per_mount {
|
||||
kmutex_t uepm_lock;
|
||||
struct ufs_extattr_list_head uepm_list;
|
||||
kauth_cred_t uepm_ucred;
|
||||
int uepm_lockcnt;
|
||||
int uepm_flags;
|
||||
};
|
||||
|
||||
void ufs_extattr_uepm_init(struct ufs_extattr_per_mount *uepm);
|
||||
void ufs_extattr_uepm_destroy(struct ufs_extattr_per_mount *uepm);
|
||||
int ufs_extattr_start(struct mount *mp, struct lwp *l);
|
||||
int ufs_extattr_autostart(struct mount *mp, struct lwp *l);
|
||||
void ufs_extattr_stop(struct mount *mp, struct lwp *l);
|
||||
int ufs_extattrctl(struct mount *mp, int cmd, struct vnode *filename,
|
||||
int attrnamespace, const char *attrname);
|
||||
struct vop_getextattr_args;
|
||||
int ufs_getextattr(struct vop_getextattr_args *ap);
|
||||
struct vop_deleteextattr_args;
|
||||
int ufs_deleteextattr(struct vop_deleteextattr_args *ap);
|
||||
struct vop_setextattr_args;
|
||||
int ufs_setextattr(struct vop_setextattr_args *ap);
|
||||
struct vop_listextattr_args;
|
||||
int ufs_listextattr(struct vop_listextattr_args *ap);
|
||||
void ufs_extattr_vnode_inactive(struct vnode *vp, struct lwp *l);
|
||||
|
||||
void ufs_extattr_init(void);
|
||||
void ufs_extattr_done(void);
|
||||
|
||||
#endif /* !_KERNEL */
|
||||
|
||||
#endif /* !_UFS_UFS_EXTATTR_H_ */
|
||||
@@ -1,300 +0,0 @@
|
||||
/* $NetBSD: inode.h,v 1.58 2011/07/12 02:22:13 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1989, 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.
|
||||
*
|
||||
* @(#)inode.h 8.9 (Berkeley) 5/14/95
|
||||
*/
|
||||
|
||||
#ifndef _UFS_UFS_INODE_H_
|
||||
#define _UFS_UFS_INODE_H_
|
||||
|
||||
#include <sys/vnode.h>
|
||||
#include <ufs/ufs/dinode.h>
|
||||
#include <ufs/ufs/dir.h>
|
||||
#include <ufs/ufs/quota.h>
|
||||
#include <ufs/ext2fs/ext2fs_dinode.h>
|
||||
#include <miscfs/genfs/genfs_node.h>
|
||||
|
||||
/*
|
||||
* Lookup result state (other than the result inode). This is
|
||||
* currently stashed in the vnode between VOP_LOOKUP and directory
|
||||
* operation VOPs, which is gross.
|
||||
*/
|
||||
struct ufs_lookup_results {
|
||||
int32_t ulr_count; /* Size of free slot in directory. */
|
||||
doff_t ulr_endoff; /* End of useful stuff in directory. */
|
||||
doff_t ulr_diroff; /* Offset in dir, where we found last entry. */
|
||||
doff_t ulr_offset; /* Offset of free space in directory. */
|
||||
u_int32_t ulr_reclen; /* Size of found directory entry. */
|
||||
};
|
||||
|
||||
/* notyet XXX */
|
||||
#define UFS_CHECK_CRAPCOUNTER(dp) ((void)(dp)->i_crapcounter)
|
||||
|
||||
/*
|
||||
* Per-filesystem inode extensions.
|
||||
*/
|
||||
struct ffs_inode_ext {
|
||||
daddr_t *ffs_snapblklist; /* Collect expunged snapshot blocks. */
|
||||
/* follow two fields are used by contiguous allocation code only. */
|
||||
daddr_t ffs_first_data_blk; /* first data block on disk. */
|
||||
daddr_t ffs_first_indir_blk; /* first indirect block on disk. */
|
||||
};
|
||||
|
||||
struct ext2fs_inode_ext {
|
||||
daddr_t ext2fs_last_lblk; /* last logical block allocated */
|
||||
daddr_t ext2fs_last_blk; /* last block allocated on disk */
|
||||
};
|
||||
|
||||
struct lfs_inode_ext;
|
||||
|
||||
/*
|
||||
* The inode is used to describe each active (or recently active) file in the
|
||||
* UFS filesystem. It is composed of two types of information. The first part
|
||||
* is the information that is needed only while the file is active (such as
|
||||
* the identity of the file and linkage to speed its lookup). The second part
|
||||
* is the permanent meta-data associated with the file which is read in
|
||||
* from the permanent dinode from long term storage when the file becomes
|
||||
* active, and is put back when the file is no longer being used.
|
||||
*/
|
||||
struct inode {
|
||||
struct genfs_node i_gnode;
|
||||
LIST_ENTRY(inode) i_hash;/* Hash chain. */
|
||||
TAILQ_ENTRY(inode) i_nextsnap; /* snapshot file list. */
|
||||
struct vnode *i_vnode; /* Vnode associated with this inode. */
|
||||
struct ufsmount *i_ump; /* Mount point associated with this inode. */
|
||||
struct vnode *i_devvp; /* Vnode for block I/O. */
|
||||
u_int32_t i_flag; /* flags, see below */
|
||||
dev_t i_dev; /* Device associated with the inode. */
|
||||
ino_t i_number; /* The identity of the inode. */
|
||||
|
||||
union { /* Associated filesystem. */
|
||||
struct fs *fs; /* FFS */
|
||||
struct lfs *lfs; /* LFS */
|
||||
struct m_ext2fs *e2fs; /* EXT2FS */
|
||||
} inode_u;
|
||||
#define i_fs inode_u.fs
|
||||
#define i_lfs inode_u.lfs
|
||||
#define i_e2fs inode_u.e2fs
|
||||
|
||||
void *i_unused1; /* Unused. */
|
||||
struct dquot *i_dquot[MAXQUOTAS]; /* Dquot structures. */
|
||||
u_quad_t i_modrev; /* Revision level for NFS lease. */
|
||||
struct lockf *i_lockf;/* Head of byte-level lock list. */
|
||||
|
||||
/*
|
||||
* Side effects; used during (and after) directory lookup.
|
||||
* XXX should not be here.
|
||||
*/
|
||||
struct ufs_lookup_results i_crap;
|
||||
unsigned i_crapcounter; /* serial number for i_crap */
|
||||
|
||||
/*
|
||||
* Inode extensions
|
||||
*/
|
||||
union {
|
||||
/* Other extensions could go here... */
|
||||
struct ffs_inode_ext ffs;
|
||||
struct ext2fs_inode_ext e2fs;
|
||||
struct lfs_inode_ext *lfs;
|
||||
} inode_ext;
|
||||
#define i_snapblklist inode_ext.ffs.ffs_snapblklist
|
||||
#define i_ffs_first_data_blk inode_ext.ffs.ffs_first_data_blk
|
||||
#define i_ffs_first_indir_blk inode_ext.ffs.ffs_first_indir_blk
|
||||
#define i_e2fs_last_lblk inode_ext.e2fs.ext2fs_last_lblk
|
||||
#define i_e2fs_last_blk inode_ext.e2fs.ext2fs_last_blk
|
||||
/*
|
||||
* Copies from the on-disk dinode itself.
|
||||
*
|
||||
* These fields are currently only used by FFS and LFS,
|
||||
* do NOT use them with ext2fs.
|
||||
*/
|
||||
u_int16_t i_mode; /* IFMT, permissions; see below. */
|
||||
int16_t i_nlink; /* File link count. */
|
||||
u_int64_t i_size; /* File byte count. */
|
||||
u_int32_t i_flags; /* Status flags (chflags). */
|
||||
int32_t i_gen; /* Generation number. */
|
||||
u_int32_t i_uid; /* File owner. */
|
||||
u_int32_t i_gid; /* File group. */
|
||||
u_int16_t i_omode; /* Old mode, for ufs_reclaim. */
|
||||
|
||||
struct dirhash *i_dirhash; /* Hashing for large directories */
|
||||
|
||||
/*
|
||||
* The on-disk dinode itself.
|
||||
*/
|
||||
union {
|
||||
struct ufs1_dinode *ffs1_din; /* 128 bytes of the on-disk dinode. */
|
||||
struct ufs2_dinode *ffs2_din;
|
||||
struct ext2fs_dinode *e2fs_din; /* 128 bytes of the on-disk
|
||||
dinode. */
|
||||
} i_din;
|
||||
};
|
||||
|
||||
#define i_ffs1_atime i_din.ffs1_din->di_atime
|
||||
#define i_ffs1_atimensec i_din.ffs1_din->di_atimensec
|
||||
#define i_ffs1_blocks i_din.ffs1_din->di_blocks
|
||||
#define i_ffs1_ctime i_din.ffs1_din->di_ctime
|
||||
#define i_ffs1_ctimensec i_din.ffs1_din->di_ctimensec
|
||||
#define i_ffs1_db i_din.ffs1_din->di_db
|
||||
#define i_ffs1_flags i_din.ffs1_din->di_flags
|
||||
#define i_ffs1_gen i_din.ffs1_din->di_gen
|
||||
#define i_ffs1_gid i_din.ffs1_din->di_gid
|
||||
#define i_ffs1_ib i_din.ffs1_din->di_ib
|
||||
#define i_ffs1_mode i_din.ffs1_din->di_mode
|
||||
#define i_ffs1_mtime i_din.ffs1_din->di_mtime
|
||||
#define i_ffs1_mtimensec i_din.ffs1_din->di_mtimensec
|
||||
#define i_ffs1_nlink i_din.ffs1_din->di_nlink
|
||||
#define i_ffs1_rdev i_din.ffs1_din->di_rdev
|
||||
#define i_ffs1_size i_din.ffs1_din->di_size
|
||||
#define i_ffs1_uid i_din.ffs1_din->di_uid
|
||||
#define i_ffs1_ouid i_din.ffs1_din->di_u.oldids[0]
|
||||
#define i_ffs1_ogid i_din.ffs1_din->di_u.oldids[1]
|
||||
|
||||
#define i_ffs2_atime i_din.ffs2_din->di_atime
|
||||
#define i_ffs2_atimensec i_din.ffs2_din->di_atimensec
|
||||
#define i_ffs2_birthtime i_din.ffs2_din->di_birthtime
|
||||
#define i_ffs2_birthnsec i_din.ffs2_din->di_birthnsec
|
||||
#define i_ffs2_blocks i_din.ffs2_din->di_blocks
|
||||
#define i_ffs2_blksize i_din.ffs2_din->di_blksize
|
||||
#define i_ffs2_ctime i_din.ffs2_din->di_ctime
|
||||
#define i_ffs2_ctimensec i_din.ffs2_din->di_ctimensec
|
||||
#define i_ffs2_db i_din.ffs2_din->di_db
|
||||
#define i_ffs2_flags i_din.ffs2_din->di_flags
|
||||
#define i_ffs2_gen i_din.ffs2_din->di_gen
|
||||
#define i_ffs2_gid i_din.ffs2_din->di_gid
|
||||
#define i_ffs2_ib i_din.ffs2_din->di_ib
|
||||
#define i_ffs2_mode i_din.ffs2_din->di_mode
|
||||
#define i_ffs2_mtime i_din.ffs2_din->di_mtime
|
||||
#define i_ffs2_mtimensec i_din.ffs2_din->di_mtimensec
|
||||
#define i_ffs2_nlink i_din.ffs2_din->di_nlink
|
||||
#define i_ffs2_rdev i_din.ffs2_din->di_rdev
|
||||
#define i_ffs2_size i_din.ffs2_din->di_size
|
||||
#define i_ffs2_uid i_din.ffs2_din->di_uid
|
||||
#define i_ffs2_kernflags i_din.ffs2_din->di_kernflags
|
||||
#define i_ffs2_extsize i_din.ffs2_din->di_extsize
|
||||
#define i_ffs2_extb i_din.ffs2_din->di_extb
|
||||
|
||||
#define i_e2fs_mode i_din.e2fs_din->e2di_mode
|
||||
#define i_e2fs_uid i_din.e2fs_din->e2di_uid
|
||||
#define i_e2fs_size i_din.e2fs_din->e2di_size
|
||||
#define i_e2fs_atime i_din.e2fs_din->e2di_atime
|
||||
#define i_e2fs_ctime i_din.e2fs_din->e2di_ctime
|
||||
#define i_e2fs_mtime i_din.e2fs_din->e2di_mtime
|
||||
#define i_e2fs_dtime i_din.e2fs_din->e2di_dtime
|
||||
#define i_e2fs_gid i_din.e2fs_din->e2di_gid
|
||||
#define i_e2fs_nlink i_din.e2fs_din->e2di_nlink
|
||||
#define i_e2fs_nblock i_din.e2fs_din->e2di_nblock
|
||||
#define i_e2fs_flags i_din.e2fs_din->e2di_flags
|
||||
#define i_e2fs_blocks i_din.e2fs_din->e2di_blocks
|
||||
#define i_e2fs_gen i_din.e2fs_din->e2di_gen
|
||||
#define i_e2fs_facl i_din.e2fs_din->e2di_facl
|
||||
#define i_e2fs_dacl i_din.e2fs_din->e2di_dacl
|
||||
#define i_e2fs_faddr i_din.e2fs_din->e2di_faddr
|
||||
#define i_e2fs_nfrag i_din.e2fs_din->e2di_nfrag
|
||||
#define i_e2fs_fsize i_din.e2fs_din->e2di_fsize
|
||||
#define i_e2fs_rdev i_din.e2fs_din->e2di_rdev
|
||||
#define i_e2fs_uid_high i_din.e2fs_din->e2di_uid_high
|
||||
#define i_e2fs_gid_high i_din.e2fs_din->e2di_gid_high
|
||||
|
||||
/* These flags are kept in i_flag. */
|
||||
#define IN_ACCESS 0x0001 /* Access time update request. */
|
||||
#define IN_CHANGE 0x0002 /* Inode change time update request. */
|
||||
#define IN_UPDATE 0x0004 /* Inode was written to; update mtime. */
|
||||
#define IN_MODIFY 0x2000 /* Modification time update request. */
|
||||
#define IN_MODIFIED 0x0008 /* Inode has been modified. */
|
||||
#define IN_ACCESSED 0x0010 /* Inode has been accessed. */
|
||||
#define IN_RENAME 0x0020 /* Inode is being renamed. */
|
||||
#define IN_SHLOCK 0x0040 /* File has shared lock. */
|
||||
#define IN_EXLOCK 0x0080 /* File has exclusive lock. */
|
||||
#define IN_CLEANING 0x0100 /* LFS: file is being cleaned */
|
||||
#define IN_ADIROP 0x0200 /* LFS: dirop in progress */
|
||||
#define IN_SPACECOUNTED 0x0400 /* Blocks to be freed in free count. */
|
||||
#define IN_PAGING 0x1000 /* LFS: file is on paging queue */
|
||||
|
||||
#if defined(_KERNEL)
|
||||
|
||||
/*
|
||||
* The DIP macro is used to access fields in the dinode that are
|
||||
* not cached in the inode itself.
|
||||
*/
|
||||
#define DIP(ip, field) \
|
||||
(((ip)->i_ump->um_fstype == UFS1) ? \
|
||||
(ip)->i_ffs1_##field : (ip)->i_ffs2_##field)
|
||||
|
||||
#define DIP_ASSIGN(ip, field, value) \
|
||||
do { \
|
||||
if ((ip)->i_ump->um_fstype == UFS1) \
|
||||
(ip)->i_ffs1_##field = (value); \
|
||||
else \
|
||||
(ip)->i_ffs2_##field = (value); \
|
||||
} while(0)
|
||||
|
||||
#define DIP_ADD(ip, field, value) \
|
||||
do { \
|
||||
if ((ip)->i_ump->um_fstype == UFS1) \
|
||||
(ip)->i_ffs1_##field += (value); \
|
||||
else \
|
||||
(ip)->i_ffs2_##field += (value); \
|
||||
} while(0)
|
||||
|
||||
#define SHORTLINK(ip) \
|
||||
(((ip)->i_ump->um_fstype == UFS1) ? \
|
||||
(void *)(ip)->i_ffs1_db : (void *)(ip)->i_ffs2_db)
|
||||
|
||||
|
||||
/*
|
||||
* Structure used to pass around logical block paths generated by
|
||||
* ufs_getlbns and used by truncate and bmap code.
|
||||
*/
|
||||
struct indir {
|
||||
daddr_t in_lbn; /* Logical block number. */
|
||||
int in_off; /* Offset in buffer. */
|
||||
int in_exists; /* Flag if the block exists. */
|
||||
};
|
||||
|
||||
/* Convert between inode pointers and vnode pointers. */
|
||||
#define VTOI(vp) ((struct inode *)(vp)->v_data)
|
||||
#define ITOV(ip) ((ip)->i_vnode)
|
||||
|
||||
/* This overlays the fid structure (see fstypes.h). */
|
||||
struct ufid {
|
||||
u_int16_t ufid_len; /* Length of structure. */
|
||||
u_int16_t ufid_pad; /* Force 32-bit alignment. */
|
||||
u_int32_t ufid_ino; /* File number (ino). */
|
||||
int32_t ufid_gen; /* Generation number. */
|
||||
};
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* !_UFS_UFS_INODE_H_ */
|
||||
@@ -1,97 +0,0 @@
|
||||
/* $NetBSD: quota.h,v 1.28 2011/03/25 10:25:17 bouyer Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Robert Elz at The University of Melbourne.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @(#)quota.h 8.3 (Berkeley) 8/19/94
|
||||
*/
|
||||
|
||||
#ifndef _UFS_UFS_QUOTA_H_
|
||||
#define _UFS_UFS_QUOTA_H_
|
||||
|
||||
/*
|
||||
* These definitions are common to the original disk quota implementation
|
||||
* (quota1) and the newer implementation (quota2)
|
||||
*/
|
||||
|
||||
/*
|
||||
* The following constants define the usage of the quota file array in the
|
||||
* ufsmount structure and dquot array in the inode structure. The semantics
|
||||
* of the elements of these arrays are defined in the routine getinoquota;
|
||||
* the remainder of the quota code treats them generically and need not be
|
||||
* inspected when changing the size of the array.
|
||||
*/
|
||||
#define MAXQUOTAS 2
|
||||
#define USRQUOTA 0 /* element used for user quotas */
|
||||
#define GRPQUOTA 1 /* element used for group quotas */
|
||||
|
||||
|
||||
#if !defined(HAVE_NBTOOL_CONFIG_H)
|
||||
#include <quota/quotaprop.h>
|
||||
__inline static int __unused
|
||||
ufsclass2qtype(int class)
|
||||
{
|
||||
switch(class) {
|
||||
case QUOTA_CLASS_USER:
|
||||
return USRQUOTA;
|
||||
case QUOTA_CLASS_GROUP:
|
||||
return GRPQUOTA;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static __inline int __unused
|
||||
qtype2ufsclass(int type)
|
||||
{
|
||||
switch(type) {
|
||||
case USRQUOTA:
|
||||
return QUOTA_CLASS_USER;
|
||||
case GRPQUOTA:
|
||||
return QUOTA_CLASS_GROUP;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
#endif /* !defined(HAVE_NBTOOL_CONFIG_H) */
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
void dqinit(void);
|
||||
void dqreinit(void);
|
||||
void dqdone(void);
|
||||
__END_DECLS
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* !_UFS_UFS_QUOTA_H_ */
|
||||
@@ -1,111 +0,0 @@
|
||||
/* $NetBSD: quota1.h,v 1.5 2011/11/25 16:55:05 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Robert Elz at The University of Melbourne.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @(#)quota.h 8.3 (Berkeley) 8/19/94
|
||||
*/
|
||||
|
||||
#ifndef _UFS_UFS_QUOTA1_H_
|
||||
#define _UFS_UFS_QUOTA1_H_
|
||||
|
||||
#include <sys/quota.h>
|
||||
#include <ufs/ufs/quota.h>
|
||||
|
||||
/*
|
||||
* These definitions are for the original disk quota implementation, which
|
||||
* is deprecated. the newer implementation is defined in quota2.h
|
||||
* and friends
|
||||
*/
|
||||
|
||||
/*
|
||||
* Definitions for the default names of the quotas files/quota types.
|
||||
*/
|
||||
#define INITQFNAMES { \
|
||||
"user", /* USRQUOTA */ \
|
||||
"group", /* GRPQUOTA */ \
|
||||
}
|
||||
|
||||
/*
|
||||
* Definitions for disk quotas imposed on the average user
|
||||
* (big brother finally hits UNIX).
|
||||
*
|
||||
* The following constants define the amount of time given a user before the
|
||||
* soft limits are treated as hard limits (usually resulting in an allocation
|
||||
* failure). The timer is started when the user crosses their soft limit, it
|
||||
* is reset when they go below their soft limit.
|
||||
*/
|
||||
#define MAX_IQ_TIME (7*24*60*60) /* seconds in 1 week */
|
||||
#define MAX_DQ_TIME (7*24*60*60) /* seconds in 1 week */
|
||||
|
||||
#define QUOTAFILENAME "quota"
|
||||
#define QUOTAGROUP "operator"
|
||||
|
||||
/*
|
||||
* Command definitions for the 'compat_50_quotactl' system call. The commands
|
||||
* are broken into a main command defined below and a subcommand that is used
|
||||
* to convey the type of quota that is being manipulated (see above).
|
||||
*/
|
||||
#define SUBCMDMASK 0x00ff
|
||||
#define SUBCMDSHIFT 8
|
||||
#define QCMD(cmd, type) (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK))
|
||||
|
||||
#define Q_QUOTAON 0x0100 /* enable quotas */
|
||||
#define Q_QUOTAOFF 0x0200 /* disable quotas */
|
||||
#define Q_GETQUOTA 0x0300 /* get limits and usage */
|
||||
#define Q_SETQUOTA 0x0400 /* set limits and usage */
|
||||
#define Q_SETUSE 0x0500 /* set usage */
|
||||
#define Q_SYNC 0x0600 /* sync disk copy of a filesystems quotas */
|
||||
|
||||
/*
|
||||
* The following structure defines the format of the disk quota file
|
||||
* (as it appears on disk) - the file is an array of these structures
|
||||
* indexed by user or group number. The setquota system call establishes
|
||||
* the vnode for each quota file (a pointer is retained in the ufsmount
|
||||
* structure).
|
||||
*/
|
||||
struct dqblk {
|
||||
u_int32_t dqb_bhardlimit; /* absolute limit on disk blks alloc */
|
||||
u_int32_t dqb_bsoftlimit; /* preferred limit on disk blks */
|
||||
u_int32_t dqb_curblocks; /* current block count */
|
||||
u_int32_t dqb_ihardlimit; /* maximum # allocated inodes + 1 */
|
||||
u_int32_t dqb_isoftlimit; /* preferred inode limit */
|
||||
u_int32_t dqb_curinodes; /* current # allocated inodes */
|
||||
int32_t dqb_btime; /* time limit for excessive disk use */
|
||||
int32_t dqb_itime; /* time limit for excessive files */
|
||||
};
|
||||
|
||||
/* quota1_subr.c */
|
||||
struct quota2_entry;
|
||||
void dqblk_to_quotaval(const struct dqblk *, struct quotaval *);
|
||||
void quotaval_to_dqblk(const struct quotaval *, struct dqblk *);
|
||||
|
||||
#endif /* !_UFS_UFS_QUOTA1_H_ */
|
||||
@@ -1,131 +0,0 @@
|
||||
/* $NetBSD: quota2.h,v 1.5 2011/06/07 14:56:13 bouyer Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2010 Manuel Bouyer
|
||||
* 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 _UFS_UFS_QUOTA2_H_
|
||||
#define _UFS_UFS_QUOTA2_H_
|
||||
#include <ufs/ufs/quota.h>
|
||||
#include <quota/quota.h>
|
||||
|
||||
|
||||
/* New disk quota implementation. In this implementation, the quota datas
|
||||
* (default values, user limits and current usage) are part of the filesystem
|
||||
* metadata. On FFS, this will be in a hidden, unlinked inode. fsck_ffs is
|
||||
* responsible for checking quotas with the rest of the filesystem integrity,
|
||||
* and quotas metadata are also covered by the filesystem journal if any.
|
||||
* quota enable/disable is done on a filesystem basis via flags in the
|
||||
* superblock
|
||||
*/
|
||||
|
||||
/*
|
||||
* The quota file is comprised of 2 parts, the header and the entries.
|
||||
* The header contains global informations, and head of list of quota entries.
|
||||
* A quota entry can either be in the free list, or one of the hash lists.
|
||||
*/
|
||||
|
||||
/* description of a block or inode quota */
|
||||
struct quota2_val {
|
||||
uint64_t q2v_hardlimit; /* absolute limit */
|
||||
uint64_t q2v_softlimit; /* overflowable limit */
|
||||
uint64_t q2v_cur; /* current usage */
|
||||
int64_t q2v_time; /* grace expiration date for softlimit overflow */
|
||||
int64_t q2v_grace; /* allowed time for softlimit overflow */
|
||||
};
|
||||
|
||||
/* NAMES for the above in the plist */
|
||||
#define INITQVNAMES_ALL { \
|
||||
QUOTADICT_LIMIT_HARD, \
|
||||
QUOTADICT_LIMIT_SOFT, \
|
||||
QUOTADICT_LIMIT_USAGE, \
|
||||
QUOTADICT_LIMIT_ETIME, \
|
||||
QUOTADICT_LIMIT_GTIME \
|
||||
}
|
||||
#define INITQVNAMES_LIMITSONLY { \
|
||||
QUOTADICT_LIMIT_HARD, \
|
||||
QUOTADICT_LIMIT_SOFT, \
|
||||
NULL, \
|
||||
NULL, \
|
||||
QUOTADICT_LIMIT_GTIME \
|
||||
}
|
||||
|
||||
#define N_QV 5
|
||||
/*
|
||||
* On-disk description of a user or group quota
|
||||
* These entries are keept as linked list, either in one of the hash HEAD,
|
||||
* or in the free list.
|
||||
*/
|
||||
|
||||
#define N_QL 2
|
||||
#define QL_BLOCK 0
|
||||
#define QL_FILE 1
|
||||
#define INITQLNAMES {QUOTADICT_LTYPE_BLOCK, QUOTADICT_LTYPE_FILE}
|
||||
|
||||
struct quota2_entry {
|
||||
/* block & inode limits and status */
|
||||
struct quota2_val q2e_val[N_QL];
|
||||
/* pointer to next entry for this list (offset in the file) */
|
||||
uint64_t q2e_next;
|
||||
/* ownership information */
|
||||
uint32_t q2e_uid;
|
||||
uint32_t q2e_pad;
|
||||
};
|
||||
|
||||
/* header present at the start of the quota file */
|
||||
struct quota2_header {
|
||||
uint32_t q2h_magic_number;
|
||||
uint8_t q2h_type; /* quota type, see below */
|
||||
uint8_t q2h_hash_shift; /* bytes used for hash index */
|
||||
uint16_t q2h_hash_size; /* size of hash table */
|
||||
/* default values applied to new entries */
|
||||
struct quota2_entry q2h_defentry;
|
||||
/* head of free quota2_entry list */
|
||||
uint64_t q2h_free;
|
||||
/* variable-sized hash table */
|
||||
uint64_t q2h_entries[0];
|
||||
};
|
||||
|
||||
#define Q2_HEAD_MAGIC 0xb746915e
|
||||
|
||||
/* superblock flags */
|
||||
#define FS_Q2_DO_TYPE(type) (0x01 << (type))
|
||||
|
||||
#define off2qindex(hsize, off) (((off) - (hsize)) / sizeof(struct quota2_entry))
|
||||
#define qindex2off(hsize, idx) \
|
||||
((daddr_t)(idx) * sizeof(struct quota2_entry) + (hsize))
|
||||
|
||||
/* quota2_subr.c */
|
||||
void quota2_addfreeq2e(struct quota2_header *, void *, uint64_t, uint64_t, int);
|
||||
void quota2_create_blk0(uint64_t, void *bp, int, int, int);
|
||||
void quota2_ufs_rwq2v(const struct quota2_val *, struct quota2_val *, int);
|
||||
void quota2_ufs_rwq2e(const struct quota2_entry *, struct quota2_entry *, int);
|
||||
|
||||
__inline static int __unused
|
||||
quota2_check_limit(struct quota2_val *q2v, uint64_t change, time_t now)
|
||||
{
|
||||
return quota_check_limit(q2v->q2v_cur, change, q2v->q2v_softlimit,
|
||||
q2v->q2v_hardlimit, q2v->q2v_time, now);
|
||||
}
|
||||
#endif /* _UFS_UFS_QUOTA2_H_ */
|
||||
@@ -1,80 +0,0 @@
|
||||
/* $NetBSD: ufs_bswap.h,v 1.19 2009/10/19 18:41:17 bouyer Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998 Manuel Bouyer.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _UFS_UFS_BSWAP_H_
|
||||
#define _UFS_UFS_BSWAP_H_
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_ffs.h"
|
||||
#endif
|
||||
|
||||
#include <sys/bswap.h>
|
||||
|
||||
/* Macros to access UFS flags */
|
||||
#ifdef FFS_EI
|
||||
#define UFS_MPNEEDSWAP(ump) ((ump)->um_flags & UFS_NEEDSWAP)
|
||||
#define UFS_FSNEEDSWAP(fs) ((fs)->fs_flags & FS_SWAPPED)
|
||||
#define UFS_IPNEEDSWAP(ip) UFS_MPNEEDSWAP((ip)->i_ump)
|
||||
#else
|
||||
#define UFS_MPNEEDSWAP(ump) (0)
|
||||
#define UFS_FSNEEDSWAP(fs) (0)
|
||||
#define UFS_IPNEEDSWAP(ip) (0)
|
||||
#endif
|
||||
|
||||
#if !defined(_KERNEL) || defined(FFS_EI)
|
||||
/* inlines for access to swapped data */
|
||||
static inline u_int16_t
|
||||
ufs_rw16(uint16_t a, int ns)
|
||||
{
|
||||
return ((ns) ? bswap16(a) : (a));
|
||||
}
|
||||
|
||||
static inline u_int32_t
|
||||
ufs_rw32(uint32_t a, int ns)
|
||||
{
|
||||
return ((ns) ? bswap32(a) : (a));
|
||||
}
|
||||
|
||||
static inline u_int64_t
|
||||
ufs_rw64(uint64_t a, int ns)
|
||||
{
|
||||
return ((ns) ? bswap64(a) : (a));
|
||||
}
|
||||
#else
|
||||
#define ufs_rw16(a, ns) ((uint16_t)(a))
|
||||
#define ufs_rw32(a, ns) ((uint32_t)(a))
|
||||
#define ufs_rw64(a, ns) ((uint64_t)(a))
|
||||
#endif
|
||||
|
||||
#define ufs_add16(a, b, ns) \
|
||||
(a) = ufs_rw16(ufs_rw16((a), (ns)) + (b), (ns))
|
||||
#define ufs_add32(a, b, ns) \
|
||||
(a) = ufs_rw32(ufs_rw32((a), (ns)) + (b), (ns))
|
||||
#define ufs_add64(a, b, ns) \
|
||||
(a) = ufs_rw64(ufs_rw64((a), (ns)) + (b), (ns))
|
||||
|
||||
#endif /* !_UFS_UFS_BSWAP_H_ */
|
||||
@@ -1,188 +0,0 @@
|
||||
/* $NetBSD: ufs_extern.h,v 1.66 2011/07/17 22:07:59 dholland Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 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.
|
||||
*
|
||||
* @(#)ufs_extern.h 8.10 (Berkeley) 5/14/95
|
||||
*/
|
||||
|
||||
#ifndef _UFS_UFS_EXTERN_H_
|
||||
#define _UFS_UFS_EXTERN_H_
|
||||
|
||||
#include <sys/mutex.h>
|
||||
|
||||
struct buf;
|
||||
struct componentname;
|
||||
struct direct;
|
||||
struct disklabel;
|
||||
struct dquot;
|
||||
struct fid;
|
||||
struct flock;
|
||||
struct indir;
|
||||
struct inode;
|
||||
struct mbuf;
|
||||
struct mount;
|
||||
struct nameidata;
|
||||
struct lwp;
|
||||
struct ufid;
|
||||
struct ufs_args;
|
||||
struct ufs_lookup_results;
|
||||
struct ufsmount;
|
||||
struct uio;
|
||||
struct vattr;
|
||||
struct vnode;
|
||||
|
||||
extern pool_cache_t ufs_direct_cache; /* memory pool for directs */
|
||||
|
||||
__BEGIN_DECLS
|
||||
#define ufs_abortop genfs_abortop
|
||||
int ufs_access(void *);
|
||||
int ufs_advlock(void *);
|
||||
int ufs_bmap(void *);
|
||||
int ufs_close(void *);
|
||||
int ufs_create(void *);
|
||||
int ufs_getattr(void *);
|
||||
int ufs_inactive(void *);
|
||||
#define ufs_fcntl genfs_fcntl
|
||||
#define ufs_ioctl genfs_enoioctl
|
||||
#define ufs_islocked genfs_islocked
|
||||
int ufs_link(void *);
|
||||
#define ufs_lock genfs_lock
|
||||
int ufs_lookup(void *);
|
||||
int ufs_mkdir(void *);
|
||||
int ufs_mknod(void *);
|
||||
#define ufs_mmap genfs_mmap
|
||||
#define ufs_revoke genfs_revoke
|
||||
int ufs_open(void *);
|
||||
int ufs_pathconf(void *);
|
||||
int ufs_print(void *);
|
||||
int ufs_readdir(void *);
|
||||
int ufs_readlink(void *);
|
||||
int ufs_remove(void *);
|
||||
int ufs_rename(void *);
|
||||
int ufs_rmdir(void *);
|
||||
#define ufs_seek genfs_seek
|
||||
#define ufs_poll genfs_poll
|
||||
int ufs_setattr(void *);
|
||||
int ufs_strategy(void *);
|
||||
int ufs_symlink(void *);
|
||||
#define ufs_unlock genfs_unlock
|
||||
int ufs_whiteout(void *);
|
||||
int ufsspec_close(void *);
|
||||
int ufsspec_read(void *);
|
||||
int ufsspec_write(void *);
|
||||
|
||||
int ufsfifo_read(void *);
|
||||
int ufsfifo_write(void *);
|
||||
int ufsfifo_close(void *);
|
||||
|
||||
/* ufs_bmap.c */
|
||||
typedef bool (*ufs_issequential_callback_t)(const struct ufsmount *,
|
||||
daddr_t, daddr_t);
|
||||
int ufs_bmaparray(struct vnode *, daddr_t, daddr_t *, struct indir *,
|
||||
int *, int *, ufs_issequential_callback_t);
|
||||
int ufs_getlbns(struct vnode *, daddr_t, struct indir *, int *);
|
||||
|
||||
/* ufs_ihash.c */
|
||||
void ufs_ihashinit(void);
|
||||
void ufs_ihashreinit(void);
|
||||
void ufs_ihashdone(void);
|
||||
struct vnode *ufs_ihashlookup(dev_t, ino_t);
|
||||
struct vnode *ufs_ihashget(dev_t, ino_t, int);
|
||||
void ufs_ihashins(struct inode *);
|
||||
void ufs_ihashrem(struct inode *);
|
||||
|
||||
/* ufs_inode.c */
|
||||
int ufs_reclaim(struct vnode *);
|
||||
int ufs_balloc_range(struct vnode *, off_t, off_t, kauth_cred_t, int);
|
||||
|
||||
/* ufs_lookup.c */
|
||||
void ufs_dirbad(struct inode *, doff_t, const char *);
|
||||
int ufs_dirbadentry(struct vnode *, struct direct *, int);
|
||||
void ufs_makedirentry(struct inode *, struct componentname *,
|
||||
struct direct *);
|
||||
int ufs_direnter(struct vnode *, const struct ufs_lookup_results *,
|
||||
struct vnode *, struct direct *,
|
||||
struct componentname *, struct buf *);
|
||||
int ufs_dirremove(struct vnode *, const struct ufs_lookup_results *,
|
||||
struct inode *, int, int);
|
||||
int ufs_dirrewrite(struct inode *, off_t,
|
||||
struct inode *, ino_t, int, int, int);
|
||||
int ufs_dirempty(struct inode *, ino_t, kauth_cred_t);
|
||||
int ufs_checkpath(struct inode *, struct inode *, kauth_cred_t);
|
||||
int ufs_parentcheck(struct vnode *, struct vnode *, kauth_cred_t,
|
||||
int *, struct vnode **);
|
||||
int ufs_blkatoff(struct vnode *, off_t, char **, struct buf **, bool);
|
||||
|
||||
/* ufs_quota.c */
|
||||
/*
|
||||
* Flags to chkdq() and chkiq()
|
||||
*/
|
||||
#define FORCE 0x01 /* force usage changes independent of limits */
|
||||
void ufsquota_init(struct inode *);
|
||||
void ufsquota_free(struct inode *);
|
||||
int chkdq(struct inode *, int64_t, kauth_cred_t, int);
|
||||
int chkiq(struct inode *, int32_t, kauth_cred_t, int);
|
||||
int quota_handle_cmd(struct mount *, struct lwp *, prop_dictionary_t);
|
||||
int qsync(struct mount *);
|
||||
|
||||
/* ufs_quota1.c */
|
||||
int quota1_umount(struct mount *, int);
|
||||
|
||||
/* ufs_quota2.c */
|
||||
int quota2_umount(struct mount *, int);
|
||||
|
||||
/* ufs_vfsops.c */
|
||||
void ufs_init(void);
|
||||
void ufs_reinit(void);
|
||||
void ufs_done(void);
|
||||
int ufs_start(struct mount *, int);
|
||||
int ufs_root(struct mount *, struct vnode **);
|
||||
int ufs_quotactl(struct mount *, prop_dictionary_t);
|
||||
int ufs_fhtovp(struct mount *, struct ufid *, struct vnode **);
|
||||
|
||||
/* ufs_vnops.c */
|
||||
void ufs_vinit(struct mount *, int (**)(void *),
|
||||
int (**)(void *), struct vnode **);
|
||||
int ufs_makeinode(int, struct vnode *, const struct ufs_lookup_results *,
|
||||
struct vnode **, struct componentname *);
|
||||
int ufs_gop_alloc(struct vnode *, off_t, off_t, int, kauth_cred_t);
|
||||
void ufs_gop_markupdate(struct vnode *, int);
|
||||
|
||||
/*
|
||||
* Snapshot function prototypes.
|
||||
*/
|
||||
|
||||
void ffs_snapgone(struct inode *);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
extern kmutex_t ufs_ihash_lock;
|
||||
extern kmutex_t ufs_hashlock;
|
||||
|
||||
#endif /* !_UFS_UFS_EXTERN_H_ */
|
||||
@@ -1,130 +0,0 @@
|
||||
/* $NetBSD: ufs_quota.h,v 1.2 2011/03/06 17:08:39 bouyer Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1990, 1993, 1995
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Robert Elz at The University of Melbourne.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @(#)ufs_quota.c 8.5 (Berkeley) 5/20/95
|
||||
*/
|
||||
#include <ufs/ufs/quota1.h>
|
||||
#include <ufs/ufs/quota2.h>
|
||||
|
||||
/* link to this quota in the quota inode (for QUOTA2) */
|
||||
struct dq2_desc {
|
||||
uint64_t dq2_lblkno; /* logical disk block holding this quota */
|
||||
u_int dq2_blkoff; /* offset in disk block holding this quota */
|
||||
};
|
||||
|
||||
/*
|
||||
* The following structure records disk usage for a user or group on a
|
||||
* filesystem. There is one allocated for each quota that exists on any
|
||||
* filesystem for the current user or group. A cache is kept of recently
|
||||
* used entries.
|
||||
* Field markings and the corresponding locks:
|
||||
* h: dqlock
|
||||
* d: dq_interlock
|
||||
*
|
||||
* Lock order is: dq_interlock -> dqlock
|
||||
* dq_interlock -> dqvp
|
||||
*/
|
||||
struct dquot {
|
||||
LIST_ENTRY(dquot) dq_hash; /* h: hash list */
|
||||
u_int16_t dq_flags; /* d: flags, see below */
|
||||
u_int16_t dq_type; /* d: quota type of this dquot */
|
||||
u_int32_t dq_cnt; /* h: count of active references */
|
||||
u_int32_t dq_id; /* d: identifier this applies to */
|
||||
struct ufsmount *dq_ump; /* d: filesystem this is taken from */
|
||||
kmutex_t dq_interlock; /* d: lock this dquot */
|
||||
union {
|
||||
struct dqblk dq1_dqb; /* d: actual usage & quotas */
|
||||
struct dq2_desc dq2_desc; /* d: pointer to quota data */
|
||||
} dq_un;
|
||||
};
|
||||
|
||||
/*
|
||||
* Flag values.
|
||||
*/
|
||||
#define DQ_MOD 0x04 /* this quota modified since read */
|
||||
#define DQ_FAKE 0x08 /* no limits here, just usage */
|
||||
#define DQ_WARN(ltype) (0x10 << ltype) /* has been warned about "type" limit */
|
||||
/*
|
||||
* Shorthand notation.
|
||||
*/
|
||||
#define dq_bhardlimit dq_un.dq1_dqb.dqb_bhardlimit
|
||||
#define dq_bsoftlimit dq_un.dq1_dqb.dqb_bsoftlimit
|
||||
#define dq_curblocks dq_un.dq1_dqb.dqb_curblocks
|
||||
#define dq_ihardlimit dq_un.dq1_dqb.dqb_ihardlimit
|
||||
#define dq_isoftlimit dq_un.dq1_dqb.dqb_isoftlimit
|
||||
#define dq_curinodes dq_un.dq1_dqb.dqb_curinodes
|
||||
#define dq_btime dq_un.dq1_dqb.dqb_btime
|
||||
#define dq_itime dq_un.dq1_dqb.dqb_itime
|
||||
|
||||
#define dq2_lblkno dq_un.dq2_desc.dq2_lblkno
|
||||
#define dq2_blkoff dq_un.dq2_desc.dq2_blkoff
|
||||
/*
|
||||
* If the system has never checked for a quota for this file, then it is
|
||||
* set to NODQUOT. Once a write attempt is made the inode pointer is set
|
||||
* to reference a dquot structure.
|
||||
*/
|
||||
#define NODQUOT NULL
|
||||
|
||||
extern kmutex_t dqlock;
|
||||
extern kcondvar_t dqcv;
|
||||
/*
|
||||
* Quota name to error message mapping.
|
||||
*/
|
||||
const char *quotatypes[MAXQUOTAS];
|
||||
|
||||
int getinoquota(struct inode *);
|
||||
int dqget(struct vnode *, u_long, struct ufsmount *, int, struct dquot **);
|
||||
void dqref(struct dquot *);
|
||||
void dqrele(struct vnode *, struct dquot *);
|
||||
void dqflush(struct vnode *);
|
||||
|
||||
int chkdq1(struct inode *, int64_t, kauth_cred_t, int);
|
||||
int chkiq1(struct inode *, int32_t, kauth_cred_t, int);
|
||||
int q1sync(struct mount *);
|
||||
int dq1get(struct vnode *, u_long, struct ufsmount *, int, struct dquot *);
|
||||
int dq1sync(struct vnode *, struct dquot *);
|
||||
int quota1_handle_cmd_get(struct ufsmount *, int, int, int, prop_array_t);
|
||||
int quota1_handle_cmd_set(struct ufsmount *, int, int, int, prop_dictionary_t);
|
||||
int quota1_handle_cmd_quotaon(struct lwp *, struct ufsmount *, int,
|
||||
const char *);
|
||||
int quota1_handle_cmd_quotaoff(struct lwp *, struct ufsmount *, int);
|
||||
|
||||
int chkdq2(struct inode *, int64_t, kauth_cred_t, int);
|
||||
int chkiq2(struct inode *, int32_t, kauth_cred_t, int);
|
||||
int quota2_handle_cmd_get(struct ufsmount *, int, int, int, prop_array_t);
|
||||
int quota2_handle_cmd_set(struct ufsmount *, int, int, int, prop_dictionary_t);
|
||||
int quota2_handle_cmd_clear(struct ufsmount *, int, int, int, prop_dictionary_t);
|
||||
int quota2_handle_cmd_getall(struct ufsmount *, int, prop_array_t);
|
||||
int q2sync(struct mount *);
|
||||
int dq2get(struct vnode *, u_long, struct ufsmount *, int, struct dquot *);
|
||||
int dq2sync(struct vnode *, struct dquot *);
|
||||
@@ -1,178 +0,0 @@
|
||||
/* $NetBSD: ufs_wapbl.h,v 1.7 2011/09/19 11:18:01 gdt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003,2006,2008 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Wasabi Systems, 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.
|
||||
*
|
||||
* 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 _UFS_UFS_UFS_WAPBL_H_
|
||||
#define _UFS_UFS_UFS_WAPBL_H_
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_wapbl.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Information for the journal location stored in the superblock.
|
||||
* We store the journal version, some flags, the journal location
|
||||
* type, and some location specific "locators" that identify where
|
||||
* the log itself is located.
|
||||
*/
|
||||
|
||||
/* fs->fs_journal_version */
|
||||
#define UFS_WAPBL_VERSION 1
|
||||
|
||||
/* fs->fs_journal_location */
|
||||
#define UFS_WAPBL_JOURNALLOC_NONE 0
|
||||
|
||||
#define UFS_WAPBL_JOURNALLOC_END_PARTITION 1
|
||||
#define UFS_WAPBL_EPART_ADDR 0 /* locator slots */
|
||||
#define UFS_WAPBL_EPART_COUNT 1
|
||||
#define UFS_WAPBL_EPART_BLKSZ 2
|
||||
#define UFS_WAPBL_EPART_UNUSED 3
|
||||
|
||||
#define UFS_WAPBL_JOURNALLOC_IN_FILESYSTEM 2
|
||||
#define UFS_WAPBL_INFS_ADDR 0 /* locator slots */
|
||||
#define UFS_WAPBL_INFS_COUNT 1
|
||||
#define UFS_WAPBL_INFS_BLKSZ 2
|
||||
#define UFS_WAPBL_INFS_INO 3
|
||||
|
||||
/* fs->fs_journal_flags */
|
||||
#define UFS_WAPBL_FLAGS_CREATE_LOG 0x1
|
||||
#define UFS_WAPBL_FLAGS_CLEAR_LOG 0x2
|
||||
|
||||
|
||||
/*
|
||||
* The journal size is limited to between 1MB and 64MB.
|
||||
* The default journal size is the filesystem size divided by
|
||||
* the scale factor - this is 1M of journal per 1GB of filesystem
|
||||
* space.
|
||||
*
|
||||
* XXX: Is 64MB too limiting? If user explicitly asks for more, allow it?
|
||||
*/
|
||||
#define UFS_WAPBL_JOURNAL_SCALE 1024
|
||||
#define UFS_WAPBL_MIN_JOURNAL_SIZE (1024 * 1024)
|
||||
#define UFS_WAPBL_MAX_JOURNAL_SIZE (64 * 1024 * 1024)
|
||||
|
||||
|
||||
#if defined(WAPBL)
|
||||
|
||||
#if defined(WAPBL_DEBUG)
|
||||
#define WAPBL_DEBUG_INODES
|
||||
#endif
|
||||
|
||||
#ifdef WAPBL_DEBUG_INODES
|
||||
#error Undefine WAPBL_DEBUG_INODES or update the code. Have a nice day.
|
||||
#endif
|
||||
|
||||
#ifdef WAPBL_DEBUG_INODES
|
||||
void ufs_wapbl_verify_inodes(struct mount *, const char *);
|
||||
#endif
|
||||
|
||||
static __inline int
|
||||
ufs_wapbl_begin2(struct mount *mp, struct vnode *vp1, struct vnode *vp2,
|
||||
const char *file, int line)
|
||||
{
|
||||
if (mp->mnt_wapbl) {
|
||||
int error;
|
||||
|
||||
if (vp1)
|
||||
vref(vp1);
|
||||
if (vp2)
|
||||
vref(vp2);
|
||||
error = wapbl_begin(mp->mnt_wapbl, file, line);
|
||||
if (error)
|
||||
return error;
|
||||
#ifdef WAPBL_DEBUG_INODES
|
||||
if (mp->mnt_wapbl->wl_lock.lk_exclusivecount == 1)
|
||||
ufs_wapbl_verify_inodes(mp, "wapbl_begin");
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static __inline void
|
||||
ufs_wapbl_end2(struct mount *mp, struct vnode *vp1, struct vnode *vp2)
|
||||
{
|
||||
if (mp->mnt_wapbl) {
|
||||
#ifdef WAPBL_DEBUG_INODES
|
||||
if (mp->mnt_wapbl->wl_lock.lk_exclusivecount == 1)
|
||||
ufs_wapbl_verify_inodes(mp, "wapbl_end");
|
||||
#endif
|
||||
wapbl_end(mp->mnt_wapbl);
|
||||
if (vp2)
|
||||
vrele(vp2);
|
||||
if (vp1)
|
||||
vrele(vp1);
|
||||
}
|
||||
}
|
||||
|
||||
#define UFS_WAPBL_BEGIN(mp) \
|
||||
ufs_wapbl_begin2(mp, NULL, NULL, __FUNCTION__, __LINE__)
|
||||
#define UFS_WAPBL_BEGIN1(mp, v1) \
|
||||
ufs_wapbl_begin2(mp, v1, NULL, __FUNCTION__, __LINE__)
|
||||
#define UFS_WAPBL_END(mp) ufs_wapbl_end2(mp, NULL, NULL)
|
||||
#define UFS_WAPBL_END1(mp, v1) ufs_wapbl_end2(mp, v1, NULL)
|
||||
|
||||
#define UFS_WAPBL_UPDATE(vp, access, modify, flags) \
|
||||
if ((vp)->v_mount->mnt_wapbl) { \
|
||||
UFS_UPDATE(vp, access, modify, flags); \
|
||||
}
|
||||
|
||||
#ifdef UFS_WAPBL_DEBUG_JLOCK
|
||||
#define UFS_WAPBL_JLOCK_ASSERT(mp) \
|
||||
if (mp->mnt_wapbl) wapbl_jlock_assert(mp->mnt_wapbl)
|
||||
#define UFS_WAPBL_JUNLOCK_ASSERT(mp) \
|
||||
if (mp->mnt_wapbl) wapbl_junlock_assert(mp->mnt_wapbl)
|
||||
#else
|
||||
#define UFS_WAPBL_JLOCK_ASSERT(mp)
|
||||
#define UFS_WAPBL_JUNLOCK_ASSERT(mp)
|
||||
#endif
|
||||
|
||||
#define UFS_WAPBL_REGISTER_INODE(mp, ino, mode) \
|
||||
if (mp->mnt_wapbl) wapbl_register_inode(mp->mnt_wapbl, ino, mode)
|
||||
#define UFS_WAPBL_UNREGISTER_INODE(mp, ino, mode) \
|
||||
if (mp->mnt_wapbl) wapbl_unregister_inode(mp->mnt_wapbl, ino, mode)
|
||||
|
||||
#define UFS_WAPBL_REGISTER_DEALLOCATION(mp, blk, len) \
|
||||
if (mp->mnt_wapbl) wapbl_register_deallocation(mp->mnt_wapbl, blk, len)
|
||||
|
||||
#else /* ! WAPBL */
|
||||
#define UFS_WAPBL_BEGIN(mp) 0
|
||||
#define UFS_WAPBL_BEGIN1(mp, v1) 0
|
||||
#define UFS_WAPBL_END(mp) do { } while (0)
|
||||
#define UFS_WAPBL_END1(mp, v1)
|
||||
#define UFS_WAPBL_UPDATE(vp, access, modify, flags) do { } while (0)
|
||||
#define UFS_WAPBL_JLOCK_ASSERT(mp)
|
||||
#define UFS_WAPBL_JUNLOCK_ASSERT(mp)
|
||||
#define UFS_WAPBL_REGISTER_INODE(mp, ino, mode) do { } while (0)
|
||||
#define UFS_WAPBL_UNREGISTER_INODE(mp, ino, mode) do { } while (0)
|
||||
#define UFS_WAPBL_REGISTER_DEALLOCATION(mp, blk, len)
|
||||
#endif
|
||||
|
||||
#endif /* !_UFS_UFS_UFS_WAPBL_H_ */
|
||||
@@ -1,197 +0,0 @@
|
||||
/* $NetBSD: ufsmount.h,v 1.37 2011/11/24 15:51:32 ahoka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)ufsmount.h 8.6 (Berkeley) 3/30/95
|
||||
*/
|
||||
|
||||
#ifndef _UFS_UFS_UFSMOUNT_H_
|
||||
#define _UFS_UFS_UFSMOUNT_H_
|
||||
|
||||
#include <sys/mount.h> /* struct export_args30 */
|
||||
|
||||
/*
|
||||
* Arguments to mount UFS-based filesystems
|
||||
*/
|
||||
struct ufs_args {
|
||||
char *fspec; /* block special device to mount */
|
||||
};
|
||||
|
||||
#ifndef __minix
|
||||
/*
|
||||
* Arguments to mount MFS
|
||||
*/
|
||||
struct mfs_args {
|
||||
char *fspec; /* name to export for statfs */
|
||||
struct export_args30 _pad1; /* compat with old userland tools */
|
||||
void * base; /* base of file system in memory */
|
||||
u_long size; /* size of file system */
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_ffs.h"
|
||||
#endif
|
||||
|
||||
#include <sys/mutex.h>
|
||||
|
||||
#include <ufs/ufs/extattr.h>
|
||||
#include <ufs/ufs/quota.h>
|
||||
|
||||
struct buf;
|
||||
struct inode;
|
||||
struct nameidata;
|
||||
struct timeval;
|
||||
struct uio;
|
||||
struct vnode;
|
||||
|
||||
/* This structure describes the UFS specific mount structure data. */
|
||||
struct ufsmount {
|
||||
struct mount *um_mountp; /* filesystem vfs structure */
|
||||
dev_t um_dev; /* device mounted */
|
||||
struct vnode *um_devvp; /* block device mounted vnode */
|
||||
u_long um_fstype;
|
||||
u_int32_t um_flags; /* UFS-specific flags - see below */
|
||||
union { /* pointer to superblock */
|
||||
struct fs *fs; /* FFS */
|
||||
struct lfs *lfs; /* LFS */
|
||||
struct m_ext2fs *e2fs; /* EXT2FS */
|
||||
struct chfs_mount *chfs; /* CHFS */
|
||||
} ufsmount_u;
|
||||
#define um_fs ufsmount_u.fs
|
||||
#define um_lfs ufsmount_u.lfs
|
||||
#define um_e2fs ufsmount_u.e2fs
|
||||
#define um_e2fsb ufsmount_u.e2fs->s_es
|
||||
#define um_chfs ufsmount_u.chfs
|
||||
|
||||
/* Extended attribute information. */
|
||||
struct ufs_extattr_per_mount um_extattr;
|
||||
|
||||
struct vnode *um_quotas[MAXQUOTAS]; /* pointer to quota files */
|
||||
kauth_cred_t um_cred[MAXQUOTAS]; /* quota file access cred */
|
||||
u_long um_nindir; /* indirect ptrs per block */
|
||||
u_long um_lognindir; /* log2 of um_nindir */
|
||||
u_long um_bptrtodb; /* indir ptr to disk block */
|
||||
u_long um_seqinc; /* inc between seq blocks */
|
||||
kmutex_t um_lock; /* lock on global data */
|
||||
union {
|
||||
struct um_q1 {
|
||||
time_t q1_btime[MAXQUOTAS]; /* block quota time limit */
|
||||
time_t q1_itime[MAXQUOTAS]; /* inode quota time limit */
|
||||
char q1_qflags[MAXQUOTAS]; /* quota specific flags */
|
||||
} um_q1;
|
||||
struct um_q2 {
|
||||
uint64_t q2_bsize; /* block size of quota file */
|
||||
uint64_t q2_bmask; /* mask for above */
|
||||
} um_q2;
|
||||
} um_q;
|
||||
#define umq1_btime um_q.um_q1.q1_btime
|
||||
#define umq1_itime um_q.um_q1.q1_itime
|
||||
#define umq1_qflags um_q.um_q1.q1_qflags
|
||||
#define umq2_bsize um_q.um_q2.q2_bsize
|
||||
#define umq2_bmask um_q.um_q2.q2_bmask
|
||||
|
||||
void *um_oldfscompat; /* save 4.2 rotbl */
|
||||
int um_maxsymlinklen;
|
||||
int um_dirblksiz;
|
||||
u_int64_t um_maxfilesize;
|
||||
void *um_snapinfo; /* snapshot private data */
|
||||
|
||||
const struct ufs_ops *um_ops;
|
||||
};
|
||||
|
||||
struct ufs_ops {
|
||||
void (*uo_itimes)(struct inode *ip, const struct timespec *,
|
||||
const struct timespec *, const struct timespec *);
|
||||
int (*uo_update)(struct vnode *, const struct timespec *,
|
||||
const struct timespec *, int);
|
||||
int (*uo_truncate)(struct vnode *, off_t, int, kauth_cred_t);
|
||||
int (*uo_valloc)(struct vnode *, int, kauth_cred_t, struct vnode **);
|
||||
int (*uo_vfree)(struct vnode *, ino_t, int);
|
||||
int (*uo_balloc)(struct vnode *, off_t, int, kauth_cred_t, int,
|
||||
struct buf **);
|
||||
void (*uo_unmark_vnode)(struct vnode *);
|
||||
};
|
||||
|
||||
#define UFS_OPS(vp) (VFSTOUFS((vp)->v_mount)->um_ops)
|
||||
|
||||
#define UFS_ITIMES(vp, acc, mod, cre) \
|
||||
(*UFS_OPS(vp)->uo_itimes)(VTOI(vp), (acc), (mod), (cre))
|
||||
#define UFS_UPDATE(vp, acc, mod, flags) \
|
||||
(*UFS_OPS(vp)->uo_update)((vp), (acc), (mod), (flags))
|
||||
#define UFS_TRUNCATE(vp, off, flags, cr) \
|
||||
(*UFS_OPS(vp)->uo_truncate)((vp), (off), (flags), (cr))
|
||||
#define UFS_VALLOC(vp, mode, cr, vpp) \
|
||||
(*UFS_OPS(vp)->uo_valloc)((vp), (mode), (cr), (vpp))
|
||||
#define UFS_VFREE(vp, ino, mode) \
|
||||
(*UFS_OPS(vp)->uo_vfree)((vp), (ino), (mode))
|
||||
#define UFS_BALLOC(vp, off, size, cr, flags, bpp) \
|
||||
(*UFS_OPS(vp)->uo_balloc)((vp), (off), (size), (cr), (flags), (bpp))
|
||||
#define UFS_UNMARK_VNODE(vp) \
|
||||
(*UFS_OPS(vp)->uo_unmark_vnode)((vp))
|
||||
|
||||
/* UFS-specific flags */
|
||||
#define UFS_NEEDSWAP 0x01 /* filesystem metadata need byte-swapping */
|
||||
#define UFS_ISAPPLEUFS 0x02 /* filesystem is Apple UFS */
|
||||
#define UFS_QUOTA 0x04 /* filesystem has QUOTA (v1) */
|
||||
#define UFS_QUOTA2 0x08 /* filesystem has QUOTA2 */
|
||||
|
||||
/*
|
||||
* Filesystem types
|
||||
*/
|
||||
#define UFS1 1
|
||||
#define UFS2 2
|
||||
|
||||
|
||||
/*
|
||||
* Flags describing the state of quotas.
|
||||
*/
|
||||
#define QTF_OPENING 0x01 /* Q_QUOTAON in progress */
|
||||
#define QTF_CLOSING 0x02 /* Q_QUOTAOFF in progress */
|
||||
|
||||
/* Convert mount ptr to ufsmount ptr. */
|
||||
#define VFSTOUFS(mp) ((struct ufsmount *)((mp)->mnt_data))
|
||||
|
||||
#ifdef APPLE_UFS
|
||||
#define UFS_MPISAPPLEUFS(ump) ((ump)->um_flags & UFS_ISAPPLEUFS)
|
||||
#else
|
||||
#define UFS_MPISAPPLEUFS(ump) (0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Macros to access file system parameters in the ufsmount structure.
|
||||
* Used by ufs_bmap.
|
||||
*/
|
||||
#define MNINDIR(ump) ((ump)->um_nindir)
|
||||
#define blkptrtodb(ump, b) ((b) << (ump)->um_bptrtodb)
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* !_UFS_UFS_UFSMOUNT_H_ */
|
||||
Reference in New Issue
Block a user