diff --git a/libcustomext2fs/source/bb_inode.c b/libcustomext2fs/source/bb_inode.c index 0b79b164..0b6c3dd2 100644 --- a/libcustomext2fs/source/bb_inode.c +++ b/libcustomext2fs/source/bb_inode.c @@ -65,8 +65,7 @@ errcode_t ext2fs_update_bb_inode(ext2_filsys fs, ext2_badblocks_list bb_list) if (!fs->block_map) return EXT2_ET_NO_BLOCK_BITMAP; - rec.bad_block_count = 0; - rec.ind_blocks_size = rec.ind_blocks_ptr = 0; + memset(&rec, 0, sizeof(rec)); rec.max_ind_blocks = 10; retval = ext2fs_get_array(rec.max_ind_blocks, sizeof(blk_t), &rec.ind_blocks); diff --git a/libcustomext2fs/source/block.c b/libcustomext2fs/source/block.c index ff0d8bd3..0e4ec775 100644 --- a/libcustomext2fs/source/block.c +++ b/libcustomext2fs/source/block.c @@ -110,7 +110,7 @@ static int block_iterate_ind(blk_t *ind_block, blk_t ref_block, } else { for (i = 0; i < limit; i++, ctx->bcount++, block_nr++) { if (*block_nr == 0) - continue; + goto skip_sparse; blk64 = *block_nr; flags = (*ctx->func)(ctx->fs, &blk64, ctx->bcount, *ind_block, offset, @@ -121,6 +121,7 @@ static int block_iterate_ind(blk_t *ind_block, blk_t ref_block, ret |= BLOCK_ABORT; break; } + skip_sparse: offset += sizeof(blk_t); } } diff --git a/libcustomext2fs/source/csum.c b/libcustomext2fs/source/csum.c index 0ef9ade5..58e29710 100644 --- a/libcustomext2fs/source/csum.c +++ b/libcustomext2fs/source/csum.c @@ -159,6 +159,8 @@ errcode_t ext2fs_set_gdt_csum(ext2_filsys fs) } #ifdef DEBUG +#include "e2p/e2p.h" + void print_csum(const char *msg, ext2_filsys fs, dgrp_t group) { __u16 crc1, crc2, crc3; @@ -195,9 +197,9 @@ void print_csum(const char *msg, ext2_filsys fs, dgrp_t group) if (offset < size) crc3 = ext2fs_crc16(crc3, (char *)desc + offset, size - offset); - printf("%s: UUID %016Lx%016Lx(%04x), grp %u(%04x): %04x=%04x\n", - msg, *(long long *)&sb->s_uuid, *(long long *)&sb->s_uuid[8], - crc1, group, crc2, crc3, ext2fs_group_desc_csum(fs, group)); + printf("%s: UUID %s(%04x), grp %u(%04x): %04x=%04x\n", + msg, e2p_uuid2str(sb->s_uuid), crc1, group, crc2, crc3, + ext2fs_group_desc_csum(fs, group)); } unsigned char sb_uuid[16] = { 0x4f, 0x25, 0xe8, 0xcf, 0xe7, 0x97, 0x48, 0x23, diff --git a/libcustomext2fs/source/dir_iterate.c b/libcustomext2fs/source/dir_iterate.c index afe0f1a2..88f6b476 100644 --- a/libcustomext2fs/source/dir_iterate.c +++ b/libcustomext2fs/source/dir_iterate.c @@ -29,7 +29,9 @@ errcode_t ext2fs_get_rec_len(ext2_filsys fs, { unsigned int len = dirent->rec_len; - if (len == EXT4_MAX_REC_LEN || len == 0) + if (fs->blocksize < 65536) + *rec_len = len; + else if (len == EXT4_MAX_REC_LEN || len == 0) *rec_len = fs->blocksize; else *rec_len = (len & 65532) | ((len & 3) << 16); diff --git a/libcustomext2fs/source/e2p/e2p.h b/libcustomext2fs/source/e2p/e2p.h deleted file mode 100644 index 319c9bcd..00000000 --- a/libcustomext2fs/source/e2p/e2p.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * e2p.h --- header file for the e2p library - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Library - * General Public License, version 2. - * %End-Header% - */ - -#include /* Needed by dirent.h on netbsd */ -#include -#include - -#include "../ext2_fs.h" - -#define E2P_FEATURE_COMPAT 0 -#define E2P_FEATURE_INCOMPAT 1 -#define E2P_FEATURE_RO_INCOMPAT 2 -#define E2P_FEATURE_TYPE_MASK 0x03 - -#define E2P_FEATURE_NEGATE_FLAG 0x80 - -#define E2P_FS_FEATURE 0 -#define E2P_JOURNAL_FEATURE 1 - -/* `options' for print_flags() */ - -#define PFOPT_LONG 1 /* Must be 1 for compatibility with `int long_format'. */ - - -int fgetflags (const char * name, unsigned long * flags); -int fgetversion (const char * name, unsigned long * version); -int fsetflags (const char * name, unsigned long flags); -int fsetversion (const char * name, unsigned long version); -int getflags (int fd, unsigned long * flags); -int getversion (int fd, unsigned long * version); -int iterate_on_dir (const char * dir_name, - int (*func) (const char *, struct dirent *, void *), - void * private); -void list_super(struct ext2_super_block * s); -void list_super2(struct ext2_super_block * s, FILE *f); -void print_fs_errors (FILE * f, unsigned short errors); -void print_flags (FILE * f, unsigned long flags, unsigned options); -void print_fs_state (FILE * f, unsigned short state); -int setflags (int fd, unsigned long flags); -int setversion (int fd, unsigned long version); - -const char *e2p_feature2string(int compat, unsigned int mask); -const char *e2p_jrnl_feature2string(int compat, unsigned int mask); -int e2p_string2feature(char *string, int *compat, unsigned int *mask); -int e2p_jrnl_string2feature(char *string, int *compat_type, unsigned int *mask); -int e2p_edit_feature(const char *str, __u32 *compat_array, __u32 *ok_array); -int e2p_edit_feature2(const char *str, __u32 *compat_array, __u32 *ok_array, - __u32 *clear_ok_array, int *type_err, - unsigned int *mask_err); - -int e2p_is_null_uuid(void *uu); -void e2p_uuid_to_str(void *uu, char *out); -const char *e2p_uuid2str(void *uu); - -const char *e2p_hash2string(int num); -int e2p_string2hash(char *string); - -const char *e2p_mntopt2string(unsigned int mask); -int e2p_string2mntopt(char *string, unsigned int *mask); -int e2p_edit_mntopts(const char *str, __u32 *mntopts, __u32 ok); - -unsigned long parse_num_blocks(const char *arg, int log_block_size); -unsigned long long parse_num_blocks2(const char *arg, int log_block_size); - -char *e2p_os2string(int os_type); -int e2p_string2os(char *str); - -unsigned int e2p_percent(int percent, unsigned int base); diff --git a/libcustomext2fs/source/e2p/feature.c b/libcustomext2fs/source/e2p/feature.c deleted file mode 100644 index 4806be50..00000000 --- a/libcustomext2fs/source/e2p/feature.c +++ /dev/null @@ -1,385 +0,0 @@ -/* - * feature.c --- convert between features and strings - * - * Copyright (C) 1999 Theodore Ts'o - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Library - * General Public License, version 2. - * %End-Header% - */ - -#include -#include -#include -#include -#include - -#include "e2p.h" -#include -#include - -struct feature { - int compat; - unsigned int mask; - const char *string; -}; - -static struct feature feature_list[] = { - { E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_DIR_PREALLOC, - "dir_prealloc" }, - { E2P_FEATURE_COMPAT, EXT3_FEATURE_COMPAT_HAS_JOURNAL, - "has_journal" }, - { E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_IMAGIC_INODES, - "imagic_inodes" }, - { E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_EXT_ATTR, - "ext_attr" }, - { E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_DIR_INDEX, - "dir_index" }, - { E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_RESIZE_INODE, - "resize_inode" }, - { E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_LAZY_BG, - "lazy_bg" }, - - { E2P_FEATURE_RO_INCOMPAT, EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER, - "sparse_super" }, - { E2P_FEATURE_RO_INCOMPAT, EXT2_FEATURE_RO_COMPAT_LARGE_FILE, - "large_file" }, - { E2P_FEATURE_RO_INCOMPAT, EXT4_FEATURE_RO_COMPAT_HUGE_FILE, - "huge_file" }, - { E2P_FEATURE_RO_INCOMPAT, EXT4_FEATURE_RO_COMPAT_GDT_CSUM, - "uninit_bg" }, - { E2P_FEATURE_RO_INCOMPAT, EXT4_FEATURE_RO_COMPAT_GDT_CSUM, - "uninit_groups" }, - { E2P_FEATURE_RO_INCOMPAT, EXT4_FEATURE_RO_COMPAT_DIR_NLINK, - "dir_nlink" }, - { E2P_FEATURE_RO_INCOMPAT, EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE, - "extra_isize" }, - - { E2P_FEATURE_INCOMPAT, EXT2_FEATURE_INCOMPAT_COMPRESSION, - "compression" }, - { E2P_FEATURE_INCOMPAT, EXT2_FEATURE_INCOMPAT_FILETYPE, - "filetype" }, - { E2P_FEATURE_INCOMPAT, EXT3_FEATURE_INCOMPAT_RECOVER, - "needs_recovery" }, - { E2P_FEATURE_INCOMPAT, EXT3_FEATURE_INCOMPAT_JOURNAL_DEV, - "journal_dev" }, - { E2P_FEATURE_INCOMPAT, EXT3_FEATURE_INCOMPAT_EXTENTS, - "extent" }, - { E2P_FEATURE_INCOMPAT, EXT3_FEATURE_INCOMPAT_EXTENTS, - "extents" }, - { E2P_FEATURE_INCOMPAT, EXT2_FEATURE_INCOMPAT_META_BG, - "meta_bg" }, - { E2P_FEATURE_INCOMPAT, EXT4_FEATURE_INCOMPAT_64BIT, - "64bit" }, - { E2P_FEATURE_INCOMPAT, EXT4_FEATURE_INCOMPAT_FLEX_BG, - "flex_bg"}, - { 0, 0, 0 }, -}; - -static struct feature jrnl_feature_list[] = { - { E2P_FEATURE_COMPAT, JFS_FEATURE_COMPAT_CHECKSUM, - "journal_checksum" }, - - { E2P_FEATURE_INCOMPAT, JFS_FEATURE_INCOMPAT_REVOKE, - "journal_incompat_revoke" }, - { E2P_FEATURE_INCOMPAT, JFS_FEATURE_INCOMPAT_ASYNC_COMMIT, - "journal_async_commit" }, - { 0, 0, 0 }, -}; - -const char *e2p_feature2string(int compat, unsigned int mask) -{ - struct feature *f; - static char buf[20]; - char fchar; - int fnum; - - for (f = feature_list; f->string; f++) { - if ((compat == f->compat) && - (mask == f->mask)) - return f->string; - } - switch (compat) { - case E2P_FEATURE_COMPAT: - fchar = 'C'; - break; - case E2P_FEATURE_INCOMPAT: - fchar = 'I'; - break; - case E2P_FEATURE_RO_INCOMPAT: - fchar = 'R'; - break; - default: - fchar = '?'; - break; - } - for (fnum = 0; mask >>= 1; fnum++); - sprintf(buf, "FEATURE_%c%d", fchar, fnum); - return buf; -} - -int e2p_string2feature(char *string, int *compat_type, unsigned int *mask) -{ - struct feature *f; - char *eptr; - int num; - - for (f = feature_list; f->string; f++) { - if (!strcasecmp(string, f->string)) { - *compat_type = f->compat; - *mask = f->mask; - return 0; - } - } - if (strncasecmp(string, "FEATURE_", 8)) - return 1; - - switch (string[8]) { - case 'c': - case 'C': - *compat_type = E2P_FEATURE_COMPAT; - break; - case 'i': - case 'I': - *compat_type = E2P_FEATURE_INCOMPAT; - break; - case 'r': - case 'R': - *compat_type = E2P_FEATURE_RO_INCOMPAT; - break; - default: - return 1; - } - if (string[9] == 0) - return 1; - num = strtol(string+9, &eptr, 10); - if (num > 32 || num < 0) - return 1; - if (*eptr) - return 1; - *mask = 1 << num; - return 0; -} - -const char *e2p_jrnl_feature2string(int compat, unsigned int mask) -{ - struct feature *f; - static char buf[20]; - char fchar; - int fnum; - - for (f = jrnl_feature_list; f->string; f++) { - if ((compat == f->compat) && - (mask == f->mask)) - return f->string; - } - switch (compat) { - case E2P_FEATURE_COMPAT: - fchar = 'C'; - break; - case E2P_FEATURE_INCOMPAT: - fchar = 'I'; - break; - case E2P_FEATURE_RO_INCOMPAT: - fchar = 'R'; - break; - default: - fchar = '?'; - break; - } - for (fnum = 0; mask >>= 1; fnum++); - sprintf(buf, "FEATURE_%c%d", fchar, fnum); - return buf; -} - -int e2p_jrnl_string2feature(char *string, int *compat_type, unsigned int *mask) -{ - struct feature *f; - char *eptr; - int num; - - for (f = jrnl_feature_list; f->string; f++) { - if (!strcasecmp(string, f->string)) { - *compat_type = f->compat; - *mask = f->mask; - return 0; - } - } - if (strncasecmp(string, "FEATURE_", 8)) - return 1; - - switch (string[8]) { - case 'c': - case 'C': - *compat_type = E2P_FEATURE_COMPAT; - break; - case 'i': - case 'I': - *compat_type = E2P_FEATURE_INCOMPAT; - break; - case 'r': - case 'R': - *compat_type = E2P_FEATURE_RO_INCOMPAT; - break; - default: - return 1; - } - if (string[9] == 0) - return 1; - num = strtol(string+9, &eptr, 10); - if (num > 32 || num < 0) - return 1; - if (*eptr) - return 1; - *mask = 1 << num; - return 0; -} -static char *skip_over_blanks(char *cp) -{ - while (*cp && isspace((int)*cp)) - cp++; - return cp; -} - -static char *skip_over_word(char *cp) -{ - while (*cp && !isspace((int)*cp) && *cp != ',') - cp++; - return cp; -} - -/* - * Edit a feature set array as requested by the user. The ok_array, - * if set, allows the application to limit what features the user is - * allowed to set or clear using this function. If clear_ok_array is set, - * then use it tell whether or not it is OK to clear a filesystem feature. - */ -int e2p_edit_feature2(const char *str, __u32 *compat_array, __u32 *ok_array, - __u32 *clear_ok_array, int *type_err, - unsigned int *mask_err) -{ - char *cp, *buf, *next; - int neg; - unsigned int mask; - int compat_type; - int rc = 0; - - if (!clear_ok_array) - clear_ok_array = ok_array; - - if (type_err) - *type_err = 0; - if (mask_err) - *mask_err = 0; - - buf = malloc(strlen(str)+1); - if (!buf) - return 1; - strcpy(buf, str); - for (cp = buf; cp && *cp; cp = next ? next+1 : 0) { - neg = 0; - cp = skip_over_blanks(cp); - next = skip_over_word(cp); - - if (*next == 0) - next = 0; - else - *next = 0; - - if ((strcasecmp(cp, "none") == 0) || - (strcasecmp(cp, "clear") == 0)) { - compat_array[0] = 0; - compat_array[1] = 0; - compat_array[2] = 0; - continue; - } - - switch (*cp) { - case '-': - case '^': - neg++; - case '+': - cp++; - break; - } - if (e2p_string2feature(cp, &compat_type, &mask)) { - rc = 1; - break; - } - if (neg) { - if (clear_ok_array && - !(clear_ok_array[compat_type] & mask)) { - rc = 1; - if (type_err) - *type_err = (compat_type | - E2P_FEATURE_NEGATE_FLAG); - if (mask_err) - *mask_err = mask; - break; - } - compat_array[compat_type] &= ~mask; - } else { - if (ok_array && !(ok_array[compat_type] & mask)) { - rc = 1; - if (type_err) - *type_err = compat_type; - if (mask_err) - *mask_err = mask; - break; - } - compat_array[compat_type] |= mask; - } - } - free(buf); - return rc; -} - -int e2p_edit_feature(const char *str, __u32 *compat_array, __u32 *ok_array) -{ - return e2p_edit_feature2(str, compat_array, ok_array, 0, 0, 0); -} - -#ifdef TEST_PROGRAM -int main(int argc, char **argv) -{ - int compat, compat2, i; - unsigned int mask, mask2; - const char *str; - struct feature *f; - - for (i = 0; i < 2; i++) { - if (i == 0) { - f = feature_list; - printf("Feature list:\n"); - } else { - printf("\nJournal feature list:\n"); - f = jrnl_feature_list; - } - for (; f->string; f++) { - if (i == 0) { - e2p_string2feature((char *)f->string, &compat, - &mask); - str = e2p_feature2string(compat, mask); - } else { - e2p_jrnl_string2feature((char *)f->string, - &compat, &mask); - str = e2p_jrnl_feature2string(compat, mask); - } - - printf("\tCompat = %d, Mask = %u, %s\n", - compat, mask, f->string); - if (strcmp(f->string, str)) { - if (e2p_string2feature((char *) str, &compat2, - &mask2) || - (compat2 != compat) || - (mask2 != mask)) { - fprintf(stderr, "Failure!\n"); - exit(1); - } - } - } - } - exit(0); -} -#endif diff --git a/libcustomext2fs/source/e2p/fgetflags.c b/libcustomext2fs/source/e2p/fgetflags.c deleted file mode 100644 index 282be320..00000000 --- a/libcustomext2fs/source/e2p/fgetflags.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - * fgetflags.c - Get a file flags on an ext2 file system - * - * Copyright (C) 1993, 1994 Remy Card - * Laboratoire MASI, Institut Blaise Pascal - * Universite Pierre et Marie Curie (Paris VI) - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Library - * General Public License, version 2. - * %End-Header% - */ - -/* - * History: - * 93/10/30 - Creation - */ - -#define _LARGEFILE_SOURCE -#define _LARGEFILE64_SOURCE - -#if HAVE_ERRNO_H -#include -#endif -#if HAVE_UNISTD_H -#include -#endif -#include -#include -#if HAVE_EXT2_IOCTLS -#include -#include -#endif - -#include "e2p.h" - -#ifdef O_LARGEFILE -#define OPEN_FLAGS (O_RDONLY|O_NONBLOCK|O_LARGEFILE) -#else -#define OPEN_FLAGS (O_RDONLY|O_NONBLOCK) -#endif - -int fgetflags (const char * name, unsigned long * flags) -{ -#if HAVE_STAT_FLAGS && !(APPLE_DARWIN && HAVE_EXT2_IOCTLS) - struct stat buf; - if (stat (name, &buf) == -1) - return -1; - - *flags = 0; -#ifdef UF_IMMUTABLE - if (buf.st_flags & UF_IMMUTABLE) - *flags |= EXT2_IMMUTABLE_FL; -#endif -#ifdef UF_APPEND - if (buf.st_flags & UF_APPEND) - *flags |= EXT2_APPEND_FL; -#endif -#ifdef UF_NODUMP - if (buf.st_flags & UF_NODUMP) - *flags |= EXT2_NODUMP_FL; -#endif - - return 0; -#else -#if HAVE_EXT2_IOCTLS - int fd, r, f, save_errno = 0; - - if (!lstat(name, &buf) && - !S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode)) { - goto notsupp; - } -#if !APPLE_DARWIN - fd = open (name, OPEN_FLAGS); - if (fd == -1) - return -1; - r = ioctl (fd, EXT2_IOC_GETFLAGS, &f); - if (r == -1) - save_errno = errno; - *flags = f; - close (fd); - if (save_errno) - errno = save_errno; - return r; -#else - f = -1; - save_errno = syscall(SYS_fsctl, name, EXT2_IOC_GETFLAGS, &f, 0); - *flags = f; - return (save_errno); -#endif -#endif /* HAVE_EXT2_IOCTLS */ -#endif - errno = EOPNOTSUPP; - return -1; -} diff --git a/libcustomext2fs/source/e2p/fgetversion.c b/libcustomext2fs/source/e2p/fgetversion.c deleted file mode 100644 index 97519d77..00000000 --- a/libcustomext2fs/source/e2p/fgetversion.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * fgetversion.c - Get a file version on an ext2 file system - * - * Copyright (C) 1993, 1994 Remy Card - * Laboratoire MASI, Institut Blaise Pascal - * Universite Pierre et Marie Curie (Paris VI) - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Library - * General Public License, version 2. - * %End-Header% - */ - -/* - * History: - * 93/10/30 - Creation - */ - -#define _LARGEFILE_SOURCE -#define _LARGEFILE64_SOURCE - -#if HAVE_ERRNO_H -#include -#endif -#if HAVE_UNISTD_H -#include -#endif -#if HAVE_EXT2_IOCTLS -#include -#include -#endif - -#include "e2p.h" - -#ifdef O_LARGEFILE -#define OPEN_FLAGS (O_RDONLY|O_NONBLOCK|O_LARGEFILE) -#else -#define OPEN_FLAGS (O_RDONLY|O_NONBLOCK) -#endif - -int fgetversion (const char * name, unsigned long * version) -{ -#if HAVE_EXT2_IOCTLS -#if !APPLE_DARWIN - int fd, r, ver, save_errno = 0; - - fd = open (name, OPEN_FLAGS); - if (fd == -1) - return -1; - r = ioctl (fd, EXT2_IOC_GETVERSION, &ver); - if (r == -1) - save_errno = errno; - *version = ver; - close (fd); - if (save_errno) - errno = save_errno; - return r; -#else - int ver=-1, err; - err = syscall(SYS_fsctl, name, EXT2_IOC_GETVERSION, &ver, 0); - *version = ver; - return(err); -#endif -#else /* ! HAVE_EXT2_IOCTLS */ - extern int errno; - errno = EOPNOTSUPP; - return -1; -#endif /* ! HAVE_EXT2_IOCTLS */ -} diff --git a/libcustomext2fs/source/e2p/fsetflags.c b/libcustomext2fs/source/e2p/fsetflags.c deleted file mode 100644 index 0f39ee9c..00000000 --- a/libcustomext2fs/source/e2p/fsetflags.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * fsetflags.c - Set a file flags on an ext2 file system - * - * Copyright (C) 1993, 1994 Remy Card - * Laboratoire MASI, Institut Blaise Pascal - * Universite Pierre et Marie Curie (Paris VI) - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Library - * General Public License, version 2. - * %End-Header% - */ - -/* - * History: - * 93/10/30 - Creation - */ - -#define _LARGEFILE_SOURCE -#define _LARGEFILE64_SOURCE - -#if HAVE_ERRNO_H -#include -#endif -#if HAVE_UNISTD_H -#include -#endif -#include -#include -#if HAVE_EXT2_IOCTLS -#include -#include -#endif - -#include "e2p.h" - -/* - * Deal with lame glibc's that define this function without actually - * implementing it. Can you say "attractive nuisance", boys and girls? - * I knew you could! - */ -#ifdef __linux__ -#undef HAVE_CHFLAGS -#endif - -#ifdef O_LARGEFILE -#define OPEN_FLAGS (O_RDONLY|O_NONBLOCK|O_LARGEFILE) -#else -#define OPEN_FLAGS (O_RDONLY|O_NONBLOCK) -#endif - -int fsetflags (const char * name, unsigned long flags) -{ -#if HAVE_CHFLAGS && !(APPLE_DARWIN && HAVE_EXT2_IOCTLS) - struct stat buf; - unsigned long bsd_flags = 0; - -#ifdef UF_IMMUTABLE - if (flags & EXT2_IMMUTABLE_FL) - bsd_flags |= UF_IMMUTABLE; -#endif -#ifdef UF_APPEND - if (flags & EXT2_APPEND_FL) - bsd_flags |= UF_APPEND; -#endif -#ifdef UF_NODUMP - if (flags & EXT2_NODUMP_FL) - bsd_flags |= UF_NODUMP; -#endif - - return chflags (name, bsd_flags); -#else -#if HAVE_EXT2_IOCTLS - int fd, r, f, save_errno = 0; - - if (!lstat(name, &buf) && - !S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode)) { - goto notsupp; - } -#if !APPLE_DARWIN - fd = open (name, OPEN_FLAGS); - if (fd == -1) - return -1; - f = (int) flags; - r = ioctl (fd, EXT2_IOC_SETFLAGS, &f); - if (r == -1) - save_errno = errno; - close (fd); - if (save_errno) - errno = save_errno; -#else - f = (int) flags; - return syscall(SYS_fsctl, name, EXT2_IOC_SETFLAGS, &f, 0); -#endif - return r; -#endif /* HAVE_EXT2_IOCTLS */ -#endif - errno = EOPNOTSUPP; - return -1; -} diff --git a/libcustomext2fs/source/e2p/fsetversion.c b/libcustomext2fs/source/e2p/fsetversion.c deleted file mode 100644 index ee26f91e..00000000 --- a/libcustomext2fs/source/e2p/fsetversion.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * fsetversion.c - Set a file version on an ext2 file system - * - * Copyright (C) 1993, 1994 Remy Card - * Laboratoire MASI, Institut Blaise Pascal - * Universite Pierre et Marie Curie (Paris VI) - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Library - * General Public License, version 2. - * %End-Header% - */ - -/* - * History: - * 93/10/30 - Creation - */ - -#define _LARGEFILE_SOURCE -#define _LARGEFILE64_SOURCE - -#if HAVE_ERRNO_H -#include -#endif -#if HAVE_UNISTD_H -#include -#endif -#if HAVE_EXT2_IOCTLS -#include -#include -#endif - -#include "e2p.h" - -#ifdef O_LARGEFILE -#define OPEN_FLAGS (O_RDONLY|O_NONBLOCK|O_LARGEFILE) -#else -#define OPEN_FLAGS (O_RDONLY|O_NONBLOCK) -#endif - -int fsetversion (const char * name, unsigned long version) -{ -#if HAVE_EXT2_IOCTLS -#if !APPLE_DARWIN - int fd, r, ver, save_errno = 0; - - fd = open (name, OPEN_FLAGS); - if (fd == -1) - return -1; - ver = (int) version; - r = ioctl (fd, EXT2_IOC_SETVERSION, &ver); - if (r == -1) - save_errno = errno; - close (fd); - if (save_errno) - errno = save_errno; - return r; -#else - int ver = (int)version; - return syscall(SYS_fsctl, name, EXT2_IOC_SETVERSION, &ver, 0); -#endif -#else /* ! HAVE_EXT2_IOCTLS */ - extern int errno; - errno = EOPNOTSUPP; - return -1; -#endif /* ! HAVE_EXT2_IOCTLS */ -} diff --git a/libcustomext2fs/source/e2p/getflags.c b/libcustomext2fs/source/e2p/getflags.c deleted file mode 100644 index 0cc768a8..00000000 --- a/libcustomext2fs/source/e2p/getflags.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * getflags.c - Get a file flags on an ext2 file system - * - * Copyright (C) 1993, 1994 Remy Card - * Laboratoire MASI, Institut Blaise Pascal - * Universite Pierre et Marie Curie (Paris VI) - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Library - * General Public License, version 2. - * %End-Header% - */ - -/* - * History: - * 93/10/30 - Creation - */ - -#if HAVE_ERRNO_H -#include -#endif -#include -#include -#if HAVE_EXT2_IOCTLS -#include -#endif - -#include "e2p.h" - -int getflags (int fd, unsigned long * flags) -{ -#if HAVE_STAT_FLAGS - struct stat buf; - if (fstat (fd, &buf) == -1) - return -1; - - *flags = 0; -#ifdef UF_IMMUTABLE - if (buf.st_flags & UF_IMMUTABLE) - *flags |= EXT2_IMMUTABLE_FL; -#endif -#ifdef UF_APPEND - if (buf.st_flags & UF_APPEND) - *flags |= EXT2_APPEND_FL; -#endif -#ifdef UF_NODUMP - if (buf.st_flags & UF_NODUMP) - *flags |= EXT2_NODUMP_FL; -#endif - - return 0; -#else -#if HAVE_EXT2_IOCTLS - int r, f; - - if (!fstat(fd, &buf) && - !S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode)) - goto notsupp; - r = ioctl (fd, EXT2_IOC_GETFLAGS, &f); - *flags = f; - return r; -#endif /* HAVE_EXT2_IOCTLS */ -#endif - errno = EOPNOTSUPP; - return -1; -} diff --git a/libcustomext2fs/source/e2p/getversion.c b/libcustomext2fs/source/e2p/getversion.c deleted file mode 100644 index 06adf6df..00000000 --- a/libcustomext2fs/source/e2p/getversion.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - * getversion.c - Get a file version on an ext2 file system - * - * Copyright (C) 1993, 1994 Remy Card - * Laboratoire MASI, Institut Blaise Pascal - * Universite Pierre et Marie Curie (Paris VI) - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Library - * General Public License, version 2. - * %End-Header% - */ - -/* - * History: - * 93/10/30 - Creation - */ - -#if HAVE_ERRNO_H -#include -#endif -#if HAVE_EXT2_IOCTLS -#include -#endif - -#include "e2p.h" - -int getversion (int fd, unsigned long * version) -{ -#if HAVE_EXT2_IOCTLS - int r, ver; - - r = ioctl (fd, EXT2_IOC_GETVERSION, &ver); - *version = ver; - return 0; -#else /* ! HAVE_EXT2_IOCTLS */ - extern int errno; - errno = EOPNOTSUPP; - return -1; -#endif /* ! HAVE_EXT2_IOCTLS */ -} diff --git a/libcustomext2fs/source/e2p/hashstr.c b/libcustomext2fs/source/e2p/hashstr.c deleted file mode 100644 index 5ee62370..00000000 --- a/libcustomext2fs/source/e2p/hashstr.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * feature.c --- convert between features and strings - * - * Copyright (C) 1999 Theodore Ts'o - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Library - * General Public License, version 2. - * %End-Header% - */ - -#include -#include -#include -#include -#include - -#include "e2p.h" - -struct hash { - int num; - const char *string; -}; - -static struct hash hash_list[] = { - { EXT2_HASH_LEGACY, "legacy" }, - { EXT2_HASH_HALF_MD4, "half_md4" }, - { EXT2_HASH_TEA, "tea" }, - { 0, 0 }, -}; - -const char *e2p_hash2string(int num) -{ - struct hash *p; - static char buf[20]; - - for (p = hash_list; p->string; p++) { - if (num == p->num) - return p->string; - } - sprintf(buf, "HASHALG_%d", num); - return buf; -} - -/* - * Returns the hash algorithm, or -1 on error - */ -int e2p_string2hash(char *string) -{ - struct hash *p; - char *eptr; - int num; - - for (p = hash_list; p->string; p++) { - if (!strcasecmp(string, p->string)) { - return p->num; - } - } - if (strncasecmp(string, "HASHALG_", 8)) - return -1; - - if (string[8] == 0) - return -1; - num = strtol(string+8, &eptr, 10); - if (num > 255 || num < 0) - return -1; - if (*eptr) - return -1; - return num; -} - diff --git a/libcustomext2fs/source/e2p/iod.c b/libcustomext2fs/source/e2p/iod.c deleted file mode 100644 index c53aafeb..00000000 --- a/libcustomext2fs/source/e2p/iod.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * iod.c - Iterate a function on each entry of a directory - * - * Copyright (C) 1993, 1994 Remy Card - * Laboratoire MASI, Institut Blaise Pascal - * Universite Pierre et Marie Curie (Paris VI) - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Library - * General Public License, version 2. - * %End-Header% - */ - -/* - * History: - * 93/10/30 - Creation - */ - -#include "e2p.h" -#if HAVE_UNISTD_H -#include -#endif -#include -#include - -int iterate_on_dir (const char * dir_name, - int (*func) (const char *, struct dirent *, void *), - void * private) -{ - DIR * dir; - struct dirent *de, *dep; - int max_len = -1, len, ret = 0; - -#if HAVE_PATHCONF && defined(_PC_NAME_MAX) - max_len = pathconf(dir_name, _PC_NAME_MAX); -#endif - if (max_len == -1) { -#ifdef _POSIX_NAME_MAX - max_len = _POSIX_NAME_MAX; -#else -#ifdef NAME_MAX - max_len = NAME_MAX; -#else - max_len = 256; -#endif /* NAME_MAX */ -#endif /* _POSIX_NAME_MAX */ - } - max_len += sizeof(struct dirent); - - de = malloc(max_len+1); - if (!de) - return -1; - memset(de, 0, max_len+1); - - dir = opendir (dir_name); - if (dir == NULL) { - free(de); - return -1; - } - while ((dep = readdir (dir))) { -#ifdef HAVE_RECLEN_DIRENT - len = dep->d_reclen; - if (len > max_len) - len = max_len; -#else - len = sizeof(struct dirent); -#endif - memcpy(de, dep, len); - if ((*func)(dir_name, de, private)) - ret++; - } - free(de); - closedir(dir); - return ret; -} diff --git a/libcustomext2fs/source/e2p/ls.c b/libcustomext2fs/source/e2p/ls.c deleted file mode 100644 index 20908a66..00000000 --- a/libcustomext2fs/source/e2p/ls.c +++ /dev/null @@ -1,403 +0,0 @@ -/* - * ls.c - List the contents of an ext2fs superblock - * - * Copyright (C) 1992, 1993, 1994 Remy Card - * Laboratoire MASI, Institut Blaise Pascal - * Universite Pierre et Marie Curie (Paris VI) - * - * Copyright (C) 1995, 1996, 1997 Theodore Ts'o - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Library - * General Public License, version 2. - * %End-Header% - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "e2p.h" - -static void print_user (unsigned short uid, FILE *f) -{ - struct passwd *pw; - - fprintf(f, "%u ", uid); - pw = getpwuid (uid); - if (pw == NULL) - fprintf(f, "(user unknown)\n"); - else - fprintf(f, "(user %s)\n", pw->pw_name); -} - -static void print_group (unsigned short gid, FILE *f) -{ - struct group *gr; - - fprintf(f, "%u ", gid); - gr = getgrgid (gid); - if (gr == NULL) - fprintf(f, "(group unknown)\n"); - else - fprintf(f, "(group %s)\n", gr->gr_name); -} - -#define MONTH_INT (86400 * 30) -#define WEEK_INT (86400 * 7) -#define DAY_INT (86400) -#define HOUR_INT (60 * 60) -#define MINUTE_INT (60) - -static const char *interval_string(unsigned int secs) -{ - static char buf[256], tmp[80]; - int hr, min, num; - - buf[0] = 0; - - if (secs == 0) - return ""; - - if (secs >= MONTH_INT) { - num = secs / MONTH_INT; - secs -= num*MONTH_INT; - sprintf(buf, "%d month%s", num, (num>1) ? "s" : ""); - } - if (secs >= WEEK_INT) { - num = secs / WEEK_INT; - secs -= num*WEEK_INT; - sprintf(tmp, "%s%d week%s", buf[0] ? ", " : "", - num, (num>1) ? "s" : ""); - strcat(buf, tmp); - } - if (secs >= DAY_INT) { - num = secs / DAY_INT; - secs -= num*DAY_INT; - sprintf(tmp, "%s%d day%s", buf[0] ? ", " : "", - num, (num>1) ? "s" : ""); - strcat(buf, tmp); - } - if (secs > 0) { - hr = secs / HOUR_INT; - secs -= hr*HOUR_INT; - min = secs / MINUTE_INT; - secs -= min*MINUTE_INT; - sprintf(tmp, "%s%d:%02d:%02d", buf[0] ? ", " : "", - hr, min, secs); - strcat(buf, tmp); - } - return buf; -} - -static void print_features(struct ext2_super_block * s, FILE *f) -{ -#ifdef EXT2_DYNAMIC_REV - int i, j, printed=0; - __u32 *mask = &s->s_feature_compat, m; - - fprintf(f, "Filesystem features: "); - for (i=0; i <3; i++,mask++) { - for (j=0,m=1; j < 32; j++, m<<=1) { - if (*mask & m) { - fprintf(f, " %s", e2p_feature2string(i, m)); - printed++; - } - } - } - if (printed == 0) - fprintf(f, " (none)"); - fprintf(f, "\n"); -#endif -} - -static void print_mntopts(struct ext2_super_block * s, FILE *f) -{ -#ifdef EXT2_DYNAMIC_REV - int i, printed=0; - __u32 mask = s->s_default_mount_opts, m; - - fprintf(f, "Default mount options: "); - if (mask & EXT3_DEFM_JMODE) { - fprintf(f, " %s", e2p_mntopt2string(mask & EXT3_DEFM_JMODE)); - printed++; - } - for (i=0,m=1; i < 32; i++, m<<=1) { - if (m & EXT3_DEFM_JMODE) - continue; - if (mask & m) { - fprintf(f, " %s", e2p_mntopt2string(m)); - printed++; - } - } - if (printed == 0) - fprintf(f, " (none)"); - fprintf(f, "\n"); -#endif -} - -static void print_super_flags(struct ext2_super_block * s, FILE *f) -{ - int flags_found = 0; - - if (s->s_flags == 0) - return; - - fputs("Filesystem flags: ", f); - if (s->s_flags & EXT2_FLAGS_SIGNED_HASH) { - fputs("signed_directory_hash ", f); - flags_found++; - } - if (s->s_flags & EXT2_FLAGS_UNSIGNED_HASH) { - fputs("unsigned_directory_hash ", f); - flags_found++; - } - if (s->s_flags & EXT2_FLAGS_TEST_FILESYS) { - fputs("test_filesystem ", f); - flags_found++; - } - if (flags_found) - fputs("\n", f); - else - fputs("(none)\n", f); -} - -static __u64 e2p_blocks_count(struct ext2_super_block *super) -{ - return super->s_blocks_count | - (super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT ? - (__u64) super->s_blocks_count_hi << 32 : 0); -} - -static __u64 e2p_r_blocks_count(struct ext2_super_block *super) -{ - return super->s_r_blocks_count | - (super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT ? - (__u64) super->s_r_blocks_count_hi << 32 : 0); -} - -static __u64 e2p_free_blocks_count(struct ext2_super_block *super) -{ - return super->s_free_blocks_count | - (super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT ? - (__u64) super->s_free_blocks_hi << 32 : 0); -} - -#ifndef EXT2_INODE_SIZE -#define EXT2_INODE_SIZE(s) sizeof(struct ext2_inode) -#endif - -#ifndef EXT2_GOOD_OLD_REV -#define EXT2_GOOD_OLD_REV 0 -#endif - -void list_super2(struct ext2_super_block * sb, FILE *f) -{ - int inode_blocks_per_group; - char buf[80], *str; - time_t tm; - - inode_blocks_per_group = (((sb->s_inodes_per_group * - EXT2_INODE_SIZE(sb)) + - EXT2_BLOCK_SIZE(sb) - 1) / - EXT2_BLOCK_SIZE(sb)); - if (sb->s_volume_name[0]) { - memset(buf, 0, sizeof(buf)); - strncpy(buf, sb->s_volume_name, sizeof(sb->s_volume_name)); - } else - strcpy(buf, ""); - fprintf(f, "Filesystem volume name: %s\n", buf); - if (sb->s_last_mounted[0]) { - memset(buf, 0, sizeof(buf)); - strncpy(buf, sb->s_last_mounted, sizeof(sb->s_last_mounted)); - } else - strcpy(buf, ""); - fprintf(f, "Last mounted on: %s\n", buf); - fprintf(f, "Filesystem UUID: %s\n", e2p_uuid2str(sb->s_uuid)); - fprintf(f, "Filesystem magic number: 0x%04X\n", sb->s_magic); - fprintf(f, "Filesystem revision #: %d", sb->s_rev_level); - if (sb->s_rev_level == EXT2_GOOD_OLD_REV) { - fprintf(f, " (original)\n"); -#ifdef EXT2_DYNAMIC_REV - } else if (sb->s_rev_level == EXT2_DYNAMIC_REV) { - fprintf(f, " (dynamic)\n"); -#endif - } else - fprintf(f, " (unknown)\n"); - print_features(sb, f); - print_super_flags(sb, f); - print_mntopts(sb, f); - if (sb->s_mount_opts[0]) - fprintf(f, "Mount options: %s\n", sb->s_mount_opts); - fprintf(f, "Filesystem state: "); - print_fs_state (f, sb->s_state); - fprintf(f, "\n"); - fprintf(f, "Errors behavior: "); - print_fs_errors(f, sb->s_errors); - fprintf(f, "\n"); - str = e2p_os2string(sb->s_creator_os); - fprintf(f, "Filesystem OS type: %s\n", str); - free(str); - fprintf(f, "Inode count: %u\n", sb->s_inodes_count); - fprintf(f, "Block count: %llu\n", e2p_blocks_count(sb)); - fprintf(f, "Reserved block count: %llu\n", e2p_r_blocks_count(sb)); - fprintf(f, "Free blocks: %llu\n", e2p_free_blocks_count(sb)); - fprintf(f, "Free inodes: %u\n", sb->s_free_inodes_count); - fprintf(f, "First block: %u\n", sb->s_first_data_block); - fprintf(f, "Block size: %u\n", EXT2_BLOCK_SIZE(sb)); - fprintf(f, "Fragment size: %u\n", EXT2_FRAG_SIZE(sb)); - if (sb->s_reserved_gdt_blocks) - fprintf(f, "Reserved GDT blocks: %u\n", - sb->s_reserved_gdt_blocks); - fprintf(f, "Blocks per group: %u\n", sb->s_blocks_per_group); - fprintf(f, "Fragments per group: %u\n", sb->s_frags_per_group); - fprintf(f, "Inodes per group: %u\n", sb->s_inodes_per_group); - fprintf(f, "Inode blocks per group: %u\n", inode_blocks_per_group); - if (sb->s_raid_stride) - fprintf(f, "RAID stride: %u\n", - sb->s_raid_stride); - if (sb->s_raid_stripe_width) - fprintf(f, "RAID stripe width: %u\n", - sb->s_raid_stripe_width); - if (sb->s_first_meta_bg) - fprintf(f, "First meta block group: %u\n", - sb->s_first_meta_bg); - if (sb->s_log_groups_per_flex) - fprintf(f, "Flex block group size: %u\n", - 1 << sb->s_log_groups_per_flex); - if (sb->s_mkfs_time) { - tm = sb->s_mkfs_time; - fprintf(f, "Filesystem created: %s", ctime(&tm)); - } - tm = sb->s_mtime; - fprintf(f, "Last mount time: %s", - sb->s_mtime ? ctime(&tm) : "n/a\n"); - tm = sb->s_wtime; - fprintf(f, "Last write time: %s", ctime(&tm)); - fprintf(f, "Mount count: %u\n", sb->s_mnt_count); - fprintf(f, "Maximum mount count: %d\n", sb->s_max_mnt_count); - tm = sb->s_lastcheck; - fprintf(f, "Last checked: %s", ctime(&tm)); - fprintf(f, "Check interval: %u (%s)\n", sb->s_checkinterval, - interval_string(sb->s_checkinterval)); - if (sb->s_checkinterval) - { - time_t next; - - next = sb->s_lastcheck + sb->s_checkinterval; - fprintf(f, "Next check after: %s", ctime(&next)); - } -#define POW2(x) ((__u64) 1 << (x)) - if (sb->s_kbytes_written) { - fprintf(f, "Lifetime writes: "); - if (sb->s_kbytes_written < POW2(13)) - fprintf(f, "%llu kB\n", sb->s_kbytes_written); - else if (sb->s_kbytes_written < POW2(23)) - fprintf(f, "%llu MB\n", - (sb->s_kbytes_written + POW2(9)) >> 10); - else if (sb->s_kbytes_written < POW2(33)) - fprintf(f, "%llu GB\n", - (sb->s_kbytes_written + POW2(19)) >> 20); - else if (sb->s_kbytes_written < POW2(43)) - fprintf(f, "%llu TB\n", - (sb->s_kbytes_written + POW2(29)) >> 30); - else - fprintf(f, "%llu PB\n", - (sb->s_kbytes_written + POW2(39)) >> 40); - } - fprintf(f, "Reserved blocks uid: "); - print_user(sb->s_def_resuid, f); - fprintf(f, "Reserved blocks gid: "); - print_group(sb->s_def_resgid, f); - if (sb->s_rev_level >= EXT2_DYNAMIC_REV) { - fprintf(f, "First inode: %d\n", sb->s_first_ino); - fprintf(f, "Inode size: %d\n", sb->s_inode_size); - if (sb->s_min_extra_isize) - fprintf(f, "Required extra isize: %d\n", - sb->s_min_extra_isize); - if (sb->s_want_extra_isize) - fprintf(f, "Desired extra isize: %d\n", - sb->s_want_extra_isize); - } - if (!e2p_is_null_uuid(sb->s_journal_uuid)) - fprintf(f, "Journal UUID: %s\n", - e2p_uuid2str(sb->s_journal_uuid)); - if (sb->s_journal_inum) - fprintf(f, "Journal inode: %u\n", - sb->s_journal_inum); - if (sb->s_journal_dev) - fprintf(f, "Journal device: 0x%04x\n", - sb->s_journal_dev); - if (sb->s_last_orphan) - fprintf(f, "First orphan inode: %u\n", - sb->s_last_orphan); - if ((sb->s_feature_compat & EXT2_FEATURE_COMPAT_DIR_INDEX) || - sb->s_def_hash_version) - fprintf(f, "Default directory hash: %s\n", - e2p_hash2string(sb->s_def_hash_version)); - if (!e2p_is_null_uuid(sb->s_hash_seed)) - fprintf(f, "Directory Hash Seed: %s\n", - e2p_uuid2str(sb->s_hash_seed)); - if (sb->s_jnl_backup_type) { - fprintf(f, "Journal backup: "); - switch (sb->s_jnl_backup_type) { - case 1: - fprintf(f, "inode blocks\n"); - break; - default: - fprintf(f, "type %u\n", sb->s_jnl_backup_type); - } - } - if (sb->s_snapshot_inum) { - fprintf(f, "Snapshot inode: %u\n", - sb->s_snapshot_inum); - fprintf(f, "Snapshot ID: %u\n", - sb->s_snapshot_id); - fprintf(f, "Snapshot reserved blocks: %llu\n", - sb->s_snapshot_r_blocks_count); - } - if (sb->s_snapshot_list) - fprintf(f, "Snapshot list head: %u\n", - sb->s_snapshot_list); - if (sb->s_error_count) - fprintf(f, "FS Error count: %u\n", - sb->s_error_count); - if (sb->s_first_error_time) { - tm = sb->s_first_error_time; - fprintf(f, "First error time: %s", ctime(&tm)); - memset(buf, 0, sizeof(buf)); - strncpy(buf, (char *)sb->s_first_error_func, - sizeof(sb->s_first_error_func)); - fprintf(f, "First error function: %s\n", buf); - fprintf(f, "First error line #: %u\n", - sb->s_first_error_line); - fprintf(f, "First error inode #: %u\n", - sb->s_first_error_ino); - fprintf(f, "First error block #: %llu\n", - sb->s_first_error_block); - } - if (sb->s_last_error_time) { - tm = sb->s_last_error_time; - fprintf(f, "Last error time: %s", ctime(&tm)); - memset(buf, 0, sizeof(buf)); - strncpy(buf, (char *) sb->s_last_error_func, - sizeof(sb->s_last_error_func)); - fprintf(f, "Last error function: %s\n", buf); - fprintf(f, "Last error line #: %u\n", - sb->s_last_error_line); - fprintf(f, "Last error inode #: %u\n", - sb->s_last_error_ino); - fprintf(f, "Last error block #: %llu\n", - sb->s_last_error_block); - } -} - -void list_super (struct ext2_super_block * s) -{ - list_super2(s, stdout); -} - diff --git a/libcustomext2fs/source/e2p/mntopts.c b/libcustomext2fs/source/e2p/mntopts.c deleted file mode 100644 index 0903ad54..00000000 --- a/libcustomext2fs/source/e2p/mntopts.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - * mountopts.c --- convert between default mount options and strings - * - * Copyright (C) 2002 Theodore Ts'o - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Library - * General Public License, version 2. - * %End-Header% - */ - -#include -#include -#include -#include -#include - -#include "e2p.h" - -struct mntopt { - unsigned int mask; - const char *string; -}; - -static struct mntopt mntopt_list[] = { - { EXT2_DEFM_DEBUG, "debug" }, - { EXT2_DEFM_BSDGROUPS, "bsdgroups" }, - { EXT2_DEFM_XATTR_USER, "user_xattr" }, - { EXT2_DEFM_ACL, "acl" }, - { EXT2_DEFM_UID16, "uid16" }, - { EXT3_DEFM_JMODE_DATA, "journal_data" }, - { EXT3_DEFM_JMODE_ORDERED, "journal_data_ordered" }, - { EXT3_DEFM_JMODE_WBACK, "journal_data_writeback" }, - { EXT4_DEFM_NOBARRIER, "nobarrier" }, - { EXT4_DEFM_BLOCK_VALIDITY, "block_validity" }, - { EXT4_DEFM_DISCARD, "discard"}, - { EXT4_DEFM_NODELALLOC, "nodelalloc"}, - { 0, 0 }, -}; - -const char *e2p_mntopt2string(unsigned int mask) -{ - struct mntopt *f; - static char buf[20]; - int fnum; - - for (f = mntopt_list; f->string; f++) { - if (mask == f->mask) - return f->string; - } - for (fnum = 0; mask >>= 1; fnum++); - sprintf(buf, "MNTOPT_%d", fnum); - return buf; -} - -int e2p_string2mntopt(char *string, unsigned int *mask) -{ - struct mntopt *f; - char *eptr; - int num; - - for (f = mntopt_list; f->string; f++) { - if (!strcasecmp(string, f->string)) { - *mask = f->mask; - return 0; - } - } - if (strncasecmp(string, "MNTOPT_", 8)) - return 1; - - if (string[8] == 0) - return 1; - num = strtol(string+8, &eptr, 10); - if (num > 32 || num < 0) - return 1; - if (*eptr) - return 1; - *mask = 1 << num; - return 0; -} - -static char *skip_over_blanks(char *cp) -{ - while (*cp && isspace((int) *cp)) - cp++; - return cp; -} - -static char *skip_over_word(char *cp) -{ - while (*cp && !isspace((int) *cp) && *cp != ',') - cp++; - return cp; -} - -/* - * Edit a mntopt set array as requested by the user. The ok - * parameter, if non-zero, allows the application to limit what - * mntopts the user is allowed to set or clear using this function. - */ -int e2p_edit_mntopts(const char *str, __u32 *mntopts, __u32 ok) -{ - char *cp, *buf, *next; - int neg; - unsigned int mask; - int rc = 0; - - buf = malloc(strlen(str)+1); - if (!buf) - return 1; - strcpy(buf, str); - cp = buf; - while (cp && *cp) { - neg = 0; - cp = skip_over_blanks(cp); - next = skip_over_word(cp); - if (*next == 0) - next = 0; - else - *next = 0; - switch (*cp) { - case '-': - case '^': - neg++; - case '+': - cp++; - break; - } - if (e2p_string2mntopt(cp, &mask)) { - rc = 1; - break; - } - if (ok && !(ok & mask)) { - rc = 1; - break; - } - if (mask & EXT3_DEFM_JMODE) - *mntopts &= ~EXT3_DEFM_JMODE; - if (neg) - *mntopts &= ~mask; - else - *mntopts |= mask; - cp = next ? next+1 : 0; - } - free(buf); - return rc; -} diff --git a/libcustomext2fs/source/e2p/ostype.c b/libcustomext2fs/source/e2p/ostype.c deleted file mode 100644 index 978315b8..00000000 --- a/libcustomext2fs/source/e2p/ostype.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * getostype.c - Get the Filesystem OS type - * - * Copyright (C) 2004,2005 Theodore Ts'o - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Library - * General Public License, version 2. - * %End-Header% - */ - -#include "e2p.h" -#include -#include - -static const char *os_tab[] = - { "Linux", - "Hurd", - "Masix", - "FreeBSD", - "Lites", - 0 }; - -/* - * Convert an os_type to a string - */ -char *e2p_os2string(int os_type) -{ - const char *os; - char *ret; - - if (os_type <= EXT2_OS_LITES) - os = os_tab[os_type]; - else - os = "(unknown os)"; - - ret = malloc(strlen(os)+1); - if (ret) - strcpy(ret, os); - return ret; -} - -/* - * Convert an os_type to a string - */ -int e2p_string2os(char *str) -{ - const char **cpp; - int i = 0; - - for (cpp = os_tab; *cpp; cpp++, i++) { - if (!strcasecmp(str, *cpp)) - return i; - } - return -1; -} - -#ifdef TEST_PROGRAM -int main(int argc, char **argv) -{ - char *s; - int i, os; - - for (i=0; i <= EXT2_OS_LITES; i++) { - s = e2p_os2string(i); - os = e2p_string2os(s); - printf("%d: %s (%d)\n", i, s, os); - if (i != os) { - fprintf(stderr, "Failure!\n"); - exit(1); - } - } - exit(0); -} -#endif - - diff --git a/libcustomext2fs/source/e2p/parse_num.c b/libcustomext2fs/source/e2p/parse_num.c deleted file mode 100644 index 83a329ae..00000000 --- a/libcustomext2fs/source/e2p/parse_num.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * parse_num.c - Parse the number of blocks - * - * Copyright (C) 2004,2005 Theodore Ts'o - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Library - * General Public License, version 2. - * %End-Header% - */ - -#include "e2p.h" - -#include - -unsigned long long parse_num_blocks2(const char *arg, int log_block_size) -{ - char *p; - unsigned long long num; - - num = strtoull(arg, &p, 0); - - if (p[0] && p[1]) - return 0; - - switch (*p) { /* Using fall-through logic */ - case 'T': case 't': - num <<= 10; - case 'G': case 'g': - num <<= 10; - case 'M': case 'm': - num <<= 10; - case 'K': case 'k': - num >>= log_block_size; - break; - case 's': - num >>= (1+log_block_size); - break; - case '\0': - break; - default: - return 0; - } - return num; -} - -unsigned long parse_num_blocks(const char *arg, int log_block_size) -{ - return parse_num_blocks2(arg, log_block_size); -} - -#ifdef DEBUG -#include -#include - -main(int argc, char **argv) -{ - unsigned long num; - int log_block_size = 0; - - if (argc != 2) { - fprintf(stderr, "Usage: %s arg\n", argv[0]); - exit(1); - } - - num = parse_num_blocks(argv[1], log_block_size); - - printf("Parsed number: %lu\n", num); - exit(0); -} -#endif diff --git a/libcustomext2fs/source/e2p/pe.c b/libcustomext2fs/source/e2p/pe.c deleted file mode 100644 index 78c80993..00000000 --- a/libcustomext2fs/source/e2p/pe.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * pe.c - Print a second extended filesystem errors behavior - * - * Copyright (C) 1992, 1993, 1994 Remy Card - * Laboratoire MASI, Institut Blaise Pascal - * Universite Pierre et Marie Curie (Paris VI) - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Library - * General Public License, version 2. - * %End-Header% - */ - -/* - * History: - * 94/01/09 - Creation - */ - -#include - -#include "e2p.h" - -void print_fs_errors (FILE * f, unsigned short errors) -{ - switch (errors) - { - case EXT2_ERRORS_CONTINUE: - fprintf (f, "Continue"); - break; - case EXT2_ERRORS_RO: - fprintf (f, "Remount read-only"); - break; - case EXT2_ERRORS_PANIC: - fprintf (f, "Panic"); - break; - default: - fprintf (f, "Unknown (continue)"); - } -} diff --git a/libcustomext2fs/source/e2p/percent.c b/libcustomext2fs/source/e2p/percent.c deleted file mode 100644 index cfa7046e..00000000 --- a/libcustomext2fs/source/e2p/percent.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * percent.c - Take percentage of a number - * - * Copyright (C) 2006 Theodore Ts'o - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Library - * General Public License, version 2. - * %End-Header% - */ - -#include "e2p.h" - -#include - -/* - * We work really hard to calculate this accurately, while avoiding - * an overflow. "Is there a hyphen in anal-retentive?" :-) - */ -unsigned int e2p_percent(int percent, unsigned int base) -{ - unsigned int mask = ~((1 << (sizeof(unsigned int) - 1) * 8) - 1); - - if (!percent) - return 0; - if (100 % percent == 0) - return base / (100 / percent); - if (mask & base) - return (base / 100) * percent; - return base * percent / 100; -} - -#ifdef DEBUG -#include -#include - -main(int argc, char **argv) -{ - unsigned int base; - int percent; - char *p; - int log_block_size = 0; - - if (argc != 3) { - fprintf(stderr, "Usage: %s percent base\n", argv[0]); - exit(1); - } - - percent = strtoul(argv[1], &p, 0); - if (p[0] && p[1]) { - fprintf(stderr, "Bad percent: %s\n", argv[1]); - exit(1); - } - - base = strtoul(argv[2], &p, 0); - if (p[0] && p[1]) { - fprintf(stderr, "Bad base: %s\n", argv[2]); - exit(1); - } - - printf("%d percent of %u is %u.\n", percent, base, - e2p_percent(percent, base)); - - exit(0); -} -#endif diff --git a/libcustomext2fs/source/e2p/pf.c b/libcustomext2fs/source/e2p/pf.c deleted file mode 100644 index f34a5cc3..00000000 --- a/libcustomext2fs/source/e2p/pf.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * pf.c - Print file attributes on an ext2 file system - * - * Copyright (C) 1993, 1994 Remy Card - * Laboratoire MASI, Institut Blaise Pascal - * Universite Pierre et Marie Curie (Paris VI) - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Library - * General Public License, version 2. - * %End-Header% - */ - -/* - * History: - * 93/10/30 - Creation - */ - -#include - -#include "e2p.h" - -struct flags_name { - unsigned long flag; - const char *short_name; - const char *long_name; -}; - -static struct flags_name flags_array[] = { - { EXT2_SECRM_FL, "s", "Secure_Deletion" }, - { EXT2_UNRM_FL, "u" , "Undelete" }, - { EXT2_SYNC_FL, "S", "Synchronous_Updates" }, - { EXT2_DIRSYNC_FL, "D", "Synchronous_Directory_Updates" }, - { EXT2_IMMUTABLE_FL, "i", "Immutable" }, - { EXT2_APPEND_FL, "a", "Append_Only" }, - { EXT2_NODUMP_FL, "d", "No_Dump" }, - { EXT2_NOATIME_FL, "A", "No_Atime" }, - { EXT2_COMPR_FL, "c", "Compression_Requested" }, -#ifdef ENABLE_COMPRESSION - { EXT2_COMPRBLK_FL, "B", "Compressed_File" }, - { EXT2_DIRTY_FL, "Z", "Compressed_Dirty_File" }, - { EXT2_NOCOMPR_FL, "X", "Compression_Raw_Access" }, - { EXT2_ECOMPR_FL, "E", "Compression_Error" }, -#endif - { EXT3_JOURNAL_DATA_FL, "j", "Journaled_Data" }, - { EXT2_INDEX_FL, "I", "Indexed_directory" }, - { EXT2_NOTAIL_FL, "t", "No_Tailmerging" }, - { EXT2_TOPDIR_FL, "T", "Top_of_Directory_Hierarchies" }, - { EXT4_EXTENTS_FL, "e", "Extents" }, - { EXT4_HUGE_FILE_FL, "h", "Huge_file" }, - { 0, NULL, NULL } -}; - -void print_flags (FILE * f, unsigned long flags, unsigned options) -{ - int long_opt = (options & PFOPT_LONG); - struct flags_name *fp; - int first = 1; - - for (fp = flags_array; fp->flag != 0; fp++) { - if (flags & fp->flag) { - if (long_opt) { - if (first) - first = 0; - else - fputs(", ", f); - fputs(fp->long_name, f); - } else - fputs(fp->short_name, f); - } else { - if (!long_opt) - fputs("-", f); - } - } - if (long_opt && first) - fputs("---", f); -} - diff --git a/libcustomext2fs/source/e2p/ps.c b/libcustomext2fs/source/e2p/ps.c deleted file mode 100644 index e6ad60ab..00000000 --- a/libcustomext2fs/source/e2p/ps.c +++ /dev/null @@ -1,31 +0,0 @@ -/* - * ps.c - Print filesystem state - * - * Copyright (C) 1993, 1994 Remy Card - * Laboratoire MASI, Institut Blaise Pascal - * Universite Pierre et Marie Curie (Paris VI) - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Library - * General Public License, version 2. - * %End-Header% - */ - -/* - * History: - * 93/12/22 - Creation - */ - -#include - -#include "e2p.h" - -void print_fs_state (FILE * f, unsigned short state) -{ - if (state & EXT2_VALID_FS) - fprintf (f, " clean"); - else - fprintf (f, " not clean"); - if (state & EXT2_ERROR_FS) - fprintf (f, " with errors"); -} diff --git a/libcustomext2fs/source/e2p/setflags.c b/libcustomext2fs/source/e2p/setflags.c deleted file mode 100644 index 776300d3..00000000 --- a/libcustomext2fs/source/e2p/setflags.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * setflags.c - Set a file flags on an ext2 file system - * - * Copyright (C) 1993, 1994 Remy Card - * Laboratoire MASI, Institut Blaise Pascal - * Universite Pierre et Marie Curie (Paris VI) - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Library - * General Public License, version 2. - * %End-Header% - */ - -/* - * History: - * 93/10/30 - Creation - */ - -#if HAVE_ERRNO_H -#include -#endif -#include -#include -#if HAVE_EXT2_IOCTLS -#include -#endif - -#include "e2p.h" - -/* - * Deal with lame glibc's that define this function without actually - * implementing it. Can you say "attractive nuisance", boys and girls? - * I knew you could! - */ -#ifdef __linux__ -#undef HAVE_CHFLAGS -#endif - -int setflags (int fd, unsigned long flags) -{ -#if HAVE_CHFLAGS - struct stat buf; - unsigned long bsd_flags = 0; - -#ifdef UF_IMMUTABLE - if (flags & EXT2_IMMUTABLE_FL) - bsd_flags |= UF_IMMUTABLE; -#endif -#ifdef UF_APPEND - if (flags & EXT2_APPEND_FL) - bsd_flags |= UF_APPEND; -#endif -#ifdef UF_NODUMP - if (flags & EXT2_NODUMP_FL) - bsd_flags |= UF_NODUMP; -#endif - - return fchflags (fd, bsd_flags); -#else -#if HAVE_EXT2_IOCTLS - int f; - - if (!fstat(fd, &buf) && - !S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode)) { - errno = EOPNOTSUPP; - return -1; - } - f = (int) flags; - return ioctl (fd, EXT2_IOC_SETFLAGS, &f); -#endif /* HAVE_EXT2_IOCTLS */ -#endif - errno = EOPNOTSUPP; - return -1; -} diff --git a/libcustomext2fs/source/e2p/setversion.c b/libcustomext2fs/source/e2p/setversion.c deleted file mode 100644 index d7d41289..00000000 --- a/libcustomext2fs/source/e2p/setversion.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * setversion.c - Set a file version on an ext2 file system - * - * Copyright (C) 1993, 1994 Remy Card - * Laboratoire MASI, Institut Blaise Pascal - * Universite Pierre et Marie Curie (Paris VI) - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Library - * General Public License, version 2. - * %End-Header% - */ - -/* - * History: - * 93/10/30 - Creation - */ - -#if HAVE_ERRNO_H -#include -#endif -#if HAVE_EXT2_IOCTLS -#include -#endif - -#include "e2p.h" - -int setversion (int fd, unsigned long version) -{ -#if HAVE_EXT2_IOCTLS - int ver; - - ver = (int) version; - return ioctl (fd, EXT2_IOC_SETVERSION, &ver); -#else /* ! HAVE_EXT2_IOCTLS */ - extern int errno; - errno = EOPNOTSUPP; - return -1; -#endif /* ! HAVE_EXT2_IOCTLS */ -} diff --git a/libcustomext2fs/source/e2p/uuid.c b/libcustomext2fs/source/e2p/uuid.c deleted file mode 100644 index 310b01de..00000000 --- a/libcustomext2fs/source/e2p/uuid.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * uuid.c -- utility routines for manipulating UUID's. - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Library - * General Public License, version 2. - * %End-Header% - */ - -#include -#include -#include - -#include "e2p.h" - -struct uuid { - __u32 time_low; - __u16 time_mid; - __u16 time_hi_and_version; - __u16 clock_seq; - __u8 node[6]; -}; - -/* Returns 1 if the uuid is the NULL uuid */ -int e2p_is_null_uuid(void *uu) -{ - __u8 *cp; - int i; - - for (i=0, cp = uu; i < 16; i++) - if (*cp++) - return 0; - return 1; -} - -static void e2p_unpack_uuid(void *in, struct uuid *uu) -{ - __u8 *ptr = in; - __u32 tmp; - - tmp = *ptr++; - tmp = (tmp << 8) | *ptr++; - tmp = (tmp << 8) | *ptr++; - tmp = (tmp << 8) | *ptr++; - uu->time_low = tmp; - - tmp = *ptr++; - tmp = (tmp << 8) | *ptr++; - uu->time_mid = tmp; - - tmp = *ptr++; - tmp = (tmp << 8) | *ptr++; - uu->time_hi_and_version = tmp; - - tmp = *ptr++; - tmp = (tmp << 8) | *ptr++; - uu->clock_seq = tmp; - - memcpy(uu->node, ptr, 6); -} - -void e2p_uuid_to_str(void *uu, char *out) -{ - struct uuid uuid; - - e2p_unpack_uuid(uu, &uuid); - sprintf(out, - "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", - uuid.time_low, uuid.time_mid, uuid.time_hi_and_version, - uuid.clock_seq >> 8, uuid.clock_seq & 0xFF, - uuid.node[0], uuid.node[1], uuid.node[2], - uuid.node[3], uuid.node[4], uuid.node[5]); -} - -const char *e2p_uuid2str(void *uu) -{ - static char buf[80]; - - if (e2p_is_null_uuid(uu)) - return ""; - e2p_uuid_to_str(uu, buf); - return buf; -} - diff --git a/libcustomext2fs/source/gen_bitmap.c b/libcustomext2fs/source/gen_bitmap.c index ca9cb284..2ef1d826 100644 --- a/libcustomext2fs/source/gen_bitmap.c +++ b/libcustomext2fs/source/gen_bitmap.c @@ -218,7 +218,7 @@ int ext2fs_unmark_generic_bitmap(ext2fs_generic_bitmap bitmap, if (!EXT2FS_IS_32_BITMAP(bitmap)) { if (EXT2FS_IS_64_BITMAP(bitmap)) { ext2fs_warn_bitmap32(bitmap, __func__); - return ext2fs_mark_generic_bmap(bitmap, bitno); + return ext2fs_unmark_generic_bmap(bitmap, bitno); } #ifndef OMIT_COM_ERR com_err(0, EXT2_ET_MAGIC_GENERIC_BITMAP, diff --git a/libcustomext2fs/source/gen_bitmap64.c b/libcustomext2fs/source/gen_bitmap64.c index 8108f3d7..8424f576 100644 --- a/libcustomext2fs/source/gen_bitmap64.c +++ b/libcustomext2fs/source/gen_bitmap64.c @@ -144,7 +144,7 @@ void ext2fs_free_generic_bmap(ext2fs_generic_bitmap bmap) return; if (EXT2FS_IS_32_BITMAP(bmap)) { - ext2fs_free_generic_bitmap((ext2fs_generic_bitmap) bmap); + ext2fs_free_generic_bitmap(bmap); return; } @@ -171,8 +171,7 @@ errcode_t ext2fs_copy_generic_bmap(ext2fs_generic_bitmap src, return EINVAL; if (EXT2FS_IS_32_BITMAP(src)) - return ext2fs_copy_generic_bitmap((ext2fs_generic_bitmap) src, - (ext2fs_generic_bitmap *) dest); + return ext2fs_copy_generic_bitmap(src, dest); if (!EXT2FS_IS_64_BITMAP(src)) return EINVAL; @@ -222,11 +221,9 @@ errcode_t ext2fs_resize_generic_bmap(ext2fs_generic_bitmap bmap, if (!bmap) return EINVAL; - if (EXT2FS_IS_32_BITMAP(bmap)) { - return ext2fs_resize_generic_bitmap(bmap->magic, - new_end, new_real_end, - (ext2fs_generic_bitmap) bmap); - } + if (EXT2FS_IS_32_BITMAP(bmap)) + return ext2fs_resize_generic_bitmap(bmap->magic, new_end, + new_real_end, bmap); if (!EXT2FS_IS_64_BITMAP(bmap)) return EINVAL; @@ -245,9 +242,8 @@ errcode_t ext2fs_fudge_generic_bmap_end(ext2fs_generic_bitmap bitmap, ext2_ino_t tmp_oend; int retval; - retval = ext2fs_fudge_generic_bitmap_end((ext2fs_generic_bitmap) bitmap, - bitmap->magic, neq, - end, &tmp_oend); + retval = ext2fs_fudge_generic_bitmap_end(bitmap, bitmap->magic, + neq, end, &tmp_oend); if (oend) *oend = tmp_oend; return retval; @@ -269,11 +265,8 @@ __u64 ext2fs_get_generic_bmap_start(ext2fs_generic_bitmap bitmap) if (!bitmap) return EINVAL; - if (EXT2FS_IS_32_BITMAP(bitmap)) { - return ext2fs_get_generic_bitmap_start((ext2fs_generic_bitmap) - bitmap); - - } + if (EXT2FS_IS_32_BITMAP(bitmap)) + return ext2fs_get_generic_bitmap_start(bitmap); if (!EXT2FS_IS_64_BITMAP(bitmap)) return EINVAL; @@ -286,11 +279,8 @@ __u64 ext2fs_get_generic_bmap_end(ext2fs_generic_bitmap bitmap) if (!bitmap) return EINVAL; - if (EXT2FS_IS_32_BITMAP(bitmap)) { - return ext2fs_get_generic_bitmap_end((ext2fs_generic_bitmap) - bitmap); - - } + if (EXT2FS_IS_32_BITMAP(bitmap)) + return ext2fs_get_generic_bitmap_end(bitmap); if (!EXT2FS_IS_64_BITMAP(bitmap)) return EINVAL; @@ -300,10 +290,8 @@ __u64 ext2fs_get_generic_bmap_end(ext2fs_generic_bitmap bitmap) void ext2fs_clear_generic_bmap(ext2fs_generic_bitmap bitmap) { - if (EXT2FS_IS_32_BITMAP(bitmap)) { - ext2fs_clear_generic_bitmap((ext2fs_generic_bitmap) bitmap); - return; - } + if (EXT2FS_IS_32_BITMAP(bitmap)) + ext2fs_clear_generic_bitmap(bitmap); bitmap->bitmap_ops->clear_bmap (bitmap); } @@ -316,12 +304,11 @@ int ext2fs_mark_generic_bmap(ext2fs_generic_bitmap bitmap, if (EXT2FS_IS_32_BITMAP(bitmap)) { if (arg & ~0xffffffffULL) { - ext2fs_warn_bitmap2((ext2fs_generic_bitmap) bitmap, + ext2fs_warn_bitmap2(bitmap, EXT2FS_MARK_ERROR, 0xffffffff); return 0; } - return ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) - bitmap, arg); + return ext2fs_mark_generic_bitmap(bitmap, arg); } if (!EXT2FS_IS_64_BITMAP(bitmap)) @@ -343,12 +330,11 @@ int ext2fs_unmark_generic_bmap(ext2fs_generic_bitmap bitmap, if (EXT2FS_IS_32_BITMAP(bitmap)) { if (arg & ~0xffffffffULL) { - ext2fs_warn_bitmap2((ext2fs_generic_bitmap) bitmap, - EXT2FS_UNMARK_ERROR, 0xffffffff); + ext2fs_warn_bitmap2(bitmap, EXT2FS_UNMARK_ERROR, + 0xffffffff); return 0; } - return ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) - bitmap, arg); + return ext2fs_unmark_generic_bitmap(bitmap, arg); } if (!EXT2FS_IS_64_BITMAP(bitmap)) @@ -370,12 +356,11 @@ int ext2fs_test_generic_bmap(ext2fs_generic_bitmap bitmap, if (EXT2FS_IS_32_BITMAP(bitmap)) { if (arg & ~0xffffffffULL) { - ext2fs_warn_bitmap2((ext2fs_generic_bitmap) bitmap, - EXT2FS_TEST_ERROR, 0xffffffff); + ext2fs_warn_bitmap2(bitmap, EXT2FS_TEST_ERROR, + 0xffffffff); return 0; } - return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) - bitmap, arg); + return ext2fs_test_generic_bitmap(bitmap, arg); } if (!EXT2FS_IS_64_BITMAP(bitmap)) @@ -398,13 +383,12 @@ errcode_t ext2fs_set_generic_bmap_range(ext2fs_generic_bitmap bmap, if (EXT2FS_IS_32_BITMAP(bmap)) { if ((start+num) & ~0xffffffffULL) { - ext2fs_warn_bitmap2((ext2fs_generic_bitmap) bmap, - EXT2FS_UNMARK_ERROR, 0xffffffff); + ext2fs_warn_bitmap2(bmap, EXT2FS_UNMARK_ERROR, + 0xffffffff); return EINVAL; } - return ext2fs_set_generic_bitmap_range((ext2fs_generic_bitmap) bmap, - bmap->magic, start, num, - in); + return ext2fs_set_generic_bitmap_range(bmap, bmap->magic, + start, num, in); } if (!EXT2FS_IS_64_BITMAP(bmap)) @@ -422,13 +406,12 @@ errcode_t ext2fs_get_generic_bmap_range(ext2fs_generic_bitmap bmap, if (EXT2FS_IS_32_BITMAP(bmap)) { if ((start+num) & ~0xffffffffULL) { - ext2fs_warn_bitmap2((ext2fs_generic_bitmap) bmap, + ext2fs_warn_bitmap2(bmap, EXT2FS_UNMARK_ERROR, 0xffffffff); return EINVAL; } - return ext2fs_get_generic_bitmap_range((ext2fs_generic_bitmap) bmap, - bmap->magic, start, num, - out); + return ext2fs_get_generic_bitmap_range(bmap, bmap->magic, + start, num, out); } if (!EXT2FS_IS_64_BITMAP(bmap)) @@ -450,9 +433,7 @@ errcode_t ext2fs_compare_generic_bmap(errcode_t neq, /* Now we know both bitmaps have the same magic */ if (EXT2FS_IS_32_BITMAP(bm1)) - return ext2fs_compare_generic_bitmap(bm1->magic, neq, - (ext2fs_generic_bitmap) bm1, - (ext2fs_generic_bitmap) bm2); + return ext2fs_compare_generic_bitmap(bm1->magic, neq, bm1, bm2); if (!EXT2FS_IS_64_BITMAP(bm1)) return EINVAL; @@ -474,7 +455,7 @@ void ext2fs_set_generic_bmap_padding(ext2fs_generic_bitmap bmap) __u64 start, num; if (EXT2FS_IS_32_BITMAP(bmap)) { - ext2fs_set_generic_bitmap_padding((ext2fs_generic_bitmap) bmap); + ext2fs_set_generic_bitmap_padding(bmap); return; } @@ -577,5 +558,5 @@ int ext2fs_warn_bitmap32(ext2fs_generic_bitmap bitmap, const char *func) com_err(0, EXT2_ET_MAGIC_GENERIC_BITMAP, "called %s with 64-bit bitmap", func); #endif - return 0; + return 0; } diff --git a/libcustomext2fs/source/inode_io.c b/libcustomext2fs/source/inode_io.c index 4faaa487..b3e7ce51 100644 --- a/libcustomext2fs/source/inode_io.c +++ b/libcustomext2fs/source/inode_io.c @@ -163,9 +163,10 @@ static errcode_t inode_open(const char *name, int flags, io_channel *channel) return 0; cleanup: - if (data) { + if (io->name) + ext2fs_free_mem(&io->name); + if (data) ext2fs_free_mem(&data); - } if (io) ext2fs_free_mem(&io); return retval; diff --git a/libcustomext2fs/source/mkjournal.c b/libcustomext2fs/source/mkjournal.c index ce207ba3..47fb92c2 100644 --- a/libcustomext2fs/source/mkjournal.c +++ b/libcustomext2fs/source/mkjournal.c @@ -36,7 +36,6 @@ #endif #include "ext2_fs.h" -#include "e2p/e2p.h" #include "ext2fs.h" #include "jfs_user.h" @@ -379,6 +378,7 @@ static errcode_t write_journal_inode(ext2_filsys fs, ext2_ino_t journal_ino, ext2fs_mark_super_dirty(fs); errout: + ext2fs_zero_blocks2(0, 0, 0, 0, 0); ext2fs_free_mem(&buf); return retval; } diff --git a/libcustomext2fs/source/progress.c b/libcustomext2fs/source/progress.c index 708df959..335b98b5 100644 --- a/libcustomext2fs/source/progress.c +++ b/libcustomext2fs/source/progress.c @@ -40,7 +40,7 @@ void ext2fs_numeric_progress_init(ext2_filsys fs, memset(spaces, ' ', sizeof(spaces)-1); spaces[sizeof(spaces)-1] = 0; memset(backspaces, '\b', sizeof(backspaces)-1); - spaces[sizeof(backspaces)-1] = 0; + backspaces[sizeof(backspaces)-1] = 0; progress->skip_progress = 0; if (getenv("E2FSPROGS_SKIP_PROGRESS")) progress->skip_progress++;