lib: add EXT2_ prefix for SUPERBLOCK_{OFFSET,SIZE}
PATCH 4/4 lib: add EXT2_ prefix for SUPERBLOCK_{OFFSET,SIZE}
Since mostly all macros have this prefix, and to avoid potential name clashes.
--- e2fsck/journal.c | 2 +- e2fsck/super.c | 4 ++-- e2fsck/util.c | 4 ++-- lib/blkid/probe.h | 2 +- lib/ext2fs/closefs.c | 18 +++++++++--------- lib/ext2fs/dupfs.c | 8 ++++---- lib/ext2fs/ext2fs.h | 10 ++++++++-- lib/ext2fs/imager.c | 4 ++-- lib/ext2fs/initialize.c | 4 ++-- lib/ext2fs/mkjournal.c | 6 +++--- lib/ext2fs/openfs.c | 12 ++++++------ lib/ext2fs/tst_badblocks.c | 4 ++-- lib/ext2fs/undo_io.c | 4 ++-- misc/e2undo.c | 4 ++-- misc/mke2fs.c | 4 ++-- misc/tune2fs.c | 12 ++++++------ 16 files changed, 54 insertions(+), 48 deletions(-)
e2fsck/journal.c +1 -1
@@ -454,7 +454,7 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)brelse (bh); goto errout; } -memcpy (&jsuper, start ? bh->b_data : bh->b_data +SUPERBLOCK_OFFSET , +memcpy (&jsuper, start ? bh->b_data : bh->b_data +EXT2_SUPERBLOCK_OFFSET ,sizeof (jsuper));brelse (bh);#ifdef WORDS_BIGENDIAN
e2fsck/super.c +2 -2
@@ -921,7 +921,7 @@ int check_backup_super_block(e2fsck_t ctx)dgrp_t g;blk64_t sb;int ret =0 ; -char buf[SUPERBLOCK_SIZE ]; +char buf[EXT2_SUPERBLOCK_SIZE ];struct ext2_super_block *backup_sb;/*
@@ -944,7 +944,7 @@ int check_backup_super_block(e2fsck_t ctx) sb =ext2fs_group_first_block2 (fs, g); - retval =io_channel_read_blk (fs->io, sb, -SUPERBLOCK_SIZE , + retval =io_channel_read_blk (fs->io, sb, -EXT2_SUPERBLOCK_SIZE , buf);if (retval)continue ;
e2fsck/util.c +2 -2
@@ -540,7 +540,7 @@ blk64_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs, const char *name,if (manager->open (name,0 , &io) !=0 ) goto cleanup; -if (ext2fs_get_mem (SUPERBLOCK_SIZE , &buf)) +if (ext2fs_get_mem (EXT2_SUPERBLOCK_SIZE , &buf)) goto cleanup; sb = (struct ext2_super_block *) buf;
@@ -551,7 +551,7 @@ blk64_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs, const char *name, superblock++;io_channel_set_blksize (io, blocksize);if (io_channel_read_blk64 (io, superblock, - -SUPERBLOCK_SIZE , buf)) + -EXT2_SUPERBLOCK_SIZE , buf))continue ;#ifdef WORDS_BIGENDIAN if (sb->s_magic ==ext2fs_swab16 (EXT2_SUPER_MAGIC ))
lib/blkid/probe.h +1 -1
@@ -403,7 +403,7 @@ struct iso_volume_descriptor {/* Common gfs/gfs2 constants: */ #define GFS_MAGIC 0x01161970#define GFS_DEFAULT_BSIZE 4096 -#define GFS_SUPERBLOCK_OFFSET (0x10 * GFS_DEFAULT_BSIZE) +#define GFS_EXT2_SUPERBLOCK_OFFSET (0x10 * GFS_DEFAULT_BSIZE)#define GFS_METATYPE_SB 1#define GFS_FORMAT_SB 100#define GFS_LOCKNAME_LEN 64
lib/ext2fs/closefs.c +9 -9
@@ -199,8 +199,8 @@ static errcode_t write_primary_superblock(ext2_filsys fs,if (!fs->io->manager->write_byte || !fs->orig_super) { fallback: -io_channel_set_blksize (fs->io,SUPERBLOCK_OFFSET ); - retval =io_channel_write_blk64 (fs->io,1 , -SUPERBLOCK_SIZE , +io_channel_set_blksize (fs->io,EXT2_SUPERBLOCK_OFFSET ); + retval =io_channel_write_blk64 (fs->io,1 , -EXT2_SUPERBLOCK_SIZE , super);io_channel_set_blksize (fs->io, fs->blocksize);return retval;
@@ -209,11 +209,11 @@ static errcode_t write_primary_superblock(ext2_filsys fs, old_super = (__u16 *) fs->orig_super; new_super = (__u16 *) super; -for (check_idx =0 ; check_idx <SUPERBLOCK_SIZE /2 ; check_idx++) { +for (check_idx =0 ; check_idx <EXT2_SUPERBLOCK_SIZE /2 ; check_idx++) {if (old_super[check_idx] == new_super[check_idx])continue ; write_idx = check_idx; -for (check_idx++; check_idx <SUPERBLOCK_SIZE /2 ; check_idx++) +for (check_idx++; check_idx <EXT2_SUPERBLOCK_SIZE /2 ; check_idx++)if (old_super[check_idx] == new_super[check_idx])break ; size =2 * (check_idx - write_idx);
@@ -222,14 +222,14 @@ static errcode_t write_primary_superblock(ext2_filsys fs, size, write_idx*2);#endif retval =io_channel_write_byte (fs->io, -SUPERBLOCK_OFFSET + (2 * write_idx), size, +EXT2_SUPERBLOCK_OFFSET + (2 * write_idx), size, new_super + write_idx);if (retval ==EXT2_ET_UNIMPLEMENTED ) goto fallback;if (retval)return retval; } -memcpy (fs->orig_super, super,SUPERBLOCK_SIZE ); +memcpy (fs->orig_super, super,EXT2_SUPERBLOCK_SIZE );return 0 ; }
@@ -269,7 +269,7 @@ static errcode_t write_backup_super(ext2_filsys fs, dgrp_t group,if (retval)return retval; -return io_channel_write_blk64 (fs->io, group_block, -SUPERBLOCK_SIZE , +return io_channel_write_blk64 (fs->io, group_block, -EXT2_SUPERBLOCK_SIZE , super_shadow); }
@@ -320,7 +320,7 @@ errcode_t ext2fs_flush2(ext2_filsys fs, int flags)/* Prepare the group descriptors for writing */ #ifdef WORDS_BIGENDIAN retval =EXT2_ET_NO_MEMORY ; - retval =ext2fs_get_mem (SUPERBLOCK_SIZE , &super_shadow); + retval =ext2fs_get_mem (EXT2_SUPERBLOCK_SIZE , &super_shadow);if (retval) goto errout; retval = ext2fs_get_array(fs->desc_blocks, fs->blocksize,
@@ -412,7 +412,7 @@ write_primary_superblock_only:/* * Write out master superblock. This has to be done * separately, since it is located at a fixed location -* (SUPERBLOCK_OFFSET). We flush all other pending changes +* (EXT2_SUPERBLOCK_OFFSET). We flush all other pending changes * out to disk first, just to avoid a race condition with an * insy-tinsy window.... */
lib/ext2fs/dupfs.c +4 -4
@@ -53,15 +53,15 @@ errcode_t ext2fs_dup_handle(ext2_filsys src, ext2_filsys *dest) goto errout;strcpy (fs->device_name, src->device_name); - retval =ext2fs_get_mem (SUPERBLOCK_SIZE , &fs->super); + retval =ext2fs_get_mem (EXT2_SUPERBLOCK_SIZE , &fs->super);if (retval) goto errout; -memcpy (fs->super, src->super,SUPERBLOCK_SIZE ); +memcpy (fs->super, src->super,EXT2_SUPERBLOCK_SIZE ); - retval =ext2fs_get_mem (SUPERBLOCK_SIZE , &fs->orig_super); + retval =ext2fs_get_mem (EXT2_SUPERBLOCK_SIZE , &fs->orig_super);if (retval) goto errout; -memcpy (fs->orig_super, src->orig_super,SUPERBLOCK_SIZE ); +memcpy (fs->orig_super, src->orig_super,EXT2_SUPERBLOCK_SIZE ); retval =ext2fs_get_array (fs->desc_blocks, fs->blocksize, &fs->group_desc);
lib/ext2fs/ext2fs.h +8 -2
@@ -36,8 +36,14 @@ extern "C" {* (some versions have the padding set up so that the superblock is * 1032 bytes long). */ -#define SUPERBLOCK_OFFSET 1024 -#define SUPERBLOCK_SIZE 1024 +#define EXT2_SUPERBLOCK_OFFSET 1024 +#define EXT2_SUPERBLOCK_SIZE 1024 +/** +* Deprecated, will be removed in the next release +* Instead use EXT2_* with the same names. +*/ +#define SUPERBLOCK_OFFSET EXT2_SUPERBLOCK_OFFSET +#define SUPERBLOCK_SIZE EXT2_SUPERBLOCK_SIZE/* * The last ext2fs revision level that this version of the library is
lib/ext2fs/imager.c +2 -2
@@ -203,7 +203,7 @@ errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd,* Write out the superblock */ memset (buf,0 , fs->blocksize); -memcpy (buf, fs->super,SUPERBLOCK_SIZE ); +memcpy (buf, fs->super,EXT2_SUPERBLOCK_SIZE ); actual =write (fd, buf, fs->blocksize);if (actual ==-1 ) { retval = errno;
@@ -266,7 +266,7 @@ errcode_t ext2fs_image_super_read(ext2_filsys fs, int fd,/* * Now copy in the superblock and group descriptors */ -memcpy (fs->super, buf,SUPERBLOCK_SIZE ); +memcpy (fs->super, buf,EXT2_SUPERBLOCK_SIZE );memcpy (fs->group_desc, buf + fs->blocksize, fs->blocksize * fs->group_desc_count);
lib/ext2fs/initialize.c +2 -2
@@ -133,12 +133,12 @@ errcode_t ext2fs_initialize(const char *name, int flags, goto cleanup;strcpy (fs->device_name, name); - retval =ext2fs_get_mem (SUPERBLOCK_SIZE , &super); + retval =ext2fs_get_mem (EXT2_SUPERBLOCK_SIZE , &super);if (retval) goto cleanup; fs->super = super; -memset (super,0 ,SUPERBLOCK_SIZE ); +memset (super,0 ,EXT2_SUPERBLOCK_SIZE );#define set_field (field, default) (super->field = param->field ? \ param->field : (default))
lib/ext2fs/mkjournal.c +3 -3
@@ -441,7 +441,7 @@ errcode_t ext2fs_add_journal_device(ext2_filsys fs, ext2_filsys journal_dev) {struct stat st;errcode_t retval; -char buf[SUPERBLOCK_SIZE ]; +char buf[EXT2_SUPERBLOCK_SIZE ];journal_superblock_t *jsb;int start;__u32 i, nr_users;
@@ -456,7 +456,7 @@ errcode_t ext2fs_add_journal_device(ext2_filsys fs, ext2_filsys journal_dev)/* Get the journal superblock */ start =ext2fs_journal_sb_start (journal_dev->blocksize);if ((retval =io_channel_read_blk64 (journal_dev->io, start, - -SUPERBLOCK_SIZE , + -EXT2_SUPERBLOCK_SIZE , buf)))return retval;
@@ -483,7 +483,7 @@ errcode_t ext2fs_add_journal_device(ext2_filsys fs, ext2_filsys journal_dev)/* Writeback the journal superblock */ if ((retval =io_channel_write_blk64 (journal_dev->io, start, - -SUPERBLOCK_SIZE , buf))) + -EXT2_SUPERBLOCK_SIZE , buf)))return retval; fs->super->s_journal_inum =0 ;
lib/ext2fs/openfs.c +6 -6
@@ -164,7 +164,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, goto cleanup; fs->image_io = fs->io; fs->io->app_data = fs; - retval =io_channel_alloc_buf (fs->io, -SUPERBLOCK_SIZE , &fs->super); + retval =io_channel_alloc_buf (fs->io, -EXT2_SUPERBLOCK_SIZE , &fs->super);if (retval) goto cleanup;if (flags &EXT2_FLAG_IMAGE_FILE ) {
@@ -187,7 +187,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,* If the user specifies a specific block # for the * superblock, then he/she must also specify the block size! * Otherwise, read the master superblock located at offset -* SUPERBLOCK_OFFSET from the start of the partition. +* EXT2_SUPERBLOCK_OFFSET from the start of the partition. * * Note: we only save a backup copy of the superblock if we * are reading the superblock from the primary superblock location.
@@ -201,19 +201,19 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, group_block = superblock; fs->orig_super =0 ; }else { -io_channel_set_blksize (fs->io,SUPERBLOCK_OFFSET ); +io_channel_set_blksize (fs->io,EXT2_SUPERBLOCK_OFFSET ); superblock =1 ; group_block =0 ; - retval =ext2fs_get_mem (SUPERBLOCK_SIZE , &fs->orig_super); + retval =ext2fs_get_mem (EXT2_SUPERBLOCK_SIZE , &fs->orig_super);if (retval) goto cleanup; } - retval =io_channel_read_blk (fs->io, superblock, -SUPERBLOCK_SIZE , + retval =io_channel_read_blk (fs->io, superblock, -EXT2_SUPERBLOCK_SIZE , fs->super);if (retval) goto cleanup;if (fs->orig_super) -memcpy (fs->orig_super, fs->super,SUPERBLOCK_SIZE ); +memcpy (fs->orig_super, fs->super,EXT2_SUPERBLOCK_SIZE );if (!(fs->flags &EXT2_FLAG_IGNORE_CSUM_ERRORS )) { retval =0 ;
lib/ext2fs/tst_badblocks.c +2 -2
@@ -225,8 +225,8 @@ int file_test_invalid(badblocks_list bb) fs =malloc (sizeof (struct struct_ext2_filsys ));memset (fs,0 ,sizeof (struct struct_ext2_filsys )); fs->magic =EXT2_ET_MAGIC_EXT2FS_FILSYS ; - fs->super =malloc (SUPERBLOCK_SIZE ); -memset (fs->super,0 ,SUPERBLOCK_SIZE ); + fs->super =malloc (EXT2_SUPERBLOCK_SIZE ); +memset (fs->super,0 ,EXT2_SUPERBLOCK_SIZE ); fs->super->s_first_data_block =1 ;ext2fs_blocks_count_set (fs->super,100 );
lib/ext2fs/undo_io.c +2 -2
@@ -113,8 +113,8 @@ static errcode_t write_file_system_identity(io_channel undo_channel, channel = data->real; block_size = channel->block_size; -io_channel_set_blksize (channel,SUPERBLOCK_OFFSET ); - retval =io_channel_read_blk64 (channel,1 , -SUPERBLOCK_SIZE , &super); +io_channel_set_blksize (channel,EXT2_SUPERBLOCK_OFFSET ); + retval =io_channel_read_blk64 (channel,1 , -EXT2_SUPERBLOCK_SIZE , &super);if (retval) goto err_out;
misc/e2undo.c +2 -2
@@ -45,8 +45,8 @@ static int check_filesystem(TDB_CONTEXT *tdb, io_channel channel)TDB_DATA tdb_key, tdb_data;struct ext2_super_block super; -io_channel_set_blksize (channel,SUPERBLOCK_OFFSET ); - retval =io_channel_read_blk64 (channel,1 , -SUPERBLOCK_SIZE , &super); +io_channel_set_blksize (channel,EXT2_SUPERBLOCK_OFFSET ); + retval =io_channel_read_blk64 (channel,1 , -EXT2_SUPERBLOCK_SIZE , &super);if (retval) {com_err (prg_name, retval,"%s" ,_ ("Failed to read the file system data \n" ));
misc/mke2fs.c +2 -2
@@ -2398,8 +2398,8 @@ static int should_do_undo(const char *name) goto open_err_out; } -io_channel_set_blksize (channel,SUPERBLOCK_OFFSET ); - retval =io_channel_read_blk64 (channel,1 , -SUPERBLOCK_SIZE , &super); +io_channel_set_blksize (channel,EXT2_SUPERBLOCK_OFFSET ); + retval =io_channel_read_blk64 (channel,1 , -EXT2_SUPERBLOCK_SIZE , &super);if (retval) { retval =0 ; goto err_out;
misc/tune2fs.c +6 -6
@@ -183,7 +183,7 @@ static __u32 clear_ok_features[3] = {/** * Try to get journal super block if any */ -static int get_journal_sb (ext2_filsys jfs,char buf[SUPERBLOCK_SIZE ]) +static int get_journal_sb (ext2_filsys jfs,char buf[EXT2_SUPERBLOCK_SIZE ]) {int retval;int start;
@@ -196,7 +196,7 @@ static int get_journal_sb(ext2_filsys jfs, char buf[SUPERBLOCK_SIZE])/* Get the journal superblock */ if ((retval =io_channel_read_blk64 (jfs->io, -ext2fs_journal_sb_start (jfs->blocksize), -SUPERBLOCK_SIZE , buf))) { +ext2fs_journal_sb_start (jfs->blocksize), -EXT2_SUPERBLOCK_SIZE , buf))) {com_err (program_name, retval,"%s" ,_ ("while reading journal superblock" ));return retval;
@@ -219,7 +219,7 @@ static int remove_journal_device(ext2_filsys fs) {char *journal_path;ext2_filsys jfs; -char buf[SUPERBLOCK_SIZE ]; +char buf[EXT2_SUPERBLOCK_SIZE ];journal_superblock_t *jsb;int i, nr_users;errcode_t retval;
@@ -283,7 +283,7 @@ static int remove_journal_device(ext2_filsys fs)/* Write back the journal superblock */ if ((retval =io_channel_write_blk64 (jfs->io, start, - -SUPERBLOCK_SIZE , buf))) { + -EXT2_SUPERBLOCK_SIZE , buf))) {com_err (program_name, retval,"while writing journal superblock." ); goto no_valid_journal;
@@ -2713,7 +2713,7 @@ retry_open:if (U_flag) {int set_csum =0 ;dgrp_t i; -char buf[SUPERBLOCK_SIZE ]; +char buf[EXT2_SUPERBLOCK_SIZE ];if (ext2fs_has_group_desc_csum (fs)) {/*
@@ -2771,7 +2771,7 @@ retry_open:/* Writeback the journal superblock */ if ((rc =io_channel_write_blk64 (fs->io,ext2fs_journal_sb_start (fs->blocksize), - -SUPERBLOCK_SIZE , buf))) + -EXT2_SUPERBLOCK_SIZE , buf))) goto closefs; }else if (rc !=EXT2_ET_UNSUPP_FEATURE ) goto closefs;
Signature · 1 line
2.0.0
Quoted 86 lines · Azat Khuzhin
Since mostly all macros have this prefix, and to avoid potential name clashes.
Proposed-by Andreas Dilger <[email protected]>Signed-off-by Azat Khuzhin <[email protected]>--- e2fsck/journal.c | 2 +- e2fsck/super.c | 4 ++-- e2fsck/util.c | 4 ++-- lib/blkid/probe.h | 2 +- lib/ext2fs/closefs.c | 18 +++++++++--------- lib/ext2fs/dupfs.c | 8 ++++---- lib/ext2fs/ext2fs.h | 10 ++++++++-- lib/ext2fs/imager.c | 4 ++-- lib/ext2fs/initialize.c | 4 ++-- lib/ext2fs/mkjournal.c | 6 +++--- lib/ext2fs/openfs.c | 12 ++++++------ lib/ext2fs/tst_badblocks.c | 4 ++-- lib/ext2fs/undo_io.c | 4 ++-- misc/e2undo.c | 4 ++-- misc/mke2fs.c | 4 ++-- misc/tune2fs.c | 12 ++++++------ 16 files changed, 54 insertions(+), 48 deletions(-)e2fsck/journal.c +1
-1@@ -454,7 +454,7 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)brelse (bh); goto errout; } -memcpy (&jsuper, start ? bh->b_data : bh->b_data +SUPERBLOCK_OFFSET , +memcpy (&jsuper, start ? bh->b_data : bh->b_data +EXT2_SUPERBLOCK_OFFSET ,sizeof (jsuper));brelse (bh);#ifdef WORDS_BIGENDIAN e2fsck/super.c +2
-2@@ -921,7 +921,7 @@ int check_backup_super_block(e2fsck_t ctx)dgrp_t g;blk64_t sb;int ret =0 ; -char buf[SUPERBLOCK_SIZE ]; +char buf[EXT2_SUPERBLOCK_SIZE ];struct ext2_super_block *backup_sb;/* @@ -944,7 +944,7 @@ int check_backup_super_block(e2fsck_t ctx) sb =ext2fs_group_first_block2 (fs, g); - retval =io_channel_read_blk (fs->io, sb, -SUPERBLOCK_SIZE , + retval =io_channel_read_blk (fs->io, sb, -EXT2_SUPERBLOCK_SIZE , buf);if (retval)continue ;e2fsck/util.c +2
-2@@ -540,7 +540,7 @@ blk64_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs, const char *name,if (manager->open (name,0 , &io) !=0 ) goto cleanup; -if (ext2fs_get_mem (SUPERBLOCK_SIZE , &buf)) +if (ext2fs_get_mem (EXT2_SUPERBLOCK_SIZE , &buf)) goto cleanup; sb = (struct ext2_super_block *) buf;@@ -551,7 +551,7 @@ blk64_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs, const char *name, superblock++;io_channel_set_blksize (io, blocksize);if (io_channel_read_blk64 (io, superblock, - -SUPERBLOCK_SIZE , buf)) + -EXT2_SUPERBLOCK_SIZE , buf))continue ;#ifdef WORDS_BIGENDIAN if (sb->s_magic ==ext2fs_swab16 (EXT2_SUPER_MAGIC ))lib/blkid/probe.h +0
-0
lib/blkid/probe.h struct iso_volume_descriptor { · line 406
Quoted 5 lines
lib/blkid/probe.h +1
-1@@ -403,7 +403,7 @@ struct iso_volume_descriptor {/* Common gfs/gfs2 constants: */ #define GFS_MAGIC 0x01161970#define GFS_DEFAULT_BSIZE 4096 -#define GFS_SUPERBLOCK_OFFSET (0x10 * GFS_DEFAULT_BSIZE) +#define GFS_EXT2_SUPERBLOCK_OFFSET (0x10 * GFS_DEFAULT_BSIZE)
I doubt the e2fsprogs blkid does much these days, but .... huh???
The rest looks ok to me.
--D
Quoted 86 lines · Darrick J. Wong
Quoted 85 lines · Azat Khuzhin
Since mostly all macros have this prefix, and to avoid potential name clashes.
Proposed-by Andreas Dilger <[email protected]>Signed-off-by Azat Khuzhin <[email protected]>--- e2fsck/journal.c | 2 +- e2fsck/super.c | 4 ++-- e2fsck/util.c | 4 ++-- lib/blkid/probe.h | 2 +- lib/ext2fs/closefs.c | 18 +++++++++--------- lib/ext2fs/dupfs.c | 8 ++++---- lib/ext2fs/ext2fs.h | 10 ++++++++-- lib/ext2fs/imager.c | 4 ++-- lib/ext2fs/initialize.c | 4 ++-- lib/ext2fs/mkjournal.c | 6 +++--- lib/ext2fs/openfs.c | 12 ++++++------ lib/ext2fs/tst_badblocks.c | 4 ++-- lib/ext2fs/undo_io.c | 4 ++-- misc/e2undo.c | 4 ++-- misc/mke2fs.c | 4 ++-- misc/tune2fs.c | 12 ++++++------ 16 files changed, 54 insertions(+), 48 deletions(-)e2fsck/journal.c +1
-1@@ -454,7 +454,7 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)brelse (bh); goto errout; } -memcpy (&jsuper, start ? bh->b_data : bh->b_data +SUPERBLOCK_OFFSET , +memcpy (&jsuper, start ? bh->b_data : bh->b_data +EXT2_SUPERBLOCK_OFFSET ,sizeof (jsuper));brelse (bh);#ifdef WORDS_BIGENDIAN e2fsck/super.c +2
-2@@ -921,7 +921,7 @@ int check_backup_super_block(e2fsck_t ctx)dgrp_t g;blk64_t sb;int ret =0 ; -char buf[SUPERBLOCK_SIZE ]; +char buf[EXT2_SUPERBLOCK_SIZE ];struct ext2_super_block *backup_sb;/* @@ -944,7 +944,7 @@ int check_backup_super_block(e2fsck_t ctx) sb =ext2fs_group_first_block2 (fs, g); - retval =io_channel_read_blk (fs->io, sb, -SUPERBLOCK_SIZE , + retval =io_channel_read_blk (fs->io, sb, -EXT2_SUPERBLOCK_SIZE , buf);if (retval)continue ;e2fsck/util.c +2
-2@@ -540,7 +540,7 @@ blk64_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs, const char *name,if (manager->open (name,0 , &io) !=0 ) goto cleanup; -if (ext2fs_get_mem (SUPERBLOCK_SIZE , &buf)) +if (ext2fs_get_mem (EXT2_SUPERBLOCK_SIZE , &buf)) goto cleanup; sb = (struct ext2_super_block *) buf;@@ -551,7 +551,7 @@ blk64_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs, const char *name, superblock++;io_channel_set_blksize (io, blocksize);if (io_channel_read_blk64 (io, superblock, - -SUPERBLOCK_SIZE , buf)) + -EXT2_SUPERBLOCK_SIZE , buf))continue ;#ifdef WORDS_BIGENDIAN if (sb->s_magic ==ext2fs_swab16 (EXT2_SUPER_MAGIC ))lib/blkid/probe.h +0
-0
Quoted 8 lines
lib/blkid/probe.h struct iso_volume_descriptor { · line 406
Quoted 6 lines
lib/blkid/probe.h +1
-1@@ -403,7 +403,7 @@ struct iso_volume_descriptor {/* Common gfs/gfs2 constants: */ #define GFS_MAGIC 0x01161970#define GFS_DEFAULT_BSIZE 4096 -#define GFS_SUPERBLOCK_OFFSET (0x10 * GFS_DEFAULT_BSIZE) +#define GFS_EXT2_SUPERBLOCK_OFFSET (0x10 * GFS_DEFAULT_BSIZE)I doubt the e2fsprogs blkid does much these days, but .... huh???
Ops, this was matched by simple pattern, next time I will be smarter. Thanks.
Quoted 4 lines
The rest looks ok to me.
--D
Signature · 2 lines
Respectfully Azat Khuzhin
PATCH v2 4/4 lib: add EXT2_ prefix for SUPERBLOCK_{OFFSET,SIZE}
In reply to Darrick J. WongSince mostly all macros have this prefix, and to avoid potential name clashes.
---
v2: don't replcae gfs consts (pattern error, thanks to Darrick J. Wong)
e2fsck/journal.c | 2 +- e2fsck/super.c | 4 ++-- e2fsck/util.c | 4 ++-- lib/ext2fs/closefs.c | 18 +++++++++--------- lib/ext2fs/dupfs.c | 8 ++++---- lib/ext2fs/ext2fs.h | 10 ++++++++-- lib/ext2fs/imager.c | 4 ++-- lib/ext2fs/initialize.c | 4 ++-- lib/ext2fs/mkjournal.c | 6 +++--- lib/ext2fs/openfs.c | 12 ++++++------ lib/ext2fs/tst_badblocks.c | 4 ++-- lib/ext2fs/undo_io.c | 4 ++-- misc/e2undo.c | 4 ++-- misc/mke2fs.c | 4 ++-- misc/tune2fs.c | 12 ++++++------ 15 files changed, 53 insertions(+), 47 deletions(-)
e2fsck/journal.c +1 -1
@@ -454,7 +454,7 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)brelse (bh); goto errout; } -memcpy (&jsuper, start ? bh->b_data : bh->b_data +SUPERBLOCK_OFFSET , +memcpy (&jsuper, start ? bh->b_data : bh->b_data +EXT2_SUPERBLOCK_OFFSET ,sizeof (jsuper));brelse (bh);#ifdef WORDS_BIGENDIAN
e2fsck/super.c +2 -2
@@ -921,7 +921,7 @@ int check_backup_super_block(e2fsck_t ctx)dgrp_t g;blk64_t sb;int ret =0 ; -char buf[SUPERBLOCK_SIZE ]; +char buf[EXT2_SUPERBLOCK_SIZE ];struct ext2_super_block *backup_sb;/*
@@ -944,7 +944,7 @@ int check_backup_super_block(e2fsck_t ctx) sb =ext2fs_group_first_block2 (fs, g); - retval =io_channel_read_blk (fs->io, sb, -SUPERBLOCK_SIZE , + retval =io_channel_read_blk (fs->io, sb, -EXT2_SUPERBLOCK_SIZE , buf);if (retval)continue ;
e2fsck/util.c +2 -2
@@ -540,7 +540,7 @@ blk64_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs, const char *name,if (manager->open (name,0 , &io) !=0 ) goto cleanup; -if (ext2fs_get_mem (SUPERBLOCK_SIZE , &buf)) +if (ext2fs_get_mem (EXT2_SUPERBLOCK_SIZE , &buf)) goto cleanup; sb = (struct ext2_super_block *) buf;
@@ -551,7 +551,7 @@ blk64_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs, const char *name, superblock++;io_channel_set_blksize (io, blocksize);if (io_channel_read_blk64 (io, superblock, - -SUPERBLOCK_SIZE , buf)) + -EXT2_SUPERBLOCK_SIZE , buf))continue ;#ifdef WORDS_BIGENDIAN if (sb->s_magic ==ext2fs_swab16 (EXT2_SUPER_MAGIC ))
lib/ext2fs/closefs.c +9 -9
@@ -199,8 +199,8 @@ static errcode_t write_primary_superblock(ext2_filsys fs,if (!fs->io->manager->write_byte || !fs->orig_super) { fallback: -io_channel_set_blksize (fs->io,SUPERBLOCK_OFFSET ); - retval =io_channel_write_blk64 (fs->io,1 , -SUPERBLOCK_SIZE , +io_channel_set_blksize (fs->io,EXT2_SUPERBLOCK_OFFSET ); + retval =io_channel_write_blk64 (fs->io,1 , -EXT2_SUPERBLOCK_SIZE , super);io_channel_set_blksize (fs->io, fs->blocksize);return retval;
@@ -209,11 +209,11 @@ static errcode_t write_primary_superblock(ext2_filsys fs, old_super = (__u16 *) fs->orig_super; new_super = (__u16 *) super; -for (check_idx =0 ; check_idx <SUPERBLOCK_SIZE /2 ; check_idx++) { +for (check_idx =0 ; check_idx <EXT2_SUPERBLOCK_SIZE /2 ; check_idx++) {if (old_super[check_idx] == new_super[check_idx])continue ; write_idx = check_idx; -for (check_idx++; check_idx <SUPERBLOCK_SIZE /2 ; check_idx++) +for (check_idx++; check_idx <EXT2_SUPERBLOCK_SIZE /2 ; check_idx++)if (old_super[check_idx] == new_super[check_idx])break ; size =2 * (check_idx - write_idx);
@@ -222,14 +222,14 @@ static errcode_t write_primary_superblock(ext2_filsys fs, size, write_idx*2);#endif retval =io_channel_write_byte (fs->io, -SUPERBLOCK_OFFSET + (2 * write_idx), size, +EXT2_SUPERBLOCK_OFFSET + (2 * write_idx), size, new_super + write_idx);if (retval ==EXT2_ET_UNIMPLEMENTED ) goto fallback;if (retval)return retval; } -memcpy (fs->orig_super, super,SUPERBLOCK_SIZE ); +memcpy (fs->orig_super, super,EXT2_SUPERBLOCK_SIZE );return 0 ; }
@@ -269,7 +269,7 @@ static errcode_t write_backup_super(ext2_filsys fs, dgrp_t group,if (retval)return retval; -return io_channel_write_blk64 (fs->io, group_block, -SUPERBLOCK_SIZE , +return io_channel_write_blk64 (fs->io, group_block, -EXT2_SUPERBLOCK_SIZE , super_shadow); }
@@ -320,7 +320,7 @@ errcode_t ext2fs_flush2(ext2_filsys fs, int flags)/* Prepare the group descriptors for writing */ #ifdef WORDS_BIGENDIAN retval =EXT2_ET_NO_MEMORY ; - retval =ext2fs_get_mem (SUPERBLOCK_SIZE , &super_shadow); + retval =ext2fs_get_mem (EXT2_SUPERBLOCK_SIZE , &super_shadow);if (retval) goto errout; retval = ext2fs_get_array(fs->desc_blocks, fs->blocksize,
@@ -412,7 +412,7 @@ write_primary_superblock_only:/* * Write out master superblock. This has to be done * separately, since it is located at a fixed location -* (SUPERBLOCK_OFFSET). We flush all other pending changes +* (EXT2_SUPERBLOCK_OFFSET). We flush all other pending changes * out to disk first, just to avoid a race condition with an * insy-tinsy window.... */
lib/ext2fs/dupfs.c +4 -4
@@ -53,15 +53,15 @@ errcode_t ext2fs_dup_handle(ext2_filsys src, ext2_filsys *dest) goto errout;strcpy (fs->device_name, src->device_name); - retval =ext2fs_get_mem (SUPERBLOCK_SIZE , &fs->super); + retval =ext2fs_get_mem (EXT2_SUPERBLOCK_SIZE , &fs->super);if (retval) goto errout; -memcpy (fs->super, src->super,SUPERBLOCK_SIZE ); +memcpy (fs->super, src->super,EXT2_SUPERBLOCK_SIZE ); - retval =ext2fs_get_mem (SUPERBLOCK_SIZE , &fs->orig_super); + retval =ext2fs_get_mem (EXT2_SUPERBLOCK_SIZE , &fs->orig_super);if (retval) goto errout; -memcpy (fs->orig_super, src->orig_super,SUPERBLOCK_SIZE ); +memcpy (fs->orig_super, src->orig_super,EXT2_SUPERBLOCK_SIZE ); retval =ext2fs_get_array (fs->desc_blocks, fs->blocksize, &fs->group_desc);
lib/ext2fs/ext2fs.h +8 -2
@@ -36,8 +36,14 @@ extern "C" {* (some versions have the padding set up so that the superblock is * 1032 bytes long). */ -#define SUPERBLOCK_OFFSET 1024 -#define SUPERBLOCK_SIZE 1024 +#define EXT2_SUPERBLOCK_OFFSET 1024 +#define EXT2_SUPERBLOCK_SIZE 1024 +/** +* Deprecated, will be removed in the next release +* Instead use EXT2_* with the same names. +*/ +#define SUPERBLOCK_OFFSET EXT2_SUPERBLOCK_OFFSET +#define SUPERBLOCK_SIZE EXT2_SUPERBLOCK_SIZE/* * The last ext2fs revision level that this version of the library is
lib/ext2fs/imager.c +2 -2
@@ -203,7 +203,7 @@ errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd,* Write out the superblock */ memset (buf,0 , fs->blocksize); -memcpy (buf, fs->super,SUPERBLOCK_SIZE ); +memcpy (buf, fs->super,EXT2_SUPERBLOCK_SIZE ); actual =write (fd, buf, fs->blocksize);if (actual ==-1 ) { retval = errno;
@@ -266,7 +266,7 @@ errcode_t ext2fs_image_super_read(ext2_filsys fs, int fd,/* * Now copy in the superblock and group descriptors */ -memcpy (fs->super, buf,SUPERBLOCK_SIZE ); +memcpy (fs->super, buf,EXT2_SUPERBLOCK_SIZE );memcpy (fs->group_desc, buf + fs->blocksize, fs->blocksize * fs->group_desc_count);
lib/ext2fs/initialize.c +2 -2
@@ -133,12 +133,12 @@ errcode_t ext2fs_initialize(const char *name, int flags, goto cleanup;strcpy (fs->device_name, name); - retval =ext2fs_get_mem (SUPERBLOCK_SIZE , &super); + retval =ext2fs_get_mem (EXT2_SUPERBLOCK_SIZE , &super);if (retval) goto cleanup; fs->super = super; -memset (super,0 ,SUPERBLOCK_SIZE ); +memset (super,0 ,EXT2_SUPERBLOCK_SIZE );#define set_field (field, default) (super->field = param->field ? \ param->field : (default))
lib/ext2fs/mkjournal.c +3 -3
@@ -441,7 +441,7 @@ errcode_t ext2fs_add_journal_device(ext2_filsys fs, ext2_filsys journal_dev) {struct stat st;errcode_t retval; -char buf[SUPERBLOCK_SIZE ]; +char buf[EXT2_SUPERBLOCK_SIZE ];journal_superblock_t *jsb;int start;__u32 i, nr_users;
@@ -456,7 +456,7 @@ errcode_t ext2fs_add_journal_device(ext2_filsys fs, ext2_filsys journal_dev)/* Get the journal superblock */ start =ext2fs_journal_sb_start (journal_dev->blocksize);if ((retval =io_channel_read_blk64 (journal_dev->io, start, - -SUPERBLOCK_SIZE , + -EXT2_SUPERBLOCK_SIZE , buf)))return retval;
@@ -483,7 +483,7 @@ errcode_t ext2fs_add_journal_device(ext2_filsys fs, ext2_filsys journal_dev)/* Writeback the journal superblock */ if ((retval =io_channel_write_blk64 (journal_dev->io, start, - -SUPERBLOCK_SIZE , buf))) + -EXT2_SUPERBLOCK_SIZE , buf)))return retval; fs->super->s_journal_inum =0 ;
lib/ext2fs/openfs.c +6 -6
@@ -164,7 +164,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, goto cleanup; fs->image_io = fs->io; fs->io->app_data = fs; - retval =io_channel_alloc_buf (fs->io, -SUPERBLOCK_SIZE , &fs->super); + retval =io_channel_alloc_buf (fs->io, -EXT2_SUPERBLOCK_SIZE , &fs->super);if (retval) goto cleanup;if (flags &EXT2_FLAG_IMAGE_FILE ) {
@@ -187,7 +187,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,* If the user specifies a specific block # for the * superblock, then he/she must also specify the block size! * Otherwise, read the master superblock located at offset -* SUPERBLOCK_OFFSET from the start of the partition. +* EXT2_SUPERBLOCK_OFFSET from the start of the partition. * * Note: we only save a backup copy of the superblock if we * are reading the superblock from the primary superblock location.
@@ -201,19 +201,19 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, group_block = superblock; fs->orig_super =0 ; }else { -io_channel_set_blksize (fs->io,SUPERBLOCK_OFFSET ); +io_channel_set_blksize (fs->io,EXT2_SUPERBLOCK_OFFSET ); superblock =1 ; group_block =0 ; - retval =ext2fs_get_mem (SUPERBLOCK_SIZE , &fs->orig_super); + retval =ext2fs_get_mem (EXT2_SUPERBLOCK_SIZE , &fs->orig_super);if (retval) goto cleanup; } - retval =io_channel_read_blk (fs->io, superblock, -SUPERBLOCK_SIZE , + retval =io_channel_read_blk (fs->io, superblock, -EXT2_SUPERBLOCK_SIZE , fs->super);if (retval) goto cleanup;if (fs->orig_super) -memcpy (fs->orig_super, fs->super,SUPERBLOCK_SIZE ); +memcpy (fs->orig_super, fs->super,EXT2_SUPERBLOCK_SIZE );if (!(fs->flags &EXT2_FLAG_IGNORE_CSUM_ERRORS )) { retval =0 ;
lib/ext2fs/tst_badblocks.c +2 -2
@@ -225,8 +225,8 @@ int file_test_invalid(badblocks_list bb) fs =malloc (sizeof (struct struct_ext2_filsys ));memset (fs,0 ,sizeof (struct struct_ext2_filsys )); fs->magic =EXT2_ET_MAGIC_EXT2FS_FILSYS ; - fs->super =malloc (SUPERBLOCK_SIZE ); -memset (fs->super,0 ,SUPERBLOCK_SIZE ); + fs->super =malloc (EXT2_SUPERBLOCK_SIZE ); +memset (fs->super,0 ,EXT2_SUPERBLOCK_SIZE ); fs->super->s_first_data_block =1 ;ext2fs_blocks_count_set (fs->super,100 );
lib/ext2fs/undo_io.c +2 -2
@@ -113,8 +113,8 @@ static errcode_t write_file_system_identity(io_channel undo_channel, channel = data->real; block_size = channel->block_size; -io_channel_set_blksize (channel,SUPERBLOCK_OFFSET ); - retval =io_channel_read_blk64 (channel,1 , -SUPERBLOCK_SIZE , &super); +io_channel_set_blksize (channel,EXT2_SUPERBLOCK_OFFSET ); + retval =io_channel_read_blk64 (channel,1 , -EXT2_SUPERBLOCK_SIZE , &super);if (retval) goto err_out;
misc/e2undo.c +2 -2
@@ -45,8 +45,8 @@ static int check_filesystem(TDB_CONTEXT *tdb, io_channel channel)TDB_DATA tdb_key, tdb_data;struct ext2_super_block super; -io_channel_set_blksize (channel,SUPERBLOCK_OFFSET ); - retval =io_channel_read_blk64 (channel,1 , -SUPERBLOCK_SIZE , &super); +io_channel_set_blksize (channel,EXT2_SUPERBLOCK_OFFSET ); + retval =io_channel_read_blk64 (channel,1 , -EXT2_SUPERBLOCK_SIZE , &super);if (retval) {com_err (prg_name, retval,"%s" ,_ ("Failed to read the file system data \n" ));
misc/mke2fs.c +2 -2
@@ -2398,8 +2398,8 @@ static int should_do_undo(const char *name) goto open_err_out; } -io_channel_set_blksize (channel,SUPERBLOCK_OFFSET ); - retval =io_channel_read_blk64 (channel,1 , -SUPERBLOCK_SIZE , &super); +io_channel_set_blksize (channel,EXT2_SUPERBLOCK_OFFSET ); + retval =io_channel_read_blk64 (channel,1 , -EXT2_SUPERBLOCK_SIZE , &super);if (retval) { retval =0 ; goto err_out;
misc/tune2fs.c +6 -6
@@ -183,7 +183,7 @@ static __u32 clear_ok_features[3] = {/** * Try to get journal super block if any */ -static int get_journal_sb (ext2_filsys jfs,char buf[SUPERBLOCK_SIZE ]) +static int get_journal_sb (ext2_filsys jfs,char buf[EXT2_SUPERBLOCK_SIZE ]) {int retval;int start;
@@ -196,7 +196,7 @@ static int get_journal_sb(ext2_filsys jfs, char buf[SUPERBLOCK_SIZE])/* Get the journal superblock */ if ((retval =io_channel_read_blk64 (jfs->io, -ext2fs_journal_sb_start (jfs->blocksize), -SUPERBLOCK_SIZE , buf))) { +ext2fs_journal_sb_start (jfs->blocksize), -EXT2_SUPERBLOCK_SIZE , buf))) {com_err (program_name, retval,"%s" ,_ ("while reading journal superblock" ));return retval;
@@ -219,7 +219,7 @@ static int remove_journal_device(ext2_filsys fs) {char *journal_path;ext2_filsys jfs; -char buf[SUPERBLOCK_SIZE ]; +char buf[EXT2_SUPERBLOCK_SIZE ];journal_superblock_t *jsb;int i, nr_users;errcode_t retval;
@@ -283,7 +283,7 @@ static int remove_journal_device(ext2_filsys fs)/* Write back the journal superblock */ if ((retval =io_channel_write_blk64 (jfs->io, start, - -SUPERBLOCK_SIZE , buf))) { + -EXT2_SUPERBLOCK_SIZE , buf))) {com_err (program_name, retval,"while writing journal superblock." ); goto no_valid_journal;
@@ -2713,7 +2713,7 @@ retry_open:if (U_flag) {int set_csum =0 ;dgrp_t i; -char buf[SUPERBLOCK_SIZE ]; +char buf[EXT2_SUPERBLOCK_SIZE ];if (ext2fs_has_group_desc_csum (fs)) {/*
@@ -2771,7 +2771,7 @@ retry_open:/* Writeback the journal superblock */ if ((rc =io_channel_write_blk64 (fs->io,ext2fs_journal_sb_start (fs->blocksize), - -SUPERBLOCK_SIZE , buf))) + -EXT2_SUPERBLOCK_SIZE , buf))) goto closefs; }else if (rc !=EXT2_ET_UNSUPP_FEATURE ) goto closefs;
Signature · 1 line
2.0.0
Quoted 5 lines · Azat Khuzhin
Since mostly all macros have this prefix, and to avoid potential name clashes.
Proposed-by Andreas Dilger <[email protected]>Signed-off-by Azat Khuzhin <[email protected]>
You can add:
If you are refreshing the whole series, it might make sense to move this first, instead of adding a bunch of SUPERBLOCK_{SIZE,OFFSET} uses, and then changing them to EXT2_SUPERBLOCK_{SIZE,OFFSET} in the next patch. Not a huge deal either way, just a suggestion.
Quoted 434 lines
---
v2: don't replcae gfs consts (pattern error, thanks to Darrick J. Wong)e2fsck/journal.c | 2 +- e2fsck/super.c | 4 ++-- e2fsck/util.c | 4 ++-- lib/ext2fs/closefs.c | 18 +++++++++--------- lib/ext2fs/dupfs.c | 8 ++++---- lib/ext2fs/ext2fs.h | 10 ++++++++-- lib/ext2fs/imager.c | 4 ++-- lib/ext2fs/initialize.c | 4 ++-- lib/ext2fs/mkjournal.c | 6 +++--- lib/ext2fs/openfs.c | 12 ++++++------ lib/ext2fs/tst_badblocks.c | 4 ++-- lib/ext2fs/undo_io.c | 4 ++-- misc/e2undo.c | 4 ++-- misc/mke2fs.c | 4 ++-- misc/tune2fs.c | 12 ++++++------ 15 files changed, 53 insertions(+), 47 deletions(-)e2fsck/journal.c +1
-1@@ -454,7 +454,7 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)brelse (bh); goto errout; } -memcpy (&jsuper, start ? bh->b_data : bh->b_data +SUPERBLOCK_OFFSET , +memcpy (&jsuper, start ? bh->b_data : bh->b_data +EXT2_SUPERBLOCK_OFFSET ,sizeof (jsuper));brelse (bh);#ifdef WORDS_BIGENDIAN e2fsck/super.c +2
-2@@ -921,7 +921,7 @@ int check_backup_super_block(e2fsck_t ctx)dgrp_t g;blk64_t sb;int ret =0 ; -char buf[SUPERBLOCK_SIZE ]; +char buf[EXT2_SUPERBLOCK_SIZE ];struct ext2_super_block *backup_sb;/* @@ -944,7 +944,7 @@ int check_backup_super_block(e2fsck_t ctx) sb =ext2fs_group_first_block2 (fs, g); - retval =io_channel_read_blk (fs->io, sb, -SUPERBLOCK_SIZE , + retval =io_channel_read_blk (fs->io, sb, -EXT2_SUPERBLOCK_SIZE , buf);if (retval)continue ;e2fsck/util.c +2
-2@@ -540,7 +540,7 @@ blk64_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs, const char *name,if (manager->open (name,0 , &io) !=0 ) goto cleanup; -if (ext2fs_get_mem (SUPERBLOCK_SIZE , &buf)) +if (ext2fs_get_mem (EXT2_SUPERBLOCK_SIZE , &buf)) goto cleanup; sb = (struct ext2_super_block *) buf;@@ -551,7 +551,7 @@ blk64_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs, const char *name, superblock++;io_channel_set_blksize (io, blocksize);if (io_channel_read_blk64 (io, superblock, - -SUPERBLOCK_SIZE , buf)) + -EXT2_SUPERBLOCK_SIZE , buf))continue ;#ifdef WORDS_BIGENDIAN if (sb->s_magic ==ext2fs_swab16 (EXT2_SUPER_MAGIC ))lib/ext2fs/closefs.c +9
-9@@ -199,8 +199,8 @@ static errcode_t write_primary_superblock(ext2_filsys fs,if (!fs->io->manager->write_byte || !fs->orig_super) { fallback: -io_channel_set_blksize (fs->io,SUPERBLOCK_OFFSET ); - retval =io_channel_write_blk64 (fs->io,1 , -SUPERBLOCK_SIZE , +io_channel_set_blksize (fs->io,EXT2_SUPERBLOCK_OFFSET ); + retval =io_channel_write_blk64 (fs->io,1 , -EXT2_SUPERBLOCK_SIZE , super);io_channel_set_blksize (fs->io, fs->blocksize);return retval;@@ -209,11 +209,11 @@ static errcode_t write_primary_superblock(ext2_filsys fs, old_super = (__u16 *) fs->orig_super; new_super = (__u16 *) super; -for (check_idx =0 ; check_idx <SUPERBLOCK_SIZE /2 ; check_idx++) { +for (check_idx =0 ; check_idx <EXT2_SUPERBLOCK_SIZE /2 ; check_idx++) {if (old_super[check_idx] == new_super[check_idx])continue ; write_idx = check_idx; -for (check_idx++; check_idx <SUPERBLOCK_SIZE /2 ; check_idx++) +for (check_idx++; check_idx <EXT2_SUPERBLOCK_SIZE /2 ; check_idx++)if (old_super[check_idx] == new_super[check_idx])break ; size =2 * (check_idx - write_idx);@@ -222,14 +222,14 @@ static errcode_t write_primary_superblock(ext2_filsys fs, size, write_idx*2);#endif retval =io_channel_write_byte (fs->io, -SUPERBLOCK_OFFSET + (2 * write_idx), size, +EXT2_SUPERBLOCK_OFFSET + (2 * write_idx), size, new_super + write_idx);if (retval ==EXT2_ET_UNIMPLEMENTED ) goto fallback;if (retval)return retval; } -memcpy (fs->orig_super, super,SUPERBLOCK_SIZE ); +memcpy (fs->orig_super, super,EXT2_SUPERBLOCK_SIZE );return 0 ; }@@ -269,7 +269,7 @@ static errcode_t write_backup_super(ext2_filsys fs, dgrp_t group,if (retval)return retval; -return io_channel_write_blk64 (fs->io, group_block, -SUPERBLOCK_SIZE , +return io_channel_write_blk64 (fs->io, group_block, -EXT2_SUPERBLOCK_SIZE , super_shadow); }@@ -320,7 +320,7 @@ errcode_t ext2fs_flush2(ext2_filsys fs, int flags)/* Prepare the group descriptors for writing */ #ifdef WORDS_BIGENDIAN retval =EXT2_ET_NO_MEMORY ; - retval =ext2fs_get_mem (SUPERBLOCK_SIZE , &super_shadow); + retval =ext2fs_get_mem (EXT2_SUPERBLOCK_SIZE , &super_shadow);if (retval) goto errout; retval = ext2fs_get_array(fs->desc_blocks, fs->blocksize,@@ -412,7 +412,7 @@ write_primary_superblock_only:/* * Write out master superblock. This has to be done * separately, since it is located at a fixed location -* (SUPERBLOCK_OFFSET). We flush all other pending changes +* (EXT2_SUPERBLOCK_OFFSET). We flush all other pending changes * out to disk first, just to avoid a race condition with an * insy-tinsy window.... */ lib/ext2fs/dupfs.c +4
-4@@ -53,15 +53,15 @@ errcode_t ext2fs_dup_handle(ext2_filsys src, ext2_filsys *dest) goto errout;strcpy (fs->device_name, src->device_name); - retval =ext2fs_get_mem (SUPERBLOCK_SIZE , &fs->super); + retval =ext2fs_get_mem (EXT2_SUPERBLOCK_SIZE , &fs->super);if (retval) goto errout; -memcpy (fs->super, src->super,SUPERBLOCK_SIZE ); +memcpy (fs->super, src->super,EXT2_SUPERBLOCK_SIZE ); - retval =ext2fs_get_mem (SUPERBLOCK_SIZE , &fs->orig_super); + retval =ext2fs_get_mem (EXT2_SUPERBLOCK_SIZE , &fs->orig_super);if (retval) goto errout; -memcpy (fs->orig_super, src->orig_super,SUPERBLOCK_SIZE ); +memcpy (fs->orig_super, src->orig_super,EXT2_SUPERBLOCK_SIZE ); retval =ext2fs_get_array (fs->desc_blocks, fs->blocksize, &fs->group_desc);lib/ext2fs/ext2fs.h +8
-2@@ -36,8 +36,14 @@ extern "C" {* (some versions have the padding set up so that the superblock is * 1032 bytes long). */ -#define SUPERBLOCK_OFFSET 1024 -#define SUPERBLOCK_SIZE 1024 +#define EXT2_SUPERBLOCK_OFFSET 1024 +#define EXT2_SUPERBLOCK_SIZE 1024 +/** +* Deprecated, will be removed in the next release +* Instead use EXT2_* with the same names. +*/ +#define SUPERBLOCK_OFFSET EXT2_SUPERBLOCK_OFFSET +#define SUPERBLOCK_SIZE EXT2_SUPERBLOCK_SIZE/* * The last ext2fs revision level that this version of the library is lib/ext2fs/imager.c +2
-2@@ -203,7 +203,7 @@ errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd,* Write out the superblock */ memset (buf,0 , fs->blocksize); -memcpy (buf, fs->super,SUPERBLOCK_SIZE ); +memcpy (buf, fs->super,EXT2_SUPERBLOCK_SIZE ); actual =write (fd, buf, fs->blocksize);if (actual ==-1 ) { retval = errno;@@ -266,7 +266,7 @@ errcode_t ext2fs_image_super_read(ext2_filsys fs, int fd,/* * Now copy in the superblock and group descriptors */ -memcpy (fs->super, buf,SUPERBLOCK_SIZE ); +memcpy (fs->super, buf,EXT2_SUPERBLOCK_SIZE );memcpy (fs->group_desc, buf + fs->blocksize, fs->blocksize * fs->group_desc_count);lib/ext2fs/initialize.c +2
-2@@ -133,12 +133,12 @@ errcode_t ext2fs_initialize(const char *name, int flags, goto cleanup;strcpy (fs->device_name, name); - retval =ext2fs_get_mem (SUPERBLOCK_SIZE , &super); + retval =ext2fs_get_mem (EXT2_SUPERBLOCK_SIZE , &super);if (retval) goto cleanup; fs->super = super; -memset (super,0 ,SUPERBLOCK_SIZE ); +memset (super,0 ,EXT2_SUPERBLOCK_SIZE );#define set_field (field, default) (super->field = param->field ? \ param->field : (default))lib/ext2fs/mkjournal.c +3
-3@@ -441,7 +441,7 @@ errcode_t ext2fs_add_journal_device(ext2_filsys fs, ext2_filsys journal_dev) {struct stat st;errcode_t retval; -char buf[SUPERBLOCK_SIZE ]; +char buf[EXT2_SUPERBLOCK_SIZE ];journal_superblock_t *jsb;int start;__u32 i, nr_users;@@ -456,7 +456,7 @@ errcode_t ext2fs_add_journal_device(ext2_filsys fs, ext2_filsys journal_dev)/* Get the journal superblock */ start =ext2fs_journal_sb_start (journal_dev->blocksize);if ((retval =io_channel_read_blk64 (journal_dev->io, start, - -SUPERBLOCK_SIZE , + -EXT2_SUPERBLOCK_SIZE , buf)))return retval;@@ -483,7 +483,7 @@ errcode_t ext2fs_add_journal_device(ext2_filsys fs, ext2_filsys journal_dev)/* Writeback the journal superblock */ if ((retval =io_channel_write_blk64 (journal_dev->io, start, - -SUPERBLOCK_SIZE , buf))) + -EXT2_SUPERBLOCK_SIZE , buf)))return retval; fs->super->s_journal_inum =0 ;lib/ext2fs/openfs.c +6
-6@@ -164,7 +164,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, goto cleanup; fs->image_io = fs->io; fs->io->app_data = fs; - retval =io_channel_alloc_buf (fs->io, -SUPERBLOCK_SIZE , &fs->super); + retval =io_channel_alloc_buf (fs->io, -EXT2_SUPERBLOCK_SIZE , &fs->super);if (retval) goto cleanup;if (flags &EXT2_FLAG_IMAGE_FILE ) {@@ -187,7 +187,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,* If the user specifies a specific block # for the * superblock, then he/she must also specify the block size! * Otherwise, read the master superblock located at offset -* SUPERBLOCK_OFFSET from the start of the partition. +* EXT2_SUPERBLOCK_OFFSET from the start of the partition. * * Note: we only save a backup copy of the superblock if we * are reading the superblock from the primary superblock location. @@ -201,19 +201,19 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, group_block = superblock; fs->orig_super =0 ; }else { -io_channel_set_blksize (fs->io,SUPERBLOCK_OFFSET ); +io_channel_set_blksize (fs->io,EXT2_SUPERBLOCK_OFFSET ); superblock =1 ; group_block =0 ; - retval =ext2fs_get_mem (SUPERBLOCK_SIZE , &fs->orig_super); + retval =ext2fs_get_mem (EXT2_SUPERBLOCK_SIZE , &fs->orig_super);if (retval) goto cleanup; } - retval =io_channel_read_blk (fs->io, superblock, -SUPERBLOCK_SIZE , + retval =io_channel_read_blk (fs->io, superblock, -EXT2_SUPERBLOCK_SIZE , fs->super);if (retval) goto cleanup;if (fs->orig_super) -memcpy (fs->orig_super, fs->super,SUPERBLOCK_SIZE ); +memcpy (fs->orig_super, fs->super,EXT2_SUPERBLOCK_SIZE );if (!(fs->flags &EXT2_FLAG_IGNORE_CSUM_ERRORS )) { retval =0 ;lib/ext2fs/tst_badblocks.c +2
-2@@ -225,8 +225,8 @@ int file_test_invalid(badblocks_list bb) fs =malloc (sizeof (struct struct_ext2_filsys ));memset (fs,0 ,sizeof (struct struct_ext2_filsys )); fs->magic =EXT2_ET_MAGIC_EXT2FS_FILSYS ; - fs->super =malloc (SUPERBLOCK_SIZE ); -memset (fs->super,0 ,SUPERBLOCK_SIZE ); + fs->super =malloc (EXT2_SUPERBLOCK_SIZE ); +memset (fs->super,0 ,EXT2_SUPERBLOCK_SIZE ); fs->super->s_first_data_block =1 ;ext2fs_blocks_count_set (fs->super,100 );lib/ext2fs/undo_io.c +2
-2@@ -113,8 +113,8 @@ static errcode_t write_file_system_identity(io_channel undo_channel, channel = data->real; block_size = channel->block_size; -io_channel_set_blksize (channel,SUPERBLOCK_OFFSET ); - retval =io_channel_read_blk64 (channel,1 , -SUPERBLOCK_SIZE , &super); +io_channel_set_blksize (channel,EXT2_SUPERBLOCK_OFFSET ); + retval =io_channel_read_blk64 (channel,1 , -EXT2_SUPERBLOCK_SIZE , &super);if (retval) goto err_out;misc/e2undo.c +2
-2@@ -45,8 +45,8 @@ static int check_filesystem(TDB_CONTEXT *tdb, io_channel channel)TDB_DATA tdb_key, tdb_data;struct ext2_super_block super; -io_channel_set_blksize (channel,SUPERBLOCK_OFFSET ); - retval =io_channel_read_blk64 (channel,1 , -SUPERBLOCK_SIZE , &super); +io_channel_set_blksize (channel,EXT2_SUPERBLOCK_OFFSET ); + retval =io_channel_read_blk64 (channel,1 , -EXT2_SUPERBLOCK_SIZE , &super);if (retval) {com_err (prg_name, retval,"%s" ,_ ("Failed to read the file system data \n" ));misc/mke2fs.c +2
-2@@ -2398,8 +2398,8 @@ static int should_do_undo(const char *name) goto open_err_out; } -io_channel_set_blksize (channel,SUPERBLOCK_OFFSET ); - retval =io_channel_read_blk64 (channel,1 , -SUPERBLOCK_SIZE , &super); +io_channel_set_blksize (channel,EXT2_SUPERBLOCK_OFFSET ); + retval =io_channel_read_blk64 (channel,1 , -EXT2_SUPERBLOCK_SIZE , &super);if (retval) { retval =0 ; goto err_out;misc/tune2fs.c +6
-6@@ -183,7 +183,7 @@ static __u32 clear_ok_features[3] = {/** * Try to get journal super block if any */ -static int get_journal_sb (ext2_filsys jfs,char buf[SUPERBLOCK_SIZE ]) +static int get_journal_sb (ext2_filsys jfs,char buf[EXT2_SUPERBLOCK_SIZE ]) {int retval;int start;@@ -196,7 +196,7 @@ static int get_journal_sb(ext2_filsys jfs, char buf[SUPERBLOCK_SIZE])/* Get the journal superblock */ if ((retval =io_channel_read_blk64 (jfs->io, -ext2fs_journal_sb_start (jfs->blocksize), -SUPERBLOCK_SIZE , buf))) { +ext2fs_journal_sb_start (jfs->blocksize), -EXT2_SUPERBLOCK_SIZE , buf))) {com_err (program_name, retval,"%s" ,_ ("while reading journal superblock" ));return retval;@@ -219,7 +219,7 @@ static int remove_journal_device(ext2_filsys fs) {char *journal_path;ext2_filsys jfs; -char buf[SUPERBLOCK_SIZE ]; +char buf[EXT2_SUPERBLOCK_SIZE ];journal_superblock_t *jsb;int i, nr_users;errcode_t retval;@@ -283,7 +283,7 @@ static int remove_journal_device(ext2_filsys fs)/* Write back the journal superblock */ if ((retval =io_channel_write_blk64 (jfs->io, start, - -SUPERBLOCK_SIZE , buf))) { + -EXT2_SUPERBLOCK_SIZE , buf))) {com_err (program_name, retval,"while writing journal superblock." ); goto no_valid_journal;@@ -2713,7 +2713,7 @@ retry_open:if (U_flag) {int set_csum =0 ;dgrp_t i; -char buf[SUPERBLOCK_SIZE ]; +char buf[EXT2_SUPERBLOCK_SIZE ];if (ext2fs_has_group_desc_csum (fs)) {/* @@ -2771,7 +2771,7 @@ retry_open:/* Writeback the journal superblock */ if ((rc =io_channel_write_blk64 (fs->io,ext2fs_journal_sb_start (fs->blocksize), - -SUPERBLOCK_SIZE , buf))) + -EXT2_SUPERBLOCK_SIZE , buf))) goto closefs; }else if (rc !=EXT2_ET_UNSUPP_FEATURE ) goto closefs;Signature · 1 line
2.0.0
Cheers, Andreas
Quoted 9 lines · Andreas Dilger
Quoted 5 lines · Azat Khuzhin
Since mostly all macros have this prefix, and to avoid potential name clashes.
Proposed-by Andreas Dilger <[email protected]>Signed-off-by Azat Khuzhin <[email protected]>
Quoted 8 lines
You can add:
Reviewed-by Andreas Dilger <[email protected]>If you are refreshing the whole series, it might make sense to move this first, instead of adding a bunch of SUPERBLOCK_{SIZE,OFFSET} uses, and then changing them to EXT2_SUPERBLOCK_{SIZE,OFFSET} in the next patch. Not a huge deal either way, just a suggestion.
Yeah, that's a good point, I will do this.
Thanks.
Cheers, Azat.
Signature · 2 lines
Respectfully Azat Khuzhin