3636// 28 Jun 2001 Bugfix: getcwd differs for Solaris/GNU [email protected] 3737// 8 Mar 2002 Bugfix: endianness swap of x-indirects
3838// 23 Mar 2002 Bugfix: test for IFCHR or IFBLK was flawed
39- // 10 Oct 2002 Added comments,makefile targets, [email protected] 40- // endianess swap assert check.
39+ // 10 Oct 2002 Added comments,makefile targets, [email protected] 40+ // endianess swap assert check.
4141// Copyright (C) 2002 Ixia communications
4242// 12 Oct 2002 Added support for triple indirection [email protected] 4343// Copyright (C) 2002 Ixia communications
4444// 14 Oct 2002 Added support for groups [email protected] 4545// Copyright (C) 2002 Ixia communications
4646// 5 Jan 2003 Bugfixes: reserved inodes should be set [email protected] 4747// only in the first group; directory names
48- // need to be null padded at the end; and
49- // number of blocks per group should be a
50- // multiple of 8. Updated md5 values.
48+ // need to be null padded at the end; and
49+ // number of blocks per group should be a
50+ // multiple of 8. Updated md5 values.
5151// 6 Jan 2003 Erik Andersen <[email protected] > added 5252// mkfs.jffs2 compatible device table support,
5353// along with -q, -P, -U
@@ -255,7 +255,7 @@ static int blocksize = 1024;
255255
256256// Get group inode bitmap (ibm) given the group number
257257#define GRP_GET_GROUP_IBM (fs ,grp ) ( get_blk((fs), get_gd((fs),(grp))->bg_inode_bitmap) )
258-
258+
259259// Given an inode number find the group it belongs to
260260#define GRP_GROUP_OF_INODE (fs ,nod ) ( ((nod)-1) / (fs)->sb.s_inodes_per_group)
261261
@@ -269,7 +269,7 @@ static int blocksize = 1024;
269269
270270// Given a block number find the group it belongs to
271271#define GRP_GROUP_OF_BLOCK (fs ,blk ) ( ((blk)-1) / (fs)->sb.s_blocks_per_group)
272-
272+
273273//Given a block number get the block bitmap that covers it
274274#define GRP_GET_BLOCK_BITMAP (fs ,blk ) \
275275 ( GRP_GET_GROUP_BBM((fs),GRP_GROUP_OF_BLOCK((fs),(blk))) )
@@ -330,14 +330,14 @@ portable_snprintf(char *str, size_t n, const char *fmt, ...)
330330// on pipes etc. However, add2fs_from_file() only calls getline() for
331331// regular files, so a larger rchunk and backward seeks are okay.
332332
333- ssize_t
333+ ssize_t
334334getdelim (char * * lineptr , size_t * n , int delim , FILE * stream )
335335{
336336 char * p ; // reads stored here
337337 size_t const rchunk = 512 ; // number of bytes to read
338338 size_t const mchunk = 512 ; // number of extra bytes to malloc
339339 size_t m = rchunk + 1 ; // initial buffer size
340-
340+
341341 if (* lineptr ) {
342342 if (* n < m ) {
343343 * lineptr = (char * )realloc (* lineptr , m );
@@ -548,17 +548,17 @@ typedef uint8 *block;
548548
549549/* blockwalker fields:
550550 The blockwalker is used to access all the blocks of a file (including
551- the indirection blocks) through repeated calls to walk_bw.
552-
551+ the indirection blocks) through repeated calls to walk_bw.
552+
553553 bpdir -> index into the inode->i_block[]. Indicates level of indirection.
554554 bnum -> total number of blocks so far accessed. including indirection
555555 blocks.
556556 bpind,bpdind,bptind -> index into indirection blocks.
557-
557+
558558 bpind, bpdind, bptind do *NOT* index into single, double and triple
559- indirect blocks resp. as you might expect from their names. Instead
559+ indirect blocks resp. as you might expect from their names. Instead
560560 they are in order the 1st, 2nd & 3rd index to be used
561-
561+
562562 As an example..
563563 To access data block number 70000:
564564 bpdir: 15 (we are doing triple indirection)
@@ -567,11 +567,11 @@ typedef uint8 *block;
567567 bptind: 99 ( index into the single indirection block)
568568 70000 = 12 + 256 + 256*256 + 16*256 + 100 (indexing starts from zero)
569569
570- So,for double indirection bpind will index into the double indirection
570+ So,for double indirection bpind will index into the double indirection
571571 block and bpdind into the single indirection block. For single indirection
572572 only bpind will be used.
573573*/
574-
574+
575575typedef struct
576576{
577577 uint32 bnum ;
@@ -616,7 +616,7 @@ struct hdlink_s
616616 uint32 dst_nod ;
617617};
618618
619- struct hdlinks_s
619+ struct hdlinks_s
620620{
621621 int32 count ;
622622 struct hdlink_s * hdl ;
@@ -937,7 +937,7 @@ alloc_nod(filesystem *fs)
937937 if (get_gd (fs , grp )-> bg_free_inodes_count < avefreei ||
938938 get_gd (fs , grp )-> bg_free_inodes_count == 0 )
939939 continue ;
940- if (!best_group ||
940+ if (!best_group ||
941941 get_gd (fs , grp )-> bg_free_blocks_count > get_gd (fs , best_group )-> bg_free_blocks_count )
942942 best_group = grp ;
943943 }
@@ -997,7 +997,7 @@ walk_bw(filesystem *fs, uint32 nod, blockwalker *bw, int32 *create, uint32 hole)
997997 (* create )-- ;
998998 extend = 1 ;
999999 }
1000- else
1000+ else
10011001 return WALK_END ;
10021002 }
10031003 // first direct block
@@ -1104,7 +1104,7 @@ walk_bw(filesystem *fs, uint32 nod, blockwalker *bw, int32 *create, uint32 hole)
11041104 /* Just starting triple indirection. Allocate the indirection
11051105 blocks and the first data block
11061106 */
1107- else if (bw -> bpdir == EXT2_DIND_BLOCK )
1107+ else if (bw -> bpdir == EXT2_DIND_BLOCK )
11081108 {
11091109 bw -> bnum += 3 ;
11101110 bw -> bpdir = EXT2_TIND_BLOCK ;
@@ -1135,7 +1135,7 @@ walk_bw(filesystem *fs, uint32 nod, blockwalker *bw, int32 *create, uint32 hole)
11351135 /* Still processing a single indirect block down the indirection
11361136 chain.Allocate a data block for it
11371137 */
1138- else if ( (bw -> bpdir == EXT2_TIND_BLOCK ) &&
1138+ else if ( (bw -> bpdir == EXT2_TIND_BLOCK ) &&
11391139 (bw -> bptind < BLOCKSIZE /4 - 1 ) )
11401140 {
11411141 bw -> bptind ++ ;
@@ -1148,7 +1148,7 @@ walk_bw(filesystem *fs, uint32 nod, blockwalker *bw, int32 *create, uint32 hole)
11481148 if (reduce ) // free block
11491149 free_blk (fs , * bkref );
11501150 }
1151- /* Finished processing a single indirect block. But still in the
1151+ /* Finished processing a single indirect block. But still in the
11521152 same double indirect block. Allocate new single indirect block
11531153 for it and a data block
11541154 */
@@ -1174,7 +1174,7 @@ walk_bw(filesystem *fs, uint32 nod, blockwalker *bw, int32 *create, uint32 hole)
11741174 /* Finished processing a double indirect block. Allocate the next
11751175 double indirect block and the single,data blocks for it
11761176 */
1177- else if ( (bw -> bpdir == EXT2_TIND_BLOCK ) &&
1177+ else if ( (bw -> bpdir == EXT2_TIND_BLOCK ) &&
11781178 (bw -> bpind < BLOCKSIZE /4 - 1 ) )
11791179 {
11801180 bw -> bnum += 2 ;
@@ -1199,7 +1199,7 @@ walk_bw(filesystem *fs, uint32 nod, blockwalker *bw, int32 *create, uint32 hole)
11991199 free_blk (fs , * bkref );
12001200 }
12011201 else
1202- error_msg_and_die ("file too big !" );
1202+ error_msg_and_die ("file too big !" );
12031203 /* End change for walking triple indirection */
12041204
12051205 if (* bkref )
@@ -1502,7 +1502,7 @@ get_mode(struct stat *st)
15021502 <path> <type> <mode> <uid> <gid> <major> <minor> <start> <inc> <count>
15031503 /dev/mem c 640 0 0 1 1 0 0 -
15041504
1505- type can be one of:
1505+ type can be one of:
15061506 f A regular file
15071507 d Directory
15081508 c Character special device file
@@ -1649,7 +1649,7 @@ add2fs_from_file(filesystem *fs, uint32 this_nod, FILE * fh, uint32 fs_timestamp
16491649 }
16501650 if (line )
16511651 free (line );
1652- if (path )
1652+ if (path )
16531653 free (path );
16541654 if (path2 )
16551655 free (path2 );
@@ -1771,7 +1771,7 @@ add2fs_from_dir(filesystem *fs, uint32 this_nod, int squash_uids, int squash_per
17711771 }
17721772 if (save_nod ) {
17731773 if (hdlinks .count == hdlink_cnt ) {
1774- if ((hdlinks .hdl =
1774+ if ((hdlinks .hdl =
17751775 realloc (hdlinks .hdl , (hdlink_cnt + HDLINK_CNT ) *
17761776 sizeof (struct hdlink_s ))) == NULL ) {
17771777 error_msg_and_die ("Not enough memory" );
@@ -1827,12 +1827,12 @@ swap_goodblocks(filesystem *fs, inode *nod)
18271827 /* Adding support for triple indirection */
18281828 b = (uint32 * )get_blk (fs ,nod -> i_block [EXT2_TIND_BLOCK ]);
18291829 for (i = 0 ;i < BLOCKSIZE /4 && !done ; i ++ ) {
1830- b2 = (uint32 * )get_blk (fs ,b [i ]);
1830+ b2 = (uint32 * )get_blk (fs ,b [i ]);
18311831 for (j = 0 ; j < BLOCKSIZE /4 ;j ++ ) {
1832- if (nblk > ( EXT2_IND_BLOCK + BLOCKSIZE /4 +
1833- (BLOCKSIZE /4 )* (BLOCKSIZE /4 ) +
1834- i * (BLOCKSIZE /4 )* (BLOCKSIZE /4 ) +
1835- j * (BLOCKSIZE /4 )) )
1832+ if (nblk > ( EXT2_IND_BLOCK + BLOCKSIZE /4 +
1833+ (BLOCKSIZE /4 )* (BLOCKSIZE /4 ) +
1834+ i * (BLOCKSIZE /4 )* (BLOCKSIZE /4 ) +
1835+ j * (BLOCKSIZE /4 )) )
18361836 swap_block (get_blk (fs ,b2 [j ]));
18371837 else {
18381838 done = 1 ;
@@ -1873,13 +1873,13 @@ swap_badblocks(filesystem *fs, inode *nod)
18731873 b = (uint32 * )get_blk (fs ,nod -> i_block [EXT2_TIND_BLOCK ]);
18741874 swap_block ((uint8 * )b );
18751875 for (i = 0 ;i < BLOCKSIZE /4 && !done ; i ++ ) {
1876- b2 = (uint32 * )get_blk (fs ,b [i ]);
1876+ b2 = (uint32 * )get_blk (fs ,b [i ]);
18771877 swap_block ((uint8 * )b2 );
18781878 for (j = 0 ; j < BLOCKSIZE /4 ;j ++ ) {
1879- if (nblk > ( EXT2_IND_BLOCK + BLOCKSIZE /4 +
1880- (BLOCKSIZE /4 )* (BLOCKSIZE /4 ) +
1881- i * (BLOCKSIZE /4 )* (BLOCKSIZE /4 ) +
1882- j * (BLOCKSIZE /4 )) )
1879+ if (nblk > ( EXT2_IND_BLOCK + BLOCKSIZE /4 +
1880+ (BLOCKSIZE /4 )* (BLOCKSIZE /4 ) +
1881+ i * (BLOCKSIZE /4 )* (BLOCKSIZE /4 ) +
1882+ j * (BLOCKSIZE /4 )) )
18831883 swap_block (get_blk (fs ,b2 [j ]));
18841884 else {
18851885 done = 1 ;
@@ -1965,7 +1965,7 @@ init_fs(int nbblocks, int nbinodes, int nbresrvd, int holes,
19651965 uint32 j ;
19661966 uint8 * bbm ,* ibm ;
19671967 inode * itab0 ;
1968-
1968+
19691969 if (nbresrvd < 0 )
19701970 error_msg_and_die ("reserved blocks value is invalid. Note: options have changed, see --help or the man page." );
19711971 if (nbinodes < EXT2_FIRST_INO - 1 + (nbresrvd ? 1 : 0 ))
@@ -2056,10 +2056,10 @@ init_fs(int nbblocks, int nbinodes, int nbresrvd, int holes,
20562056 //non-filesystem blocks
20572057 for (j = get_gd (fs , i )-> bg_free_blocks_count
20582058 + overhead_per_group + 1 ; j <= BLOCKSIZE * 8 ; j ++ )
2059- allocate (bbm , j );
2059+ allocate (bbm , j );
20602060 //system blocks
20612061 for (j = 1 ; j <= overhead_per_group ; j ++ )
2062- allocate (bbm , j );
2062+ allocate (bbm , j );
20632063
20642064 /* Inode bitmap */
20652065 ibm = GRP_GET_GROUP_IBM (fs , i );
@@ -2079,7 +2079,7 @@ init_fs(int nbblocks, int nbinodes, int nbresrvd, int holes,
20792079 get_gd (fs , 0 )-> bg_free_inodes_count -- ;
20802080 get_gd (fs , 0 )-> bg_used_dirs_count = 1 ;
20812081 itab0 = (inode * )get_blk (fs , get_gd (fs ,0 )-> bg_inode_table );
2082- itab0 [EXT2_ROOT_INO - 1 ].i_mode = FM_IFDIR | FM_IRWXU | FM_IRGRP | FM_IROTH | FM_IXGRP | FM_IXOTH ;
2082+ itab0 [EXT2_ROOT_INO - 1 ].i_mode = FM_IFDIR | FM_IRWXU | FM_IRGRP | FM_IROTH | FM_IXGRP | FM_IXOTH ;
20832083 itab0 [EXT2_ROOT_INO - 1 ].i_ctime = fs_timestamp ;
20842084 itab0 [EXT2_ROOT_INO - 1 ].i_mtime = fs_timestamp ;
20852085 itab0 [EXT2_ROOT_INO - 1 ].i_atime = fs_timestamp ;
@@ -2109,7 +2109,7 @@ init_fs(int nbblocks, int nbinodes, int nbresrvd, int holes,
21092109 /* We run into problems with e2fsck if directory lost+found grows
21102110 * bigger than this. Need to find out why this happens - sundar
21112111 */
2112- if (fs -> sb .s_r_blocks_count > fs -> sb .s_blocks_count * MAX_RESERVED_BLOCKS )
2112+ if (fs -> sb .s_r_blocks_count > fs -> sb .s_blocks_count * MAX_RESERVED_BLOCKS )
21132113 fs -> sb .s_r_blocks_count = fs -> sb .s_blocks_count * MAX_RESERVED_BLOCKS ;
21142114 for (i = 1 ; i < fs -> sb .s_r_blocks_count ; i ++ )
21152115 extend_blk (fs , nod , b , 1 );
@@ -2124,7 +2124,7 @@ init_fs(int nbblocks, int nbinodes, int nbresrvd, int holes,
21242124 // options for me
21252125 if (holes )
21262126 fs -> sb .s_reserved [200 ] |= OP_HOLES ;
2127-
2127+
21282128 return fs ;
21292129}
21302130
@@ -2338,7 +2338,7 @@ print_inode(filesystem *fs, uint32 nod)
23382338 s = "undelete directory" ;
23392339 break ;
23402340 default :
2341- s = (nod >= EXT2_FIRST_INO ) ? "normal" : "unknown reserved" ;
2341+ s = (nod >= EXT2_FIRST_INO ) ? "normal" : "unknown reserved" ;
23422342 }
23432343 printf ("inode %d (%s, %d links): " , nod , s , get_nod (fs , nod )-> i_links_count );
23442344 if (!allocated (GRP_GET_INODE_BITMAP (fs ,nod ), GRP_IBM_OFFSET (fs ,nod )))
@@ -2691,7 +2691,7 @@ main(int argc, char **argv)
26912691 {
26922692 if (reserved_frac == -1 )
26932693 nbresrvd = nbblocks * RESERVED_BLOCKS ;
2694- else
2694+ else
26952695 nbresrvd = nbblocks * reserved_frac ;
26962696
26972697 stats .ninodes = EXT2_FIRST_INO - 1 + (nbresrvd ? 1 : 0 );
@@ -2718,7 +2718,7 @@ main(int argc, char **argv)
27182718 fs = init_fs (nbblocks , nbinodes , nbresrvd , holes ,
27192719 fs_timestamp , creator_os );
27202720 }
2721-
2721+
27222722 populate_fs (fs , dopt , didx , squash_uids , squash_perms , fs_timestamp , NULL );
27232723
27242724 if (emptyval ) {
0 commit comments