The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/fs/ext2fs/fs.h

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  *  modified for EXT2FS support in Lites 1.1
    3  *
    4  *  Aug 1995, Godmar Back (gback@cs.utah.edu)
    5  *  University of Utah, Department of Computer Science
    6  */
    7 /*-
    8  * Copyright (c) 1982, 1986, 1993
    9  *      The Regents of the University of California.  All rights reserved.
   10  *
   11  * Redistribution and use in source and binary forms, with or without
   12  * modification, are permitted provided that the following conditions
   13  * are met:
   14  * 1. Redistributions of source code must retain the above copyright
   15  *    notice, this list of conditions and the following disclaimer.
   16  * 2. Redistributions in binary form must reproduce the above copyright
   17  *    notice, this list of conditions and the following disclaimer in the
   18  *    documentation and/or other materials provided with the distribution.
   19  * 4. Neither the name of the University nor the names of its contributors
   20  *    may be used to endorse or promote products derived from this software
   21  *    without specific prior written permission.
   22  *
   23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   33  * SUCH DAMAGE.
   34  *
   35  *      @(#)fs.h        8.7 (Berkeley) 4/19/94
   36  * $FreeBSD: releng/9.1/sys/fs/ext2fs/fs.h 229549 2012-01-05 01:35:01Z pfg $
   37  */
   38 
   39 #ifndef _FS_EXT2FS_FS_H_
   40 #define _FS_EXT2FS_FS_H_
   41 
   42 /*
   43  * Each disk drive contains some number of file systems.
   44  * A file system consists of a number of cylinder groups.
   45  * Each cylinder group has inodes and data.
   46  *
   47  * A file system is described by its super-block, which in turn
   48  * describes the cylinder groups.  The super-block is critical
   49  * data and is replicated in each cylinder group to protect against
   50  * catastrophic loss.  This is done at `newfs' time and the critical
   51  * super-block data does not change, so the copies need not be
   52  * referenced further unless disaster strikes.
   53  *
   54  * The first boot and super blocks are given in absolute disk addresses.
   55  * The byte-offset forms are preferred, as they don't imply a sector size.
   56  */
   57 #define SBSIZE          1024
   58 #define SBLOCK          2
   59 
   60 /*
   61  * The path name on which the file system is mounted is maintained
   62  * in fs_fsmnt. MAXMNTLEN defines the amount of space allocated in 
   63  * the super block for this name. 
   64  */
   65 #define MAXMNTLEN       512
   66 
   67 /*
   68  * Grigoriy Orlov <gluk@ptci.ru> has done some extensive work to fine
   69  * tune the layout preferences for directories within a filesystem.
   70  * His algorithm can be tuned by adjusting the following parameters
   71  * which tell the system the average file size and the average number
   72  * of files per directory. These defaults are well selected for typical
   73  * filesystems, but may need to be tuned for odd cases like filesystems
   74  * being used for squid caches or news spools.
   75  * AVFPDIR is the expected number of files per directory. AVGDIRSIZE is 
   76  * obtained by multiplying AVFPDIR and AVFILESIZ which is assumed to be 
   77  * 16384.
   78  */
   79 
   80 #define AFPDIR          64
   81 #define AVGDIRSIZE      1048576
   82 
   83 /*
   84  * Macros for access to superblock array structures
   85  */
   86 
   87 /*
   88  * Turn file system block numbers into disk block addresses.
   89  * This maps file system blocks to device size blocks.
   90  */
   91 #define fsbtodb(fs, b)  ((b) << ((fs)->e2fs_fsbtodb))
   92 #define dbtofsb(fs, b)  ((b) >> ((fs)->e2fs_fsbtodb))
   93 
   94 /* get group containing inode */
   95 #define ino_to_cg(fs, x)        (((x) - 1) / (fs->e2fs_ipg))
   96 
   97 /* get block containing inode from its number x */
   98 #define ino_to_fsba(fs, x)                                              \
   99         ((fs)->e2fs_gd[ino_to_cg((fs), (x))].ext2bgd_i_tables +         \
  100         (((x) - 1) % (fs)->e2fs->e2fs_ipg) / (fs)->e2fs_ipb)
  101 
  102 /* get offset for inode in block */
  103 #define ino_to_fsbo(fs, x)      ((x-1) % (fs->e2fs_ipb))
  104 
  105 /*
  106  * Give cylinder group number for a file system block.
  107  * Give cylinder group block number for a file system block.
  108  */
  109 #define dtog(fs, d)     (((d) - fs->e2fs->e2fs_first_dblock) / \
  110                         EXT2_BLOCKS_PER_GROUP(fs))
  111 #define dtogd(fs, d)    (((d) - fs->e2fs->e2fs_first_dblock) % \
  112                         EXT2_BLOCKS_PER_GROUP(fs))
  113 
  114 /*
  115  * The following macros optimize certain frequently calculated
  116  * quantities by using shifts and masks in place of divisions
  117  * modulos and multiplications.
  118  */
  119 #define blkoff(fs, loc)         /* calculates (loc % fs->fs_bsize) */ \
  120         ((loc) & (fs)->e2fs_qbmask)
  121 
  122 #define lblktosize(fs, blk)     /* calculates (blk * fs->fs_bsize) */ \
  123         ((blk) << (fs->e2fs_bshift))
  124 
  125 #define lblkno(fs, loc)         /* calculates (loc / fs->fs_bsize) */ \
  126         ((loc) >> (fs->e2fs_bshift))
  127 
  128 /* no fragments -> logical block number equal # of frags */
  129 #define numfrags(fs, loc)       /* calculates (loc / fs->fs_fsize) */ \
  130         ((loc) >> (fs->e2fs_bshift))
  131 
  132 #define fragroundup(fs, size)   /* calculates roundup(size, fs->fs_fsize) */ \
  133         roundup(size, fs->e2fs_fsize)
  134         /* was (((size) + (fs)->fs_qfmask) & (fs)->fs_fmask) */
  135 
  136 /*
  137  * Determining the size of a file block in the file system.
  138  * easy w/o fragments
  139  */
  140 #define blksize(fs, ip, lbn) ((fs)->e2fs_fsize)
  141 
  142 /*
  143  * INOPB is the number of inodes in a secondary storage block.
  144  */
  145 #define INOPB(fs)       (fs->e2fs_ipb)
  146 
  147 /*
  148  * NINDIR is the number of indirects in a file system block.
  149  */
  150 #define NINDIR(fs)      (EXT2_ADDR_PER_BLOCK(fs))
  151 
  152 extern int inside[], around[];
  153 extern u_char *fragtbl[];
  154 
  155 #endif /* !_FS_EXT2FS_FS_H_ */

Cache object: cd096d25e57404ddc7493c0b134944c0


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.