~csurbhi/ubuntu/maverick/e2fsprogs/e2fsprogs.fix-505719

« back to all changes in this revision

Viewing changes to resize/main.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2008-08-08 20:32:11 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20080808203211-w72lpsd9q7o3bw6x
Tags: 1.41.0-3ubuntu1
* Merge from Debian unstable (LP: #254152, #246461), remaining changes:
  - Do not build-depend on dietlibc-dev, which is in universe.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
 
37
37
static void usage (char *prog)
38
38
{
39
 
        fprintf (stderr, _("Usage: %s [-d debug_flags] [-f] [-F] [-p] "
40
 
                           "device [new_size]\n\n"), prog);
 
39
        fprintf (stderr, _("Usage: %s [-d debug_flags] [-f] [-F] [-M] [-P] "
 
40
                           "[-p] device [new_size]\n\n"), prog);
41
41
 
42
42
        exit (1);
43
43
}
152
152
        int             flush = 0;
153
153
        int             force = 0;
154
154
        int             io_flags = 0;
 
155
        int             force_min_size = 0;
 
156
        int             print_min_size = 0;
155
157
        int             fd, ret;
156
158
        blk_t           new_size = 0;
157
159
        blk_t           max_size = 0;
183
185
        if (argc && *argv)
184
186
                program_name = *argv;
185
187
 
186
 
        while ((c = getopt (argc, argv, "d:fFhpS:")) != EOF) {
 
188
        while ((c = getopt (argc, argv, "d:fFhMPpS:")) != EOF) {
187
189
                switch (c) {
188
190
                case 'h':
189
191
                        usage(program_name);
194
196
                case 'F':
195
197
                        flush = 1;
196
198
                        break;
 
199
                case 'M':
 
200
                        force_min_size = 1;
 
201
                        break;
 
202
                case 'P':
 
203
                        print_min_size = 1;
 
204
                        break;
197
205
                case 'd':
198
206
                        flags |= atoi(optarg);
199
207
                        break;
298
306
                printf (_("Couldn't find valid filesystem superblock.\n"));
299
307
                exit (1);
300
308
        }
 
309
 
301
310
        /*
302
311
         * Check for compatibility with the feature sets.  We need to
303
312
         * be more stringent than ext2fs_open().
307
316
                        "(%s)", device_name);
308
317
                exit(1);
309
318
        }
 
319
 
 
320
        /*
 
321
         * XXXX   The combination of flex_bg and !resize_inode causes
 
322
         * major problems for resize2fs, since when the group descriptors
 
323
         * grow in size this can potentially require multiple inode
 
324
         * tables to be moved aside to make room, and resize2fs chokes
 
325
         * rather badly in this scenario.  It's a rare combination,
 
326
         * except when a filesystem is expanded more than a certain
 
327
         * size, so for now, we'll just prohibit that combination.
 
328
         * This is something we should fix eventually, though.
 
329
         */
 
330
        if ((fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_FLEX_BG) &&
 
331
            !(fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INODE)) {
 
332
                com_err(program_name, 0, _("%s: The combination of flex_bg "
 
333
                                           "and\n\t!resize_inode features "
 
334
                                           "is not supported by resize2fs.\n"),
 
335
                        device_name);
 
336
                exit(1);
 
337
        }
310
338
        
 
339
        if (print_min_size) {
 
340
                printf(_("Estimated minimum size of the filesystem: %u\n"),
 
341
                       calculate_minimum_resize_size(fs));
 
342
                exit(0);
 
343
        }
 
344
 
311
345
        /* Determine the system page size if possible */
312
346
#ifdef HAVE_SYSCONF
313
347
#if (!defined(_SC_PAGESIZE) && defined(_SC_PAGE_SIZE))
332
366
                        _("while trying to determine filesystem size"));
333
367
                exit(1);
334
368
        }
335
 
        if (new_size_str) {
 
369
        if (force_min_size)
 
370
                new_size = calculate_minimum_resize_size(fs);
 
371
        else if (new_size_str) {
336
372
                new_size = parse_num_blocks(new_size_str, 
337
373
                                            fs->super->s_log_block_size);
338
 
                if (!new_size) {
339
 
                        com_err(program_name, 0, _("bad filesystem size - %s"),
340
 
                                new_size_str);
341
 
                        exit(1);
342
 
                }
343
374
        } else {
344
375
                new_size = max_size;
345
376
                /* Round down to an even multiple of a pagesize */