Whamcloud - gitweb
fs_ext2.c, fsimext2.c: Synchronize with EVMS CVS tree.
authorTheodore Ts'o <tytso@mit.edu>
Sun, 18 Aug 2002 05:48:46 +0000 (01:48 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 18 Aug 2002 05:48:46 +0000 (01:48 -0400)
Fixed up confusion caused by bad parameter names for
get_fs_limits().  Added missing conversion of
volume->vol_size from sectors to bytes.  Fix up error
returns for unsupported tasks as EINVAL, not ENOSYS.
Use logical names for the API version numbers, since
the ABI is much more dependent on the headers.  Add
code to byte-swap the superblock if necessary.

lib/evms/ChangeLog
lib/evms/fs_ext2.c
lib/evms/fsimext2.c

index 42bb840..6f52bb0 100644 (file)
@@ -1,5 +1,14 @@
 2002-08-17  Theodore Ts'o  <tytso@mit.edu>
 
+       * fs_ext2.c, fsimext2.c: Synchronize with EVMS CVS tree.
+               Fixed up confusion caused by bad parameter names for
+               get_fs_limits().  Added missing conversion of
+               volume->vol_size from sectors to bytes.  Fix up error 
+               returns for unsupported tasks as EINVAL, not ENOSYS.
+               Use logical names for the API version numbers, since 
+               the ABI is much more dependent on the headers.  Add
+               code to byte-swap the superblock if necessary.
+
        * common.h, dlist.h, enginestructs.h, options.h, plugfuncs.c, 
                fs_ext2.c: Synchronize with ABI of EVMS 1.1.
 
index e54d7e1..2d0a946 100644 (file)
@@ -219,9 +219,9 @@ static int fs_get_fs_size( logical_volume_t * volume,
  * Get the size limits for this volume.
  */
 static int fs_get_fs_limits( logical_volume_t * volume,
-                                                sector_count_t   * min_size,
-                                                sector_count_t   * max_volume_size,
-                                                sector_count_t   * max_object_size)
+                                                sector_count_t   * fs_min_size,
+                                                sector_count_t   * fs_max_size,
+                                                sector_count_t   * vol_max_size)
 {
        int rc = EINVAL;
        struct ext2_super_block *sb_ptr = (struct ext2_super_block *) volume->private_data;
@@ -237,13 +237,13 @@ static int fs_get_fs_limits( logical_volume_t * volume,
     rc = fsim_get_ext2_superblock( volume, sb_ptr );
     
     if ( !rc ) {
-           rc = fsim_get_volume_limits( sb_ptr, min_size, max_volume_size, max_object_size);
-           LOG_EXTRA("volume:%s, min:%lld, max:%lld\n",EVMS_GET_DEVNAME(volume), *min_size, *max_volume_size);
+           rc = fsim_get_volume_limits( sb_ptr, fs_min_size, fs_max_size, vol_max_size);
+           LOG_EXTRA("volume:%s, min:%lld, max:%lld\n",EVMS_GET_DEVNAME(volume), *fs_min_size, *fs_max_size);
            LOG_EXTRA("fssize:%lld, vol_size:%lld\n",volume->fs_size,volume->vol_size );
 
-           if (*min_size > volume->vol_size) {
+           if (*fs_min_size > volume->vol_size) {
                    LOG_ERROR("EXT2 FSIM returned min size > volume size, setting min size to volume size\n");
-                   *min_size = volume->vol_size;
+                   *fs_min_size = volume->vol_size;
            }
     }
 
@@ -649,7 +649,7 @@ static int fs_init_task( task_context_t * context )
                        /* only mkfs unformatted volumes */
                        if ((volume->file_system_manager == NULL) &&
                            !EVMS_IS_MOUNTED(volume) &&
-                           (volume->vol_size > MINEXT2)) {
+                           ((volume->vol_size * PBSIZE) > MINEXT2)) {
                                rc = InsertObject(context->acceptable_objects, sizeof(logical_volume_t), volume, VOLUME_TAG, NULL, InsertAtStart, TRUE, (void **)&waste);
                        }
                        break;
@@ -662,7 +662,7 @@ static int fs_init_task( task_context_t * context )
                        break;
 
                default:
-                       rc = ENOSYS;
+                       rc = EINVAL;
                        break;
                }
        }
@@ -840,6 +840,7 @@ static int fs_init_task( task_context_t * context )
                break;
 
        default:
+               rc = EINVAL;
                break;
        }
 
@@ -1078,7 +1079,7 @@ static int fs_get_volume_info( logical_volume_t        * volume,
 
        /* reset limits. */
        fs_get_fs_limits( volume, &volume->min_fs_size,
-                        &volume->max_vol_size, &volume->max_fs_size);
+                         &volume->max_fs_size, &volume->max_vol_size);
 
        Info = EngFncs->engine_alloc( sizeof(extended_info_array_t) + ( 5 * sizeof(extended_info_t) ) );
 
@@ -1094,7 +1095,7 @@ static int fs_get_volume_info( logical_volume_t        * volume,
        SET_STRING_FIELD( Info->info[0].desc, "Ext2 Revision Number.");
        Info->info[0].type               = EVMS_Type_Unsigned_Int32;
        Info->info[0].unit               = EVMS_Unit_None;
-       Info->info[0].value.ui64         = sb_ptr->s_rev_level;
+       Info->info[0].value.ui32         = sb_ptr->s_rev_level;
        Info->info[0].collection_type    = EVMS_Collection_None;
        memset( &Info->info[0].group, 0, sizeof(group_info_t));
 
@@ -1326,8 +1327,8 @@ static int fs_can_expand_by(logical_volume_t * volume,
        } 
        fs_get_fs_limits( volume,       /* reset limits */
                         &volume->min_fs_size,
-                        &volume->max_vol_size,
-                        &volume->max_fs_size);
+                        &volume->max_fs_size,
+                        &volume->max_vol_size);
        if (volume->fs_size + *delta > volume->max_fs_size) {
                *delta = volume->max_fs_size - volume->fs_size;
        }
@@ -1352,8 +1353,8 @@ static int fs_can_shrink_by(logical_volume_t * volume,
        } 
        fs_get_fs_limits( volume,       /* reset limits */
                         &volume->min_fs_size,
-                        &volume->max_vol_size,
-                        &volume->max_fs_size);
+                        &volume->max_fs_size,
+                        &volume->max_vol_size);
        if (volume->fs_size - *delta < volume->min_fs_size) {
                *delta = volume->fs_size - volume->min_fs_size;
        }
@@ -1411,12 +1412,12 @@ plugin_record_t  ext2_plugrec = {
                                           ENGINE_PLUGIN_API_MINOR_VERION,
                                           ENGINE_PLUGIN_API_PATCH_LEVEL},
 #else
-       required_engine_api_version:      {8
-                                          0,
-                                          0},
-       required_plugin_api_version: {fsim: {8
-                                          0,
-                                          0} },
+       required_engine_api_version:      {ENGINE_SERVICES_API_MAJOR_VERION
+                                          ENGINE_SERVICES_API_MINOR_VERION,
+                                          ENGINE_SERVICES_API_PATCH_LEVEL},
+       required_plugin_api_version: {fsim: {ENGINE_FSIM_API_MAJOR_VERION
+                                          ENGINE_FSIM_API_MINOR_VERION,
+                                          ENGINE_FSIM_API_PATCH_LEVEL} },
 #endif
        short_name:                       "Ext2/3",
        long_name:                        "Ext2 File System Interface Module",
index 29f38bb..325cce2 100644 (file)
@@ -63,15 +63,11 @@ int fsim_get_volume_limits( struct ext2_super_block * sb,
        sector_count_t fs_size;
        int             blk_to_sect;
 
-       /* 
-        * Since ext2/3 does not yet support shrink or expand,
-        * all values are actual file system size.
-        */
        blk_to_sect = (1 + sb->s_log_block_size);
        fs_size = sb->s_blocks_count << blk_to_sect;
        *fs_min_size = (sb->s_blocks_count - sb->s_free_blocks_count) << blk_to_sect;
        *fs_max_size = (sector_count_t) 1 << (32+blk_to_sect);
-       *vol_max_size = 0xffffffff;
+       *vol_max_size = 0xffffffffff;
 
        return rc;
 }
@@ -492,6 +488,57 @@ void set_fsck_options( option_array_t * options, char ** argv, logical_volume_t
     
     return;
 }
+/*
+ * NAME:ext2fs_swap_super
+ *
+ * FUNCTION: Swap all fields in the super block to CPU format.
+ *
+ * PARAMETERS:
+ *      sb   - pointer to superblock
+ *
+ * RETURNS:
+ *        void
+ */                        
+static void ext2fs_swap_super(struct ext2_super_block * sb)
+{
+       sb->s_inodes_count = DISK_TO_CPU32(sb->s_inodes_count);
+       sb->s_blocks_count = DISK_TO_CPU32(sb->s_blocks_count);
+       sb->s_r_blocks_count = DISK_TO_CPU32(sb->s_r_blocks_count);
+       sb->s_free_blocks_count = DISK_TO_CPU32(sb->s_free_blocks_count);
+       sb->s_free_inodes_count = DISK_TO_CPU32(sb->s_free_inodes_count);
+       sb->s_first_data_block = DISK_TO_CPU32(sb->s_first_data_block);
+       sb->s_log_block_size = DISK_TO_CPU32(sb->s_log_block_size);
+       sb->s_log_frag_size = DISK_TO_CPU32(sb->s_log_frag_size);
+       sb->s_blocks_per_group = DISK_TO_CPU32(sb->s_blocks_per_group);
+       sb->s_frags_per_group = DISK_TO_CPU32(sb->s_frags_per_group);
+       sb->s_inodes_per_group = DISK_TO_CPU32(sb->s_inodes_per_group);
+       sb->s_mtime = DISK_TO_CPU32(sb->s_mtime);
+       sb->s_wtime = DISK_TO_CPU32(sb->s_wtime);
+       sb->s_mnt_count = DISK_TO_CPU16(sb->s_mnt_count);
+       sb->s_max_mnt_count = DISK_TO_CPU16(sb->s_max_mnt_count);
+       sb->s_magic = DISK_TO_CPU16(sb->s_magic);
+       sb->s_state = DISK_TO_CPU16(sb->s_state);
+       sb->s_errors = DISK_TO_CPU16(sb->s_errors);
+       sb->s_minor_rev_level = DISK_TO_CPU16(sb->s_minor_rev_level);
+       sb->s_lastcheck = DISK_TO_CPU32(sb->s_lastcheck);
+       sb->s_checkinterval = DISK_TO_CPU32(sb->s_checkinterval);
+       sb->s_creator_os = DISK_TO_CPU32(sb->s_creator_os);
+       sb->s_rev_level = DISK_TO_CPU32(sb->s_rev_level);
+       sb->s_def_resuid = DISK_TO_CPU16(sb->s_def_resuid);
+       sb->s_def_resgid = DISK_TO_CPU16(sb->s_def_resgid);
+       sb->s_first_ino = DISK_TO_CPU32(sb->s_first_ino);
+       sb->s_inode_size = DISK_TO_CPU16(sb->s_inode_size);
+       sb->s_block_group_nr = DISK_TO_CPU16(sb->s_block_group_nr);
+       sb->s_feature_compat = DISK_TO_CPU32(sb->s_feature_compat);
+       sb->s_feature_incompat = DISK_TO_CPU32(sb->s_feature_incompat);
+       sb->s_feature_ro_compat = DISK_TO_CPU32(sb->s_feature_ro_compat);
+       sb->s_algorithm_usage_bitmap = DISK_TO_CPU32(sb->s_algorithm_usage_bitmap);
+       sb->s_journal_inum = DISK_TO_CPU32(sb->s_journal_inum);
+       sb->s_journal_dev = DISK_TO_CPU32(sb->s_journal_dev);
+       sb->s_last_orphan = DISK_TO_CPU32(sb->s_last_orphan);
+
+       return;
+}
 
 
 /*
@@ -520,6 +567,7 @@ int fsim_get_ext2_superblock( logical_volume_t *volume, struct ext2_super_block
     rc = fsim_rw_diskblocks( fd, EXT2_SUPER_LOC, SIZE_OF_SUPER, sb_ptr, GET );
 
     if( rc == 0 ) {
+       ext2fs_swap_super(sb_ptr);
         /* see if superblock is ext2/3 */
         if (( sb_ptr->s_magic != EXT2_SUPER_MAGIC ) ||
            ( sb_ptr->s_rev_level > 1 ))