summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcvs2svn <cvs2svn@FreeBSD.org>2003-02-23 21:58:32 +0000
committercvs2svn <cvs2svn@FreeBSD.org>2003-02-23 21:58:32 +0000
commitcd63b28bfb067359ef01b892ef6eb3f10307c712 (patch)
treeb1b3a8e748fcb462bb1907e73649dbc4b9e08660
parent068bd9b1d9a59953828036e07833059abd2635c8 (diff)
Notes
-rw-r--r--sys/gnu/ext2fs/ext2_bitmap.c27
-rw-r--r--sys/gnu/ext2fs/ext2_fs.h622
-rw-r--r--sys/gnu/ext2fs/ext2_fs_i.h42
-rw-r--r--sys/gnu/ext2fs/ext2_fs_sb.h66
-rw-r--r--sys/gnu/ext2fs/ext2_linux_balloc.c756
-rw-r--r--sys/gnu/ext2fs/ext2_linux_ialloc.c569
-rw-r--r--sys/gnu/ext2fs/ext2_super.c802
-rw-r--r--sys/gnu/ext2fs/i386-bitops.h235
8 files changed, 0 insertions, 3119 deletions
diff --git a/sys/gnu/ext2fs/ext2_bitmap.c b/sys/gnu/ext2fs/ext2_bitmap.c
deleted file mode 100644
index c0ffb68cdac9..000000000000
--- a/sys/gnu/ext2fs/ext2_bitmap.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * linux/fs/ext2/bitmap.c
- *
- * Copyright (C) 1992, 1993, 1994, 1995
- * Remy Card (card@masi.ibp.fr)
- * Laboratoire MASI - Institut Blaise Pascal
- * Universite Pierre et Marie Curie (Paris VI)
- */
-
-#include <linux/fs.h>
-
-
-
-static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0};
-
-unsigned long ext2_count_free (struct buffer_head * map, unsigned int numchars)
-{
- unsigned int i;
- unsigned long sum = 0;
-
- if (!map)
- return (0);
- for (i = 0; i < numchars; i++)
- sum += nibblemap[map->b_data[i] & 0xf] +
- nibblemap[(map->b_data[i] >> 4) & 0xf];
- return (sum);
-}
diff --git a/sys/gnu/ext2fs/ext2_fs.h b/sys/gnu/ext2fs/ext2_fs.h
deleted file mode 100644
index 836038e59d6e..000000000000
--- a/sys/gnu/ext2fs/ext2_fs.h
+++ /dev/null
@@ -1,622 +0,0 @@
-/*
- * linux/include/linux/ext2_fs.h
- *
- * Copyright (C) 1992, 1993, 1994, 1995
- * Remy Card (card@masi.ibp.fr)
- * Laboratoire MASI - Institut Blaise Pascal
- * Universite Pierre et Marie Curie (Paris VI)
- *
- * from
- *
- * linux/include/linux/minix_fs.h
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- */
-
-#ifndef _LINUX_EXT2_FS_H
-#define _LINUX_EXT2_FS_H
-
-#include <linux/types.h>
-
-/*
- * The second extended filesystem constants/structures
- */
-
-/*
- * Define EXT2FS_DEBUG to produce debug messages
- */
-#undef EXT2FS_DEBUG
-
-/*
- * Define EXT2_PREALLOCATE to preallocate data blocks for expanding files
- */
-#define EXT2_PREALLOCATE
-#define EXT2_DEFAULT_PREALLOC_BLOCKS 8
-
-/*
- * The second extended file system version
- */
-#define EXT2FS_DATE "95/08/09"
-#define EXT2FS_VERSION "0.5b"
-
-/*
- * Debug code
- */
-#ifdef EXT2FS_DEBUG
-# define ext2_debug(f, a...) { \
- printk ("EXT2-fs DEBUG (%s, %d): %s:", \
- __FILE__, __LINE__, __FUNCTION__); \
- printk (f, ## a); \
- }
-#else
-# define ext2_debug(f, a...) /**/
-#endif
-
-/*
- * Special inodes numbers
- */
-#define EXT2_BAD_INO 1 /* Bad blocks inode */
-#define EXT2_ROOT_INO 2 /* Root inode */
-#define EXT2_ACL_IDX_INO 3 /* ACL inode */
-#define EXT2_ACL_DATA_INO 4 /* ACL inode */
-#define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */
-#define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */
-
-/* First non-reserved inode for old ext2 filesystems */
-#define EXT2_GOOD_OLD_FIRST_INO 11
-
-/*
- * The second extended file system magic number
- */
-#define EXT2_SUPER_MAGIC 0xEF53
-
-/*
- * Maximal count of links to a file
- */
-#define EXT2_LINK_MAX 32000
-
-/*
- * Macro-instructions used to manage several block sizes
- */
-#define EXT2_MIN_BLOCK_SIZE 1024
-#define EXT2_MAX_BLOCK_SIZE 4096
-#define EXT2_MIN_BLOCK_LOG_SIZE 10
-#ifdef __KERNEL__
-# define EXT2_BLOCK_SIZE(s) ((s)->s_blocksize)
-#else
-# define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
-#endif
-#define EXT2_ACLE_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_acl_entry))
-#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (__u32))
-#ifdef __KERNEL__
-# define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
-#else
-# define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
-#endif
-#ifdef __KERNEL__
-#define EXT2_ADDR_PER_BLOCK_BITS(s) ((s)->u.ext2_sb.s_addr_per_block_bits)
-#define EXT2_INODE_SIZE(s) ((s)->u.ext2_sb.s_inode_size)
-#define EXT2_FIRST_INO(s) ((s)->u.ext2_sb.s_first_ino)
-#else
-#define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
- EXT2_GOOD_OLD_INODE_SIZE : \
- (s)->s_inode_size)
-#define EXT2_FIRST_INO(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
- EXT2_GOOD_OLD_FIRST_INO : \
- (s)->s_first_ino)
-#endif
-
-/*
- * Macro-instructions used to manage fragments
- */
-#define EXT2_MIN_FRAG_SIZE 1024
-#define EXT2_MAX_FRAG_SIZE 4096
-#define EXT2_MIN_FRAG_LOG_SIZE 10
-#ifdef __KERNEL__
-# define EXT2_FRAG_SIZE(s) ((s)->u.ext2_sb.s_frag_size)
-# define EXT2_FRAGS_PER_BLOCK(s) ((s)->u.ext2_sb.s_frags_per_block)
-#else
-# define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size)
-# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
-#endif
-
-/*
- * ACL structures
- */
-struct ext2_acl_header /* Header of Access Control Lists */
-{
- __u32 aclh_size;
- __u32 aclh_file_count;
- __u32 aclh_acle_count;
- __u32 aclh_first_acle;
-};
-
-struct ext2_acl_entry /* Access Control List Entry */
-{
- __u32 acle_size;
- __u16 acle_perms; /* Access permissions */
- __u16 acle_type; /* Type of entry */
- __u16 acle_tag; /* User or group identity */
- __u16 acle_pad1;
- __u32 acle_next; /* Pointer on next entry for the */
- /* same inode or on next free entry */
-};
-
-/*
- * Structure of a blocks group descriptor
- */
-struct ext2_group_desc
-{
- __u32 bg_block_bitmap; /* Blocks bitmap block */
- __u32 bg_inode_bitmap; /* Inodes bitmap block */
- __u32 bg_inode_table; /* Inodes table block */
- __u16 bg_free_blocks_count; /* Free blocks count */
- __u16 bg_free_inodes_count; /* Free inodes count */
- __u16 bg_used_dirs_count; /* Directories count */
- __u16 bg_pad;
- __u32 bg_reserved[3];
-};
-
-/*
- * Macro-instructions used to manage group descriptors
- */
-#ifdef __KERNEL__
-# define EXT2_BLOCKS_PER_GROUP(s) ((s)->u.ext2_sb.s_blocks_per_group)
-# define EXT2_DESC_PER_BLOCK(s) ((s)->u.ext2_sb.s_desc_per_block)
-# define EXT2_INODES_PER_GROUP(s) ((s)->u.ext2_sb.s_inodes_per_group)
-# define EXT2_DESC_PER_BLOCK_BITS(s) ((s)->u.ext2_sb.s_desc_per_block_bits)
-#else
-# define EXT2_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group)
-# define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc))
-# define EXT2_INODES_PER_GROUP(s) ((s)->s_inodes_per_group)
-#endif
-
-/*
- * Constants relative to the data blocks
- */
-#define EXT2_NDIR_BLOCKS 12
-#define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS
-#define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1)
-#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1)
-#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1)
-
-/*
- * Inode flags
- */
-#define EXT2_SECRM_FL 0x00000001 /* Secure deletion */
-#define EXT2_UNRM_FL 0x00000002 /* Undelete */
-#define EXT2_COMPR_FL 0x00000004 /* Compress file */
-#define EXT2_SYNC_FL 0x00000008 /* Synchronous updates */
-#define EXT2_IMMUTABLE_FL 0x00000010 /* Immutable file */
-#define EXT2_APPEND_FL 0x00000020 /* writes to file may only append */
-#define EXT2_NODUMP_FL 0x00000040 /* do not dump file */
-#define EXT2_NOATIME_FL 0x00000080 /* do not update atime */
-/* Reserved for compression usage... */
-#define EXT2_DIRTY_FL 0x00000100
-#define EXT2_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */
-#define EXT2_NOCOMP_FL 0x00000400 /* Don't compress */
-#define EXT2_ECOMPR_FL 0x00000800 /* Compression error */
-/* End compression flags --- maybe not all used */
-#define EXT2_BTREE_FL 0x00001000 /* btree format dir */
-#define EXT2_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
-
-#define EXT2_FL_USER_VISIBLE 0x00001FFF /* User visible flags */
-#define EXT2_FL_USER_MODIFIABLE 0x000000FF /* User modifiable flags */
-
-/*
- * ioctl commands
- */
-#define EXT2_IOC_GETFLAGS _IOR('f', 1, long)
-#define EXT2_IOC_SETFLAGS _IOW('f', 2, long)
-#define EXT2_IOC_GETVERSION _IOR('v', 1, long)
-#define EXT2_IOC_SETVERSION _IOW('v', 2, long)
-
-/*
- * Structure of an inode on the disk
- */
-struct ext2_inode {
- __u16 i_mode; /* File mode */
- __u16 i_uid; /* Owner Uid */
- __u32 i_size; /* Size in bytes */
- __u32 i_atime; /* Access time */
- __u32 i_ctime; /* Creation time */
- __u32 i_mtime; /* Modification time */
- __u32 i_dtime; /* Deletion Time */
- __u16 i_gid; /* Group Id */
- __u16 i_links_count; /* Links count */
- __u32 i_blocks; /* Blocks count */
- __u32 i_flags; /* File flags */
- union {
- struct {
- __u32 l_i_reserved1;
- } linux1;
- struct {
- __u32 h_i_translator;
- } hurd1;
- struct {
- __u32 m_i_reserved1;
- } masix1;
- } osd1; /* OS dependent 1 */
- __u32 i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
- __u32 i_generation; /* File version (for NFS) */
- __u32 i_file_acl; /* File ACL */
- __u32 i_dir_acl; /* Directory ACL */
- __u32 i_faddr; /* Fragment address */
- union {
- struct {
- __u8 l_i_frag; /* Fragment number */
- __u8 l_i_fsize; /* Fragment size */
- __u16 i_pad1;
- __u32 l_i_reserved2[2];
- } linux2;
- struct {
- __u8 h_i_frag; /* Fragment number */
- __u8 h_i_fsize; /* Fragment size */
- __u16 h_i_mode_high;
- __u16 h_i_uid_high;
- __u16 h_i_gid_high;
- __u32 h_i_author;
- } hurd2;
- struct {
- __u8 m_i_frag; /* Fragment number */
- __u8 m_i_fsize; /* Fragment size */
- __u16 m_pad1;
- __u32 m_i_reserved2[2];
- } masix2;
- } osd2; /* OS dependent 2 */
-};
-
-#define i_size_high i_dir_acl
-
-#if defined(__KERNEL__) || defined(__linux__)
-#define i_reserved1 osd1.linux1.l_i_reserved1
-#define i_frag osd2.linux2.l_i_frag
-#define i_fsize osd2.linux2.l_i_fsize
-#define i_reserved2 osd2.linux2.l_i_reserved2
-#endif
-
-#ifdef __hurd__
-#define i_translator osd1.hurd1.h_i_translator
-#define i_frag osd2.hurd2.h_i_frag;
-#define i_fsize osd2.hurd2.h_i_fsize;
-#define i_uid_high osd2.hurd2.h_i_uid_high
-#define i_gid_high osd2.hurd2.h_i_gid_high
-#define i_author osd2.hurd2.h_i_author
-#endif
-
-#ifdef __masix__
-#define i_reserved1 osd1.masix1.m_i_reserved1
-#define i_frag osd2.masix2.m_i_frag
-#define i_fsize osd2.masix2.m_i_fsize
-#define i_reserved2 osd2.masix2.m_i_reserved2
-#endif
-
-/*
- * File system states
- */
-#define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */
-#define EXT2_ERROR_FS 0x0002 /* Errors detected */
-
-/*
- * Mount flags
- */
-#define EXT2_MOUNT_CHECK_NORMAL 0x0001 /* Do some more checks */
-#define EXT2_MOUNT_CHECK_STRICT 0x0002 /* Do again more checks */
-#define EXT2_MOUNT_CHECK (EXT2_MOUNT_CHECK_NORMAL | \
- EXT2_MOUNT_CHECK_STRICT)
-#define EXT2_MOUNT_GRPID 0x0004 /* Create files with directory's group */
-#define EXT2_MOUNT_DEBUG 0x0008 /* Some debugging messages */
-#define EXT2_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */
-#define EXT2_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */
-#define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */
-#define EXT2_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */
-
-#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
-#define set_opt(o, opt) o |= EXT2_MOUNT_##opt
-#define test_opt(sb, opt) ((sb)->u.ext2_sb.s_mount_opt & \
- EXT2_MOUNT_##opt)
-/*
- * Maximal mount counts between two filesystem checks
- */
-#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */
-#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */
-
-/*
- * Behaviour when detecting errors
- */
-#define EXT2_ERRORS_CONTINUE 1 /* Continue execution */
-#define EXT2_ERRORS_RO 2 /* Remount fs read-only */
-#define EXT2_ERRORS_PANIC 3 /* Panic */
-#define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE
-
-/*
- * Structure of the super block
- */
-struct ext2_super_block {
- __u32 s_inodes_count; /* Inodes count */
- __u32 s_blocks_count; /* Blocks count */
- __u32 s_r_blocks_count; /* Reserved blocks count */
- __u32 s_free_blocks_count; /* Free blocks count */
- __u32 s_free_inodes_count; /* Free inodes count */
- __u32 s_first_data_block; /* First Data Block */
- __u32 s_log_block_size; /* Block size */
- __s32 s_log_frag_size; /* Fragment size */
- __u32 s_blocks_per_group; /* # Blocks per group */
- __u32 s_frags_per_group; /* # Fragments per group */
- __u32 s_inodes_per_group; /* # Inodes per group */
- __u32 s_mtime; /* Mount time */
- __u32 s_wtime; /* Write time */
- __u16 s_mnt_count; /* Mount count */
- __s16 s_max_mnt_count; /* Maximal mount count */
- __u16 s_magic; /* Magic signature */
- __u16 s_state; /* File system state */
- __u16 s_errors; /* Behaviour when detecting errors */
- __u16 s_minor_rev_level; /* minor revision level */
- __u32 s_lastcheck; /* time of last check */
- __u32 s_checkinterval; /* max. time between checks */
- __u32 s_creator_os; /* OS */
- __u32 s_rev_level; /* Revision level */
- __u16 s_def_resuid; /* Default uid for reserved blocks */
- __u16 s_def_resgid; /* Default gid for reserved blocks */
- /*
- * These fields are for EXT2_DYNAMIC_REV superblocks only.
- *
- * Note: the difference between the compatible feature set and
- * the incompatible feature set is that if there is a bit set
- * in the incompatible feature set that the kernel doesn't
- * know about, it should refuse to mount the filesystem.
- *
- * e2fsck's requirements are more strict; if it doesn't know
- * about a feature in either the compatible or incompatible
- * feature set, it must abort and not try to meddle with
- * things it doesn't understand...
- */
- __u32 s_first_ino; /* First non-reserved inode */
- __u16 s_inode_size; /* size of inode structure */
- __u16 s_block_group_nr; /* block group # of this superblock */
- __u32 s_feature_compat; /* compatible feature set */
- __u32 s_feature_incompat; /* incompatible feature set */
- __u32 s_feature_ro_compat; /* readonly-compatible feature set */
- __u8 s_uuid[16]; /* 128-bit uuid for volume */
- char s_volume_name[16]; /* volume name */
- char s_last_mounted[64]; /* directory where last mounted */
- __u32 s_algorithm_usage_bitmap; /* For compression */
- /*
- * Performance hints. Directory preallocation should only
- * happen if the EXT2_COMPAT_PREALLOC flag is on.
- */
- __u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
- __u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
- __u16 s_padding1;
- __u32 s_reserved[204]; /* Padding to the end of the block */
-};
-
-#ifdef __KERNEL__
-#define EXT2_SB(sb) (&((sb)->u.ext2_sb))
-#else
-/* Assume that user mode programs are passing in an ext2fs superblock, not
- * a kernel struct super_block. This will allow us to call the feature-test
- * macros from user land. */
-#define EXT2_SB(sb) (sb)
-#endif
-
-/*
- * Codes for operating systems
- */
-#define EXT2_OS_LINUX 0
-#define EXT2_OS_HURD 1
-#define EXT2_OS_MASIX 2
-#define EXT2_OS_FREEBSD 3
-#define EXT2_OS_LITES 4
-
-/*
- * Revision levels
- */
-#define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */
-#define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */
-
-#define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV
-#define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV
-
-#define EXT2_GOOD_OLD_INODE_SIZE 128
-
-/*
- * Feature set definitions
- */
-
-#define EXT2_HAS_COMPAT_FEATURE(sb,mask) \
- ( EXT2_SB(sb)->s_feature_compat & (mask) )
-#define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask) \
- ( EXT2_SB(sb)->s_feature_ro_compat & (mask) )
-#define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \
- ( EXT2_SB(sb)->s_feature_incompat & (mask) )
-
-#define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001
-
-#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
-#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
-#define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004
-
-#define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001
-#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
-
-#define EXT2_FEATURE_COMPAT_SUPP 0
-#define EXT2_FEATURE_INCOMPAT_SUPP EXT2_FEATURE_INCOMPAT_FILETYPE
-#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
- EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
- EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
-
-/*
- * Default values for user and/or group using reserved blocks
- */
-#define EXT2_DEF_RESUID 0
-#define EXT2_DEF_RESGID 0
-
-/*
- * Structure of a directory entry
- */
-#define EXT2_NAME_LEN 255
-
-struct ext2_dir_entry {
- __u32 inode; /* Inode number */
- __u16 rec_len; /* Directory entry length */
- __u16 name_len; /* Name length */
- char name[EXT2_NAME_LEN]; /* File name */
-};
-
-/*
- * The new version of the directory entry. Since EXT2 structures are
- * stored in intel byte order, and the name_len field could never be
- * bigger than 255 chars, it's safe to reclaim the extra byte for the
- * file_type field.
- */
-struct ext2_dir_entry_2 {
- __u32 inode; /* Inode number */
- __u16 rec_len; /* Directory entry length */
- __u8 name_len; /* Name length */
- __u8 file_type;
- char name[EXT2_NAME_LEN]; /* File name */
-};
-
-/*
- * Ext2 directory file types. Only the low 3 bits are used. The
- * other bits are reserved for now.
- */
-#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
-
-/*
- * EXT2_DIR_PAD defines the directory entries boundaries
- *
- * NOTE: It must be a multiple of 4
- */
-#define EXT2_DIR_PAD 4
-#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1)
-#define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \
- ~EXT2_DIR_ROUND)
-
-#ifdef __KERNEL__
-/*
- * Function prototypes
- */
-
-/*
- * Ok, these declarations are also in <linux/kernel.h> but none of the
- * ext2 source programs needs to include it so they are duplicated here.
- */
-# define NORET_TYPE /**/
-# define ATTRIB_NORET __attribute__((noreturn))
-# define NORET_AND noreturn,
-
-/* acl.c */
-extern int ext2_permission (struct inode *, int);
-
-/* balloc.c */
-extern int ext2_group_sparse(int group);
-extern int ext2_new_block (const struct inode *, unsigned long,
- __u32 *, __u32 *, int *);
-extern void ext2_free_blocks (const struct inode *, unsigned long,
- unsigned long);
-extern unsigned long ext2_count_free_blocks (struct super_block *);
-extern void ext2_check_blocks_bitmap (struct super_block *);
-extern struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
- unsigned int block_group,
- struct buffer_head ** bh);
-
-/* bitmap.c */
-extern unsigned long ext2_count_free (struct buffer_head *, unsigned);
-
-/* dir.c */
-extern int ext2_check_dir_entry (const char *, struct inode *,
- struct ext2_dir_entry_2 *, struct buffer_head *,
- unsigned long);
-
-/* file.c */
-extern int ext2_read (struct inode *, struct file *, char *, int);
-extern int ext2_write (struct inode *, struct file *, char *, int);
-
-/* fsync.c */
-extern int ext2_sync_file (struct file *, struct dentry *);
-
-/* ialloc.c */
-extern struct inode * ext2_new_inode (const struct inode *, int, int *);
-extern void ext2_free_inode (struct inode *);
-extern unsigned long ext2_count_free_inodes (struct super_block *);
-extern void ext2_check_inodes_bitmap (struct super_block *);
-
-/* inode.c */
-extern long ext2_bmap (struct inode *, long);
-extern int ext2_get_block (struct inode *, long, struct buffer_head *, int);
-
-extern struct buffer_head * ext2_getblk (struct inode *, long, int, int *);
-extern int ext2_getblk_block (struct inode *, long, int, int *, int *);
-extern struct buffer_head * ext2_bread (struct inode *, int, int, int *);
-
-extern int ext2_getcluster (struct inode * inode, long block);
-extern void ext2_read_inode (struct inode *);
-extern void ext2_write_inode (struct inode *);
-extern void ext2_put_inode (struct inode *);
-extern void ext2_delete_inode (struct inode *);
-extern int ext2_sync_inode (struct inode *);
-extern void ext2_discard_prealloc (struct inode *);
-
-/* ioctl.c */
-extern int ext2_ioctl (struct inode *, struct file *, unsigned int,
- unsigned long);
-
-/* namei.c */
-extern void ext2_release (struct inode *, struct file *);
-extern struct dentry *ext2_lookup (struct inode *, struct dentry *);
-extern int ext2_create (struct inode *,struct dentry *,int);
-extern int ext2_mkdir (struct inode *,struct dentry *,int);
-extern int ext2_rmdir (struct inode *,struct dentry *);
-extern int ext2_unlink (struct inode *,struct dentry *);
-extern int ext2_symlink (struct inode *,struct dentry *,const char *);
-extern int ext2_link (struct dentry *, struct inode *, struct dentry *);
-extern int ext2_mknod (struct inode *, struct dentry *, int, int);
-extern int ext2_rename (struct inode *, struct dentry *,
- struct inode *, struct dentry *);
-
-/* super.c */
-extern void ext2_error (struct super_block *, const char *, const char *, ...)
- __attribute__ ((format (printf, 3, 4)));
-extern NORET_TYPE void ext2_panic (struct super_block *, const char *,
- const char *, ...)
- __attribute__ ((NORET_AND format (printf, 3, 4)));
-extern void ext2_warning (struct super_block *, const char *, const char *, ...)
- __attribute__ ((format (printf, 3, 4)));
-extern void ext2_put_super (struct super_block *);
-extern void ext2_write_super (struct super_block *);
-extern int ext2_remount (struct super_block *, int *, char *);
-extern struct super_block * ext2_read_super (struct super_block *,void *,int);
-extern int init_ext2_fs(void);
-extern int ext2_statfs (struct super_block *, struct statfs *, int);
-
-/* truncate.c */
-extern void ext2_truncate (struct inode *);
-
-/*
- * Inodes and files operations
- */
-
-/* dir.c */
-extern struct inode_operations ext2_dir_inode_operations;
-
-/* file.c */
-extern struct inode_operations ext2_file_inode_operations;
-
-/* symlink.c */
-extern struct inode_operations ext2_symlink_inode_operations;
-extern struct inode_operations ext2_fast_symlink_inode_operations;
-
-#endif /* __KERNEL__ */
-
-#endif /* _LINUX_EXT2_FS_H */
diff --git a/sys/gnu/ext2fs/ext2_fs_i.h b/sys/gnu/ext2fs/ext2_fs_i.h
deleted file mode 100644
index 72bcd5c06da8..000000000000
--- a/sys/gnu/ext2fs/ext2_fs_i.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * linux/include/linux/ext2_fs_i.h
- *
- * Copyright (C) 1992, 1993, 1994, 1995
- * Remy Card (card@masi.ibp.fr)
- * Laboratoire MASI - Institut Blaise Pascal
- * Universite Pierre et Marie Curie (Paris VI)
- *
- * from
- *
- * linux/include/linux/minix_fs_i.h
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- */
-
-#ifndef _LINUX_EXT2_FS_I
-#define _LINUX_EXT2_FS_I
-
-/*
- * second extended file system inode data in memory
- */
-struct ext2_inode_info {
- __u32 i_data[15];
- __u32 i_flags;
- __u32 i_faddr;
- __u8 i_frag_no;
- __u8 i_frag_size;
- __u16 i_osync;
- __u32 i_file_acl;
- __u32 i_dir_acl;
- __u32 i_dtime;
- __u32 not_used_1; /* FIX: not used/ 2.2 placeholder */
- __u32 i_block_group;
- __u32 i_next_alloc_block;
- __u32 i_next_alloc_goal;
- __u32 i_prealloc_block;
- __u32 i_prealloc_count;
- __u32 i_high_size;
- int i_new_inode:1; /* Is a freshly allocated inode */
-};
-
-#endif /* _LINUX_EXT2_FS_I */
diff --git a/sys/gnu/ext2fs/ext2_fs_sb.h b/sys/gnu/ext2fs/ext2_fs_sb.h
deleted file mode 100644
index 207216323d18..000000000000
--- a/sys/gnu/ext2fs/ext2_fs_sb.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * linux/include/linux/ext2_fs_sb.h
- *
- * Copyright (C) 1992, 1993, 1994, 1995
- * Remy Card (card@masi.ibp.fr)
- * Laboratoire MASI - Institut Blaise Pascal
- * Universite Pierre et Marie Curie (Paris VI)
- *
- * from
- *
- * linux/include/linux/minix_fs_sb.h
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- */
-
-#ifndef _LINUX_EXT2_FS_SB
-#define _LINUX_EXT2_FS_SB
-
-#include <linux/ext2_fs.h>
-
-/*
- * The following is not needed anymore since the descriptors buffer
- * heads are now dynamically allocated
- */
-/* #define EXT2_MAX_GROUP_DESC 8 */
-
-#define EXT2_MAX_GROUP_LOADED 8
-
-/*
- * second extended-fs super-block data in memory
- */
-struct ext2_sb_info {
- unsigned long s_frag_size; /* Size of a fragment in bytes */
- unsigned long s_frags_per_block;/* Number of fragments per block */
- unsigned long s_inodes_per_block;/* Number of inodes per block */
- unsigned long s_frags_per_group;/* Number of fragments in a group */
- unsigned long s_blocks_per_group;/* Number of blocks in a group */
- unsigned long s_inodes_per_group;/* Number of inodes in a group */
- unsigned long s_itb_per_group; /* Number of inode table blocks per group */
- unsigned long s_db_per_group; /* Number of descriptor blocks per group */
- unsigned long s_desc_per_block; /* Number of group descriptors per block */
- unsigned long s_groups_count; /* Number of groups in the fs */
- struct buffer_head * s_sbh; /* Buffer containing the super block */
- struct ext2_super_block * s_es; /* Pointer to the super block in the buffer */
- struct buffer_head ** s_group_desc;
- unsigned short s_loaded_inode_bitmaps;
- unsigned short s_loaded_block_bitmaps;
- unsigned long s_inode_bitmap_number[EXT2_MAX_GROUP_LOADED];
- struct buffer_head * s_inode_bitmap[EXT2_MAX_GROUP_LOADED];
- unsigned long s_block_bitmap_number[EXT2_MAX_GROUP_LOADED];
- struct buffer_head * s_block_bitmap[EXT2_MAX_GROUP_LOADED];
- unsigned long s_mount_opt;
- unsigned short s_resuid;
- unsigned short s_resgid;
- unsigned short s_mount_state;
- unsigned short s_pad;
- int s_addr_per_block_bits;
- int s_desc_per_block_bits;
- int s_inode_size;
- int s_first_ino;
- int s_feature_compat;
- int s_feature_incompat;
- int s_feature_ro_compat;
-};
-
-#endif /* _LINUX_EXT2_FS_SB */
diff --git a/sys/gnu/ext2fs/ext2_linux_balloc.c b/sys/gnu/ext2fs/ext2_linux_balloc.c
deleted file mode 100644
index 43a425bbb148..000000000000
--- a/sys/gnu/ext2fs/ext2_linux_balloc.c
+++ /dev/null
@@ -1,756 +0,0 @@
-/*
- * linux/fs/ext2/balloc.c
- *
- * Copyright (C) 1992, 1993, 1994, 1995
- * Remy Card (card@masi.ibp.fr)
- * Laboratoire MASI - Institut Blaise Pascal
- * Universite Pierre et Marie Curie (Paris VI)
- *
- * Enhanced block allocation by Stephen Tweedie (sct@dcs.ed.ac.uk), 1993
- * Big-endian to little-endian byte-swapping/bitmaps by
- * David S. Miller (davem@caip.rutgers.edu), 1995
- */
-
-#include <linux/fs.h>
-#include <linux/locks.h>
-#include <linux/quotaops.h>
-
-
-/*
- * balloc.c contains the blocks allocation and deallocation routines
- */
-
-/*
- * The free blocks are managed by bitmaps. A file system contains several
- * blocks groups. Each group contains 1 bitmap block for blocks, 1 bitmap
- * block for inodes, N blocks for the inode table and data blocks.
- *
- * The file system contains group descriptors which are located after the
- * super block. Each descriptor contains the number of the bitmap block and
- * the free blocks count in the block. The descriptors are loaded in memory
- * when a file system is mounted (see ext2_read_super).
- */
-
-
-#define in_range(b, first, len) ((b) >= (first) && (b) <= (first) + (len) - 1)
-
-struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
- unsigned int block_group,
- struct buffer_head ** bh)
-{
- unsigned long group_desc;
- unsigned long desc;
- struct ext2_group_desc * gdp;
-
- if (block_group >= sb->u.ext2_sb.s_groups_count) {
- ext2_error (sb, "ext2_get_group_desc",
- "block_group >= groups_count - "
- "block_group = %d, groups_count = %lu",
- block_group, sb->u.ext2_sb.s_groups_count);
-
- return NULL;
- }
-
- group_desc = block_group / EXT2_DESC_PER_BLOCK(sb);
- desc = block_group % EXT2_DESC_PER_BLOCK(sb);
- if (!sb->u.ext2_sb.s_group_desc[group_desc]) {
- ext2_error (sb, "ext2_get_group_desc",
- "Group descriptor not loaded - "
- "block_group = %d, group_desc = %lu, desc = %lu",
- block_group, group_desc, desc);
- return NULL;
- }
-
- gdp = (struct ext2_group_desc *)
- sb->u.ext2_sb.s_group_desc[group_desc]->b_data;
- if (bh)
- *bh = sb->u.ext2_sb.s_group_desc[group_desc];
- return gdp + desc;
-}
-
-/*
- * Read the bitmap for a given block_group, reading into the specified
- * slot in the superblock's bitmap cache.
- *
- * Return >=0 on success or a -ve error code.
- */
-
-static int read_block_bitmap (struct super_block * sb,
- unsigned int block_group,
- unsigned long bitmap_nr)
-{
- struct ext2_group_desc * gdp;
- struct buffer_head * bh = NULL;
- int retval = -EIO;
-
- gdp = ext2_get_group_desc (sb, block_group, NULL);
- if (!gdp)
- goto error_out;
- retval = 0;
- bh = bread (sb->s_dev, le32_to_cpu(gdp->bg_block_bitmap), sb->s_blocksize);
- if (!bh) {
- ext2_error (sb, "read_block_bitmap",
- "Cannot read block bitmap - "
- "block_group = %d, block_bitmap = %lu",
- block_group, (unsigned long) gdp->bg_block_bitmap);
- retval = -EIO;
- }
- /*
- * On IO error, just leave a zero in the superblock's block pointer for
- * this group. The IO will be retried next time.
- */
-error_out:
- sb->u.ext2_sb.s_block_bitmap_number[bitmap_nr] = block_group;
- sb->u.ext2_sb.s_block_bitmap[bitmap_nr] = bh;
- return retval;
-}
-
-/*
- * load_block_bitmap loads the block bitmap for a blocks group
- *
- * It maintains a cache for the last bitmaps loaded. This cache is managed
- * with a LRU algorithm.
- *
- * Notes:
- * 1/ There is one cache per mounted file system.
- * 2/ If the file system contains less than EXT2_MAX_GROUP_LOADED groups,
- * this function reads the bitmap without maintaining a LRU cache.
- *
- * Return the slot used to store the bitmap, or a -ve error code.
- */
-static int __load_block_bitmap (struct super_block * sb,
- unsigned int block_group)
-{
- int i, j, retval = 0;
- unsigned long block_bitmap_number;
- struct buffer_head * block_bitmap;
-
- if (block_group >= sb->u.ext2_sb.s_groups_count)
- ext2_panic (sb, "load_block_bitmap",
- "block_group >= groups_count - "
- "block_group = %d, groups_count = %lu",
- block_group, sb->u.ext2_sb.s_groups_count);
-
- if (sb->u.ext2_sb.s_groups_count <= EXT2_MAX_GROUP_LOADED) {
- if (sb->u.ext2_sb.s_block_bitmap[block_group]) {
- if (sb->u.ext2_sb.s_block_bitmap_number[block_group] ==
- block_group)
- return block_group;
- ext2_error (sb, "__load_block_bitmap",
- "block_group != block_bitmap_number");
- }
- retval = read_block_bitmap (sb, block_group, block_group);
- if (retval < 0)
- return retval;
- return block_group;
- }
-
- for (i = 0; i < sb->u.ext2_sb.s_loaded_block_bitmaps &&
- sb->u.ext2_sb.s_block_bitmap_number[i] != block_group; i++)
- ;
- if (i < sb->u.ext2_sb.s_loaded_block_bitmaps &&
- sb->u.ext2_sb.s_block_bitmap_number[i] == block_group) {
- block_bitmap_number = sb->u.ext2_sb.s_block_bitmap_number[i];
- block_bitmap = sb->u.ext2_sb.s_block_bitmap[i];
- for (j = i; j > 0; j--) {
- sb->u.ext2_sb.s_block_bitmap_number[j] =
- sb->u.ext2_sb.s_block_bitmap_number[j - 1];
- sb->u.ext2_sb.s_block_bitmap[j] =
- sb->u.ext2_sb.s_block_bitmap[j - 1];
- }
- sb->u.ext2_sb.s_block_bitmap_number[0] = block_bitmap_number;
- sb->u.ext2_sb.s_block_bitmap[0] = block_bitmap;
-
- /*
- * There's still one special case here --- if block_bitmap == 0
- * then our last attempt to read the bitmap failed and we have
- * just ended up caching that failure. Try again to read it.
- */
- if (!block_bitmap)
- retval = read_block_bitmap (sb, block_group, 0);
- } else {
- if (sb->u.ext2_sb.s_loaded_block_bitmaps < EXT2_MAX_GROUP_LOADED)
- sb->u.ext2_sb.s_loaded_block_bitmaps++;
- else
- brelse (sb->u.ext2_sb.s_block_bitmap[EXT2_MAX_GROUP_LOADED - 1]);
- for (j = sb->u.ext2_sb.s_loaded_block_bitmaps - 1; j > 0; j--) {
- sb->u.ext2_sb.s_block_bitmap_number[j] =
- sb->u.ext2_sb.s_block_bitmap_number[j - 1];
- sb->u.ext2_sb.s_block_bitmap[j] =
- sb->u.ext2_sb.s_block_bitmap[j - 1];
- }
- retval = read_block_bitmap (sb, block_group, 0);
- }
- return retval;
-}
-
-/*
- * Load the block bitmap for a given block group. First of all do a couple
- * of fast lookups for common cases and then pass the request onto the guts
- * of the bitmap loader.
- *
- * Return the slot number of the group in the superblock bitmap cache's on
- * success, or a -ve error code.
- *
- * There is still one inconsistency here --- if the number of groups in this
- * filesystems is <= EXT2_MAX_GROUP_LOADED, then we have no way of
- * differentiating between a group for which we have never performed a bitmap
- * IO request, and a group for which the last bitmap read request failed.
- */
-static inline int load_block_bitmap (struct super_block * sb,
- unsigned int block_group)
-{
- int slot;
-
- /*
- * Do the lookup for the slot. First of all, check if we're asking
- * for the same slot as last time, and did we succeed that last time?
- */
- if (sb->u.ext2_sb.s_loaded_block_bitmaps > 0 &&
- sb->u.ext2_sb.s_block_bitmap_number[0] == block_group &&
- sb->u.ext2_sb.s_block_bitmap[block_group]) {
- return 0;
- }
- /*
- * Or can we do a fast lookup based on a loaded group on a filesystem
- * small enough to be mapped directly into the superblock?
- */
- else if (sb->u.ext2_sb.s_groups_count <= EXT2_MAX_GROUP_LOADED &&
- sb->u.ext2_sb.s_block_bitmap_number[block_group] == block_group &&
- sb->u.ext2_sb.s_block_bitmap[block_group]) {
- slot = block_group;
- }
- /*
- * If not, then do a full lookup for this block group.
- */
- else {
- slot = __load_block_bitmap (sb, block_group);
- }
-
- /*
- * <0 means we just got an error
- */
- if (slot < 0)
- return slot;
-
- /*
- * If it's a valid slot, we may still have cached a previous IO error,
- * in which case the bh in the superblock cache will be zero.
- */
- if (!sb->u.ext2_sb.s_block_bitmap[slot])
- return -EIO;
-
- /*
- * Must have been read in OK to get this far.
- */
- return slot;
-}
-
-void ext2_free_blocks (const struct inode * inode, unsigned long block,
- unsigned long count)
-{
- struct buffer_head * bh;
- struct buffer_head * bh2;
- unsigned long block_group;
- unsigned long bit;
- unsigned long i;
- int bitmap_nr;
- unsigned long overflow;
- struct super_block * sb;
- struct ext2_group_desc * gdp;
- struct ext2_super_block * es;
-
- sb = inode->i_sb;
- if (!sb) {
- printk ("ext2_free_blocks: nonexistent device");
- return;
- }
- lock_super (sb);
- es = sb->u.ext2_sb.s_es;
- if (block < le32_to_cpu(es->s_first_data_block) ||
- (block + count) > le32_to_cpu(es->s_blocks_count)) {
- ext2_error (sb, "ext2_free_blocks",
- "Freeing blocks not in datazone - "
- "block = %lu, count = %lu", block, count);
- goto error_return;
- }
-
- ext2_debug ("freeing block %lu\n", block);
-
-do_more:
- overflow = 0;
- block_group = (block - le32_to_cpu(es->s_first_data_block)) /
- EXT2_BLOCKS_PER_GROUP(sb);
- bit = (block - le32_to_cpu(es->s_first_data_block)) %
- EXT2_BLOCKS_PER_GROUP(sb);
- /*
- * Check to see if we are freeing blocks across a group
- * boundary.
- */
- if (bit + count > EXT2_BLOCKS_PER_GROUP(sb)) {
- overflow = bit + count - EXT2_BLOCKS_PER_GROUP(sb);
- count -= overflow;
- }
- bitmap_nr = load_block_bitmap (sb, block_group);
- if (bitmap_nr < 0)
- goto error_return;
-
- bh = sb->u.ext2_sb.s_block_bitmap[bitmap_nr];
- gdp = ext2_get_group_desc (sb, block_group, &bh2);
- if (!gdp)
- goto error_return;
-
- if (test_opt (sb, CHECK_STRICT) &&
- (in_range (le32_to_cpu(gdp->bg_block_bitmap), block, count) ||
- in_range (le32_to_cpu(gdp->bg_inode_bitmap), block, count) ||
- in_range (block, le32_to_cpu(gdp->bg_inode_table),
- sb->u.ext2_sb.s_itb_per_group) ||
- in_range (block + count - 1, le32_to_cpu(gdp->bg_inode_table),
- sb->u.ext2_sb.s_itb_per_group)))
- ext2_panic (sb, "ext2_free_blocks",
- "Freeing blocks in system zones - "
- "Block = %lu, count = %lu",
- block, count);
-
- for (i = 0; i < count; i++) {
- if (!ext2_clear_bit (bit + i, bh->b_data))
- ext2_warning (sb, "ext2_free_blocks",
- "bit already cleared for block %lu",
- block);
- else {
- DQUOT_FREE_BLOCK(sb, inode, 1);
- gdp->bg_free_blocks_count =
- cpu_to_le16(le16_to_cpu(gdp->bg_free_blocks_count)+1);
- es->s_free_blocks_count =
- cpu_to_le32(le32_to_cpu(es->s_free_blocks_count)+1);
- }
- }
-
- mark_buffer_dirty(bh2, 1);
- mark_buffer_dirty(sb->u.ext2_sb.s_sbh, 1);
-
- mark_buffer_dirty(bh, 1);
- if (sb->s_flags & MS_SYNCHRONOUS) {
- ll_rw_block (WRITE, 1, &bh);
- wait_on_buffer (bh);
- }
- if (overflow) {
- block += count;
- count = overflow;
- goto do_more;
- }
- sb->s_dirt = 1;
-error_return:
- unlock_super (sb);
- return;
-}
-
-/*
- * ext2_new_block uses a goal block to assist allocation. If the goal is
- * free, or there is a free block within 32 blocks of the goal, that block
- * is allocated. Otherwise a forward search is made for a free block; within
- * each block group the search first looks for an entire free byte in the block
- * bitmap, and then for any free bit if that fails.
- */
-int ext2_new_block (const struct inode * inode, unsigned long goal,
- u32 * prealloc_count, u32 * prealloc_block, int * err)
-{
- struct buffer_head * bh;
- struct buffer_head * bh2;
- char * p, * r;
- int i, j, k, tmp;
- int bitmap_nr;
- struct super_block * sb;
- struct ext2_group_desc * gdp;
- struct ext2_super_block * es;
-#ifdef EXT2FS_DEBUG
- static int goal_hits = 0, goal_attempts = 0;
-#endif
- *err = -ENOSPC;
- sb = inode->i_sb;
- if (!sb) {
- printk ("ext2_new_block: nonexistent device");
- return 0;
- }
-
- lock_super (sb);
- es = sb->u.ext2_sb.s_es;
- if (le32_to_cpu(es->s_free_blocks_count) <= le32_to_cpu(es->s_r_blocks_count) &&
- ((sb->u.ext2_sb.s_resuid != current->fsuid) &&
- (sb->u.ext2_sb.s_resgid == 0 ||
- !in_group_p (sb->u.ext2_sb.s_resgid)) &&
- !capable(CAP_SYS_RESOURCE))) {
- unlock_super (sb);
- return 0;
- }
-
- ext2_debug ("goal=%lu.\n", goal);
-
-repeat:
- /*
- * First, test whether the goal block is free.
- */
- if (goal < le32_to_cpu(es->s_first_data_block) ||
- goal >= le32_to_cpu(es->s_blocks_count))
- goal = le32_to_cpu(es->s_first_data_block);
- i = (goal - le32_to_cpu(es->s_first_data_block)) / EXT2_BLOCKS_PER_GROUP(sb);
- gdp = ext2_get_group_desc (sb, i, &bh2);
- if (!gdp)
- goto io_error;
-
- if (le16_to_cpu(gdp->bg_free_blocks_count) > 0) {
- j = ((goal - le32_to_cpu(es->s_first_data_block)) % EXT2_BLOCKS_PER_GROUP(sb));
-#ifdef EXT2FS_DEBUG
- if (j)
- goal_attempts++;
-#endif
- bitmap_nr = load_block_bitmap (sb, i);
- if (bitmap_nr < 0)
- goto io_error;
-
- bh = sb->u.ext2_sb.s_block_bitmap[bitmap_nr];
-
- ext2_debug ("goal is at %d:%d.\n", i, j);
-
- if (!ext2_test_bit(j, bh->b_data)) {
-#ifdef EXT2FS_DEBUG
- goal_hits++;
- ext2_debug ("goal bit allocated.\n");
-#endif
- goto got_block;
- }
- if (j) {
- /*
- * The goal was occupied; search forward for a free
- * block within the next XX blocks.
- *
- * end_goal is more or less random, but it has to be
- * less than EXT2_BLOCKS_PER_GROUP. Aligning up to the
- * next 64-bit boundary is simple..
- */
- int end_goal = (j + 63) & ~63;
- j = ext2_find_next_zero_bit(bh->b_data, end_goal, j);
- if (j < end_goal)
- goto got_block;
- }
-
- ext2_debug ("Bit not found near goal\n");
-
- /*
- * There has been no free block found in the near vicinity
- * of the goal: do a search forward through the block groups,
- * searching in each group first for an entire free byte in
- * the bitmap and then for any free bit.
- *
- * Search first in the remainder of the current group; then,
- * cyclicly search through the rest of the groups.
- */
- p = ((char *) bh->b_data) + (j >> 3);
- r = memscan(p, 0, (EXT2_BLOCKS_PER_GROUP(sb) - j + 7) >> 3);
- k = (r - ((char *) bh->b_data)) << 3;
- if (k < EXT2_BLOCKS_PER_GROUP(sb)) {
- j = k;
- goto search_back;
- }
-
- k = ext2_find_next_zero_bit ((unsigned long *) bh->b_data,
- EXT2_BLOCKS_PER_GROUP(sb),
- j);
- if (k < EXT2_BLOCKS_PER_GROUP(sb)) {
- j = k;
- goto got_block;
- }
- }
-
- ext2_debug ("Bit not found in block group %d.\n", i);
-
- /*
- * Now search the rest of the groups. We assume that
- * i and gdp correctly point to the last group visited.
- */
- for (k = 0; k < sb->u.ext2_sb.s_groups_count; k++) {
- i++;
- if (i >= sb->u.ext2_sb.s_groups_count)
- i = 0;
- gdp = ext2_get_group_desc (sb, i, &bh2);
- if (!gdp) {
- *err = -EIO;
- unlock_super (sb);
- return 0;
- }
- if (le16_to_cpu(gdp->bg_free_blocks_count) > 0)
- break;
- }
- if (k >= sb->u.ext2_sb.s_groups_count) {
- unlock_super (sb);
- return 0;
- }
- bitmap_nr = load_block_bitmap (sb, i);
- if (bitmap_nr < 0)
- goto io_error;
-
- bh = sb->u.ext2_sb.s_block_bitmap[bitmap_nr];
- r = memscan(bh->b_data, 0, EXT2_BLOCKS_PER_GROUP(sb) >> 3);
- j = (r - bh->b_data) << 3;
- if (j < EXT2_BLOCKS_PER_GROUP(sb))
- goto search_back;
- else
- j = ext2_find_first_zero_bit ((unsigned long *) bh->b_data,
- EXT2_BLOCKS_PER_GROUP(sb));
- if (j >= EXT2_BLOCKS_PER_GROUP(sb)) {
- ext2_error (sb, "ext2_new_block",
- "Free blocks count corrupted for block group %d", i);
- unlock_super (sb);
- return 0;
- }
-
-search_back:
- /*
- * We have succeeded in finding a free byte in the block
- * bitmap. Now search backwards up to 7 bits to find the
- * start of this group of free blocks.
- */
- for (k = 0; k < 7 && j > 0 && !ext2_test_bit (j - 1, bh->b_data); k++, j--);
-
-got_block:
-
- ext2_debug ("using block group %d(%d)\n", i, gdp->bg_free_blocks_count);
-
- /*
- * Check quota for allocation of this block.
- */
- if(DQUOT_ALLOC_BLOCK(sb, inode, 1)) {
- unlock_super(sb);
- *err = -EDQUOT;
- return 0;
- }
-
- tmp = j + i * EXT2_BLOCKS_PER_GROUP(sb) + le32_to_cpu(es->s_first_data_block);
-
- if (test_opt (sb, CHECK_STRICT) &&
- (tmp == le32_to_cpu(gdp->bg_block_bitmap) ||
- tmp == le32_to_cpu(gdp->bg_inode_bitmap) ||
- in_range (tmp, le32_to_cpu(gdp->bg_inode_table), sb->u.ext2_sb.s_itb_per_group)))
- ext2_panic (sb, "ext2_new_block",
- "Allocating block in system zone - "
- "block = %u", tmp);
-
- if (ext2_set_bit (j, bh->b_data)) {
- ext2_warning (sb, "ext2_new_block",
- "bit already set for block %d", j);
- DQUOT_FREE_BLOCK(sb, inode, 1);
- goto repeat;
- }
-
- ext2_debug ("found bit %d\n", j);
-
- /*
- * Do block preallocation now if required.
- */
-#ifdef EXT2_PREALLOCATE
- if (prealloc_block) {
- int prealloc_goal;
-
- prealloc_goal = es->s_prealloc_blocks ?
- es->s_prealloc_blocks : EXT2_DEFAULT_PREALLOC_BLOCKS;
-
- *prealloc_count = 0;
- *prealloc_block = tmp + 1;
- for (k = 1;
- k < prealloc_goal && (j + k) < EXT2_BLOCKS_PER_GROUP(sb);
- k++) {
- if (DQUOT_PREALLOC_BLOCK(sb, inode, 1))
- break;
- if (ext2_set_bit (j + k, bh->b_data)) {
- DQUOT_FREE_BLOCK(sb, inode, 1);
- break;
- }
- (*prealloc_count)++;
- }
- gdp->bg_free_blocks_count =
- cpu_to_le16(le16_to_cpu(gdp->bg_free_blocks_count) -
- *prealloc_count);
- es->s_free_blocks_count =
- cpu_to_le32(le32_to_cpu(es->s_free_blocks_count) -
- *prealloc_count);
- ext2_debug ("Preallocated a further %lu bits.\n",
- *prealloc_count);
- }
-#endif
-
- j = tmp;
-
- mark_buffer_dirty(bh, 1);
- if (sb->s_flags & MS_SYNCHRONOUS) {
- ll_rw_block (WRITE, 1, &bh);
- wait_on_buffer (bh);
- }
-
- if (j >= le32_to_cpu(es->s_blocks_count)) {
- ext2_error (sb, "ext2_new_block",
- "block(%d) >= blocks count(%d) - "
- "block_group = %d, es == %p ",j,
- le32_to_cpu(es->s_blocks_count), i, es);
- unlock_super (sb);
- return 0;
- }
-
- ext2_debug ("allocating block %d. "
- "Goal hits %d of %d.\n", j, goal_hits, goal_attempts);
-
- gdp->bg_free_blocks_count = cpu_to_le16(le16_to_cpu(gdp->bg_free_blocks_count) - 1);
- mark_buffer_dirty(bh2, 1);
- es->s_free_blocks_count = cpu_to_le32(le32_to_cpu(es->s_free_blocks_count) - 1);
- mark_buffer_dirty(sb->u.ext2_sb.s_sbh, 1);
- sb->s_dirt = 1;
- unlock_super (sb);
- *err = 0;
- return j;
-
-io_error:
- *err = -EIO;
- unlock_super (sb);
- return 0;
-
-}
-
-unsigned long ext2_count_free_blocks (struct super_block * sb)
-{
-#ifdef EXT2FS_DEBUG
- struct ext2_super_block * es;
- unsigned long desc_count, bitmap_count, x;
- int bitmap_nr;
- struct ext2_group_desc * gdp;
- int i;
-
- lock_super (sb);
- es = sb->u.ext2_sb.s_es;
- desc_count = 0;
- bitmap_count = 0;
- gdp = NULL;
- for (i = 0; i < sb->u.ext2_sb.s_groups_count; i++) {
- gdp = ext2_get_group_desc (sb, i, NULL);
- if (!gdp)
- continue;
- desc_count += le16_to_cpu(gdp->bg_free_blocks_count);
- bitmap_nr = load_block_bitmap (sb, i);
- if (bitmap_nr < 0)
- continue;
-
- x = ext2_count_free (sb->u.ext2_sb.s_block_bitmap[bitmap_nr],
- sb->s_blocksize);
- printk ("group %d: stored = %d, counted = %lu\n",
- i, le16_to_cpu(gdp->bg_free_blocks_count), x);
- bitmap_count += x;
- }
- printk("ext2_count_free_blocks: stored = %lu, computed = %lu, %lu\n",
- le32_to_cpu(es->s_free_blocks_count), desc_count, bitmap_count);
- unlock_super (sb);
- return bitmap_count;
-#else
- return le32_to_cpu(sb->u.ext2_sb.s_es->s_free_blocks_count);
-#endif
-}
-
-static inline int block_in_use (unsigned long block,
- struct super_block * sb,
- unsigned char * map)
-{
- return ext2_test_bit ((block - le32_to_cpu(sb->u.ext2_sb.s_es->s_first_data_block)) %
- EXT2_BLOCKS_PER_GROUP(sb), map);
-}
-
-static int test_root(int a, int b)
-{
- if (a == 0)
- return 1;
- while (1) {
- if (a == 1)
- return 1;
- if (a % b)
- return 0;
- a = a / b;
- }
-}
-
-int ext2_group_sparse(int group)
-{
- return (test_root(group, 3) || test_root(group, 5) ||
- test_root(group, 7));
-}
-
-void ext2_check_blocks_bitmap (struct super_block * sb)
-{
- struct buffer_head * bh;
- struct ext2_super_block * es;
- unsigned long desc_count, bitmap_count, x;
- unsigned long desc_blocks;
- int bitmap_nr;
- struct ext2_group_desc * gdp;
- int i, j;
-
- lock_super (sb);
- es = sb->u.ext2_sb.s_es;
- desc_count = 0;
- bitmap_count = 0;
- gdp = NULL;
- desc_blocks = (sb->u.ext2_sb.s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) /
- EXT2_DESC_PER_BLOCK(sb);
- for (i = 0; i < sb->u.ext2_sb.s_groups_count; i++) {
- gdp = ext2_get_group_desc (sb, i, NULL);
- if (!gdp)
- continue;
- desc_count += le16_to_cpu(gdp->bg_free_blocks_count);
- bitmap_nr = load_block_bitmap (sb, i);
- if (bitmap_nr < 0)
- continue;
-
- bh = sb->u.ext2_sb.s_block_bitmap[bitmap_nr];
-
- if (!(sb->u.ext2_sb.s_feature_ro_compat &
- EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER) ||
- ext2_group_sparse(i)) {
- if (!ext2_test_bit (0, bh->b_data))
- ext2_error (sb, "ext2_check_blocks_bitmap",
- "Superblock in group %d "
- "is marked free", i);
-
- for (j = 0; j < desc_blocks; j++)
- if (!ext2_test_bit (j + 1, bh->b_data))
- ext2_error (sb,
- "ext2_check_blocks_bitmap",
- "Descriptor block #%d in group "
- "%d is marked free", j, i);
- }
-
- if (!block_in_use (le32_to_cpu(gdp->bg_block_bitmap), sb, bh->b_data))
- ext2_error (sb, "ext2_check_blocks_bitmap",
- "Block bitmap for group %d is marked free",
- i);
-
- if (!block_in_use (le32_to_cpu(gdp->bg_inode_bitmap), sb, bh->b_data))
- ext2_error (sb, "ext2_check_blocks_bitmap",
- "Inode bitmap for group %d is marked free",
- i);
-
- for (j = 0; j < sb->u.ext2_sb.s_itb_per_group; j++)
- if (!block_in_use (le32_to_cpu(gdp->bg_inode_table) + j, sb, bh->b_data))
- ext2_error (sb, "ext2_check_blocks_bitmap",
- "Block #%d of the inode table in "
- "group %d is marked free", j, i);
-
- x = ext2_count_free (bh, sb->s_blocksize);
- if (le16_to_cpu(gdp->bg_free_blocks_count) != x)
- ext2_error (sb, "ext2_check_blocks_bitmap",
- "Wrong free blocks count for group %d, "
- "stored = %d, counted = %lu", i,
- le16_to_cpu(gdp->bg_free_blocks_count), x);
- bitmap_count += x;
- }
- if (le32_to_cpu(es->s_free_blocks_count) != bitmap_count)
- ext2_error (sb, "ext2_check_blocks_bitmap",
- "Wrong free blocks count in super block, "
- "stored = %lu, counted = %lu",
- (unsigned long) le32_to_cpu(es->s_free_blocks_count), bitmap_count);
- unlock_super (sb);
-}
diff --git a/sys/gnu/ext2fs/ext2_linux_ialloc.c b/sys/gnu/ext2fs/ext2_linux_ialloc.c
deleted file mode 100644
index d519f6001ae7..000000000000
--- a/sys/gnu/ext2fs/ext2_linux_ialloc.c
+++ /dev/null
@@ -1,569 +0,0 @@
-/*
- * linux/fs/ext2/ialloc.c
- *
- * Copyright (C) 1992, 1993, 1994, 1995
- * Remy Card (card@masi.ibp.fr)
- * Laboratoire MASI - Institut Blaise Pascal
- * Universite Pierre et Marie Curie (Paris VI)
- *
- * BSD ufs-inspired inode and directory allocation by
- * Stephen Tweedie (sct@dcs.ed.ac.uk), 1993
- * Big-endian to little-endian byte-swapping/bitmaps by
- * David S. Miller (davem@caip.rutgers.edu), 1995
- */
-
-#include <linux/fs.h>
-#include <linux/locks.h>
-#include <linux/quotaops.h>
-
-
-/*
- * ialloc.c contains the inodes allocation and deallocation routines
- */
-
-/*
- * The free inodes are managed by bitmaps. A file system contains several
- * blocks groups. Each group contains 1 bitmap block for blocks, 1 bitmap
- * block for inodes, N blocks for the inode table and data blocks.
- *
- * The file system contains group descriptors which are located after the
- * super block. Each descriptor contains the number of the bitmap block and
- * the free blocks count in the block. The descriptors are loaded in memory
- * when a file system is mounted (see ext2_read_super).
- */
-
-
-/*
- * Read the inode allocation bitmap for a given block_group, reading
- * into the specified slot in the superblock's bitmap cache.
- *
- * Return >=0 on success or a -ve error code.
- */
-static int read_inode_bitmap (struct super_block * sb,
- unsigned long block_group,
- unsigned int bitmap_nr)
-{
- struct ext2_group_desc * gdp;
- struct buffer_head * bh = NULL;
- int retval = 0;
-
- gdp = ext2_get_group_desc (sb, block_group, NULL);
- if (!gdp) {
- retval = -EIO;
- goto error_out;
- }
- bh = bread (sb->s_dev, le32_to_cpu(gdp->bg_inode_bitmap), sb->s_blocksize);
- if (!bh) {
- ext2_error (sb, "read_inode_bitmap",
- "Cannot read inode bitmap - "
- "block_group = %lu, inode_bitmap = %lu",
- block_group, (unsigned long) gdp->bg_inode_bitmap);
- retval = -EIO;
- }
- /*
- * On IO error, just leave a zero in the superblock's block pointer for
- * this group. The IO will be retried next time.
- */
-error_out:
- sb->u.ext2_sb.s_inode_bitmap_number[bitmap_nr] = block_group;
- sb->u.ext2_sb.s_inode_bitmap[bitmap_nr] = bh;
- return retval;
-}
-
-/*
- * load_inode_bitmap loads the inode bitmap for a blocks group
- *
- * It maintains a cache for the last bitmaps loaded. This cache is managed
- * with a LRU algorithm.
- *
- * Notes:
- * 1/ There is one cache per mounted file system.
- * 2/ If the file system contains less than EXT2_MAX_GROUP_LOADED groups,
- * this function reads the bitmap without maintaining a LRU cache.
- *
- * Return the slot used to store the bitmap, or a -ve error code.
- */
-static int load_inode_bitmap (struct super_block * sb,
- unsigned int block_group)
-{
- int i, j, retval = 0;
- unsigned long inode_bitmap_number;
- struct buffer_head * inode_bitmap;
-
- if (block_group >= sb->u.ext2_sb.s_groups_count)
- ext2_panic (sb, "load_inode_bitmap",
- "block_group >= groups_count - "
- "block_group = %d, groups_count = %lu",
- block_group, sb->u.ext2_sb.s_groups_count);
- if (sb->u.ext2_sb.s_loaded_inode_bitmaps > 0 &&
- sb->u.ext2_sb.s_inode_bitmap_number[0] == block_group &&
- sb->u.ext2_sb.s_inode_bitmap[0] != NULL)
- return 0;
- if (sb->u.ext2_sb.s_groups_count <= EXT2_MAX_GROUP_LOADED) {
- if (sb->u.ext2_sb.s_inode_bitmap[block_group]) {
- if (sb->u.ext2_sb.s_inode_bitmap_number[block_group] != block_group)
- ext2_panic (sb, "load_inode_bitmap",
- "block_group != inode_bitmap_number");
- else
- return block_group;
- } else {
- retval = read_inode_bitmap (sb, block_group,
- block_group);
- if (retval < 0)
- return retval;
- return block_group;
- }
- }
-
- for (i = 0; i < sb->u.ext2_sb.s_loaded_inode_bitmaps &&
- sb->u.ext2_sb.s_inode_bitmap_number[i] != block_group;
- i++)
- ;
- if (i < sb->u.ext2_sb.s_loaded_inode_bitmaps &&
- sb->u.ext2_sb.s_inode_bitmap_number[i] == block_group) {
- inode_bitmap_number = sb->u.ext2_sb.s_inode_bitmap_number[i];
- inode_bitmap = sb->u.ext2_sb.s_inode_bitmap[i];
- for (j = i; j > 0; j--) {
- sb->u.ext2_sb.s_inode_bitmap_number[j] =
- sb->u.ext2_sb.s_inode_bitmap_number[j - 1];
- sb->u.ext2_sb.s_inode_bitmap[j] =
- sb->u.ext2_sb.s_inode_bitmap[j - 1];
- }
- sb->u.ext2_sb.s_inode_bitmap_number[0] = inode_bitmap_number;
- sb->u.ext2_sb.s_inode_bitmap[0] = inode_bitmap;
-
- /*
- * There's still one special case here --- if inode_bitmap == 0
- * then our last attempt to read the bitmap failed and we have
- * just ended up caching that failure. Try again to read it.
- */
- if (!inode_bitmap)
- retval = read_inode_bitmap (sb, block_group, 0);
-
- } else {
- if (sb->u.ext2_sb.s_loaded_inode_bitmaps < EXT2_MAX_GROUP_LOADED)
- sb->u.ext2_sb.s_loaded_inode_bitmaps++;
- else
- brelse (sb->u.ext2_sb.s_inode_bitmap[EXT2_MAX_GROUP_LOADED - 1]);
- for (j = sb->u.ext2_sb.s_loaded_inode_bitmaps - 1; j > 0; j--) {
- sb->u.ext2_sb.s_inode_bitmap_number[j] =
- sb->u.ext2_sb.s_inode_bitmap_number[j - 1];
- sb->u.ext2_sb.s_inode_bitmap[j] =
- sb->u.ext2_sb.s_inode_bitmap[j - 1];
- }
- retval = read_inode_bitmap (sb, block_group, 0);
- }
- return retval;
-}
-
-/*
- * NOTE! When we get the inode, we're the only people
- * that have access to it, and as such there are no
- * race conditions we have to worry about. The inode
- * is not on the hash-lists, and it cannot be reached
- * through the filesystem because the directory entry
- * has been deleted earlier.
- *
- * HOWEVER: we must make sure that we get no aliases,
- * which means that we have to call "clear_inode()"
- * _before_ we mark the inode not in use in the inode
- * bitmaps. Otherwise a newly created file might use
- * the same inode number (not actually the same pointer
- * though), and then we'd have two inodes sharing the
- * same inode number and space on the harddisk.
- */
-void ext2_free_inode (struct inode * inode)
-{
- struct super_block * sb = inode->i_sb;
- int is_directory;
- unsigned long ino;
- struct buffer_head * bh;
- struct buffer_head * bh2;
- unsigned long block_group;
- unsigned long bit;
- int bitmap_nr;
- struct ext2_group_desc * gdp;
- struct ext2_super_block * es;
-
- if (!inode->i_dev) {
- printk ("ext2_free_inode: inode has no device\n");
- return;
- }
- if (inode->i_count > 1) {
- printk ("ext2_free_inode: inode has count=%d\n", inode->i_count);
- return;
- }
- if (inode->i_nlink) {
- printk ("ext2_free_inode: inode has nlink=%d\n",
- inode->i_nlink);
- return;
- }
- if (!sb) {
- printk("ext2_free_inode: inode on nonexistent device\n");
- return;
- }
-
- ino = inode->i_ino;
- ext2_debug ("freeing inode %lu\n", ino);
-
- /*
- * Note: we must free any quota before locking the superblock,
- * as writing the quota to disk may need the lock as well.
- */
- DQUOT_FREE_INODE(sb, inode);
- DQUOT_DROP(inode);
-
- lock_super (sb);
- es = sb->u.ext2_sb.s_es;
- if (ino < EXT2_FIRST_INO(sb) ||
- ino > le32_to_cpu(es->s_inodes_count)) {
- ext2_error (sb, "free_inode",
- "reserved inode or nonexistent inode");
- goto error_return;
- }
- block_group = (ino - 1) / EXT2_INODES_PER_GROUP(sb);
- bit = (ino - 1) % EXT2_INODES_PER_GROUP(sb);
- bitmap_nr = load_inode_bitmap (sb, block_group);
- if (bitmap_nr < 0)
- goto error_return;
-
- bh = sb->u.ext2_sb.s_inode_bitmap[bitmap_nr];
-
- is_directory = S_ISDIR(inode->i_mode);
-
- /* Do this BEFORE marking the inode not in use */
- clear_inode (inode);
-
- /* Ok, now we can actually update the inode bitmaps.. */
- if (!ext2_clear_bit (bit, bh->b_data))
- ext2_warning (sb, "ext2_free_inode",
- "bit already cleared for inode %lu", ino);
- else {
- gdp = ext2_get_group_desc (sb, block_group, &bh2);
- if (gdp) {
- gdp->bg_free_inodes_count =
- cpu_to_le16(le16_to_cpu(gdp->bg_free_inodes_count) + 1);
- if (is_directory)
- gdp->bg_used_dirs_count =
- cpu_to_le16(le16_to_cpu(gdp->bg_used_dirs_count) - 1);
- }
- mark_buffer_dirty(bh2, 1);
- es->s_free_inodes_count =
- cpu_to_le32(le32_to_cpu(es->s_free_inodes_count) + 1);
- mark_buffer_dirty(sb->u.ext2_sb.s_sbh, 1);
- }
- mark_buffer_dirty(bh, 1);
- if (sb->s_flags & MS_SYNCHRONOUS) {
- ll_rw_block (WRITE, 1, &bh);
- wait_on_buffer (bh);
- }
- sb->s_dirt = 1;
-error_return:
- unlock_super (sb);
-}
-
-/*
- * There are two policies for allocating an inode. If the new inode is
- * a directory, then a forward search is made for a block group with both
- * free space and a low directory-to-inode ratio; if that fails, then of
- * the groups with above-average free space, that group with the fewest
- * directories already is chosen.
- *
- * For other inodes, search forward from the parent directory\'s block
- * group to find a free inode.
- */
-struct inode * ext2_new_inode (const struct inode * dir, int mode, int * err)
-{
- struct super_block * sb;
- struct buffer_head * bh;
- struct buffer_head * bh2;
- int i, j, avefreei;
- struct inode * inode;
- int bitmap_nr;
- struct ext2_group_desc * gdp;
- struct ext2_group_desc * tmp;
- struct ext2_super_block * es;
-
- /* Cannot create files in a deleted directory */
- if (!dir || !dir->i_nlink) {
- *err = -EPERM;
- return NULL;
- }
-
- inode = get_empty_inode ();
- if (!inode) {
- *err = -ENOMEM;
- return NULL;
- }
-
- sb = dir->i_sb;
- inode->i_sb = sb;
- inode->i_flags = 0;
- lock_super (sb);
- es = sb->u.ext2_sb.s_es;
-repeat:
- gdp = NULL; i=0;
-
- *err = -ENOSPC;
- if (S_ISDIR(mode)) {
- avefreei = le32_to_cpu(es->s_free_inodes_count) /
- sb->u.ext2_sb.s_groups_count;
-/* I am not yet convinced that this next bit is necessary.
- i = dir->u.ext2_i.i_block_group;
- for (j = 0; j < sb->u.ext2_sb.s_groups_count; j++) {
- tmp = ext2_get_group_desc (sb, i, &bh2);
- if (tmp &&
- (le16_to_cpu(tmp->bg_used_dirs_count) << 8) <
- le16_to_cpu(tmp->bg_free_inodes_count)) {
- gdp = tmp;
- break;
- }
- else
- i = ++i % sb->u.ext2_sb.s_groups_count;
- }
-*/
- if (!gdp) {
- for (j = 0; j < sb->u.ext2_sb.s_groups_count; j++) {
- tmp = ext2_get_group_desc (sb, j, &bh2);
- if (tmp &&
- le16_to_cpu(tmp->bg_free_inodes_count) &&
- le16_to_cpu(tmp->bg_free_inodes_count) >= avefreei) {
- if (!gdp ||
- (le16_to_cpu(tmp->bg_free_blocks_count) >
- le16_to_cpu(gdp->bg_free_blocks_count))) {
- i = j;
- gdp = tmp;
- }
- }
- }
- }
- }
- else
- {
- /*
- * Try to place the inode in its parent directory
- */
- i = dir->u.ext2_i.i_block_group;
- tmp = ext2_get_group_desc (sb, i, &bh2);
- if (tmp && le16_to_cpu(tmp->bg_free_inodes_count))
- gdp = tmp;
- else
- {
- /*
- * Use a quadratic hash to find a group with a
- * free inode
- */
- for (j = 1; j < sb->u.ext2_sb.s_groups_count; j <<= 1) {
- i += j;
- if (i >= sb->u.ext2_sb.s_groups_count)
- i -= sb->u.ext2_sb.s_groups_count;
- tmp = ext2_get_group_desc (sb, i, &bh2);
- if (tmp &&
- le16_to_cpu(tmp->bg_free_inodes_count)) {
- gdp = tmp;
- break;
- }
- }
- }
- if (!gdp) {
- /*
- * That failed: try linear search for a free inode
- */
- i = dir->u.ext2_i.i_block_group + 1;
- for (j = 2; j < sb->u.ext2_sb.s_groups_count; j++) {
- if (++i >= sb->u.ext2_sb.s_groups_count)
- i = 0;
- tmp = ext2_get_group_desc (sb, i, &bh2);
- if (tmp &&
- le16_to_cpu(tmp->bg_free_inodes_count)) {
- gdp = tmp;
- break;
- }
- }
- }
- }
-
- if (!gdp) {
- unlock_super (sb);
- iput(inode);
- return NULL;
- }
- bitmap_nr = load_inode_bitmap (sb, i);
- if (bitmap_nr < 0) {
- unlock_super (sb);
- iput(inode);
- *err = -EIO;
- return NULL;
- }
-
- bh = sb->u.ext2_sb.s_inode_bitmap[bitmap_nr];
- if ((j = ext2_find_first_zero_bit ((unsigned long *) bh->b_data,
- EXT2_INODES_PER_GROUP(sb))) <
- EXT2_INODES_PER_GROUP(sb)) {
- if (ext2_set_bit (j, bh->b_data)) {
- ext2_warning (sb, "ext2_new_inode",
- "bit already set for inode %d", j);
- goto repeat;
- }
- mark_buffer_dirty(bh, 1);
- if (sb->s_flags & MS_SYNCHRONOUS) {
- ll_rw_block (WRITE, 1, &bh);
- wait_on_buffer (bh);
- }
- } else {
- if (le16_to_cpu(gdp->bg_free_inodes_count) != 0) {
- ext2_error (sb, "ext2_new_inode",
- "Free inodes count corrupted in group %d",
- i);
- unlock_super (sb);
- iput (inode);
- return NULL;
- }
- goto repeat;
- }
- j += i * EXT2_INODES_PER_GROUP(sb) + 1;
- if (j < EXT2_FIRST_INO(sb) || j > le32_to_cpu(es->s_inodes_count)) {
- ext2_error (sb, "ext2_new_inode",
- "reserved inode or inode > inodes count - "
- "block_group = %d,inode=%d", i, j);
- unlock_super (sb);
- iput (inode);
- return NULL;
- }
- gdp->bg_free_inodes_count =
- cpu_to_le16(le16_to_cpu(gdp->bg_free_inodes_count) - 1);
- if (S_ISDIR(mode))
- gdp->bg_used_dirs_count =
- cpu_to_le16(le16_to_cpu(gdp->bg_used_dirs_count) + 1);
- mark_buffer_dirty(bh2, 1);
- es->s_free_inodes_count =
- cpu_to_le32(le32_to_cpu(es->s_free_inodes_count) - 1);
- mark_buffer_dirty(sb->u.ext2_sb.s_sbh, 1);
- sb->s_dirt = 1;
- inode->i_mode = mode;
- inode->i_sb = sb;
- inode->i_nlink = 1;
- inode->i_dev = sb->s_dev;
- inode->i_uid = current->fsuid;
- if (test_opt (sb, GRPID))
- inode->i_gid = dir->i_gid;
- else if (dir->i_mode & S_ISGID) {
- inode->i_gid = dir->i_gid;
- if (S_ISDIR(mode))
- mode |= S_ISGID;
- } else
- inode->i_gid = current->fsgid;
-
- inode->i_ino = j;
- inode->i_blksize = PAGE_SIZE; /* This is the optimal IO size (for stat), not the fs block size */
- inode->i_blocks = 0;
- inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
- inode->u.ext2_i.i_new_inode = 1;
- inode->u.ext2_i.i_flags = dir->u.ext2_i.i_flags;
- if (S_ISLNK(mode))
- inode->u.ext2_i.i_flags &= ~(EXT2_IMMUTABLE_FL | EXT2_APPEND_FL);
- inode->u.ext2_i.i_faddr = 0;
- inode->u.ext2_i.i_frag_no = 0;
- inode->u.ext2_i.i_frag_size = 0;
- inode->u.ext2_i.i_file_acl = 0;
- inode->u.ext2_i.i_dir_acl = 0;
- inode->u.ext2_i.i_dtime = 0;
- inode->u.ext2_i.i_block_group = i;
- inode->i_op = NULL;
- if (inode->u.ext2_i.i_flags & EXT2_SYNC_FL)
- inode->i_flags |= MS_SYNCHRONOUS;
- insert_inode_hash(inode);
- inode->i_generation = event++;
- mark_inode_dirty(inode);
-
- unlock_super (sb);
- if(DQUOT_ALLOC_INODE(sb, inode)) {
- sb->dq_op->drop(inode);
- inode->i_nlink = 0;
- iput(inode);
- *err = -EDQUOT;
- return NULL;
- }
- ext2_debug ("allocating inode %lu\n", inode->i_ino);
-
- *err = 0;
- return inode;
-}
-
-unsigned long ext2_count_free_inodes (struct super_block * sb)
-{
-#ifdef EXT2FS_DEBUG
- struct ext2_super_block * es;
- unsigned long desc_count, bitmap_count, x;
- int bitmap_nr;
- struct ext2_group_desc * gdp;
- int i;
-
- lock_super (sb);
- es = sb->u.ext2_sb.s_es;
- desc_count = 0;
- bitmap_count = 0;
- gdp = NULL;
- for (i = 0; i < sb->u.ext2_sb.s_groups_count; i++) {
- gdp = ext2_get_group_desc (sb, i, NULL);
- if (!gdp)
- continue;
- desc_count += le16_to_cpu(gdp->bg_free_inodes_count);
- bitmap_nr = load_inode_bitmap (sb, i);
- if (bitmap_nr < 0)
- continue;
-
- x = ext2_count_free (sb->u.ext2_sb.s_inode_bitmap[bitmap_nr],
- EXT2_INODES_PER_GROUP(sb) / 8);
- printk ("group %d: stored = %d, counted = %lu\n",
- i, le16_to_cpu(gdp->bg_free_inodes_count), x);
- bitmap_count += x;
- }
- printk("ext2_count_free_inodes: stored = %lu, computed = %lu, %lu\n",
- le32_to_cpu(es->s_free_inodes_count), desc_count, bitmap_count);
- unlock_super (sb);
- return desc_count;
-#else
- return le32_to_cpu(sb->u.ext2_sb.s_es->s_free_inodes_count);
-#endif
-}
-
-void ext2_check_inodes_bitmap (struct super_block * sb)
-{
- struct ext2_super_block * es;
- unsigned long desc_count, bitmap_count, x;
- int bitmap_nr;
- struct ext2_group_desc * gdp;
- int i;
-
- lock_super (sb);
- es = sb->u.ext2_sb.s_es;
- desc_count = 0;
- bitmap_count = 0;
- gdp = NULL;
- for (i = 0; i < sb->u.ext2_sb.s_groups_count; i++) {
- gdp = ext2_get_group_desc (sb, i, NULL);
- if (!gdp)
- continue;
- desc_count += le16_to_cpu(gdp->bg_free_inodes_count);
- bitmap_nr = load_inode_bitmap (sb, i);
- if (bitmap_nr < 0)
- continue;
-
- x = ext2_count_free (sb->u.ext2_sb.s_inode_bitmap[bitmap_nr],
- EXT2_INODES_PER_GROUP(sb) / 8);
- if (le16_to_cpu(gdp->bg_free_inodes_count) != x)
- ext2_error (sb, "ext2_check_inodes_bitmap",
- "Wrong free inodes count in group %d, "
- "stored = %d, counted = %lu", i,
- le16_to_cpu(gdp->bg_free_inodes_count), x);
- bitmap_count += x;
- }
- if (le32_to_cpu(es->s_free_inodes_count) != bitmap_count)
- ext2_error (sb, "ext2_check_inodes_bitmap",
- "Wrong free inodes count in super block, "
- "stored = %lu, counted = %lu",
- (unsigned long) le32_to_cpu(es->s_free_inodes_count),
- bitmap_count);
- unlock_super (sb);
-}
diff --git a/sys/gnu/ext2fs/ext2_super.c b/sys/gnu/ext2fs/ext2_super.c
deleted file mode 100644
index 11f99b4dc291..000000000000
--- a/sys/gnu/ext2fs/ext2_super.c
+++ /dev/null
@@ -1,802 +0,0 @@
-/*
- * linux/fs/ext2/super.c
- *
- * Copyright (C) 1992, 1993, 1994, 1995
- * Remy Card (card@masi.ibp.fr)
- * Laboratoire MASI - Institut Blaise Pascal
- * Universite Pierre et Marie Curie (Paris VI)
- *
- * from
- *
- * linux/fs/minix/inode.c
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- *
- * Big-endian to little-endian byte-swapping/bitmaps by
- * David S. Miller (davem@caip.rutgers.edu), 1995
- */
-
-#include <linux/module.h>
-#include <linux/string.h>
-#include <linux/fs.h>
-#include <linux/slab.h>
-#include <linux/init.h>
-#include <linux/locks.h>
-#include <asm/uaccess.h>
-
-
-
-static char error_buf[1024];
-
-void ext2_error (struct super_block * sb, const char * function,
- const char * fmt, ...)
-{
- va_list args;
-
- if (!(sb->s_flags & MS_RDONLY)) {
- sb->u.ext2_sb.s_mount_state |= EXT2_ERROR_FS;
- sb->u.ext2_sb.s_es->s_state =
- cpu_to_le16(le16_to_cpu(sb->u.ext2_sb.s_es->s_state) | EXT2_ERROR_FS);
- mark_buffer_dirty(sb->u.ext2_sb.s_sbh, 1);
- sb->s_dirt = 1;
- }
- va_start (args, fmt);
- vsprintf (error_buf, fmt, args);
- va_end (args);
- if (test_opt (sb, ERRORS_PANIC) ||
- (le16_to_cpu(sb->u.ext2_sb.s_es->s_errors) == EXT2_ERRORS_PANIC &&
- !test_opt (sb, ERRORS_CONT) && !test_opt (sb, ERRORS_RO)))
- panic ("EXT2-fs panic (device %s): %s: %s\n",
- bdevname(sb->s_dev), function, error_buf);
- printk (KERN_CRIT "EXT2-fs error (device %s): %s: %s\n",
- bdevname(sb->s_dev), function, error_buf);
- if (test_opt (sb, ERRORS_RO) ||
- (le16_to_cpu(sb->u.ext2_sb.s_es->s_errors) == EXT2_ERRORS_RO &&
- !test_opt (sb, ERRORS_CONT) && !test_opt (sb, ERRORS_PANIC))) {
- printk ("Remounting filesystem read-only\n");
- sb->s_flags |= MS_RDONLY;
- }
-}
-
-NORET_TYPE void ext2_panic (struct super_block * sb, const char * function,
- const char * fmt, ...)
-{
- va_list args;
-
- if (!(sb->s_flags & MS_RDONLY)) {
- sb->u.ext2_sb.s_mount_state |= EXT2_ERROR_FS;
- sb->u.ext2_sb.s_es->s_state =
- cpu_to_le16(le16_to_cpu(sb->u.ext2_sb.s_es->s_state) | EXT2_ERROR_FS);
- mark_buffer_dirty(sb->u.ext2_sb.s_sbh, 1);
- sb->s_dirt = 1;
- }
- va_start (args, fmt);
- vsprintf (error_buf, fmt, args);
- va_end (args);
- /* this is to prevent panic from syncing this filesystem */
- if (sb->s_lock)
- sb->s_lock=0;
- sb->s_flags |= MS_RDONLY;
- panic ("EXT2-fs panic (device %s): %s: %s\n",
- bdevname(sb->s_dev), function, error_buf);
-}
-
-void ext2_warning (struct super_block * sb, const char * function,
- const char * fmt, ...)
-{
- va_list args;
-
- va_start (args, fmt);
- vsprintf (error_buf, fmt, args);
- va_end (args);
- printk (KERN_WARNING "EXT2-fs warning (device %s): %s: %s\n",
- bdevname(sb->s_dev), function, error_buf);
-}
-
-void ext2_put_super (struct super_block * sb)
-{
- int db_count;
- int i;
-
- if (!(sb->s_flags & MS_RDONLY)) {
- sb->u.ext2_sb.s_es->s_state = le16_to_cpu(sb->u.ext2_sb.s_mount_state);
- mark_buffer_dirty(sb->u.ext2_sb.s_sbh, 1);
- }
- db_count = sb->u.ext2_sb.s_db_per_group;
- for (i = 0; i < db_count; i++)
- if (sb->u.ext2_sb.s_group_desc[i])
- brelse (sb->u.ext2_sb.s_group_desc[i]);
- kfree_s (sb->u.ext2_sb.s_group_desc,
- db_count * sizeof (struct buffer_head *));
- for (i = 0; i < EXT2_MAX_GROUP_LOADED; i++)
- if (sb->u.ext2_sb.s_inode_bitmap[i])
- brelse (sb->u.ext2_sb.s_inode_bitmap[i]);
- for (i = 0; i < EXT2_MAX_GROUP_LOADED; i++)
- if (sb->u.ext2_sb.s_block_bitmap[i])
- brelse (sb->u.ext2_sb.s_block_bitmap[i]);
- brelse (sb->u.ext2_sb.s_sbh);
-
- MOD_DEC_USE_COUNT;
- return;
-}
-
-static struct super_operations ext2_sops = {
- ext2_read_inode,
- ext2_write_inode,
- ext2_put_inode,
- ext2_delete_inode,
- NULL,
- ext2_put_super,
- ext2_write_super,
- ext2_statfs,
- ext2_remount
-};
-
-/*
- * This function has been shamelessly adapted from the msdos fs
- */
-static int parse_options (char * options, unsigned long * sb_block,
- unsigned short *resuid, unsigned short * resgid,
- unsigned long * mount_options)
-{
- char * this_char;
- char * value;
-
- if (!options)
- return 1;
- for (this_char = strtok (options, ",");
- this_char != NULL;
- this_char = strtok (NULL, ",")) {
- if ((value = strchr (this_char, '=')) != NULL)
- *value++ = 0;
- if (!strcmp (this_char, "bsddf"))
- clear_opt (*mount_options, MINIX_DF);
- else if (!strcmp (this_char, "check")) {
- if (!value || !*value)
- set_opt (*mount_options, CHECK_NORMAL);
- else if (!strcmp (value, "none")) {
- clear_opt (*mount_options, CHECK_NORMAL);
- clear_opt (*mount_options, CHECK_STRICT);
- }
- else if (!strcmp (value, "normal"))
- set_opt (*mount_options, CHECK_NORMAL);
- else if (!strcmp (value, "strict")) {
- set_opt (*mount_options, CHECK_NORMAL);
- set_opt (*mount_options, CHECK_STRICT);
- }
- else {
- printk ("EXT2-fs: Invalid check option: %s\n",
- value);
- return 0;
- }
- }
- else if (!strcmp (this_char, "debug"))
- set_opt (*mount_options, DEBUG);
- else if (!strcmp (this_char, "errors")) {
- if (!value || !*value) {
- printk ("EXT2-fs: the errors option requires "
- "an argument");
- return 0;
- }
- if (!strcmp (value, "continue")) {
- clear_opt (*mount_options, ERRORS_RO);
- clear_opt (*mount_options, ERRORS_PANIC);
- set_opt (*mount_options, ERRORS_CONT);
- }
- else if (!strcmp (value, "remount-ro")) {
- clear_opt (*mount_options, ERRORS_CONT);
- clear_opt (*mount_options, ERRORS_PANIC);
- set_opt (*mount_options, ERRORS_RO);
- }
- else if (!strcmp (value, "panic")) {
- clear_opt (*mount_options, ERRORS_CONT);
- clear_opt (*mount_options, ERRORS_RO);
- set_opt (*mount_options, ERRORS_PANIC);
- }
- else {
- printk ("EXT2-fs: Invalid errors option: %s\n",
- value);
- return 0;
- }
- }
- else if (!strcmp (this_char, "grpid") ||
- !strcmp (this_char, "bsdgroups"))
- set_opt (*mount_options, GRPID);
- else if (!strcmp (this_char, "minixdf"))
- set_opt (*mount_options, MINIX_DF);
- else if (!strcmp (this_char, "nocheck")) {
- clear_opt (*mount_options, CHECK_NORMAL);
- clear_opt (*mount_options, CHECK_STRICT);
- }
- else if (!strcmp (this_char, "nogrpid") ||
- !strcmp (this_char, "sysvgroups"))
- clear_opt (*mount_options, GRPID);
- else if (!strcmp (this_char, "resgid")) {
- if (!value || !*value) {
- printk ("EXT2-fs: the resgid option requires "
- "an argument");
- return 0;
- }
- *resgid = simple_strtoul (value, &value, 0);
- if (*value) {
- printk ("EXT2-fs: Invalid resgid option: %s\n",
- value);
- return 0;
- }
- }
- else if (!strcmp (this_char, "resuid")) {
- if (!value || !*value) {
- printk ("EXT2-fs: the resuid option requires "
- "an argument");
- return 0;
- }
- *resuid = simple_strtoul (value, &value, 0);
- if (*value) {
- printk ("EXT2-fs: Invalid resuid option: %s\n",
- value);
- return 0;
- }
- }
- else if (!strcmp (this_char, "sb")) {
- if (!value || !*value) {
- printk ("EXT2-fs: the sb option requires "
- "an argument");
- return 0;
- }
- *sb_block = simple_strtoul (value, &value, 0);
- if (*value) {
- printk ("EXT2-fs: Invalid sb option: %s\n",
- value);
- return 0;
- }
- }
- /* Silently ignore the quota options */
- else if (!strcmp (this_char, "grpquota")
- || !strcmp (this_char, "noquota")
- || !strcmp (this_char, "quota")
- || !strcmp (this_char, "usrquota"))
- /* Don't do anything ;-) */ ;
- else {
- printk ("EXT2-fs: Unrecognized mount option %s\n", this_char);
- return 0;
- }
- }
- return 1;
-}
-
-static void ext2_setup_super (struct super_block * sb,
- struct ext2_super_block * es)
-{
- if (le32_to_cpu(es->s_rev_level) > EXT2_MAX_SUPP_REV) {
- printk ("EXT2-fs warning: revision level too high, "
- "forcing read/only mode\n");
- sb->s_flags |= MS_RDONLY;
- }
- if (!(sb->s_flags & MS_RDONLY)) {
- if (!(sb->u.ext2_sb.s_mount_state & EXT2_VALID_FS))
- printk ("EXT2-fs warning: mounting unchecked fs, "
- "running e2fsck is recommended\n");
- else if ((sb->u.ext2_sb.s_mount_state & EXT2_ERROR_FS))
- printk ("EXT2-fs warning: mounting fs with errors, "
- "running e2fsck is recommended\n");
- else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 &&
- le16_to_cpu(es->s_mnt_count) >=
- (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count))
- printk ("EXT2-fs warning: maximal mount count reached, "
- "running e2fsck is recommended\n");
- else if (le32_to_cpu(es->s_checkinterval) &&
- (le32_to_cpu(es->s_lastcheck) + le32_to_cpu(es->s_checkinterval) <= CURRENT_TIME))
- printk ("EXT2-fs warning: checktime reached, "
- "running e2fsck is recommended\n");
- es->s_state = cpu_to_le16(le16_to_cpu(es->s_state) & ~EXT2_VALID_FS);
- if (!(__s16) le16_to_cpu(es->s_max_mnt_count))
- es->s_max_mnt_count = (__s16) cpu_to_le16(EXT2_DFL_MAX_MNT_COUNT);
- es->s_mnt_count=cpu_to_le16(le16_to_cpu(es->s_mnt_count) + 1);
- es->s_mtime = cpu_to_le32(CURRENT_TIME);
- mark_buffer_dirty(sb->u.ext2_sb.s_sbh, 1);
- sb->s_dirt = 1;
- if (test_opt (sb, DEBUG))
- printk ("[EXT II FS %s, %s, bs=%lu, fs=%lu, gc=%lu, "
- "bpg=%lu, ipg=%lu, mo=%04lx]\n",
- EXT2FS_VERSION, EXT2FS_DATE, sb->s_blocksize,
- sb->u.ext2_sb.s_frag_size,
- sb->u.ext2_sb.s_groups_count,
- EXT2_BLOCKS_PER_GROUP(sb),
- EXT2_INODES_PER_GROUP(sb),
- sb->u.ext2_sb.s_mount_opt);
- if (test_opt (sb, CHECK)) {
- ext2_check_blocks_bitmap (sb);
- ext2_check_inodes_bitmap (sb);
- }
- }
-#if 0 /* ibasket's still have unresolved bugs... -DaveM */
-
- /* [T. Schoebel-Theuer] This limit should be maintained on disk.
- * This is just provisionary.
- */
- sb->s_ibasket_max = 100;
-#endif
-}
-
-static int ext2_check_descriptors (struct super_block * sb)
-{
- int i;
- int desc_block = 0;
- unsigned long block = le32_to_cpu(sb->u.ext2_sb.s_es->s_first_data_block);
- struct ext2_group_desc * gdp = NULL;
-
- ext2_debug ("Checking group descriptors");
-
- for (i = 0; i < sb->u.ext2_sb.s_groups_count; i++)
- {
- if ((i % EXT2_DESC_PER_BLOCK(sb)) == 0)
- gdp = (struct ext2_group_desc *) sb->u.ext2_sb.s_group_desc[desc_block++]->b_data;
- if (le32_to_cpu(gdp->bg_block_bitmap) < block ||
- le32_to_cpu(gdp->bg_block_bitmap) >= block + EXT2_BLOCKS_PER_GROUP(sb))
- {
- ext2_error (sb, "ext2_check_descriptors",
- "Block bitmap for group %d"
- " not in group (block %lu)!",
- i, (unsigned long) le32_to_cpu(gdp->bg_block_bitmap));
- return 0;
- }
- if (le32_to_cpu(gdp->bg_inode_bitmap) < block ||
- le32_to_cpu(gdp->bg_inode_bitmap) >= block + EXT2_BLOCKS_PER_GROUP(sb))
- {
- ext2_error (sb, "ext2_check_descriptors",
- "Inode bitmap for group %d"
- " not in group (block %lu)!",
- i, (unsigned long) le32_to_cpu(gdp->bg_inode_bitmap));
- return 0;
- }
- if (le32_to_cpu(gdp->bg_inode_table) < block ||
- le32_to_cpu(gdp->bg_inode_table) + sb->u.ext2_sb.s_itb_per_group >=
- block + EXT2_BLOCKS_PER_GROUP(sb))
- {
- ext2_error (sb, "ext2_check_descriptors",
- "Inode table for group %d"
- " not in group (block %lu)!",
- i, (unsigned long) le32_to_cpu(gdp->bg_inode_table));
- return 0;
- }
- block += EXT2_BLOCKS_PER_GROUP(sb);
- gdp++;
- }
- return 1;
-}
-
-#define log2(n) ffz(~(n))
-
-struct super_block * ext2_read_super (struct super_block * sb, void * data,
- int silent)
-{
- struct buffer_head * bh;
- struct ext2_super_block * es;
- unsigned long sb_block = 1;
- unsigned short resuid = EXT2_DEF_RESUID;
- unsigned short resgid = EXT2_DEF_RESGID;
- unsigned long logic_sb_block = 1;
- unsigned long offset = 0;
- kdev_t dev = sb->s_dev;
- int blocksize = BLOCK_SIZE;
- int hblock;
- int db_count;
- int i, j;
-
- /*
- * See what the current blocksize for the device is, and
- * use that as the blocksize. Otherwise (or if the blocksize
- * is smaller than the default) use the default.
- * This is important for devices that have a hardware
- * sectorsize that is larger than the default.
- */
- blocksize = get_hardblocksize(dev);
- if( blocksize == 0 || blocksize < BLOCK_SIZE )
- {
- blocksize = BLOCK_SIZE;
- }
-
- sb->u.ext2_sb.s_mount_opt = 0;
- set_opt (sb->u.ext2_sb.s_mount_opt, CHECK_NORMAL);
- if (!parse_options ((char *) data, &sb_block, &resuid, &resgid,
- &sb->u.ext2_sb.s_mount_opt)) {
- sb->s_dev = 0;
- return NULL;
- }
-
- MOD_INC_USE_COUNT;
- lock_super (sb);
- set_blocksize (dev, blocksize);
-
- /*
- * If the superblock doesn't start on a sector boundary,
- * calculate the offset. FIXME(eric) this doesn't make sense
- * that we would have to do this.
- */
- if (blocksize != BLOCK_SIZE) {
- logic_sb_block = (sb_block*BLOCK_SIZE) / blocksize;
- offset = (sb_block*BLOCK_SIZE) % blocksize;
- }
-
- if (!(bh = bread (dev, logic_sb_block, blocksize))) {
- sb->s_dev = 0;
- unlock_super (sb);
- printk ("EXT2-fs: unable to read superblock\n");
- MOD_DEC_USE_COUNT;
- return NULL;
- }
- /*
- * Note: s_es must be initialized s_es as soon as possible because
- * some ext2 macro-instructions depend on its value
- */
- es = (struct ext2_super_block *) (((char *)bh->b_data) + offset);
- sb->u.ext2_sb.s_es = es;
- sb->s_magic = le16_to_cpu(es->s_magic);
- if (sb->s_magic != EXT2_SUPER_MAGIC) {
- if (!silent)
- printk ("VFS: Can't find an ext2 filesystem on dev "
- "%s.\n", bdevname(dev));
- failed_mount:
- sb->s_dev = 0;
- unlock_super (sb);
- if (bh)
- brelse(bh);
- MOD_DEC_USE_COUNT;
- return NULL;
- }
- if (le32_to_cpu(es->s_rev_level) > EXT2_GOOD_OLD_REV) {
- if (le32_to_cpu(es->s_feature_incompat) & ~EXT2_FEATURE_INCOMPAT_SUPP) {
- printk("EXT2-fs: %s: couldn't mount because of "
- "unsupported optional features.\n",
- bdevname(dev));
- goto failed_mount;
- }
- if (!(sb->s_flags & MS_RDONLY) &&
- (le32_to_cpu(es->s_feature_ro_compat) & ~EXT2_FEATURE_RO_COMPAT_SUPP)) {
- printk("EXT2-fs: %s: couldn't mount RDWR because of "
- "unsupported optional features.\n",
- bdevname(dev));
- goto failed_mount;
- }
- }
- sb->s_blocksize_bits = le32_to_cpu(sb->u.ext2_sb.s_es->s_log_block_size) + 10;
- sb->s_blocksize = 1 << sb->s_blocksize_bits;
- if (sb->s_blocksize != BLOCK_SIZE &&
- (sb->s_blocksize == 1024 || sb->s_blocksize == 2048 ||
- sb->s_blocksize == 4096)) {
- /*
- * Make sure the blocksize for the filesystem is larger
- * than the hardware sectorsize for the machine.
- */
- hblock = get_hardblocksize(dev);
- if( (hblock != 0)
- && (sb->s_blocksize < hblock) )
- {
- printk("EXT2-fs: blocksize too small for device.\n");
- goto failed_mount;
- }
-
- brelse (bh);
- set_blocksize (dev, sb->s_blocksize);
- logic_sb_block = (sb_block*BLOCK_SIZE) / sb->s_blocksize;
- offset = (sb_block*BLOCK_SIZE) % sb->s_blocksize;
- bh = bread (dev, logic_sb_block, sb->s_blocksize);
- if(!bh) {
- printk("EXT2-fs: Couldn't read superblock on "
- "2nd try.\n");
- goto failed_mount;
- }
- es = (struct ext2_super_block *) (((char *)bh->b_data) + offset);
- sb->u.ext2_sb.s_es = es;
- if (es->s_magic != le16_to_cpu(EXT2_SUPER_MAGIC)) {
- printk ("EXT2-fs: Magic mismatch, very weird !\n");
- goto failed_mount;
- }
- }
- if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV) {
- sb->u.ext2_sb.s_inode_size = EXT2_GOOD_OLD_INODE_SIZE;
- sb->u.ext2_sb.s_first_ino = EXT2_GOOD_OLD_FIRST_INO;
- } else {
- sb->u.ext2_sb.s_inode_size = le16_to_cpu(es->s_inode_size);
- sb->u.ext2_sb.s_first_ino = le32_to_cpu(es->s_first_ino);
- if (sb->u.ext2_sb.s_inode_size != EXT2_GOOD_OLD_INODE_SIZE) {
- printk ("EXT2-fs: unsupported inode size: %d\n",
- sb->u.ext2_sb.s_inode_size);
- goto failed_mount;
- }
- }
- sb->u.ext2_sb.s_feature_compat = le32_to_cpu(es->s_feature_compat);
- sb->u.ext2_sb.s_feature_incompat = le32_to_cpu(es->s_feature_incompat);
- sb->u.ext2_sb.s_feature_ro_compat = le32_to_cpu(es->s_feature_ro_compat);
- sb->u.ext2_sb.s_frag_size = EXT2_MIN_FRAG_SIZE <<
- le32_to_cpu(es->s_log_frag_size);
- if (sb->u.ext2_sb.s_frag_size)
- sb->u.ext2_sb.s_frags_per_block = sb->s_blocksize /
- sb->u.ext2_sb.s_frag_size;
- else
- sb->s_magic = 0;
- sb->u.ext2_sb.s_blocks_per_group = le32_to_cpu(es->s_blocks_per_group);
- sb->u.ext2_sb.s_frags_per_group = le32_to_cpu(es->s_frags_per_group);
- sb->u.ext2_sb.s_inodes_per_group = le32_to_cpu(es->s_inodes_per_group);
- sb->u.ext2_sb.s_inodes_per_block = sb->s_blocksize /
- EXT2_INODE_SIZE(sb);
- sb->u.ext2_sb.s_itb_per_group = sb->u.ext2_sb.s_inodes_per_group /
- sb->u.ext2_sb.s_inodes_per_block;
- sb->u.ext2_sb.s_desc_per_block = sb->s_blocksize /
- sizeof (struct ext2_group_desc);
- sb->u.ext2_sb.s_sbh = bh;
- if (resuid != EXT2_DEF_RESUID)
- sb->u.ext2_sb.s_resuid = resuid;
- else
- sb->u.ext2_sb.s_resuid = le16_to_cpu(es->s_def_resuid);
- if (resgid != EXT2_DEF_RESGID)
- sb->u.ext2_sb.s_resgid = resgid;
- else
- sb->u.ext2_sb.s_resgid = le16_to_cpu(es->s_def_resgid);
- sb->u.ext2_sb.s_mount_state = le16_to_cpu(es->s_state);
- sb->u.ext2_sb.s_addr_per_block_bits =
- log2 (EXT2_ADDR_PER_BLOCK(sb));
- sb->u.ext2_sb.s_desc_per_block_bits =
- log2 (EXT2_DESC_PER_BLOCK(sb));
- if (sb->s_magic != EXT2_SUPER_MAGIC) {
- if (!silent)
- printk ("VFS: Can't find an ext2 filesystem on dev "
- "%s.\n",
- bdevname(dev));
- goto failed_mount;
- }
- if (sb->s_blocksize != bh->b_size) {
- if (!silent)
- printk ("VFS: Unsupported blocksize on dev "
- "%s.\n", bdevname(dev));
- goto failed_mount;
- }
-
- if (sb->s_blocksize != sb->u.ext2_sb.s_frag_size) {
- printk ("EXT2-fs: fragsize %lu != blocksize %lu (not supported yet)\n",
- sb->u.ext2_sb.s_frag_size, sb->s_blocksize);
- goto failed_mount;
- }
-
- if (sb->u.ext2_sb.s_blocks_per_group > sb->s_blocksize * 8) {
- printk ("EXT2-fs: #blocks per group too big: %lu\n",
- sb->u.ext2_sb.s_blocks_per_group);
- goto failed_mount;
- }
- if (sb->u.ext2_sb.s_frags_per_group > sb->s_blocksize * 8) {
- printk ("EXT2-fs: #fragments per group too big: %lu\n",
- sb->u.ext2_sb.s_frags_per_group);
- goto failed_mount;
- }
- if (sb->u.ext2_sb.s_inodes_per_group > sb->s_blocksize * 8) {
- printk ("EXT2-fs: #inodes per group too big: %lu\n",
- sb->u.ext2_sb.s_inodes_per_group);
- goto failed_mount;
- }
-
- sb->u.ext2_sb.s_groups_count = (le32_to_cpu(es->s_blocks_count) -
- le32_to_cpu(es->s_first_data_block) +
- EXT2_BLOCKS_PER_GROUP(sb) - 1) /
- EXT2_BLOCKS_PER_GROUP(sb);
- db_count = (sb->u.ext2_sb.s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) /
- EXT2_DESC_PER_BLOCK(sb);
- sb->u.ext2_sb.s_group_desc = kmalloc (db_count * sizeof (struct buffer_head *), GFP_KERNEL);
- if (sb->u.ext2_sb.s_group_desc == NULL) {
- printk ("EXT2-fs: not enough memory\n");
- goto failed_mount;
- }
- for (i = 0; i < db_count; i++) {
- sb->u.ext2_sb.s_group_desc[i] = bread (dev, logic_sb_block + i + 1,
- sb->s_blocksize);
- if (!sb->u.ext2_sb.s_group_desc[i]) {
- for (j = 0; j < i; j++)
- brelse (sb->u.ext2_sb.s_group_desc[j]);
- kfree_s (sb->u.ext2_sb.s_group_desc,
- db_count * sizeof (struct buffer_head *));
- printk ("EXT2-fs: unable to read group descriptors\n");
- goto failed_mount;
- }
- }
- if (!ext2_check_descriptors (sb)) {
- for (j = 0; j < db_count; j++)
- brelse (sb->u.ext2_sb.s_group_desc[j]);
- kfree_s (sb->u.ext2_sb.s_group_desc,
- db_count * sizeof (struct buffer_head *));
- printk ("EXT2-fs: group descriptors corrupted !\n");
- goto failed_mount;
- }
- for (i = 0; i < EXT2_MAX_GROUP_LOADED; i++) {
- sb->u.ext2_sb.s_inode_bitmap_number[i] = 0;
- sb->u.ext2_sb.s_inode_bitmap[i] = NULL;
- sb->u.ext2_sb.s_block_bitmap_number[i] = 0;
- sb->u.ext2_sb.s_block_bitmap[i] = NULL;
- }
- sb->u.ext2_sb.s_loaded_inode_bitmaps = 0;
- sb->u.ext2_sb.s_loaded_block_bitmaps = 0;
- sb->u.ext2_sb.s_db_per_group = db_count;
- unlock_super (sb);
- /*
- * set up enough so that it can read an inode
- */
- sb->s_dev = dev;
- sb->s_op = &ext2_sops;
- sb->s_root = d_alloc_root(iget(sb, EXT2_ROOT_INO));
- if (!sb->s_root) {
- sb->s_dev = 0;
- for (i = 0; i < db_count; i++)
- if (sb->u.ext2_sb.s_group_desc[i])
- brelse (sb->u.ext2_sb.s_group_desc[i]);
- kfree_s (sb->u.ext2_sb.s_group_desc,
- db_count * sizeof (struct buffer_head *));
- brelse (bh);
- printk ("EXT2-fs: get root inode failed\n");
- MOD_DEC_USE_COUNT;
- return NULL;
- }
- ext2_setup_super (sb, es);
- return sb;
-}
-
-static void ext2_commit_super (struct super_block * sb,
- struct ext2_super_block * es)
-{
- es->s_wtime = cpu_to_le32(CURRENT_TIME);
- mark_buffer_dirty(sb->u.ext2_sb.s_sbh, 1);
- sb->s_dirt = 0;
-}
-
-/*
- * In the second extended file system, it is not necessary to
- * write the super block since we use a mapping of the
- * disk super block in a buffer.
- *
- * However, this function is still used to set the fs valid
- * flags to 0. We need to set this flag to 0 since the fs
- * may have been checked while mounted and e2fsck may have
- * set s_state to EXT2_VALID_FS after some corrections.
- */
-
-void ext2_write_super (struct super_block * sb)
-{
- struct ext2_super_block * es;
-
- if (!(sb->s_flags & MS_RDONLY)) {
- es = sb->u.ext2_sb.s_es;
-
- ext2_debug ("setting valid to 0\n");
-
- if (le16_to_cpu(es->s_state) & EXT2_VALID_FS) {
- es->s_state = cpu_to_le16(le16_to_cpu(es->s_state) & ~EXT2_VALID_FS);
- es->s_mtime = cpu_to_le32(CURRENT_TIME);
- }
- ext2_commit_super (sb, es);
- }
- sb->s_dirt = 0;
-}
-
-int ext2_remount (struct super_block * sb, int * flags, char * data)
-{
- struct ext2_super_block * es;
- unsigned short resuid = sb->u.ext2_sb.s_resuid;
- unsigned short resgid = sb->u.ext2_sb.s_resgid;
- unsigned long new_mount_opt;
- unsigned long tmp;
-
- /*
- * Allow the "check" option to be passed as a remount option.
- */
- new_mount_opt = EXT2_MOUNT_CHECK_NORMAL;
- if (!parse_options (data, &tmp, &resuid, &resgid,
- &new_mount_opt))
- return -EINVAL;
-
- sb->u.ext2_sb.s_mount_opt = new_mount_opt;
- sb->u.ext2_sb.s_resuid = resuid;
- sb->u.ext2_sb.s_resgid = resgid;
- es = sb->u.ext2_sb.s_es;
- if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
- return 0;
- if (*flags & MS_RDONLY) {
- if (le16_to_cpu(es->s_state) & EXT2_VALID_FS ||
- !(sb->u.ext2_sb.s_mount_state & EXT2_VALID_FS))
- return 0;
- /*
- * OK, we are remounting a valid rw partition rdonly, so set
- * the rdonly flag and then mark the partition as valid again.
- */
- es->s_state = cpu_to_le16(sb->u.ext2_sb.s_mount_state);
- es->s_mtime = cpu_to_le32(CURRENT_TIME);
- mark_buffer_dirty(sb->u.ext2_sb.s_sbh, 1);
- sb->s_dirt = 1;
- ext2_commit_super (sb, es);
- }
- else {
- /*
- * Mounting a RDONLY partition read-write, so reread and
- * store the current valid flag. (It may have been changed
- * by e2fsck since we originally mounted the partition.)
- */
- sb->u.ext2_sb.s_mount_state = le16_to_cpu(es->s_state);
- sb->s_flags &= ~MS_RDONLY;
- ext2_setup_super (sb, es);
- }
- return 0;
-}
-
-int ext2_statfs (struct super_block * sb, struct statfs * buf, int bufsiz)
-{
- unsigned long overhead;
- struct statfs tmp;
- int ngroups, i;
-
- if (test_opt (sb, MINIX_DF))
- overhead = 0;
- else {
- /*
- * Compute the overhead (FS structures)
- */
-
- /*
- * All of the blocks before first_data_block are
- * overhead
- */
- overhead = le32_to_cpu(sb->u.ext2_sb.s_es->s_first_data_block);
-
- /*
- * Add the overhead attributed to the superblock and
- * block group descriptors. If this is sparse
- * superblocks is turned on, then not all groups have
- * this.
- */
- if (sb->u.ext2_sb.s_feature_ro_compat &
- EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER) {
- ngroups = 0;
- for (i=0 ; i < sb->u.ext2_sb.s_groups_count; i++)
- if (ext2_group_sparse(i))
- ngroups++;
- } else
- ngroups = sb->u.ext2_sb.s_groups_count;
- overhead += ngroups * (1 + sb->u.ext2_sb.s_db_per_group);
-
- /*
- * Every block group has an inode bitmap, a block
- * bitmap, and an inode table.
- */
- overhead += (sb->u.ext2_sb.s_groups_count *
- (2 + sb->u.ext2_sb.s_itb_per_group));
- }
-
- tmp.f_type = EXT2_SUPER_MAGIC;
- tmp.f_bsize = sb->s_blocksize;
- tmp.f_blocks = le32_to_cpu(sb->u.ext2_sb.s_es->s_blocks_count) - overhead;
- tmp.f_bfree = ext2_count_free_blocks (sb);
- tmp.f_bavail = tmp.f_bfree - le32_to_cpu(sb->u.ext2_sb.s_es->s_r_blocks_count);
- if (tmp.f_bfree < le32_to_cpu(sb->u.ext2_sb.s_es->s_r_blocks_count))
- tmp.f_bavail = 0;
- tmp.f_files = le32_to_cpu(sb->u.ext2_sb.s_es->s_inodes_count);
- tmp.f_ffree = ext2_count_free_inodes (sb);
- tmp.f_namelen = EXT2_NAME_LEN;
- return copy_to_user(buf, &tmp, bufsiz) ? -EFAULT : 0;
-}
-
-static struct file_system_type ext2_fs_type = {
- "ext2",
- FS_REQUIRES_DEV /* | FS_IBASKET */, /* ibaskets have unresolved bugs */
- ext2_read_super,
- NULL
-};
-
-static int __init init_ext2_fs(void)
-{
- return register_filesystem(&ext2_fs_type);
-}
-
-static int __exit exit_ext2_fs(void)
-{
- unregister_filesystem(&ext2_fs_type);
-}
-
-EXPORT_NO_SYMBOLS;
-
-module_init(init_ext2_fs)
-module_exit(exit_ext2_fs)
diff --git a/sys/gnu/ext2fs/i386-bitops.h b/sys/gnu/ext2fs/i386-bitops.h
deleted file mode 100644
index 86068d069773..000000000000
--- a/sys/gnu/ext2fs/i386-bitops.h
+++ /dev/null
@@ -1,235 +0,0 @@
-#ifndef _I386_BITOPS_H
-#define _I386_BITOPS_H
-
-/*
- * Copyright 1992, Linus Torvalds.
- */
-
-/*
- * These have to be done with inline assembly: that way the bit-setting
- * is guaranteed to be atomic. All bit operations return 0 if the bit
- * was cleared before the operation and != 0 if it was not.
- *
- * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
- */
-
-#ifdef __SMP__
-#define LOCK_PREFIX "lock ; "
-#else
-#define LOCK_PREFIX ""
-#endif
-
-/*
- * Function prototypes to keep gcc -Wall happy
- */
-extern void set_bit(int nr, volatile void * addr);
-extern void clear_bit(int nr, volatile void * addr);
-extern void change_bit(int nr, volatile void * addr);
-extern int test_and_set_bit(int nr, volatile void * addr);
-extern int test_and_clear_bit(int nr, volatile void * addr);
-extern int test_and_change_bit(int nr, volatile void * addr);
-extern int __constant_test_bit(int nr, const volatile void * addr);
-extern int __test_bit(int nr, volatile void * addr);
-extern int find_first_zero_bit(void * addr, unsigned size);
-extern int find_next_zero_bit (void * addr, int size, int offset);
-extern unsigned long ffz(unsigned long word);
-
-/*
- * Some hacks to defeat gcc over-optimizations..
- */
-struct __dummy { unsigned long a[100]; };
-#define ADDR (*(volatile struct __dummy *) addr)
-#define CONST_ADDR (*(volatile const struct __dummy *) addr)
-
-extern __inline__ void set_bit(int nr, volatile void * addr)
-{
- __asm__ __volatile__( LOCK_PREFIX
- "btsl %1,%0"
- :"=m" (ADDR)
- :"Ir" (nr));
-}
-
-extern __inline__ void clear_bit(int nr, volatile void * addr)
-{
- __asm__ __volatile__( LOCK_PREFIX
- "btrl %1,%0"
- :"=m" (ADDR)
- :"Ir" (nr));
-}
-
-extern __inline__ void change_bit(int nr, volatile void * addr)
-{
- __asm__ __volatile__( LOCK_PREFIX
- "btcl %1,%0"
- :"=m" (ADDR)
- :"Ir" (nr));
-}
-
-extern __inline__ int test_and_set_bit(int nr, volatile void * addr)
-{
- int oldbit;
-
- __asm__ __volatile__( LOCK_PREFIX
- "btsl %2,%1\n\tsbbl %0,%0"
- :"=r" (oldbit),"=m" (ADDR)
- :"Ir" (nr));
- return oldbit;
-}
-
-extern __inline__ int test_and_clear_bit(int nr, volatile void * addr)
-{
- int oldbit;
-
- __asm__ __volatile__( LOCK_PREFIX
- "btrl %2,%1\n\tsbbl %0,%0"
- :"=r" (oldbit),"=m" (ADDR)
- :"Ir" (nr));
- return oldbit;
-}
-
-extern __inline__ int test_and_change_bit(int nr, volatile void * addr)
-{
- int oldbit;
-
- __asm__ __volatile__( LOCK_PREFIX
- "btcl %2,%1\n\tsbbl %0,%0"
- :"=r" (oldbit),"=m" (ADDR)
- :"Ir" (nr));
- return oldbit;
-}
-
-/*
- * This routine doesn't need to be atomic.
- */
-extern __inline__ int __constant_test_bit(int nr, const volatile void * addr)
-{
- return ((1UL << (nr & 31)) & (((const volatile unsigned int *) addr)[nr >> 5])) != 0;
-}
-
-extern __inline__ int __test_bit(int nr, volatile void * addr)
-{
- int oldbit;
-
- __asm__ __volatile__(
- "btl %2,%1\n\tsbbl %0,%0"
- :"=r" (oldbit)
- :"m" (ADDR),"Ir" (nr));
- return oldbit;
-}
-
-#define test_bit(nr,addr) \
-(__builtin_constant_p(nr) ? \
- __constant_test_bit((nr),(addr)) : \
- __test_bit((nr),(addr)))
-
-/*
- * Find-bit routines..
- */
-extern __inline__ int find_first_zero_bit(void * addr, unsigned size)
-{
- int d0, d1, d2;
- int res;
-
- if (!size)
- return 0;
- __asm__("movl $-1,%%eax\n\t"
- "xorl %%edx,%%edx\n\t"
- "repe; scasl\n\t"
- "je 1f\n\t"
- "xorl -4(%%edi),%%eax\n\t"
- "subl $4,%%edi\n\t"
- "bsfl %%eax,%%edx\n"
- "1:\tsubl %%ebx,%%edi\n\t"
- "shll $3,%%edi\n\t"
- "addl %%edi,%%edx"
- :"=d" (res), "=&c" (d0), "=&D" (d1), "=&a" (d2)
- :"1" ((size + 31) >> 5), "2" (addr), "b" (addr));
- return res;
-}
-
-extern __inline__ int find_next_zero_bit (void * addr, int size, int offset)
-{
- unsigned long * p = ((unsigned long *) addr) + (offset >> 5);
- int set = 0, bit = offset & 31, res;
-
- if (bit) {
- /*
- * Look for zero in first byte
- */
- __asm__("bsfl %1,%0\n\t"
- "jne 1f\n\t"
- "movl $32, %0\n"
- "1:"
- : "=r" (set)
- : "r" (~(*p >> bit)));
- if (set < (32 - bit))
- return set + offset;
- set = 32 - bit;
- p++;
- }
- /*
- * No zero yet, search remaining full bytes for a zero
- */
- res = find_first_zero_bit (p, size - 32 * (p - (unsigned long *) addr));
- return (offset + set + res);
-}
-
-/*
- * ffz = Find First Zero in word. Undefined if no zero exists,
- * so code should check against ~0UL first..
- */
-extern __inline__ unsigned long ffz(unsigned long word)
-{
- __asm__("bsfl %1,%0"
- :"=r" (word)
- :"r" (~word));
- return word;
-}
-
-#ifdef __KERNEL__
-
-/*
- * ffs: find first bit set. This is defined the same way as
- * the libc and compiler builtin ffs routines, therefore
- * differs in spirit from the above ffz (man ffs).
- */
-
-extern __inline__ int ffs(int x)
-{
- int r;
-
- __asm__("bsfl %1,%0\n\t"
- "jnz 1f\n\t"
- "movl $-1,%0\n"
- "1:" : "=r" (r) : "g" (x));
- return r+1;
-}
-
-/*
- * hweightN: returns the hamming weight (i.e. the number
- * of bits set) of a N-bit word
- */
-
-#define hweight32(x) generic_hweight32(x)
-#define hweight16(x) generic_hweight16(x)
-#define hweight8(x) generic_hweight8(x)
-
-#endif /* __KERNEL__ */
-
-#ifdef __KERNEL__
-
-#define ext2_set_bit test_and_set_bit
-#define ext2_clear_bit test_and_clear_bit
-#define ext2_test_bit test_bit
-#define ext2_find_first_zero_bit find_first_zero_bit
-#define ext2_find_next_zero_bit find_next_zero_bit
-
-/* Bitmap functions for the minix filesystem. */
-#define minix_set_bit(nr,addr) test_and_set_bit(nr,addr)
-#define minix_clear_bit(nr,addr) test_and_clear_bit(nr,addr)
-#define minix_test_bit(nr,addr) test_bit(nr,addr)
-#define minix_find_first_zero_bit(addr,size) find_first_zero_bit(addr,size)
-
-#endif /* __KERNEL__ */
-
-#endif /* _I386_BITOPS_H */