~ubuntu-branches/ubuntu/precise/util-linux/precise-proposed

« back to all changes in this revision

Viewing changes to disk-utils/mkfs.cramfs.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2011-06-20 22:31:50 UTC
  • mfrom: (1.6.3 upstream) (4.5.1 sid)
  • Revision ID: james.westby@ubuntu.com-20110620223150-lz8wrv0946ihcz3z
Tags: 2.19.1-2ubuntu1
* Merge from Debian unstable, remaining changes:
  - Build for multiarch.
  - Add pre-depends on multiarch-support.
  - configure.ac: don't try to be clever about extracting a path name from
    $libdir to append to /usr in a way that's not overridable; instead,
    reuse the built-in configurable libexecdir.
  - Fix up the .pc.in files to know about libexecdir, so our substitutions
    don't leave us with unusable pkg-config files.
  - Install custom blkid.conf to use /dev/.blkid.tab since we don't
    expect device names to survive a reboot
  - Mention mountall(8) in fstab(5) manpages, along with its special
    options.
  - Since upstart is required in Ubuntu, the hwclock.sh init script is not
    called on startup and the hwclockfirst.sh init script is removed.
  - Drop depends on initscripts for the above.
  - Replace hwclock udev rule with an Upstart job.
  - For the case where mount is called with a directory to mount, look
    that directory up in mountall's /lib/init/fstab if we couldn't find
    it mentioned anywhere else.  This means "mount /proc", "mount /sys",
    etc. work.
  - mount.8 points to the cifs-utils package, not the obsolete smbfs one. 
* Dropped changes:
  - mount.preinst: lsb_release has been fixed in lucid and above to be
    usable without configuration, so we don't have to diverge from Debian
    here anymore.
* Changes merged upstream:
  - sfdisk support for '+' with '-N'
  - mount/umount.c: fix a segfault on umount with empty mtab entry
  - Fix arbitrary unmount with fuse security issue

Show diffs side-by-side

added added

removed removed

Lines of Context:
151
151
        void *t = malloc(size);
152
152
        if (t == NULL) {
153
153
                perror(NULL);
154
 
                exit(8);        /* out of memory */
 
154
                exit(MKFS_ERROR);       /* out of memory */
155
155
        }
156
156
        return t;
157
157
}
184
184
        start = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
185
185
        if (-1 == (int) (long) start) {
186
186
                perror("mmap");
187
 
                exit(8);
 
187
                exit(MKFS_ERROR);
188
188
        }
189
189
        close(fd);
190
190
 
310
310
 
311
311
        if (dircount < 0) {
312
312
                perror(name);
313
 
                exit(8);
 
313
                exit(MKFS_ERROR);
314
314
        }
315
315
 
316
316
        /* process directory */
340
340
                                  " Please increase MAX_INPUT_NAMELEN in "
341
341
                                  "mkcramfs.c and recompile.  Exiting.\n"),
342
342
                                namelen, dirent->d_name);
343
 
                        exit(8);
 
343
                        exit(MKFS_ERROR);
344
344
                }
345
345
                memcpy(endpath, dirent->d_name, namelen + 1);
346
346
 
352
352
                entry = calloc(1, sizeof(struct entry));
353
353
                if (!entry) {
354
354
                        perror(NULL);
355
 
                        exit(8);
 
355
                        exit(MKFS_ERROR);
356
356
                }
357
357
                entry->name = (unsigned char *)strdup(dirent->d_name);
358
358
                if (!entry->name) {
359
359
                        perror(NULL);
360
 
                        exit(8);
 
360
                        exit(MKFS_ERROR);
361
361
                }
362
362
                if (namelen > 255) {
363
363
                        /* Can't happen when reading from ext2fs. */
469
469
        inode_to_host(cramfs_is_big_endian, inode, inode);
470
470
        if (offset >= (1 << (2 + CRAMFS_OFFSET_WIDTH))) {
471
471
                fprintf(stderr, _("filesystem too big.  Exiting.\n"));
472
 
                exit(8);
 
472
                exit(MKFS_ERROR);
473
473
        }
474
474
        inode->offset = (offset >> 2);
475
475
        inode_from_host(cramfs_is_big_endian, inode, inode);
525
525
                                        entry_stack = realloc(entry_stack, stack_size * sizeof(struct entry *));
526
526
                                        if (!entry_stack) {
527
527
                                                perror(NULL);
528
 
                                                exit(8);        /* out of memory */
 
528
                                                exit(MKFS_ERROR);        /* out of memory */
529
529
                                        }
530
530
                                }
531
531
                                entry_stack[stack_entries] = entry;
636
636
                        printf(_("AIEEE: block \"compressed\" to > "
637
637
                                 "2*blocklength (%ld)\n"),
638
638
                               len);
639
 
                        exit(8);
 
639
                        exit(MKFS_ERROR);
640
640
                }
641
641
 
642
642
                *(u32 *) (base + offset) = u32_toggle_endianness(cramfs_is_big_endian, curr);
693
693
        fd = open(file, O_RDONLY);
694
694
        if (fd < 0) {
695
695
                perror(file);
696
 
                exit(8);
 
696
                exit(MKFS_ERROR);
697
697
        }
698
698
        buf = mmap(NULL, image_length, PROT_READ, MAP_PRIVATE, fd, 0);
699
699
        memcpy(base + offset, buf, image_length);
785
785
                        else if (strcmp(optarg, "host") == 0);  /* default */
786
786
                        else    {
787
787
                                perror("invalid endianness given. Must be 'big', 'little', or 'host'");
788
 
                                exit(16);
 
788
                                exit(MKFS_USAGE);
789
789
                        }
790
790
 
791
791
                        break;
793
793
                        opt_image = optarg;
794
794
                        if (lstat(opt_image, &st) < 0) {
795
795
                                perror(opt_image);
796
 
                                exit(16);
 
796
                                exit(MKFS_USAGE);
797
797
                        }
798
798
                        image_length = st.st_size; /* may be padded later */
799
799
                        fslen_ub += (image_length + 3); /* 3 is for padding */
811
811
                case 'V':
812
812
                        printf(_("%s (%s)\n"),
813
813
                               progname, PACKAGE_STRING);
814
 
                        exit(0);
 
814
                        exit(MKFS_OK);
815
815
                case 'v':
816
816
                        verbose = 1;
817
817
                        break;
828
828
 
829
829
        if (stat(dirname, &st) < 0) {
830
830
                perror(dirname);
831
 
                exit(16);
 
831
                exit(MKFS_USAGE);
832
832
        }
833
833
        fd = open(outfile, O_WRONLY | O_CREAT | O_TRUNC, 0666);
834
834
 
835
835
        root_entry = calloc(1, sizeof(struct entry));
836
836
        if (!root_entry) {
837
837
                perror(NULL);
838
 
                exit(8);
 
838
                exit(MKFS_ERROR);
839
839
        }
840
840
        root_entry->mode = st.st_mode;
841
841
        root_entry->uid = st.st_uid;
878
878
 
879
879
        if (-1 == (int) (long) rom_image) {
880
880
                perror(_("ROM image map"));
881
 
                exit(8);
 
881
                exit(MKFS_ERROR);
882
882
        }
883
883
 
884
884
        /* Skip the first opt_pad bytes for boot loader code */
925
925
                        _("not enough space allocated for ROM image "
926
926
                          "(%lld allocated, %zu used)\n"),
927
927
                        (long long) fslen_ub, offset);
928
 
                exit(8);
 
928
                exit(MKFS_ERROR);
929
929
        }
930
930
 
931
931
        written = write(fd, rom_image, offset);
932
932
        if (written < 0) {
933
933
                perror(_("ROM image"));
934
 
                exit(8);
 
934
                exit(MKFS_ERROR);
935
935
        }
936
936
        if (offset != written) {
937
937
                fprintf(stderr, _("ROM image write failed (%zd %zd)\n"),
938
938
                        written, offset);
939
 
                exit(8);
 
939
                exit(MKFS_ERROR);
940
940
        }
941
941
 
942
942
        /* (These warnings used to come at the start, but they scroll off the
970
970
                        CRAMFS_OFFSET_WIDTH);
971
971
        if (opt_errors &&
972
972
            (warn_namelen|warn_skip|warn_size|warn_uid|warn_gid|warn_dev))
973
 
                exit(8);
 
973
                exit(MKFS_ERROR);
974
974
        return 0;
975
975
}