diff options
author | Theodore Ts'o <tytso@mit.edu> | 1997-04-26 13:34:30 +0000 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 1997-04-26 13:34:30 +0000 |
commit | f3db3566b5e1342e49dffc5ec3f418a838584194 (patch) | |
tree | 1f6c5daaee7f33beb697143a8891da8a55752dd6 | |
parent | 6f4a109706f51ad11b9fff0983c140ab62549d2f (diff) | |
download | e2fsprogs-f3db3566b5e1342e49dffc5ec3f418a838584194.tar.gz |
Many files:
Checkin of e2fsprogs 0.5b
144 files changed, 5985 insertions, 3182 deletions
diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c index b92746a0..6c16af86 100644 --- a/debugfs/debugfs.c +++ b/debugfs/debugfs.c @@ -370,9 +370,9 @@ void do_freei(int argc, char *argv[]) if (!inode) return; - if (!ext2fs_test_inode_bitmap(fs,fs->inode_map,inode)) + if (!ext2fs_test_inode_bitmap(fs->inode_map,inode)) com_err(argv[0], 0, "Warning: inode already clear"); - ext2fs_unmark_inode_bitmap(fs,fs->inode_map,inode); + ext2fs_unmark_inode_bitmap(fs->inode_map,inode); ext2fs_mark_ib_dirty(fs); } @@ -394,9 +394,9 @@ void do_seti(int argc, char *argv[]) if (!inode) return; - if (ext2fs_test_inode_bitmap(fs,fs->inode_map,inode)) + if (ext2fs_test_inode_bitmap(fs->inode_map,inode)) com_err(argv[0], 0, "Warning: inode already set"); - ext2fs_mark_inode_bitmap(fs,fs->inode_map,inode); + ext2fs_mark_inode_bitmap(fs->inode_map,inode); ext2fs_mark_ib_dirty(fs); } @@ -414,7 +414,7 @@ void do_testi(int argc, char *argv[]) if (!inode) return; - if (ext2fs_test_inode_bitmap(fs,fs->inode_map,inode)) + if (ext2fs_test_inode_bitmap(fs->inode_map,inode)) printf("Inode %ld is marked in use\n", inode); else printf("Inode %ld is not in use\n", inode); @@ -441,9 +441,9 @@ void do_freeb(int argc, char *argv[]) com_err(argv[0], 0, "No block 0"); return; } - if (!ext2fs_test_block_bitmap(fs,fs->block_map,block)) + if (!ext2fs_test_block_bitmap(fs->block_map,block)) com_err(argv[0], 0, "Warning: block already clear"); - ext2fs_unmark_block_bitmap(fs,fs->block_map,block); + ext2fs_unmark_block_bitmap(fs->block_map,block); ext2fs_mark_bb_dirty(fs); } @@ -467,9 +467,9 @@ void do_setb(int argc, char *argv[]) com_err(argv[0], 0, "No block 0"); return; } - if (ext2fs_test_block_bitmap(fs,fs->block_map,block)) + if (ext2fs_test_block_bitmap(fs->block_map,block)) com_err(argv[0], 0, "Warning: block already set"); - ext2fs_mark_block_bitmap(fs,fs->block_map,block); + ext2fs_mark_block_bitmap(fs->block_map,block); ext2fs_mark_bb_dirty(fs); } @@ -489,7 +489,7 @@ void do_testb(int argc, char *argv[]) com_err(argv[0], 0, "No block 0"); return; } - if (ext2fs_test_block_bitmap(fs,fs->block_map,block)) + if (ext2fs_test_block_bitmap(fs->block_map,block)) printf("Block %ld marked in use\n", block); else printf("Block %ld not in use\n", block); } @@ -719,22 +719,6 @@ void do_change_working_dir(int argc, char *argv[]) return; } -void do_iname(int argc, char *argv[]) -{ - ino_t inode; - - if (argc > 2) { - com_err(argv[0], 0, "Usage: iname <inode>"); - return; - } - if (check_fs_open(argv[0])) - return; - - inode = strtoul(argv[1], NULL, 0); - com_err(argv[0],0,"Function unimplemented"); - return; -} - void do_print_working_directory(int argc, char *argv[]) { int retval; @@ -932,10 +916,6 @@ void do_find_free_inode(int argc, char *argv[]) printf("Free inode found: %ld\n", free_inode); } -/* - * Doesn't change directories count ---> add this later - */ - void do_mkdir(int argc, char *argv[]) { char *cp; @@ -983,7 +963,7 @@ void do_rmdir(int argc, char *argv[]) int release_blocks_proc(ext2_filsys fs, blk_t *blocknr, int blockcnt, void *private) { printf("%ld ", *blocknr); - ext2fs_unmark_block_bitmap(fs,fs->block_map,*blocknr); + ext2fs_unmark_block_bitmap(fs->block_map,*blocknr); return 0; } @@ -997,7 +977,7 @@ void kill_file_by_inode(ino_t inode) printf("Kill file by inode %ld\n", inode); ext2fs_block_iterate(fs,inode,0,NULL,release_blocks_proc,NULL); - ext2fs_unmark_inode_bitmap(fs,fs->inode_map,inode); + ext2fs_unmark_inode_bitmap(fs->inode_map,inode); ext2fs_mark_bb_dirty(fs); ext2fs_mark_ib_dirty(fs); diff --git a/debugfs/dump.c b/debugfs/dump.c new file mode 100644 index 00000000..06c588de --- /dev/null +++ b/debugfs/dump.c @@ -0,0 +1,143 @@ +/* + * dump.c --- dump the contents of an inode out to a file + * + * Copyright (C) 1994 Theodore Ts'o. This file may be redistributed + * under the terms of the GNU Public License. + */ + +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <ctype.h> +#include <string.h> +#include <time.h> +#include <getopt.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> + +#include "debugfs.h" + +struct dump_block_struct { + int fd; + char *buf; + errcode_t errcode; +}; + +int dump_block(ext2_filsys fs, blk_t *blocknr, int blockcnt, void + *private) +{ + ssize_t nbytes; + + struct dump_block_struct *rec = (struct dump_block_struct *) private; + + if (blockcnt < 0) + return 0; + + if (*blocknr) { + rec->errcode = io_channel_read_blk(fs->io, *blocknr, + 1, rec->buf); + if (rec->errcode) + return BLOCK_ABORT; + } else + memset(rec->buf, 0, fs->blocksize); + +retry_write: + nbytes = write(rec->fd, rec->buf, fs->blocksize); + if (nbytes == -1) { + if (errno == EINTR) + goto retry_write; + rec->errcode = errno; + return BLOCK_ABORT; + } + if (nbytes != fs->blocksize) { + /* XXX not quite right, but good enough */ + rec->errcode = EXT2_ET_SHORT_WRITE; + return BLOCK_ABORT; + } + return 0; +} + +void dump_file(char *cmdname, ino_t inode, int fd, char *outname) +{ + errcode_t retval; + struct dump_block_struct rec; + + rec.fd = fd; + rec.errcode = 0; + rec.buf = malloc(fs->blocksize); + + if (rec.buf == 0) { + com_err(cmdname, ENOMEM, "while allocating block buffer for dump_inode"); + return; + } + + retval = ext2fs_block_iterate(fs, inode, 0, NULL, + dump_block, &rec); + if (retval) { + com_err(cmdname, retval, "while iterating over blocks in %s", + outname); + goto cleanup; + } + if (rec.errcode) { + com_err(cmdname, retval, "in dump_block while dumping %s", + outname); + goto cleanup; + } + +cleanup: + free(rec.buf); + return; +} + +void do_dump(int argc, char **argv) +{ + ino_t inode; + int fd; + + if (argc != 3) { + com_err(argv[0], 0, "Usage: dump_inode <file> <output_file>"); + return; + } + + if (check_fs_open(argv[0])) + return; + + inode = string_to_inode(argv[1]); + if (!inode) + return; + + fd = open(argv[2], O_CREAT | O_WRONLY | O_TRUNC, 0666); + if (fd < 0) { + com_err(argv[0], errno, "while opening %s for dump_inode", + argv[2]); + return; + } + + dump_file(argv[0], inode, fd, argv[2]); + + close(fd); + return; +} + +void do_cat(int argc, char **argv) +{ + ino_t inode; + + if (argc != 2) { + com_err(argv[0], 0, "Usage: cat <file>"); + return; + } + + if (check_fs_open(argv[0])) + return; + + inode = string_to_inode(argv[1]); + if (!inode) + return; + + dump_file(argv[0], inode, 0, argv[2]); + + return; +} + diff --git a/debugfs/lsdel.c b/debugfs/lsdel.c new file mode 100644 index 00000000..3da9a9ef --- /dev/null +++ b/debugfs/lsdel.c @@ -0,0 +1,186 @@ +/* + * undelete.c --- routines to try to help a user recover a deleted file. + * + * Copyright (C) 1994 Theodore Ts'o. This file may be redistributed + * under the terms of the GNU Public License. + */ + +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <ctype.h> +#include <string.h> +#include <time.h> +#include <getopt.h> +#include <sys/types.h> +#include <sys/stat.h> + +#include "debugfs.h" + +struct deleted_info { + ino_t ino; + unsigned short mode; + unsigned short uid; + unsigned long size; + time_t dtime; + int num_blocks; + int free_blocks; +}; + +struct lsdel_struct { + ino_t inode; + int num_blocks; + int free_blocks; + int bad_blocks; +}; + +int deleted_info_compare(const void *a, const void *b) +{ + struct deleted_info *arg1, *arg2; + + arg1 = (struct deleted_info *) a; + arg2 = (struct deleted_info *) b; + + return arg1->dtime - arg2->dtime; +} + +int lsdel_proc(ext2_filsys fs, + blk_t *block_nr, + int blockcnt, + void *private) +{ + struct lsdel_struct *lsd = (struct lsdel_struct *) private; + + lsd->num_blocks++; + + if (*block_nr < fs->super->s_first_data_block || + *block_nr >= fs->super->s_blocks_count) { + lsd->bad_blocks++; + return BLOCK_ABORT; + } + + if (!ext2fs_test_block_bitmap(fs->block_map,*block_nr)) + lsd->free_blocks++; + + return 0; +} + +void do_lsdel(int argc, char **argv) +{ + struct lsdel_struct lsd; + struct deleted_info *delarray; + int num_delarray, max_delarray; + ext2_inode_scan scan = 0; + ino_t ino; + struct ext2_inode inode; + errcode_t retval; + char *block_buf; + int i; + + if (argc > 1) { + com_err(argv[0], 0, "Usage: ls_deleted_inodes\n"); + return; + } + if (check_fs_open(argv[0])) + return; + + max_delarray = 100; + num_delarray = 0; + delarray = malloc(max_delarray * sizeof(struct deleted_info)); + if (!delarray) { + com_err("ls_deleted_inodes", ENOMEM, + "while allocating deleted information storage"); + exit(1); + } + + block_buf = malloc(fs->blocksize * 3); + if (!block_buf) { + com_err("ls_deleted_inodes", ENOMEM, "while allocating block buffer"); + goto error_out; + } + + retval = ext2fs_open_inode_scan(fs, 0, &scan); + if (retval) { + com_err("ls_deleted_inodes", retval, + "while opening inode scan"); + goto error_out; + } + + retval = ext2fs_get_next_inode(scan, &ino, &inode); + if (retval) { + com_err("ls_deleted_inodes", retval, + "while starting inode scan"); + goto error_out; + } + + while (ino) { + if (inode.i_dtime == 0) + goto next; + + lsd.inode = ino; + lsd.num_blocks = 0; + lsd.free_blocks = 0; + lsd.bad_blocks = 0; + + retval = ext2fs_block_iterate(fs, ino, 0, block_buf, + lsdel_proc, &lsd); + if (retval) { + com_err("ls_deleted_inodes", retval, + "while calling ext2_block_iterate"); + goto next; + } + if (lsd.free_blocks && !lsd.bad_blocks) { + if (num_delarray >= max_delarray) { + max_delarray += 50; + delarray = realloc(delarray, + max_delarray * sizeof(struct deleted_info)); + if (!delarray) { + com_err("ls_deleted_inodes", + ENOMEM, + "while reallocating array"); + exit(1); + } + } + + delarray[num_delarray].ino = ino; + delarray[num_delarray].mode = inode.i_mode; + delarray[num_delarray].uid = inode.i_uid; + delarray[num_delarray].size = inode.i_size; + delarray[num_delarray].dtime = inode.i_dtime; + delarray[num_delarray].num_blocks = lsd.num_blocks; + delarray[num_delarray].free_blocks = lsd.free_blocks; + num_delarray++; + } + + next: + retval = ext2fs_get_next_inode(scan, &ino, &inode); + if (retval) { + com_err("ls_deleted_inodes", retval, + "while doing inode scan"); + goto error_out; + } + } + + printf("%d deleted inodes found.\n", num_delarray); + printf(" Inode Owner Mode Size Blocks Time deleted\n"); + + qsort(delarray, num_delarray, sizeof(struct deleted_info), + deleted_info_compare); + + for (i = 0; i < num_delarray; i++) { + printf("%6lu %6d %6o %6lu %4d/%4d %s", delarray[i].ino, + delarray[i].uid, delarray[i].mode, delarray[i].size, + delarray[i].free_blocks, delarray[i].num_blocks, + ctime(&delarray[i].dtime)); + } + +error_out: + free(block_buf); + free(delarray); + if (scan) + ext2fs_close_inode_scan(scan); + return; +} + + + diff --git a/e2fsck/.depend b/e2fsck/.depend index e48c1af4..e9715c62 100644 --- a/e2fsck/.depend +++ b/e2fsck/.depend @@ -3,227 +3,231 @@ badblocks.o : badblocks.c /usr/include/time.h /usr/include/features.h /usr/inclu /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h \ /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/unistd.h /usr/include/posix_opt.h \ /usr/include/gnu/types.h /usr/include/sys/types.h /usr/include/linux/types.h \ - /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ - /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/sys/time.h /usr/include/linux/time.h \ + /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/alloca.h /usr/include/sys/stat.h \ + /usr/include/linux/stat.h /usr/include/sys/time.h /usr/include/linux/time.h \ /usr/include/linux/fs.h /usr/include/linux/linkage.h /usr/include/linux/limits.h \ /usr/include/linux/wait.h /usr/include/linux/dirent.h /usr/include/linux/vfs.h \ /usr/include/linux/net.h /usr/include/linux/socket.h /usr/include/linux/sockios.h \ /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h \ /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h \ - /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h \ - /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h \ - /usr/include/linux/ext_fs_sb.h /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h \ - /usr/include/linux/msdos_fs_sb.h /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h \ - /usr/include/linux/xia_fs_sb.h /usr/include/linux/sysv_fs_sb.h /usr/include/linux/ext2_fs.h \ - ../lib/ext2fs/ext2fs.h ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h + /usr/include/linux/umsdos_fs_i.h /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h \ + /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h \ + /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h \ + ../lib/ext2fs/bitops.h dirinfo.o : dirinfo.c ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ e2fsck.h /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h \ - /usr/include/linux/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/sys/stat.h /usr/include/linux/stat.h \ - /usr/include/sys/time.h /usr/include/linux/time.h /usr/include/time.h /usr/include/linux/fs.h \ - /usr/include/linux/linkage.h /usr/include/linux/limits.h /usr/include/linux/wait.h \ - /usr/include/linux/dirent.h /usr/include/linux/vfs.h /usr/include/linux/net.h \ - /usr/include/linux/socket.h /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h \ - /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h \ - /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h \ + /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h \ + /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/sys/time.h \ + /usr/include/linux/time.h /usr/include/time.h /usr/include/linux/fs.h /usr/include/linux/linkage.h \ + /usr/include/linux/limits.h /usr/include/linux/wait.h /usr/include/linux/dirent.h \ + /usr/include/linux/vfs.h /usr/include/linux/net.h /usr/include/linux/socket.h \ + /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h \ + /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h \ + /usr/include/linux/msdos_fs_i.h /usr/include/linux/umsdos_fs_i.h /usr/include/linux/iso_fs_i.h \ /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h \ - /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h \ - /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h \ - /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h \ - /usr/include/linux/sysv_fs_sb.h /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h \ + /usr/include/linux/sysv_fs_i.h /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h \ ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h e2fsck.o : e2fsck.c /usr/include/string.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/fcntl.h /usr/include/sys/types.h \ - /usr/include/linux/types.h /usr/include/linux/fcntl.h /usr/include/ctype.h /usr/include/termios.h \ - /usr/include/linux/termios.h /usr/include/time.h /usr/include/getopt.h /usr/include/unistd.h \ - /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/mntent.h /usr/include/stdio.h \ - /usr/include/libio.h /usr/include/_G_config.h /usr/include/sys/ioctl.h /usr/include/linux/ioctl.h \ - /usr/include/malloc.h ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ - e2fsck.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/sys/stat.h /usr/include/linux/stat.h \ - /usr/include/sys/time.h /usr/include/linux/time.h /usr/include/linux/fs.h /usr/include/linux/linkage.h \ + /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/linux/fcntl.h \ + /usr/include/ctype.h /usr/include/termios.h /usr/include/linux/termios.h /usr/include/time.h \ + /usr/include/getopt.h /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h \ + /usr/include/mntent.h /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/sys/ioctl.h /usr/include/linux/ioctl.h /usr/include/malloc.h ../lib/et/com_err.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h e2fsck.h /usr/include/stdlib.h \ + /usr/include/errno.h /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/sys/time.h \ + /usr/include/linux/time.h /usr/include/linux/fs.h /usr/include/linux/linkage.h \ /usr/include/linux/limits.h /usr/include/linux/wait.h /usr/include/linux/dirent.h \ /usr/include/linux/vfs.h /usr/include/linux/net.h /usr/include/linux/socket.h \ /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h \ /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h \ - /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h \ - /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h \ - /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h /usr/include/linux/ext2_fs_sb.h \ - /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h /usr/include/linux/iso_fs_sb.h \ - /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h /usr/include/linux/sysv_fs_sb.h \ - /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h \ - ../lib/ext2fs/bitops.h ../version.h + /usr/include/linux/msdos_fs_i.h /usr/include/linux/umsdos_fs_i.h /usr/include/linux/iso_fs_i.h \ + /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h \ + /usr/include/linux/sysv_fs_i.h /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h \ + ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h ../version.h ehandler.o : ehandler.c /usr/include/stdlib.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/errno.h /usr/include/linux/errno.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/unistd.h /usr/include/posix_opt.h \ - /usr/include/gnu/types.h /usr/include/sys/types.h /usr/include/linux/types.h \ - /usr/include/string.h /usr/include/ctype.h /usr/include/termios.h /usr/include/linux/termios.h \ - /usr/include/sys/resource.h /usr/include/sys/time.h /usr/include/linux/time.h \ - /usr/include/time.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/limits.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/syslimits.h \ - /usr/include/limits.h /usr/include/posix1_lim.h /usr/include/linux/limits.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/alloca.h /usr/include/unistd.h \ + /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h /usr/include/linux/types.h \ + /usr/include/asm/types.h /usr/include/string.h /usr/include/ctype.h /usr/include/termios.h \ + /usr/include/linux/termios.h /usr/include/sys/resource.h /usr/include/sys/time.h \ + /usr/include/linux/time.h /usr/include/time.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/limits.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/syslimits.h /usr/include/limits.h \ + /usr/include/posix1_lim.h /usr/include/linux/limits.h /usr/include/posix2_lim.h \ /usr/include/linux/resource.h e2fsck.h /usr/include/stdio.h /usr/include/libio.h \ /usr/include/_G_config.h /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/linux/fs.h \ /usr/include/linux/linkage.h /usr/include/linux/wait.h /usr/include/linux/dirent.h \ /usr/include/linux/vfs.h /usr/include/linux/net.h /usr/include/linux/socket.h \ /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h \ /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h \ - /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h \ - /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h \ - /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h /usr/include/linux/ext2_fs_sb.h \ - /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h /usr/include/linux/iso_fs_sb.h \ - /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h /usr/include/linux/sysv_fs_sb.h \ - /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ - ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h + /usr/include/linux/msdos_fs_i.h /usr/include/linux/umsdos_fs_i.h /usr/include/linux/iso_fs_i.h \ + /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h \ + /usr/include/linux/sysv_fs_i.h /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h \ + ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../lib/ext2fs/io.h \ + ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h flushb.o : flushb.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h \ - /usr/include/linux/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/fcntl.h /usr/include/linux/fcntl.h \ - /usr/include/sys/ioctl.h /usr/include/linux/ioctl.h /usr/include/termios.h /usr/include/linux/termios.h \ + /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h \ + /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/fcntl.h /usr/include/linux/fcntl.h /usr/include/sys/ioctl.h \ + /usr/include/linux/ioctl.h /usr/include/termios.h /usr/include/linux/termios.h \ /usr/include/linux/fs.h /usr/include/linux/linkage.h /usr/include/linux/limits.h \ /usr/include/linux/wait.h /usr/include/linux/dirent.h /usr/include/linux/vfs.h \ /usr/include/linux/net.h /usr/include/linux/socket.h /usr/include/linux/sockios.h \ /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h \ /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h \ - /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h \ - /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h \ - /usr/include/linux/ext_fs_sb.h /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h \ - /usr/include/linux/msdos_fs_sb.h /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h \ - /usr/include/linux/xia_fs_sb.h /usr/include/linux/sysv_fs_sb.h + /usr/include/linux/umsdos_fs_i.h /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h \ + /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h mtrace.o : mtrace.c ./malloc.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h /usr/include/libio.h \ /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/limits.h \ /usr/lib/gcc-lib/i486-linux/2.5.8/include/syslimits.h /usr/include/limits.h \ - /usr/include/posix1_lim.h /usr/include/linux/limits.h /usr/include/stdlib.h \ - /usr/include/errno.h /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h + /usr/include/posix1_lim.h /usr/include/linux/limits.h /usr/include/posix2_lim.h \ + /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h pass1.o : pass1.c /usr/include/time.h /usr/include/features.h /usr/include/sys/cdefs.h \ ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h e2fsck.h \ /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h \ /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/unistd.h /usr/include/posix_opt.h \ /usr/include/gnu/types.h /usr/include/sys/types.h /usr/include/linux/types.h \ - /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ - /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/sys/time.h /usr/include/linux/time.h \ + /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/alloca.h /usr/include/sys/stat.h \ + /usr/include/linux/stat.h /usr/include/sys/time.h /usr/include/linux/time.h \ /usr/include/linux/fs.h /usr/include/linux/linkage.h /usr/include/linux/limits.h \ /usr/include/linux/wait.h /usr/include/linux/dirent.h /usr/include/linux/vfs.h \ /usr/include/linux/net.h /usr/include/linux/socket.h /usr/include/linux/sockios.h \ /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h \ /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h \ - /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h \ - /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h \ - /usr/include/linux/ext_fs_sb.h /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h \ - /usr/include/linux/msdos_fs_sb.h /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h \ - /usr/include/linux/xia_fs_sb.h /usr/include/linux/sysv_fs_sb.h /usr/include/linux/ext2_fs.h \ - ../lib/ext2fs/ext2fs.h ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h + /usr/include/linux/umsdos_fs_i.h /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h \ + /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h \ + /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h \ + ../lib/ext2fs/bitops.h pass1b.o : pass1b.c /usr/include/time.h /usr/include/features.h /usr/include/sys/cdefs.h \ ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h e2fsck.h \ /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h \ /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/unistd.h /usr/include/posix_opt.h \ /usr/include/gnu/types.h /usr/include/sys/types.h /usr/include/linux/types.h \ - /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ - /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/sys/time.h /usr/include/linux/time.h \ + /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/alloca.h /usr/include/sys/stat.h \ + /usr/include/linux/stat.h /usr/include/sys/time.h /usr/include/linux/time.h \ /usr/include/linux/fs.h /usr/include/linux/linkage.h /usr/include/linux/limits.h \ /usr/include/linux/wait.h /usr/include/linux/dirent.h /usr/include/linux/vfs.h \ /usr/include/linux/net.h /usr/include/linux/socket.h /usr/include/linux/sockios.h \ /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h \ /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h \ - /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h \ - /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h \ - /usr/include/linux/ext_fs_sb.h /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h \ - /usr/include/linux/msdos_fs_sb.h /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h \ - /usr/include/linux/xia_fs_sb.h /usr/include/linux/sysv_fs_sb.h /usr/include/linux/ext2_fs.h \ - ../lib/ext2fs/ext2fs.h ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h + /usr/include/linux/umsdos_fs_i.h /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h \ + /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h \ + /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h \ + ../lib/ext2fs/bitops.h pass2.o : pass2.c ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ e2fsck.h /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h \ - /usr/include/linux/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/sys/stat.h /usr/include/linux/stat.h \ - /usr/include/sys/time.h /usr/include/linux/time.h /usr/include/time.h /usr/include/linux/fs.h \ - /usr/include/linux/linkage.h /usr/include/linux/limits.h /usr/include/linux/wait.h \ - /usr/include/linux/dirent.h /usr/include/linux/vfs.h /usr/include/linux/net.h \ - /usr/include/linux/socket.h /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h \ - /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h \ - /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h \ + /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h \ + /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/sys/time.h \ + /usr/include/linux/time.h /usr/include/time.h /usr/include/linux/fs.h /usr/include/linux/linkage.h \ + /usr/include/linux/limits.h /usr/include/linux/wait.h /usr/include/linux/dirent.h \ + /usr/include/linux/vfs.h /usr/include/linux/net.h /usr/include/linux/socket.h \ + /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h \ + /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h \ + /usr/include/linux/msdos_fs_i.h /usr/include/linux/umsdos_fs_i.h /usr/include/linux/iso_fs_i.h \ /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h \ - /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h \ - /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h \ - /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h \ - /usr/include/linux/sysv_fs_sb.h /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h \ + /usr/include/linux/sysv_fs_i.h /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h \ ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h pass3.o : pass3.c ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ e2fsck.h /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h \ - /usr/include/linux/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/sys/stat.h /usr/include/linux/stat.h \ - /usr/include/sys/time.h /usr/include/linux/time.h /usr/include/time.h /usr/include/linux/fs.h \ - /usr/include/linux/linkage.h /usr/include/linux/limits.h /usr/include/linux/wait.h \ - /usr/include/linux/dirent.h /usr/include/linux/vfs.h /usr/include/linux/net.h \ - /usr/include/linux/socket.h /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h \ - /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h \ - /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h \ + /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h \ + /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/sys/time.h \ + /usr/include/linux/time.h /usr/include/time.h /usr/include/linux/fs.h /usr/include/linux/linkage.h \ + /usr/include/linux/limits.h /usr/include/linux/wait.h /usr/include/linux/dirent.h \ + /usr/include/linux/vfs.h /usr/include/linux/net.h /usr/include/linux/socket.h \ + /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h \ + /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h \ + /usr/include/linux/msdos_fs_i.h /usr/include/linux/umsdos_fs_i.h /usr/include/linux/iso_fs_i.h \ /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h \ - /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h \ - /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h \ - /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h \ - /usr/include/linux/sysv_fs_sb.h /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h \ + /usr/include/linux/sysv_fs_i.h /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h \ ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h pass4.o : pass4.c e2fsck.h /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h \ - /usr/include/linux/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/sys/stat.h /usr/include/linux/stat.h \ - /usr/include/sys/time.h /usr/include/linux/time.h /usr/include/time.h /usr/include/linux/fs.h \ - /usr/include/linux/linkage.h /usr/include/linux/limits.h /usr/include/linux/wait.h \ - /usr/include/linux/dirent.h /usr/include/linux/vfs.h /usr/include/linux/net.h \ - /usr/include/linux/socket.h /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h \ - /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h \ - /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h \ + /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h \ + /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/sys/time.h \ + /usr/include/linux/time.h /usr/include/time.h /usr/include/linux/fs.h /usr/include/linux/linkage.h \ + /usr/include/linux/limits.h /usr/include/linux/wait.h /usr/include/linux/dirent.h \ + /usr/include/linux/vfs.h /usr/include/linux/net.h /usr/include/linux/socket.h \ + /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h \ + /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h \ + /usr/include/linux/msdos_fs_i.h /usr/include/linux/umsdos_fs_i.h /usr/include/linux/iso_fs_i.h \ /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h \ - /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h \ - /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h \ - /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h \ - /usr/include/linux/sysv_fs_sb.h /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h \ + /usr/include/linux/sysv_fs_i.h /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h \ ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../lib/ext2fs/io.h \ ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h pass5.o : pass5.c ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ e2fsck.h /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h \ - /usr/include/linux/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/sys/stat.h /usr/include/linux/stat.h \ - /usr/include/sys/time.h /usr/include/linux/time.h /usr/include/time.h /usr/include/linux/fs.h \ - /usr/include/linux/linkage.h /usr/include/linux/limits.h /usr/include/linux/wait.h \ - /usr/include/linux/dirent.h /usr/include/linux/vfs.h /usr/include/linux/net.h \ - /usr/include/linux/socket.h /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h \ - /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h \ - /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h \ + /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h \ + /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/sys/time.h \ + /usr/include/linux/time.h /usr/include/time.h /usr/include/linux/fs.h /usr/include/linux/linkage.h \ + /usr/include/linux/limits.h /usr/include/linux/wait.h /usr/include/linux/dirent.h \ + /usr/include/linux/vfs.h /usr/include/linux/net.h /usr/include/linux/socket.h \ + /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h \ + /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h \ + /usr/include/linux/msdos_fs_i.h /usr/include/linux/umsdos_fs_i.h /usr/include/linux/iso_fs_i.h \ /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h \ - /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h \ - /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h \ - /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h \ - /usr/include/linux/sysv_fs_sb.h /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h \ + /usr/include/linux/sysv_fs_i.h /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h \ ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h +scantest.o : scantest.c /usr/include/string.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/fcntl.h /usr/include/sys/types.h \ + /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/linux/fcntl.h \ + /usr/include/ctype.h /usr/include/termios.h /usr/include/linux/termios.h /usr/include/time.h \ + /usr/include/getopt.h /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h \ + /usr/include/mntent.h /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/sys/ioctl.h /usr/include/linux/ioctl.h /usr/include/malloc.h /usr/include/sys/resource.h \ + /usr/include/sys/time.h /usr/include/linux/time.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/limits.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/syslimits.h /usr/include/limits.h \ + /usr/include/posix1_lim.h /usr/include/linux/limits.h /usr/include/posix2_lim.h \ + /usr/include/linux/resource.h ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ + ../version.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/alloca.h /usr/include/sys/stat.h \ + /usr/include/linux/stat.h /usr/include/linux/fs.h /usr/include/linux/linkage.h \ + /usr/include/linux/wait.h /usr/include/linux/dirent.h /usr/include/linux/vfs.h \ + /usr/include/linux/net.h /usr/include/linux/socket.h /usr/include/linux/sockios.h \ + /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h \ + /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h \ + /usr/include/linux/umsdos_fs_i.h /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h \ + /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h \ + /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h \ + ../lib/ext2fs/bitops.h util.o : util.c /usr/include/stdlib.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/errno.h /usr/include/linux/errno.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/unistd.h /usr/include/posix_opt.h \ - /usr/include/gnu/types.h /usr/include/sys/types.h /usr/include/linux/types.h \ - /usr/include/string.h /usr/include/ctype.h /usr/include/termios.h /usr/include/linux/termios.h \ - /usr/include/sys/resource.h /usr/include/sys/time.h /usr/include/linux/time.h \ - /usr/include/time.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/limits.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/syslimits.h \ - /usr/include/limits.h /usr/include/posix1_lim.h /usr/include/linux/limits.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/alloca.h /usr/include/unistd.h \ + /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h /usr/include/linux/types.h \ + /usr/include/asm/types.h /usr/include/string.h /usr/include/ctype.h /usr/include/termios.h \ + /usr/include/linux/termios.h /usr/include/sys/resource.h /usr/include/sys/time.h \ + /usr/include/linux/time.h /usr/include/time.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/limits.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/syslimits.h /usr/include/limits.h \ + /usr/include/posix1_lim.h /usr/include/linux/limits.h /usr/include/posix2_lim.h \ /usr/include/linux/resource.h e2fsck.h /usr/include/stdio.h /usr/include/libio.h \ /usr/include/_G_config.h /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/linux/fs.h \ /usr/include/linux/linkage.h /usr/include/linux/wait.h /usr/include/linux/dirent.h \ /usr/include/linux/vfs.h /usr/include/linux/net.h /usr/include/linux/socket.h \ /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h \ /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h \ - /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h \ - /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h \ - /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h /usr/include/linux/ext2_fs_sb.h \ - /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h /usr/include/linux/iso_fs_sb.h \ - /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h /usr/include/linux/sysv_fs_sb.h \ - /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ - ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h + /usr/include/linux/msdos_fs_i.h /usr/include/linux/umsdos_fs_i.h /usr/include/linux/iso_fs_i.h \ + /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h \ + /usr/include/linux/sysv_fs_i.h /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h \ + ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../lib/ext2fs/io.h \ + ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog new file mode 100644 index 00000000..be0ac6cd --- /dev/null +++ b/e2fsck/ChangeLog @@ -0,0 +1,70 @@ +Sat Mar 11 13:12:16 1995 Theodore Y. Ts'o <tytso@localhost> + + * pass1.c (unwind_pass1): Clear the file type statistics counter + when pass 1 needs to be restarted from scratch. + + * pass1.c (handle_fs_bad_blocks): Fix bug where bitmap blocks were + being reallocated to blocks in the next block group, + instead of the current block grup. + + * pass1.c (pass1, check_blocks): Set inode_link_info[ino] whenever + inode.i_links_count is set. + +Tue Feb 14 01:38:04 1995 Theodore Y. Ts'o (tytso@rt-11) + + * pass1.c (process_block): Add checks for if the block is + trepassing on a superblock or group descriptor table. + +Sat Dec 31 00:52:11 1994 <tytso@rsx-11.mit.edu> + + * main.c (corrupt_msg): Extend the message which is printed out + when the superblock is corrupt, to include the suggestion + of using the -b option to specify an alternate superblock. + +Thu Nov 24 09:29:58 1994 Theodore Y. Ts'o (tytso@rt-11) + + * badblocks.c (read_bad_blocks_file): If we are adding or + replacing bad blocks in the bad blocks inode, sanity check + the bad block inode first, and clear out any illegal blocks. + + * pass2.c (check_name): Don't bomb out if the attempt to get the + pathname of the containing directory returns an error; the + directory may be too badly damaged to expect that + ext2fs_get_pathname will always succeed. Use "???" if the + pathname can't be obtained (it's only for a printf to the + user anyway). + + The name of the containing directory and the bad filename + were incorrectly interchanged in the user message. Fixed. + + * pass2.c (check_name, check_dir_block): Use a common static + string for the unknown pathname. + +Mon Nov 7 22:30:54 1994 Remy Card <card@bbj> + + * Fixed lots of printf formats to make sure that block and inode + numbers are printed as unsigned integers. + +Mon Oct 24 14:10:46 1994 (tytso@rsx-11) + + * pass5.c (check_block_end): Fix calculation of how the last block + in the block bitmap should be calculated. + +Wed Sep 7 10:01:13 1994 (tytso@rsx-11) + + * pass1b.c (pass1_dupblocks): Fix declaration of dup_inode_map to + be an ext2fs_inode_bitmap, and free it properly. + + * e2fsck.h + * e2fsck.c (main): Folded in Remy Card's changes to add a revision + level to the superblock. + +Wed Aug 17 22:00:20 1994 Remy Card (card@bbj) + + * e2fsck.c (usage): Fixed bogus usage message. + +Wed Aug 17 11:21:45 1994 Theodore Y. Ts'o (tytso@rt-11) + + * pass1.c (process_bad_block): Fixed bug so that blocks in the + backup superblocks and group descriptors are handled gracefully. + diff --git a/e2fsck/Makefile b/e2fsck/Makefile index c0c64c63..a8e0f756 100644 --- a/e2fsck/Makefile +++ b/e2fsck/Makefile @@ -9,8 +9,6 @@ CFLAGS= $(PROF) $(OPT) $(MTRACE) $(MCHECK) $(WFLAGS) -I../lib LDFLAGS= $(PROF) $(OPT) PROGS= e2fsck flushb MANPAGES= e2fsck.8 -BINDIR= $(SBINDIR) -MANDIR= $(SMANDIR) LIBS= -L../lib -lss -lcom_err -lext2fs $(CHECKLIB) DEPLIBS= ../lib/libss.a ../lib/libcom_err.a ../lib/libext2fs.a @@ -20,7 +18,7 @@ DEPLIBS= ../lib/libss.a ../lib/libcom_err.a ../lib/libext2fs.a # Note: The optimization flags must include -g # #MCHECK= -checker -#LIBS= -L../lib -lss -lcom_err -lext2fs $(CHECKLIB) +#LIBS= -L../lib -lss -lcom_err -le2fs $(CHECKLIB) #DEPLIBS= ../lib/libss.a ../lib/libcom_err.a ../lib/libext2fs.a #CHECKLIB= /usr/lib/libchecker.o @@ -54,26 +52,34 @@ all: $(PROGS) # cc $(LDFLAGS) -o e2fsck $(OBJS) $(LIBS) e2fsck: $(OBJS) $(DEPLIBS) - cc $(LDFLAGS) -static -o e2fsck $(OBJS) $(LIBS) + $(CC) $(LDFLAGS) -static -o e2fsck $(OBJS) $(LIBS) flushb: flushb.o - cc $(LDFLAGS) -o flushb flushb.o $(CHECKLIB) + $(CC) $(LDFLAGS) -o flushb flushb.o $(CHECKLIB) install:: $(PROGS) - for i in $(PROGS); do \ - $(INSTALLBIN) $$i $(BINDIR)/$$i; \ - done - ln -sf e2fsck $(BINDIR)/fsck.ext2 + $(INSTALLBIN) e2fsck $(SBINDIR)/e2fsck + $(INSTALLBIN) flushb $(USRSBINDIR)/flushb + ln -sf e2fsck $(SBINDIR)/fsck.ext2 install:: $(MANPAGES) for i in $(MANPAGES); do \ - $(INSTALLMAN) $$i $(MANDIR)/$$i; \ + $(INSTALLMAN) $$i $(SMANDIR)/$$i; \ + done + +install-tree:: $(PROGS) + for i in $(PROGS); do \ + rm -f ../bin/$$i; \ + cp $$i ../bin; \ + strip ../bin/$$i; \ + chmod 555 ../bin/$$i; \ done + ln -sf e2fsck ../bin/fsck.ext2 clean: rm -f $(PROGS) \#* *\# *.s *.o *.a *~ core -really-clean: +really-clean: clean rm -f .depend dep depend .depend: diff --git a/e2fsck/badblocks.c b/e2fsck/badblocks.c index 6dff23d9..62f99c9c 100644 --- a/e2fsck/badblocks.c +++ b/e2fsck/badblocks.c @@ -10,6 +10,10 @@ #include <et/com_err.h> #include "e2fsck.h" +static int check_bb_inode_blocks(ext2_filsys fs, blk_t *block_nr, int blockcnt, + void *private); + + static void invalid_block(ext2_filsys fs, blk_t blk) { printf("Bad block %lu out of range; ignored.\n", blk); @@ -24,6 +28,19 @@ void read_bad_blocks_file(ext2_filsys fs, const char *bad_blocks_file, FILE *f; read_bitmaps(fs); + + /* + * Make sure the bad block inode is sane. If there are any + * illegal blocks, clear them. + */ + retval = ext2fs_block_iterate(fs, EXT2_BAD_INO, 0, 0, + check_bb_inode_blocks, 0); + if (retval) { + com_err("ext2fs_block_iterate", retval, + "while sanity checking the bad blocks inode"); + fatal_error(0); + } + /* * If we're appending to the bad blocks inode, read in the @@ -69,6 +86,25 @@ void read_bad_blocks_file(ext2_filsys fs, const char *bad_blocks_file, return; } +static int check_bb_inode_blocks(ext2_filsys fs, blk_t *block_nr, int blockcnt, + void *private) +{ + if (!*block_nr) + return 0; + + /* + * If the block number is outrageous, clear it and ignore it. + */ + if (*block_nr >= fs->super->s_blocks_count || + *block_nr < fs->super->s_first_data_block) { + printf("Warning illegal block %lu found in bad block inode. Cleared.\n", *block_nr); + *block_nr = 0; + return BLOCK_CHANGED; + } + + return 0; +} + void test_disk(ext2_filsys fs) { errcode_t retval; diff --git a/e2fsck/dirinfo.c b/e2fsck/dirinfo.c index 101ccee7..6c78dd1f 100644 --- a/e2fsck/dirinfo.c +++ b/e2fsck/dirinfo.c @@ -35,7 +35,7 @@ void add_dir_info(ext2_filsys fs, ino_t ino, ino_t parent, int i, j; #if 0 - printf("add_dir_info for inode %d...\n", ino); + printf("add_dir_info for inode %lu...\n", ino); #endif if (!dir_info) { dir_info_count = 0; diff --git a/e2fsck/e2fsck.8 b/e2fsck/e2fsck.8 index d79903c3..ca829630 100644 --- a/e2fsck/e2fsck.8 +++ b/e2fsck/e2fsck.8 @@ -2,7 +2,7 @@ .\" Copyright 1993, 1994 by Theodore Ts'o. All Rights Reserved. .\" This file may be copied under the terms of the GNU Public License. .\" -.TH NEW-E2FSCK 8 "March 1994" "Version 0.5" +.TH E2FSCK 8 "November 1994" "Version 0.5b" .SH NAME e2fsck \- check a Linux second extended file system .SH SYNOPSIS @@ -31,11 +31,26 @@ is used to check a Linux second extended file system. is the special file corresponding to the device (e.g /dev/hdXX). .SH OPTIONS .TP +.I -a +This option does the same thing as the +.I -p +option. It is provided for backwards compatibility only; it is +suggested that people use +.I -p +option whever possible. +.TP .I -b superblock Instead of using the normal superblock, use the alternative superblock specified by .IR superblock . .TP +.I -B blocksize +Normally, e2fsck will search for the superblock at various different +block sizes in an attempt to find the appropriate block size. This +search can be fooled in some cases. This option forces e2fsck to only +try locating the superblock at a particular blocksize. If the +superblock is not found, e2fsck will terminate with a fatal error. +.TP .I -d Print debugging output (useless unless you are debugging .B e2fsck @@ -77,9 +92,10 @@ to the filesystem.) .TP .I -p Automatically repair ("preen") the file system without any questions. -The -.I -a -option is provided for backwards compatibility. +.TP +.I -r +This option does nothing at all; it is provided only for backwards +compatibility. .TP .I -t Print timing statistics for @@ -118,10 +134,48 @@ is the sum of the following conditions: .br \ 128\ \-\ Shared library error .br +.SH BUGS +Almost any piece of software will have bugs. If you manage to find a +filesystem which causes +.B e2fsck +to crash, or which +.B e2fsck +is unable to repair, please report it to the author. +.PP +Please include as much information as possible in your bug report. +Ideally, include a complete transcript of the +.B e2fsck +run, so I can see exactly what error messages are displayed. If you +have a writeable filesystem where the transcript can be stored, the +.BR script (1) +program is a handy way to save the output of +.e2fsck +to a file. +.PP +It is also useful to send the output of +.BR dumpe2fs (8). +If a specific inode or inodes seems to be giving +.B e2fsck +trouble, try running the +.BR debugfs (8) +command and send the output of the +.I stat +command run on the relevant inode(s). If the inode is a directory, +the debugfs +.I dump +command will allow you to extract the contents of the directory inode, +which can sent to me after being first run through +.BR uuencode (1). +.PP +Always include the full version string which +.B e2fsck +displays when it is run, so I know which version you are running. .SH AUTHOR This version of .B e2fsck is written by Theodore Ts'o <tytso@mit.edu>. .SH SEE ALSO .BR mke2fs (8), -.BR tune2fs (8) +.BR tune2fs (8), +.BR dumpe2fs (8), +.BR debugfs (8) diff --git a/e2fsck/e2fsck.c b/e2fsck/e2fsck.c index 37d202b5..78fe3c92 100644 --- a/e2fsck/e2fsck.c +++ b/e2fsck/e2fsck.c @@ -51,6 +51,7 @@ int verbose = 0; int list = 0; int debug = 0; int force = 0; +int invalid_bitmaps = 0; static int show_version_only = 0; static int replace_bad_blocks = 0; @@ -63,11 +64,17 @@ struct resource_track global_rtrack; static int root_filesystem = 0; static int read_only_root = 0; +int *invalid_inode_bitmap; +int *invalid_block_bitmap; +int *invalid_inode_table; +int restart_e2fsck = 0; + static void usage(NOARGS) { fprintf(stderr, - "Usage: %s [-panyrdfvtFV] [-b superblock] [-B blocksize]\n" - "\t\tdevice\n", program_name); + "Usage: %s [-panyrcdfvtFV] [-b superblock] [-B blocksize]\n" + "\t\t[-I inode_buffer_blocks] [-P process_inode_size]\n" + "\t\t[-l|-L bad_blocks_file] device\n", program_name); exit(FSCK_USAGE); } @@ -182,34 +189,133 @@ static void sync_disks(NOARGS) sync(); } +#define MIN_CHECK 1 +#define MAX_CHECK 2 + +static const char *corrupt_msg = "\nThe filesystem superblock is corrupt. " + "Try running e2fsck with an alternate\n" + "superblock using the -b option. " + "(8193 is commonly an alternate superblock;\n" + "Hence, 'e2fsck -b 8193 <device>' may recover the filesystem.)\n\n"; + +static void check_super_value(const char *descr, unsigned long value, + int flags, unsigned long min, unsigned long max) +{ + if (((flags & MIN_CHECK) && (value < min)) || + ((flags & MAX_CHECK) && (value > max))) { + printf("Corruption found in superblock. (%s = %lu).\n", + descr, value); + printf(corrupt_msg); + fatal_error(0); + } +} + static void check_super_block(ext2_filsys fs) { blk_t first_block, last_block; - int blocks_per_group = fs->super->s_blocks_per_group; + struct ext2_super_block *s = fs->super; + blk_t blocks_per_group = fs->super->s_blocks_per_group; int i; + blk_t should_be; + /* + * Verify the super block constants... + */ + check_super_value("inodes_count", s->s_inodes_count, + MIN_CHECK, 1, 0); + check_super_value("blocks_count", s->s_blocks_count, + MIN_CHECK, 1, 0); + check_super_value("first_data_block", s->s_first_data_block, + MAX_CHECK, 0, s->s_blocks_count); + check_super_value("log_frag_size", s->s_log_frag_size, + MAX_CHECK, 0, 2); + check_super_value("log_block_size", s->s_log_block_size, + MIN_CHECK | MAX_CHECK, s->s_log_frag_size, + 2); + check_super_value("frags_per_group", s->s_frags_per_group, + MIN_CHECK | MAX_CHECK, 1, 8 * EXT2_BLOCK_SIZE(s)); + check_super_value("blocks_per_group", s->s_blocks_per_group, + MIN_CHECK | MAX_CHECK, 1, 8 * EXT2_BLOCK_SIZE(s)); + check_super_value("inodes_per_group", s->s_inodes_per_group, + MIN_CHECK, 1, 0); + check_super_value("r_blocks_count", s->s_r_blocks_count, + MAX_CHECK, 0, s->s_blocks_count); + + if (s->s_log_block_size != s->s_log_frag_size) { + printf("Superblock block_size = %d, fragsize = %d.\n", + EXT2_BLOCK_SIZE(s), EXT2_FRAG_SIZE(s)); + printf("This version of e2fsck does not support fragment " + "sizes different\n" + "from the block size.\n"); + fatal_error(0); + } + + should_be = s->s_frags_per_group / + (s->s_log_block_size - s->s_log_frag_size + 1); + if (s->s_blocks_per_group != should_be) { + printf("Superblock blocks_per_group = %lu, should " + "have been %lu\n", s->s_blocks_per_group, + should_be); + printf(corrupt_msg); + } + + should_be = (s->s_log_block_size == 0) ? 1 : 0; + if (s->s_first_data_block != should_be) { + printf("Superblock first_data_block = %lu, should " + "have been %lu\n", s->s_first_data_block, + should_be); + printf(corrupt_msg); + } + + /* + * Verify the group descriptors.... + */ first_block = fs->super->s_first_data_block; last_block = first_block + blocks_per_group; for (i = 0; i < fs->group_desc_count; i++) { + if (i == fs->group_desc_count - 1) + last_block = fs->super->s_blocks_count; if ((fs->group_desc[i].bg_block_bitmap < first_block) || (fs->group_desc[i].bg_block_bitmap >= last_block)) { - printf("Block bitmap %ld for group %d not in group.\n", + printf("Block bitmap %lu for group %d is " + "not in group.\n", fs->group_desc[i].bg_block_bitmap, i); - fatal_error(0); + preenhalt(); + if (!ask("Continue (and relocate)", 1)) { + fatal_error(0); + } + fs->group_desc[i].bg_block_bitmap = 0; + invalid_block_bitmap[i]++; + invalid_bitmaps++; } if ((fs->group_desc[i].bg_inode_bitmap < first_block) || (fs->group_desc[i].bg_inode_bitmap >= last_block)) { - printf("Inode bitmap %ld for group %d not in group.\n", + printf("Warning: Inode bitmap %lu for group %d " + "not in group.\n", fs->group_desc[i].bg_inode_bitmap, i); - fatal_error(0); + preenhalt(); + if (!ask("Continue", 1)) { + fatal_error(0); + } + fs->group_desc[i].bg_inode_bitmap = 0; + invalid_inode_bitmap[i]++; + invalid_bitmaps++; } if ((fs->group_desc[i].bg_inode_table < first_block) || ((fs->group_desc[i].bg_inode_table + fs->inode_blocks_per_group - 1) >= last_block)) { - printf("Inode table %ld for group %d not in group.\n", + printf("Warning: Inode table %lu for group %d " + "not in group.\n", fs->group_desc[i].bg_inode_table, i); - fatal_error(0); + printf("WARNING: SEVERE DATA LOSS POSSIBLE.\n"); + preenhalt(); + if (!ask("Continue", 1)) { + fatal_error(0); + } + fs->group_desc[i].bg_inode_table = 0; + invalid_inode_table[i]++; + invalid_bitmaps++; } first_block += fs->super->s_blocks_per_group; last_block += fs->super->s_blocks_per_group; @@ -250,12 +356,13 @@ static void check_if_skip(ext2_filsys fs) static void PRS(int argc, char *argv[]) { - int flush = 0; - char c; + int flush = 0; + char c; #ifdef MTRACE - extern void *mallwatch; + extern void *mallwatch; #endif - char *oldpath, newpath[PATH_MAX]; + char *oldpath; + static char newpath[PATH_MAX]; /* Update our PATH to include /sbin */ strcpy(newpath, "PATH=/sbin:"); @@ -392,6 +499,7 @@ int main (int argc, char *argv[]) if (!isatty (0) || !isatty (1)) die ("need terminal for interactive repairs"); } +restart: sync_disks(); if (superblock && blocksize) { retval = ext2fs_open(device_name, rwflag ? EXT2_FLAG_RW : 0, @@ -413,9 +521,21 @@ int main (int argc, char *argv[]) if (retval) { com_err(program_name, retval, "while trying to open %s", device_name); - printf("Couldn't find valid filesystem superblock.\n"); + if (retval == EXT2_ET_REV_TOO_HIGH) + printf ("Get a newer version of e2fsck!\n"); + else + printf(corrupt_msg); fatal_error(0); } + +#ifdef EXT2_CURRENT_REV + if (fs->super->s_rev_level > E2FSCK_CURRENT_REV) { + com_err(program_name, retval, "while trying to open %s", + device_name); + printf ("Get a newer version of e2fsck!\n"); + fatal_error(0); + } +#endif /* * If the user specified a specific superblock, presumably the * master superblock has been trashed. So we mark the @@ -426,6 +546,16 @@ int main (int argc, char *argv[]) ehandler_init(fs->io); + invalid_inode_bitmap = allocate_memory(sizeof(int) * + fs->group_desc_count, + "invalid_inode_bitmap"); + invalid_block_bitmap = allocate_memory(sizeof(int) * + fs->group_desc_count, + "invalid_block_bitmap"); + invalid_inode_table = allocate_memory(sizeof(int) * + fs->group_desc_count, + "invalid_inode_table"); + check_super_block(fs); check_if_skip(fs); if (bad_blocks_file) @@ -439,6 +569,12 @@ int main (int argc, char *argv[]) ext2fs_mark_valid(fs); pass1(fs); + if (restart_e2fsck) { + ext2fs_close(fs); + printf("Restarting e2fsck from the beginning...\n"); + restart_e2fsck = 0; + goto restart; + } pass2(fs); pass3(fs); pass4(fs); diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h index a25f461a..e9788443 100644 --- a/e2fsck/e2fsck.h +++ b/e2fsck/e2fsck.h @@ -38,6 +38,12 @@ #define FSCK_LIBRARY 128 /* Shared library error */ /* + * The last ext2fs revision level that this version of e2fsck is able to + * support + */ +#define E2FSCK_CURRENT_REV 0 + +/* * Inode count arrays */ extern unsigned short * inode_count; @@ -81,16 +87,21 @@ struct resource_track { extern const char * program_name; extern const char * device_name; -extern char * inode_used_map; /* Inodes which are in use */ -extern char * inode_bad_map; /* Inodes which are bad in some way */ -extern char * inode_dir_map; /* Inodes which are directories */ +extern ext2fs_inode_bitmap inode_used_map; /* Inodes which are in use */ +extern ext2fs_inode_bitmap inode_bad_map; /* Inodes which are bad somehow */ +extern ext2fs_inode_bitmap inode_dir_map; /* Inodes which are directories */ -extern char * block_found_map; /* Blocks which are used by an inode */ -extern char * block_dup_map; /* Blocks which are used by more than once */ +extern ext2fs_block_bitmap block_found_map; /* Blocks which are in use */ +extern ext2fs_block_bitmap block_dup_map; /* Blocks which are used by more than once */ extern const char *fix_msg[2]; /* Fixed or ignored! */ extern const char *clear_msg[2]; /* Cleared or ignored! */ +extern int *invalid_inode_bitmap; +extern int *invalid_block_bitmap; +extern int *invalid_inode_table; +extern int restart_e2fsck; + /* Command line options */ extern int nflag; extern int yflag; @@ -126,6 +137,8 @@ extern int fs_sockets_count; extern struct resource_track global_rtrack; +extern int invalid_bitmaps; + /* * Procedure declarations */ @@ -164,6 +177,10 @@ extern void preenhalt(NOARGS); extern void print_resource_track(struct resource_track *track); extern void init_resource_track(struct resource_track *track); extern int inode_has_valid_blocks(struct ext2_inode *inode); +extern void e2fsck_read_inode(ext2_filsys fs, unsigned long ino, + struct ext2_inode * inode, const char * proc); +extern void e2fsck_write_inode(ext2_filsys fs, unsigned long ino, + struct ext2_inode * inode, const char * proc); #ifdef MTRACE extern void mtrace_print(char *mesg); #endif diff --git a/e2fsck/ehandler.c b/e2fsck/ehandler.c index 96aedfb8..4873a95e 100644 --- a/e2fsck/ehandler.c +++ b/e2fsck/ehandler.c @@ -44,10 +44,10 @@ static errcode_t e2fsck_handle_read_error(io_channel channel, return 0; } if (operation) - printf("Error reading block %ld (%s) while %s. ", block, + printf("Error reading block %lu (%s) while %s. ", block, error_message(error), operation); else - printf("Error reading block %ld (%s). ", block, + printf("Error reading block %lu (%s). ", block, error_message(error)); preenhalt(); if (ask("Ignore error", 1)) @@ -84,10 +84,10 @@ static errcode_t e2fsck_handle_write_error(io_channel channel, } if (operation) - printf("Error writing block %ld (%s) while %s. ", block, + printf("Error writing block %lu (%s) while %s. ", block, error_message(error), operation); else - printf("Error writing block %ld (%s). ", block, + printf("Error writing block %lu (%s). ", block, error_message(error)); preenhalt(); if (ask("Ignore error", 1)) diff --git a/e2fsck/images/README b/e2fsck/images/README index bd111fdb..73e26817 100644 --- a/e2fsck/images/README +++ b/e2fsck/images/README @@ -15,14 +15,14 @@ follows: prepared to deal with) 16 Usage or syntax error -During the regression test, the first exit code should be 1 (with the -exception of the empty filesystem, empty.img, which will have an exit -code of 0), and the second exit code should be 0. In other words, all -of the test filesystems in this directory (with the exception of -empty.img) have some sort of filesystem corruption, which e2fsck -should fix on the first pass. After the first pass, e2fsck should -leave a fully consistent filesystem with no detectable errors found in -the second pass. +During the regression test, the first exit code should be 1, and the +second exit code should be 0. In other words, all (with one +exception) of the test filesystems in this directory have some sort of +filesystem corruption, which e2fsck should fix on the first pass. +After the first pass, e2fsck should leave a fully consistent +filesystem with no detectable errors found in the second pass. The +exception is the okgroup.img filesystem, which contains no errors, and +so both exit codes should be 0. NOTE: It appears that at least some versions of the original e2fsck do not exit with an exit status code of 1 after correcting filesystem @@ -35,6 +35,7 @@ Here's a one-line descriptons of the various test images in this directory: baddir.img Filesystem with a corrupted directory +badbblocks.img Filesystem with illegal blocks in the bad block inode. badinode.img Filesystem with various different corrupted inode entries. badlkcnt.img Filesystem with deleted files with non-zero link count @@ -46,6 +47,10 @@ bitmaps.img Filesystem with corrupted inode and block bitmaps dirlink.img Filesystem with a hard link to a directory dup.img Filesystem with blocks claimed by two different files dup2.img Filesystem with blocks claimed by three different files +dupfsblks.img Filesystem with blocks claimed by a file and + inode/block bitmaps and inode tables +dupsuper.img Filesystem with blocks claimed by a file and + the superblock / group descriptors end-bitmap.img Filesystem with corruption at the end of the block bitmap expand.img Tests e2fsck's ability to expand lost+found if @@ -54,6 +59,9 @@ lpf.img Filesystem with disconnected files and no /lost+found directory mke2fs2b.img Filesystem with corruption similar to that created by mke2fs version 0.2b -noroot.img Filesystem with a deleted root directory. +noroot.img Filesystem with a deleted root directory +okgroup.img Filesystem that's exactly 8193 blocks long + (otherwise OK) +overfsblks.img Filesystem with overlapping inode and block bitmaps diff --git a/e2fsck/images/badbblocks.img.gz b/e2fsck/images/badbblocks.img.gz Binary files differnew file mode 100644 index 00000000..3fd89cb7 --- /dev/null +++ b/e2fsck/images/badbblocks.img.gz diff --git a/e2fsck/images/bbfile.img.gz b/e2fsck/images/bbfile.img.gz Binary files differindex 155363af..1924a3f3 100644 --- a/e2fsck/images/bbfile.img.gz +++ b/e2fsck/images/bbfile.img.gz diff --git a/e2fsck/images/bitmapblks.img.gz b/e2fsck/images/bitmapblks.img.gz Binary files differnew file mode 100644 index 00000000..d5aa60fa --- /dev/null +++ b/e2fsck/images/bitmapblks.img.gz diff --git a/e2fsck/images/dupfsblks.img.gz b/e2fsck/images/dupfsblks.img.gz Binary files differnew file mode 100644 index 00000000..d3fd2a18 --- /dev/null +++ b/e2fsck/images/dupfsblks.img.gz diff --git a/e2fsck/images/dupsuper.img.gz b/e2fsck/images/dupsuper.img.gz Binary files differnew file mode 100644 index 00000000..f5c2f3eb --- /dev/null +++ b/e2fsck/images/dupsuper.img.gz diff --git a/e2fsck/images/illfsblks.img.gz b/e2fsck/images/illfsblks.img.gz Binary files differnew file mode 100644 index 00000000..f218c579 --- /dev/null +++ b/e2fsck/images/illfsblks.img.gz diff --git a/e2fsck/images/lotsbad.img.gz b/e2fsck/images/lotsbad.img.gz Binary files differnew file mode 100644 index 00000000..8e49295f --- /dev/null +++ b/e2fsck/images/lotsbad.img.gz diff --git a/e2fsck/images/messy_inode.img.gz b/e2fsck/images/messy_inode.img.gz Binary files differnew file mode 100644 index 00000000..a7eab4a2 --- /dev/null +++ b/e2fsck/images/messy_inode.img.gz diff --git a/e2fsck/images/okgroup.img.gz b/e2fsck/images/okgroup.img.gz Binary files differnew file mode 100644 index 00000000..e3530320 --- /dev/null +++ b/e2fsck/images/okgroup.img.gz diff --git a/e2fsck/images/overfsblks.img.gz b/e2fsck/images/overfsblks.img.gz Binary files differnew file mode 100644 index 00000000..15f391fa --- /dev/null +++ b/e2fsck/images/overfsblks.img.gz diff --git a/e2fsck/images/test_script.log b/e2fsck/images/test_script.log deleted file mode 100644 index c583fe5d..00000000 --- a/e2fsck/images/test_script.log +++ /dev/null @@ -1,1289 +0,0 @@ -Testing baddir.img.gz... -../e2fsck -yft /tmp/baddir.img.gz.994 -e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10 -Pass 1: Checking inodes, blocks, and sizes -Inode 13 is a zero length directory. Clear? yes - -Pass 2: Checking directory structure -Entry 'zero' in / (2) has deleted/unused inode 13. -Clear? yes - -Directory inode 12, block 0, offset 0: directory corrupted -Salvage? yes - -Missing '.' in directory inode 12. -Fix? yes - -Missing '..' in directory inode 12. -Fix? yes - -Pass 3: Checking directory connectivity -Peak memory: Memory used: 74192, elapsed time: 2.354/ 0.000/ 0.320 -'..' in /block.h (12) is . (0), should be / (2). -Fix? yes - -Pass 4: Check reference counts. -Inode 12 has ref count 1, expecting 2. -Set i_nlinks to count? yes - -Pass 5: Checking group summary information. -Fix summary information? yes - -Block bitmap differences: -22. FIXED -Free blocks count wrong (76, counted=77). FIXED -Inode bitmap differences: -13. FIXED -Free inodes count wrong for group #0 (19, counted=20). FIXED -Directories count wrong for group #0 (4, counted=3). FIXED -Free inodes count wrong (19, counted=20). FIXED - -/tmp/baddir.img.gz.994: ***** FILE SYSTEM WAS MODIFIED ***** -/tmp/baddir.img.gz.994: 12/32 files, 23/100 blocks -Memory used: 74192, elapsed time: 3.648/ 0.020/ 0.590 -Exit status is 1 - -Running e2fsck again.... -../e2fsck -yft /tmp/baddir.img.gz.994 -e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10 -Pass 1: Checking inodes, blocks, and sizes -Pass 2: Checking directory structure -Pass 3: Checking directory connectivity -Peak memory: Memory used: 78288, elapsed time: 1.369/ 0.010/ 0.280 -Pass 4: Check reference counts. -Pass 5: Checking group summary information. -/tmp/baddir.img.gz.994: 12/32 files, 23/100 blocks -Memory used: 78288, elapsed time: 2.638/ 0.030/ 0.520 -Exit status is 0 ---------------------------------------------------- -Testing badinode.img.gz... -../e2fsck -yft /tmp/badinode.img.gz.994 -e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10 -Pass 1: Checking inodes, blocks, and sizes -Pass 2: Checking directory structure -Inode 12 (/motd) has a bad mode (0110444). -Clear? yes - -i_fsize for inode 13 (/timings) is 4, should be zero. -Clear i_fsize? yes - -i_file_acl for inode 13 (/timings) is 39, should be zero. -Clear i_file_acl? yes - -Pass 3: Checking directory connectivity -Peak memory: Memory used: 78288, elapsed time: 1.882/ 0.010/ 0.300 -Pass 4: Check reference counts. -Pass 5: Checking group summary information. -Fix summary information? yes - -Block bitmap differences: -25. FIXED -Free blocks count wrong for group 0 (76, counted=77). FIXED -Free blocks count wrong (76, counted=77). FIXED -Free inodes count wrong for group #0 (19, counted=20). FIXED -Free inodes count wrong (19, counted=20). FIXED - -/tmp/badinode.img.gz.994: ***** FILE SYSTEM WAS MODIFIED ***** -/tmp/badinode.img.gz.994: 12/32 files, 23/100 blocks -Memory used: 78288, elapsed time: 3.171/ 0.040/ 0.550 -Exit status is 1 - -Running e2fsck again.... -../e2fsck -yft /tmp/badinode.img.gz.994 -e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10 -Pass 1: Checking inodes, blocks, and sizes -Pass 2: Checking directory structure -Pass 3: Checking directory connectivity -Peak memory: Memory used: 78288, elapsed time: 1.380/ 0.000/ 0.300 -Pass 4: Check reference counts. -Pass 5: Checking group summary information. -/tmp/badinode.img.gz.994: 12/32 files, 23/100 blocks -Memory used: 78288, elapsed time: 2.659/ 0.010/ 0.560 -Exit status is 0 ---------------------------------------------------- -Testing badlkcnt.img.gz... -../e2fsck -yft /tmp/badlkcnt.img.gz.994 -e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10 -Pass 1: Checking inodes, blocks, and sizes - -Deleted inode detected with non-zero link count. -This is probably due to old ext2fs kernel code. -Fix inode(s)? yes - -Inode 13 is deleted w/ non-zero link_count. CLEARED -Inode 15 is deleted w/ non-zero link_count. CLEARED -Inode 16 is deleted w/ non-zero link_count. CLEARED -Pass 2: Checking directory structure -Pass 3: Checking directory connectivity -Peak memory: Memory used: 78288, elapsed time: 1.935/ 0.030/ 0.270 -Pass 4: Check reference counts. -Pass 5: Checking group summary information. - -/tmp/badlkcnt.img.gz.994: ***** FILE SYSTEM WAS MODIFIED ***** -/tmp/badlkcnt.img.gz.994: 29/32 files, 32/100 blocks -Memory used: 78288, elapsed time: 3.211/ 0.050/ 0.520 -Exit status is 1 - -Running e2fsck again.... -../e2fsck -yft /tmp/badlkcnt.img.gz.994 -e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10 -Pass 1: Checking inodes, blocks, and sizes -Pass 2: Checking directory structure -Pass 3: Checking directory connectivity -Peak memory: Memory used: 78288, elapsed time: 1.382/ 0.010/ 0.280 -Pass 4: Check reference counts. -Pass 5: Checking group summary information. -/tmp/badlkcnt.img.gz.994: 29/32 files, 32/100 blocks -Memory used: 78288, elapsed time: 2.659/ 0.020/ 0.540 -Exit status is 0 ---------------------------------------------------- -Testing badroot.img.gz... -../e2fsck -yft /tmp/badroot.img.gz.994 -e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10 -Pass 1: Checking inodes, blocks, and sizes -Root inode is not a directory. Clear? yes - -Pass 2: Checking directory structure -Entry '..' in ??? (11) has deleted/unused inode 2. -Clear? yes - -Pass 3: Checking directory connectivity -Peak memory: Memory used: 78288, elapsed time: 1.920/ 0.020/ 0.280 -Root inode not allocated. Rellocate? yes - -Unconnected directory inode 11 (...) -Connect to /lost+found? yes - -/lost+found not found. Create? yes - -Pass 4: Check reference counts. -Inode 11 has ref count 3, expecting 2. -Set i_nlinks to count? yes - -Unattached inode 12 -Connect to /lost+found? yes - -Inode 12 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Pass 5: Checking group summary information. -Fix summary information? yes - -Free blocks count wrong for group 0 (77, counted=76). FIXED -Free blocks count wrong (77, counted=76). FIXED -Free inodes count wrong for group #0 (20, counted=19). FIXED -Directories count wrong for group #0 (2, counted=3). FIXED -Free inodes count wrong (20, counted=19). FIXED - -/tmp/badroot.img.gz.994: ***** FILE SYSTEM WAS MODIFIED ***** -/tmp/badroot.img.gz.994: 13/32 files, 24/100 blocks -Memory used: 78288, elapsed time: 3.222/ 0.040/ 0.560 -Exit status is 1 - -Running e2fsck again.... -../e2fsck -yft /tmp/badroot.img.gz.994 -e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10 -Pass 1: Checking inodes, blocks, and sizes -Pass 2: Checking directory structure -Pass 3: Checking directory connectivity -Peak memory: Memory used: 78288, elapsed time: 1.380/ 0.010/ 0.290 -Pass 4: Check reference counts. -Pass 5: Checking group summary information. -/tmp/badroot.img.gz.994: 13/32 files, 24/100 blocks -Memory used: 78288, elapsed time: 2.658/ 0.020/ 0.540 -Exit status is 0 ---------------------------------------------------- -Testing badtable.img.gz... -../e2fsck -yft /tmp/badtable.img.gz.994 -e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10 -Pass 1: Checking inodes, blocks, and sizes -Warning: Bad block(s) found in filesystem-reserved blocks. -Bad block 3 in group 0's block bitmap. Relocate? yes - -Bad block 4 in group 0's inode bitmap. Relocate? yes - -WARNING: Severe data loss possible!!!! -Bad block 6 in group 0's inode table. Relocate? yes - -Pass 2: Checking directory structure -Pass 3: Checking directory connectivity -Peak memory: Memory used: 78288, elapsed time: 1.939/ 0.020/ 0.280 -Pass 4: Check reference counts. -Pass 5: Checking group summary information. -Fix summary information? yes - -Block bitmap differences: -5 -7 +22 +23 +24 +25 +26 +27. FIXED -Free blocks count wrong for group 0 (78, counted=74). FIXED -Free blocks count wrong (78, counted=74). FIXED - -/tmp/badtable.img.gz.994: ***** FILE SYSTEM WAS MODIFIED ***** -/tmp/badtable.img.gz.994: 11/32 files, 26/100 blocks -Memory used: 78288, elapsed time: 3.232/ 0.040/ 0.550 -Exit status is 1 - -Running e2fsck again.... -../e2fsck -yft /tmp/badtable.img.gz.994 -e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10 -Pass 1: Checking inodes, blocks, and sizes -Pass 2: Checking directory structure -Pass 3: Checking directory connectivity -Peak memory: Memory used: 78288, elapsed time: 1.379/ 0.010/ 0.290 -Pass 4: Check reference counts. -Pass 5: Checking group summary information. -/tmp/badtable.img.gz.994: 11/32 files, 26/100 blocks -Memory used: 78288, elapsed time: 2.658/ 0.020/ 0.550 -Exit status is 0 ---------------------------------------------------- -Testing bbfile.img.gz... -../e2fsck -yft /tmp/bbfile.img.gz.994 -e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10 -Pass 1: Checking inodes, blocks, and sizes -Duplicate blocks found... invoking duplicate block passes. -Pass 1B: Rescan for duplicate/bad blocks -Duplicate/bad block(s) in inode 2: 21 -Duplicate/bad block(s) in inode 11: 9 10 11 12 13 14 15 16 17 18 19 20 -Duplicate/bad block(s) in inode 12: 25 26 -Pass 1C: Scan directories for inodes with dup blocks. -Pass 1D: Reconciling duplicate blocks -(There are 3 inodes containing duplicate/bad blocks.) - -File /termcap (inode #12, mod time Sun Jan 2 03:29:13 1994) - has 2 duplicate blocks, shared with 1 file: - <The bad blocks inode> (inode #1, mod time Sun Jan 2 03:32:04 1994) -Clone duplicate/bad blocks? yes - - -File /lost+found (inode #11, mod time Sun Jan 2 03:28:40 1994) - has 12 duplicate blocks, shared with 1 file: - <The bad blocks inode> (inode #1, mod time Sun Jan 2 03:32:04 1994) -Clone duplicate/bad blocks? yes - - -File / (inode #2, mod time Sun Jan 2 03:29:13 1994) - has 1 duplicate blocks, shared with 1 file: - <The bad blocks inode> (inode #1, mod time Sun Jan 2 03:32:04 1994) -Clone duplicate/bad blocks? yes - - -Warning: Bad block(s) found in filesystem-reserved blocks. -Bad block 4 in group 0's inode bitmap. Relocate? yes - -Pass 2: Checking directory structure -Pass 3: Checking directory connectivity -Peak memory: Memory used: 78288, elapsed time: 2.031/ 0.070/ 0.280 -Pass 4: Check reference counts. -Pass 5: Checking group summary information. -Fix summary information? yes - -Block bitmap differences: +22 +23 +24 +57. FIXED -Free blocks count wrong for group 0 (61, counted=42). FIXED -Free blocks count wrong (61, counted=42). FIXED - -/tmp/bbfile.img.gz.994: ***** FILE SYSTEM WAS MODIFIED ***** -/tmp/bbfile.img.gz.994: 12/32 files, 58/100 blocks -Memory used: 78288, elapsed time: 3.322/ 0.100/ 0.530 -Exit status is 1 - -Running e2fsck again.... -../e2fsck -yft /tmp/bbfile.img.gz.994 -e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10 -Pass 1: Checking inodes, blocks, and sizes -Warning: Bad block(s) found in filesystem-reserved blocks. -Pass 2: Checking directory structure -Pass 3: Checking directory connectivity -Peak memory: Memory used: 78288, elapsed time: 1.374/ 0.000/ 0.300 -Pass 4: Check reference counts. -Pass 5: Checking group summary information. -/tmp/bbfile.img.gz.994: 12/32 files, 58/100 blocks -Memory used: 78288, elapsed time: 2.649/ 0.020/ 0.550 -Exit status is 0 ---------------------------------------------------- -Testing bitmaps.img.gz... -../e2fsck -yft /tmp/bitmaps.img.gz.994 -e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10 -Pass 1: Checking inodes, blocks, and sizes -Pass 2: Checking directory structure -Pass 3: Checking directory connectivity -Peak memory: Memory used: 78288, elapsed time: 1.811/ 0.020/ 0.290 -Pass 4: Check reference counts. -Pass 5: Checking group summary information. -Fix summary information? yes - -Block bitmap differences: +12 -20 +41 -50. FIXED -Inode bitmap differences: +11 -15. FIXED - -/tmp/bitmaps.img.gz.994: ***** FILE SYSTEM WAS MODIFIED ***** -/tmp/bitmaps.img.gz.994: 11/32 files, 22/100 blocks -Memory used: 78288, elapsed time: 3.101/ 0.040/ 0.550 -Exit status is 1 - -Running e2fsck again.... -../e2fsck -yft /tmp/bitmaps.img.gz.994 -e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10 -Pass 1: Checking inodes, blocks, and sizes -Pass 2: Checking directory structure -Pass 3: Checking directory connectivity -Peak memory: Memory used: 78288, elapsed time: 1.359/ 0.000/ 0.300 -Pass 4: Check reference counts. -Pass 5: Checking group summary information. -/tmp/bitmaps.img.gz.994: 11/32 files, 22/100 blocks -Memory used: 78288, elapsed time: 2.639/ 0.010/ 0.560 -Exit status is 0 ---------------------------------------------------- -Testing dirlink.img.gz... -../e2fsck -yft /tmp/dirlink.img.gz.994 -e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10 -Pass 1: Checking inodes, blocks, and sizes -Pass 2: Checking directory structure -Entry 'quux' in /foo (12) is a link to directory /bar (13). -Clear? yes - -Pass 3: Checking directory connectivity -Peak memory: Memory used: 74192, elapsed time: 1.928/ 0.000/ 0.300 -Pass 4: Check reference counts. -Pass 5: Checking group summary information. - -/tmp/dirlink.img.gz.994: ***** FILE SYSTEM WAS MODIFIED ***** -/tmp/dirlink.img.gz.994: 13/32 files, 24/100 blocks -Memory used: 74192, elapsed time: 3.203/ 0.010/ 0.560 -Exit status is 1 - -Running e2fsck again.... -../e2fsck -yft /tmp/dirlink.img.gz.994 -e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10 -Pass 1: Checking inodes, blocks, and sizes -Pass 2: Checking directory structure -Pass 3: Checking directory connectivity -Peak memory: Memory used: 74192, elapsed time: 1.370/ 0.010/ 0.280 -Pass 4: Check reference counts. -Pass 5: Checking group summary information. -/tmp/dirlink.img.gz.994: 13/32 files, 24/100 blocks -Memory used: 74192, elapsed time: 2.649/ 0.030/ 0.530 -Exit status is 0 ---------------------------------------------------- -Testing dup.img.gz... -../e2fsck -yft /tmp/dup.img.gz.994 -e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10 -Pass 1: Checking inodes, blocks, and sizes -Duplicate blocks found... invoking duplicate block passes. -Pass 1B: Rescan for duplicate/bad blocks -Duplicate/bad block(s) in inode 12: 25 26 -Duplicate/bad block(s) in inode 13: 25 26 -Pass 1C: Scan directories for inodes with dup blocks. -Pass 1D: Reconciling duplicate blocks -(There are 2 inodes containing duplicate/bad blocks.) - -File /motd (inode #13, mod time Mon Sep 20 23:19:20 1993) - has 2 duplicate blocks, shared with 1 file: - /termcap (inode #12, mod time Mon Sep 20 23:19:14 1993) -Clone duplicate/bad blocks? yes - - -File /termcap (inode #12, mod time Mon Sep 20 23:19:14 1993) - has 2 duplicate blocks, shared with 1 file: - /motd (inode #13, mod time Mon Sep 20 23:19:20 1993) -Duplicated blocks already reassigned or cloned. - -Pass 2: Checking directory structure -Pass 3: Checking directory connectivity -Peak memory: Memory used: 78288, elapsed time: 1.652/ 0.020/ 0.310 -Pass 4: Check reference counts. -Pass 5: Checking group summary information. -Fix summary information? yes - -Free blocks count wrong for group 0 (44, counted=60). FIXED -Free blocks count wrong (62, counted=60). FIXED -Padding at end of block bitmap is not set. Fix? yes - - -/tmp/dup.img.gz.994: ***** FILE SYSTEM WAS MODIFIED ***** -/tmp/dup.img.gz.994: 13/16 files, 40/100 blocks -Memory used: 78288, elapsed time: 2.955/ 0.060/ 0.570 -Exit status is 1 - -Running e2fsck again.... -../e2fsck -yft /tmp/dup.img.gz.994 -e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10 -Pass 1: Checking inodes, blocks, and sizes -Pass 2: Checking directory structure -Pass 3: Checking directory connectivity -Peak memory: Memory used: 78288, elapsed time: 1.370/ 0.000/ 0.300 -Pass 4: Check reference counts. -Pass 5: Checking group summary information. -/tmp/dup.img.gz.994: 13/16 files, 40/100 blocks -Memory used: 78288, elapsed time: 2.647/ 0.010/ 0.560 -Exit status is 0 ---------------------------------------------------- -Testing dup2.img.gz... -../e2fsck -yft /tmp/dup2.img.gz.994 -e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10 -Pass 1: Checking inodes, blocks, and sizes -Duplicate blocks found... invoking duplicate block passes. -Pass 1B: Rescan for duplicate/bad blocks -Duplicate/bad block(s) in inode 12: 25 26 -Duplicate/bad block(s) in inode 13: 25 26 57 58 -Duplicate/bad block(s) in inode 14: 57 58 -Pass 1C: Scan directories for inodes with dup blocks. -Pass 1D: Reconciling duplicate blocks -(There are 3 inodes containing duplicate/bad blocks.) - -File /pass1.c (inode #14, mod time Tue Sep 21 00:28:37 1993) - has 2 duplicate blocks, shared with 1 file: - /motd (inode #13, mod time Mon Sep 20 23:19:20 1993) -Clone duplicate/bad blocks? yes - - -File /motd (inode #13, mod time Mon Sep 20 23:19:20 1993) - has 4 duplicate blocks, shared with 2 files: - /pass1.c (inode #14, mod time Tue Sep 21 00:28:37 1993) - /termcap (inode #12, mod time Mon Sep 20 23:19:14 1993) -Clone duplicate/bad blocks? yes - - -File /termcap (inode #12, mod time Mon Sep 20 23:19:14 1993) - has 2 duplicate blocks, shared with 1 file: - /motd (inode #13, mod time Mon Sep 20 23:19:20 1993) -Duplicated blocks already reassigned or cloned. - -Pass 2: Checking directory structure -Pass 3: Checking directory connectivity -Peak memory: Memory used: 78288, elapsed time: 1.969/ 0.020/ 0.300 -Pass 4: Check reference counts. -Pass 5: Checking group summary information. -Fix summary information? yes - -Free blocks count wrong for group 0 (8, counted=22). FIXED -Free blocks count wrong (26, counted=22). FIXED -Padding at end of block bitmap is not set. Fix? yes - - -/tmp/dup2.img.gz.994: ***** FILE SYSTEM WAS MODIFIED ***** -/tmp/dup2.img.gz.994: 16/16 files, 78/100 blocks -Memory used: 78288, elapsed time: 3.270/ 0.060/ 0.560 -Exit status is 1 - -Running e2fsck again.... -../e2fsck -yft /tmp/dup2.img.gz.994 -e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10 -Pass 1: Checking inodes, blocks, and sizes -Pass 2: Checking directory structure -Pass 3: Checking directory connectivity -Peak memory: Memory used: 78288, elapsed time: 1.383/ 0.000/ 0.300 -Pass 4: Check reference counts. -Pass 5: Checking group summary information. -/tmp/dup2.img.gz.994: 16/16 files, 78/100 blocks -Memory used: 78288, elapsed time: 2.659/ 0.020/ 0.550 -Exit status is 0 ---------------------------------------------------- -Testing end-bitmap.img.gz... -../e2fsck -yft /tmp/end-bitmap.img.gz.994 -e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10 -Pass 1: Checking inodes, blocks, and sizes -Pass 2: Checking directory structure -Pass 3: Checking directory connectivity -Peak memory: Memory used: 78288, elapsed time: 1.998/ 0.010/ 0.300 -Pass 4: Check reference counts. -Pass 5: Checking group summary information. -Fix summary information? yes - -Free blocks count wrong for group 0 (44, counted=63). FIXED -Padding at end of block bitmap is not set. Fix? yes - - -/tmp/end-bitmap.img.gz.994: ***** FILE SYSTEM WAS MODIFIED ***** -/tmp/end-bitmap.img.gz.994: 12/16 files, 37/100 blocks -Memory used: 78288, elapsed time: 3.285/ 0.030/ 0.560 -Exit status is 1 - -Running e2fsck again.... -../e2fsck -yft /tmp/end-bitmap.img.gz.994 -e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10 -Pass 1: Checking inodes, blocks, and sizes -Pass 2: Checking directory structure -Pass 3: Checking directory connectivity -Peak memory: Memory used: 78288, elapsed time: 1.391/ 0.020/ 0.270 -Pass 4: Check reference counts. -Pass 5: Checking group summary information. -/tmp/end-bitmap.img.gz.994: 12/16 files, 37/100 blocks -Memory used: 78288, elapsed time: 2.668/ 0.030/ 0.530 -Exit status is 0 ---------------------------------------------------- -Testing expand.img.gz... -../e2fsck -yft /tmp/expand.img.gz.994 -e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10 -Pass 1: Checking inodes, blocks, and sizes -Deleted inode 2 has zero dtime. -Set dtime? yes - -Pass 2: Checking directory structure -Entry '..' in /lost+found (11) has deleted/unused inode 2. -Clear? yes - -Pass 3: Checking directory connectivity -Peak memory: Memory used: 74192, elapsed time: 2.008/ 0.030/ 0.280 -Root inode not allocated. Rellocate? yes - -Unconnected directory inode 11 (...) -Connect to /lost+found? yes - -/lost+found not found. Create? yes - -Pass 4: Check reference counts. -Inode 11 has ref count 3, expecting 2. -Set i_nlinks to count? yes - -Unattached inode 12 -Connect to /lost+found? yes - -Inode 12 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 13 -Connect to /lost+found? yes - -Inode 13 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 14 -Connect to /lost+found? yes - -Inode 14 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 15 -Connect to /lost+found? yes - -Inode 15 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 16 -Connect to /lost+found? yes - -Inode 16 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 17 -Connect to /lost+found? yes - -Inode 17 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 18 -Connect to /lost+found? yes - -Inode 18 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 19 -Connect to /lost+found? yes - -Inode 19 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 20 -Connect to /lost+found? yes - -Inode 20 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 21 -Connect to /lost+found? yes - -Inode 21 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 22 -Connect to /lost+found? yes - -Inode 22 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 23 -Connect to /lost+found? yes - -Inode 23 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 24 -Connect to /lost+found? yes - -Inode 24 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 25 -Connect to /lost+found? yes - -Inode 25 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 26 -Connect to /lost+found? yes - -Inode 26 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 27 -Connect to /lost+found? yes - -Inode 27 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 28 -Connect to /lost+found? yes - -Inode 28 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 29 -Connect to /lost+found? yes - -Inode 29 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 30 -Connect to /lost+found? yes - -Inode 30 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 31 -Connect to /lost+found? yes - -Inode 31 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 32 -Connect to /lost+found? yes - -Inode 32 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 33 -Connect to /lost+found? yes - -Inode 33 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 34 -Connect to /lost+found? yes - -Inode 34 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 35 -Connect to /lost+found? yes - -Inode 35 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 36 -Connect to /lost+found? yes - -Inode 36 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 37 -Connect to /lost+found? yes - -Inode 37 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 38 -Connect to /lost+found? yes - -Inode 38 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 39 -Connect to /lost+found? yes - -Inode 39 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 40 -Connect to /lost+found? yes - -Inode 40 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 41 -Connect to /lost+found? yes - -Inode 41 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 42 -Connect to /lost+found? yes - -Inode 42 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 43 -Connect to /lost+found? yes - -Inode 43 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 44 -Connect to /lost+found? yes - -Inode 44 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 45 -Connect to /lost+found? yes - -Inode 45 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 46 -Connect to /lost+found? yes - -Inode 46 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 47 -Connect to /lost+found? yes - -Inode 47 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 48 -Connect to /lost+found? yes - -Inode 48 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 49 -Connect to /lost+found? yes - -Inode 49 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 50 -Connect to /lost+found? yes - -Inode 50 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 51 -Connect to /lost+found? yes - -Inode 51 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 52 -Connect to /lost+found? yes - -Inode 52 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 53 -Connect to /lost+found? yes - -Inode 53 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 54 -Connect to /lost+found? yes - -Inode 54 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 55 -Connect to /lost+found? yes - -Inode 55 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 56 -Connect to /lost+found? yes - -Inode 56 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 57 -Connect to /lost+found? yes - -Inode 57 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 58 -Connect to /lost+found? yes - -Inode 58 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 59 -Connect to /lost+found? yes - -Inode 59 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 60 -Connect to /lost+found? yes - -Inode 60 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 61 -Connect to /lost+found? yes - -Inode 61 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 62 -Connect to /lost+found? yes - -Inode 62 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 63 -Connect to /lost+found? yes - -Inode 63 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 64 -Connect to /lost+found? yes - -Inode 64 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 65 -Connect to /lost+found? yes - -Inode 65 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 66 -Connect to /lost+found? yes - -Inode 66 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 67 -Connect to /lost+found? yes - -Inode 67 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 68 -Connect to /lost+found? yes - -Inode 68 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 69 -Connect to /lost+found? yes - -Inode 69 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 70 -Connect to /lost+found? yes - -Inode 70 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 71 -Connect to /lost+found? yes - -Inode 71 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 72 -Connect to /lost+found? yes - -Inode 72 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 73 -Connect to /lost+found? yes - -Inode 73 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 74 -Connect to /lost+found? yes - -Inode 74 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 75 -Connect to /lost+found? yes - -Inode 75 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 76 -Connect to /lost+found? yes - -Inode 76 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 77 -Connect to /lost+found? yes - -Inode 77 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 78 -Connect to /lost+found? yes - -Inode 78 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 79 -Connect to /lost+found? yes - -Inode 79 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 80 -Connect to /lost+found? yes - -Inode 80 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 81 -Connect to /lost+found? yes - -Inode 81 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 82 -Connect to /lost+found? yes - -Inode 82 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 83 -Connect to /lost+found? yes - -Inode 83 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 84 -Connect to /lost+found? yes - -Inode 84 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 85 -Connect to /lost+found? yes - -Inode 85 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 86 -Connect to /lost+found? yes - -Inode 86 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 87 -Connect to /lost+found? yes - -Inode 87 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 88 -Connect to /lost+found? yes - -Inode 88 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 89 -Connect to /lost+found? yes - -Inode 89 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 90 -Connect to /lost+found? yes - -Inode 90 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 91 -Connect to /lost+found? yes - -Inode 91 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 92 -Connect to /lost+found? yes - -Inode 92 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 93 -Connect to /lost+found? yes - -Inode 93 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 94 -Connect to /lost+found? yes - -No room in /lost+found; expand /lost+found? yes - -Inode 94 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 95 -Connect to /lost+found? yes - -Inode 95 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 96 -Connect to /lost+found? yes - -Inode 96 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 97 -Connect to /lost+found? yes - -Inode 97 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 98 -Connect to /lost+found? yes - -Inode 98 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 99 -Connect to /lost+found? yes - -Inode 99 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 100 -Connect to /lost+found? yes - -Inode 100 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 102 -Connect to /lost+found? yes - -Inode 102 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 103 -Connect to /lost+found? yes - -Inode 103 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 104 -Connect to /lost+found? yes - -Inode 104 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Pass 5: Checking group summary information. -Fix summary information? yes - -Block bitmap differences: -33. FIXED -Free blocks count wrong for group 0 (68, counted=67). FIXED -Free blocks count wrong (68, counted=67). FIXED -Free inodes count wrong for group #0 (1, counted=0). FIXED -Directories count wrong for group #0 (2, counted=3). FIXED -Free inodes count wrong (1, counted=0). FIXED - -/tmp/expand.img.gz.994: ***** FILE SYSTEM WAS MODIFIED ***** -/tmp/expand.img.gz.994: 104/104 files, 33/100 blocks -Memory used: 74192, elapsed time: 3.652/ 0.210/ 0.740 -Exit status is 1 - -Running e2fsck again.... -../e2fsck -yft /tmp/expand.img.gz.994 -e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10 -Pass 1: Checking inodes, blocks, and sizes -Pass 2: Checking directory structure -Pass 3: Checking directory connectivity -Peak memory: Memory used: 74192, elapsed time: 1.387/ 0.010/ 0.300 -Pass 4: Check reference counts. -Pass 5: Checking group summary information. -/tmp/expand.img.gz.994: 104/104 files, 33/100 blocks -Memory used: 74192, elapsed time: 2.668/ 0.020/ 0.560 -Exit status is 0 ---------------------------------------------------- -Testing lpf.img.gz... -../e2fsck -yft /tmp/lpf.img.gz.994 -e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10 -Pass 1: Checking inodes, blocks, and sizes - -Deleted inode detected with non-zero link count. -This is probably due to old ext2fs kernel code. -Fix inode(s)? yes - -Inode 11 is deleted w/ non-zero link_count. CLEARED -Inode 13 is deleted w/ non-zero link_count. CLEARED -Pass 2: Checking directory structure -Pass 3: Checking directory connectivity -Peak memory: Memory used: 74192, elapsed time: 1.933/ 0.010/ 0.290 -Pass 4: Check reference counts. -Unattached inode 14 -Connect to /lost+found? yes - -/lost+found not found. Create? yes - -Inode 14 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Unattached inode 15 -Connect to /lost+found? yes - -Inode 15 has ref count 2, expecting 1. -Set i_nlinks to count? yes - -Pass 5: Checking group summary information. -Fix summary information? yes - -Free blocks count wrong for group 0 (25, counted=38). FIXED -Free blocks count wrong (39, counted=38). FIXED -Free inodes count wrong for group #0 (2, counted=1). FIXED -Directories count wrong for group #0 (1, counted=2). FIXED -Free inodes count wrong (2, counted=1). FIXED -Padding at end of block bitmap is not set. Fix? yes - - -/tmp/lpf.img.gz.994: ***** FILE SYSTEM WAS MODIFIED ***** -/tmp/lpf.img.gz.994: 15/16 files, 62/100 blocks -Memory used: 74192, elapsed time: 3.242/ 0.050/ 0.550 -Exit status is 1 - -Running e2fsck again.... -../e2fsck -yft /tmp/lpf.img.gz.994 -e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10 -Pass 1: Checking inodes, blocks, and sizes -Pass 2: Checking directory structure -Pass 3: Checking directory connectivity -Peak memory: Memory used: 74192, elapsed time: 1.438/ 0.000/ 0.290 -Pass 4: Check reference counts. -Pass 5: Checking group summary information. -/tmp/lpf.img.gz.994: 15/16 files, 62/100 blocks -Memory used: 74192, elapsed time: 2.717/ 0.010/ 0.550 -Exit status is 0 ---------------------------------------------------- -Testing mke2fs2b.img.gz... -../e2fsck -yft /tmp/mke2fs2b.img.gz.994 -e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10 -Pass 1: Checking inodes, blocks, and sizes -Root inode has dtime set (probably due to old mke2fs). Fix? yes - -Note: /lost+found will probably be deleted as well, due to the mke2fs bug. -Be sure to run mklost+found to recreate it after e2fsck finishes. - - -Deleted inode detected with non-zero link count. -This is probably due to old ext2fs kernel code. -Fix inode(s)? yes - -Inode 11 is deleted w/ non-zero link_count. CLEARED -Inode 15 is deleted w/ non-zero link_count. CLEARED -Pass 2: Checking directory structure -Entry 'lost+found' in / (2) has deleted/unused inode 11. -Clear? yes - -Pass 3: Checking directory connectivity -Peak memory: Memory used: 74192, elapsed time: 1.911/ 0.000/ 0.300 -Pass 4: Check reference counts. -Inode 2 has ref count 4, expecting 3. -Set i_nlinks to count? yes - -Pass 5: Checking group summary information. -Fix summary information? yes - -Block bitmap differences: -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20. FIXED -Free blocks count wrong for group 0 (75, counted=87). FIXED -Free blocks count wrong (75, counted=87). FIXED -Inode bitmap differences: -11. FIXED -Free inodes count wrong for group #0 (17, counted=18). FIXED -Directories count wrong for group #0 (4, counted=3). FIXED -Free inodes count wrong (17, counted=18). FIXED - -/tmp/mke2fs2b.img.gz.994: ***** FILE SYSTEM WAS MODIFIED ***** -/tmp/mke2fs2b.img.gz.994: 14/32 files, 13/100 blocks -Memory used: 74192, elapsed time: 3.208/ 0.020/ 0.570 -Exit status is 1 - -Running e2fsck again.... -../e2fsck -yft /tmp/mke2fs2b.img.gz.994 -e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10 -Pass 1: Checking inodes, blocks, and sizes -Pass 2: Checking directory structure -Pass 3: Checking directory connectivity -Peak memory: Memory used: 74192, elapsed time: 1.364/ 0.010/ 0.280 -Pass 4: Check reference counts. -Pass 5: Checking group summary information. -/tmp/mke2fs2b.img.gz.994: 14/32 files, 13/100 blocks -Memory used: 74192, elapsed time: 2.637/ 0.030/ 0.530 -Exit status is 0 ---------------------------------------------------- -Testing noroot.img.gz... -../e2fsck -yft /tmp/noroot.img.gz.994 -e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10 -Pass 1: Checking inodes, blocks, and sizes - -Deleted inode detected with non-zero link count. -This is probably due to old ext2fs kernel code. -Fix inode(s)? yes - -Inode 15 is deleted w/ non-zero link_count. CLEARED -Pass 2: Checking directory structure -Entry '..' in /lost+found (11) has deleted/unused inode 2. -Clear? yes - -Entry '..' in /foo (12) has deleted/unused inode 2. -Clear? yes - -Pass 3: Checking directory connectivity -Peak memory: Memory used: 74192, elapsed time: 1.951/ 0.030/ 0.280 -Root inode not allocated. Rellocate? yes - -Unconnected directory inode 11 (...) -Connect to /lost+found? yes - -/lost+found not found. Create? yes - -Unconnected directory inode 12 (...) -Connect to /lost+found? yes - -Pass 4: Check reference counts. -Inode 11 has ref count 3, expecting 2. -Set i_nlinks to count? yes - -Inode 12 has ref count 4, expecting 3. -Set i_nlinks to count? yes - -Pass 5: Checking group summary information. -Fix summary information? yes - -Free blocks count wrong for group 0 (75, counted=74). FIXED -Free blocks count wrong (75, counted=74). FIXED -Free inodes count wrong for group #0 (17, counted=16). FIXED -Directories count wrong for group #0 (4, counted=5). FIXED -Free inodes count wrong (17, counted=16). FIXED - -/tmp/noroot.img.gz.994: ***** FILE SYSTEM WAS MODIFIED ***** -/tmp/noroot.img.gz.994: 16/32 files, 26/100 blocks -Memory used: 74192, elapsed time: 3.259/ 0.050/ 0.560 -Exit status is 1 - -Running e2fsck again.... -../e2fsck -yft /tmp/noroot.img.gz.994 -e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10 -Pass 1: Checking inodes, blocks, and sizes -Pass 2: Checking directory structure -Pass 3: Checking directory connectivity -Peak memory: Memory used: 74192, elapsed time: 1.360/ 0.000/ 0.290 -Pass 4: Check reference counts. -Pass 5: Checking group summary information. -/tmp/noroot.img.gz.994: 16/32 files, 26/100 blocks -Memory used: 74192, elapsed time: 2.638/ 0.010/ 0.550 -Exit status is 0 ---------------------------------------------------- diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index 2f23b9d6..7eadea80 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -48,13 +48,12 @@ int fs_total_count = 0; int fs_badblocks_count = 0; int fs_sockets_count = 0; -char * inode_used_map = 0; /* Inodes which are in use */ -char * inode_bad_map = 0; /* Inodes which are bad in some way */ -char * inode_dir_map = 0; /* Inodes which are directories */ +ext2fs_inode_bitmap inode_used_map = 0; /* Inodes which are in use */ +ext2fs_inode_bitmap inode_bad_map = 0; /* Inodes which are bad in some way */ +ext2fs_inode_bitmap inode_dir_map = 0; /* Inodes which are directories */ -char * block_found_map = 0; -char * block_dup_map = 0; -static char * bad_fs_block_map = 0; +ext2fs_block_bitmap block_found_map = 0; +ext2fs_block_bitmap block_dup_map = 0; static int fix_link_count = -1; @@ -64,25 +63,27 @@ static int process_block(ext2_filsys fs, blk_t *blocknr, int blockcnt, void *private); static int process_bad_block(ext2_filsys fs, blk_t *block_nr, int blockcnt, void *private); -static int process_fs_bad_block(ext2_filsys fs, blk_t *block_nr, - int blockcnt, void *private); static void check_blocks(ext2_filsys fs, ino_t ino, struct ext2_inode *inode, char *block_buf); static void mark_table_blocks(ext2_filsys fs); static errcode_t pass1_check_directory(ext2_filsys fs, ino_t ino); static errcode_t pass1_get_blocks(ext2_filsys fs, ino_t ino, blk_t *blocks); static void alloc_bad_map(ext2_filsys fs); -static void handle_fs_bad_blocks(ext2_filsys fs, char *block_buf); +static void handle_fs_bad_blocks(ext2_filsys fs); static void process_inodes(ext2_filsys fs, char *block_buf); static int process_inode_cmp(const void *a, const void *b); static int dir_block_cmp(const void *a, const void *b); +static errcode_t scan_callback(ext2_filsys fs, ext2_inode_scan scan, + dgrp_t group, void * private); struct process_block_struct { ino_t ino; - int is_dir; + int is_dir:1, clear:1, suppress:1; int num_blocks; int last_block; + int num_illegal_blocks; int fix; + struct ext2_inode *inode; }; struct process_inode_block { @@ -101,7 +102,7 @@ struct ext2_inode *stashed_inode; */ static struct process_inode_block *inodes_to_process; static int process_inode_count; -int process_inode_size = 128; +int process_inode_size = 256; /* * For the directory blocks list. @@ -110,6 +111,37 @@ struct dir_block_struct *dir_blocks = 0; int dir_block_count = 0; int dir_block_size = 0; +/* + * Free all memory allocated by pass1 in preparation for restarting + * things. + */ +static void unwind_pass1(ext2_filsys fs) +{ + ext2fs_free_inode_bitmap(inode_used_map); inode_used_map = 0; + ext2fs_free_inode_bitmap(inode_dir_map); inode_dir_map = 0; + ext2fs_free_block_bitmap(block_found_map); block_found_map = 0; + free(inode_link_info); inode_link_info = 0; + free(inodes_to_process);inodes_to_process = 0; + free(dir_blocks); dir_blocks = 0; + dir_block_size = 0; + if (block_dup_map) { + free(block_dup_map); block_dup_map = 0; + } + + /* Clear statistic counters */ + fs_directory_count = 0; + fs_regular_count = 0; + fs_blockdev_count = 0; + fs_chardev_count = 0; + fs_links_count = 0; + fs_symlinks_count = 0; + fs_fast_symlinks_count = 0; + fs_fifo_count = 0; + fs_total_count = 0; + fs_badblocks_count = 0; + fs_sockets_count = 0; +} + void pass1(ext2_filsys fs) { ino_t ino; @@ -131,19 +163,22 @@ void pass1(ext2_filsys fs) /* * Allocate bitmaps structures */ - retval = ext2fs_allocate_inode_bitmap(fs, &inode_used_map); + retval = ext2fs_allocate_inode_bitmap(fs, "in-use inode map", + &inode_used_map); if (retval) { com_err("ext2fs_allocate_inode_bitmap", retval, "while allocating inode_used_map"); fatal_error(0); } - retval = ext2fs_allocate_inode_bitmap(fs, &inode_dir_map); + retval = ext2fs_allocate_inode_bitmap(fs, "directory inode map", + &inode_dir_map); if (retval) { com_err("ext2fs_allocate_inode_bitmap", retval, "while allocating inode_dir_map"); fatal_error(0); } - retval = ext2fs_allocate_block_bitmap(fs, &block_found_map); + retval = ext2fs_allocate_block_bitmap(fs, "in-use block map", + &block_found_map); if (retval) { com_err("ext2fs_allocate_block_bitmap", retval, "while allocating block_found_map"); @@ -179,6 +214,7 @@ void pass1(ext2_filsys fs) fatal_error(0); } stashed_inode = &inode; + ext2fs_set_inode_callback(scan, scan_callback, block_buf); while (ino) { stashed_ino = ino; inode_link_info[ino] = inode.i_links_count; @@ -187,14 +223,16 @@ void pass1(ext2_filsys fs) pb.ino = EXT2_BAD_INO; pb.num_blocks = pb.last_block = 0; - pb.is_dir = 0; + pb.num_illegal_blocks = 0; + pb.suppress = pb.clear = pb.is_dir = 0; pb.fix = -1; + pb.inode = &inode; retval = ext2fs_block_iterate(fs, ino, 0, block_buf, process_bad_block, &pb); if (retval) com_err(program_name, retval, "while calling e2fsc_block_interate in pass 1"); - ext2fs_mark_inode_bitmap(fs, inode_used_map, ino); + ext2fs_mark_inode_bitmap(inode_used_map, ino); goto next; } if (ino == EXT2_ROOT_INO) { @@ -209,7 +247,9 @@ void pass1(ext2_filsys fs) if (ask("Clear", 1)) { inode.i_dtime = time(0); inode.i_links_count = 0; - ext2fs_write_inode(fs, ino, &inode); + inode_link_info[ino] = 0; + e2fsck_write_inode(fs, ino, &inode, + "pass1"); } else ext2fs_unmark_valid(fs); } @@ -227,7 +267,8 @@ void pass1(ext2_filsys fs) "(probably due to old mke2fs). Fix", 1)) { inode.i_dtime = 0; - ext2fs_write_inode(fs, ino, &inode); + e2fsck_write_inode(fs, ino, &inode, + "pass1"); printf("Note: /lost+found will " "probably be deleted as well, " "due to the mke2fs bug.\n" @@ -239,7 +280,7 @@ void pass1(ext2_filsys fs) } } if ((ino != EXT2_ROOT_INO) && (ino < EXT2_FIRST_INO)) { - ext2fs_mark_inode_bitmap(fs, inode_used_map, ino); + ext2fs_mark_inode_bitmap(inode_used_map, ino); check_blocks(fs, ino, &inode, block_buf); goto next; } @@ -249,11 +290,12 @@ void pass1(ext2_filsys fs) */ if (!inode.i_links_count) { if (!inode.i_dtime && inode.i_mode) { - printf("Deleted inode %ld has zero dtime.\n", + printf("Deleted inode %lu has zero dtime.\n", ino); if (ask("Set dtime", 1)) { inode.i_dtime = time(0); - ext2fs_write_inode(fs, ino, &inode); + e2fsck_write_inode(fs, ino, &inode, + "pass1"); } else ext2fs_unmark_valid(fs); } @@ -275,26 +317,27 @@ void pass1(ext2_filsys fs) printf("This is probably due to old ext2fs kernel code. \n"); fix_link_count = ask("Fix inode(s)", 1); } - printf("Inode %ld is deleted w/ non-zero link_count. %s\n", + printf("Inode %lu is deleted w/ non-zero link_count. %s\n", ino, clear_msg[fix_link_count]); if (fix_link_count) { inode.i_links_count = 0; - ext2fs_write_inode(fs, ino, &inode); + inode_link_info[ino] = 0; + e2fsck_write_inode(fs, ino, &inode, "pass1"); } else ext2fs_unmark_valid(fs); goto next; } - ext2fs_mark_inode_bitmap(fs, inode_used_map, ino); + ext2fs_mark_inode_bitmap(inode_used_map, ino); if (inode.i_faddr || inode.i_frag || inode.i_fsize || inode.i_file_acl || inode.i_dir_acl) { if (!inode_bad_map) alloc_bad_map(fs); - ext2fs_mark_inode_bitmap(fs, inode_bad_map, ino); + ext2fs_mark_inode_bitmap(inode_bad_map, ino); } if (S_ISDIR(inode.i_mode)) { - ext2fs_mark_inode_bitmap(fs, inode_dir_map, ino); + ext2fs_mark_inode_bitmap(inode_dir_map, ino); add_dir_info(fs, ino, 0, &inode); fs_directory_count++; } else if (S_ISREG (inode.i_mode)) @@ -315,7 +358,7 @@ void pass1(ext2_filsys fs) else { if (!inode_bad_map) alloc_bad_map(fs); - ext2fs_mark_inode_bitmap(fs, inode_bad_map, ino); + ext2fs_mark_inode_bitmap(inode_bad_map, ino); } if (inode.i_block[EXT2_IND_BLOCK] || inode.i_block[EXT2_DIND_BLOCK] || @@ -323,9 +366,8 @@ void pass1(ext2_filsys fs) inodes_to_process[process_inode_count].ino = ino; inodes_to_process[process_inode_count].inode = inode; process_inode_count++; - } else + } else check_blocks(fs, ino, &inode, block_buf); - inode_link_info[ino] = inode.i_links_count; if (process_inode_count >= process_inode_size) process_inodes(fs, block_buf); @@ -344,6 +386,14 @@ void pass1(ext2_filsys fs) qsort(dir_blocks, dir_block_count, sizeof(struct dir_block_struct), dir_block_cmp); + if (invalid_bitmaps) + handle_fs_bad_blocks(fs); + + if (restart_e2fsck) { + unwind_pass1(fs); + goto endit; + } + if (block_dup_map) { if (preen) { printf("Duplicate or bad blocks in use!\n"); @@ -354,12 +404,8 @@ void pass1(ext2_filsys fs) fs->get_blocks = 0; fs->check_directory = 0; free(inodes_to_process); - if (bad_fs_block_map) { - handle_fs_bad_blocks(fs, block_buf); - free(bad_fs_block_map); - } +endit: free(block_buf); - if (tflag > 1) { printf("Pass 1: "); print_resource_track(&rtrack); @@ -367,6 +413,17 @@ void pass1(ext2_filsys fs) } /* + * When the inode_scan routines call this callback at the end of the + * glock group, call process_inodes. + */ +static errcode_t scan_callback(ext2_filsys fs, ext2_inode_scan scan, + dgrp_t group, void * private) +{ + process_inodes(fs, (char *) private); + return 0; +} + +/* * Process the inodes in the "inodes to process" list. */ static void process_inodes(ext2_filsys fs, char *block_buf) @@ -378,7 +435,7 @@ static void process_inodes(ext2_filsys fs, char *block_buf) char buf[80]; #if 0 - printf("process_inodes: "); + printf("begin process_inodes: "); #endif old_operation = ehandler_operation(0); old_stashed_inode = stashed_inode; @@ -389,9 +446,9 @@ static void process_inodes(ext2_filsys fs, char *block_buf) ino = inodes_to_process[i].ino; stashed_ino = ino; #if 0 - printf("%d ", ino); + printf("%lu ", ino); #endif - sprintf(buf, "reading indirect blocks of inode %ld", ino); + sprintf(buf, "reading indirect blocks of inode %lu", ino); ehandler_operation(buf); check_blocks(fs, ino, stashed_inode, block_buf); @@ -399,7 +456,7 @@ static void process_inodes(ext2_filsys fs, char *block_buf) stashed_inode = old_stashed_inode; process_inode_count = 0; #if 0 - printf("\n"); + printf("end process inodes\n"); #endif ehandler_operation(old_operation); } @@ -432,7 +489,8 @@ static void alloc_bad_map(ext2_filsys fs) { errcode_t retval; - retval = ext2fs_allocate_inode_bitmap(fs, &inode_bad_map); + retval = ext2fs_allocate_inode_bitmap(fs, "bad inode map", + &inode_bad_map); if (retval) { com_err("ext2fs_allocate_inode_bitmap", retval, "while allocating inode_bad_map"); @@ -448,19 +506,19 @@ static void mark_block_used(ext2_filsys fs, blk_t block) { errcode_t retval; - if (ext2fs_test_block_bitmap(fs, block_found_map, block)) { + if (ext2fs_test_block_bitmap(block_found_map, block)) { if (!block_dup_map) { retval = ext2fs_allocate_block_bitmap(fs, - &block_dup_map); + "multiply claimed block map", &block_dup_map); if (retval) { com_err("ext2fs_allocate_block_bitmap", retval, "while allocating block_dup_map"); fatal_error(0); } } - ext2fs_mark_block_bitmap(fs, block_dup_map, block); + ext2fs_mark_block_bitmap(block_dup_map, block); } else { - ext2fs_mark_block_bitmap(fs, block_found_map, block); + ext2fs_mark_block_bitmap(block_found_map, block); } } @@ -479,48 +537,77 @@ static void check_blocks(ext2_filsys fs, ino_t ino, struct ext2_inode *inode, pb.ino = ino; pb.num_blocks = pb.last_block = 0; + pb.num_illegal_blocks = 0; + pb.suppress = pb.clear = 0; pb.is_dir = S_ISDIR(inode->i_mode); pb.fix = -1; + pb.inode = inode; retval = ext2fs_block_iterate(fs, ino, 0, block_buf, process_block, &pb); if (retval) com_err(program_name, retval, "while calling ext2fs_block_iterate in check_blocks"); + if (pb.clear) { + e2fsck_read_inode(fs, ino, inode, "check_blocks"); + if (retval) { + com_err("check_blocks", retval, + "while reading to be cleared inode %d", ino); + fatal_error(0); + } + inode->i_links_count = 0; + inode_link_info[ino] = 0; + inode->i_dtime = time(0); + e2fsck_write_inode(fs, ino, inode, "check_blocks"); + ext2fs_unmark_inode_bitmap(inode_dir_map, ino); + ext2fs_unmark_inode_bitmap(inode_used_map, ino); + /* + * The inode was probably partially accounted for + * before processing was aborted, so we need to + * restart the pass 1 scan. + */ + restart_e2fsck++; + return; + } + + if (pb.fix > 0) + e2fsck_read_inode(fs, ino, inode, "check_blocks"); + pb.num_blocks *= (fs->blocksize / 512); #if 0 - printf("inode %d, i_size = %d, last_block = %d, i_blocks=%d, num_blocks = %d\n", + printf("inode %lu, i_size = %lu, last_block = %lu, i_blocks=%lu, num_blocks = %lu\n", ino, inode->i_size, pb.last_block, inode->i_blocks, pb.num_blocks); #endif if (!pb.num_blocks && pb.is_dir) { - printf("Inode %ld is a zero length directory. ", ino); + printf("Inode %lu is a zero length directory. ", ino); if (ask("Clear", 1)) { inode->i_links_count = 0; + inode_link_info[ino] = 0; inode->i_dtime = time(0); - ext2fs_write_inode(fs, ino, inode); - ext2fs_unmark_inode_bitmap(fs, inode_dir_map, ino); - ext2fs_unmark_inode_bitmap(fs, inode_used_map, ino); + e2fsck_write_inode(fs, ino, inode, "check_blocks"); + ext2fs_unmark_inode_bitmap(inode_dir_map, ino); + ext2fs_unmark_inode_bitmap(inode_used_map, ino); fs_directory_count--; } else ext2fs_unmark_valid(fs); } if (inode->i_size < pb.last_block * fs->blocksize) { - printf ("Inode %ld, incorrect size, %ld (counted = %d). ", + printf ("Inode %lu, incorrect size, %lu (counted = %u). ", ino, inode->i_size, (pb.last_block+1) * fs->blocksize); if (ask ("Set size to counted", 1)) { inode->i_size = (pb.last_block+1) * fs->blocksize; - ext2fs_write_inode(fs, ino, inode); + e2fsck_write_inode(fs, ino, inode, "check_blocks"); } else ext2fs_unmark_valid(fs); } if (pb.num_blocks != inode->i_blocks) { - printf ("Inode %ld, i_blocks wrong %ld (counted=%d) .", + printf ("Inode %lu, i_blocks wrong %lu (counted=%u). ", ino, inode->i_blocks, pb.num_blocks); if (ask ("Set i_blocks to counted", 1)) { inode->i_blocks = pb.num_blocks; - ext2fs_write_inode(fs, ino, inode); + e2fsck_write_inode(fs, ino, inode, "check_blocks"); } else ext2fs_unmark_valid(fs); } @@ -538,7 +625,7 @@ int process_block(ext2_filsys fs, int group; int illegal_block = 0; char problem[80]; - blk_t firstblock; + blk_t firstblock, group_super; blk_t blk = *block_nr; if (!blk) @@ -546,21 +633,27 @@ int process_block(ext2_filsys fs, p = (struct process_block_struct *) private; #if 0 - printf("Process_block, inode %d, block %d, #%d\n", p->ino, blk, + printf("Process_block, inode %lu, block %lu, #%d\n", p->ino, blk, blockcnt); #endif - p->num_blocks++; - if (blockcnt > 0) - p->last_block = blockcnt; - firstblock = fs->super->s_first_data_block; group = (blk - firstblock) / fs->super->s_blocks_per_group; + group_super = ((group * fs->super->s_blocks_per_group) + + fs->super->s_first_data_block); if (blk < firstblock) { - sprintf(problem, "< FIRSTBLOCK (%ld)", firstblock); + sprintf(problem, "< FIRSTBLOCK (%lu)", firstblock); illegal_block++; } else if (blk >= fs->super->s_blocks_count) { - sprintf(problem, "> BLOCKS (%ld)", fs->super->s_blocks_count); + sprintf(problem, "> BLOCKS (%lu)", fs->super->s_blocks_count); + illegal_block++; + } else if (blk == group_super) { + sprintf(problem, "is the superblock in group %d", group); + illegal_block++; + } else if (blk > group_super && + blk <= (group_super + fs->desc_blocks)) { + sprintf(problem, "is in the group descriptors in group %d", + group); illegal_block++; } else if (blk == fs->group_desc[group].bg_block_bitmap) { sprintf(problem, "is the block bitmap of group %d", group); @@ -575,16 +668,29 @@ int process_block(ext2_filsys fs, } if (illegal_block) { if (preen) { - printf("Block %ld of inode %ld %s\n", blk, p->ino, + printf("Block %lu of inode %lu %s\n", blk, p->ino, problem); preenhalt(); } if (p->fix == -1) { - printf("Remove illegal block(s) in inode %ld", p->ino); + printf("Remove illegal block(s) in inode %lu", p->ino); p->fix = ask("", 1); } - printf("Block #%d (%ld) %s. %s\n", blockcnt, blk, problem, - clear_msg[p->fix]); + p->num_illegal_blocks++; + if (!p->suppress && (p->num_illegal_blocks % 20) == 0) { + printf("Too many illegal blocks in inode %lu.\n", + p->ino); + if (ask("Clear inode", 1)) { + p->clear = 1; + return BLOCK_ABORT; + } + if (ask("Supress messages", 0)) { + p->suppress = 1; + } + } + if (!p->suppress) + printf("Block #%d (%lu) %s. %s\n", blockcnt, blk, + problem, clear_msg[p->fix]); if (p->fix) { *block_nr = 0; return BLOCK_CHANGED; @@ -594,6 +700,9 @@ int process_block(ext2_filsys fs, } } + p->num_blocks++; + if (blockcnt > 0) + p->last_block = blockcnt; mark_block_used(fs, blk); if (p->is_dir && (blockcnt >= 0)) { @@ -611,21 +720,36 @@ int process_block(ext2_filsys fs, } #if 0 - printf("process block, inode %d, block #%d is %d\n", + printf("process block, inode %lu, block #%d is %lu\n", p->ino, blockcnt, blk); #endif return 0; } +static void bad_block_indirect(blk_t blk) +{ + printf("Bad block %lu used as bad block indirect block?!?\n", blk); + preenhalt(); + printf("\nThis inconsistency can not be fixed with " + "e2fsck; to fix it, use\n" + """dumpe2fs -b"" to dump out the bad block " + "list and ""e2fsck -L filename""\n" + "to read it back in again.\n"); + if (ask("Continue", 0)) + return; + fatal_error(0); +} + int process_bad_block(ext2_filsys fs, blk_t *block_nr, int blockcnt, void *private) { struct process_block_struct *p; - errcode_t retval; blk_t blk = *block_nr; + int first_block; + int i; if (!blk) return 0; @@ -634,12 +758,12 @@ int process_bad_block(ext2_filsys fs, if ((blk < fs->super->s_first_data_block) || (blk >= fs->super->s_blocks_count)) { if (preen) { - printf("Illegal block %ld in bad block inode\n", blk); + printf("Illegal block %lu in bad block inode\n", blk); preenhalt(); } if (p->fix == -1) p->fix = ask("Remove illegal block(s) in bad block inode", 1); - printf("Illegal block %ld in bad block inode. %s\n", blk, + printf("Illegal block %lu in bad block inode. %s\n", blk, clear_msg[p->fix]); if (p->fix) { *block_nr = 0; @@ -651,11 +775,14 @@ int process_bad_block(ext2_filsys fs, } if (blockcnt < 0) { - mark_block_used(fs, blk); + if (ext2fs_test_block_bitmap(block_found_map, blk)) + bad_block_indirect(blk); + else + mark_block_used(fs, blk); return 0; } #if 0 - printf ("DEBUG: Marking %d as bad.\n", blk); + printf ("DEBUG: Marking %lu as bad.\n", blk); #endif fs_badblocks_count++; /* @@ -664,40 +791,93 @@ int process_bad_block(ext2_filsys fs, * there's an overlap between the filesystem table blocks * (bitmaps and inode table) and the bad block list. */ - if (!ext2fs_test_block_bitmap(fs, block_found_map, blk)) { - ext2fs_mark_block_bitmap(fs, block_found_map, blk); + if (!ext2fs_test_block_bitmap(block_found_map, blk)) { + ext2fs_mark_block_bitmap(block_found_map, blk); return 0; } - if (!bad_fs_block_map) { - retval = ext2fs_allocate_inode_bitmap(fs, &bad_fs_block_map); - if (retval) { - com_err("ext2fs_allocate_block_bitmap", retval, - "while allocating bad_fs_block_map"); - fatal_error(0); + /* + * Try to find the where the filesystem block was used... + */ + first_block = fs->super->s_first_data_block; + + for (i = 0; i < fs->group_desc_count; i++ ) { + if (blk == first_block) { + if (i == 0) { + printf("The primary superblock (%lu) is " + "bad. Aiiieeee....\n", blk); + fatal_error(0); + } + if (!preen) + printf("Warning: Group %d's superblock " + "(%lu) is bad.\n", i, blk); + return 0; + } + if ((blk > first_block) && + (blk <= first_block + fs->desc_blocks)) { + if (i == 0) { + printf("Bad block %lu is in the primary " + "group descriptors. Aiiieeee....\n", + blk); + fatal_error(0); + } + if (!preen) + printf("Warning: Group %d's copy of the " + "group descriptors has a bad " + "block (%lu).\n", i, blk); + return 0; } + if (blk == fs->group_desc[i].bg_block_bitmap) { + printf("Group %d's block bitmap (%lu) is bad. ", + i, blk); + if (ask("Relocate", 1)) { + invalid_block_bitmap[i]++; + invalid_bitmaps++; + } else + ext2fs_unmark_valid(fs); + return 0; + } + if (blk == fs->group_desc[i].bg_inode_bitmap) { + printf("Group %d's inode bitmap (%lu) is bad. ", + i, blk); + if (ask("Relocate", 1)) { + invalid_inode_bitmap[i]++; + invalid_bitmaps++; + } else + ext2fs_unmark_valid(fs); + return 0; + } + if ((blk >= fs->group_desc[i].bg_inode_table) && + (blk < (fs->group_desc[i].bg_inode_table + + fs->inode_blocks_per_group))) { + printf("WARNING: Severe data loss possible!!!!\n"); + printf("Bad block %lu in group %d's inode table. ", + blk, i); + if (ask("Relocate", 1)) { + invalid_inode_table[i]++; + invalid_bitmaps++; + } else + ext2fs_unmark_valid(fs); + return 0; + } + first_block += fs->super->s_blocks_per_group; + } + /* + * If we've gotten to this point, then the only + * possibility is that the bad block inode meta data + * is using a bad block. + */ + if ((blk == p->inode->i_block[EXT2_IND_BLOCK]) || + p->inode->i_block[EXT2_DIND_BLOCK]) { + bad_block_indirect(blk); + return 0; } - ext2fs_mark_block_bitmap(fs, bad_fs_block_map, blk); - return 0; -} - -/* - * This routine gets called at the end of pass 1 if bad blocks are - * detected in the superblock, group descriptors, inode_bitmaps, or - * block bitmaps. At this point, all of the blocks have been mapped - * out, so we can try to allocate new block(s) to replace the bad - * blocks. - */ -static void handle_fs_bad_blocks(ext2_filsys fs, char *block_buf) -{ - errcode_t retval; - - printf("Warning: Bad block(s) found in filesystem-reserved blocks.\n"); - retval = ext2fs_block_iterate(fs, EXT2_BAD_INO, 0, block_buf, - process_fs_bad_block, 0); + printf("Programming error? block #%lu claimed for no reason " + "in process_bad_block.\n", blk); + return 0; } -static void new_table_block(ext2_filsys fs, blk_t first_block, +static void new_table_block(ext2_filsys fs, blk_t first_block, int group, const char *name, int num, blk_t *new_block) { errcode_t retval; @@ -722,99 +902,62 @@ static void new_table_block(ext2_filsys fs, blk_t first_block, return; } ext2fs_mark_super_dirty(fs); + printf("Relocating group %d's %s ", group, name); + if (old_block) + printf("from %lu ", old_block); + printf("to %lu...\n", *new_block); for (i = 0; i < num; i++) { - ext2fs_mark_block_bitmap(fs, block_found_map, (*new_block)+i); - retval = io_channel_read_blk(fs->io, old_block + i, - 1, buf); - if (retval) - printf("Warning: could not read block %ld of %s: %s\n", - old_block + i, name, error_message(retval)); + ext2fs_mark_block_bitmap(block_found_map, (*new_block)+i); + if (old_block) { + retval = io_channel_read_blk(fs->io, old_block + i, + 1, buf); + if (retval) + printf("Warning: could not read block %lu " + "of %s: %s\n", + old_block + i, name, + error_message(retval)); + } else + memset(buf, 0, fs->blocksize); + retval = io_channel_write_blk(fs->io, (*new_block) + i, 1, buf); if (retval) - printf("Warning: could not write block %ld for %s: %s\n", + printf("Warning: could not write block %lu for %s: %s\n", (*new_block) + i, name, error_message(retval)); - /* - * If this particular block is not marked as bad, then - * clear its bit in the block_found map. Otherwise, - * leave it set, since it is included in the bad - * blocks inode. - */ - if (!ext2fs_test_block_bitmap(fs, bad_fs_block_map, - old_block + i)) - ext2fs_unmark_block_bitmap(fs, block_found_map, - old_block + i); - /* - * Clear the bitmap since this block has now been moved. - */ - ext2fs_unmark_block_bitmap(fs, bad_fs_block_map, - old_block + i); } free(buf); } /* - * Helper function for handle_fs_bad_blocks() + * This routine gets called at the end of pass 1 if bad blocks are + * detected in the superblock, group descriptors, inode_bitmaps, or + * block bitmaps. At this point, all of the blocks have been mapped + * out, so we can try to allocate new block(s) to replace the bad + * blocks. */ -static int process_fs_bad_block(ext2_filsys fs, blk_t *block_nr, - int blockcnt, void *private) +static void handle_fs_bad_blocks(ext2_filsys fs) { - int i; - blk_t block = *block_nr; - int first_block = fs->super->s_first_data_block; - - /* - * If this block isn't one that is marked as a bad block in - * the filesystem tables, return - */ - if (!ext2fs_test_block_bitmap(fs, bad_fs_block_map, block)) - return 0; + int i; + int first_block = fs->super->s_first_data_block; for (i = 0; i < fs->group_desc_count; i++) { - if (block == first_block) - printf("Bad block %ld in group %d's superblock.\n", - block, i); - if (block == fs->group_desc[i].bg_block_bitmap) { - printf("Bad block %ld in group %d's block bitmap. ", - block, i); - if (ask("Relocate", 1)) { - new_table_block(fs, first_block, - "block bitmap", 1, + if (invalid_block_bitmap[i]) { + new_table_block(fs, first_block, i, "block bitmap", 1, &fs->group_desc[i].bg_block_bitmap); - } else - ext2fs_unmark_valid(fs); } - if (block == fs->group_desc[i].bg_inode_bitmap) { - printf("Bad block %ld in group %d's inode bitmap. ", - block, i); - if (ask("Relocate", 1)) { - new_table_block(fs, first_block, - "inode bitmap", 1, + if (invalid_inode_bitmap[i]) { + new_table_block(fs, first_block, i, "inode bitmap", 1, &fs->group_desc[i].bg_inode_bitmap); - } else - ext2fs_unmark_valid(fs); } - if ((block >= fs->group_desc[i].bg_inode_table) && - (block < (fs->group_desc[i].bg_inode_table + - fs->inode_blocks_per_group))) { - printf("WARNING: Severe data loss possible!!!!\n"); - printf("Bad block %ld in group %d's inode table. ", - block, i); - if (ask("Relocate", 1)) { - new_table_block(fs, first_block, - "inode table", - fs->inode_blocks_per_group, + if (invalid_inode_table[i]) { + new_table_block(fs, first_block, i, "inode table", + fs->inode_blocks_per_group, &fs->group_desc[i].bg_inode_table); - } else - ext2fs_unmark_valid(fs); + restart_e2fsck++; } - if ((block > first_block) && - (block <= first_block + fs->desc_blocks)) - printf("Bad block %ld in group %d's copy of the descriptors.\n", - block, i); first_block += fs->super->s_blocks_per_group; } - return 0; + invalid_bitmaps = 0; } /* @@ -823,7 +966,7 @@ static int process_fs_bad_block(ext2_filsys fs, blk_t *block_nr, */ static void mark_table_blocks(ext2_filsys fs) { - blk_t block; + blk_t block, b; int i,j; block = fs->super->s_first_data_block; @@ -831,29 +974,80 @@ static void mark_table_blocks(ext2_filsys fs) /* * Mark block used for the block bitmap */ - ext2fs_mark_block_bitmap(fs, block_found_map, - fs->group_desc[i].bg_block_bitmap); + if (fs->group_desc[i].bg_block_bitmap) { + if (ext2fs_test_block_bitmap(block_found_map, + fs->group_desc[i].bg_block_bitmap)) { + printf("Group %i's block bitmap at %lu " + "conflicts with some other fs block.\n", + i, fs->group_desc[i].bg_block_bitmap); + preenhalt(); + if (ask("Relocate", 1)) { + invalid_block_bitmap[i]++; + invalid_bitmaps++; + } else { + ext2fs_unmark_valid(fs); + } + } else + ext2fs_mark_block_bitmap(block_found_map, + fs->group_desc[i].bg_block_bitmap); + } /* * Mark block used for the inode bitmap */ - ext2fs_mark_block_bitmap(fs, block_found_map, - fs->group_desc[i].bg_inode_bitmap); + if (fs->group_desc[i].bg_inode_bitmap) { + if (ext2fs_test_block_bitmap(block_found_map, + fs->group_desc[i].bg_inode_bitmap)) { + printf("Group %i's inode bitmap at %lu " + "conflicts with some other fs block.\n", + i, fs->group_desc[i].bg_inode_bitmap); + preenhalt(); + if (ask("Relocate", 1)) { + invalid_inode_bitmap[i]++; + invalid_bitmaps++; + } else { + ext2fs_unmark_valid(fs); + } + } else + ext2fs_mark_block_bitmap(block_found_map, + fs->group_desc[i].bg_inode_bitmap); + } + /* * Mark the blocks used for the inode table */ - for (j = 0; j < fs->inode_blocks_per_group; j++) - ext2fs_mark_block_bitmap(fs, block_found_map, - fs->group_desc[i].bg_inode_table + j); + if (fs->group_desc[i].bg_inode_table) { + for (j = 0, b = fs->group_desc[i].bg_inode_table; + j < fs->inode_blocks_per_group; + j++, b++) { + if (ext2fs_test_block_bitmap(block_found_map, + b)) { + printf("Group %i's inode table at %lu " + "conflicts with some other " + "fs block.\n", + i, b); + preenhalt(); + if (ask("Relocate", 1)) { + invalid_inode_table[i]++; + invalid_bitmaps++; + } else { + ext2fs_unmark_valid(fs); + } + } else + ext2fs_mark_block_bitmap(block_found_map, + b); + } + } + /* * Mark this group's copy of the superblock */ - ext2fs_mark_block_bitmap(fs, block_found_map, block); + ext2fs_mark_block_bitmap(block_found_map, block); /* * Mark this group's copy of the descriptors */ for (j = 0; j < fs->desc_blocks; j++) - ext2fs_mark_block_bitmap(fs, block_found_map, + ext2fs_mark_block_bitmap(block_found_map, block + j + 1); block += fs->super->s_blocks_per_group; } @@ -874,9 +1068,9 @@ static errcode_t pass1_get_blocks(ext2_filsys fs, ino_t ino, blk_t *blocks) blocks[i] = stashed_inode->i_block[i]; return 0; } - printf("INTERNAL ERROR: pass1_get_blocks: unexpected inode #%ld\n", + printf("INTERNAL ERROR: pass1_get_blocks: unexpected inode #%lu\n", ino); - printf("\t(was expecting %ld)\n", stashed_ino); + printf("\t(was expecting %lu)\n", stashed_ino); exit(FSCK_ERROR); } @@ -887,8 +1081,8 @@ static errcode_t pass1_check_directory(ext2_filsys fs, ino_t ino) return ENOTDIR; return 0; } - printf("INTERNAL ERROR: pass1_check_directory: unexpected inode #%ld\n", + printf("INTERNAL ERROR: pass1_check_directory: unexpected inode #%lu\n", ino); - printf("\t(was expecting %ld)\n", stashed_ino); + printf("\t(was expecting %lu)\n", stashed_ino); exit(FSCK_ERROR); } diff --git a/e2fsck/pass1b.c b/e2fsck/pass1b.c index dd657bfa..c98030fb 100644 --- a/e2fsck/pass1b.c +++ b/e2fsck/pass1b.c @@ -101,7 +101,7 @@ static int dup_inode_count = 0; extern ino_t stashed_ino; extern struct ext2_inode *stashed_inode; -static char *inode_dup_map; +static ext2fs_inode_bitmap inode_dup_map; /* * Main procedure for handling duplicate blocks @@ -112,7 +112,8 @@ void pass1_dupblocks(ext2_filsys fs, char *block_buf) struct dup_block *p, *q, *next_p, *next_q; struct dup_inode *r, *next_r; - retval = ext2fs_allocate_inode_bitmap(fs, &inode_dup_map); + retval = ext2fs_allocate_inode_bitmap(fs, + "multiply claimed inode map", &inode_dup_map); if (retval) { com_err("ext2fs_allocate_inode_bitmap", retval, "while allocating inode_dup_map"); @@ -127,8 +128,8 @@ void pass1_dupblocks(ext2_filsys fs, char *block_buf) * Time to free all of the accumulated data structures that we * don't need anymore. */ - free(inode_dup_map); inode_dup_map = 0; - free(block_dup_map); block_dup_map = 0; + ext2fs_free_inode_bitmap(inode_dup_map); inode_dup_map = 0; + ext2fs_free_block_bitmap(block_dup_map); block_dup_map = 0; for (p = dup_blk; p; p = next_p) { next_p = p->next_block; for (q = p; q; q = next_q) { @@ -177,7 +178,7 @@ void pass1b(ext2_filsys fs, char *block_buf) while (ino) { stashed_ino = ino; if ((ino != EXT2_BAD_INO) && - (!ext2fs_test_inode_bitmap(fs, inode_used_map, ino) || + (!ext2fs_test_inode_bitmap(inode_used_map, ino) || !inode_has_valid_blocks(&inode))) goto next; @@ -230,17 +231,17 @@ int process_pass1b_block(ext2_filsys fs, return 0; p = (struct process_block_struct *) private; - if (ext2fs_test_block_bitmap(fs, block_dup_map, *block_nr)) { + if (ext2fs_test_block_bitmap(block_dup_map, *block_nr)) { /* OK, this is a duplicate block */ if (p->ino != EXT2_BAD_INO) { if (!p->dup_blocks) - printf("Duplicate/bad block(s) in inode %ld:", + printf("Duplicate/bad block(s) in inode %lu:", p->ino); - printf(" %ld", *block_nr); + printf(" %lu", *block_nr); } p->dup_blocks++; - ext2fs_mark_block_bitmap(fs, block_dup_map, *block_nr); - ext2fs_mark_inode_bitmap(fs, inode_dup_map, p->ino); + ext2fs_mark_block_bitmap(block_dup_map, *block_nr); + ext2fs_mark_inode_bitmap(inode_dup_map, p->ino); dp = allocate_memory(sizeof(struct dup_block), "duplicate block record"); dp->block = *block_nr; @@ -340,7 +341,7 @@ void pass1c(ext2_filsys fs, char *block_buf) ((dir_blocks[i].blockcnt == 0) && (entry <= 2))) goto next; - if (!ext2fs_test_inode_bitmap(fs, inode_dup_map, + if (!ext2fs_test_inode_bitmap(inode_dup_map, dirent->inode)) goto next; @@ -369,7 +370,7 @@ void pass1c(ext2_filsys fs, char *block_buf) */ for (p = dup_ino; p; p = p->next) { if (!p->pathname) { - sprintf(buf, "<Unknown inode #%ld>", p->ino); + sprintf(buf, "<Unknown inode #%lu>", p->ino); p->pathname = malloc(strlen(buf)+1); if (!p->pathname) { fprintf(stderr, "pass1c: couldn't malloc " @@ -440,7 +441,7 @@ static void pass1d(ext2_filsys fs, char *block_buf) } time_str = ctime(&p->mtime); time_str[24] = 0; - printf("File %s (inode #%ld, mod time %s) \n", + printf("File %s (inode #%lu, mod time %s) \n", p->pathname, p->ino, time_str); printf(" has %d duplicate blocks, shared with %d file%s:\n", p->num_dupblocks, shared_len, @@ -453,7 +454,7 @@ static void pass1d(ext2_filsys fs, char *block_buf) continue; time_str = ctime(&s->mtime); time_str[24] = 0; - printf("\t%s (inode #%ld, mod time %s)\n", + printf("\t%s (inode #%lu, mod time %s)\n", s->pathname, s->ino, time_str); } if (file_ok) { @@ -489,22 +490,22 @@ static int delete_file_block(ext2_filsys fs, if (!*block_nr) return 0; - if (ext2fs_test_block_bitmap(fs, block_dup_map, *block_nr)) { + if (ext2fs_test_block_bitmap(block_dup_map, *block_nr)) { for (p = dup_blk; p; p = p->next_block) if (p->block == *block_nr) break; if (p) { p->num_bad--; if (p->num_bad == 1) - ext2fs_unmark_block_bitmap(fs, block_dup_map, + ext2fs_unmark_block_bitmap(block_dup_map, *block_nr); } else com_err("delete_file_block", 0, "internal error; can't find dup_blk for %d\n", *block_nr); } else { - ext2fs_unmark_block_bitmap(fs, block_found_map, *block_nr); - ext2fs_unmark_block_bitmap(fs, fs->block_map, *block_nr); + ext2fs_unmark_block_bitmap(block_found_map, *block_nr); + ext2fs_unmark_block_bitmap(fs->block_map, *block_nr); } return 0; @@ -525,27 +526,17 @@ static void delete_file(ext2_filsys fs, struct dup_inode *dp, char* block_buf) com_err("delete_file", retval, "while calling ext2fs_block_iterate for inode %d", dp->ino); - ext2fs_unmark_inode_bitmap(fs, inode_used_map, dp->ino); - ext2fs_unmark_inode_bitmap(fs, inode_dir_map, dp->ino); + ext2fs_unmark_inode_bitmap(inode_used_map, dp->ino); + ext2fs_unmark_inode_bitmap(inode_dir_map, dp->ino); if (inode_bad_map) - ext2fs_unmark_inode_bitmap(fs, inode_bad_map, dp->ino); - ext2fs_unmark_inode_bitmap(fs, fs->inode_map, dp->ino); + ext2fs_unmark_inode_bitmap(inode_bad_map, dp->ino); + ext2fs_unmark_inode_bitmap(fs->inode_map, dp->ino); ext2fs_mark_ib_dirty(fs); ext2fs_mark_bb_dirty(fs); - retval = ext2fs_read_inode(fs, dp->ino, &inode); - if (retval) { - com_err("delete_file", retval, "while reading inode %d", - dp->ino); - return; - } + e2fsck_read_inode(fs, dp->ino, &inode, "delete_file"); inode.i_links_count = 0; inode.i_dtime = time(0); - retval = ext2fs_write_inode(fs, dp->ino, &inode); - if (retval) { - com_err("delete_file", retval, "while writing inode %d", - dp->ino); - return; - } + e2fsck_write_inode(fs, dp->ino, &inode, "delete_file"); } struct clone_struct { @@ -566,7 +557,7 @@ static int clone_file_block(ext2_filsys fs, if (!*block_nr) return 0; - if (ext2fs_test_block_bitmap(fs, block_dup_map, *block_nr)) { + if (ext2fs_test_block_bitmap(block_dup_map, *block_nr)) { for (p = dup_blk; p; p = p->next_block) if (p->block == *block_nr) break; @@ -591,12 +582,12 @@ static int clone_file_block(ext2_filsys fs, } p->num_bad--; if (p->num_bad == 1) - ext2fs_unmark_block_bitmap(fs, block_dup_map, + ext2fs_unmark_block_bitmap(block_dup_map, *block_nr); *block_nr = new_block; - ext2fs_mark_block_bitmap(fs, block_found_map, + ext2fs_mark_block_bitmap(block_found_map, new_block); - ext2fs_mark_block_bitmap(fs, fs->block_map, new_block); + ext2fs_mark_block_bitmap(fs->block_map, new_block); return BLOCK_CHANGED; } else com_err("clone_file_block", 0, diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c index 327cf16d..3331cb97 100644 --- a/e2fsck/pass2.c +++ b/e2fsck/pass2.c @@ -79,7 +79,7 @@ void pass2(ext2_filsys fs) free(buf); free(dir_blocks); if (inode_bad_map) { - free(inode_bad_map); + ext2fs_free_inode_bitmap(inode_bad_map); inode_bad_map = 0; } if (tflag > 1) { @@ -103,7 +103,7 @@ static int check_dot(ext2_filsys fs, char name[BLOCK_SIZE]; if (!dirent->inode) { - printf("Missing '.' in directory inode %ld.\n", ino); + printf("Missing '.' in directory inode %lu.\n", ino); if (dirent->rec_len < 12) fatal_error("Cannot fix, insufficient space to add '.'"); preenhalt(); @@ -122,13 +122,13 @@ static int check_dot(ext2_filsys fs, strncmp(dirent->name, ".", dirent->name_len)) { strncpy(name, dirent->name, dirent->name_len); name[dirent->name_len] = '\0'; - printf("Missing '.' in directory inode %ld.\n", ino); + printf("Missing '.' in directory inode %lu.\n", ino); printf("Cannot fix, first entry in directory contains '%s'\n", name); exit(FSCK_ERROR); } if (dirent->inode != ino) { - printf("Bad inode number for '.' in directory inode %ld.\n", + printf("Bad inode number for '.' in directory inode %lu.\n", ino); preenhalt(); if (ask("Fix", 1)) { @@ -166,10 +166,10 @@ static int check_dotdot(ext2_filsys fs, struct dir_info *dir) { char name[BLOCK_SIZE]; - int ino = dir->ino; + ino_t ino = dir->ino; if (!dirent->inode) { - printf("Missing '..' in directory inode %d.\n", ino); + printf("Missing '..' in directory inode %lu.\n", ino); if (dirent->rec_len < 12) fatal_error("Cannot fix, insufficient space to add '..'"); preenhalt(); @@ -192,7 +192,7 @@ static int check_dotdot(ext2_filsys fs, strncmp(dirent->name, "..", dirent->name_len)) { strncpy(name, dirent->name, dirent->name_len); name[dirent->name_len] = '\0'; - printf("Missing '..' in directory inode %d.\n", ino); + printf("Missing '..' in directory inode %lu.\n", ino); printf("Cannot fix, first entry in directory contains %s\n", name); exit(FSCK_ERROR); @@ -201,6 +201,8 @@ static int check_dotdot(ext2_filsys fs, return 0; } +static char unknown_pathname[] = "???"; + /* * Check to make sure a directory entry doesn't contain any illegal * characters. @@ -223,12 +225,13 @@ static int check_name(ext2_filsys fs, 0, &pathname); if (retval) { com_err(program_name, retval, "while getting pathname in check_name"); - fatal_error(0); + pathname = unknown_pathname; } printf ("Bad file name '%s' (contains '/' or " - " null) in directory '%s'", - pathname, name); - free(pathname); + " null) in directory '%s' (%lu)\n", + name, pathname, dir_ino); + if (pathname != unknown_pathname) + free(pathname); preenhalt(); fixup = ask("Replace '/' or null by '.'", 1); } @@ -256,13 +259,12 @@ static int check_dir_block(ext2_filsys fs, int dot_state; blk_t block_nr = db->blk; ino_t ino = db->ino; - static char unknown[] = "???"; /* * Make sure the inode is still in use (could have been * deleted in the duplicate/bad blocks pass. */ - if (!(ext2fs_test_inode_bitmap(fs, inode_used_map, ino))) + if (!(ext2fs_test_inode_bitmap(inode_used_map, ino))) return 0; if (db->blockcnt) @@ -271,7 +273,7 @@ static int check_dir_block(ext2_filsys fs, dot_state = 0; #if 0 - printf("In process_dir_block block %d, #%d, inode %d\n", block_nr, + printf("In process_dir_block block %lu, #%d, inode %lu\n", block_nr, db->blockcnt, ino); #endif @@ -287,7 +289,7 @@ static int check_dir_block(ext2_filsys fs, if (((offset + dirent->rec_len) > fs->blocksize) || (dirent->rec_len < 8) || ((dirent->name_len+8) > dirent->rec_len)) { - printf("Directory inode %ld, block %d, offset %d: directory corrupted\n", + printf("Directory inode %lu, block %d, offset %d: directory corrupted\n", ino, db->blockcnt, offset); preenhalt(); if (ask("Salvage", 1)) { @@ -308,7 +310,7 @@ static int check_dir_block(ext2_filsys fs, } else if (dot_state == 2) { dir = get_dir_info(ino); if (!dir) { - printf("Internal error: couldn't find dir_info for %ld\n", + printf("Internal error: couldn't find dir_info for %lu\n", ino); fatal_error(0); } @@ -317,10 +319,10 @@ static int check_dir_block(ext2_filsys fs, } else if (dirent->inode == ino) { retval = ext2fs_get_pathname(fs, ino, 0, &path1); if (retval) - path1 = unknown; - printf("Entry '%s' in %s (%ld) is a link to '.' ", + path1 = unknown_pathname; + printf("Entry '%s' in %s (%lu) is a link to '.' ", name, path1, ino); - if (path1 != unknown) + if (path1 != unknown_pathname) free(path1); preenhalt(); if (ask("Clear", 1)) { @@ -332,7 +334,7 @@ static int check_dir_block(ext2_filsys fs, goto next; #if 0 - printf("Entry '%s', name_len %d, rec_len %d, inode %d... ", + printf("Entry '%s', name_len %d, rec_len %d, inode %lu... ", name, dirent->name_len, dirent->rec_len, dirent->inode); #endif if (check_name(fs, dirent, ino, name)) @@ -346,10 +348,10 @@ static int check_dir_block(ext2_filsys fs, (dirent->inode > fs->super->s_inodes_count)) { retval = ext2fs_get_pathname(fs, ino, 0, &path1); if (retval) - path1 = unknown; - printf("Entry '%s' in %s (%ld) has bad inode #: %ld.\n", + path1 = unknown_pathname; + printf("Entry '%s' in %s (%lu) has bad inode #: %lu.\n", name, path1, ino, dirent->inode); - if (path1 != unknown) + if (path1 != unknown_pathname) free(path1); preenhalt(); if (ask("Clear", 1)) { @@ -363,14 +365,14 @@ static int check_dir_block(ext2_filsys fs, /* * If the inode is unusued, offer to clear it. */ - if (!(ext2fs_test_inode_bitmap(fs, inode_used_map, + if (!(ext2fs_test_inode_bitmap(inode_used_map, dirent->inode))) { retval = ext2fs_get_pathname(fs, ino, 0, &path1); if (retval) - path1 = unknown; - printf("Entry '%s' in %s (%ld) has deleted/unused inode %ld.\n", + path1 = unknown_pathname; + printf("Entry '%s' in %s (%lu) has deleted/unused inode %lu.\n", name, path1, ino, dirent->inode); - if (path1 != unknown) + if (path1 != unknown_pathname) free(path1); if (ask("Clear", 1)) { dirent->inode = 0; @@ -387,7 +389,7 @@ static int check_dir_block(ext2_filsys fs, * pathname to the user.) */ if (inode_bad_map && - ext2fs_test_inode_bitmap(fs, inode_bad_map, + ext2fs_test_inode_bitmap(inode_bad_map, dirent->inode)) { if (process_bad_inode(fs, ino, dirent->inode)) { dirent->inode = 0; @@ -404,11 +406,11 @@ static int check_dir_block(ext2_filsys fs, * and ask the user if he/she wants to clear this one. */ if ((dot_state > 2) && - (ext2fs_test_inode_bitmap(fs, inode_dir_map, + (ext2fs_test_inode_bitmap(inode_dir_map, dirent->inode))) { subdir = get_dir_info(dirent->inode); if (!subdir) { - printf("INTERNAL ERROR: missing dir %ld\n", + printf("INTERNAL ERROR: missing dir %lu\n", dirent->inode); fatal_error(0); } @@ -416,19 +418,19 @@ static int check_dir_block(ext2_filsys fs, retval = ext2fs_get_pathname(fs, ino, 0, &path1); if (retval) - path1 = unknown; + path1 = unknown_pathname; retval = ext2fs_get_pathname(fs, subdir->parent, dirent->inode, &path2); if (retval) - path2 = unknown; - printf("Entry '%s' in %s (%ld) is a link to directory %s (%ld).\n", + path2 = unknown_pathname; + printf("Entry '%s' in %s (%lu) is a link to directory %s (%lu).\n", name, path1, ino, path2, dirent->inode); - if (path1 != unknown) + if (path1 != unknown_pathname) free(path1); - if (path2 != unknown) + if (path2 != unknown_pathname) free(path2); if (ask("Clear", 1)) { dirent->inode = 0; @@ -477,8 +479,8 @@ static int deallocate_inode_block(ext2_filsys fs, { if (!*block_nr) return 0; - ext2fs_unmark_block_bitmap(fs, block_found_map, *block_nr); - ext2fs_unmark_block_bitmap(fs, fs->block_map, *block_nr); + ext2fs_unmark_block_bitmap(block_found_map, *block_nr); + ext2fs_unmark_block_bitmap(fs->block_map, *block_nr); return 0; } @@ -491,29 +493,20 @@ static void deallocate_inode(ext2_filsys fs, ino_t ino, errcode_t retval; struct ext2_inode inode; - retval = ext2fs_read_inode(fs, ino, &inode); - if (retval) { - com_err("deallocate_inode", retval, "while reading inode %d", - ino); - return; - } + e2fsck_read_inode(fs, ino, &inode, "deallocate_inode"); inode.i_links_count = 0; inode.i_dtime = time(0); - retval = ext2fs_write_inode(fs, ino, &inode); - if (retval) { - com_err("deallocate_inode", retval, "while writing inode %d", - ino); - return; - } + e2fsck_write_inode(fs, ino, &inode, "deallocate_inode"); + /* * Fix up the bitmaps... */ read_bitmaps(fs); - ext2fs_unmark_inode_bitmap(fs, inode_used_map, ino); - ext2fs_unmark_inode_bitmap(fs, inode_dir_map, ino); + ext2fs_unmark_inode_bitmap(inode_used_map, ino); + ext2fs_unmark_inode_bitmap(inode_dir_map, ino); if (inode_bad_map) - ext2fs_unmark_inode_bitmap(fs, inode_bad_map, ino); - ext2fs_unmark_inode_bitmap(fs, fs->inode_map, ino); + ext2fs_unmark_inode_bitmap(inode_bad_map, ino); + ext2fs_unmark_inode_bitmap(fs->inode_map, ino); ext2fs_mark_ib_dirty(fs); if (!inode_has_valid_blocks(&inode)) @@ -540,7 +533,7 @@ static void check_for_zero_long(ext2_filsys fs, ino_t ino, char *pathname, char prompt[80]; if (*val) { - printf("%s for inode %ld (%s) is %ld, should be zero.\n", + printf("%s for inode %lu (%s) is %lu, should be zero.\n", name, ino, pathname, *val); preenhalt(); sprintf(prompt, "Clear %s", name); @@ -559,7 +552,7 @@ static void check_for_zero_char(ext2_filsys fs, ino_t ino, char *pathname, char prompt[80]; if (*val) { - printf("%s for inode %ld (%s) is %d, should be zero.\n", + printf("%s for inode %lu (%s) is %d, should be zero.\n", name, ino, pathname, *val); preenhalt(); sprintf(prompt, "Clear %s", name); @@ -580,12 +573,7 @@ static int process_bad_inode(ext2_filsys fs, ino_t dir, ino_t ino) int inode_modified = 0; char *pathname; - retval = ext2fs_read_inode(fs, ino, &inode); - if (retval) { - com_err("process_bad_inode", retval, "while reading inode %d", - ino); - return 0; - } + e2fsck_read_inode(fs, ino, &inode, "process_bad_inode"); retval = ext2fs_get_pathname(fs, dir, ino, &pathname); if (retval) { com_err("process_bad_inode", retval, @@ -597,7 +585,7 @@ static int process_bad_inode(ext2_filsys fs, ino_t dir, ino_t ino) !S_ISCHR(inode.i_mode) && !S_ISBLK(inode.i_mode) && !S_ISLNK(inode.i_mode) && !S_ISFIFO(inode.i_mode) && !(S_ISSOCK(inode.i_mode))) { - printf("Inode %ld (%s) has a bad mode (0%o).\n", + printf("Inode %lu (%s) has a bad mode (0%o).\n", ino, pathname, inode.i_mode); preenhalt(); if (ask("Clear", 1)) { @@ -617,15 +605,8 @@ static int process_bad_inode(ext2_filsys fs, ino_t dir, ino_t ino) check_for_zero_long(fs, ino, pathname, "i_dir_acl", &inode.i_dir_acl, &inode_modified); free(pathname); - if (inode_modified) { - retval = ext2fs_write_inode(fs, ino, &inode); - if (retval) { - com_err("process_bad_inode", retval, - "while writing inode %d", - ino); - return 0; - } - } + if (inode_modified) + e2fsck_write_inode(fs, ino, &inode, "process_bad_inode"); return 0; } diff --git a/e2fsck/pass3.c b/e2fsck/pass3.c index b34acd2a..7e3ad97e 100644 --- a/e2fsck/pass3.c +++ b/e2fsck/pass3.c @@ -38,14 +38,14 @@ static void check_root(ext2_filsys fs, ino_t root_ino); static void check_directory(ext2_filsys fs, ino_t dir); static ino_t get_lost_and_found(ext2_filsys fs); static void fix_dotdot(ext2_filsys fs, struct dir_info *dir, ino_t parent); -static int adjust_inode_count(ext2_filsys fs, ino_t ino, int adj); +static errcode_t adjust_inode_count(ext2_filsys fs, ino_t ino, int adj); static errcode_t expand_directory(ext2_filsys fs, ino_t dir); static ino_t lost_and_found = 0; static int bad_lost_and_found = 0; -static char *inode_loop_detect; -static char *inode_done_map; +static ext2fs_inode_bitmap inode_loop_detect; +static ext2fs_inode_bitmap inode_done_map; void pass3(ext2_filsys fs) { @@ -65,13 +65,16 @@ void pass3(ext2_filsys fs) /* * Allocate some bitmaps to do loop detection. */ - retval = ext2fs_allocate_inode_bitmap(fs, &inode_loop_detect); + retval = ext2fs_allocate_inode_bitmap(fs, + "inode loop detection bitmap", + &inode_loop_detect); if (retval) { com_err("ext2fs_allocate_inode_bitmap", retval, "while allocating inode_loop_detect"); fatal_error(0); } - retval = ext2fs_allocate_inode_bitmap(fs, &inode_done_map); + retval = ext2fs_allocate_inode_bitmap(fs, "inode done bitmap", + &inode_done_map); if (retval) { com_err("ext2fs_allocate_inode_bitmap", retval, "while allocating inode_done_map"); @@ -83,16 +86,16 @@ void pass3(ext2_filsys fs) } check_root(fs, EXT2_ROOT_INO); - ext2fs_mark_inode_bitmap(fs, inode_done_map, EXT2_ROOT_INO); + ext2fs_mark_inode_bitmap(inode_done_map, EXT2_ROOT_INO); for (i=1; i <= fs->super->s_inodes_count; i++) { - if (ext2fs_test_inode_bitmap(fs, inode_dir_map, i)) + if (ext2fs_test_inode_bitmap(inode_dir_map, i)) check_directory(fs, i); } free_dir_info(fs); - free(inode_loop_detect); - free(inode_done_map); + ext2fs_free_inode_bitmap(inode_loop_detect); + ext2fs_free_inode_bitmap(inode_done_map); if (tflag > 1) { printf("Pass 3: "); print_resource_track(&rtrack); @@ -111,13 +114,13 @@ void check_root(ext2_filsys fs, ino_t root_ino) char * block; struct dir_info *dir; - if (ext2fs_test_inode_bitmap(fs, inode_used_map, root_ino)) { + if (ext2fs_test_inode_bitmap(inode_used_map, root_ino)) { /* * If the root inode is a directory, die here. The * user must have answered 'no' in pass1 when we * offered to clear it. */ - if (!(ext2fs_test_inode_bitmap(fs, inode_dir_map, root_ino))) + if (!(ext2fs_test_inode_bitmap(inode_dir_map, root_ino))) fatal_error("Root inode not directory"); /* @@ -148,8 +151,8 @@ void check_root(ext2_filsys fs, ino_t root_ino) "while trying to create root directory"); fatal_error(0); } - ext2fs_mark_block_bitmap(fs, block_found_map, blk); - ext2fs_mark_block_bitmap(fs, fs->block_map, blk); + ext2fs_mark_block_bitmap(block_found_map, blk); + ext2fs_mark_block_bitmap(fs->block_map, blk); ext2fs_mark_bb_dirty(fs); /* @@ -199,9 +202,9 @@ void check_root(ext2_filsys fs, ino_t root_ino) inode_count[EXT2_ROOT_INO] = 2; inode_link_info[EXT2_ROOT_INO] = 2; - ext2fs_mark_inode_bitmap(fs, inode_used_map, EXT2_ROOT_INO); - ext2fs_mark_inode_bitmap(fs, inode_dir_map, EXT2_ROOT_INO); - ext2fs_mark_inode_bitmap(fs, fs->inode_map, EXT2_ROOT_INO); + ext2fs_mark_inode_bitmap(inode_used_map, EXT2_ROOT_INO); + ext2fs_mark_inode_bitmap(inode_dir_map, EXT2_ROOT_INO); + ext2fs_mark_inode_bitmap(fs->inode_map, EXT2_ROOT_INO); ext2fs_mark_ib_dirty(fs); } @@ -223,12 +226,12 @@ static void check_directory(ext2_filsys fs, ino_t ino) dir = get_dir_info(ino); if (!dir) { - printf("Internal error: couldn't find dir_info for %ld\n", + printf("Internal error: couldn't find dir_info for %lu\n", ino); fatal_error(0); } - memset(inode_loop_detect, 0, (fs->super->s_inodes_count / 8) + 1); + ext2fs_clear_inode_bitmap(inode_loop_detect); p = dir; while (p) { /* @@ -238,7 +241,7 @@ static void check_directory(ext2_filsys fs, ino_t ino) * already told us he doesn't want us to reconnect the * disconnected subtree. */ - if (ext2fs_test_inode_bitmap(fs, inode_done_map, p->ino)) + if (ext2fs_test_inode_bitmap(inode_done_map, p->ino)) goto check_dot_dot; /* * Mark this inode as being "done"; by the time we @@ -247,17 +250,17 @@ static void check_directory(ext2_filsys fs, ino_t ino) * or we will have offered to reconnect this to * lost+found. */ - ext2fs_mark_inode_bitmap(fs, inode_done_map, p->ino); + ext2fs_mark_inode_bitmap(inode_done_map, p->ino); /* * If this directory doesn't have a parent, or we've * seen the parent once already, then offer to * reparent it to lost+found */ if (!p->parent || - (ext2fs_test_inode_bitmap(fs, inode_loop_detect, + (ext2fs_test_inode_bitmap(inode_loop_detect, p->parent))) break; - ext2fs_mark_inode_bitmap(fs, inode_loop_detect, + ext2fs_mark_inode_bitmap(inode_loop_detect, p->parent); p = get_dir_info(p->parent); } @@ -269,7 +272,7 @@ static void check_directory(ext2_filsys fs, ino_t ino) if (retval) path1 = unknown; - printf("Unconnected directory inode %li (%s)\n", p->ino, path1); + printf("Unconnected directory inode %lu (%s)\n", p->ino, path1); if (path1 != unknown) free(path1); preenhalt(); @@ -301,7 +304,7 @@ check_dot_dot: if (retval) path3 = unknown; - printf("'..' in %s (%ld) is %s (%ld), should be %s (%ld).\n", + printf("'..' in %s (%lu) is %s (%lu), should be %s (%lu).\n", path1, ino, path2, dir->dotdot, path3, dir->parent); if (path1 != unknown) @@ -359,8 +362,8 @@ ino_t get_lost_and_found(ext2_filsys fs) "while trying to create /lost+found directory"); return 0; } - ext2fs_mark_block_bitmap(fs, block_found_map, blk); - ext2fs_mark_block_bitmap(fs, fs->block_map, blk); + ext2fs_mark_block_bitmap(block_found_map, blk); + ext2fs_mark_block_bitmap(fs->block_map, blk); ext2fs_mark_bb_dirty(fs); /* @@ -373,9 +376,9 @@ ino_t get_lost_and_found(ext2_filsys fs) "while trying to create /lost+found directory"); return 0; } - ext2fs_mark_inode_bitmap(fs, inode_used_map, ino); - ext2fs_mark_inode_bitmap(fs, inode_dir_map, ino); - ext2fs_mark_inode_bitmap(fs, fs->inode_map, ino); + ext2fs_mark_inode_bitmap(inode_used_map, ino); + ext2fs_mark_inode_bitmap(inode_dir_map, ino); + ext2fs_mark_inode_bitmap(fs->inode_map, ino); ext2fs_mark_ib_dirty(fs); /* @@ -433,7 +436,7 @@ ino_t get_lost_and_found(ext2_filsys fs) inode_count[ino] = 2; inode_link_info[ino] = 2; #if 0 - printf("/lost+found created; inode #%d\n", ino); + printf("/lost+found created; inode #%lu\n", ino); #endif return ino; } @@ -459,7 +462,7 @@ int reconnect_file(ext2_filsys fs, ino_t inode) } } - sprintf(name, "#%ld", inode); + sprintf(name, "#%lu", inode); retval = ext2fs_link(fs, lost_and_found, name, inode, 0); if (retval == EXT2_ET_DIR_NO_SPACE) { if (!ask("No room in /lost+found; expand /lost+found", 1)) @@ -473,7 +476,7 @@ int reconnect_file(ext2_filsys fs, ino_t inode) retval = ext2fs_link(fs, lost_and_found, name, inode, 0); } if (retval) { - printf("Could not reconnect %ld: %s\n", inode, + printf("Could not reconnect %lu: %s\n", inode, error_message(retval)); return 1; } @@ -486,7 +489,7 @@ int reconnect_file(ext2_filsys fs, ino_t inode) /* * Utility routine to adjust the inode counts on an inode. */ -static int adjust_inode_count(ext2_filsys fs, ino_t ino, int adj) +static errcode_t adjust_inode_count(ext2_filsys fs, ino_t ino, int adj) { errcode_t retval; struct ext2_inode inode; @@ -499,7 +502,7 @@ static int adjust_inode_count(ext2_filsys fs, ino_t ino, int adj) return retval; #if 0 - printf("Adjusting link count for inode %d by %d (from %d)\n", ino, adj, + printf("Adjusting link count for inode %lu by %d (from %d)\n", ino, adj, inode.i_links_count); #endif @@ -539,11 +542,11 @@ static int fix_dotdot_proc(struct ext2_dir_entry *dirent, retval = adjust_inode_count(fp->fs, dirent->inode, -1); if (retval) - printf("Error while adjusting inode count on inode %ld\n", + printf("Error while adjusting inode count on inode %lu\n", dirent->inode); retval = adjust_inode_count(fp->fs, fp->parent, 1); if (retval) - printf("Error while adjusting inode count on inode %ld\n", + printf("Error while adjusting inode count on inode %lu\n", fp->parent); dirent->inode = fp->parent; @@ -562,13 +565,13 @@ static void fix_dotdot(ext2_filsys fs, struct dir_info *dir, ino_t parent) fp.done = 0; #if 0 - printf("Fixing '..' of inode %d to be %d...\n", dir->ino, parent); + printf("Fixing '..' of inode %lu to be %lu...\n", dir->ino, parent); #endif retval = ext2fs_dir_iterate(fs, dir->ino, DIRENT_FLAG_INCLUDE_EMPTY, 0, fix_dotdot_proc, &fp); if (retval || !fp.done) { - printf("Couldn't fix parent of inode %ld: %s\n\n", + printf("Couldn't fix parent of inode %lu: %s\n\n", dir->ino, retval ? error_message(retval) : "Couldn't find parent direntory entry"); ext2fs_unmark_valid(fs); @@ -630,8 +633,8 @@ static int expand_dir_proc(ext2_filsys fs, } free(block); *blocknr = new_blk; - ext2fs_mark_block_bitmap(fs, block_found_map, new_blk); - ext2fs_mark_block_bitmap(fs, fs->block_map, new_blk); + ext2fs_mark_block_bitmap(block_found_map, new_blk); + ext2fs_mark_block_bitmap(fs->block_map, new_blk); ext2fs_mark_bb_dirty(fs); if (es->done) return (BLOCK_CHANGED | BLOCK_ABORT); @@ -673,9 +676,7 @@ static errcode_t expand_directory(ext2_filsys fs, ino_t dir) inode.i_size += fs->blocksize; inode.i_blocks += fs->blocksize / 512; - retval = ext2fs_write_inode(fs, dir, &inode); - if (retval) - return retval; + e2fsck_write_inode(fs, dir, &inode, "expand_directory"); return 0; } diff --git a/e2fsck/pass4.c b/e2fsck/pass4.c index 290e1b95..1075731e 100644 --- a/e2fsck/pass4.c +++ b/e2fsck/pass4.c @@ -10,7 +10,7 @@ void pass4(ext2_filsys fs) { - int i; + ino_t i; struct ext2_inode inode; struct resource_track rtrack; @@ -21,19 +21,19 @@ void pass4(ext2_filsys fs) #endif if (!preen) - printf("Pass 4: Check reference counts.\n"); + printf("Pass 4: Checking reference counts\n"); for (i=1; i <= fs->super->s_inodes_count; i++) { if (i == EXT2_BAD_INO || (i > EXT2_ROOT_INO && i < EXT2_FIRST_INO)) continue; - if (!(ext2fs_test_inode_bitmap(fs, inode_used_map, i))) + if (!(ext2fs_test_inode_bitmap(inode_used_map, i))) continue; if (inode_count[i] == 0) { /* * Inode isn't attached to the filesystem; * prompt to reconnect. */ - printf("Unattached inode %d\n", i); + printf("Unattached inode %lu\n", i); preenhalt(); if (ask("Connect to /lost+found", 1)) { if (reconnect_file(fs, i)) @@ -42,20 +42,20 @@ void pass4(ext2_filsys fs) ext2fs_unmark_valid(fs); } if (inode_count[i] != inode_link_info[i]) { - ext2fs_read_inode(fs, i, &inode); + e2fsck_read_inode(fs, i, &inode, "pass4"); if (inode_link_info[i] != inode.i_links_count) { printf("WARNING: PROGRAMMING BUG IN E2FSCK!\n"); - printf("inode_link_info[%d] is %d, " + printf("inode_link_info[%d] is %lu, " "inode.i_links_count is %d. " "They should be the same!\n", i, inode_link_info[i], inode.i_links_count); } - printf("Inode %d has ref count %d, expecting %d.\n", + printf("Inode %lu has ref count %d, expecting %d.\n", i, inode.i_links_count, inode_count[i]); if (ask("Set i_nlinks to count", 1)) { inode.i_links_count = inode_count[i]; - ext2fs_write_inode(fs, i, &inode); + e2fsck_write_inode(fs, i, &inode, "pass4"); } else ext2fs_unmark_valid(fs); } diff --git a/e2fsck/pass5.c b/e2fsck/pass5.c index cd0cf5b7..888ac97d 100644 --- a/e2fsck/pass5.c +++ b/e2fsck/pass5.c @@ -29,7 +29,7 @@ void pass5(ext2_filsys fs) init_resource_track(&rtrack); if (!preen) - printf("Pass 5: Checking group summary information.\n"); + printf("Pass 5: Checking group summary information\n"); read_bitmaps(fs); @@ -38,9 +38,9 @@ void pass5(ext2_filsys fs) check_inode_end(fs); check_block_end(fs); - free(inode_used_map); - free(inode_dir_map); - free(block_found_map); + ext2fs_free_inode_bitmap(inode_used_map); + ext2fs_free_inode_bitmap(inode_dir_map); + ext2fs_free_block_bitmap(block_found_map); if (tflag > 1) { printf("Pass 5: "); @@ -50,7 +50,7 @@ void pass5(ext2_filsys fs) static void check_block_bitmaps(ext2_filsys fs) { - int i; + blk_t i; int *free_array; int group = 0; int blocks = 0; @@ -65,15 +65,15 @@ static void check_block_bitmaps(ext2_filsys fs) for (i = fs->super->s_first_data_block; i < fs->super->s_blocks_count; i++) { - actual = ext2fs_test_block_bitmap(fs, block_found_map, i); - bitmap = ext2fs_test_block_bitmap(fs, fs->block_map, i); + actual = ext2fs_test_block_bitmap(block_found_map, i); + bitmap = ext2fs_test_block_bitmap(fs->block_map, i); if (actual == bitmap) goto do_counts; if (do_fix < 0) do_fix = ask(fix_question, 1); - if (print_header) { + if (!preen && print_header) { printf(print_header); print_header = 0; } @@ -81,17 +81,19 @@ static void check_block_bitmaps(ext2_filsys fs) /* * Block not used, but marked in use in the bitmap. */ - printf(" -%d", i); + if (!preen) + printf(" -%lu", i); if (do_fix) - ext2fs_unmark_block_bitmap(fs, fs->block_map, + ext2fs_unmark_block_bitmap(fs->block_map, i); } else { /* * Block used, but not marked in use in the bitmap. */ - printf(" +%d", i); + if (!preen) + printf(" +%lu", i); if (do_fix) - ext2fs_mark_block_bitmap(fs, fs->block_map, + ext2fs_mark_block_bitmap(fs->block_map, i); } if (do_fix) { @@ -120,9 +122,11 @@ static void check_block_bitmaps(ext2_filsys fs) if (free_array[i] != fs->group_desc[i].bg_free_blocks_count) { if (do_fix < 0) do_fix = ask(fix_question, 1); - printf("Free blocks count wrong for group %d (%d, counted=%d). %s\n", - i, fs->group_desc[i].bg_free_blocks_count, - free_array[i], fix_msg[do_fix]); + if (!preen) + printf("Free blocks count wrong for " + "group %lu (%u, counted=%d). %s\n", i, + fs->group_desc[i].bg_free_blocks_count, + free_array[i], fix_msg[do_fix]); if (do_fix) { fs->group_desc[i].bg_free_blocks_count = free_array[i]; @@ -134,9 +138,11 @@ static void check_block_bitmaps(ext2_filsys fs) if (free_blocks != fs->super->s_free_blocks_count) { if (do_fix < 0) do_fix = ask(fix_question, 1); - printf("Free blocks count wrong (%ld, counted=%d). %s\n", - fs->super->s_free_blocks_count, free_blocks, - fix_msg[do_fix]); + if (!preen) + printf("Free blocks count wrong " + "(%lu, counted=%d). %s\n", + fs->super->s_free_blocks_count, free_blocks, + fix_msg[do_fix]); if (do_fix) { fs->super->s_free_blocks_count = free_blocks; ext2fs_mark_super_dirty(fs); @@ -147,7 +153,7 @@ static void check_block_bitmaps(ext2_filsys fs) static void check_inode_bitmaps(ext2_filsys fs) { - int i; + ino_t i; int free_inodes = 0; int group_free = 0; int dirs_count = 0; @@ -165,15 +171,15 @@ static void check_inode_bitmaps(ext2_filsys fs) "directory count array"); for (i = 1; i <= fs->super->s_inodes_count; i++) { - actual = ext2fs_test_inode_bitmap(fs, inode_used_map, i); - bitmap = ext2fs_test_inode_bitmap(fs, fs->inode_map, i); + actual = ext2fs_test_inode_bitmap(inode_used_map, i); + bitmap = ext2fs_test_inode_bitmap(fs->inode_map, i); if (actual == bitmap) goto do_counts; if (do_fix < 0) do_fix = ask(fix_question, 1); - if (print_header) { + if (!preen && print_header) { printf(print_header); print_header = 0; } @@ -181,17 +187,18 @@ static void check_inode_bitmaps(ext2_filsys fs) /* * Inode wasn't used, but marked in bitmap */ - printf(" -%d", i); + if (!preen) + printf(" -%lu", i); if (do_fix) - ext2fs_unmark_inode_bitmap(fs, fs->inode_map, - i); + ext2fs_unmark_inode_bitmap(fs->inode_map, i); } else if (actual && !bitmap) { /* * Inode used, but not in bitmap */ - printf (" +%d", i); + if (!preen) + printf (" +%lu", i); if (do_fix) - ext2fs_mark_inode_bitmap(fs, fs->inode_map, i); + ext2fs_mark_inode_bitmap(fs->inode_map, i); } if (do_fix) { ext2fs_mark_ib_dirty(fs); @@ -204,7 +211,7 @@ do_counts: group_free++; free_inodes++; } else { - if (ext2fs_test_inode_bitmap(fs, inode_dir_map, i)) + if (ext2fs_test_inode_bitmap(inode_dir_map, i)) dirs_count++; } inodes++; @@ -225,9 +232,11 @@ do_counts: if (free_array[i] != fs->group_desc[i].bg_free_inodes_count) { if (do_fix < 0) do_fix = ask(fix_question, 1); - printf ("Free inodes count wrong for group #%d (%d, counted=%d). %s\n", - i, fs->group_desc[i].bg_free_inodes_count, - free_array[i], fix_msg[do_fix]); + if (!preen) + printf ("Free inodes count wrong for " + "group #%lu (%u, counted=%d). %s\n", i, + fs->group_desc[i].bg_free_inodes_count, + free_array[i], fix_msg[do_fix]); if (do_fix) { fs->group_desc[i].bg_free_inodes_count = free_array[i]; @@ -238,9 +247,11 @@ do_counts: if (dir_array[i] != fs->group_desc[i].bg_used_dirs_count) { if (do_fix < 0) do_fix = ask(fix_question, 1); - printf ("Directories count wrong for group #%d (%d, counted=%d). %s\n", - i, fs->group_desc[i].bg_used_dirs_count, - dir_array[i], fix_msg[do_fix]); + if (!preen) + printf ("Directories count wrong for " + "group #%lu (%u, counted=%d). %s\n", i, + fs->group_desc[i].bg_used_dirs_count, + dir_array[i], fix_msg[do_fix]); if (do_fix) { fs->group_desc[i].bg_used_dirs_count = dir_array[i]; @@ -252,9 +263,11 @@ do_counts: if (free_inodes != fs->super->s_free_inodes_count) { if (do_fix < 0) do_fix = ask(fix_question, 1); - printf("Free inodes count wrong (%ld, counted=%d). %s\n", - fs->super->s_free_inodes_count, free_inodes, - fix_msg[do_fix]); + if (!preen) + printf("Free inodes count wrong " + "(%lu, counted=%d). %s\n", + fs->super->s_free_inodes_count, free_inodes, + fix_msg[do_fix]); if (do_fix) { fs->super->s_free_inodes_count = free_inodes; ext2fs_mark_super_dirty(fs); @@ -265,23 +278,26 @@ do_counts: static void check_inode_end(ext2_filsys fs) { - ino_t end; - ino_t save_inodes_count = fs->super->s_inodes_count; - ino_t i; + ino_t end, save_inodes_count, i; + errcode_t retval; end = EXT2_INODES_PER_GROUP(fs->super) * fs->group_desc_count; + retval = ext2fs_fudge_inode_bitmap_end(fs->inode_map, end, + &save_inodes_count); + if (retval) { + com_err("check_inode_end", retval, + "while trying to fudge end of inode bitmap"); + fatal_error(0); + } if (save_inodes_count == end) return; - fs->super->s_inodes_count = end; - for (i = save_inodes_count + 1; i <= end; i++) { - if (!ext2fs_test_inode_bitmap(fs, fs->inode_map, i)) { + if (!ext2fs_test_inode_bitmap(fs->inode_map, i)) { printf("Padding at end of inode bitmap is not set. "); if (ask("Fix", 1)) { for (i = save_inodes_count + 1; i <= end; i++) - ext2fs_mark_inode_bitmap(fs, - fs->inode_map, + ext2fs_mark_inode_bitmap(fs->inode_map, i); ext2fs_mark_ib_dirty(fs); } else @@ -290,31 +306,39 @@ static void check_inode_end(ext2_filsys fs) } } - fs->super->s_inodes_count = save_inodes_count; + retval = ext2fs_fudge_inode_bitmap_end(fs->inode_map, + save_inodes_count, 0); + if (retval) { + com_err("check_inode_end", retval, + "while trying to fudge end of inode bitmap back"); + fatal_error(0); + } } static void check_block_end(ext2_filsys fs) { - blk_t end; - blk_t save_blocks_count = fs->super->s_blocks_count; - blk_t i; - - end = fs->super->s_first_data_block + - (EXT2_BLOCKS_PER_GROUP(fs->super) * fs->group_desc_count); + blk_t end, save_blocks_count, i; + errcode_t retval; + end = fs->block_map->start + + (EXT2_BLOCKS_PER_GROUP(fs->super) * fs->group_desc_count) - 1; + retval = ext2fs_fudge_block_bitmap_end(fs->block_map, end, + &save_blocks_count); + if (retval) { + com_err("check_block_end", retval, + "while trying to fudge end of block bitmap"); + fatal_error(0); + } if (save_blocks_count == end) return; - fs->super->s_blocks_count = end; - - for (i = save_blocks_count; i < end; i++) { - if (!ext2fs_test_block_bitmap(fs, fs->block_map, i)) { + for (i = save_blocks_count + 1; i <= end; i++) { + if (!ext2fs_test_block_bitmap(fs->block_map, i)) { printf("Padding at end of block bitmap is not set. "); if (ask("Fix", 1)) { for (i = save_blocks_count + 1; i < end; i++) - ext2fs_mark_block_bitmap(fs, - fs->block_map, + ext2fs_mark_block_bitmap(fs->block_map, i); ext2fs_mark_bb_dirty(fs); } else @@ -323,6 +347,12 @@ static void check_block_end(ext2_filsys fs) } } - fs->super->s_blocks_count = save_blocks_count; + retval = ext2fs_fudge_block_bitmap_end(fs->block_map, + save_blocks_count, 0); + if (retval) { + com_err("check_block_end", retval, + "while trying to fudge end of block bitmap back"); + fatal_error(0); + } } diff --git a/e2fsck/scantest.c b/e2fsck/scantest.c new file mode 100644 index 00000000..a0b078d4 --- /dev/null +++ b/e2fsck/scantest.c @@ -0,0 +1,139 @@ +/* + * scantest.c - test the speed of the inode scan routine + */ + +#include <string.h> +#include <fcntl.h> +#include <ctype.h> +#include <termios.h> +#include <time.h> +#include <getopt.h> +#include <unistd.h> +#include <mntent.h> +#include <sys/ioctl.h> +#include <malloc.h> +#include <sys/resource.h> + +#include "et/com_err.h" +#include "../version.h" + +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <stdlib.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <sys/time.h> + +#include <linux/fs.h> +#include <linux/ext2_fs.h> + +#include "ext2fs/ext2fs.h" + + +extern int isatty(int); + +const char * device_name = NULL; + +/* + * This structure is used for keeping track of how much resources have + * been used for a particular pass of e2fsck. + */ +struct resource_track { + struct timeval time_start; + struct timeval user_start; + struct timeval system_start; + void *brk_start; +}; + +struct resource_track global_rtrack; + +void init_resource_track(struct resource_track *track) +{ + struct rusage r; + + track->brk_start = sbrk(0); + gettimeofday(&track->time_start, 0); + getrusage(RUSAGE_SELF, &r); + track->user_start = r.ru_utime; + track->system_start = r.ru_stime; +} + +static __inline__ float timeval_subtract(struct timeval *tv1, + struct timeval *tv2) +{ + return ((tv1->tv_sec - tv2->tv_sec) + + ((float) (tv1->tv_usec - tv2->tv_usec)) / 1000000); +} + +void print_resource_track(struct resource_track *track) +{ + struct rusage r; + struct timeval time_end; + + gettimeofday(&time_end, 0); + getrusage(RUSAGE_SELF, &r); + + printf("Memory used: %d, elapsed time: %6.3f/%6.3f/%6.3f\n", + (int) (((char *) sbrk(0)) - ((char *) track->brk_start)), + timeval_subtract(&time_end, &track->time_start), + timeval_subtract(&r.ru_utime, &track->user_start), + timeval_subtract(&r.ru_stime, &track->system_start)); +} + + + +int main (int argc, char *argv[]) +{ + errcode_t retval = 0; + int exit_value = 0; + int i; + ext2_filsys fs; + ext2_inode_scan scan; + ino_t ino; + struct ext2_inode inode; + + printf("size of inode=%d\n", sizeof(inode)); + + device_name = "/dev/hda3"; + + init_resource_track(&global_rtrack); + + retval = ext2fs_open(device_name, 0, + 0, 0, unix_io_manager, &fs); + if (retval) { + com_err(argv[0], retval, "while trying to open %s", + device_name); + exit(1); + } + + retval = ext2fs_open_inode_scan(fs, 0, &scan); + if (retval) { + com_err(argv[0], retval, "while opening inode scan"); + exit(1); + } + retval = ext2fs_get_next_inode(scan, &ino, &inode); + if (retval) { + com_err(argv[0], retval, "while starting inode scan"); + exit(1); + } + while (ino) { + if (!inode.i_links_count) + goto next; + printf("%lu\n", inode.i_blocks); + next: + retval = ext2fs_get_next_inode(scan, &ino, &inode); + if (retval) { + com_err(argv[0], retval, + "while doing inode scan"); + exit(1); + } + } + + + ext2fs_close(fs); + + print_resource_track(&global_rtrack); + + return exit_value; +} diff --git a/e2fsck/util.c b/e2fsck/util.c index c9e63960..3f5447d7 100644 --- a/e2fsck/util.c +++ b/e2fsck/util.c @@ -105,28 +105,21 @@ void read_bitmaps(ext2_filsys fs) { errcode_t retval; - if (!fs->inode_map) { - ehandler_operation("reading inode bitmaps"); - retval = ext2fs_read_inode_bitmap(fs); - ehandler_operation(0); - if (retval) { - com_err(program_name, retval, - "while retrying to read inode bitmaps for %s", - device_name); - fatal_error(0); - } + if (invalid_bitmaps) { + com_err(program_name, 0, + "read_bitmaps: illegal bitmap block(s) for %s", + device_name); + fatal_error(0); } - - if (!fs->block_map) { - ehandler_operation("reading block bitmaps"); - retval = ext2fs_read_block_bitmap(fs); - ehandler_operation(0); - if (retval) { - com_err(program_name, retval, - "while retrying to read block bitmaps for %s", - device_name); - fatal_error(0); - } + + ehandler_operation("reading inode and block bitmaps"); + retval = ext2fs_read_bitmaps(fs); + ehandler_operation(0); + if (retval) { + com_err(program_name, retval, + "while retrying to read bitmaps for %s", + device_name); + fatal_error(0); } } @@ -201,6 +194,32 @@ void print_resource_track(struct resource_track *track) timeval_subtract(&r.ru_stime, &track->system_start)); } +void e2fsck_read_inode(ext2_filsys fs, unsigned long ino, + struct ext2_inode * inode, const char *proc) +{ + int retval; + + retval = ext2fs_read_inode(fs, ino, inode); + if (retval) { + com_err("ext2fs_read_inode", retval, + "while reading inode %ld in %s", ino, proc); + fatal_error(0); + } +} + +extern void e2fsck_write_inode(ext2_filsys fs, unsigned long ino, + struct ext2_inode * inode, const char *proc) +{ + int retval; + + retval = ext2fs_write_inode(fs, ino, inode); + if (retval) { + com_err("ext2fs_write_inode", retval, + "while writing inode %ld in %s", ino, proc); + fatal_error(0); + } +} + /* * This function returns 1 if the inode's block entries actually * contain block entries. diff --git a/install-utils/ChangeLog b/install-utils/ChangeLog new file mode 100644 index 00000000..abeddf46 --- /dev/null +++ b/install-utils/ChangeLog @@ -0,0 +1,4 @@ +Sat Mar 11 18:26:33 1995 Theodore Y. Ts'o <tytso@localhost> + + * compile_manpages: Include an exit 0 at the end because some + implementations of man exit with a status of 1. diff --git a/install-utils/compile_manpages b/install-utils/compile_manpages new file mode 100644 index 00000000..fb3bbdbf --- /dev/null +++ b/install-utils/compile_manpages @@ -0,0 +1,18 @@ +#!/bin/sh + +MAN8="debugfs badblocks e2fsck mke2fs dumpe2fs mklost+found \ + fsck tune2fs" +MAN1="lsattr chattr" + +for i in $MAN8 +do + man -S 8 $i > /dev/null +done + + +for i in $MAN1 +do + man -S 1 $i > /dev/null +done + +exit 0 diff --git a/install-utils/convfstab b/install-utils/convfstab new file mode 100644 index 00000000..01938d63 --- /dev/null +++ b/install-utils/convfstab @@ -0,0 +1,78 @@ +#!/bin/sh +# Make /etc/fstab standard compliant. +# M.Weller (eowmob@exp-math.uni-essen.de) 13.11.1994. +# This script is public domain. Still if only slightly +# modified a credit to me might be nice. + +ROOT_PASS=1 # Pass for root file system +NON_ROOT_PASS=2 # Pass for non root file systems +DEF_FLAGS="defaults" # Default filesysflags +DEF_DUMP=0 # Default dumpfreq. + +while read LINE +do + set -- $LINE + if [ $# != 0 ] + then + case $1 in + \#* | !* ) + echo "$LINE" + # Actually there are no comments allowed in /etc/fstab + echo "Warning: comment in /etc/fstab detected." >&2 + echo "Please remove it by hand." >&2 + ;; + * ) + if [ $# -gt 6 -o $# -lt 3 ] + then + echo "Don't have a clue about \"$LINE\"." >&2 + echo "$LINE" + else + case $2 in + / ) + PASS=$ROOT_PASS + ;; + none ) + PASS=0 + ;; + * ) + PASS=$NON_ROOT_PASS + ;; + esac + DUMP=$DEF_DUMP + case $3 in + ignore | iso9660 | msdos | hpfs | sysv | \ + xenix | coherent | nfs | proc | sw | swap ) + DUMP=0; + PASS=0; + ;; + esac + case $# in + 3 ) + echo "$LINE $DEF_FLAGS $DUMP $PASS" + ;; + 4 ) + echo "$LINE $DUMP $PASS" + ;; + 5 ) + echo "$LINE $PASS" + ;; + 6) + echo "$LINE" + ;; + esac + fi + ;; + esac + else + echo "Warning: One empty line removed." >&2 + fi +done </etc/fstab >/tmp/newfstab.$$ +mv -f /etc/fstab /etc/fstab.bak +mv -f /tmp/newfstab.$$ /etc/fstab +if [ $? != 0 ] +then + echo "Installation of patched /etc/fstab failed." + echo "It would have been:" + cat /tmp/newfstab.$$ + rm -f /tmp/newfstab.$$ +fi diff --git a/install-utils/remove_preformat_manpages b/install-utils/remove_preformat_manpages new file mode 100644 index 00000000..3532adfe --- /dev/null +++ b/install-utils/remove_preformat_manpages @@ -0,0 +1,21 @@ +#!/bin/sh + +PREFORMAT_ROOT=/usr/man/preformat +COMPILED_ROOT=/usr/man + +MAN8="debugfs.8 badblocks.8 e2fsck.8 mke2fs.8 dumpe2fs.8 mklost+found.8 \ + fsck.8 tune2fs.8" +MAN1="lsattr.1 chattr.1" + +for i in $MAN8 +do + rm -f $PREFORMAT_ROOT/cat8/$i $COMPILED_ROOT/cat8/$i \ + $PREFORMAT_ROOT/cat8/$i.gz $COMPILED_ROOT/cat8/$i.gz +done + + +for i in $MAN1 +do + rm -f $PREFORMAT_ROOT/cat1/$i $COMPILED_ROOT/cat1/$i \ + $PREFORMAT_ROOT/cat1/$i.gz $COMPILED_ROOT/cat1/$i.gz +done diff --git a/lib/Makefile.dll-lib b/lib/Makefile.dll-lib new file mode 100644 index 00000000..dee8e62c --- /dev/null +++ b/lib/Makefile.dll-lib @@ -0,0 +1,70 @@ +# +# This is a Makefile stub which handles the creation of Linux DLL-style shared +# libraries. +# +# In order to use this stub, the following makefile variables must be defined. +# +# DLL_ADDRESS = 0x80000000 +# DLL_JUMPSIZE = 0x1000 +# DLL_GOTSIZE = 0x1000 +# DLL_VERSION = 1.0 +# DLL_IMAGE = libce +# DLL_STUB = libcom_err +# DLL_MYDIR = et +# DLL_INSTALL_DIR = $(SHLIBDIR) +# + +all:: image stubs + +# +# This is a horrible hack to try to find libgcc.a --- the DLL documentation +# states that you should just be able to do -lgcc, but modern gcc +# installation packages don't install /usr/lib/libgcc.a --- as well they +# shouldn't since libgcc.a can be gcc version dependent. +# If this hack doesn't work, try replacing it with a hardcoded path to +# libgcc.a, or -lgcc. +# +#DLL_LIBGCC ="`$(CC) -v 2>&1 | head -1 | \ +# sed -e 's;[^/]*;;' -e 's/specs/libgcc.a/'`" +DLL_LIBGCC ="`$(CC) --print-libgcc-file-name`" + +image: $(DLL_IMAGE).so.$(DLL_VERSION) + +stubs: $(DLL_STUB).sa $(OBJS) + +$(DLL_IMAGE).so.$(DLL_VERSION): $(OBJS) + (cd jump; export JUMP_DIR=`pwd`; \ + $(DLL_BIN)/mkimage -l $(DLL_IMAGE) -v $(DLL_VERSION) \ + -a $(DLL_ADDRESS) -j $(DLL_JUMPSIZE) -g $(DLL_GOTSIZE) -- \ + $(OBJS) -lc $(DLL_LIBS) $(DLL_LIBGCC) -lc) + mv jump/$(DLL_IMAGE).so.$(DLL_VERSION) . + +$(DLL_STUB).sa: + (cd jump; export JUMP_DIR=`pwd`; \ + $(DLL_BIN)/mkstubs -l $(DLL_IMAGE) -v $(DLL_VERSION) \ + -a $(DLL_ADDRESS) -j $(DLL_JUMPSIZE) -g $(DLL_GOTSIZE) \ + -- $(DLL_STUB)) + mv jump/$(DLL_STUB).sa . + @$(RM) ../$@ + @$(LN) $(DLL_MYDIR)/$@ ../$@ + +install:: $(DLL_IMAGE).so.$(DLL_VERSION) + $(INSTALLBIN) $(DLL_IMAGE).so.$(DLL_VERSION) \ + $(DLL_INSTALL_DIR)/$(DLL_IMAGE).so.$(DLL_VERSION) + -ldconfig + +install-libs:: $(DLL_STUB).sa + $(INSTALLLIB) $(DLL_STUB).sa $(LIBDIR)/$(DLL_STUB).sa + $(CHMOD) 644 $(LIBDIR)/$(DLL_STUB).sa + $(RANLIB) $(LIBDIR)/$(DLL_STUB).sa + $(CHMOD) $(LIBMODE) $(LIBDIR)/$(DLL_STUB).sa + +install-tree:: $(DLL_IMAGE).so.$(DLL_VERSION) + rm -f ../../shlibs/$(DLL_IMAGE).so.$(DLL_VERSION) + cp $(DLL_IMAGE).so.$(DLL_VERSION) ../../shlibs + strip ../../shlibs/$(DLL_IMAGE).so.$(DLL_VERSION) + chmod 555 ../../shlibs/$(DLL_IMAGE).so.$(DLL_VERSION) + +clean:: + (cd jump; $(RM) *~ *.o *.s jump.log size.nm) + $(RM) ../$(DLL_STUB).sa $(DLL_STUB).sa $(DLL_IMAGE).so.$(DLL_VERSION) diff --git a/lib/e2p/.depend b/lib/e2p/.depend index 12950ef5..f3bd9164 100644 --- a/lib/e2p/.depend +++ b/lib/e2p/.depend @@ -1,77 +1,86 @@ fgetflags.o : fgetflags.c /usr/include/errno.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/linux/errno.h /usr/include/fcntl.h /usr/include/sys/types.h /usr/include/linux/types.h \ - /usr/include/linux/fcntl.h /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/sys/ioctl.h \ - /usr/include/linux/ioctl.h /usr/include/termios.h /usr/include/linux/termios.h \ + /usr/include/asm/types.h /usr/include/linux/fcntl.h /usr/include/unistd.h /usr/include/posix_opt.h \ + /usr/include/gnu/types.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ + /usr/include/sys/ioctl.h /usr/include/linux/ioctl.h /usr/include/termios.h /usr/include/linux/termios.h \ /usr/include/linux/ext2_fs.h e2p.h /usr/include/dirent.h /usr/include/linux/limits.h \ - /usr/include/linux/dirent.h /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h + /usr/include/linux/dirent.h /usr/include/posix1_lim.h /usr/include/stdio.h /usr/include/libio.h \ + /usr/include/_G_config.h fgetversion.o : fgetversion.c /usr/include/errno.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/linux/errno.h /usr/include/fcntl.h /usr/include/sys/types.h /usr/include/linux/types.h \ - /usr/include/linux/fcntl.h /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/sys/ioctl.h \ - /usr/include/linux/ioctl.h /usr/include/termios.h /usr/include/linux/termios.h \ + /usr/include/asm/types.h /usr/include/linux/fcntl.h /usr/include/unistd.h /usr/include/posix_opt.h \ + /usr/include/gnu/types.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ + /usr/include/sys/ioctl.h /usr/include/linux/ioctl.h /usr/include/termios.h /usr/include/linux/termios.h \ /usr/include/linux/ext2_fs.h e2p.h /usr/include/dirent.h /usr/include/linux/limits.h \ - /usr/include/linux/dirent.h /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h + /usr/include/linux/dirent.h /usr/include/posix1_lim.h /usr/include/stdio.h /usr/include/libio.h \ + /usr/include/_G_config.h fsetflags.o : fsetflags.c /usr/include/errno.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/linux/errno.h /usr/include/fcntl.h /usr/include/sys/types.h /usr/include/linux/types.h \ - /usr/include/linux/fcntl.h /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/sys/ioctl.h \ - /usr/include/linux/ioctl.h /usr/include/termios.h /usr/include/linux/termios.h \ + /usr/include/asm/types.h /usr/include/linux/fcntl.h /usr/include/unistd.h /usr/include/posix_opt.h \ + /usr/include/gnu/types.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ + /usr/include/sys/ioctl.h /usr/include/linux/ioctl.h /usr/include/termios.h /usr/include/linux/termios.h \ /usr/include/linux/ext2_fs.h e2p.h /usr/include/dirent.h /usr/include/linux/limits.h \ - /usr/include/linux/dirent.h /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h + /usr/include/linux/dirent.h /usr/include/posix1_lim.h /usr/include/stdio.h /usr/include/libio.h \ + /usr/include/_G_config.h fsetversion.o : fsetversion.c /usr/include/errno.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/linux/errno.h /usr/include/fcntl.h /usr/include/sys/types.h /usr/include/linux/types.h \ - /usr/include/linux/fcntl.h /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/sys/ioctl.h \ - /usr/include/linux/ioctl.h /usr/include/termios.h /usr/include/linux/termios.h \ + /usr/include/asm/types.h /usr/include/linux/fcntl.h /usr/include/unistd.h /usr/include/posix_opt.h \ + /usr/include/gnu/types.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ + /usr/include/sys/ioctl.h /usr/include/linux/ioctl.h /usr/include/termios.h /usr/include/linux/termios.h \ /usr/include/linux/ext2_fs.h e2p.h /usr/include/dirent.h /usr/include/linux/limits.h \ - /usr/include/linux/dirent.h /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h + /usr/include/linux/dirent.h /usr/include/posix1_lim.h /usr/include/stdio.h /usr/include/libio.h \ + /usr/include/_G_config.h getflags.o : getflags.c /usr/include/errno.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/linux/errno.h /usr/include/sys/ioctl.h /usr/include/linux/ioctl.h \ - /usr/include/termios.h /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/linux/termios.h \ - /usr/include/linux/ext2_fs.h e2p.h /usr/include/dirent.h /usr/include/gnu/types.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/linux/limits.h \ - /usr/include/linux/dirent.h /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h + /usr/include/termios.h /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/asm/types.h \ + /usr/include/linux/termios.h /usr/include/linux/ext2_fs.h e2p.h /usr/include/dirent.h \ + /usr/include/gnu/types.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ + /usr/include/linux/limits.h /usr/include/linux/dirent.h /usr/include/posix1_lim.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h getversion.o : getversion.c /usr/include/errno.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/linux/errno.h /usr/include/sys/ioctl.h /usr/include/linux/ioctl.h \ - /usr/include/termios.h /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/linux/termios.h \ - /usr/include/linux/ext2_fs.h e2p.h /usr/include/dirent.h /usr/include/gnu/types.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/linux/limits.h \ - /usr/include/linux/dirent.h /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h + /usr/include/termios.h /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/asm/types.h \ + /usr/include/linux/termios.h /usr/include/linux/ext2_fs.h e2p.h /usr/include/dirent.h \ + /usr/include/gnu/types.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ + /usr/include/linux/limits.h /usr/include/linux/dirent.h /usr/include/posix1_lim.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h iod.o : iod.c /usr/include/dirent.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/gnu/types.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ - /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/linux/limits.h \ - /usr/include/linux/dirent.h e2p.h /usr/include/stdio.h /usr/include/libio.h \ - /usr/include/_G_config.h /usr/include/linux/ext2_fs.h -ls.o : ls.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ - /usr/include/libio.h /usr/include/_G_config.h /usr/include/time.h /usr/include/linux/ext2_fs.h \ - e2p.h /usr/include/dirent.h /usr/include/gnu/types.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ - /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/linux/limits.h \ - /usr/include/linux/dirent.h + /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/asm/types.h \ + /usr/include/linux/limits.h /usr/include/linux/dirent.h /usr/include/posix1_lim.h \ + e2p.h /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h /usr/include/linux/ext2_fs.h +ls.o : ls.c /usr/include/grp.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/types.h /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/pwd.h /usr/include/time.h \ + /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/asm/types.h \ + /usr/include/linux/ext2_fs.h e2p.h /usr/include/dirent.h /usr/include/linux/limits.h \ + /usr/include/linux/dirent.h /usr/include/posix1_lim.h pe.o : pe.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ - /usr/include/libio.h /usr/include/_G_config.h /usr/include/linux/ext2_fs.h e2p.h \ - /usr/include/dirent.h /usr/include/gnu/types.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ - /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/linux/limits.h \ - /usr/include/linux/dirent.h + /usr/include/libio.h /usr/include/_G_config.h /usr/include/linux/ext2_fs.h /usr/include/linux/types.h \ + /usr/include/asm/types.h e2p.h /usr/include/dirent.h /usr/include/gnu/types.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/sys/types.h \ + /usr/include/linux/limits.h /usr/include/linux/dirent.h /usr/include/posix1_lim.h pf.o : pf.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ - /usr/include/libio.h /usr/include/_G_config.h /usr/include/linux/ext2_fs.h e2p.h \ - /usr/include/dirent.h /usr/include/gnu/types.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ - /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/linux/limits.h \ - /usr/include/linux/dirent.h + /usr/include/libio.h /usr/include/_G_config.h /usr/include/linux/ext2_fs.h /usr/include/linux/types.h \ + /usr/include/asm/types.h e2p.h /usr/include/dirent.h /usr/include/gnu/types.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/sys/types.h \ + /usr/include/linux/limits.h /usr/include/linux/dirent.h /usr/include/posix1_lim.h ps.o : ps.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ - /usr/include/libio.h /usr/include/_G_config.h /usr/include/linux/ext2_fs.h e2p.h \ - /usr/include/dirent.h /usr/include/gnu/types.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ - /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/linux/limits.h \ - /usr/include/linux/dirent.h + /usr/include/libio.h /usr/include/_G_config.h /usr/include/linux/ext2_fs.h /usr/include/linux/types.h \ + /usr/include/asm/types.h e2p.h /usr/include/dirent.h /usr/include/gnu/types.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/sys/types.h \ + /usr/include/linux/limits.h /usr/include/linux/dirent.h /usr/include/posix1_lim.h setflags.o : setflags.c /usr/include/errno.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/linux/errno.h /usr/include/sys/ioctl.h /usr/include/linux/ioctl.h \ - /usr/include/termios.h /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/linux/termios.h \ - /usr/include/linux/ext2_fs.h e2p.h /usr/include/dirent.h /usr/include/gnu/types.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/linux/limits.h \ - /usr/include/linux/dirent.h /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h + /usr/include/termios.h /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/asm/types.h \ + /usr/include/linux/termios.h /usr/include/linux/ext2_fs.h e2p.h /usr/include/dirent.h \ + /usr/include/gnu/types.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ + /usr/include/linux/limits.h /usr/include/linux/dirent.h /usr/include/posix1_lim.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h setversion.o : setversion.c /usr/include/errno.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/linux/errno.h /usr/include/sys/ioctl.h /usr/include/linux/ioctl.h \ - /usr/include/termios.h /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/linux/termios.h \ - /usr/include/linux/ext2_fs.h e2p.h /usr/include/dirent.h /usr/include/gnu/types.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/linux/limits.h \ - /usr/include/linux/dirent.h /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h + /usr/include/termios.h /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/asm/types.h \ + /usr/include/linux/termios.h /usr/include/linux/ext2_fs.h e2p.h /usr/include/dirent.h \ + /usr/include/gnu/types.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ + /usr/include/linux/limits.h /usr/include/linux/dirent.h /usr/include/posix1_lim.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h diff --git a/lib/e2p/ChangeLog b/lib/e2p/ChangeLog new file mode 100644 index 00000000..f96ffa82 --- /dev/null +++ b/lib/e2p/ChangeLog @@ -0,0 +1,15 @@ +Mon Nov 7 21:59:12 1994 Remy Card <card@bbj> + + * ls.c (list_super): List the new fields s_def_resuid and + s_def_resgid. + + (print_user): New function which prints the uid and the user name. + + (print_group): New function which prints the gid and the group name. + +Wed Aug 17 21:50:39 1994 Remy Card (card@bbj) + + * pf.c (print_flags): New attributes are recognized and a long + format can be used. + + diff --git a/lib/e2p/Makefile b/lib/e2p/Makefile index e890bb5f..8ade7fa0 100644 --- a/lib/e2p/Makefile +++ b/lib/e2p/Makefile @@ -5,14 +5,14 @@ # This file can be redistributed under the terms of the GNU General # Public License +all:: + include ../../MCONFIG CFLAGS_NO= $(WFLAGS) -I.. CFLAGS= $(OPT) $(CFLAGS_NO) LDFLAGS= $(OPT) -ARCHIVE=ar r -RANLIB=ranlib RM=rm -f MV=mv LN=ln -s @@ -21,12 +21,35 @@ OBJS= fgetflags.o fsetflags.o fgetversion.o fsetversion.o \ getflags.o getversion.o iod.o ls.o pe.o pf.o ps.o \ setflags.o setversion.o +ifdef BUILD_DLL_SHLIBS +DLL_ADDRESS = 0x66980000 +DLL_JUMPSIZE = 0x1000 +DLL_GOTSIZE = 0x1000 +DLL_VERSION = 1.0 +DLL_IMAGE = libe2p +DLL_STUB = libe2p +DLL_MYDIR = e2p +DLL_INSTALL_DIR = $(SHLIBDIR) + +include ../Makefile.dll-lib +endif + .c.o: $(CC) $(CFLAGS) -c $*.c +ifdef BUILD_PROFILE_LIBS $(CC) $(CFLAGS_NO) -pg -o profiled/$*.o -c $*.c +endif +ifdef BUILD_DLL_SHLIBS + (export JUMP_DIR=`pwd`/jump; $(CC) -B$(JUMP_PREFIX) $(CFLAGS) \ + -o jump/$*.o -c $*.c) +endif # $(CC) $(CFLAGS_NO) -checker -g -o checker/$*.o -c $*.c -all: libe2p.a libe2p_p.a +all:: libe2p.a + +ifdef BUILD_PROFILE_LIBS +all:: libe2p_p.a +endif libe2p.a: $(OBJS) $(RM) $@.bak @@ -52,12 +75,21 @@ libe2p_chk.a: $(OBJS) $(RM) ../$@ $(LN) e2p/$@ ../$@ -install: +install:: + +install-libs:: + $(INSTALLLIB) libe2p.a $(LIBDIR)/libe2p.a + $(CHMOD) 644 $(LIBDIR)/libe2p.a + $(RANLIB) $(LIBDIR)/libe2p.a + $(CHMOD) $(LIBMODE) $(LIBDIR)/libe2p.a + +install-tree:: -clean: +clean:: rm -f \#* *.s *.o *.a *~ *.bak core profiled/* checker/* + rm -f ../libe2p.a ../libe2p_p.a -really-clean: clean +really-clean:: clean rm -f .depend dep depend .depend: diff --git a/lib/e2p/e2p.h b/lib/e2p/e2p.h index d459e87d..8ff770f5 100644 --- a/lib/e2p/e2p.h +++ b/lib/e2p/e2p.h @@ -14,7 +14,7 @@ int iterate_on_dir (const char * dir_name, void * private); void list_super (struct ext2_super_block * s); void print_fs_errors (FILE * f, unsigned short errors); -void print_flags (FILE * f, unsigned long flags); +void print_flags (FILE * f, unsigned long flags, int long_format); void print_fs_state (FILE * f, unsigned short state); int setflags (int fd, unsigned long flags); int setversion (int fd, unsigned long version); diff --git a/lib/e2p/jump/jump.funcs b/lib/e2p/jump/jump.funcs new file mode 100644 index 00000000..61a69fb6 --- /dev/null +++ b/lib/e2p/jump/jump.funcs @@ -0,0 +1,13 @@ +00000000 T _fgetflags libe2p jump/fgetflags +00000000 T _fsetflags libe2p jump/fsetflags +00000000 T _fgetversion libe2p jump/fgetversion +00000000 T _fsetversion libe2p jump/fsetversion +00000000 T _getflags libe2p jump/getflags +00000000 T _getversion libe2p jump/getversion +00000000 T _iterate_on_dir libe2p jump/iod +00000000 T _list_super libe2p jump/ls +00000000 T _print_fs_errors libe2p jump/pe +00000000 T _print_flags libe2p jump/pf +00000000 T _print_fs_state libe2p jump/ps +00000000 T _setflags libe2p jump/setflags +00000000 T _setversion libe2p jump/setversion diff --git a/lib/e2p/jump/jump.import b/lib/e2p/jump/jump.import new file mode 100644 index 00000000..51b1fd88 --- /dev/null +++ b/lib/e2p/jump/jump.import @@ -0,0 +1,164 @@ +/usr/lib/libc.sa(__libc.o):00001000 a __GOT_SIZE +/usr/lib/libc.sa(__libc.o):6008f0b0 A _AL +/usr/lib/libc.sa(__libc.o):6008f198 A _AL_PARM +/usr/lib/libc.sa(__libc.o):6008f060 A _AM +/usr/lib/libc.sa(__libc.o):6008f0b4 A _BC +/usr/lib/libc.sa(__libc.o):6008f064 A _BS +/usr/lib/libc.sa(__libc.o):6008f0bc A _BT +/usr/lib/libc.sa(__libc.o):6008f068 A _CA +/usr/lib/libc.sa(__libc.o):6008f0c0 A _CD +/usr/lib/libc.sa(__libc.o):6008f0c4 A _CE +/usr/lib/libc.sa(__libc.o):6008f0c8 A _CL +/usr/lib/libc.sa(__libc.o):6008f0cc A _CM +/usr/lib/libc.sa(__libc.o):6008f048 A _COLS +/usr/lib/libc.sa(__libc.o):6008f0d0 A _CR +/usr/lib/libc.sa(__libc.o):6008f0d4 A _CS +/usr/lib/libc.sa(__libc.o):6008f06c A _DA +/usr/lib/libc.sa(__libc.o):6008f070 A _DB +/usr/lib/libc.sa(__libc.o):6008f0d8 A _DC +/usr/lib/libc.sa(__libc.o):6008f0dc A _DL +/usr/lib/libc.sa(__libc.o):6008f19c A _DL_PARM +/usr/lib/libc.sa(__libc.o):6008f0e0 A _DM +/usr/lib/libc.sa(__libc.o):6008f0e4 A _DO +/usr/lib/libc.sa(__libc.o):6008f1a4 A _DOWN_PARM +/usr/lib/libc.sa(__libc.o):6008f03c A _Def_term +/usr/lib/libc.sa(__libc.o):6008f0e8 A _ED +/usr/lib/libc.sa(__libc.o):6008f0ec A _EI +/usr/lib/libc.sa(__libc.o):6008f074 A _EO +/usr/lib/libc.sa(__libc.o):6008f1b8 A _GT +/usr/lib/libc.sa(__libc.o):6008f078 A _HC +/usr/lib/libc.sa(__libc.o):6008f118 A _HO +/usr/lib/libc.sa(__libc.o):6008f07c A _HZ +/usr/lib/libc.sa(__libc.o):6008f11c A _IC +/usr/lib/libc.sa(__libc.o):6008f120 A _IM +/usr/lib/libc.sa(__libc.o):6008f080 A _IN +/usr/lib/libc.sa(__libc.o):6008f124 A _IP +/usr/lib/libc.sa(__libc.o):6008f0f0 A _K0 +/usr/lib/libc.sa(__libc.o):6008f0f4 A _K1 +/usr/lib/libc.sa(__libc.o):6008f0f8 A _K2 +/usr/lib/libc.sa(__libc.o):6008f0fc A _K3 +/usr/lib/libc.sa(__libc.o):6008f100 A _K4 +/usr/lib/libc.sa(__libc.o):6008f104 A _K5 +/usr/lib/libc.sa(__libc.o):6008f108 A _K6 +/usr/lib/libc.sa(__libc.o):6008f10c A _K7 +/usr/lib/libc.sa(__libc.o):6008f110 A _K8 +/usr/lib/libc.sa(__libc.o):6008f114 A _K9 +/usr/lib/libc.sa(__libc.o):6008f128 A _KD +/usr/lib/libc.sa(__libc.o):6008f12c A _KE +/usr/lib/libc.sa(__libc.o):6008f130 A _KH +/usr/lib/libc.sa(__libc.o):6008f134 A _KL +/usr/lib/libc.sa(__libc.o):6008f138 A _KR +/usr/lib/libc.sa(__libc.o):6008f13c A _KS +/usr/lib/libc.sa(__libc.o):6008f140 A _KU +/usr/lib/libc.sa(__libc.o):6008f1a8 A _LEFT_PARM +/usr/lib/libc.sa(__libc.o):6008f044 A _LINES +/usr/lib/libc.sa(__libc.o):6008f144 A _LL +/usr/lib/libc.sa(__libc.o):6008f148 A _MA +/usr/lib/libc.sa(__libc.o):6008f300 A _MCAppPath +/usr/lib/libc.sa(__libc.o):6008f084 A _MI +/usr/lib/libc.sa(__libc.o):6008f088 A _MS +/usr/lib/libc.sa(__libc.o):6008f030 A _My_term +/usr/lib/libc.sa(__libc.o):6008f08c A _NC +/usr/lib/libc.sa(__libc.o):6008f14c A _ND +/usr/lib/libc.sa(__libc.o):6008f150 A _NL +/usr/lib/libc.sa(__libc.o):6008f1bc A _NONL +/usr/lib/libc.sa(__libc.o):6008f090 A _NS +/usr/lib/libc.sa(__libc.o):6008f094 A _OS +/usr/lib/libc.sa(__libc.o):6008f1b0 A _PC +/usr/lib/libc.sa(__libc.o):6008f154 A _RC +/usr/lib/libc.sa(__libc.o):6008f1ac A _RIGHT_PARM +/usr/lib/libc.sa(__libc.o):6008f158 A _SC +/usr/lib/libc.sa(__libc.o):6008f15c A _SE +/usr/lib/libc.sa(__libc.o):6008f160 A _SF +/usr/lib/libc.sa(__libc.o):6008f164 A _SO +/usr/lib/libc.sa(__libc.o):6008f168 A _SR +/usr/lib/libc.sa(__libc.o):6008f16c A _TA +/usr/lib/libc.sa(__libc.o):6008f170 A _TE +/usr/lib/libc.sa(__libc.o):6008f174 A _TI +/usr/lib/libc.sa(__libc.o):6008f178 A _UC +/usr/lib/libc.sa(__libc.o):6008f17c A _UE +/usr/lib/libc.sa(__libc.o):6008f098 A _UL +/usr/lib/libc.sa(__libc.o):6008f180 A _UP +/usr/lib/libc.sa(__libc.o):6008f1c0 A _UPPERCASE +/usr/lib/libc.sa(__libc.o):6008f1a0 A _UP_PARM +/usr/lib/libc.sa(__libc.o):6008f188 A _US +/usr/lib/libc.sa(__libc.o):6008f18c A _VB +/usr/lib/libc.sa(__libc.o):6008f194 A _VE +/usr/lib/libc.sa(__libc.o):6008f190 A _VS +/usr/lib/libc.sa(__libc.o):6008f09c A _XB +/usr/lib/libc.sa(__libc.o):6008f0a0 A _XN +/usr/lib/libc.sa(__libc.o):6008f0a8 A _XS +/usr/lib/libc.sa(__libc.o):6008f0a4 A _XT +/usr/lib/libc.sa(__libc.o):6008f0ac A _XX +/usr/lib/libc.sa(__libc.o):6008f2a4 A __IO_file_jumps +/usr/lib/libc.sa(__libc.o):6008f1f4 A __IO_list_all +/usr/lib/libc.sa(__libc.o):6008f2a8 A __IO_proc_jumps +/usr/lib/libc.sa(__libc.o):6008f1ec A __IO_stderr_ +/usr/lib/libc.sa(__libc.o):6008f1e4 A __IO_stdin_ +/usr/lib/libc.sa(__libc.o):6008f1e8 A __IO_stdout_ +/usr/lib/libc.sa(__libc.o):6008f2ac A __IO_str_jumps +/usr/lib/libc.sa(__libc.o):6008f214 A ____brk_addr +/usr/lib/libc.sa(__libc.o):6008f01c A ___ctype_b +/usr/lib/libc.sa(__libc.o):6008f020 A ___ctype_tolower +/usr/lib/libc.sa(__libc.o):6008f024 A ___ctype_toupper +/usr/lib/libc.sa(__libc.o):6008f1fc A ___environ +/usr/lib/libc.sa(__libc.o):6008f250 A ___exit_funcs +/usr/lib/libc.sa(__libc.o):6008f2f0 A ___glob_closedir_hook +/usr/lib/libc.sa(__libc.o):6008f2f4 A ___glob_opendir_hook +/usr/lib/libc.sa(__libc.o):6008f2f8 A ___glob_readdir_hook +/usr/lib/libc.sa(__libc.o):6008f278 A ___ttyname +/usr/lib/libc.sa(__libc.o):6008f238 A __collate_info +/usr/lib/libc.sa(__libc.o):6008f23c A __ctype_info +/usr/lib/libc.sa(__libc.o):6008f028 A __echoit +/usr/lib/libc.sa(__libc.o):6008f034 A __endwin +/usr/lib/libc.sa(__libc.o):6008f288 A __gdbm_fetch_val +/usr/lib/libc.sa(__libc.o):6008f280 A __gdbm_file +/usr/lib/libc.sa(__libc.o):6008f284 A __gdbm_memory +/usr/lib/libc.sa(__libc.o):6008f240 A __monetary_info +/usr/lib/libc.sa(__libc.o):6008f234 A __null_auth +/usr/lib/libc.sa(__libc.o):6008f244 A __numeric_info +/usr/lib/libc.sa(__libc.o):6008f2ec A __obstack +/usr/lib/libc.sa(__libc.o):6008f1c8 A __pfast +/usr/lib/libc.sa(__libc.o):6008f02c A __rawmode +/usr/lib/libc.sa(__libc.o):6008f1dc A __res +/usr/lib/libc.sa(__libc.o):6008f04c A __res_iflg +/usr/lib/libc.sa(__libc.o):6008f050 A __res_lflg +/usr/lib/libc.sa(__libc.o):6008f270 A __res_opcodes +/usr/lib/libc.sa(__libc.o):6008f274 A __res_resultcodes +/usr/lib/libc.sa(__libc.o):6008f248 A __response_info +/usr/lib/libc.sa(__libc.o):6008f2fc A __sigintr +/usr/lib/libc.sa(__libc.o):6008f00c A __sys_errlist +/usr/lib/libc.sa(__libc.o):6008f010 A __sys_nerr +/usr/lib/libc.sa(__libc.o):6008f014 A __sys_siglist +/usr/lib/libc.sa(__libc.o):6008f24c A __time_info +/usr/lib/libc.sa(__libc.o):6008f05c A __tty +/usr/lib/libc.sa(__libc.o):6008f040 A __tty_ch +/usr/lib/libc.sa(__libc.o):6008f1cc A __unctrl +/usr/lib/libc.sa(__libc.o):6008f27c A __win +/usr/lib/libc.sa(__libc.o):6008f058 A _curscr +/usr/lib/libc.sa(__libc.o):6008f228 A _daylight +/usr/lib/libc.sa(__libc.o):6008f200 A _errno +/usr/lib/libc.sa(__libc.o):6008f1d0 A _gdbm_errno +/usr/lib/libc.sa(__libc.o):6008f28c A _gdbm_version +/usr/lib/libc.sa(__libc.o):6008f008 A _h_errlist +/usr/lib/libc.sa(__libc.o):6008f1d8 A _h_errno +/usr/lib/libc.sa(__libc.o):6008f2a0 A _h_nerr +/usr/lib/libc.sa(__libc.o):6008f1c4 A _normtty +/usr/lib/libc.sa(__libc.o):6008f204 A _optarg +/usr/lib/libc.sa(__libc.o):6008f20c A _opterr +/usr/lib/libc.sa(__libc.o):6008f208 A _optind +/usr/lib/libc.sa(__libc.o):6008f2e4 A _optopt +/usr/lib/libc.sa(__libc.o):6008f218 A _ospeed +/usr/lib/libc.sa(__libc.o):6008f26c A _re_max_failures +/usr/lib/libc.sa(__libc.o):6008f210 A _re_syntax_options +/usr/lib/libc.sa(__libc.o):6008f1e0 A _rexecoptions +/usr/lib/libc.sa(__libc.o):6008f230 A _rpc_createerr +/usr/lib/libc.sa(__libc.o):6008f25c A _stderr +/usr/lib/libc.sa(__libc.o):6008f254 A _stdin +/usr/lib/libc.sa(__libc.o):6008f258 A _stdout +/usr/lib/libc.sa(__libc.o):6008f054 A _stdscr +/usr/lib/libc.sa(__libc.o):6008f2e8 A _svc_fdset +/usr/lib/libc.sa(__libc.o):6008f224 A _timezone +/usr/lib/libc.sa(__libc.o):6008f21c A _tputs_baud_rate +/usr/lib/libc.sa(__libc.o):6008f038 A _ttytype +/usr/lib/libc.sa(__libc.o):6008f220 A _tzname diff --git a/lib/e2p/jump/jump.params b/lib/e2p/jump/jump.params new file mode 100644 index 00000000..7d3efe93 --- /dev/null +++ b/lib/e2p/jump/jump.params @@ -0,0 +1,6 @@ +Name=libe2p +Text=0x66980000 +Data=0x00000000 +Jump=0x00001000 +GOT=0x00001000 +Version=1.0.0 diff --git a/lib/e2p/jump/jump.undefs b/lib/e2p/jump/jump.undefs new file mode 100644 index 00000000..44925621 --- /dev/null +++ b/lib/e2p/jump/jump.undefs @@ -0,0 +1 @@ +66983040 D __NEEDS_SHRLIB_libc_4 diff --git a/lib/e2p/ls.c b/lib/e2p/ls.c index 982f0443..f879a3c6 100644 --- a/lib/e2p/ls.c +++ b/lib/e2p/ls.c @@ -9,13 +9,40 @@ * Public License */ +#include <grp.h> +#include <pwd.h> #include <stdio.h> #include <time.h> +#include <sys/types.h> #include <linux/ext2_fs.h> #include "e2p.h" +static void print_user (unsigned short uid) +{ + struct passwd *pw; + + printf ("%u ", uid); + pw = getpwuid (uid); + if (pw == NULL) + printf ("(user unknown)\n"); + else + printf ("(user %s)\n", pw->pw_name); +} + +static void print_group (unsigned short gid) +{ + struct group *gr; + + printf ("%u ", gid); + gr = getgrgid (gid); + if (gr == NULL) + printf ("(group unknown)\n"); + else + printf ("(group %s)\n", gr->gr_name); +} + void list_super (struct ext2_super_block * s) { printf ("Filesystem magic number: 0x%04X\n", s->s_magic); @@ -49,4 +76,10 @@ void list_super (struct ext2_super_block * s) next = s->s_lastcheck + s->s_checkinterval; printf ("Next check after: %s", ctime (&next)); } +#ifdef EXT2_DEF_RESUID + printf ("Reserved blocks uid: "); + print_user (s->s_def_resuid); + printf ("Reserved blocks gid: "); + print_group (s->s_def_resuid); +#endif } diff --git a/lib/e2p/pf.c b/lib/e2p/pf.c index 58f05de1..e4f072f2 100644 --- a/lib/e2p/pf.c +++ b/lib/e2p/pf.c @@ -19,22 +19,69 @@ #include "e2p.h" -void print_flags (FILE * f, unsigned long flags) +static const unsigned long flags_array[] = { + EXT2_SECRM_FL, + EXT2_UNRM_FL, + EXT2_COMPR_FL, + EXT2_SYNC_FL, +#ifdef EXT2_IMMUTABLE_FL + EXT2_IMMUTABLE_FL, +#endif +#ifdef EXT2_APPEND_FL + EXT2_APPEND_FL, +#endif +#ifdef EXT2_NODUMP_FL + EXT2_NODUMP_FL, +#endif + 0}; + +static const char * short_flags[] = { + "s", + "u", + "c", + "S", +#ifdef EXT2_IMMUTABLE_FL + "i", +#endif +#ifdef EXT2_APPEND_FL + "a", +#endif +#ifdef EXT2_NODUMP_FL + "d", +#endif + NULL}; + +static const char * long_flags[] = { + "Secure_Deletion, ", + "Undelete, ", + "Compressed_File, ", + "Synchronous_Updates, ", +#ifdef EXT2_IMMUTABLE_FL + "Immutable, ", +#endif +#ifdef EXT2_NODUMP_FL + "Append_Only, ", +#endif +#ifdef EXT2_NODUMP_FL + "No_Dump, ", +#endif + NULL}; + +void print_flags (FILE * f, unsigned long flags, int long_format) { - if (flags & EXT2_SYNC_FL) - fprintf (f, "S"); - else - fprintf (f, "-"); - if (flags & EXT2_COMPR_FL) - fprintf (f, "c"); - else - fprintf (f, "-"); - if (flags & EXT2_SECRM_FL) - fprintf (f, "s"); - else - fprintf (f, "-"); - if (flags & EXT2_UNRM_FL) - fprintf (f, "u"); + int i; + const char ** flags_names; + + if (long_format) + flags_names = long_flags; else - fprintf (f, "-"); + flags_names = short_flags; + + for (i = 0; flags_array[i] != 0; i++) + { + if (flags & flags_array[i]) + fprintf (f, flags_names[i]); + else + fprintf (f, "-"); + } } diff --git a/lib/et/.depend b/lib/et/.depend index c0ebdfbd..2556ee49 100644 --- a/lib/et/.depend +++ b/lib/et/.depend @@ -1,13 +1,17 @@ com_err.o : com_err.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ - /usr/include/libio.h /usr/include/_G_config.h mit-sipb-copyright.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ - error_table.h internal.h /usr/include/errno.h /usr/include/linux/errno.h com_err.h + /usr/include/libio.h /usr/include/_G_config.h com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ + mit-sipb-copyright.h error_table.h internal.h /usr/include/errno.h /usr/include/linux/errno.h error_message.o : error_message.c /usr/include/stdio.h /usr/include/features.h \ /usr/include/sys/cdefs.h /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h error_table.h mit-sipb-copyright.h \ - internal.h /usr/include/errno.h /usr/include/linux/errno.h + /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/errno.h /usr/include/linux/errno.h \ + com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h error_table.h mit-sipb-copyright.h \ + internal.h et_name.o : et_name.c error_table.h mit-sipb-copyright.h internal.h /usr/include/errno.h \ /usr/include/features.h /usr/include/sys/cdefs.h /usr/include/linux/errno.h init_et.o : init_et.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ - /usr/include/libio.h /usr/include/_G_config.h error_table.h mit-sipb-copyright.h + /usr/include/libio.h /usr/include/_G_config.h /usr/include/errno.h /usr/include/linux/errno.h \ + /usr/include/stdlib.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ + error_table.h mit-sipb-copyright.h vfprintf.o : vfprintf.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/libio.h /usr/include/_G_config.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/varargs.h diff --git a/lib/et/ChangeLog b/lib/et/ChangeLog new file mode 100644 index 00000000..3c372243 --- /dev/null +++ b/lib/et/ChangeLog @@ -0,0 +1,9 @@ +Mon Nov 7 21:17:48 1994 Remy Card <card@bbj> + + * Makefile: Added a dummy install target in case shared libraries + are not built. + +Thu Sep 8 22:33:33 1994 (tytso@rsx-11) + + * com_err.c (default_com_err_proc): Reversed order of \n\r to make + jik happy. diff --git a/lib/et/Makefile b/lib/et/Makefile index 6b4cd476..2dcf1ef1 100644 --- a/lib/et/Makefile +++ b/lib/et/Makefile @@ -1,19 +1,42 @@ +# +# Makefile for lib/et +# + +all:: compile_et libcom_err.a + include ../../MCONFIG -ARCHIVE=ar r -RANLIB=ranlib +OBJS= error_message.o et_name.o init_et.o com_err.o +SRCS = error_message.c et_name.c init_et.c com_err.c + +HFILES= com_err.h + +ifdef BUILD_PROFILE_LIBS +all:: libcom_err_p.a +endif + +ifdef BUILD_DLL_SHLIBS +DLL_ADDRESS = 0x66800000 +DLL_JUMPSIZE = 0x1000 +DLL_GOTSIZE = 0x1000 +DLL_VERSION = 1.0 +DLL_IMAGE = libet +DLL_STUB = libcom_err +DLL_MYDIR = et +DLL_INSTALL_DIR = $(SHLIBDIR) + +include ../Makefile.dll-lib +endif + RM=rm -f MV=mv LN=ln -s TAGS=etags -CFLAGS_NO= -CFLAGS= $(CFLAGS_NO) $(OPT) - -OBJS= error_message.o et_name.o init_et.o com_err.o -SRCS = error_message.c et_name.c init_et.c com_err.c +DEFS= -DHAS_STDLIB_H -HFILES= com_err.h +CFLAGS_NO= $(WFLAGS) $(DEFS) +CFLAGS= $(CFLAGS_NO) $(OPT) # # what to build... @@ -21,9 +44,14 @@ HFILES= com_err.h .c.o: $(CC) $(CFLAGS) -c $*.c +ifdef BUILD_PROFILE_LIBS $(CC) $(CFLAGS_NO) -g -pg -o profiled/$*.o -c $*.c +endif +ifdef BUILD_DLL_SHLIBS + (export JUMP_DIR=`pwd`/jump; $(CC) -B$(JUMP_PREFIX) $(CFLAGS) \ + -o jump/$*.o -c $*.c) +endif -all: compile_et libcom_err.a libcom_err_p.a compile_et: compile_et.sh ./config_script compile_et.sh $(AWK) > compile_et @@ -45,27 +73,32 @@ libcom_err_p.a: $(OBJS) $(RM) ../$@ $(LN) et/$@ ../$@ -clean: +clean:: $(RM) compile_et libcom_err.a libcom_err_p.a $(RM) $(OBJS) profiled/* $(RM) *~ \#* *.bak *.otl *.aux *.toc *.PS *.dvi *.ps TAGS *.ln + $(RM) ../libcom_err.a ../libcom_err_p.a -really-clean: clean +really-clean:: clean $(RM) .depend -install:: libcom_err.a - $(INSTALLLIB) libcom_err.a $(DESTDIR)$(LIBDIR)/libcom_err.a - $(CHMOD) 644 $(DESTDIR)$(LIBDIR)/libcom_err.a - $(RANLIB) $(DESTDIR)$(LIBDIR)/libcom_err.a - $(CHMOD) $(LIBMODE) $(DESTDIR)$(LIBDIR)/libcom_err.a +install-libs:: libcom_err.a + $(INSTALLLIB) libcom_err.a $(LIBDIR)/libcom_err.a + $(CHMOD) 644 $(LIBDIR)/libcom_err.a + $(RANLIB) $(LIBDIR)/libcom_err.a + $(CHMOD) $(LIBMODE) $(LIBDIR)/libcom_err.a -install:: $(HFILES) - @rm -rf ${DESTDIR}$(INCLDIR)/et - @mkdir ${DESTDIR}$(INCLDIR)/et +install-libs:: $(HFILES) + @rm -rf $(INCLDIR)/et + @mkdir $(INCLDIR)/et for i in $(HFILES); do \ - $(INSTALLINC) $$i ${DESTDIR}$(INCLDIR)/et/$$i; \ + $(INSTALLINC) $$i $(INCLDIR)/et/$$i; \ done +install-tree:: + +install:: + ## com_err.ps : com_err.dvi diff --git a/lib/et/com_err.c b/lib/et/com_err.c index 9f4ba5fa..8ee332a3 100644 --- a/lib/et/com_err.c +++ b/lib/et/com_err.c @@ -5,42 +5,24 @@ */ #include <stdio.h> +#include "com_err.h" #include "mit-sipb-copyright.h" - -#if __STDC__ || defined(STDARG_PROTOTYPES) -#include <stdarg.h> -#else -#include <varargs.h> -#define VARARGS -#endif - #include "error_table.h" #include "internal.h" -#ifdef notdef -/* - * Protect us from header version (externally visible) of com_err, so - * we can survive in a <varargs.h> environment. I think. - */ -#define com_err com_err_external -#include "com_err.h" -#undef com_err -#else -#include "com_err.h" +#if !defined(__STDC__) && !defined(STDARG_PROTOTYPES) +#include <varargs.h> +#define VARARGS #endif -#if ! lint -static const char rcsid[] = - "$Header$"; -#endif /* ! lint */ - static void #ifdef __STDC__ - default_com_err_proc (const char *whoami, long code, const char *fmt, va_list args) + default_com_err_proc (const char *whoami, errcode_t code, const + char *fmt, va_list args) #else default_com_err_proc (whoami, code, fmt, args) const char *whoami; - long code; + errcode_t code; const char *fmt; va_list args; #endif @@ -56,32 +38,37 @@ static void if (fmt) { vfprintf (stderr, fmt, args); } - putc('\n', stderr); /* should do this only on a tty in raw mode */ putc('\r', stderr); + putc('\n', stderr); fflush(stderr); } #ifdef __STDC__ -typedef void (*errf) (const char *, long, const char *, va_list); +typedef void (*errf) (const char *, errcode_t, const char *, va_list); #else typedef void (*errf) (); #endif errf com_err_hook = default_com_err_proc; +#ifdef __STDC__ +void com_err_va (const char *whoami, errcode_t code, const char *fmt, + va_list args) +#else void com_err_va (whoami, code, fmt, args) const char *whoami; - long code; + errcode_t code; const char *fmt; va_list args; +#endif { (*com_err_hook) (whoami, code, fmt, args); } #ifndef VARARGS void com_err (const char *whoami, - long code, + errcode_t code, const char *fmt, ...) { #else @@ -89,7 +76,7 @@ void com_err (va_alist) va_dcl { const char *whoami, *fmt; - long code; + errcode_t code; #endif va_list pvar; @@ -98,7 +85,7 @@ void com_err (va_alist) #ifdef VARARGS va_start (pvar); whoami = va_arg (pvar, const char *); - code = va_arg (pvar, long); + code = va_arg (pvar, errcode_t); fmt = va_arg (pvar, const char *); #else va_start(pvar, fmt); diff --git a/lib/et/com_err.h b/lib/et/com_err.h index 54904c35..f28dce88 100644 --- a/lib/et/com_err.h +++ b/lib/et/com_err.h @@ -13,25 +13,27 @@ typedef long errcode_t; #ifdef __STDC__ -#ifndef __HIGHC__ /* gives us STDC but not stdarg */ #include <stdarg.h> -#else -#include <varargs.h> -#endif + /* ANSI C -- use prototypes etc */ void com_err (const char *, long, const char *, ...); +void com_err_va (const char *whoami, errcode_t code, const char *fmt, + va_list args); char const *error_message (long); -void (*com_err_hook) (const char *, long, const char *, va_list); +extern void (*com_err_hook) (const char *, long, const char *, va_list); void (*set_com_err_hook (void (*) (const char *, long, const char *, va_list))) (const char *, long, const char *, va_list); void (*reset_com_err_hook (void)) (const char *, long, const char *, va_list); +int init_error_table(const char * const *msgs, int base, int count); #else /* no prototypes */ void com_err (); +void com_err_va (); char *error_message (); -void (*com_err_hook) (); +extern void (*com_err_hook) (); void (*set_com_err_hook ()) (); void (*reset_com_err_hook ()) (); +int init_error_table(); #endif #define __COM_ERR_H diff --git a/lib/et/error_message.c b/lib/et/error_message.c index 043b02eb..c6c2b397 100644 --- a/lib/et/error_message.c +++ b/lib/et/error_message.c @@ -11,21 +11,23 @@ #include <stdio.h> #include <string.h> +#include <errno.h> +#include "com_err.h" #include "error_table.h" #include "mit-sipb-copyright.h" #include "internal.h" -static const char rcsid[] = - "$Header$"; -static const char copyright[] = - "Copyright 1986, 1987, 1988 by the Student Information Processing Board\nand the department of Information Systems\nof the Massachusetts Institute of Technology"; - static char buffer[25]; struct et_list * _et_list = (struct et_list *) NULL; + +#ifdef __STDC__ +const char * error_message (errcode_t code) +#else const char * error_message (code) -long code; + errcode_t code; +#endif { int offset; struct et_list *et; @@ -36,10 +38,18 @@ long code; offset = code & ((1<<ERRCODE_RANGE)-1); table_num = code - offset; if (!table_num) { +#ifdef HAS_SYS_ERRLIST if (offset < sys_nerr) return(sys_errlist[offset]); else goto oops; +#else + cp = strerror(offset); + if (cp) + return(cp); + else + goto oops; +#endif } for (et = _et_list; et; et = et->next) { if (et->table->base == table_num) { diff --git a/lib/et/error_table.h b/lib/et/error_table.h index 78f7db20..31971f03 100644 --- a/lib/et/error_table.h +++ b/lib/et/error_table.h @@ -10,7 +10,7 @@ #ifndef __STDC__ #define const #endif -extern int errno; + struct error_table { char const * const * msgs; long base; @@ -25,6 +25,11 @@ extern struct et_list * _et_list; #define ERRCODE_RANGE 8 /* # of bits to shift table number */ #define BITS_PER_CHAR 6 /* # bits to shift per character in name */ +#ifdef __STDC__ +extern const char *error_table_name(int num); +#else extern const char *error_table_name(); +#endif + #define _ET_H #endif diff --git a/lib/et/et_name.c b/lib/et/et_name.c index 19da71d3..db4099fa 100644 --- a/lib/et/et_name.c +++ b/lib/et/et_name.c @@ -8,13 +8,6 @@ #include "mit-sipb-copyright.h" #include "internal.h" -#ifndef lint -static const char copyright[] = - "Copyright 1987,1988 by Student Information Processing Board, Massachusetts Institute of Technology"; -static const char rcsid_et_name_c[] = - "$Header$"; -#endif - static const char char_set[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"; diff --git a/lib/et/init_et.c b/lib/et/init_et.c index 856f0fdc..8e5af844 100644 --- a/lib/et/init_et.c +++ b/lib/et/init_et.c @@ -10,6 +10,11 @@ */ #include <stdio.h> +#include <errno.h> +#ifdef HAS_STDLIB_H +#include <stdlib.h> +#endif +#include "com_err.h" #include "error_table.h" #include "mit-sipb-copyright.h" @@ -17,13 +22,6 @@ #define const #endif -#ifndef lint -static const char rcsid_init_et_c[] = - "$Header$"; -#endif - -extern char *malloc(), *realloc(); - struct foobar { struct et_list etl; struct error_table et; @@ -31,10 +29,14 @@ struct foobar { extern struct et_list * _et_list; +#ifdef __STDC__ +int init_error_table(const char * const *msgs, int base, int count) +#else int init_error_table(msgs, base, count) const char * const * msgs; int base; int count; +#endif { struct foobar * new_et; @@ -43,7 +45,7 @@ int init_error_table(msgs, base, count) new_et = (struct foobar *) malloc(sizeof(struct foobar)); if (!new_et) - return errno; /* oops */ + return ENOMEM; /* oops */ new_et->etl.table = &new_et->et; new_et->et.msgs = msgs; new_et->et.base = base; diff --git a/lib/et/jump/jump.funcs b/lib/et/jump/jump.funcs new file mode 100644 index 00000000..c5cdbc41 --- /dev/null +++ b/lib/et/jump/jump.funcs @@ -0,0 +1,6 @@ +00000000 T _error_message libcom_err jump/error_message +00000000 T _init_error_table libcom_err jump/init_et +00000000 T _com_err_va libcom_err jump/com_err +00000000 T _com_err libcom_err jump/com_err +00000000 T _set_com_err_hook libcom_err jump/com_err +00000000 T _reset_com_err_hook libcom_err jump/com_err diff --git a/lib/et/jump/jump.ignore b/lib/et/jump/jump.ignore new file mode 100644 index 00000000..0bcb5519 --- /dev/null +++ b/lib/et/jump/jump.ignore @@ -0,0 +1 @@ +00000000 T _error_table_name libxyzzy jump/et_name diff --git a/lib/et/jump/jump.import b/lib/et/jump/jump.import new file mode 100644 index 00000000..51b1fd88 --- /dev/null +++ b/lib/et/jump/jump.import @@ -0,0 +1,164 @@ +/usr/lib/libc.sa(__libc.o):00001000 a __GOT_SIZE +/usr/lib/libc.sa(__libc.o):6008f0b0 A _AL +/usr/lib/libc.sa(__libc.o):6008f198 A _AL_PARM +/usr/lib/libc.sa(__libc.o):6008f060 A _AM +/usr/lib/libc.sa(__libc.o):6008f0b4 A _BC +/usr/lib/libc.sa(__libc.o):6008f064 A _BS +/usr/lib/libc.sa(__libc.o):6008f0bc A _BT +/usr/lib/libc.sa(__libc.o):6008f068 A _CA +/usr/lib/libc.sa(__libc.o):6008f0c0 A _CD +/usr/lib/libc.sa(__libc.o):6008f0c4 A _CE +/usr/lib/libc.sa(__libc.o):6008f0c8 A _CL +/usr/lib/libc.sa(__libc.o):6008f0cc A _CM +/usr/lib/libc.sa(__libc.o):6008f048 A _COLS +/usr/lib/libc.sa(__libc.o):6008f0d0 A _CR +/usr/lib/libc.sa(__libc.o):6008f0d4 A _CS +/usr/lib/libc.sa(__libc.o):6008f06c A _DA +/usr/lib/libc.sa(__libc.o):6008f070 A _DB +/usr/lib/libc.sa(__libc.o):6008f0d8 A _DC +/usr/lib/libc.sa(__libc.o):6008f0dc A _DL +/usr/lib/libc.sa(__libc.o):6008f19c A _DL_PARM +/usr/lib/libc.sa(__libc.o):6008f0e0 A _DM +/usr/lib/libc.sa(__libc.o):6008f0e4 A _DO +/usr/lib/libc.sa(__libc.o):6008f1a4 A _DOWN_PARM +/usr/lib/libc.sa(__libc.o):6008f03c A _Def_term +/usr/lib/libc.sa(__libc.o):6008f0e8 A _ED +/usr/lib/libc.sa(__libc.o):6008f0ec A _EI +/usr/lib/libc.sa(__libc.o):6008f074 A _EO +/usr/lib/libc.sa(__libc.o):6008f1b8 A _GT +/usr/lib/libc.sa(__libc.o):6008f078 A _HC +/usr/lib/libc.sa(__libc.o):6008f118 A _HO +/usr/lib/libc.sa(__libc.o):6008f07c A _HZ +/usr/lib/libc.sa(__libc.o):6008f11c A _IC +/usr/lib/libc.sa(__libc.o):6008f120 A _IM +/usr/lib/libc.sa(__libc.o):6008f080 A _IN +/usr/lib/libc.sa(__libc.o):6008f124 A _IP +/usr/lib/libc.sa(__libc.o):6008f0f0 A _K0 +/usr/lib/libc.sa(__libc.o):6008f0f4 A _K1 +/usr/lib/libc.sa(__libc.o):6008f0f8 A _K2 +/usr/lib/libc.sa(__libc.o):6008f0fc A _K3 +/usr/lib/libc.sa(__libc.o):6008f100 A _K4 +/usr/lib/libc.sa(__libc.o):6008f104 A _K5 +/usr/lib/libc.sa(__libc.o):6008f108 A _K6 +/usr/lib/libc.sa(__libc.o):6008f10c A _K7 +/usr/lib/libc.sa(__libc.o):6008f110 A _K8 +/usr/lib/libc.sa(__libc.o):6008f114 A _K9 +/usr/lib/libc.sa(__libc.o):6008f128 A _KD +/usr/lib/libc.sa(__libc.o):6008f12c A _KE +/usr/lib/libc.sa(__libc.o):6008f130 A _KH +/usr/lib/libc.sa(__libc.o):6008f134 A _KL +/usr/lib/libc.sa(__libc.o):6008f138 A _KR +/usr/lib/libc.sa(__libc.o):6008f13c A _KS +/usr/lib/libc.sa(__libc.o):6008f140 A _KU +/usr/lib/libc.sa(__libc.o):6008f1a8 A _LEFT_PARM +/usr/lib/libc.sa(__libc.o):6008f044 A _LINES +/usr/lib/libc.sa(__libc.o):6008f144 A _LL +/usr/lib/libc.sa(__libc.o):6008f148 A _MA +/usr/lib/libc.sa(__libc.o):6008f300 A _MCAppPath +/usr/lib/libc.sa(__libc.o):6008f084 A _MI +/usr/lib/libc.sa(__libc.o):6008f088 A _MS +/usr/lib/libc.sa(__libc.o):6008f030 A _My_term +/usr/lib/libc.sa(__libc.o):6008f08c A _NC +/usr/lib/libc.sa(__libc.o):6008f14c A _ND +/usr/lib/libc.sa(__libc.o):6008f150 A _NL +/usr/lib/libc.sa(__libc.o):6008f1bc A _NONL +/usr/lib/libc.sa(__libc.o):6008f090 A _NS +/usr/lib/libc.sa(__libc.o):6008f094 A _OS +/usr/lib/libc.sa(__libc.o):6008f1b0 A _PC +/usr/lib/libc.sa(__libc.o):6008f154 A _RC +/usr/lib/libc.sa(__libc.o):6008f1ac A _RIGHT_PARM +/usr/lib/libc.sa(__libc.o):6008f158 A _SC +/usr/lib/libc.sa(__libc.o):6008f15c A _SE +/usr/lib/libc.sa(__libc.o):6008f160 A _SF +/usr/lib/libc.sa(__libc.o):6008f164 A _SO +/usr/lib/libc.sa(__libc.o):6008f168 A _SR +/usr/lib/libc.sa(__libc.o):6008f16c A _TA +/usr/lib/libc.sa(__libc.o):6008f170 A _TE +/usr/lib/libc.sa(__libc.o):6008f174 A _TI +/usr/lib/libc.sa(__libc.o):6008f178 A _UC +/usr/lib/libc.sa(__libc.o):6008f17c A _UE +/usr/lib/libc.sa(__libc.o):6008f098 A _UL +/usr/lib/libc.sa(__libc.o):6008f180 A _UP +/usr/lib/libc.sa(__libc.o):6008f1c0 A _UPPERCASE +/usr/lib/libc.sa(__libc.o):6008f1a0 A _UP_PARM +/usr/lib/libc.sa(__libc.o):6008f188 A _US +/usr/lib/libc.sa(__libc.o):6008f18c A _VB +/usr/lib/libc.sa(__libc.o):6008f194 A _VE +/usr/lib/libc.sa(__libc.o):6008f190 A _VS +/usr/lib/libc.sa(__libc.o):6008f09c A _XB +/usr/lib/libc.sa(__libc.o):6008f0a0 A _XN +/usr/lib/libc.sa(__libc.o):6008f0a8 A _XS +/usr/lib/libc.sa(__libc.o):6008f0a4 A _XT +/usr/lib/libc.sa(__libc.o):6008f0ac A _XX +/usr/lib/libc.sa(__libc.o):6008f2a4 A __IO_file_jumps +/usr/lib/libc.sa(__libc.o):6008f1f4 A __IO_list_all +/usr/lib/libc.sa(__libc.o):6008f2a8 A __IO_proc_jumps +/usr/lib/libc.sa(__libc.o):6008f1ec A __IO_stderr_ +/usr/lib/libc.sa(__libc.o):6008f1e4 A __IO_stdin_ +/usr/lib/libc.sa(__libc.o):6008f1e8 A __IO_stdout_ +/usr/lib/libc.sa(__libc.o):6008f2ac A __IO_str_jumps +/usr/lib/libc.sa(__libc.o):6008f214 A ____brk_addr +/usr/lib/libc.sa(__libc.o):6008f01c A ___ctype_b +/usr/lib/libc.sa(__libc.o):6008f020 A ___ctype_tolower +/usr/lib/libc.sa(__libc.o):6008f024 A ___ctype_toupper +/usr/lib/libc.sa(__libc.o):6008f1fc A ___environ +/usr/lib/libc.sa(__libc.o):6008f250 A ___exit_funcs +/usr/lib/libc.sa(__libc.o):6008f2f0 A ___glob_closedir_hook +/usr/lib/libc.sa(__libc.o):6008f2f4 A ___glob_opendir_hook +/usr/lib/libc.sa(__libc.o):6008f2f8 A ___glob_readdir_hook +/usr/lib/libc.sa(__libc.o):6008f278 A ___ttyname +/usr/lib/libc.sa(__libc.o):6008f238 A __collate_info +/usr/lib/libc.sa(__libc.o):6008f23c A __ctype_info +/usr/lib/libc.sa(__libc.o):6008f028 A __echoit +/usr/lib/libc.sa(__libc.o):6008f034 A __endwin +/usr/lib/libc.sa(__libc.o):6008f288 A __gdbm_fetch_val +/usr/lib/libc.sa(__libc.o):6008f280 A __gdbm_file +/usr/lib/libc.sa(__libc.o):6008f284 A __gdbm_memory +/usr/lib/libc.sa(__libc.o):6008f240 A __monetary_info +/usr/lib/libc.sa(__libc.o):6008f234 A __null_auth +/usr/lib/libc.sa(__libc.o):6008f244 A __numeric_info +/usr/lib/libc.sa(__libc.o):6008f2ec A __obstack +/usr/lib/libc.sa(__libc.o):6008f1c8 A __pfast +/usr/lib/libc.sa(__libc.o):6008f02c A __rawmode +/usr/lib/libc.sa(__libc.o):6008f1dc A __res +/usr/lib/libc.sa(__libc.o):6008f04c A __res_iflg +/usr/lib/libc.sa(__libc.o):6008f050 A __res_lflg +/usr/lib/libc.sa(__libc.o):6008f270 A __res_opcodes +/usr/lib/libc.sa(__libc.o):6008f274 A __res_resultcodes +/usr/lib/libc.sa(__libc.o):6008f248 A __response_info +/usr/lib/libc.sa(__libc.o):6008f2fc A __sigintr +/usr/lib/libc.sa(__libc.o):6008f00c A __sys_errlist +/usr/lib/libc.sa(__libc.o):6008f010 A __sys_nerr +/usr/lib/libc.sa(__libc.o):6008f014 A __sys_siglist +/usr/lib/libc.sa(__libc.o):6008f24c A __time_info +/usr/lib/libc.sa(__libc.o):6008f05c A __tty +/usr/lib/libc.sa(__libc.o):6008f040 A __tty_ch +/usr/lib/libc.sa(__libc.o):6008f1cc A __unctrl +/usr/lib/libc.sa(__libc.o):6008f27c A __win +/usr/lib/libc.sa(__libc.o):6008f058 A _curscr +/usr/lib/libc.sa(__libc.o):6008f228 A _daylight +/usr/lib/libc.sa(__libc.o):6008f200 A _errno +/usr/lib/libc.sa(__libc.o):6008f1d0 A _gdbm_errno +/usr/lib/libc.sa(__libc.o):6008f28c A _gdbm_version +/usr/lib/libc.sa(__libc.o):6008f008 A _h_errlist +/usr/lib/libc.sa(__libc.o):6008f1d8 A _h_errno +/usr/lib/libc.sa(__libc.o):6008f2a0 A _h_nerr +/usr/lib/libc.sa(__libc.o):6008f1c4 A _normtty +/usr/lib/libc.sa(__libc.o):6008f204 A _optarg +/usr/lib/libc.sa(__libc.o):6008f20c A _opterr +/usr/lib/libc.sa(__libc.o):6008f208 A _optind +/usr/lib/libc.sa(__libc.o):6008f2e4 A _optopt +/usr/lib/libc.sa(__libc.o):6008f218 A _ospeed +/usr/lib/libc.sa(__libc.o):6008f26c A _re_max_failures +/usr/lib/libc.sa(__libc.o):6008f210 A _re_syntax_options +/usr/lib/libc.sa(__libc.o):6008f1e0 A _rexecoptions +/usr/lib/libc.sa(__libc.o):6008f230 A _rpc_createerr +/usr/lib/libc.sa(__libc.o):6008f25c A _stderr +/usr/lib/libc.sa(__libc.o):6008f254 A _stdin +/usr/lib/libc.sa(__libc.o):6008f258 A _stdout +/usr/lib/libc.sa(__libc.o):6008f054 A _stdscr +/usr/lib/libc.sa(__libc.o):6008f2e8 A _svc_fdset +/usr/lib/libc.sa(__libc.o):6008f224 A _timezone +/usr/lib/libc.sa(__libc.o):6008f21c A _tputs_baud_rate +/usr/lib/libc.sa(__libc.o):6008f038 A _ttytype +/usr/lib/libc.sa(__libc.o):6008f220 A _tzname diff --git a/lib/et/jump/jump.params b/lib/et/jump/jump.params new file mode 100644 index 00000000..d88c8c2f --- /dev/null +++ b/lib/et/jump/jump.params @@ -0,0 +1,6 @@ +Name=libet +Text=0x66800000 +Data=0x00000000 +Jump=0x00001000 +GOT=0x00001000 +Version=1.0.0 diff --git a/lib/et/jump/jump.undefs b/lib/et/jump/jump.undefs new file mode 100644 index 00000000..c61658a2 --- /dev/null +++ b/lib/et/jump/jump.undefs @@ -0,0 +1 @@ +66804000 D __NEEDS_SHRLIB_libc_4 diff --git a/lib/et/jump/jump.vars b/lib/et/jump/jump.vars new file mode 100644 index 00000000..c0aad656 --- /dev/null +++ b/lib/et/jump/jump.vars @@ -0,0 +1,2 @@ +00000004 D __et_list libcom_err jump/error_message +00000004 D _com_err_hook libcom_err jump/com_err diff --git a/lib/ext2fs/.depend b/lib/ext2fs/.depend index 653e1916..dd371f65 100644 --- a/lib/ext2fs/.depend +++ b/lib/ext2fs/.depend @@ -1,350 +1,198 @@ alloc.o : alloc.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/libio.h /usr/include/_G_config.h /usr/include/unistd.h /usr/include/posix_opt.h \ /usr/include/gnu/types.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ - /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/stdlib.h /usr/include/errno.h \ - /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ - /usr/include/time.h /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/linux/fs.h \ - /usr/include/linux/linkage.h /usr/include/linux/limits.h /usr/include/linux/wait.h \ - /usr/include/linux/dirent.h /usr/include/linux/vfs.h /usr/include/linux/net.h \ - /usr/include/linux/socket.h /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h \ - /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h \ - /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h \ - /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h \ - /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h \ - /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h \ - /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h \ - /usr/include/linux/sysv_fs_sb.h /usr/include/linux/ext2_fs.h ext2fs.h ../et/com_err.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../ext2fs/io.h ../ext2fs/ext2_err.h \ - ../ext2fs/bitops.h + /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/asm/types.h \ + /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/time.h /usr/include/sys/stat.h /usr/include/linux/stat.h \ + /usr/include/linux/ext2_fs.h ext2fs.h ../et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ + ../ext2fs/io.h ../ext2fs/ext2_err.h ../ext2fs/bitops.h badblocks.o : badblocks.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h \ - /usr/include/linux/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/fcntl.h /usr/include/linux/fcntl.h \ - /usr/include/time.h /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/linux/fs.h \ - /usr/include/linux/linkage.h /usr/include/linux/limits.h /usr/include/linux/wait.h \ - /usr/include/linux/dirent.h /usr/include/linux/vfs.h /usr/include/linux/net.h \ - /usr/include/linux/socket.h /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h \ - /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h \ - /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h \ - /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h \ - /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h \ - /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h \ - /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h \ - /usr/include/linux/sysv_fs_sb.h /usr/include/linux/ext2_fs.h ext2fs.h ../et/com_err.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../ext2fs/io.h ../ext2fs/ext2_err.h \ - ../ext2fs/bitops.h + /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h \ + /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/fcntl.h /usr/include/linux/fcntl.h /usr/include/time.h \ + /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/linux/ext2_fs.h \ + ext2fs.h ../et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ + ../ext2fs/io.h ../ext2fs/ext2_err.h ../ext2fs/bitops.h bb_inode.o : bb_inode.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h \ - /usr/include/linux/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/fcntl.h /usr/include/linux/fcntl.h \ - /usr/include/time.h /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/linux/fs.h \ - /usr/include/linux/linkage.h /usr/include/linux/limits.h /usr/include/linux/wait.h \ - /usr/include/linux/dirent.h /usr/include/linux/vfs.h /usr/include/linux/net.h \ - /usr/include/linux/socket.h /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h \ - /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h \ - /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h \ - /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h \ - /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h \ - /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h \ - /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h \ - /usr/include/linux/sysv_fs_sb.h /usr/include/linux/ext2_fs.h ext2fs.h ../et/com_err.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../ext2fs/io.h ../ext2fs/ext2_err.h \ - ../ext2fs/bitops.h + /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h \ + /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/fcntl.h /usr/include/linux/fcntl.h /usr/include/time.h \ + /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/linux/ext2_fs.h \ + ext2fs.h ../et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ + ../ext2fs/io.h ../ext2fs/ext2_err.h ../ext2fs/bitops.h bitmaps.o : bitmaps.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h \ - /usr/include/linux/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/fcntl.h /usr/include/linux/fcntl.h \ - /usr/include/time.h /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/linux/fs.h \ - /usr/include/linux/linkage.h /usr/include/linux/limits.h /usr/include/linux/wait.h \ - /usr/include/linux/dirent.h /usr/include/linux/vfs.h /usr/include/linux/net.h \ - /usr/include/linux/socket.h /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h \ - /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h \ - /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h \ - /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h \ - /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h \ - /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h \ - /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h \ - /usr/include/linux/sysv_fs_sb.h /usr/include/linux/ext2_fs.h ext2fs.h ../et/com_err.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../ext2fs/io.h ../ext2fs/ext2_err.h \ - ../ext2fs/bitops.h -bitops.o : bitops.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ - /usr/include/libio.h /usr/include/_G_config.h /usr/include/sys/types.h /usr/include/linux/types.h \ - /usr/include/linux/fs.h /usr/include/linux/linkage.h /usr/include/linux/limits.h \ - /usr/include/linux/wait.h /usr/include/linux/dirent.h /usr/include/linux/vfs.h \ - /usr/include/linux/net.h /usr/include/linux/socket.h /usr/include/linux/sockios.h \ - /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h \ - /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h \ - /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h \ - /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h \ - /usr/include/linux/ext_fs_sb.h /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h \ - /usr/include/linux/msdos_fs_sb.h /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h \ - /usr/include/linux/xia_fs_sb.h /usr/include/linux/sysv_fs_sb.h /usr/include/linux/ext2_fs.h \ + /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h \ + /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/fcntl.h /usr/include/linux/fcntl.h /usr/include/time.h \ + /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/linux/ext2_fs.h \ ext2fs.h ../et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ ../ext2fs/io.h ../ext2fs/ext2_err.h ../ext2fs/bitops.h +bitops.o : bitops.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/sys/types.h /usr/include/linux/types.h \ + /usr/include/asm/types.h /usr/include/linux/ext2_fs.h ext2fs.h ../et/com_err.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../ext2fs/io.h ../ext2fs/ext2_err.h \ + ../ext2fs/bitops.h block.o : block.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h \ - /usr/include/linux/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/linux/fs.h /usr/include/linux/linkage.h \ - /usr/include/linux/limits.h /usr/include/linux/wait.h /usr/include/linux/dirent.h \ - /usr/include/linux/vfs.h /usr/include/linux/net.h /usr/include/linux/socket.h \ - /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h \ - /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h \ - /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h \ - /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h \ - /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h /usr/include/linux/ext2_fs_sb.h \ - /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h /usr/include/linux/iso_fs_sb.h \ - /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h /usr/include/linux/sysv_fs_sb.h \ - /usr/include/linux/ext2_fs.h ext2fs.h ../et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ + /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h \ + /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/linux/ext2_fs.h ext2fs.h ../et/com_err.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../ext2fs/io.h ../ext2fs/ext2_err.h \ + ../ext2fs/bitops.h +check_desc.o : check_desc.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ + /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h \ + /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h \ + /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/fcntl.h /usr/include/linux/fcntl.h /usr/include/time.h \ + /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/linux/ext2_fs.h \ + ext2fs.h ../et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ ../ext2fs/io.h ../ext2fs/ext2_err.h ../ext2fs/bitops.h closefs.o : closefs.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/libio.h /usr/include/_G_config.h /usr/include/unistd.h /usr/include/posix_opt.h \ /usr/include/gnu/types.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ - /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/stdlib.h /usr/include/errno.h \ - /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ - /usr/include/time.h /usr/include/linux/fs.h /usr/include/linux/linkage.h /usr/include/linux/limits.h \ - /usr/include/linux/wait.h /usr/include/linux/dirent.h /usr/include/linux/vfs.h \ - /usr/include/linux/net.h /usr/include/linux/socket.h /usr/include/linux/sockios.h \ - /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h \ - /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h \ - /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h \ - /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h \ - /usr/include/linux/ext_fs_sb.h /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h \ - /usr/include/linux/msdos_fs_sb.h /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h \ - /usr/include/linux/xia_fs_sb.h /usr/include/linux/sysv_fs_sb.h /usr/include/linux/ext2_fs.h \ - ext2fs.h ../et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ - ../ext2fs/io.h ../ext2fs/ext2_err.h ../ext2fs/bitops.h + /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/asm/types.h \ + /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/time.h /usr/include/linux/ext2_fs.h ext2fs.h \ + ../et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../ext2fs/io.h \ + ../ext2fs/ext2_err.h ../ext2fs/bitops.h expanddir.o : expanddir.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h \ - /usr/include/linux/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/linux/fs.h /usr/include/linux/linkage.h \ - /usr/include/linux/limits.h /usr/include/linux/wait.h /usr/include/linux/dirent.h \ - /usr/include/linux/vfs.h /usr/include/linux/net.h /usr/include/linux/socket.h \ - /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h \ - /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h \ - /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h \ - /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h \ - /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h /usr/include/linux/ext2_fs_sb.h \ - /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h /usr/include/linux/iso_fs_sb.h \ - /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h /usr/include/linux/sysv_fs_sb.h \ - /usr/include/linux/ext2_fs.h ext2fs.h ../et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ - ../ext2fs/io.h ../ext2fs/ext2_err.h ../ext2fs/bitops.h + /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h \ + /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/linux/ext2_fs.h ext2fs.h ../et/com_err.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../ext2fs/io.h ../ext2fs/ext2_err.h \ + ../ext2fs/bitops.h ext2_err.o : ext2_err.c freefs.o : freefs.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/libio.h /usr/include/_G_config.h /usr/include/unistd.h /usr/include/posix_opt.h \ /usr/include/gnu/types.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ - /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/stdlib.h /usr/include/errno.h \ - /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ - /usr/include/linux/fs.h /usr/include/linux/linkage.h /usr/include/linux/limits.h \ - /usr/include/linux/wait.h /usr/include/linux/dirent.h /usr/include/linux/vfs.h \ - /usr/include/linux/net.h /usr/include/linux/socket.h /usr/include/linux/sockios.h \ - /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h \ - /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h \ - /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h \ - /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h \ - /usr/include/linux/ext_fs_sb.h /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h \ - /usr/include/linux/msdos_fs_sb.h /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h \ - /usr/include/linux/xia_fs_sb.h /usr/include/linux/sysv_fs_sb.h /usr/include/linux/ext2_fs.h \ - ext2fs.h ../et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ - ../ext2fs/io.h ../ext2fs/ext2_err.h ../ext2fs/bitops.h + /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/asm/types.h \ + /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/linux/ext2_fs.h ext2fs.h ../et/com_err.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../ext2fs/io.h ../ext2fs/ext2_err.h \ + ../ext2fs/bitops.h get_pathname.o : get_pathname.c /usr/include/stdio.h /usr/include/features.h \ /usr/include/sys/cdefs.h /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h \ /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/unistd.h /usr/include/posix_opt.h \ /usr/include/gnu/types.h /usr/include/sys/types.h /usr/include/linux/types.h \ - /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ - /usr/include/linux/fs.h /usr/include/linux/linkage.h /usr/include/linux/limits.h \ - /usr/include/linux/wait.h /usr/include/linux/dirent.h /usr/include/linux/vfs.h \ - /usr/include/linux/net.h /usr/include/linux/socket.h /usr/include/linux/sockios.h \ - /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h \ - /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h \ - /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h \ - /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h \ - /usr/include/linux/ext_fs_sb.h /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h \ - /usr/include/linux/msdos_fs_sb.h /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h \ - /usr/include/linux/xia_fs_sb.h /usr/include/linux/sysv_fs_sb.h /usr/include/linux/ext2_fs.h \ + /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/alloca.h /usr/include/linux/ext2_fs.h \ ext2fs.h ../et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ ../ext2fs/io.h ../ext2fs/ext2_err.h ../ext2fs/bitops.h initialize.o : initialize.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h \ - /usr/include/linux/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/fcntl.h /usr/include/linux/fcntl.h \ - /usr/include/time.h /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/linux/fs.h \ - /usr/include/linux/linkage.h /usr/include/linux/limits.h /usr/include/linux/wait.h \ - /usr/include/linux/dirent.h /usr/include/linux/vfs.h /usr/include/linux/net.h \ - /usr/include/linux/socket.h /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h \ - /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h \ - /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h \ - /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h \ - /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h \ - /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h \ - /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h \ - /usr/include/linux/sysv_fs_sb.h /usr/include/linux/ext2_fs.h ext2fs.h ../et/com_err.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../ext2fs/io.h ../ext2fs/ext2_err.h \ - ../ext2fs/bitops.h + /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h \ + /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/fcntl.h /usr/include/linux/fcntl.h /usr/include/time.h \ + /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/linux/ext2_fs.h \ + ext2fs.h ../et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ + ../ext2fs/io.h ../ext2fs/ext2_err.h ../ext2fs/bitops.h inline.o : inline.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h \ - /usr/include/linux/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/fcntl.h /usr/include/linux/fcntl.h \ - /usr/include/time.h /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/linux/fs.h \ - /usr/include/linux/linkage.h /usr/include/linux/limits.h /usr/include/linux/wait.h \ - /usr/include/linux/dirent.h /usr/include/linux/vfs.h /usr/include/linux/net.h \ - /usr/include/linux/socket.h /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h \ - /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h \ - /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h \ - /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h \ - /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h \ - /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h \ - /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h \ - /usr/include/linux/sysv_fs_sb.h /usr/include/linux/ext2_fs.h ext2fs.h ../et/com_err.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../ext2fs/io.h ../ext2fs/ext2_err.h \ - ../ext2fs/bitops.h + /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h \ + /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/fcntl.h /usr/include/linux/fcntl.h /usr/include/time.h \ + /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/linux/ext2_fs.h \ + ext2fs.h ../et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ + ../ext2fs/io.h ../ext2fs/ext2_err.h ../ext2fs/bitops.h inode.o : inode.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h \ - /usr/include/linux/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/sys/stat.h /usr/include/linux/stat.h \ - /usr/include/linux/fs.h /usr/include/linux/linkage.h /usr/include/linux/limits.h \ - /usr/include/linux/wait.h /usr/include/linux/dirent.h /usr/include/linux/vfs.h \ - /usr/include/linux/net.h /usr/include/linux/socket.h /usr/include/linux/sockios.h \ - /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h \ - /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h \ - /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h \ - /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h \ - /usr/include/linux/ext_fs_sb.h /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h \ - /usr/include/linux/msdos_fs_sb.h /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h \ - /usr/include/linux/xia_fs_sb.h /usr/include/linux/sysv_fs_sb.h /usr/include/linux/ext2_fs.h \ + /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h \ + /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/linux/ext2_fs.h \ ext2fs.h ../et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ ../ext2fs/io.h ../ext2fs/ext2_err.h ../ext2fs/bitops.h link.o : link.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h \ - /usr/include/linux/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/linux/fs.h /usr/include/linux/linkage.h \ - /usr/include/linux/limits.h /usr/include/linux/wait.h /usr/include/linux/dirent.h \ - /usr/include/linux/vfs.h /usr/include/linux/net.h /usr/include/linux/socket.h \ - /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h \ - /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h \ - /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h \ - /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h \ - /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h /usr/include/linux/ext2_fs_sb.h \ - /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h /usr/include/linux/iso_fs_sb.h \ - /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h /usr/include/linux/sysv_fs_sb.h \ - /usr/include/linux/ext2_fs.h ext2fs.h ../et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ - ../ext2fs/io.h ../ext2fs/ext2_err.h ../ext2fs/bitops.h + /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h \ + /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/linux/ext2_fs.h ext2fs.h ../et/com_err.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../ext2fs/io.h ../ext2fs/ext2_err.h \ + ../ext2fs/bitops.h +llseek.o : llseek.c /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/asm/types.h \ + /usr/include/errno.h /usr/include/features.h /usr/include/sys/cdefs.h /usr/include/linux/errno.h \ + /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ + /usr/include/linux/unistd.h /usr/include/asm/unistd.h ../et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ + ../ext2fs/io.h mkdir.o : mkdir.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h \ - /usr/include/linux/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/fcntl.h /usr/include/linux/fcntl.h \ - /usr/include/time.h /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/linux/fs.h \ - /usr/include/linux/linkage.h /usr/include/linux/limits.h /usr/include/linux/wait.h \ - /usr/include/linux/dirent.h /usr/include/linux/vfs.h /usr/include/linux/net.h \ - /usr/include/linux/socket.h /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h \ - /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h \ - /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h \ - /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h \ - /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h \ - /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h \ - /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h \ - /usr/include/linux/sysv_fs_sb.h /usr/include/linux/ext2_fs.h ext2fs.h ../et/com_err.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../ext2fs/io.h ../ext2fs/ext2_err.h \ - ../ext2fs/bitops.h + /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h \ + /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/fcntl.h /usr/include/linux/fcntl.h /usr/include/time.h \ + /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/linux/ext2_fs.h \ + ext2fs.h ../et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ + ../ext2fs/io.h ../ext2fs/ext2_err.h ../ext2fs/bitops.h namei.o : namei.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h \ - /usr/include/linux/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/linux/fs.h /usr/include/linux/linkage.h \ - /usr/include/linux/limits.h /usr/include/linux/wait.h /usr/include/linux/dirent.h \ - /usr/include/linux/vfs.h /usr/include/linux/net.h /usr/include/linux/socket.h \ - /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h \ - /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h \ - /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h \ - /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h \ - /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h /usr/include/linux/ext2_fs_sb.h \ - /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h /usr/include/linux/iso_fs_sb.h \ - /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h /usr/include/linux/sysv_fs_sb.h \ - /usr/include/linux/ext2_fs.h ext2fs.h ../et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ - ../ext2fs/io.h ../ext2fs/ext2_err.h ../ext2fs/bitops.h + /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h \ + /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/linux/ext2_fs.h ext2fs.h ../et/com_err.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../ext2fs/io.h ../ext2fs/ext2_err.h \ + ../ext2fs/bitops.h newdir.o : newdir.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h \ - /usr/include/linux/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/linux/fs.h /usr/include/linux/linkage.h \ - /usr/include/linux/limits.h /usr/include/linux/wait.h /usr/include/linux/dirent.h \ - /usr/include/linux/vfs.h /usr/include/linux/net.h /usr/include/linux/socket.h \ - /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h \ - /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h \ - /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h \ - /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h \ - /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h /usr/include/linux/ext2_fs_sb.h \ - /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h /usr/include/linux/iso_fs_sb.h \ - /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h /usr/include/linux/sysv_fs_sb.h \ - /usr/include/linux/ext2_fs.h ext2fs.h ../et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ - ../ext2fs/io.h ../ext2fs/ext2_err.h ../ext2fs/bitops.h + /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h \ + /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/linux/ext2_fs.h ext2fs.h ../et/com_err.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../ext2fs/io.h ../ext2fs/ext2_err.h \ + ../ext2fs/bitops.h openfs.o : openfs.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h \ - /usr/include/linux/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/fcntl.h /usr/include/linux/fcntl.h \ - /usr/include/time.h /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/linux/fs.h \ - /usr/include/linux/linkage.h /usr/include/linux/limits.h /usr/include/linux/wait.h \ - /usr/include/linux/dirent.h /usr/include/linux/vfs.h /usr/include/linux/net.h \ - /usr/include/linux/socket.h /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h \ - /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h \ - /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h \ - /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h \ - /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h \ - /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h \ - /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h \ - /usr/include/linux/sysv_fs_sb.h /usr/include/linux/ext2_fs.h ext2fs.h ../et/com_err.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../ext2fs/io.h ../ext2fs/ext2_err.h \ - ../ext2fs/bitops.h + /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h \ + /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/fcntl.h /usr/include/linux/fcntl.h /usr/include/time.h \ + /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/linux/ext2_fs.h \ + ext2fs.h ../et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ + ../ext2fs/io.h ../ext2fs/ext2_err.h ../ext2fs/bitops.h read_bb.o : read_bb.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h \ - /usr/include/linux/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/fcntl.h /usr/include/linux/fcntl.h \ - /usr/include/time.h /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/linux/fs.h \ - /usr/include/linux/linkage.h /usr/include/linux/limits.h /usr/include/linux/wait.h \ - /usr/include/linux/dirent.h /usr/include/linux/vfs.h /usr/include/linux/net.h \ - /usr/include/linux/socket.h /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h \ - /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h \ - /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h \ - /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h \ - /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h \ - /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h \ - /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h \ - /usr/include/linux/sysv_fs_sb.h /usr/include/linux/ext2_fs.h ext2fs.h ../et/com_err.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../ext2fs/io.h ../ext2fs/ext2_err.h \ - ../ext2fs/bitops.h + /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h \ + /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/fcntl.h /usr/include/linux/fcntl.h /usr/include/time.h \ + /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/linux/ext2_fs.h \ + ext2fs.h ../et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ + ../ext2fs/io.h ../ext2fs/ext2_err.h ../ext2fs/bitops.h read_bb_file.o : read_bb_file.c /usr/include/stdio.h /usr/include/features.h \ /usr/include/sys/cdefs.h /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h \ /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/unistd.h /usr/include/posix_opt.h \ /usr/include/gnu/types.h /usr/include/sys/types.h /usr/include/linux/types.h \ - /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ - /usr/include/fcntl.h /usr/include/linux/fcntl.h /usr/include/time.h /usr/include/sys/stat.h \ - /usr/include/linux/stat.h /usr/include/linux/fs.h /usr/include/linux/linkage.h \ - /usr/include/linux/limits.h /usr/include/linux/wait.h /usr/include/linux/dirent.h \ - /usr/include/linux/vfs.h /usr/include/linux/net.h /usr/include/linux/socket.h \ - /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h \ - /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h \ - /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h \ - /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h \ - /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h /usr/include/linux/ext2_fs_sb.h \ - /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h /usr/include/linux/iso_fs_sb.h \ - /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h /usr/include/linux/sysv_fs_sb.h \ + /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/alloca.h /usr/include/fcntl.h \ + /usr/include/linux/fcntl.h /usr/include/time.h /usr/include/sys/stat.h /usr/include/linux/stat.h \ /usr/include/linux/ext2_fs.h ext2fs.h ../et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ ../ext2fs/io.h ../ext2fs/ext2_err.h ../ext2fs/bitops.h +rw_bitmaps.o : rw_bitmaps.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ + /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h \ + /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h \ + /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/fcntl.h /usr/include/linux/fcntl.h /usr/include/time.h \ + /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/linux/ext2_fs.h \ + ext2fs.h ../et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ + ../ext2fs/io.h ../ext2fs/ext2_err.h ../ext2fs/bitops.h unix_io.o : unix_io.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h \ - /usr/include/linux/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/fcntl.h /usr/include/linux/fcntl.h \ - /usr/include/time.h /usr/include/sys/stat.h /usr/include/linux/stat.h ../et/com_err.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ext2_err.h io.h + /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h \ + /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/fcntl.h /usr/include/linux/fcntl.h /usr/include/time.h \ + /usr/include/sys/stat.h /usr/include/linux/stat.h ../et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ + ext2_err.h io.h diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog new file mode 100644 index 00000000..5fd3bfed --- /dev/null +++ b/lib/ext2fs/ChangeLog @@ -0,0 +1,155 @@ +Sat Mar 11 14:07:11 1995 Theodore Y. Ts'o <tytso@localhost> + + * llseek.c (ext2_llseek): Added error checking to the llseek() + compat code to protect against overflow. This only + applies to 1.0 and early 1.1 kernels, which don't support + the llseek() system call. + +Thu Nov 24 16:29:00 1994 Theodore Y. Ts'o (tytso@rt-11) + + * unix_io.c (unix_open): Initialize the read_error and write_error + io_channel pointers to be null. + + * bb_inode.c (clear_bad_block_proc): If an illegal block number is + found, clear it but don't try to update the filesystem + accounting information, since that's hopeless anyway. + + * block.c (bloblock_iterate_ind, bloblock_iterate_dind, + bloblock_iterate_tind): Check to see if the indirect blocks are + valid before trying to read them. + + * ext2_err.et (EXT2_ET_BAD_IND_BLOCK, EX2_ET_BAD_DIND_BLOCK, + EXT2_ET_BAD_TIND_BLOCK): Add new error codes. + + * bitops.h (ext2fs_mark_block_bitmap, ext2fs_unmark_block_bitmap, + ext2fs_test_block_bitmap, ext2fs_mark_inode_bitmap, + ext2fs_unmark_inode_bitmap, ext2fs_test_inode_bitmap): If an + illegal block or inode number is passed in, return instead + of trying to test, set, or clear the bit. + +Mon Nov 7 21:32:33 1994 Remy Card <card@bbj> + + * Makefile: Added a dummy install target in case shared libraries + are not built. + +Mon Oct 24 14:11:44 1994 (tytso@rsx-11) + + * bitmaps.c (ext2fs_allocate_block_bitmap): Fix calculation of how + the real last block of the bitmap should be calculated. + +Wed Sep 7 10:05:36 1994 (tytso@rsx-11) + + * bitmaps.c (ext2fs_fudge_inode_bitmap_end, + ext2fs_fudge_block_bitmap_end, ext2fs_clear_inode_bitmap, + ext2fs_clear_block_bitmap, ext2fs_free_inode_bitmap, + ext2fs_free_block_bitmap): Add magic number checking for + the inode and block bitmaps. + + * bitmaps.c (ext2fs_allocate_block_bitmap): Fix to set the correct + magic number for a block bitmap instead of an inode bitmap. + + * inode.c (ext2fs_close_inode_scan, ext2fs_get_next_inode): Add + magic number checking for the inode_scan structure. + + * badblocks.c (badblocks_list_free, badblocks_list_add, + badblocks_list_test, badblocks_list_iterate_begin, + badblocks_list_iterate, badblocks_list_iterate_end): Add + magic number checking for the badblocks_list and + badblocks_iterate structures. + + * ext2_err.et (EXT2_ET_MAGIC_UNIX_IO_CHANNEL): + * unix_io.c (unix_open, unix_close, unix_set_blksize, unix_read_blk, + unix_write_blk, unix_flush): Add magic number checking + both for io_channel structure and unix_private_data + structure. + + * openfs.c (ext2fs_open): Add check for io_manager structure's + magic number. + + * rw_bitmaps.c (ext2fs_write_inode_bitmap, ext2fs_write_block_bitmap, + ext2fs_read_inode_bitmap, ext2fs_read_block_bitmap, + ext2fs_read_bitmaps, ext2fs_write_bitmaps): + * read_bb.c (ext2fs_read_bb_inode): + * read_bb_file.c (ext2fs_read_bb_FILE): + * newdir.c (ext2fs_new_dir_block): + * namei.c (ext2fs_dir_iterate, ext2fs_lookup, ext2fs_namei): + * link.c (ext2fs_link, ext2fs_unlink): + * inode.c (ext2fs_open_inode_scan, ext2fs_read_inode, + ext2fs_write_inode, ext2fs_get_blocks, + ext2fs_check_directory): + * get_pathname.c (ext2fs_get_pathname): + * expanddir.c (ext2fs_expand_dir): + * block.c (ext2fs_block_iterate): + * bitmaps.c (ext2fs_allocate_inode_bitmap, + ext2fs_allocate_block_bitmap): + * bb_inode.c (ext2fs_update_bb_inode): + * alloc.c (ext2fs_new_inode,ext2fs_new_block,ext2fs_get_free_blocks): + * check_desc.c (ext2fs_check_desc): + * closefs.c (ext2fs_close, ext2fs_flush): + * freefs.c (ext2fs_free): Add check for ext2_filsys magic number. + + * Makefile: + * ext2fs.h: + * openfs.c: + * check_desc.c (ext2fs_check_desc): Move ext2fs_check_desc from + openfs.c into its own file. + + * ext2fs.h (EXT2_CHECK_MAGIC): Added macro for checking for + structure magic numbers. + + * closefs.c (ext2fs_flush): Folded in Remy Card's changes to clear + the EXT2_VALID_FS flag in the backup superblock blocks, so that if + someone uses the -b option to specify the use of the backup + superblock --- this usually means that the main superblock is + toast. :-) + + * ext2fs.h: + * ext2_err.et (EXT2_ET_REV_TOO_HIGH): + * openfs.c (ext2fs_open): Folded in Remy Card's changes to add a + revision level to the superblock. + +Sun Aug 21 00:50:08 1994 Theodore Y. Ts'o (tytso@rt-11) + + * ext2fs.h: + * bitmaps.c: + * bitops.c + * bitops.h: + * openfs.c: + * initialize.c: Completely revamped the inode and block bitmap + structures, so that they can be better chance of being extensible + in a shared library. They are now their own type, instead of + being a char *. Also, the function signatures of + ext2fs_test_block_bitmap, ext2fs_mark_block_bitmap, + ext2fs_unmark_block_bitmap, ext2fs_test_inode_bitmap, + ext2fs_mark_inode_bitmap, and ext2fs_unmark_inode_bitmap were + changed to eliminate the ext2_filsys argument, since it is no + longer necessary. + +Wed Aug 17 21:46:44 1994 Remy Card (card@bbj) + + * unix_io.c (unix_read_blk and unix_write_blk): use the llseek + system call if available. + + * llseek.c: new file. This is the stub calling the llseek system + call which allows supports for 2GB+ file systems. + + * initialize.c (ext2fs_initialize): Ext2fs_initialize now stores + the creator operating system. + +Wed Aug 17 10:03:24 1994 Theodore Y. Ts'o (tytso@rt-11) + + * initialize.c (ext2fs_initialize): Ext2fs_initialize now sets up + the group descriptor statistics in addition to everything else. + This relieves mke2fs of the responsibility of doing it. + + * bitops.c, bitops.h: Add assembly inline functions for the 68000. + Added a new #define, _EXT2_HAVE_ASM_BITOPS_ to control whether or + not the generic C function equivalents should be included or not. + + * openfs.c (ext2fs_open): If a superblock is specified, then use + the backup group descriptors that go along with this superblock, + instead of using the primary group descriptors. This allows + e2fsck to recover filesystems where the primary group descriptors + have been trashed. + + diff --git a/lib/ext2fs/MAKELOG b/lib/ext2fs/MAKELOG new file mode 100644 index 00000000..bb85c24a --- /dev/null +++ b/lib/ext2fs/MAKELOG @@ -0,0 +1,54 @@ +gcc -O2 -fomit-frame-pointer -ansi -D_POSIX_SOURCE -pedantic -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wenum-clash -Wcast-align -Wtraditional -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -I.. -c bitmaps.c +In file included from ext2fs.h:22, + from bitmaps.c:20: +../ext2fs/io.h:12: warning: ANSI C does not support `long long' +../ext2fs/bitops.h: In function `ext2fs_mark_block_bitmap': +In file included from ext2fs.h:112, + from bitmaps.c:20: +../ext2fs/bitops.h:145: warning: passing arg 1 of `ext2fs_warn_bitmap' from incompatible pointer type +../ext2fs/bitops.h: In function `ext2fs_unmark_block_bitmap': +../ext2fs/bitops.h:154: warning: passing arg 1 of `ext2fs_warn_bitmap' from incompatible pointer type +../ext2fs/bitops.h: At top level: +../ext2fs/bitops.h:160: conflicting types for `ext2fs_test_block_bitmap' +../ext2fs/bitops.h:31: previous declaration of `ext2fs_test_block_bitmap' +../ext2fs/bitops.h: In function `ext2fs_test_block_bitmap': +../ext2fs/bitops.h:163: warning: passing arg 1 of `ext2fs_warn_bitmap' from incompatible pointer type +../ext2fs/bitops.h: In function `ext2fs_mark_inode_bitmap': +../ext2fs/bitops.h:172: warning: passing arg 1 of `ext2fs_warn_bitmap' from incompatible pointer type +../ext2fs/bitops.h: In function `ext2fs_unmark_inode_bitmap': +../ext2fs/bitops.h:181: warning: passing arg 1 of `ext2fs_warn_bitmap' from incompatible pointer type +../ext2fs/bitops.h: At top level: +../ext2fs/bitops.h:187: conflicting types for `ext2fs_test_inode_bitmap' +../ext2fs/bitops.h:36: previous declaration of `ext2fs_test_inode_bitmap' +../ext2fs/bitops.h: In function `ext2fs_test_inode_bitmap': +../ext2fs/bitops.h:190: warning: passing arg 1 of `ext2fs_warn_bitmap' from incompatible pointer type +bitmaps.c: In function `ext2fs_read_inode_bitmap': +bitmaps.c:108: warning: implicit declaration of function `ext2fs_free_inode_bitmap' +bitmaps.c:109: structure has no member named `device' +bitmaps.c:110: structure has no member named `device' +bitmaps.c:110: warning: format argument is not a pointer (arg 3) +bitmaps.c:103: warning: `nbytes' may be used uninitialized in this function +bitmaps.c: In function `ext2fs_read_block_bitmap': +bitmaps.c:154: warning: implicit declaration of function `ext2fs_free_block_bitmap' +bitmaps.c:155: structure has no member named `device' +bitmaps.c:156: structure has no member named `device' +bitmaps.c:156: warning: format argument is not a pointer (arg 3) +bitmaps.c:149: warning: `nbytes' may be used uninitialized in this function +bitmaps.c: In function `ext2fs_allocate_inode_bitmap': +bitmaps.c:194: warning: `map' may be used uninitialized in this function +bitmaps.c: In function `ext2fs_allocate_block_bitmap': +bitmaps.c:235: warning: `map' may be used uninitialized in this function +bitmaps.c: At top level: +bitmaps.c:272: warning: no previous prototype for `ext2fs_free_inode_bitmap' +bitmaps.c:272: warning: type mismatch with previous external decl +bitmaps.c:108: warning: previous external decl of `ext2fs_free_inode_bitmap' +bitmaps.c:272: warning: type mismatch with previous implicit declaration +bitmaps.c:108: warning: previous implicit declaration of `ext2fs_free_inode_bitmap' +bitmaps.c:272: warning: `ext2fs_free_inode_bitmap' was previously implicitly declared to return `int' +bitmaps.c:286: warning: no previous prototype for `ext2fs_free_block_bitmap' +bitmaps.c:286: warning: type mismatch with previous external decl +bitmaps.c:154: warning: previous external decl of `ext2fs_free_block_bitmap' +bitmaps.c:286: warning: type mismatch with previous implicit declaration +bitmaps.c:154: warning: previous implicit declaration of `ext2fs_free_block_bitmap' +bitmaps.c:286: warning: `ext2fs_free_block_bitmap' was previously implicitly declared to return `int' +make: *** [bitmaps.o] Error 1 diff --git a/lib/ext2fs/Makefile b/lib/ext2fs/Makefile index 82c72806..5f991cfe 100644 --- a/lib/ext2fs/Makefile +++ b/lib/ext2fs/Makefile @@ -1,32 +1,54 @@ +all:: libext2fs.a + include ../../MCONFIG +OBJS= ext2_err.o openfs.o freefs.o closefs.o bitmaps.o rw_bitmaps.o inode.o \ + unix_io.o block.o namei.o newdir.o mkdir.o check_desc.o \ + get_pathname.o bitops.o link.o alloc.o expanddir.o inline.o \ + initialize.o badblocks.o read_bb.o bb_inode.o read_bb_file.o llseek.o + +HFILES= bitops.h ext2_err.h ext2fs.h io.h + +ifdef BUILD_PROFILE_LIBS +all:: libext2fs_p.a +endif + +ifdef BUILD_DLL_SHLIBS +DLL_ADDRESS = 0x66900000 +DLL_JUMPSIZE = 0x1000 +DLL_GOTSIZE = 0x1000 +DLL_VERSION = 1.0 +DLL_IMAGE = libe2fs +DLL_STUB = libext2fs +DLL_LIBS = -L../.. -lcom_err +DLL_MYDIR = ext2fs +DLL_INSTALL_DIR = $(SHLIBDIR) + +include ../Makefile.dll-lib +endif + COMPILE_ET=../et/compile_et CFLAGS_NO= $(WFLAGS) -I.. CFLAGS= $(OPT) $(CFLAGS_NO) LDFLAGS= $(OPT) -ARCHIVE=ar r -RANLIB=ranlib RM=rm -f MV=mv LN=ln -s -OBJS= ext2_err.o openfs.o freefs.o closefs.o bitmaps.o inode.o unix_io.o \ - block.o namei.o newdir.o mkdir.o \ - get_pathname.o bitops.o link.o alloc.o expanddir.o inline.o \ - initialize.o badblocks.o read_bb.o bb_inode.o read_bb_file.o - -HFILES= bitops.h ext2_err.h ext2fs.h io.h - DISTFILES= Makefile *.c *.h image .c.o: $(CC) $(CFLAGS) -c $*.c +ifdef BUILD_PROFILE_LIBS $(CC) $(CFLAGS_NO) -pg -o profiled/$*.o -c $*.c +endif # $(CC) $(CFLAGS_NO) -checker -g -o checker/$*.o -c $*.c - -all: libext2fs.a libext2fs_p.a +ifdef BUILD_DLL_SHLIBS + (export JUMP_DIR=`pwd`/jump; $(CC) -B$(JUMP_PREFIX) $(CFLAGS) \ + -o jump/$*.o -c $*.c) +endif libext2fs.a: $(OBJS) $(RM) $@.bak @@ -55,23 +77,28 @@ libext2fs_chk.a: $(OBJS) ext2_err.c ext2_err.h: ext2_err.et $(COMPILE_ET) ext2_err.et -install:: all - $(INSTALLLIB) libext2fs.a ${DESTDIR}$(LIBDIR)/libext2fs.a - $(CHMOD) 644 ${DESTDIR}$(LIBDIR)/libext2fs.a - $(RANLIB) ${DESTDIR}$(LIBDIR)/libext2fs.a - $(CHMOD) $(LIBMODE) ${DESTDIR}$(LIBDIR)/libext2fs.a +install-libs:: all + $(INSTALLLIB) libext2fs.a $(LIBDIR)/libext2fs.a + $(CHMOD) 644 $(LIBDIR)/libext2fs.a + $(RANLIB) $(LIBDIR)/libext2fs.a + $(CHMOD) $(LIBMODE) $(LIBDIR)/libext2fs.a -install:: $(HFILES) - @rm -rf ${DESTDIR}$(INCLDIR)/ext2fs - @mkdir ${DESTDIR}$(INCLDIR)/ext2fs +install-libs:: $(HFILES) + @rm -rf $(INCLDIR)/ext2fs + @mkdir $(INCLDIR)/ext2fs for i in $(HFILES); do \ - $(INSTALLINC) $$i ${DESTDIR}$(INCLDIR)/ext2fs/$$i; \ + $(INSTALLINC) $$i $(INCLDIR)/ext2fs/$$i; \ done -clean: +install-tree:: + +install:: + +clean:: rm -f \#* *.s *.o *.a *~ *.bak core profiled/* checker/* + rm -f ../libext2fs.a ../libext2fs_p.a ../libext2fs_chk.a -really-clean: clean +really-clean:: clean rm -f .depend ext2_err.c ext2_err.h dep depend .depend: ext2_err.h diff --git a/lib/ext2fs/alloc.c b/lib/ext2fs/alloc.c index c456ad13..26c01118 100644 --- a/lib/ext2fs/alloc.c +++ b/lib/ext2fs/alloc.c @@ -12,7 +12,6 @@ #include <sys/stat.h> #include <sys/types.h> -#include <linux/fs.h> #include <linux/ext2_fs.h> #include "ext2fs.h" @@ -23,13 +22,15 @@ * * Should have a special policy for directories. */ -errcode_t ext2fs_new_inode(ext2_filsys fs, ino_t dir, int mode, char *map, - ino_t *ret) +errcode_t ext2fs_new_inode(ext2_filsys fs, ino_t dir, int mode, + ext2fs_inode_bitmap map, ino_t *ret) { int dir_group = 0; ino_t i; ino_t start_inode; + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); + if (!map) map = fs->inode_map; if (!map) @@ -44,14 +45,14 @@ errcode_t ext2fs_new_inode(ext2_filsys fs, ino_t dir, int mode, char *map, i = EXT2_FIRST_INO; do { - if (!ext2fs_test_inode_bitmap(fs, map, i)) + if (!ext2fs_test_inode_bitmap(map, i)) break; i++; if (i > fs->super->s_inodes_count) i = EXT2_FIRST_INO; } while (i != start_inode); - if (ext2fs_test_inode_bitmap(fs, map, i)) + if (ext2fs_test_inode_bitmap(map, i)) return ENOSPC; *ret = i; return 0; @@ -61,10 +62,13 @@ errcode_t ext2fs_new_inode(ext2_filsys fs, ino_t dir, int mode, char *map, * Stupid algorithm --- we now just search forward starting from the * goal. Should put in a smarter one someday.... */ -errcode_t ext2fs_new_block(ext2_filsys fs, blk_t goal, char *map, blk_t *ret) +errcode_t ext2fs_new_block(ext2_filsys fs, blk_t goal, + ext2fs_block_bitmap map, blk_t *ret) { blk_t i = goal; + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); + if (!map) map = fs->block_map; if (!map) @@ -72,7 +76,7 @@ errcode_t ext2fs_new_block(ext2_filsys fs, blk_t goal, char *map, blk_t *ret) if (!i) i = fs->super->s_first_data_block; do { - if (!ext2fs_test_block_bitmap(fs, map, i)) { + if (!ext2fs_test_block_bitmap(map, i)) { *ret = i; return 0; } @@ -83,24 +87,27 @@ errcode_t ext2fs_new_block(ext2_filsys fs, blk_t goal, char *map, blk_t *ret) return ENOSPC; } -static int check_blocks_free(ext2_filsys fs, char *map, blk_t blk, int num) +static int check_blocks_free(ext2_filsys fs, ext2fs_block_bitmap map, + blk_t blk, int num) { int i; for (i=0; i < num; i++) { if ((blk+i) > fs->super->s_blocks_count) return 0; - if (ext2fs_test_block_bitmap(fs, map, blk+i)) + if (ext2fs_test_block_bitmap(map, blk+i)) return 0; } return 1; } errcode_t ext2fs_get_free_blocks(ext2_filsys fs, blk_t start, blk_t finish, - int num, char *map, blk_t *ret) + int num, ext2fs_block_bitmap map, blk_t *ret) { blk_t b = start; + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); + if (!map) map = fs->block_map; if (!map) diff --git a/lib/ext2fs/badblocks.c b/lib/ext2fs/badblocks.c index 5e8cd436..8a405012 100644 --- a/lib/ext2fs/badblocks.c +++ b/lib/ext2fs/badblocks.c @@ -14,7 +14,6 @@ #include <sys/stat.h> #include <sys/types.h> -#include <linux/fs.h> #include <linux/ext2_fs.h> #include "ext2fs.h" @@ -30,6 +29,7 @@ errcode_t badblocks_list_create(badblocks_list *ret, int size) if (!bb) return ENOMEM; memset(bb, 0, sizeof(struct struct_badblocks_list)); + bb->magic = EXT2_ET_MAGIC_BADBLOCKS_LIST; bb->size = size ? size : 10; bb->list = malloc(bb->size * sizeof(blk_t)); if (!bb->list) { @@ -45,6 +45,9 @@ errcode_t badblocks_list_create(badblocks_list *ret, int size) */ void badblocks_list_free(badblocks_list bb) { + if (bb->magic != EXT2_ET_MAGIC_BADBLOCKS_LIST) + return; + if (bb->list) free(bb->list); bb->list = 0; @@ -58,6 +61,8 @@ errcode_t badblocks_list_add(badblocks_list bb, blk_t blk) { int i; + EXT2_CHECK_MAGIC(bb, EXT2_ET_MAGIC_BADBLOCKS_LIST); + for (i=0; i < bb->num; i++) if (bb->list[i] == blk) return 0; @@ -84,6 +89,8 @@ int badblocks_list_test(badblocks_list bb, blk_t blk) { int i; + EXT2_CHECK_MAGIC(bb, EXT2_ET_MAGIC_BADBLOCKS_LIST); + for (i=0; i < bb->num; i++) if (bb->list[i] == blk) return 1; @@ -96,10 +103,13 @@ errcode_t badblocks_list_iterate_begin(badblocks_list bb, { badblocks_iterate iter; + EXT2_CHECK_MAGIC(bb, EXT2_ET_MAGIC_BADBLOCKS_LIST); + iter = malloc(sizeof(struct struct_badblocks_iterate)); if (!iter) return ENOMEM; + iter->magic = EXT2_ET_MAGIC_BADBLOCKS_ITERATE; iter->bb = bb; iter->ptr = 0; *ret = iter; @@ -108,7 +118,15 @@ errcode_t badblocks_list_iterate_begin(badblocks_list bb, int badblocks_list_iterate(badblocks_iterate iter, blk_t *blk) { - badblocks_list bb = iter->bb; + badblocks_list bb; + + if (iter->magic != EXT2_ET_MAGIC_BADBLOCKS_ITERATE) + return 0; + + bb = iter->bb; + + if (bb->magic != EXT2_ET_MAGIC_BADBLOCKS_LIST) + return 0; if (iter->ptr < bb->num) { *blk = bb->list[iter->ptr++]; @@ -120,6 +138,9 @@ int badblocks_list_iterate(badblocks_iterate iter, blk_t *blk) void badblocks_list_iterate_end(badblocks_iterate iter) { + if (!iter || (iter->magic != EXT2_ET_MAGIC_BADBLOCKS_ITERATE)) + return; + iter->bb = 0; free(iter); } diff --git a/lib/ext2fs/bb_inode.c b/lib/ext2fs/bb_inode.c index d345f1dd..2b0ea9f6 100644 --- a/lib/ext2fs/bb_inode.c +++ b/lib/ext2fs/bb_inode.c @@ -18,7 +18,6 @@ #include <sys/stat.h> #include <sys/types.h> -#include <linux/fs.h> #include <linux/ext2_fs.h> #include "ext2fs.h" @@ -48,7 +47,10 @@ errcode_t ext2fs_update_bb_inode(ext2_filsys fs, badblocks_list bb_list) errcode_t retval; struct set_badblock_record rec; struct ext2_inode inode; + blk_t blk; + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); + if (!fs->block_map) return EXT2_ET_NO_BLOCK_BITMAP; @@ -70,7 +72,8 @@ errcode_t ext2fs_update_bb_inode(ext2_filsys fs, badblocks_list bb_list) /* * First clear the old bad blocks (while saving the indirect blocks) */ - retval = ext2fs_block_iterate(fs, EXT2_BAD_INO, 0, 0, + retval = ext2fs_block_iterate(fs, EXT2_BAD_INO, + BLOCK_FLAG_DEPTH_TRAVERSE, 0, clear_bad_block_proc, &rec); if (retval) goto cleanup; @@ -81,11 +84,24 @@ errcode_t ext2fs_update_bb_inode(ext2_filsys fs, badblocks_list bb_list) /* * Now set the bad blocks! + * + * First, mark the bad blocks as used. This prevents a bad + * block from being used as an indirecto block for the bad + * block inode (!). */ if (bb_list) { retval = badblocks_list_iterate_begin(bb_list, &rec.bb_iter); if (retval) goto cleanup; + while (badblocks_list_iterate(rec.bb_iter, &blk)) { + ext2fs_mark_block_bitmap(fs->block_map, blk); + } + badblocks_list_iterate_end(rec.bb_iter); + ext2fs_mark_bb_dirty(fs); + + retval = badblocks_list_iterate_begin(bb_list, &rec.bb_iter); + if (retval) + goto cleanup; retval = ext2fs_block_iterate(fs, EXT2_BAD_INO, BLOCK_FLAG_APPEND, 0, set_bad_block_proc, &rec); @@ -138,6 +154,15 @@ static int clear_bad_block_proc(ext2_filsys fs, blk_t *block_nr, int blockcnt, if (!*block_nr) return 0; + /* + * If the block number is outrageous, clear it and ignore it. + */ + if (*block_nr >= fs->super->s_blocks_count || + *block_nr < fs->super->s_first_data_block) { + *block_nr = 0; + return BLOCK_CHANGED; + } + if (blockcnt < 0) { if (rec->ind_blocks_size >= rec->max_ind_blocks) { rec->max_ind_blocks += 10; @@ -155,7 +180,7 @@ static int clear_bad_block_proc(ext2_filsys fs, blk_t *block_nr, int blockcnt, /* * Mark the block as unused, and update accounting information */ - ext2fs_unmark_block_bitmap(fs, fs->block_map, *block_nr); + ext2fs_unmark_block_bitmap(fs->block_map, *block_nr); ext2fs_mark_bb_dirty(fs); group = ext2fs_group_of_blk(fs, *block_nr); fs->group_desc[group].bg_free_blocks_count++; @@ -188,34 +213,38 @@ static int set_bad_block_proc(ext2_filsys fs, blk_t *block_nr, if (!badblocks_list_iterate(rec->bb_iter, &blk)) return BLOCK_ABORT; rec->bad_block_count++; - } else if (rec->ind_blocks_ptr < rec->ind_blocks_size) + } else { /* * An indirect block; fetch a block from the - * previously used indirect block list. - */ - blk = rec->ind_blocks[rec->ind_blocks_ptr++]; - else { - /* - * An indirect block, and we're out of reserved - * indirect blocks. Allocate a new one. + * previously used indirect block list. The block + * most be not marked as used; if so, get another one. + * If we run out of reserved indirect blocks, allocate + * a new one. */ - retval = ext2fs_new_block(fs, 0, 0, &blk); - if (retval) { - rec->err = retval; - return BLOCK_ABORT; + retry: + if (rec->ind_blocks_ptr < rec->ind_blocks_size) { + blk = rec->ind_blocks[rec->ind_blocks_ptr++]; + if (ext2fs_test_block_bitmap(fs->block_map, blk)) + goto retry; + } else { + retval = ext2fs_new_block(fs, 0, 0, &blk); + if (retval) { + rec->err = retval; + return BLOCK_ABORT; + } } retval = io_channel_write_blk(fs->io, blk, 1, rec->block_buf); if (retval) { rec->err = retval; return BLOCK_ABORT; } + ext2fs_mark_block_bitmap(fs->block_map, blk); + ext2fs_mark_bb_dirty(fs); } /* - * Mark the block as used, and update block counts + * Update block counts */ - ext2fs_mark_block_bitmap(fs, fs->block_map, blk); - ext2fs_mark_bb_dirty(fs); group = ext2fs_group_of_blk(fs, blk); fs->group_desc[group].bg_free_blocks_count--; fs->super->s_free_blocks_count--; diff --git a/lib/ext2fs/bitmaps.c b/lib/ext2fs/bitmaps.c index c12433a6..8712e2d5 100644 --- a/lib/ext2fs/bitmaps.c +++ b/lib/ext2fs/bitmaps.c @@ -15,244 +15,173 @@ #include <sys/stat.h> #include <sys/types.h> -#include <linux/fs.h> #include <linux/ext2_fs.h> #include "ext2fs.h" -errcode_t ext2fs_write_inode_bitmap(ext2_filsys fs) +errcode_t ext2fs_allocate_inode_bitmap(ext2_filsys fs, + const char *descr, + ext2fs_inode_bitmap *ret) { - int i; - int nbytes; - errcode_t retval; - char * inode_bitmap = fs->inode_map; - char * bitmap_block = NULL; + ext2fs_inode_bitmap bitmap; + int size; - if (!(fs->flags & EXT2_FLAG_RW)) - return EXT2_ET_RO_FILSYS; - if (!inode_bitmap) - return 0; - nbytes = EXT2_INODES_PER_GROUP(fs->super) / 8; - bitmap_block = malloc(fs->blocksize); - if (!bitmap_block) - return ENOMEM; - memset(bitmap_block, 0xff, fs->blocksize); - for (i = 0; i < fs->group_desc_count; i++) { - memcpy(bitmap_block, inode_bitmap, nbytes); - retval = io_channel_write_blk(fs->io, - fs->group_desc[i].bg_inode_bitmap, 1, - bitmap_block); - if (retval) - return EXT2_ET_INODE_BITMAP_WRITE; - inode_bitmap += nbytes; - } - fs->flags |= EXT2_FLAG_CHANGED; - fs->flags &= ~EXT2_FLAG_IB_DIRTY; - free(bitmap_block); - return 0; -} + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); -errcode_t ext2fs_write_block_bitmap (ext2_filsys fs) -{ - int i; - int j; - int nbytes; - int nbits; - errcode_t retval; - char * block_bitmap = fs->block_map; - char * bitmap_block = NULL; + fs->write_bitmaps = ext2fs_write_bitmaps; - if (!(fs->flags & EXT2_FLAG_RW)) - return EXT2_ET_RO_FILSYS; - if (!block_bitmap) - return 0; - nbytes = EXT2_BLOCKS_PER_GROUP(fs->super) / 8; - bitmap_block = malloc(fs->blocksize); - if (!bitmap_block) + bitmap = malloc(sizeof(struct ext2fs_struct_inode_bitmap)); + if (!bitmap) return ENOMEM; - memset(bitmap_block, 0xff, fs->blocksize); - for (i = 0; i < fs->group_desc_count; i++) { - memcpy(bitmap_block, block_bitmap, nbytes); - if (i == fs->group_desc_count - 1) { - /* Force bitmap padding for the last group */ - nbits = (fs->super->s_blocks_count - - fs->super->s_first_data_block) - % EXT2_BLOCKS_PER_GROUP(fs->super); - for (j = nbits; j < fs->blocksize * 8; j++) - set_bit(j, bitmap_block); + + bitmap->magic = EXT2_ET_MAGIC_INODE_BITMAP; + bitmap->fs = fs; + bitmap->start = 1; + bitmap->end = fs->super->s_inodes_count; + bitmap->real_end = (EXT2_INODES_PER_GROUP(fs->super) + * fs->group_desc_count); + if (descr) { + bitmap->description = malloc(strlen(descr)+1); + if (!bitmap->description) { + free(bitmap); + return ENOMEM; } - retval = io_channel_write_blk(fs->io, - fs->group_desc[i].bg_block_bitmap, 1, - bitmap_block); - if (retval) - return EXT2_ET_BLOCK_BITMAP_WRITE; - block_bitmap += nbytes; + strcpy(bitmap->description, descr); + } else + bitmap->description = 0; + + size = ((bitmap->real_end - bitmap->start) / 8) + 1; + bitmap->bitmap = malloc(size); + if (!bitmap->bitmap) { + free(bitmap->description); + free(bitmap); + return ENOMEM; } - fs->flags |= EXT2_FLAG_CHANGED; - fs->flags &= ~EXT2_FLAG_BB_DIRTY; - free(bitmap_block); + + memset(bitmap->bitmap, 0, size); + *ret = bitmap; return 0; } -errcode_t ext2fs_read_inode_bitmap (ext2_filsys fs) +errcode_t ext2fs_allocate_block_bitmap(ext2_filsys fs, + const char *descr, + ext2fs_block_bitmap *ret) { - int i; - char * inode_bitmap; - char *buf = 0; - errcode_t retval; - int nbytes; + ext2fs_block_bitmap bitmap; + int size; - fs->write_bitmaps = ext2fs_write_bitmaps; + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); - if (fs->inode_map) - free(fs->inode_map); - nbytes = EXT2_INODES_PER_GROUP(fs->super) / 8; - fs->flags &= ~EXT2_FLAG_IB_DIRTY; - fs->inode_map = malloc((nbytes * fs->group_desc_count) + 1); - if (!fs->inode_map) - return ENOMEM; - inode_bitmap = fs->inode_map; + fs->write_bitmaps = ext2fs_write_bitmaps; - buf = malloc(fs->blocksize); - if (!buf) + bitmap = malloc(sizeof(struct ext2fs_struct_inode_bitmap)); + if (!bitmap) return ENOMEM; - for (i = 0; i < fs->group_desc_count; i++) { - retval = io_channel_read_blk(fs->io, - fs->group_desc[i].bg_inode_bitmap, 1, - buf); - if (retval) { - retval = EXT2_ET_INODE_BITMAP_READ; - goto cleanup; + bitmap->magic = EXT2_ET_MAGIC_BLOCK_BITMAP; + bitmap->fs = fs; + bitmap->start = fs->super->s_first_data_block; + bitmap->end = fs->super->s_blocks_count-1; + bitmap->real_end = (EXT2_BLOCKS_PER_GROUP(fs->super) + * fs->group_desc_count)-1 + bitmap->start; + if (descr) { + bitmap->description = malloc(strlen(descr)+1); + if (!bitmap->description) { + free(bitmap); + return ENOMEM; } - memcpy(inode_bitmap, buf, nbytes); - inode_bitmap += nbytes; + strcpy(bitmap->description, descr); + } else + bitmap->description = 0; + + size = ((bitmap->real_end - bitmap->start) / 8) + 1; + bitmap->bitmap = malloc(size); + if (!bitmap->bitmap) { + free(bitmap->description); + free(bitmap); + return ENOMEM; } - free(buf); + + memset(bitmap->bitmap, 0, size); + *ret = bitmap; return 0; - -cleanup: - free(fs->inode_map); - fs->inode_map = 0; - if (buf) - free(buf); - return retval; } -errcode_t ext2fs_read_block_bitmap(ext2_filsys fs) +errcode_t ext2fs_fudge_inode_bitmap_end(ext2fs_inode_bitmap bitmap, + ino_t end, ino_t *oend) { - int i; - char * block_bitmap; - char *buf = 0; - errcode_t retval; - int nbytes; - - fs->write_bitmaps = ext2fs_write_bitmaps; - - if (fs->block_map) - free(fs->block_map); - nbytes = EXT2_BLOCKS_PER_GROUP(fs->super) / 8; - fs->flags &= ~EXT2_FLAG_BB_DIRTY; - fs->block_map = malloc((nbytes * fs->group_desc_count) + 1); - if (!fs->block_map) - return ENOMEM; - block_bitmap = fs->block_map; - - buf = malloc(fs->blocksize); - if (!buf) - return ENOMEM; - - for (i = 0; i < fs->group_desc_count; i++) { - retval = io_channel_read_blk(fs->io, - fs->group_desc[i].bg_block_bitmap, 1, - buf); - if (retval) { - retval = EXT2_ET_BLOCK_BITMAP_READ; - goto cleanup; - } - memcpy(block_bitmap, buf, nbytes); - block_bitmap += nbytes; - } - free(buf); - return 0; + EXT2_CHECK_MAGIC(bitmap, EXT2_ET_MAGIC_INODE_BITMAP); -cleanup: - free(fs->block_map); - fs->block_map = 0; - if (buf) - free(buf); - return retval; + if (end > bitmap->real_end) + return EXT2_ET_FUDGE_INODE_BITMAP_END; + if (oend) + *oend = bitmap->end; + bitmap->end = end; + return 0; } -errcode_t ext2fs_allocate_inode_bitmap(ext2_filsys fs, char **ret) +errcode_t ext2fs_fudge_block_bitmap_end(ext2fs_block_bitmap bitmap, + blk_t end, blk_t *oend) { - char *map; - int size; + EXT2_CHECK_MAGIC(bitmap, EXT2_ET_MAGIC_BLOCK_BITMAP); - fs->write_bitmaps = ext2fs_write_bitmaps; - - size = (fs->super->s_inodes_count / 8) + 1; - map = malloc(size); - if (!map) - return ENOMEM; - memset(map, 0, size); - *ret = map; + if (end > bitmap->real_end) + return EXT2_ET_FUDGE_BLOCK_BITMAP_END; + if (oend) + *oend = bitmap->end; + bitmap->end = end; return 0; } -errcode_t ext2fs_allocate_block_bitmap(ext2_filsys fs, char **ret) +void ext2fs_clear_inode_bitmap(ext2fs_inode_bitmap bitmap) { - char *map; - int size; + if (!bitmap || (bitmap->magic != EXT2_ET_MAGIC_INODE_BITMAP)) + return; - fs->write_bitmaps = ext2fs_write_bitmaps; - - size = (fs->super->s_blocks_count / 8) + 1; - map = malloc(size); - if (!map) - return ENOMEM; - memset(map, 0, size); - *ret = map; - return 0; + memset(bitmap->bitmap, 0, + ((bitmap->real_end - bitmap->start) / 8) + 1); } -errcode_t ext2fs_read_bitmaps(ext2_filsys fs) +void ext2fs_clear_block_bitmap(ext2fs_block_bitmap bitmap) { - errcode_t retval; + if (!bitmap || (bitmap->magic != EXT2_ET_MAGIC_BLOCK_BITMAP)) + return; - fs->write_bitmaps = ext2fs_write_bitmaps; + memset(bitmap->bitmap, 0, + ((bitmap->real_end - bitmap->start) / 8) + 1); +} - if (!fs->inode_map) { - retval = ext2fs_read_inode_bitmap(fs); - if (retval) - return retval; +void ext2fs_free_inode_bitmap(ext2fs_inode_bitmap bitmap) +{ + if (!bitmap || (bitmap->magic != EXT2_ET_MAGIC_INODE_BITMAP)) + return; + + bitmap->magic = 0; + if (bitmap->description) { + free(bitmap->description); + bitmap->description = 0; } - if (!fs->block_map) { - retval = ext2fs_read_block_bitmap(fs); - if (retval) - return retval; + if (bitmap->bitmap) { + free(bitmap->bitmap); + bitmap->bitmap = 0; } - return 0; + free(bitmap); } -errcode_t ext2fs_write_bitmaps(ext2_filsys fs) +void ext2fs_free_block_bitmap(ext2fs_block_bitmap bitmap) { - errcode_t retval; + if (!bitmap || (bitmap->magic != EXT2_ET_MAGIC_BLOCK_BITMAP)) + return; - if (fs->block_map && ext2fs_test_bb_dirty(fs)) { - retval = ext2fs_write_block_bitmap(fs); - if (retval) - return retval; + bitmap->magic = 0; + if (bitmap->description) { + free(bitmap->description); + bitmap->description = 0; } - if (fs->inode_map && ext2fs_test_ib_dirty(fs)) { - retval = ext2fs_write_inode_bitmap(fs); - if (retval) - return retval; + if (bitmap->bitmap) { + free(bitmap->bitmap); + bitmap->bitmap = 0; } - return 0; -} - - - - + free(bitmap); +} diff --git a/lib/ext2fs/bitops.c b/lib/ext2fs/bitops.c index a53d8ee8..c037199e 100644 --- a/lib/ext2fs/bitops.c +++ b/lib/ext2fs/bitops.c @@ -10,12 +10,12 @@ #include <stdio.h> #include <sys/types.h> -#include <linux/fs.h> + #include <linux/ext2_fs.h> #include "ext2fs.h" -#if (!defined(__i386__) && !defined(__i486__) && !defined(__i586__)) +#ifndef _EXT2_HAVE_ASM_BITOPS_ /* * For the benefit of those who are trying to port Linux to another @@ -69,27 +69,14 @@ int test_bit(int nr, const void * addr) mask = 1 << (nr & 0x1f); return ((mask & *ADDR) != 0); } -#endif /* !i386 */ - -/* - * These are routines print warning messages; they are called by - * inline routines. - */ -const char *ext2fs_block_string = "block"; -const char *ext2fs_inode_string = "inode"; -const char *ext2fs_mark_string = "mark"; -const char *ext2fs_unmark_string = "unmark"; -const char *ext2fs_test_string = "test"; +#endif /* !_EXT2_HAVE_ASM_BITOPS_ */ -void ext2fs_warn_bitmap(ext2_filsys fs, const char *op, const char *type, - int arg) +void ext2fs_warn_bitmap(errcode_t errcode, unsigned long arg, + const char *description) { - char func[80]; - - sprintf(func, "ext2fs_%s_%s_bitmap", op, type); - com_err(func, 0, "INTERNAL ERROR: illegal %s #%d for %s", - type, arg, fs->device_name); + if (description) + com_err(0, errcode, "#%u for %s", arg, description); + else + com_err(0, errcode, "#%u", arg); } - - diff --git a/lib/ext2fs/bitops.h b/lib/ext2fs/bitops.h index c01cc866..87e7d79e 100644 --- a/lib/ext2fs/bitops.h +++ b/lib/ext2fs/bitops.h @@ -22,19 +22,18 @@ extern const char *ext2fs_inode_string; extern const char *ext2fs_mark_string; extern const char *ext2fs_unmark_string; extern const char *ext2fs_test_string; -extern void ext2fs_warn_bitmap(ext2_filsys fs, const char *op, - const char *type, int arg); - -extern void ext2fs_mark_block_bitmap(ext2_filsys fs, char *bitmap, int block); -extern void ext2fs_unmark_block_bitmap(ext2_filsys fs, char *bitmap, - int block); -extern int ext2fs_test_block_bitmap(ext2_filsys fs, const char *bitmap, - int block); -extern void ext2fs_mark_inode_bitmap(ext2_filsys fs, char *bitmap, int inode); -extern void ext2fs_unmark_inode_bitmap(ext2_filsys fs, char *bitmap, - int inode); -extern int ext2fs_test_inode_bitmap(ext2_filsys fs, const char *bitmap, - int inode); +extern void ext2fs_warn_bitmap(errcode_t errcode, unsigned long arg, + const char *description); + +extern void ext2fs_mark_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block); +extern void ext2fs_unmark_block_bitmap(ext2fs_block_bitmap bitmap, + blk_t block); +extern int ext2fs_test_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block); + +extern void ext2fs_mark_inode_bitmap(ext2fs_inode_bitmap bitmap, ino_t inode); +extern void ext2fs_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap, + ino_t inode); +extern int ext2fs_test_inode_bitmap(ext2fs_inode_bitmap bitmap, ino_t inode); /* * The inline routines themselves... @@ -50,6 +49,9 @@ extern int ext2fs_test_inode_bitmap(ext2_filsys fs, const char *bitmap, #endif #if (defined(__i386__) || defined(__i486__) || defined(__i586__)) + +#define _EXT2_HAVE_ASM_BITOPS_ + /* * These are done by inline assembly for speed reasons..... * @@ -99,73 +101,106 @@ _INLINE_ int test_bit(int nr, const void * addr) #endif /* i386 */ -_INLINE_ void ext2fs_mark_block_bitmap(ext2_filsys fs, char *bitmap, - int block) +#ifdef __mc68000__ + +#define _EXT2_HAVE_ASM_BITOPS_ + +_INLINE_ int set_bit(int nr,void * addr) +{ + char retval; + + __asm__ __volatile__ ("bfset %2@{%1:#1}; sne %0" + : "=d" (retval) : "d" (nr), "a" (addr)); + + return retval; +} + +_INLINE_ int clear_bit(int nr, void * addr) +{ + char retval; + + __asm__ __volatile__ ("bfclr %2@{%1:#1}; sne %0" + : "=d" (retval) : "d" (nr), "a" (addr)); + + return retval; +} + +_INLINE_ int test_bit(int nr, const void * addr) +{ + char retval; + + __asm__ __volatile__ ("bftst %2@{%1:#1}; sne %0" + : "=d" (retval) : "d" (nr), "a" (addr)); + + return retval; +} + +#endif /* __mc68000__ */ + +_INLINE_ void ext2fs_mark_block_bitmap(ext2fs_block_bitmap bitmap, + blk_t block) { - if ((block < fs->super->s_first_data_block) || - (block >= fs->super->s_blocks_count)) { - ext2fs_warn_bitmap(fs, ext2fs_mark_string, - ext2fs_block_string, block); + if ((block < bitmap->start) || (block > bitmap->end)) { + ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_MARK, block, + bitmap->description); return; } - set_bit(block - fs->super->s_first_data_block, bitmap); + set_bit(block - bitmap->start, bitmap->bitmap); } -_INLINE_ void ext2fs_unmark_block_bitmap(ext2_filsys fs, char *bitmap, - int block) +_INLINE_ void ext2fs_unmark_block_bitmap(ext2fs_block_bitmap bitmap, + blk_t block) { - if ((block < fs->super->s_first_data_block) || - (block >= fs->super->s_blocks_count)) { - ext2fs_warn_bitmap(fs, ext2fs_unmark_string, - ext2fs_block_string, block); + if ((block < bitmap->start) || (block > bitmap->end)) { + ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_UNMARK, + block, bitmap->description); return; } - clear_bit(block - fs->super->s_first_data_block, bitmap); + clear_bit(block - bitmap->start, bitmap->bitmap); } -_INLINE_ int ext2fs_test_block_bitmap(ext2_filsys fs, const char *bitmap, - int block) +_INLINE_ int ext2fs_test_block_bitmap(ext2fs_block_bitmap bitmap, + blk_t block) { - if ((block < fs->super->s_first_data_block) || - (block >= fs->super->s_blocks_count)) { - ext2fs_warn_bitmap(fs, ext2fs_test_string, - ext2fs_block_string, block); + if ((block < bitmap->start) || (block > bitmap->end)) { + ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_TEST, + block, bitmap->description); return 0; } - return test_bit(block - fs->super->s_first_data_block, bitmap); + return test_bit(block - bitmap->start, bitmap->bitmap); } -_INLINE_ void ext2fs_mark_inode_bitmap(ext2_filsys fs, char *bitmap, - int inode) +_INLINE_ void ext2fs_mark_inode_bitmap(ext2fs_inode_bitmap bitmap, + ino_t inode) { - if ((inode < 1) || (inode > fs->super->s_inodes_count)) { - ext2fs_warn_bitmap(fs, ext2fs_mark_string, - ext2fs_inode_string, inode); + if ((inode < bitmap->start) || (inode > bitmap->end)) { + ext2fs_warn_bitmap(EXT2_ET_BAD_INODE_MARK, + inode, bitmap->description); return; } - set_bit(inode - 1, bitmap); + set_bit(inode - bitmap->start, bitmap->bitmap); } -_INLINE_ void ext2fs_unmark_inode_bitmap(ext2_filsys fs, char *bitmap, - int inode) +_INLINE_ void ext2fs_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap, + ino_t inode) { - if ((inode < 1) || (inode > fs->super->s_inodes_count)) { - ext2fs_warn_bitmap(fs, ext2fs_unmark_string, - ext2fs_inode_string, inode); + if ((inode < bitmap->start) || (inode > bitmap->end)) { + ext2fs_warn_bitmap(EXT2_ET_BAD_INODE_UNMARK, + inode, bitmap->description); return; } - clear_bit(inode - 1, bitmap); + clear_bit(inode - bitmap->start, bitmap->bitmap); } -_INLINE_ int ext2fs_test_inode_bitmap(ext2_filsys fs, const char *bitmap, - int inode) +_INLINE_ int ext2fs_test_inode_bitmap(ext2fs_inode_bitmap bitmap, + ino_t inode) { - if ((inode < 1) || (inode > fs->super->s_inodes_count)) { - ext2fs_warn_bitmap(fs, ext2fs_test_string, - ext2fs_inode_string, inode); + if ((inode < bitmap->start) || (inode > bitmap->end)) { + ext2fs_warn_bitmap(EXT2_ET_BAD_INODE_TEST, + inode, bitmap->description); return 0; } - return test_bit(inode - 1, bitmap); + return test_bit(inode - bitmap->start, bitmap->bitmap); } #undef _INLINE_ diff --git a/lib/ext2fs/block.c b/lib/ext2fs/block.c index d2c87cef..53c193c2 100644 --- a/lib/ext2fs/block.c +++ b/lib/ext2fs/block.c @@ -9,7 +9,7 @@ #include <string.h> #include <unistd.h> #include <stdlib.h> -#include <linux/fs.h> + #include <linux/ext2_fs.h> #include "ext2fs.h" @@ -40,6 +40,12 @@ static int block_iterate_ind(blk_t *ind_block, struct block_context *ctx) ret = (*ctx->func)(ctx->fs, ind_block, -1, ctx->private); if (!*ind_block || (ret & BLOCK_ABORT)) return ret; + if (*ind_block >= ctx->fs->super->s_blocks_count || + *ind_block < ctx->fs->super->s_first_data_block) { + ctx->errcode = EXT2_ET_BAD_IND_BLOCK; + ret |= BLOCK_ERROR; + return ret; + } ctx->errcode = io_channel_read_blk(ctx->fs->io, *ind_block, 1, ctx->ind_buf); if (ctx->errcode) { @@ -80,6 +86,12 @@ static int block_iterate_dind(blk_t *dind_block, struct block_context *ctx) ret = (*ctx->func)(ctx->fs, dind_block, -2, ctx->private); if (!*dind_block || (ret & BLOCK_ABORT)) return ret; + if (*dind_block >= ctx->fs->super->s_blocks_count || + *dind_block < ctx->fs->super->s_first_data_block) { + ctx->errcode = EXT2_ET_BAD_DIND_BLOCK; + ret |= BLOCK_ERROR; + return ret; + } ctx->errcode = io_channel_read_blk(ctx->fs->io, *dind_block, 1, ctx->dind_buf); if (ctx->errcode) { @@ -119,6 +131,12 @@ static int block_iterate_tind(blk_t *tind_block, struct block_context *ctx) ret = (*ctx->func)(ctx->fs, tind_block, -3, ctx->private); if (!*tind_block || (ret & BLOCK_ABORT)) return ret; + if (*tind_block >= ctx->fs->super->s_blocks_count || + *tind_block < ctx->fs->super->s_first_data_block) { + ctx->errcode = EXT2_ET_BAD_TIND_BLOCK; + ret |= BLOCK_ERROR; + return ret; + } ctx->errcode = io_channel_read_blk(ctx->fs->io, *tind_block, 1, ctx->tind_buf); if (ctx->errcode) { @@ -165,6 +183,8 @@ errcode_t ext2fs_block_iterate(ext2_filsys fs, struct ext2_inode inode; errcode_t retval; + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); + ret = ext2fs_get_blocks(fs, ino, blocks); if (ret) return ret; diff --git a/lib/ext2fs/check_desc.c b/lib/ext2fs/check_desc.c new file mode 100644 index 00000000..a8d5d95b --- /dev/null +++ b/lib/ext2fs/check_desc.c @@ -0,0 +1,63 @@ +/* + * check_desc.c --- Check the group descriptors of an ext2 filesystem + * + * Copyright (C) 1993, 1994 Theodore Ts'o. This file may be redistributed + * under the terms of the GNU Public License. + */ + +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <stdlib.h> +#include <fcntl.h> +#include <time.h> +#include <sys/stat.h> +#include <sys/types.h> + +#include <linux/ext2_fs.h> + +#include "ext2fs.h" + +/* + * This routine sanity checks the group descriptors + */ +errcode_t ext2fs_check_desc(ext2_filsys fs) +{ + int i; + int block = fs->super->s_first_data_block; + int next, inode_blocks_per_group; + + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); + + inode_blocks_per_group = fs->super->s_inodes_per_group / + EXT2_INODES_PER_BLOCK (fs->super); + + for (i = 0; i < fs->group_desc_count; i++) { + next = block + fs->super->s_blocks_per_group; + /* + * Check to make sure block bitmap for group is + * located within the group. + */ + if (fs->group_desc[i].bg_block_bitmap < block || + fs->group_desc[i].bg_block_bitmap >= next) + return EXT2_ET_GDESC_BAD_BLOCK_MAP; + /* + * Check to make sure inode bitmap for group is + * located within the group + */ + if (fs->group_desc[i].bg_inode_bitmap < block || + fs->group_desc[i].bg_inode_bitmap >= next) + return EXT2_ET_GDESC_BAD_INODE_MAP; + /* + * Check to make sure inode table for group is located + * within the group + */ + if (fs->group_desc[i].bg_inode_table < block || + fs->group_desc[i].bg_inode_table+inode_blocks_per_group >= + next) + return EXT2_ET_GDESC_BAD_INODE_TABLE; + + block = next; + } + return 0; +} diff --git a/lib/ext2fs/closefs.c b/lib/ext2fs/closefs.c index d25f312b..41a5052c 100644 --- a/lib/ext2fs/closefs.c +++ b/lib/ext2fs/closefs.c @@ -10,7 +10,6 @@ #include <stdlib.h> #include <time.h> -#include <linux/fs.h> #include <linux/ext2_fs.h> #include "ext2fs.h" @@ -21,7 +20,10 @@ errcode_t ext2fs_flush(ext2_filsys fs) int group_block; errcode_t retval; char *group_ptr; + unsigned long fs_state; + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); + /* * Write out master superblock. This has to be done * separately, since it is located at a fixed location @@ -35,6 +37,13 @@ errcode_t ext2fs_flush(ext2_filsys fs) io_channel_set_blksize(fs->io, fs->blocksize); /* + * Save the state of the FS and set it to non valid for the + * backup superblocks + */ + fs_state = fs->super->s_state; + fs->super->s_state &= ~EXT2_VALID_FS; + + /* * Write out the master group descriptors, and the backup * superblocks and group descriptors. */ @@ -44,21 +53,27 @@ errcode_t ext2fs_flush(ext2_filsys fs) retval = io_channel_write_blk(fs->io, group_block, -SUPERBLOCK_SIZE, fs->super); - if (retval) + if (retval) { + fs->super->s_state = fs_state; return retval; + } } group_ptr = (char *) fs->group_desc; for (j=0; j < fs->desc_blocks; j++) { retval = io_channel_write_blk(fs->io, group_block+1+j, 1, group_ptr); - if (retval) + if (retval) { + fs->super->s_state = fs_state; return retval; + } group_ptr += fs->blocksize; } group_block += EXT2_BLOCKS_PER_GROUP(fs->super); } + fs->super->s_state = fs_state; + /* * If the write_bitmaps() function is present, call it to * flush the bitmaps. This is done this way so that a simple @@ -78,6 +93,8 @@ errcode_t ext2fs_close(ext2_filsys fs) { errcode_t retval; + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); + if (fs->flags & EXT2_FLAG_DIRTY) { retval = ext2fs_flush(fs); if (retval) diff --git a/lib/ext2fs/expanddir.c b/lib/ext2fs/expanddir.c index 1bc3f491..5af9853d 100644 --- a/lib/ext2fs/expanddir.c +++ b/lib/ext2fs/expanddir.c @@ -9,7 +9,7 @@ #include <string.h> #include <unistd.h> #include <stdlib.h> -#include <linux/fs.h> + #include <linux/ext2_fs.h> #include "ext2fs.h" @@ -62,7 +62,7 @@ static int expand_dir_proc(ext2_filsys fs, } free(block); *blocknr = new_blk; - ext2fs_mark_block_bitmap(fs, fs->block_map, new_blk); + ext2fs_mark_block_bitmap(fs->block_map, new_blk); ext2fs_mark_bb_dirty(fs); group = ext2fs_group_of_blk(fs, new_blk); fs->group_desc[group].bg_free_blocks_count--; @@ -80,6 +80,8 @@ errcode_t ext2fs_expand_dir(ext2_filsys fs, ino_t dir) struct expand_dir_struct es; struct ext2_inode inode; + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); + if (!(fs->flags & EXT2_FLAG_RW)) return EXT2_ET_RO_FILSYS; diff --git a/lib/ext2fs/ext2_err.c b/lib/ext2fs/ext2_err.c index 86bfcd34..f9759493 100644 --- a/lib/ext2fs/ext2_err.c +++ b/lib/ext2fs/ext2_err.c @@ -10,8 +10,27 @@ #endif static const char * const text[] = { - "EXT2FS Library version 0.0", + "EXT2FS Library version 0.5b", + "Wrong magic number for ext2_filsys structure", + "Wrong magic number for badblocks_list structure", + "Wrong magic number for badblocks_iterate structure", + "Wrong magic number for inode_scan structure", + "Wrong magic number for io_channel structure", + "Wrong magic number for unix io_channel structure", + "Wrong magic number for io_manager structure", + "Wrong magic number for block_bitmap structure", + "Wrong magic number for inode_bitmap structure", + "Wrong magic number --- RESERVED_1", + "Wrong magic number --- RESERVED_2", + "Wrong magic number --- RESERVED_3", + "Wrong magic number --- RESERVED_4", + "Wrong magic number --- RESERVED_5", + "Wrong magic number --- RESERVED_6", + "Wrong magic number --- RESERVED_7", + "Wrong magic number --- RESERVED_8", + "Wrong magic number --- RESERVED_9", "Bad magic number in super-block", + "Filesystem revision too high", "Can't seek to superblock", "Can't read superblock", "Can't write superblock", @@ -39,6 +58,17 @@ static const char * const text[] = { "Illegal block number", "Internal error in ext2fs_expand_dir", "Not enough space to build proposed filesystem", + "Illegal block number passed to ext2fs_mark_block_bitmap", + "Illegal block number passed to ext2fs_unmark_block_bitmap", + "Illegal block number passed to ext2fs_test_block_bitmap", + "Illegal inode number passed to ext2fs_mark_inode_bitmap", + "Illegal inode number passed to ext2fs_unmark_inode_bitmap", + "Illegal inode number passed to ext2fs_test_inode_bitmap", + "Attempt to fudge end of block bitmap past the real end", + "Attempt to fudge end of inode bitmap past the real end", + "Illegal indirect block found" , + "Illegal doubly indirect block found" , + "Illegal triply indirect block found" , 0 }; @@ -53,7 +83,7 @@ struct et_list { }; extern struct et_list *_et_list; -static const struct error_table et = { text, 2133571328L, 29 }; +static const struct error_table et = { text, 2133571328L, 59 }; static struct et_list link = { 0, 0 }; diff --git a/lib/ext2fs/ext2_err.et b/lib/ext2fs/ext2_err.et index 69eacda6..f439f5a2 100644 --- a/lib/ext2fs/ext2_err.et +++ b/lib/ext2fs/ext2_err.et @@ -1,15 +1,72 @@ # -# Copyright (C) 1993 Theodore Ts'o. This file may be redistributed +# Copyright (C) 1993, 1994 Theodore Ts'o. This file may be redistributed # under the terms of the GNU Public License. # error_table ext2 ec EXT2_ET_BASE, - "EXT2FS Library version 0.0" + "EXT2FS Library version 0.5b" + +ec EXT2_ET_MAGIC_EXT2FS_FILSYS, + "Wrong magic number for ext2_filsys structure" + +ec EXT2_ET_MAGIC_BADBLOCKS_LIST, + "Wrong magic number for badblocks_list structure" + +ec EXT2_ET_MAGIC_BADBLOCKS_ITERATE, + "Wrong magic number for badblocks_iterate structure" + +ec EXT2_ET_MAGIC_INODE_SCAN, + "Wrong magic number for inode_scan structure" + +ec EXT2_ET_MAGIC_IO_CHANNEL, + "Wrong magic number for io_channel structure" + +ec EXT2_ET_MAGIC_UNIX_IO_CHANNEL, + "Wrong magic number for unix io_channel structure" + +ec EXT2_ET_MAGIC_IO_MANAGER, + "Wrong magic number for io_manager structure" + +ec EXT2_ET_MAGIC_BLOCK_BITMAP, + "Wrong magic number for block_bitmap structure" + +ec EXT2_ET_MAGIC_INODE_BITMAP, + "Wrong magic number for inode_bitmap structure" + +ec EXT2_ET_MAGIC_RESERVED_1, + "Wrong magic number --- RESERVED_1" + +ec EXT2_ET_MAGIC_RESERVED_2, + "Wrong magic number --- RESERVED_2" + +ec EXT2_ET_MAGIC_RESERVED_3, + "Wrong magic number --- RESERVED_3" + +ec EXT2_ET_MAGIC_RESERVED_4, + "Wrong magic number --- RESERVED_4" + +ec EXT2_ET_MAGIC_RESERVED_5, + "Wrong magic number --- RESERVED_5" + +ec EXT2_ET_MAGIC_RESERVED_6, + "Wrong magic number --- RESERVED_6" + +ec EXT2_ET_MAGIC_RESERVED_7, + "Wrong magic number --- RESERVED_7" + +ec EXT2_ET_MAGIC_RESERVED_8, + "Wrong magic number --- RESERVED_8" + +ec EXT2_ET_MAGIC_RESERVED_9, + "Wrong magic number --- RESERVED_9" ec EXT2_ET_BAD_MAGIC, "Bad magic number in super-block" +ec EXT2_ET_REV_TOO_HIGH, + "Filesystem revision too high" + ec EXT2_ET_SB_LSEEK, "Can't seek to superblock" @@ -91,5 +148,38 @@ ec EXT2_ET_EXPAND_DIR_ERR, ec EXT2_ET_TOOSMALL, "Not enough space to build proposed filesystem" +ec EXT2_ET_BAD_BLOCK_MARK, + "Illegal block number passed to ext2fs_mark_block_bitmap" + +ec EXT2_ET_BAD_BLOCK_UNMARK, + "Illegal block number passed to ext2fs_unmark_block_bitmap" + +ec EXT2_ET_BAD_BLOCK_TEST, + "Illegal block number passed to ext2fs_test_block_bitmap" + +ec EXT2_ET_BAD_INODE_MARK, + "Illegal inode number passed to ext2fs_mark_inode_bitmap" + +ec EXT2_ET_BAD_INODE_UNMARK, + "Illegal inode number passed to ext2fs_unmark_inode_bitmap" + +ec EXT2_ET_BAD_INODE_TEST, + "Illegal inode number passed to ext2fs_test_inode_bitmap" + +ec EXT2_ET_FUDGE_BLOCK_BITMAP_END, + "Attempt to fudge end of block bitmap past the real end" + +ec EXT2_ET_FUDGE_INODE_BITMAP_END, + "Attempt to fudge end of inode bitmap past the real end" + +ec EXT2_ET_BAD_IND_BLOCK, + "Illegal indirect block found" + +ec EXT2_ET_BAD_DIND_BLOCK, + "Illegal doubly indirect block found" + +ec EXT2_ET_BAD_TIND_BLOCK, + "Illegal triply indirect block found" + end diff --git a/lib/ext2fs/ext2_err.h b/lib/ext2fs/ext2_err.h index 1e72cedc..0a93b1a1 100644 --- a/lib/ext2fs/ext2_err.h +++ b/lib/ext2fs/ext2_err.h @@ -10,34 +10,64 @@ #endif #define EXT2_ET_BASE (2133571328L) -#define EXT2_ET_BAD_MAGIC (2133571329L) -#define EXT2_ET_SB_LSEEK (2133571330L) -#define EXT2_ET_SB_READ (2133571331L) -#define EXT2_ET_SB_WRITE (2133571332L) -#define EXT2_ET_RO_FILSYS (2133571333L) -#define EXT2_ET_GDESC_READ (2133571334L) -#define EXT2_ET_GDESC_WRITE (2133571335L) -#define EXT2_ET_GDESC_BAD_BLOCK_MAP (2133571336L) -#define EXT2_ET_GDESC_BAD_INODE_MAP (2133571337L) -#define EXT2_ET_GDESC_BAD_INODE_TABLE (2133571338L) -#define EXT2_ET_INODE_BITMAP_WRITE (2133571339L) -#define EXT2_ET_INODE_BITMAP_READ (2133571340L) -#define EXT2_ET_BLOCK_BITMAP_WRITE (2133571341L) -#define EXT2_ET_BLOCK_BITMAP_READ (2133571342L) -#define EXT2_ET_INODE_TABLE_WRITE (2133571343L) -#define EXT2_ET_INODE_TABLE_READ (2133571344L) -#define EXT2_ET_NEXT_INODE_READ (2133571345L) -#define EXT2_ET_UNEXPECTED_BLOCK_SIZE (2133571346L) -#define EXT2_ET_DIR_CORRUPTED (2133571347L) -#define EXT2_ET_SHORT_READ (2133571348L) -#define EXT2_ET_SHORT_WRITE (2133571349L) -#define EXT2_ET_DIR_NO_SPACE (2133571350L) -#define EXT2_ET_NO_INODE_BITMAP (2133571351L) -#define EXT2_ET_NO_BLOCK_BITMAP (2133571352L) -#define EXT2_ET_BAD_INODE_NUM (2133571353L) -#define EXT2_ET_BAD_BLOCK_NUM (2133571354L) -#define EXT2_ET_EXPAND_DIR_ERR (2133571355L) -#define EXT2_ET_TOOSMALL (2133571356L) +#define EXT2_ET_MAGIC_EXT2FS_FILSYS (2133571329L) +#define EXT2_ET_MAGIC_BADBLOCKS_LIST (2133571330L) +#define EXT2_ET_MAGIC_BADBLOCKS_ITERATE (2133571331L) +#define EXT2_ET_MAGIC_INODE_SCAN (2133571332L) +#define EXT2_ET_MAGIC_IO_CHANNEL (2133571333L) +#define EXT2_ET_MAGIC_UNIX_IO_CHANNEL (2133571334L) +#define EXT2_ET_MAGIC_IO_MANAGER (2133571335L) +#define EXT2_ET_MAGIC_BLOCK_BITMAP (2133571336L) +#define EXT2_ET_MAGIC_INODE_BITMAP (2133571337L) +#define EXT2_ET_MAGIC_RESERVED_1 (2133571338L) +#define EXT2_ET_MAGIC_RESERVED_2 (2133571339L) +#define EXT2_ET_MAGIC_RESERVED_3 (2133571340L) +#define EXT2_ET_MAGIC_RESERVED_4 (2133571341L) +#define EXT2_ET_MAGIC_RESERVED_5 (2133571342L) +#define EXT2_ET_MAGIC_RESERVED_6 (2133571343L) +#define EXT2_ET_MAGIC_RESERVED_7 (2133571344L) +#define EXT2_ET_MAGIC_RESERVED_8 (2133571345L) +#define EXT2_ET_MAGIC_RESERVED_9 (2133571346L) +#define EXT2_ET_BAD_MAGIC (2133571347L) +#define EXT2_ET_REV_TOO_HIGH (2133571348L) +#define EXT2_ET_SB_LSEEK (2133571349L) +#define EXT2_ET_SB_READ (2133571350L) +#define EXT2_ET_SB_WRITE (2133571351L) +#define EXT2_ET_RO_FILSYS (2133571352L) +#define EXT2_ET_GDESC_READ (2133571353L) +#define EXT2_ET_GDESC_WRITE (2133571354L) +#define EXT2_ET_GDESC_BAD_BLOCK_MAP (2133571355L) +#define EXT2_ET_GDESC_BAD_INODE_MAP (2133571356L) +#define EXT2_ET_GDESC_BAD_INODE_TABLE (2133571357L) +#define EXT2_ET_INODE_BITMAP_WRITE (2133571358L) +#define EXT2_ET_INODE_BITMAP_READ (2133571359L) +#define EXT2_ET_BLOCK_BITMAP_WRITE (2133571360L) +#define EXT2_ET_BLOCK_BITMAP_READ (2133571361L) +#define EXT2_ET_INODE_TABLE_WRITE (2133571362L) +#define EXT2_ET_INODE_TABLE_READ (2133571363L) +#define EXT2_ET_NEXT_INODE_READ (2133571364L) +#define EXT2_ET_UNEXPECTED_BLOCK_SIZE (2133571365L) +#define EXT2_ET_DIR_CORRUPTED (2133571366L) +#define EXT2_ET_SHORT_READ (2133571367L) +#define EXT2_ET_SHORT_WRITE (2133571368L) +#define EXT2_ET_DIR_NO_SPACE (2133571369L) +#define EXT2_ET_NO_INODE_BITMAP (2133571370L) +#define EXT2_ET_NO_BLOCK_BITMAP (2133571371L) +#define EXT2_ET_BAD_INODE_NUM (2133571372L) +#define EXT2_ET_BAD_BLOCK_NUM (2133571373L) +#define EXT2_ET_EXPAND_DIR_ERR (2133571374L) +#define EXT2_ET_TOOSMALL (2133571375L) +#define EXT2_ET_BAD_BLOCK_MARK (2133571376L) +#define EXT2_ET_BAD_BLOCK_UNMARK (2133571377L) +#define EXT2_ET_BAD_BLOCK_TEST (2133571378L) +#define EXT2_ET_BAD_INODE_MARK (2133571379L) +#define EXT2_ET_BAD_INODE_UNMARK (2133571380L) +#define EXT2_ET_BAD_INODE_TEST (2133571381L) +#define EXT2_ET_FUDGE_BLOCK_BITMAP_END (2133571382L) +#define EXT2_ET_FUDGE_INODE_BITMAP_END (2133571383L) +#define EXT2_ET_BAD_IND_BLOCK (2133571384L) +#define EXT2_ET_BAD_DIND_BLOCK (2133571385L) +#define EXT2_ET_BAD_TIND_BLOCK (2133571386L) extern void initialize_ext2_error_table (NOARGS); #define ERROR_TABLE_BASE_ext2 (2133571328L) diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index 998527a1..672466b3 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -15,6 +15,12 @@ #define SUPERBLOCK_OFFSET 1024 #define SUPERBLOCK_SIZE 1024 +/* + * The last ext2fs revision level that this version of the library is + * able to support. + */ +#define EXT2_LIB_CURRENT_REV 0 + typedef unsigned long blk_t; typedef unsigned int dgrp_t; @@ -22,6 +28,32 @@ typedef unsigned int dgrp_t; #include "ext2fs/io.h" #include "ext2fs/ext2_err.h" +typedef struct struct_ext2_filsys *ext2_filsys; + +struct ext2fs_struct_inode_bitmap { + int magic; + ext2_filsys fs; + ino_t start, end; + ino_t real_end; + char *description; + char *bitmap; + int reserved[8]; +}; + +typedef struct ext2fs_struct_inode_bitmap *ext2fs_inode_bitmap; + +struct ext2fs_struct_block_bitmap { + int magic; + ext2_filsys fs; + blk_t start, end; + ino_t real_end; + char *description; + char *bitmap; + int reserved[8]; +}; + +typedef struct ext2fs_struct_block_bitmap *ext2fs_block_bitmap; + /* * Flags for the ext2_filsys structure */ @@ -33,9 +65,8 @@ typedef unsigned int dgrp_t; #define EXT2_FLAG_IB_DIRTY 0x10 #define EXT2_FLAG_BB_DIRTY 0x20 -typedef struct struct_ext2_filsys *ext2_filsys; - struct struct_ext2_filsys { + int magic; io_channel io; int flags; char * device_name; @@ -46,11 +77,12 @@ struct struct_ext2_filsys { unsigned long desc_blocks; struct ext2_group_desc * group_desc; int inode_blocks_per_group; - char * inode_map; - char * block_map; + ext2fs_inode_bitmap inode_map; + ext2fs_block_bitmap block_map; errcode_t (*get_blocks)(ext2_filsys fs, ino_t ino, blk_t *blocks); errcode_t (*check_directory)(ext2_filsys fs, ino_t ino); errcode_t (*write_bitmaps)(ext2_filsys fs); + int reserved[16]; /* * Not used by ext2fs library; reserved for the use of the @@ -66,10 +98,12 @@ struct struct_ext2_filsys { typedef struct struct_badblocks_list *badblocks_list; struct struct_badblocks_list { + int magic; int num; int size; blk_t *list; int badblocks_flags; + int reserved[8]; }; #define BADBLOCKS_FLAG_DIRTY 1 @@ -77,12 +111,14 @@ struct struct_badblocks_list { typedef struct struct_badblocks_iterate *badblocks_iterate; struct struct_badblocks_iterate { + int magic; badblocks_list bb; int ptr; + int reserved[8]; }; - -#include "ext2fs/bitops.h" +#include "ext2fs/bitops.h" + /* * Return flags for the block iterator functions */ @@ -112,7 +148,10 @@ struct struct_badblocks_iterate { /* * Inode scan definitions */ +typedef struct ext2_struct_inode_scan *ext2_inode_scan; + struct ext2_struct_inode_scan { + int magic; ext2_filsys fs; ino_t current_inode; blk_t current_block; @@ -121,21 +160,33 @@ struct ext2_struct_inode_scan { int inode_buffer_blocks; char * inode_buffer; struct ext2_inode * inode_scan_ptr; + errcode_t (*done_group)(ext2_filsys fs, + ext2_inode_scan scan, + dgrp_t group, + void * private); + void * done_group_data; + int reserved[8]; }; -typedef struct ext2_struct_inode_scan *ext2_inode_scan; +/* + * For checking structure magic numbers... + */ +#define EXT2_CHECK_MAGIC(struct, code) \ + if ((struct)->magic != (code)) return (code) + /* * function prototypes */ /* alloc.c */ extern errcode_t ext2fs_new_inode(ext2_filsys fs, ino_t dir, int mode, - char *map, ino_t *ret); + ext2fs_inode_bitmap map, ino_t *ret); extern errcode_t ext2fs_new_block(ext2_filsys fs, blk_t goal, - char *map, blk_t *ret); + ext2fs_block_bitmap map, blk_t *ret); extern errcode_t ext2fs_get_free_blocks(ext2_filsys fs, blk_t start, - blk_t finish, int num, char *map, + blk_t finish, int num, + ext2fs_block_bitmap map, blk_t *ret); /* badblocks.c */ @@ -157,8 +208,20 @@ extern errcode_t ext2fs_write_inode_bitmap(ext2_filsys fs); extern errcode_t ext2fs_write_block_bitmap (ext2_filsys fs); extern errcode_t ext2fs_read_inode_bitmap (ext2_filsys fs); extern errcode_t ext2fs_read_block_bitmap(ext2_filsys fs); -extern errcode_t ext2fs_allocate_inode_bitmap(ext2_filsys fs, char **ret); -extern errcode_t ext2fs_allocate_block_bitmap(ext2_filsys fs, char **ret); +errcode_t ext2fs_allocate_block_bitmap(ext2_filsys fs, + const char *descr, + ext2fs_block_bitmap *ret); +errcode_t ext2fs_allocate_inode_bitmap(ext2_filsys fs, + const char *descr, + ext2fs_inode_bitmap *ret); +errcode_t ext2fs_fudge_inode_bitmap_end(ext2fs_inode_bitmap bitmap, + ino_t end, ino_t *oend); +errcode_t ext2fs_fudge_block_bitmap_end(ext2fs_block_bitmap bitmap, + blk_t end, blk_t *oend); +void ext2fs_clear_inode_bitmap(ext2fs_inode_bitmap bitmap); +void ext2fs_clear_block_bitmap(ext2fs_block_bitmap bitmap); +void ext2fs_free_block_bitmap(ext2fs_block_bitmap bitmap); +void ext2fs_free_inode_bitmap(ext2fs_inode_bitmap bitmap); extern errcode_t ext2fs_read_bitmaps(ext2_filsys fs); extern errcode_t ext2fs_write_bitmaps(ext2_filsys fs); @@ -173,6 +236,9 @@ extern errcode_t ext2fs_block_iterate(ext2_filsys fs, void *private), void *private); +/* check_desc.c */ +extern errcode_t ext2fs_check_desc(ext2_filsys fs); + /* closefs.c */ extern errcode_t ext2fs_close(ext2_filsys fs); extern errcode_t ext2fs_flush(ext2_filsys fs); @@ -194,6 +260,18 @@ extern errcode_t ext2fs_open_inode_scan(ext2_filsys fs, int buffer_blocks, extern void ext2fs_close_inode_scan(ext2_inode_scan scan); extern errcode_t ext2fs_get_next_inode(ext2_inode_scan scan, ino_t *ino, struct ext2_inode *inode); +void ext2fs_set_inode_callback(ext2_inode_scan scan, + errcode_t (*done_group)(ext2_filsys fs, + ext2_inode_scan scan, + dgrp_t group, + void * private), + void *done_group_data); +void ext2fs_set_inode_callback(ext2_inode_scan scan, + errcode_t (*done_group)(ext2_filsys fs, + ext2_inode_scan scan, + dgrp_t group, + void * private), + void *done_group_data); extern errcode_t ext2fs_read_inode (ext2_filsys fs, unsigned long ino, struct ext2_inode * inode); extern errcode_t ext2fs_write_inode(ext2_filsys fs, unsigned long ino, @@ -229,7 +307,6 @@ extern errcode_t ext2fs_mkdir(ext2_filsys fs, ino_t parent, ino_t inum, extern errcode_t ext2fs_open(const char *name, int flags, int superblock, int block_size, io_manager manager, ext2_filsys *ret_fs); -extern errcode_t ext2fs_check_desc(ext2_filsys fs); /* get_pathname.c */ extern errcode_t ext2fs_get_pathname(ext2_filsys fs, ino_t dir, ino_t ino, diff --git a/lib/ext2fs/freefs.c b/lib/ext2fs/freefs.c index ecd169af..d9d4fe98 100644 --- a/lib/ext2fs/freefs.c +++ b/lib/ext2fs/freefs.c @@ -9,14 +9,13 @@ #include <unistd.h> #include <stdlib.h> -#include <linux/fs.h> #include <linux/ext2_fs.h> #include "ext2fs.h" void ext2fs_free(ext2_filsys fs) { - if (!fs) + if (!fs || (fs->magic != EXT2_ET_MAGIC_EXT2FS_FILSYS)) return; if (fs->io) { io_channel_close(fs->io); diff --git a/lib/ext2fs/get_pathname.c b/lib/ext2fs/get_pathname.c index 591af6d4..a5db2e09 100644 --- a/lib/ext2fs/get_pathname.c +++ b/lib/ext2fs/get_pathname.c @@ -9,7 +9,7 @@ #include <string.h> #include <unistd.h> #include <stdlib.h> -#include <linux/fs.h> + #include <linux/ext2_fs.h> #include "ext2fs.h" @@ -92,7 +92,11 @@ static errcode_t ext2fs_get_pathname_int(ext2_filsys fs, ino_t dir, ino_t ino, return 0; } - ret = malloc(strlen(parent_name)+strlen(gp.name)+2); + if (gp.name) + ret = malloc(strlen(parent_name)+strlen(gp.name)+2); + else + ret = malloc(strlen(parent_name)+5); /* strlen("???") + 2 */ + if (!ret) { retval = ENOMEM; goto cleanup; @@ -121,6 +125,8 @@ errcode_t ext2fs_get_pathname(ext2_filsys fs, ino_t dir, ino_t ino, char *buf; errcode_t retval; + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); + buf = malloc(fs->blocksize); if (!buf) return ENOMEM; diff --git a/lib/ext2fs/initialize.c b/lib/ext2fs/initialize.c index e7e07c46..22e7eaf3 100644 --- a/lib/ext2fs/initialize.c +++ b/lib/ext2fs/initialize.c @@ -12,7 +12,6 @@ #include <sys/stat.h> #include <sys/types.h> -#include <linux/fs.h> #include <linux/ext2_fs.h> #include "ext2fs.h" @@ -29,6 +28,8 @@ errcode_t ext2fs_initialize(const char *name, int flags, int overhead = 0; blk_t group_block; int i, j; + int numblocks; + char *buf; if (!param || !param->s_blocks_count) return EINVAL; @@ -38,6 +39,7 @@ errcode_t ext2fs_initialize(const char *name, int flags, return ENOMEM; memset(fs, 0, sizeof(struct struct_ext2_filsys)); + fs->magic = EXT2_ET_MAGIC_EXT2FS_FILSYS; fs->flags = flags | EXT2_FLAG_RW; retval = manager->open(name, IO_FLAG_RW, &fs->io); if (retval) @@ -70,6 +72,10 @@ errcode_t ext2fs_initialize(const char *name, int flags, set_field(s_checkinterval, EXT2_DFL_CHECKINTERVAL); super->s_lastcheck = time(NULL); +#ifdef EXT2_OS_LINUX + super->s_creator_os = EXT2_OS_LINUX; +#endif + fs->blocksize = EXT2_BLOCK_SIZE(super); fs->fragsize = EXT2_FRAG_SIZE(super); frags_per_block = fs->blocksize / fs->fragsize; @@ -78,10 +84,13 @@ errcode_t ext2fs_initialize(const char *name, int flags, super->s_frags_per_group = super->s_blocks_per_group * frags_per_block; super->s_blocks_count = param->s_blocks_count; + super->s_r_blocks_count = param->s_r_blocks_count; + if (super->s_r_blocks_count >= param->s_blocks_count) { + retval = EINVAL; + goto cleanup; + } retry: - set_field(s_r_blocks_count, super->s_blocks_count/20); /* 5% default */ - fs->group_desc_count = (super->s_blocks_count - super->s_first_data_block + EXT2_BLOCKS_PER_GROUP(super) - 1) @@ -149,14 +158,24 @@ retry: * count. */ - retval = ext2fs_allocate_block_bitmap(fs, &fs->block_map); + buf = malloc(strlen(fs->device_name) + 80); + if (!buf) { + retval = ENOMEM; + goto cleanup; + } + + sprintf(buf, "block bitmap for %s", fs->device_name); + retval = ext2fs_allocate_block_bitmap(fs, buf, &fs->block_map); if (retval) goto cleanup; - retval = ext2fs_allocate_inode_bitmap(fs, &fs->inode_map); + sprintf(buf, "inode bitmap for %s", fs->device_name); + retval = ext2fs_allocate_inode_bitmap(fs, 0, &fs->inode_map); if (retval) goto cleanup; + free(buf); + fs->group_desc = malloc(fs->desc_blocks * fs->blocksize); if (!fs->group_desc) { retval = ENOMEM; @@ -164,11 +183,34 @@ retry: } memset(fs->group_desc, 0, fs->desc_blocks * fs->blocksize); + /* + * Reserve the superblock and group descriptors for each + * group, and fill in the correct group statistics for group. + * Note that although the block bitmap, inode bitmap, and + * inode table have not been allocated (and in fact won't be + * by this routine), they are accounted for nevertheless. + */ group_block = super->s_first_data_block; for (i = 0; i < fs->group_desc_count; i++) { for (j=0; j < fs->desc_blocks+1; j++) - ext2fs_mark_block_bitmap(fs, fs->block_map, + ext2fs_mark_block_bitmap(fs->block_map, group_block + j); + + if (i == fs->group_desc_count-1) { + numblocks = (fs->super->s_blocks_count - + fs->super->s_first_data_block) % + fs->super->s_blocks_per_group; + if (!numblocks) + numblocks = fs->super->s_blocks_per_group; + } else + numblocks = fs->super->s_blocks_per_group; + numblocks -= 3 + fs->desc_blocks + fs->inode_blocks_per_group; + + fs->group_desc[i].bg_free_blocks_count = numblocks; + fs->group_desc[i].bg_free_inodes_count = + fs->super->s_inodes_per_group; + fs->group_desc[i].bg_used_dirs_count = 0; + group_block += super->s_blocks_per_group; } diff --git a/lib/ext2fs/inline.c b/lib/ext2fs/inline.c index 6ec7387a..599fceb1 100644 --- a/lib/ext2fs/inline.c +++ b/lib/ext2fs/inline.c @@ -17,7 +17,6 @@ #include <sys/stat.h> #include <sys/types.h> -#include <linux/fs.h> #include <linux/ext2_fs.h> #define INCLUDE_INLINE_FUNCS diff --git a/lib/ext2fs/inode.c b/lib/ext2fs/inode.c index ba3cee8a..6a9c1785 100644 --- a/lib/ext2fs/inode.c +++ b/lib/ext2fs/inode.c @@ -12,7 +12,6 @@ #include <sys/stat.h> #include <sys/types.h> -#include <linux/fs.h> #include <linux/ext2_fs.h> #include "ext2fs.h" @@ -22,16 +21,21 @@ errcode_t ext2fs_open_inode_scan(ext2_filsys fs, int buffer_blocks, { ext2_inode_scan scan; + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); + scan = (ext2_inode_scan) malloc(sizeof(struct ext2_struct_inode_scan)); if (!scan) return ENOMEM; memset(scan, 0, sizeof(struct ext2_struct_inode_scan)); + scan->magic = EXT2_ET_MAGIC_INODE_SCAN; scan->fs = fs; scan->current_group = -1; scan->inode_buffer_blocks = buffer_blocks ? buffer_blocks : 8; scan->groups_left = fs->group_desc_count; scan->inode_buffer = malloc(scan->inode_buffer_blocks * fs->blocksize); + scan->done_group = 0; + scan->done_group_data = 0; if (!scan->inode_buffer) { free(scan); return ENOMEM; @@ -42,33 +46,63 @@ errcode_t ext2fs_open_inode_scan(ext2_filsys fs, int buffer_blocks, void ext2fs_close_inode_scan(ext2_inode_scan scan) { + if (!scan || (scan->magic != EXT2_ET_MAGIC_INODE_SCAN)) + return; + free(scan->inode_buffer); scan->inode_buffer = NULL; free(scan); return; } +void ext2fs_set_inode_callback(ext2_inode_scan scan, + errcode_t (*done_group)(ext2_filsys fs, + ext2_inode_scan scan, + dgrp_t group, + void * private), + void *done_group_data) +{ + if (!scan || (scan->magic != EXT2_ET_MAGIC_INODE_SCAN)) + return; + + scan->done_group = done_group; + scan->done_group_data = done_group_data; +} + errcode_t ext2fs_get_next_inode(ext2_inode_scan scan, ino_t *ino, struct ext2_inode *inode) { errcode_t retval; int num_blocks; + EXT2_CHECK_MAGIC(scan, EXT2_ET_MAGIC_INODE_SCAN); + if (!scan->inode_buffer) return EINVAL; if (scan->inodes_left <= 0) { if (scan->blocks_left <= 0) { - if (scan->groups_left <= 0) { - *ino = 0; - return 0; + if (scan->done_group) { + retval = (scan->done_group) + (scan->fs, scan, + scan->current_group, + scan->done_group_data); + if (retval) + return retval; } - scan->current_group++; - scan->groups_left--; + do { + if (scan->groups_left <= 0) { + *ino = 0; + return 0; + } + scan->current_group++; + scan->groups_left--; - scan->current_block = scan->fs->group_desc[scan->current_group].bg_inode_table; - scan->blocks_left = (EXT2_INODES_PER_GROUP(scan->fs->super) / - EXT2_INODES_PER_BLOCK(scan->fs->super)); + scan->current_block = + scan->fs->group_desc[scan->current_group].bg_inode_table; + scan->blocks_left = (EXT2_INODES_PER_GROUP(scan->fs->super) / + EXT2_INODES_PER_BLOCK(scan->fs->super)); + } while (scan->current_block == 0); } else { scan->current_block += scan->inode_buffer_blocks; } @@ -109,6 +143,8 @@ errcode_t ext2fs_read_inode (ext2_filsys fs, unsigned long ino, errcode_t retval; int i; + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); + if (ino > fs->super->s_inodes_count) return EXT2_ET_BAD_INODE_NUM; if (inode_buffer_size != fs->blocksize) { @@ -149,6 +185,8 @@ errcode_t ext2fs_write_inode(ext2_filsys fs, unsigned long ino, errcode_t retval; int i; + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); + if (!(fs->flags & EXT2_FLAG_RW)) return EXT2_ET_RO_FILSYS; @@ -194,6 +232,8 @@ errcode_t ext2fs_get_blocks(ext2_filsys fs, ino_t ino, blk_t *blocks) int i; errcode_t retval; + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); + if (ino > fs->super->s_inodes_count) return EXT2_ET_BAD_INODE_NUM; @@ -214,6 +254,8 @@ errcode_t ext2fs_check_directory(ext2_filsys fs, ino_t ino) struct ext2_inode inode; errcode_t retval; + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); + if (ino > fs->super->s_inodes_count) return EXT2_ET_BAD_INODE_NUM; diff --git a/lib/ext2fs/io.h b/lib/ext2fs/io.h index fd054f84..7a44a115 100644 --- a/lib/ext2fs/io.h +++ b/lib/ext2fs/io.h @@ -5,10 +5,23 @@ * under the terms of the GNU Public License. */ +/* + * ext2_loff_t is defined here since unix_io.c needs it. + */ +#if defined(__GNUC__) || defined(HAS_LONG_LONG) +typedef long long ext2_loff_t; +#else +typedef long ext2_loff_t; +#endif + +/* llseek.c */ +ext2_loff_t ext2_llseek (unsigned int, ext2_loff_t, unsigned int); + typedef struct struct_io_manager *io_manager; typedef struct struct_io_channel *io_channel; struct struct_io_channel { + int magic; io_manager manager; char *name; int block_size; @@ -26,10 +39,12 @@ struct struct_io_channel { size_t size, int actual_bytes_written, errcode_t error); + int reserved[16]; void *private_data; }; struct struct_io_manager { + int magic; const char *name; errcode_t (*open)(const char *name, int flags, io_channel *channel); errcode_t (*close)(io_channel channel); @@ -39,6 +54,7 @@ struct struct_io_manager { errcode_t (*write_blk)(io_channel channel, unsigned long block, int count, const void *data); errcode_t (*flush)(io_channel channel); + int reserved[16]; }; #define IO_FLAG_RW 1 diff --git a/lib/ext2fs/jump/jump.funcs b/lib/ext2fs/jump/jump.funcs new file mode 100644 index 00000000..a8f5674b --- /dev/null +++ b/lib/ext2fs/jump/jump.funcs @@ -0,0 +1,75 @@ +00000000 T _ext2fs_open libext2fs openfs +00000000 T _ext2fs_check_desc libext2fs openfs +00000000 T _ext2fs_free libext2fs freefs +00000000 T _ext2fs_flush libext2fs closefs +00000000 T _ext2fs_close libext2fs closefs +00000000 T _ext2fs_allocate_inode_bitmap libext2fs bitmaps +00000000 T _ext2fs_allocate_block_bitmap libext2fs bitmaps +00000000 T _ext2fs_free_inode_bitmap libext2fs bitmaps +00000000 T _ext2fs_free_block_bitmap libext2fs bitmaps +00000000 T _ext2fs_fudge_inode_bitmap_end libext2fs bitmaps +00000000 T _ext2fs_fudge_block_bitmap_end libext2fs bitmaps +00000000 T _ext2fs_clear_inode_bitmap libext2fs bitmaps +00000000 T _ext2fs_clear_block_bitmap libext2fs bitmaps +00000000 T _ext2fs_write_inode_bitmap libext2fs rw_bitmaps +00000000 T _ext2fs_write_block_bitmap libext2fs rw_bitmaps +00000000 T _ext2fs_read_inode_bitmap libext2fs rw_bitmaps +00000000 T _ext2fs_read_block_bitmap libext2fs rw_bitmaps +00000000 T _ext2fs_read_bitmaps libext2fs rw_bitmaps +00000000 T _ext2fs_write_bitmaps libext2fs rw_bitmaps +00000000 T _ext2fs_open_inode_scan libext2fs inode +00000000 T _ext2fs_close_inode_scan libext2fs inode +00000000 T _ext2fs_get_next_inode libext2fs inode +00000000 T _ext2fs_read_inode libext2fs inode +00000000 T _ext2fs_write_inode libext2fs inode +00000000 T _ext2fs_get_blocks libext2fs inode +00000000 T _ext2fs_check_directory libext2fs inode +00000000 T _ext2fs_block_iterate libext2fs block +00000000 T _ext2fs_dir_iterate libext2fs namei +00000000 T _ext2fs_lookup libext2fs namei +00000000 T _ext2fs_namei libext2fs namei +00000000 T _ext2fs_new_dir_block libext2fs newdir +00000000 T _ext2fs_mkdir libext2fs mkdir +00000000 T _ext2fs_get_pathname libext2fs get_pathname +00000000 T _ext2fs_warn_bitmap libext2fs bitops +00000000 T _ext2fs_link libext2fs link +00000000 T _ext2fs_unlink libext2fs link +00000000 T _ext2fs_new_inode libext2fs alloc +00000000 T _ext2fs_new_block libext2fs alloc +00000000 T _ext2fs_get_free_blocks libext2fs alloc +00000000 T _ext2fs_expand_dir libext2fs expanddir +00000000 T _set_bit libext2fs inline +00000000 T _clear_bit libext2fs inline +00000000 T _test_bit libext2fs inline +00000000 T _ext2fs_mark_block_bitmap libext2fs inline +00000000 T _ext2fs_unmark_block_bitmap libext2fs inline +00000000 T _ext2fs_test_block_bitmap libext2fs inline +00000000 T _ext2fs_mark_inode_bitmap libext2fs inline +00000000 T _ext2fs_unmark_inode_bitmap libext2fs inline +00000000 T _ext2fs_test_inode_bitmap libext2fs inline +00000000 T _ext2fs_mark_super_dirty libext2fs inline +00000000 T _ext2fs_mark_changed libext2fs inline +00000000 T _ext2fs_test_changed libext2fs inline +00000000 T _ext2fs_mark_valid libext2fs inline +00000000 T _ext2fs_unmark_valid libext2fs inline +00000000 T _ext2fs_test_valid libext2fs inline +00000000 T _ext2fs_mark_ib_dirty libext2fs inline +00000000 T _ext2fs_mark_bb_dirty libext2fs inline +00000000 T _ext2fs_test_ib_dirty libext2fs inline +00000000 T _ext2fs_test_bb_dirty libext2fs inline +00000000 T _ext2fs_group_of_blk libext2fs inline +00000000 T _ext2fs_group_of_ino libext2fs inline +00000000 T _ext2fs_initialize libext2fs initialize +00000000 T _badblocks_list_create libext2fs badblocks +00000000 T _badblocks_list_free libext2fs badblocks +00000000 T _badblocks_list_add libext2fs badblocks +00000000 T _badblocks_list_test libext2fs badblocks +00000000 T _badblocks_list_iterate_begin libext2fs badblocks +00000000 T _badblocks_list_iterate libext2fs badblocks +00000000 T _badblocks_list_iterate_end libext2fs badblocks +00000000 T _ext2fs_read_bb_inode libext2fs read_bb +00000000 T _ext2fs_update_bb_inode libext2fs bb_inode +00000000 T _ext2fs_read_bb_FILE libext2fs read_bb_file +00000000 T _initialize_ext2_error_table libext2fs ext2_err +00000000 T _ext2_llseek libext2fs llseek +00000000 T _ext2fs_set_inode_callback libext2fs inode diff --git a/lib/ext2fs/jump/jump.import b/lib/ext2fs/jump/jump.import new file mode 100644 index 00000000..53208d55 --- /dev/null +++ b/lib/ext2fs/jump/jump.import @@ -0,0 +1,166 @@ +00000004 D __et_list libcom_err jump/error_message +00000004 D _com_err_hook libcom_err jump/com_err +/usr/lib/libc.sa(__libc.o):00001000 a __GOT_SIZE +/usr/lib/libc.sa(__libc.o):6008f0b0 A _AL +/usr/lib/libc.sa(__libc.o):6008f198 A _AL_PARM +/usr/lib/libc.sa(__libc.o):6008f060 A _AM +/usr/lib/libc.sa(__libc.o):6008f0b4 A _BC +/usr/lib/libc.sa(__libc.o):6008f064 A _BS +/usr/lib/libc.sa(__libc.o):6008f0bc A _BT +/usr/lib/libc.sa(__libc.o):6008f068 A _CA +/usr/lib/libc.sa(__libc.o):6008f0c0 A _CD +/usr/lib/libc.sa(__libc.o):6008f0c4 A _CE +/usr/lib/libc.sa(__libc.o):6008f0c8 A _CL +/usr/lib/libc.sa(__libc.o):6008f0cc A _CM +/usr/lib/libc.sa(__libc.o):6008f048 A _COLS +/usr/lib/libc.sa(__libc.o):6008f0d0 A _CR +/usr/lib/libc.sa(__libc.o):6008f0d4 A _CS +/usr/lib/libc.sa(__libc.o):6008f06c A _DA +/usr/lib/libc.sa(__libc.o):6008f070 A _DB +/usr/lib/libc.sa(__libc.o):6008f0d8 A _DC +/usr/lib/libc.sa(__libc.o):6008f0dc A _DL +/usr/lib/libc.sa(__libc.o):6008f19c A _DL_PARM +/usr/lib/libc.sa(__libc.o):6008f0e0 A _DM +/usr/lib/libc.sa(__libc.o):6008f0e4 A _DO +/usr/lib/libc.sa(__libc.o):6008f1a4 A _DOWN_PARM +/usr/lib/libc.sa(__libc.o):6008f03c A _Def_term +/usr/lib/libc.sa(__libc.o):6008f0e8 A _ED +/usr/lib/libc.sa(__libc.o):6008f0ec A _EI +/usr/lib/libc.sa(__libc.o):6008f074 A _EO +/usr/lib/libc.sa(__libc.o):6008f1b8 A _GT +/usr/lib/libc.sa(__libc.o):6008f078 A _HC +/usr/lib/libc.sa(__libc.o):6008f118 A _HO +/usr/lib/libc.sa(__libc.o):6008f07c A _HZ +/usr/lib/libc.sa(__libc.o):6008f11c A _IC +/usr/lib/libc.sa(__libc.o):6008f120 A _IM +/usr/lib/libc.sa(__libc.o):6008f080 A _IN +/usr/lib/libc.sa(__libc.o):6008f124 A _IP +/usr/lib/libc.sa(__libc.o):6008f0f0 A _K0 +/usr/lib/libc.sa(__libc.o):6008f0f4 A _K1 +/usr/lib/libc.sa(__libc.o):6008f0f8 A _K2 +/usr/lib/libc.sa(__libc.o):6008f0fc A _K3 +/usr/lib/libc.sa(__libc.o):6008f100 A _K4 +/usr/lib/libc.sa(__libc.o):6008f104 A _K5 +/usr/lib/libc.sa(__libc.o):6008f108 A _K6 +/usr/lib/libc.sa(__libc.o):6008f10c A _K7 +/usr/lib/libc.sa(__libc.o):6008f110 A _K8 +/usr/lib/libc.sa(__libc.o):6008f114 A _K9 +/usr/lib/libc.sa(__libc.o):6008f128 A _KD +/usr/lib/libc.sa(__libc.o):6008f12c A _KE +/usr/lib/libc.sa(__libc.o):6008f130 A _KH +/usr/lib/libc.sa(__libc.o):6008f134 A _KL +/usr/lib/libc.sa(__libc.o):6008f138 A _KR +/usr/lib/libc.sa(__libc.o):6008f13c A _KS +/usr/lib/libc.sa(__libc.o):6008f140 A _KU +/usr/lib/libc.sa(__libc.o):6008f1a8 A _LEFT_PARM +/usr/lib/libc.sa(__libc.o):6008f044 A _LINES +/usr/lib/libc.sa(__libc.o):6008f144 A _LL +/usr/lib/libc.sa(__libc.o):6008f148 A _MA +/usr/lib/libc.sa(__libc.o):6008f300 A _MCAppPath +/usr/lib/libc.sa(__libc.o):6008f084 A _MI +/usr/lib/libc.sa(__libc.o):6008f088 A _MS +/usr/lib/libc.sa(__libc.o):6008f030 A _My_term +/usr/lib/libc.sa(__libc.o):6008f08c A _NC +/usr/lib/libc.sa(__libc.o):6008f14c A _ND +/usr/lib/libc.sa(__libc.o):6008f150 A _NL +/usr/lib/libc.sa(__libc.o):6008f1bc A _NONL +/usr/lib/libc.sa(__libc.o):6008f090 A _NS +/usr/lib/libc.sa(__libc.o):6008f094 A _OS +/usr/lib/libc.sa(__libc.o):6008f1b0 A _PC +/usr/lib/libc.sa(__libc.o):6008f154 A _RC +/usr/lib/libc.sa(__libc.o):6008f1ac A _RIGHT_PARM +/usr/lib/libc.sa(__libc.o):6008f158 A _SC +/usr/lib/libc.sa(__libc.o):6008f15c A _SE +/usr/lib/libc.sa(__libc.o):6008f160 A _SF +/usr/lib/libc.sa(__libc.o):6008f164 A _SO +/usr/lib/libc.sa(__libc.o):6008f168 A _SR +/usr/lib/libc.sa(__libc.o):6008f16c A _TA +/usr/lib/libc.sa(__libc.o):6008f170 A _TE +/usr/lib/libc.sa(__libc.o):6008f174 A _TI +/usr/lib/libc.sa(__libc.o):6008f178 A _UC +/usr/lib/libc.sa(__libc.o):6008f17c A _UE +/usr/lib/libc.sa(__libc.o):6008f098 A _UL +/usr/lib/libc.sa(__libc.o):6008f180 A _UP +/usr/lib/libc.sa(__libc.o):6008f1c0 A _UPPERCASE +/usr/lib/libc.sa(__libc.o):6008f1a0 A _UP_PARM +/usr/lib/libc.sa(__libc.o):6008f188 A _US +/usr/lib/libc.sa(__libc.o):6008f18c A _VB +/usr/lib/libc.sa(__libc.o):6008f194 A _VE +/usr/lib/libc.sa(__libc.o):6008f190 A _VS +/usr/lib/libc.sa(__libc.o):6008f09c A _XB +/usr/lib/libc.sa(__libc.o):6008f0a0 A _XN +/usr/lib/libc.sa(__libc.o):6008f0a8 A _XS +/usr/lib/libc.sa(__libc.o):6008f0a4 A _XT +/usr/lib/libc.sa(__libc.o):6008f0ac A _XX +/usr/lib/libc.sa(__libc.o):6008f2a4 A __IO_file_jumps +/usr/lib/libc.sa(__libc.o):6008f1f4 A __IO_list_all +/usr/lib/libc.sa(__libc.o):6008f2a8 A __IO_proc_jumps +/usr/lib/libc.sa(__libc.o):6008f1ec A __IO_stderr_ +/usr/lib/libc.sa(__libc.o):6008f1e4 A __IO_stdin_ +/usr/lib/libc.sa(__libc.o):6008f1e8 A __IO_stdout_ +/usr/lib/libc.sa(__libc.o):6008f2ac A __IO_str_jumps +/usr/lib/libc.sa(__libc.o):6008f214 A ____brk_addr +/usr/lib/libc.sa(__libc.o):6008f01c A ___ctype_b +/usr/lib/libc.sa(__libc.o):6008f020 A ___ctype_tolower +/usr/lib/libc.sa(__libc.o):6008f024 A ___ctype_toupper +/usr/lib/libc.sa(__libc.o):6008f1fc A ___environ +/usr/lib/libc.sa(__libc.o):6008f250 A ___exit_funcs +/usr/lib/libc.sa(__libc.o):6008f2f0 A ___glob_closedir_hook +/usr/lib/libc.sa(__libc.o):6008f2f4 A ___glob_opendir_hook +/usr/lib/libc.sa(__libc.o):6008f2f8 A ___glob_readdir_hook +/usr/lib/libc.sa(__libc.o):6008f278 A ___ttyname +/usr/lib/libc.sa(__libc.o):6008f238 A __collate_info +/usr/lib/libc.sa(__libc.o):6008f23c A __ctype_info +/usr/lib/libc.sa(__libc.o):6008f028 A __echoit +/usr/lib/libc.sa(__libc.o):6008f034 A __endwin +/usr/lib/libc.sa(__libc.o):6008f288 A __gdbm_fetch_val +/usr/lib/libc.sa(__libc.o):6008f280 A __gdbm_file +/usr/lib/libc.sa(__libc.o):6008f284 A __gdbm_memory +/usr/lib/libc.sa(__libc.o):6008f240 A __monetary_info +/usr/lib/libc.sa(__libc.o):6008f234 A __null_auth +/usr/lib/libc.sa(__libc.o):6008f244 A __numeric_info +/usr/lib/libc.sa(__libc.o):6008f2ec A __obstack +/usr/lib/libc.sa(__libc.o):6008f1c8 A __pfast +/usr/lib/libc.sa(__libc.o):6008f02c A __rawmode +/usr/lib/libc.sa(__libc.o):6008f1dc A __res +/usr/lib/libc.sa(__libc.o):6008f04c A __res_iflg +/usr/lib/libc.sa(__libc.o):6008f050 A __res_lflg +/usr/lib/libc.sa(__libc.o):6008f270 A __res_opcodes +/usr/lib/libc.sa(__libc.o):6008f274 A __res_resultcodes +/usr/lib/libc.sa(__libc.o):6008f248 A __response_info +/usr/lib/libc.sa(__libc.o):6008f2fc A __sigintr +/usr/lib/libc.sa(__libc.o):6008f00c A __sys_errlist +/usr/lib/libc.sa(__libc.o):6008f010 A __sys_nerr +/usr/lib/libc.sa(__libc.o):6008f014 A __sys_siglist +/usr/lib/libc.sa(__libc.o):6008f24c A __time_info +/usr/lib/libc.sa(__libc.o):6008f05c A __tty +/usr/lib/libc.sa(__libc.o):6008f040 A __tty_ch +/usr/lib/libc.sa(__libc.o):6008f1cc A __unctrl +/usr/lib/libc.sa(__libc.o):6008f27c A __win +/usr/lib/libc.sa(__libc.o):6008f058 A _curscr +/usr/lib/libc.sa(__libc.o):6008f228 A _daylight +/usr/lib/libc.sa(__libc.o):6008f200 A _errno +/usr/lib/libc.sa(__libc.o):6008f1d0 A _gdbm_errno +/usr/lib/libc.sa(__libc.o):6008f28c A _gdbm_version +/usr/lib/libc.sa(__libc.o):6008f008 A _h_errlist +/usr/lib/libc.sa(__libc.o):6008f1d8 A _h_errno +/usr/lib/libc.sa(__libc.o):6008f2a0 A _h_nerr +/usr/lib/libc.sa(__libc.o):6008f1c4 A _normtty +/usr/lib/libc.sa(__libc.o):6008f204 A _optarg +/usr/lib/libc.sa(__libc.o):6008f20c A _opterr +/usr/lib/libc.sa(__libc.o):6008f208 A _optind +/usr/lib/libc.sa(__libc.o):6008f2e4 A _optopt +/usr/lib/libc.sa(__libc.o):6008f218 A _ospeed +/usr/lib/libc.sa(__libc.o):6008f26c A _re_max_failures +/usr/lib/libc.sa(__libc.o):6008f210 A _re_syntax_options +/usr/lib/libc.sa(__libc.o):6008f1e0 A _rexecoptions +/usr/lib/libc.sa(__libc.o):6008f230 A _rpc_createerr +/usr/lib/libc.sa(__libc.o):6008f25c A _stderr +/usr/lib/libc.sa(__libc.o):6008f254 A _stdin +/usr/lib/libc.sa(__libc.o):6008f258 A _stdout +/usr/lib/libc.sa(__libc.o):6008f054 A _stdscr +/usr/lib/libc.sa(__libc.o):6008f2e8 A _svc_fdset +/usr/lib/libc.sa(__libc.o):6008f224 A _timezone +/usr/lib/libc.sa(__libc.o):6008f21c A _tputs_baud_rate +/usr/lib/libc.sa(__libc.o):6008f038 A _ttytype +/usr/lib/libc.sa(__libc.o):6008f220 A _tzname diff --git a/lib/ext2fs/jump/jump.params b/lib/ext2fs/jump/jump.params new file mode 100644 index 00000000..ea74d630 --- /dev/null +++ b/lib/ext2fs/jump/jump.params @@ -0,0 +1,6 @@ +Name=libe2fs +Text=0x66900000 +Data=0x00000000 +Jump=0x00001000 +GOT=0x00001000 +Version=1.0.0 diff --git a/lib/ext2fs/jump/jump.undefs b/lib/ext2fs/jump/jump.undefs new file mode 100644 index 00000000..94699926 --- /dev/null +++ b/lib/ext2fs/jump/jump.undefs @@ -0,0 +1,2 @@ +66909078 D __NEEDS_SHRLIB_libc_4 +6690908c D __NEEDS_SHRLIB_libet_1 diff --git a/lib/ext2fs/jump/jump.vars b/lib/ext2fs/jump/jump.vars new file mode 100644 index 00000000..edbbf7c7 --- /dev/null +++ b/lib/ext2fs/jump/jump.vars @@ -0,0 +1 @@ +00000004 D _unix_io_manager libext2fs unix_io diff --git a/lib/ext2fs/link.c b/lib/ext2fs/link.c index f0dbbc51..042183b9 100644 --- a/lib/ext2fs/link.c +++ b/lib/ext2fs/link.c @@ -9,7 +9,7 @@ #include <string.h> #include <unistd.h> #include <stdlib.h> -#include <linux/fs.h> + #include <linux/ext2_fs.h> #include "ext2fs.h" @@ -86,6 +86,8 @@ errcode_t ext2fs_link(ext2_filsys fs, ino_t dir, const char *name, ino_t ino, errcode_t retval; struct link_struct ls; + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); + if (!(fs->flags & EXT2_FLAG_RW)) return EXT2_ET_RO_FILSYS; @@ -129,6 +131,8 @@ errcode_t ext2fs_unlink(ext2_filsys fs, ino_t dir, const char *name, ino_t ino, errcode_t retval; struct link_struct ls; + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); + if (!(fs->flags & EXT2_FLAG_RW)) return EXT2_ET_RO_FILSYS; diff --git a/lib/ext2fs/llseek.c b/lib/ext2fs/llseek.c new file mode 100644 index 00000000..00fe3cdc --- /dev/null +++ b/lib/ext2fs/llseek.c @@ -0,0 +1,79 @@ +/* + * llseek.c -- stub calling the llseek system call + * + * Copyright (C) 1994 Remy Card. This file may be redistributed + * under the terms of the GNU Public License. + */ + +#include <sys/types.h> + +#include <errno.h> +#include <unistd.h> +#include <linux/unistd.h> +#include "et/com_err.h" +#include "ext2fs/io.h" + +#ifdef __linux__ + +#ifndef __NR__llseek +#define __NR__llseek 140 +#endif + +static int _llseek (unsigned int, unsigned long, + unsigned long, ext2_loff_t *, unsigned int); + +static _syscall5(int,_llseek,unsigned int,fd,unsigned long,offset_high, + unsigned long, offset_low,ext2_loff_t *,result, + unsigned int, origin) + +ext2_loff_t ext2_llseek (unsigned int fd, ext2_loff_t offset, + unsigned int origin) +{ + unsigned long offset_high; + unsigned long offset_low; + ext2_loff_t result; + int retval; + static int do_compat = 0; + + if (do_compat) { + compat_lseek: + if ((sizeof(off_t) < sizeof(ext2_loff_t)) && + (offset >= ((ext2_loff_t) 1 << ((sizeof(off_t)*8) -1)))) { + errno = -EINVAL; + return -1; + } + return lseek (fd, (off_t) offset, origin); + } + + offset_high = ((unsigned long long) offset) >> 32; + offset_low = ((unsigned long long) offset) & 0xffffffff; + retval = _llseek (fd, offset_high, offset_low, &result, origin); + if (retval == -1 && errno == ENOSYS) { + /* + * Just in case this code runs on top of an old kernel + * which does not support the llseek system call + */ + do_compat++; + goto compat_lseek; + } + if (retval == -1) + result = -1; + return result; +} + +#else + +ext2_loff_t ext2_llseek (unsigned int fd, ext2_loff_t offset, + unsigned int origin) +{ + if ((sizeof(off_t) < sizeof(ext2_loff_t)) && + (offset >= ((ext2_loff_t) 1 << ((sizeof(off_t)*8) -1)))) { + errno = -EINVAL; + return -1; + } + return lseek (fd, (off_t) offset, origin); +} + +#endif + + diff --git a/lib/ext2fs/mkdir.c b/lib/ext2fs/mkdir.c index 03e49d8f..8bcb5426 100644 --- a/lib/ext2fs/mkdir.c +++ b/lib/ext2fs/mkdir.c @@ -14,7 +14,6 @@ #include <sys/stat.h> #include <sys/types.h> -#include <linux/fs.h> #include <linux/ext2_fs.h> #include "ext2fs.h" @@ -30,6 +29,8 @@ errcode_t ext2fs_mkdir(ext2_filsys fs, ino_t parent, ino_t inum, char *block = 0; int group; + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); + /* * Allocate an inode, if necessary */ @@ -109,9 +110,9 @@ errcode_t ext2fs_mkdir(ext2_filsys fs, ino_t parent, ino_t inum, /* * Update accounting.... */ - ext2fs_mark_block_bitmap(fs, fs->block_map, blk); + ext2fs_mark_block_bitmap(fs->block_map, blk); ext2fs_mark_bb_dirty(fs); - ext2fs_mark_inode_bitmap(fs, fs->inode_map, ino); + ext2fs_mark_inode_bitmap(fs->inode_map, ino); ext2fs_mark_ib_dirty(fs); group = ext2fs_group_of_blk(fs, blk); diff --git a/lib/ext2fs/namei.c b/lib/ext2fs/namei.c index 3bb6d570..da382f71 100644 --- a/lib/ext2fs/namei.c +++ b/lib/ext2fs/namei.c @@ -9,7 +9,7 @@ #include <string.h> #include <unistd.h> #include <stdlib.h> -#include <linux/fs.h> + #include <linux/ext2_fs.h> #include "ext2fs.h" @@ -46,6 +46,8 @@ errcode_t ext2fs_dir_iterate(ext2_filsys fs, struct dir_context ctx; errcode_t retval; + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); + retval = ext2fs_check_directory(fs, dir); if (retval) return retval; @@ -155,6 +157,8 @@ errcode_t ext2fs_lookup(ext2_filsys fs, ino_t dir, const char *name, errcode_t retval; struct lookup_struct ls; + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); + ls.name = name; ls.len = namelen; ls.inode = inode; @@ -176,6 +180,8 @@ errcode_t ext2fs_namei(ext2_filsys fs, ino_t root, ino_t cwd, const char *name, int len; errcode_t retval; + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); + buf = malloc(fs->blocksize); if (!buf) return ENOMEM; diff --git a/lib/ext2fs/newdir.c b/lib/ext2fs/newdir.c index 948bad9f..d1018c17 100644 --- a/lib/ext2fs/newdir.c +++ b/lib/ext2fs/newdir.c @@ -9,7 +9,7 @@ #include <string.h> #include <unistd.h> #include <stdlib.h> -#include <linux/fs.h> + #include <linux/ext2_fs.h> #include "ext2fs.h" @@ -24,6 +24,8 @@ errcode_t ext2fs_new_dir_block(ext2_filsys fs, ino_t dir_ino, ino_t parent_ino, struct ext2_dir_entry *dir = NULL; int rec_len; + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); + buf = malloc(fs->blocksize); if (!buf) return ENOMEM; diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c index b63b7aaa..d6f5432d 100644 --- a/lib/ext2fs/openfs.c +++ b/lib/ext2fs/openfs.c @@ -14,7 +14,6 @@ #include <sys/stat.h> #include <sys/types.h> -#include <linux/fs.h> #include <linux/ext2_fs.h> #include "ext2fs.h" @@ -31,11 +30,14 @@ errcode_t ext2fs_open(const char *name, int flags, int superblock, int i, group_block; char *dest; + EXT2_CHECK_MAGIC(manager, EXT2_ET_MAGIC_IO_MANAGER); + fs = (ext2_filsys) malloc(sizeof(struct struct_ext2_filsys)); if (!fs) return ENOMEM; memset(fs, 0, sizeof(struct struct_ext2_filsys)); + fs->magic = EXT2_ET_MAGIC_EXT2FS_FILSYS; fs->flags = flags; retval = manager->open(name, (flags & EXT2_FLAG_RW) ? IO_FLAG_RW : 0, &fs->io); @@ -65,9 +67,11 @@ errcode_t ext2fs_open(const char *name, int flags, int superblock, goto cleanup; } io_channel_set_blksize(fs->io, block_size); + group_block = superblock + 1; } else { io_channel_set_blksize(fs->io, SUPERBLOCK_OFFSET); superblock = 1; + group_block = 0; } retval = io_channel_read_blk(fs->io, superblock, -SUPERBLOCK_SIZE, fs->super); @@ -78,6 +82,12 @@ errcode_t ext2fs_open(const char *name, int flags, int superblock, retval = EXT2_ET_BAD_MAGIC; goto cleanup; } +#ifdef EXT2_CURRENT_REV + if (fs->super->s_rev_level > EXT2_LIB_CURRENT_REV) { + retval = EXT2_ET_REV_TOO_HIGH; + goto cleanup; + } +#endif fs->blocksize = EXT2_BLOCK_SIZE(fs->super); fs->fragsize = EXT2_FRAG_SIZE(fs->super); fs->inode_blocks_per_group = (fs->super->s_inodes_per_group / @@ -108,7 +118,8 @@ errcode_t ext2fs_open(const char *name, int flags, int superblock, retval = ENOMEM; goto cleanup; } - group_block = fs->super->s_first_data_block + 1; + if (!group_block) + group_block = fs->super->s_first_data_block + 1; dest = (char *) fs->group_desc; for (i=0 ; i < fs->desc_blocks; i++) { retval = io_channel_read_blk(fs->io, group_block, 1, dest); @@ -125,45 +136,3 @@ cleanup: return retval; } -/* - * This routine sanity checks the group descriptors - */ -errcode_t ext2fs_check_desc(ext2_filsys fs) -{ - int i; - int block = fs->super->s_first_data_block; - int next, inode_blocks_per_group; - - inode_blocks_per_group = fs->super->s_inodes_per_group / - EXT2_INODES_PER_BLOCK (fs->super); - - for (i = 0; i < fs->group_desc_count; i++) { - next = block + fs->super->s_blocks_per_group; - /* - * Check to make sure block bitmap for group is - * located within the group. - */ - if (fs->group_desc[i].bg_block_bitmap < block || - fs->group_desc[i].bg_block_bitmap >= next) - return EXT2_ET_GDESC_BAD_BLOCK_MAP; - /* - * Check to make sure inode bitmap for group is - * located within the group - */ - if (fs->group_desc[i].bg_inode_bitmap < block || - fs->group_desc[i].bg_inode_bitmap >= next) - return EXT2_ET_GDESC_BAD_INODE_MAP; - /* - * Check to make sure inode table for group is located - * within the group - */ - if (fs->group_desc[i].bg_inode_table < block || - fs->group_desc[i].bg_inode_table+inode_blocks_per_group >= - next) - return EXT2_ET_GDESC_BAD_INODE_TABLE; - - block = next; - } - return 0; -} - diff --git a/lib/ext2fs/read_bb.c b/lib/ext2fs/read_bb.c index 65663a0f..1a9f7742 100644 --- a/lib/ext2fs/read_bb.c +++ b/lib/ext2fs/read_bb.c @@ -14,7 +14,6 @@ #include <sys/stat.h> #include <sys/types.h> -#include <linux/fs.h> #include <linux/ext2_fs.h> #include "ext2fs.h" @@ -51,6 +50,8 @@ errcode_t ext2fs_read_bb_inode(ext2_filsys fs, badblocks_list *bb_list) struct ext2_inode inode; int numblocks; + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); + if (!*bb_list) { retval = ext2fs_read_inode(fs, EXT2_BAD_INO, &inode); if (retval) diff --git a/lib/ext2fs/read_bb_file.c b/lib/ext2fs/read_bb_file.c index db7b9107..c24674ba 100644 --- a/lib/ext2fs/read_bb_file.c +++ b/lib/ext2fs/read_bb_file.c @@ -14,7 +14,6 @@ #include <sys/stat.h> #include <sys/types.h> -#include <linux/fs.h> #include <linux/ext2_fs.h> #include "ext2fs.h" @@ -29,6 +28,9 @@ errcode_t ext2fs_read_bb_FILE(ext2_filsys fs, FILE *f, errcode_t retval; blk_t blockno; int count; + char buf[128]; + + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); if (!*bb_list) { retval = badblocks_list_create(bb_list, 10); @@ -37,9 +39,11 @@ errcode_t ext2fs_read_bb_FILE(ext2_filsys fs, FILE *f, } while (!feof (f)) { - count = fscanf (f, "%lu", &blockno); - if (count <= 0) + if (fgets(buf, sizeof(buf), f) == NULL) break; + count = sscanf(buf, "%lu", &blockno); + if (count <= 0) + continue; if ((blockno < fs->super->s_first_data_block) || (blockno >= fs->super->s_blocks_count)) { if (invalid) @@ -47,7 +51,8 @@ errcode_t ext2fs_read_bb_FILE(ext2_filsys fs, FILE *f, continue; } retval = badblocks_list_add(*bb_list, blockno); - return retval; + if (retval) + return retval; } return 0; } diff --git a/lib/ext2fs/rw_bitmaps.c b/lib/ext2fs/rw_bitmaps.c new file mode 100644 index 00000000..95232940 --- /dev/null +++ b/lib/ext2fs/rw_bitmaps.c @@ -0,0 +1,218 @@ +/* + * rw_bitmaps.c --- routines to read and write the inode and block bitmaps. + * + * Copyright (C) 1993,1994 Theodore Ts'o. This file may be redistributed + * under the terms of the GNU Public License. + */ + +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <stdlib.h> +#include <fcntl.h> +#include <time.h> +#include <sys/stat.h> +#include <sys/types.h> + +#include <linux/ext2_fs.h> + +#include "ext2fs.h" + +errcode_t ext2fs_write_inode_bitmap(ext2_filsys fs) +{ + int i; + int nbytes; + errcode_t retval; + char * inode_bitmap = fs->inode_map->bitmap; + char * bitmap_block = NULL; + + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); + + if (!(fs->flags & EXT2_FLAG_RW)) + return EXT2_ET_RO_FILSYS; + if (!inode_bitmap) + return 0; + nbytes = EXT2_INODES_PER_GROUP(fs->super) / 8; + bitmap_block = malloc(fs->blocksize); + if (!bitmap_block) + return ENOMEM; + memset(bitmap_block, 0xff, fs->blocksize); + for (i = 0; i < fs->group_desc_count; i++) { + memcpy(bitmap_block, inode_bitmap, nbytes); + retval = io_channel_write_blk(fs->io, + fs->group_desc[i].bg_inode_bitmap, 1, + bitmap_block); + if (retval) + return EXT2_ET_INODE_BITMAP_WRITE; + inode_bitmap += nbytes; + } + fs->flags |= EXT2_FLAG_CHANGED; + fs->flags &= ~EXT2_FLAG_IB_DIRTY; + free(bitmap_block); + return 0; +} + +errcode_t ext2fs_write_block_bitmap (ext2_filsys fs) +{ + int i; + int j; + int nbytes; + int nbits; + errcode_t retval; + char * block_bitmap = fs->block_map->bitmap; + char * bitmap_block = NULL; + + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); + + if (!(fs->flags & EXT2_FLAG_RW)) + return EXT2_ET_RO_FILSYS; + if (!block_bitmap) + return 0; + nbytes = EXT2_BLOCKS_PER_GROUP(fs->super) / 8; + bitmap_block = malloc(fs->blocksize); + if (!bitmap_block) + return ENOMEM; + memset(bitmap_block, 0xff, fs->blocksize); + for (i = 0; i < fs->group_desc_count; i++) { + memcpy(bitmap_block, block_bitmap, nbytes); + if (i == fs->group_desc_count - 1) { + /* Force bitmap padding for the last group */ + nbits = (fs->super->s_blocks_count + - fs->super->s_first_data_block) + % EXT2_BLOCKS_PER_GROUP(fs->super); + if (nbits) + for (j = nbits; j < fs->blocksize * 8; j++) + set_bit(j, bitmap_block); + } + retval = io_channel_write_blk(fs->io, + fs->group_desc[i].bg_block_bitmap, 1, + bitmap_block); + if (retval) + return EXT2_ET_BLOCK_BITMAP_WRITE; + block_bitmap += nbytes; + } + fs->flags |= EXT2_FLAG_CHANGED; + fs->flags &= ~EXT2_FLAG_BB_DIRTY; + free(bitmap_block); + return 0; +} + +static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) +{ + int i; + char *block_bitmap, *inode_bitmap; + char *buf; + errcode_t retval; + int block_nbytes = EXT2_BLOCKS_PER_GROUP(fs->super) / 8; + int inode_nbytes = EXT2_INODES_PER_GROUP(fs->super) / 8; + + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); + + fs->write_bitmaps = ext2fs_write_bitmaps; + + buf = malloc(strlen(fs->device_name) + 80); + if (do_block) { + if (fs->block_map) + ext2fs_free_block_bitmap(fs->block_map); + sprintf(buf, "block bitmap for %s", fs->device_name); + retval = ext2fs_allocate_block_bitmap(fs, buf, &fs->block_map); + if (retval) + goto cleanup; + block_bitmap = fs->block_map->bitmap; + } + if (do_inode) { + if (fs->inode_map) + ext2fs_free_inode_bitmap(fs->inode_map); + sprintf(buf, "inode bitmap for %s", fs->device_name); + retval = ext2fs_allocate_inode_bitmap(fs, buf, &fs->inode_map); + if (retval) + goto cleanup; + inode_bitmap = fs->inode_map->bitmap; + } + free(buf); + buf = malloc(fs->blocksize); + if (!buf) { + retval = ENOMEM; + goto cleanup; + } + + for (i = 0; i < fs->group_desc_count; i++) { + if (do_block) { + retval = io_channel_read_blk + (fs->io, + fs->group_desc[i].bg_block_bitmap, + 1, buf); + if (retval) { + retval = EXT2_ET_BLOCK_BITMAP_READ; + goto cleanup; + } + memcpy(block_bitmap, buf, block_nbytes); + block_bitmap += block_nbytes; + } + if (do_inode) { + retval = io_channel_read_blk + (fs->io, + fs->group_desc[i].bg_inode_bitmap, + 1, buf); + if (retval) { + retval = EXT2_ET_INODE_BITMAP_READ; + goto cleanup; + } + memcpy(inode_bitmap, buf, inode_nbytes); + inode_bitmap += inode_nbytes; + } + } + free(buf); + return 0; + +cleanup: + if (do_block) { + free(fs->block_map); + fs->block_map = 0; + } + if (do_inode) { + free(fs->inode_map); + fs->inode_map = 0; + } + if (buf) + free(buf); + return retval; +} + +errcode_t ext2fs_read_inode_bitmap (ext2_filsys fs) +{ + return read_bitmaps(fs, 1, 0); +} + +errcode_t ext2fs_read_block_bitmap(ext2_filsys fs) +{ + return read_bitmaps(fs, 0, 1); +} + +errcode_t ext2fs_read_bitmaps(ext2_filsys fs) +{ + + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); + + return read_bitmaps(fs, !fs->inode_map, !fs->block_map); +} + +errcode_t ext2fs_write_bitmaps(ext2_filsys fs) +{ + errcode_t retval; + + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); + + if (fs->block_map && ext2fs_test_bb_dirty(fs)) { + retval = ext2fs_write_block_bitmap(fs); + if (retval) + return retval; + } + if (fs->inode_map && ext2fs_test_ib_dirty(fs)) { + retval = ext2fs_write_inode_bitmap(fs); + if (retval) + return retval; + } + return 0; +} + diff --git a/lib/ext2fs/rw_bitmaps.size b/lib/ext2fs/rw_bitmaps.size new file mode 100644 index 00000000..5a3c9449 --- /dev/null +++ b/lib/ext2fs/rw_bitmaps.size @@ -0,0 +1,2 @@ +text data bss dec hex +1720 0 0 1720 6b8 diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c index 1137870e..5126583e 100644 --- a/lib/ext2fs/unix_io.c +++ b/lib/ext2fs/unix_io.c @@ -20,7 +20,15 @@ #include "ext2_err.h" #include "io.h" +/* + * For checking structure magic numbers... + */ + +#define EXT2_CHECK_MAGIC(struct, code) \ + if ((struct)->magic != (code)) return (code) + struct unix_private_data { + int magic; int dev; int flags; char *buf; @@ -36,7 +44,8 @@ static errcode_t unix_write_blk(io_channel channel, unsigned long block, int count, const void *data); static errcode_t unix_flush(io_channel channel); -struct struct_io_manager struct_unix_manager = { +static struct struct_io_manager struct_unix_manager = { + EXT2_ET_MAGIC_IO_MANAGER, "Unix I/O Manager", unix_open, unix_close, @@ -57,6 +66,8 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel) io = (io_channel) malloc(sizeof(struct struct_io_channel)); if (!io) return ENOMEM; + memset(io, 0, sizeof(struct struct_io_channel)); + io->magic = EXT2_ET_MAGIC_IO_CHANNEL; data = (struct unix_private_data *) malloc(sizeof(struct unix_private_data)); if (!data) { @@ -71,9 +82,12 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel) } strcpy(io->name, name); io->private_data = data; + io->block_size = 1024; + io->read_error = 0; + io->write_error = 0; memset(data, 0, sizeof(struct unix_private_data)); - io->block_size = 1024; + data->magic = EXT2_ET_MAGIC_UNIX_IO_CHANNEL; data->buf = malloc(io->block_size); data->buf_block_nr = -1; if (!data->buf) { @@ -104,7 +118,10 @@ static errcode_t unix_close(io_channel channel) struct unix_private_data *data; errcode_t retval = 0; + EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL); data = (struct unix_private_data *) channel->private_data; + EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL); + if (close(data->dev) < 0) retval = errno; if (data->buf) @@ -121,7 +138,10 @@ static errcode_t unix_set_blksize(io_channel channel, int blksize) { struct unix_private_data *data; + EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL); data = (struct unix_private_data *) channel->private_data; + EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL); + if (channel->block_size != blksize) { channel->block_size = blksize; free(data->buf); @@ -140,9 +160,12 @@ static errcode_t unix_read_blk(io_channel channel, unsigned long block, struct unix_private_data *data; errcode_t retval; size_t size; + ext2_loff_t location; int actual = 0; + EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL); data = (struct unix_private_data *) channel->private_data; + EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL); /* * If it's in the cache, use it! @@ -151,9 +174,12 @@ static errcode_t unix_read_blk(io_channel channel, unsigned long block, memcpy(buf, data->buf, channel->block_size); return 0; } +#if 0 + printf("read_block %lu (%d)\n", block, count); +#endif size = (count < 0) ? -count : count * channel->block_size; - if (lseek(data->dev, block * channel->block_size, SEEK_SET) != - block * channel->block_size) { + location = (ext2_loff_t) block * channel->block_size; + if (ext2_llseek(data->dev, location, SEEK_SET) != location) { retval = errno; goto error_out; } @@ -183,10 +209,13 @@ static errcode_t unix_write_blk(io_channel channel, unsigned long block, { struct unix_private_data *data; size_t size; + ext2_loff_t location; int actual = 0; errcode_t retval; + EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL); data = (struct unix_private_data *) channel->private_data; + EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL); if (count == 1) size = channel->block_size; @@ -197,9 +226,9 @@ static errcode_t unix_write_blk(io_channel channel, unsigned long block, else size = count * channel->block_size; } - - if (lseek(data->dev, block * channel->block_size, SEEK_SET) != - block * channel->block_size) { + + location = (ext2_loff_t) block * channel->block_size; + if (ext2_llseek(data->dev, location, SEEK_SET) != location) { retval = errno; goto error_out; } @@ -228,6 +257,12 @@ error_out: */ static errcode_t unix_flush(io_channel channel) { + struct unix_private_data *data; + + EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL); + data = (struct unix_private_data *) channel->private_data; + EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL); + return 0; } diff --git a/lib/fpopen.c b/lib/fpopen.c new file mode 100644 index 00000000..f12ab90f --- /dev/null +++ b/lib/fpopen.c @@ -0,0 +1,91 @@ +/* + * fpopen.c --- unlike the libc popen, it directly executes the + * command instead of call out to the shell. + */ + +#include <unistd.h> +#include <stdlib.h> +#include <stdio.h> +#include <errno.h> +#include <string.h> +#include <ctype.h> + +#define MAX_ARGV 256 + +extern FILE *fpopen(const char *cmd, const char *mode); + +FILE *fpopen(const char *cmd, const char *mode) +{ + char *argv[MAX_ARGV]; + int i = 0; + char *buf, *prog = 0; + char *p; + int do_stdin; + int fds[2]; + pid_t pid; + + if (!mode) { + errno = EFAULT; + return NULL; + } + + switch (*mode) { + case 'r': + do_stdin = 0; + break; + case 'w': + do_stdin = 1; + break; + default: + errno = EINVAL; + return NULL; + } + + /* + * Create the argv vector.... + */ + buf = malloc(strlen(cmd)+1); + if (!buf) + return NULL; + strcpy(buf, cmd); + p = buf; + while (p && *p) { + if (isspace(*p)) { + p++; + continue; + } + if (i == 0) + prog = p; + argv[i++] = p; + p = strchr(p, ' '); + if (p) + *p++ = 0; + } + + argv[i] = 0; + + /* + * Get the pipe + */ + if (pipe(fds) < 0) + return NULL; + + /* Fork and execute the correct program. */ + if ((pid = fork()) < 0) { + perror("fork"); + return NULL; + } else if (pid == 0) { + if (do_stdin) { + close(fds[1]); + dup2(fds[0], 0); + } else { + close(fds[0]); + dup2(fds[1], 1); + } + (void) execvp(prog, argv); + perror(prog); + exit(1); + } + return fdopen(do_stdin ? fds[1] : fds[0], mode); +} + diff --git a/lib/ss/.depend b/lib/ss/.depend index 64a78dc8..b35a6829 100644 --- a/lib/ss/.depend +++ b/lib/ss/.depend @@ -6,50 +6,59 @@ error.o : error.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/ /usr/include/libio.h /usr/include/_G_config.h copyright.h ../et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ ss_internal.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ ss.h ../ss/mit-sipb-copyright.h ../ss/ss_err.h -execute_cmd.o : execute_cmd.c ss_internal.h /usr/include/stdio.h /usr/include/features.h \ - /usr/include/sys/cdefs.h /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h ss.h ../ss/mit-sipb-copyright.h \ +execute_cmd.o : execute_cmd.c /usr/include/stdlib.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ + /usr/include/errno.h /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h ss_internal.h /usr/include/stdio.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/string.h ss.h ../ss/mit-sipb-copyright.h \ ../ss/ss_err.h copyright.h -help.o : help.c /usr/include/sys/param.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/limits.h \ +help.o : help.c /usr/include/unistd.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ + /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/asm/types.h \ + /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/sys/param.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/limits.h \ /usr/lib/gcc-lib/i486-linux/2.5.8/include/syslimits.h /usr/include/limits.h \ - /usr/include/features.h /usr/include/sys/cdefs.h /usr/include/posix1_lim.h /usr/include/linux/limits.h \ - /usr/include/posix2_lim.h /usr/include/linux/param.h /usr/include/sys/types.h \ - /usr/include/linux/types.h /usr/include/sys/file.h /usr/include/fcntl.h /usr/include/linux/fcntl.h \ - /usr/include/sys/wait.h /usr/include/gnu/types.h /usr/include/waitflags.h /usr/include/waitstatus.h \ - /usr/include/endian.h /usr/include/bytesex.h ss_internal.h /usr/include/stdio.h \ - /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ - ss.h ../ss/mit-sipb-copyright.h ../ss/ss_err.h copyright.h /usr/include/sys/dir.h \ - /usr/include/dirent.h /usr/include/linux/dirent.h -invocation.o : invocation.c ss_internal.h /usr/include/stdio.h /usr/include/features.h \ - /usr/include/sys/cdefs.h /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h ss.h ../ss/mit-sipb-copyright.h \ - ../ss/ss_err.h copyright.h + /usr/include/posix1_lim.h /usr/include/linux/limits.h /usr/include/posix2_lim.h \ + /usr/include/linux/param.h /usr/include/asm/param.h /usr/include/sys/file.h \ + /usr/include/fcntl.h /usr/include/linux/fcntl.h /usr/include/sys/wait.h /usr/include/waitflags.h \ + /usr/include/linux/wait.h /usr/include/waitstatus.h /usr/include/endian.h /usr/include/bytesex.h \ + ss_internal.h /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/string.h ss.h ../ss/mit-sipb-copyright.h ../ss/ss_err.h copyright.h \ + /usr/include/sys/dir.h /usr/include/dirent.h /usr/include/linux/dirent.h +invocation.o : invocation.c /usr/include/stdlib.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/errno.h /usr/include/linux/errno.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/alloca.h ss_internal.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h \ + ss.h ../ss/mit-sipb-copyright.h ../ss/ss_err.h copyright.h list_rqs.o : list_rqs.c copyright.h ss_internal.h /usr/include/stdio.h /usr/include/features.h \ /usr/include/sys/cdefs.h /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h \ /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h ss.h ../ss/mit-sipb-copyright.h \ ../ss/ss_err.h /usr/include/signal.h /usr/include/sys/types.h /usr/include/linux/types.h \ - /usr/include/linux/signal.h /usr/include/setjmp.h /usr/include/jmp_buf.h /usr/include/i386/jmp_buf.h \ - /usr/include/sys/wait.h /usr/include/gnu/types.h /usr/include/waitflags.h /usr/include/waitstatus.h \ + /usr/include/asm/types.h /usr/include/linux/signal.h /usr/include/setjmp.h /usr/include/jmp_buf.h \ + /usr/include/i386/jmp_buf.h /usr/include/sys/wait.h /usr/include/gnu/types.h \ + /usr/include/waitflags.h /usr/include/linux/wait.h /usr/include/waitstatus.h \ /usr/include/endian.h /usr/include/bytesex.h listen.o : listen.c copyright.h ss_internal.h /usr/include/stdio.h /usr/include/features.h \ /usr/include/sys/cdefs.h /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h \ /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h ss.h ../ss/mit-sipb-copyright.h \ ../ss/ss_err.h /usr/include/setjmp.h /usr/include/jmp_buf.h /usr/include/i386/jmp_buf.h \ - /usr/include/signal.h /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/linux/signal.h \ - /usr/include/sys/param.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/limits.h \ + /usr/include/signal.h /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/asm/types.h \ + /usr/include/linux/signal.h /usr/include/sys/param.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/limits.h \ /usr/lib/gcc-lib/i486-linux/2.5.8/include/syslimits.h /usr/include/limits.h \ /usr/include/posix1_lim.h /usr/include/linux/limits.h /usr/include/posix2_lim.h \ - /usr/include/linux/param.h -pager.o : pager.c ss_internal.h /usr/include/stdio.h /usr/include/features.h \ - /usr/include/sys/cdefs.h /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h ss.h ../ss/mit-sipb-copyright.h \ - ../ss/ss_err.h copyright.h /usr/include/sys/types.h /usr/include/linux/types.h \ + /usr/include/linux/param.h /usr/include/asm/param.h +pager.o : pager.c /usr/include/unistd.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ + /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/asm/types.h \ + ss_internal.h /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/string.h ss.h ../ss/mit-sipb-copyright.h ../ss/ss_err.h copyright.h \ /usr/include/sys/file.h /usr/include/fcntl.h /usr/include/linux/fcntl.h /usr/include/signal.h \ /usr/include/linux/signal.h -parse.o : parse.c ss_internal.h /usr/include/stdio.h /usr/include/features.h \ - /usr/include/sys/cdefs.h /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h ss.h ../ss/mit-sipb-copyright.h \ - ../ss/ss_err.h copyright.h +parse.o : parse.c /usr/include/stdlib.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/errno.h /usr/include/linux/errno.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/alloca.h ss_internal.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h \ + ss.h ../ss/mit-sipb-copyright.h ../ss/ss_err.h copyright.h prompt.o : prompt.c copyright.h /usr/include/stdio.h /usr/include/features.h \ /usr/include/sys/cdefs.h /usr/include/libio.h /usr/include/_G_config.h ss_internal.h \ /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h ss.h \ diff --git a/lib/ss/ChangeLog b/lib/ss/ChangeLog new file mode 100644 index 00000000..9c255538 --- /dev/null +++ b/lib/ss/ChangeLog @@ -0,0 +1,6 @@ +Sat Mar 11 18:14:52 1995 Theodore Y. Ts'o <tytso@localhost> + + * Makefile (DLL_INSTALL_DIR): Install libss in /lib, since it's + needed by debugfs (which is installed in /sbin). + + diff --git a/lib/ss/MAKELOG b/lib/ss/MAKELOG new file mode 100644 index 00000000..5356fcb7 --- /dev/null +++ b/lib/ss/MAKELOG @@ -0,0 +1,156 @@ +gcc -I. -I.. -I../et -O2 -fomit-frame-pointer -ansi -D_POSIX_SOURCE -pedantic -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wenum-clash -Wcast-align -Wtraditional -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -DWAIT_USES_INT -DHAS_STDLIB_H -DHAS_UNISTD_H -c ss_err.c +(export JUMP_DIR=`pwd`/jump; gcc -B/usr/dll/jump/ -I. -I.. -I../et -O2 -fomit-frame-pointer -ansi -D_POSIX_SOURCE -pedantic -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wenum-clash -Wcast-align -Wtraditional -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -DWAIT_USES_INT -DHAS_STDLIB_H -DHAS_UNISTD_H \ + -o jump/ss_err.o -c ss_err.c) +gcc -I. -I.. -I../et -O2 -fomit-frame-pointer -ansi -D_POSIX_SOURCE -pedantic -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wenum-clash -Wcast-align -Wtraditional -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -DWAIT_USES_INT -DHAS_STDLIB_H -DHAS_UNISTD_H -c std_rqs.c +(export JUMP_DIR=`pwd`/jump; gcc -B/usr/dll/jump/ -I. -I.. -I../et -O2 -fomit-frame-pointer -ansi -D_POSIX_SOURCE -pedantic -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wenum-clash -Wcast-align -Wtraditional -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -DWAIT_USES_INT -DHAS_STDLIB_H -DHAS_UNISTD_H \ + -o jump/std_rqs.o -c std_rqs.c) +gcc -I. -I.. -I../et -O2 -fomit-frame-pointer -ansi -D_POSIX_SOURCE -pedantic -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wenum-clash -Wcast-align -Wtraditional -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -DWAIT_USES_INT -DHAS_STDLIB_H -DHAS_UNISTD_H -c invocation.c +(export JUMP_DIR=`pwd`/jump; gcc -B/usr/dll/jump/ -I. -I.. -I../et -O2 -fomit-frame-pointer -ansi -D_POSIX_SOURCE -pedantic -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wenum-clash -Wcast-align -Wtraditional -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -DWAIT_USES_INT -DHAS_STDLIB_H -DHAS_UNISTD_H \ + -o jump/invocation.o -c invocation.c) +gcc -I. -I.. -I../et -O2 -fomit-frame-pointer -ansi -D_POSIX_SOURCE -pedantic -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wenum-clash -Wcast-align -Wtraditional -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -DWAIT_USES_INT -DHAS_STDLIB_H -DHAS_UNISTD_H -c help.c +help.c: In function `ss_help': +help.c:45: warning: implicit declaration of function `ss_list_requests' +help.c: At top level: +help.c:101: warning: function declaration isn't a prototype +(export JUMP_DIR=`pwd`/jump; gcc -B/usr/dll/jump/ -I. -I.. -I../et -O2 -fomit-frame-pointer -ansi -D_POSIX_SOURCE -pedantic -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wenum-clash -Wcast-align -Wtraditional -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -DWAIT_USES_INT -DHAS_STDLIB_H -DHAS_UNISTD_H \ + -o jump/help.o -c help.c) +help.c: In function `ss_help': +help.c:45: warning: implicit declaration of function `ss_list_requests' +help.c: At top level: +help.c:101: warning: function declaration isn't a prototype +gcc -I. -I.. -I../et -O2 -fomit-frame-pointer -ansi -D_POSIX_SOURCE -pedantic -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wenum-clash -Wcast-align -Wtraditional -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -DWAIT_USES_INT -DHAS_STDLIB_H -DHAS_UNISTD_H -c execute_cmd.c +execute_cmd.c:69: warning: function declaration isn't a prototype +execute_cmd.c:122: warning: function declaration isn't a prototype +execute_cmd.c:155: warning: return-type defaults to `int' +execute_cmd.c:155: warning: function declaration isn't a prototype +(export JUMP_DIR=`pwd`/jump; gcc -B/usr/dll/jump/ -I. -I.. -I../et -O2 -fomit-frame-pointer -ansi -D_POSIX_SOURCE -pedantic -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wenum-clash -Wcast-align -Wtraditional -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -DWAIT_USES_INT -DHAS_STDLIB_H -DHAS_UNISTD_H \ + -o jump/execute_cmd.o -c execute_cmd.c) +execute_cmd.c:69: warning: function declaration isn't a prototype +execute_cmd.c:122: warning: function declaration isn't a prototype +execute_cmd.c:155: warning: return-type defaults to `int' +execute_cmd.c:155: warning: function declaration isn't a prototype +gcc -I. -I.. -I../et -O2 -fomit-frame-pointer -ansi -D_POSIX_SOURCE -pedantic -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wenum-clash -Wcast-align -Wtraditional -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -DWAIT_USES_INT -DHAS_STDLIB_H -DHAS_UNISTD_H -c listen.c +listen.c:33: warning: function declaration isn't a prototype +listen.c:49: warning: function declaration isn't a prototype +listen.c: In function `ss_listen': +listen.c:60: warning: function declaration isn't a prototype +listen.c:60: warning: function declaration isn't a prototype +listen.c:60: warning: function declaration isn't a prototype +listen.c:70: warning: function declaration isn't a prototype +listen.c:72: warning: implicit declaration of function `sigblock' +listen.c:72: warning: implicit declaration of function `sigmask' +listen.c:76: warning: implicit declaration of function `sigsetmask' +listen.c:60: warning: variable `sig_cont' may be clobbered by `longjmp' or `vfork' +listen.c:63: warning: variable `end' may be clobbered by `longjmp' or `vfork' +listen.c: At top level: +listen.c:132: warning: function declaration isn't a prototype +listen.c: In function `ss_quit': +listen.c:138: warning: control reaches end of non-void function +listen.c: At top level: +listen.c:23: warning: `rcs_id' defined but not used +(export JUMP_DIR=`pwd`/jump; gcc -B/usr/dll/jump/ -I. -I.. -I../et -O2 -fomit-frame-pointer -ansi -D_POSIX_SOURCE -pedantic -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wenum-clash -Wcast-align -Wtraditional -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -DWAIT_USES_INT -DHAS_STDLIB_H -DHAS_UNISTD_H \ + -o jump/listen.o -c listen.c) +listen.c:33: warning: function declaration isn't a prototype +listen.c:49: warning: function declaration isn't a prototype +listen.c: In function `ss_listen': +listen.c:60: warning: function declaration isn't a prototype +listen.c:60: warning: function declaration isn't a prototype +listen.c:60: warning: function declaration isn't a prototype +listen.c:70: warning: function declaration isn't a prototype +listen.c:72: warning: implicit declaration of function `sigblock' +listen.c:72: warning: implicit declaration of function `sigmask' +listen.c:76: warning: implicit declaration of function `sigsetmask' +listen.c:60: warning: variable `sig_cont' may be clobbered by `longjmp' or `vfork' +listen.c:63: warning: variable `end' may be clobbered by `longjmp' or `vfork' +listen.c: At top level: +listen.c:132: warning: function declaration isn't a prototype +listen.c: In function `ss_quit': +listen.c:138: warning: control reaches end of non-void function +listen.c: At top level: +listen.c:23: warning: `rcs_id' defined but not used +gcc -I. -I.. -I../et -O2 -fomit-frame-pointer -ansi -D_POSIX_SOURCE -pedantic -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wenum-clash -Wcast-align -Wtraditional -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -DWAIT_USES_INT -DHAS_STDLIB_H -DHAS_UNISTD_H -c parse.c +(export JUMP_DIR=`pwd`/jump; gcc -B/usr/dll/jump/ -I. -I.. -I../et -O2 -fomit-frame-pointer -ansi -D_POSIX_SOURCE -pedantic -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wenum-clash -Wcast-align -Wtraditional -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -DWAIT_USES_INT -DHAS_STDLIB_H -DHAS_UNISTD_H \ + -o jump/parse.o -c parse.c) +gcc -I. -I.. -I../et -O2 -fomit-frame-pointer -ansi -D_POSIX_SOURCE -pedantic -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wenum-clash -Wcast-align -Wtraditional -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -DWAIT_USES_INT -DHAS_STDLIB_H -DHAS_UNISTD_H -c error.c +error.c:87: warning: no previous prototype for `ss_error' +error.c: In function `ss_error': +error.c:103: warning: implicit declaration of function `free' +(export JUMP_DIR=`pwd`/jump; gcc -B/usr/dll/jump/ -I. -I.. -I../et -O2 -fomit-frame-pointer -ansi -D_POSIX_SOURCE -pedantic -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wenum-clash -Wcast-align -Wtraditional -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -DWAIT_USES_INT -DHAS_STDLIB_H -DHAS_UNISTD_H \ + -o jump/error.o -c error.c) +error.c:87: warning: no previous prototype for `ss_error' +error.c: In function `ss_error': +error.c:103: warning: implicit declaration of function `free' +gcc -I. -I.. -I../et -O2 -fomit-frame-pointer -ansi -D_POSIX_SOURCE -pedantic -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wenum-clash -Wcast-align -Wtraditional -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -DWAIT_USES_INT -DHAS_STDLIB_H -DHAS_UNISTD_H -c prompt.c +prompt.c:23: warning: no previous prototype for `ss_set_prompt' +prompt.c:33: warning: no previous prototype for `ss_get_prompt' +(export JUMP_DIR=`pwd`/jump; gcc -B/usr/dll/jump/ -I. -I.. -I../et -O2 -fomit-frame-pointer -ansi -D_POSIX_SOURCE -pedantic -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wenum-clash -Wcast-align -Wtraditional -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -DWAIT_USES_INT -DHAS_STDLIB_H -DHAS_UNISTD_H \ + -o jump/prompt.o -c prompt.c) +prompt.c:23: warning: no previous prototype for `ss_set_prompt' +prompt.c:33: warning: no previous prototype for `ss_get_prompt' +gcc -I. -I.. -I../et -O2 -fomit-frame-pointer -ansi -D_POSIX_SOURCE -pedantic -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wenum-clash -Wcast-align -Wtraditional -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -DWAIT_USES_INT -DHAS_STDLIB_H -DHAS_UNISTD_H -c request_tbl.c +(export JUMP_DIR=`pwd`/jump; gcc -B/usr/dll/jump/ -I. -I.. -I../et -O2 -fomit-frame-pointer -ansi -D_POSIX_SOURCE -pedantic -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wenum-clash -Wcast-align -Wtraditional -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -DWAIT_USES_INT -DHAS_STDLIB_H -DHAS_UNISTD_H \ + -o jump/request_tbl.o -c request_tbl.c) +gcc -I. -I.. -I../et -O2 -fomit-frame-pointer -ansi -D_POSIX_SOURCE -pedantic -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wenum-clash -Wcast-align -Wtraditional -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -DWAIT_USES_INT -DHAS_STDLIB_H -DHAS_UNISTD_H -c list_rqs.c +list_rqs.c:25: warning: function declaration isn't a prototype +list_rqs.c: In function `ss_list_requests': +list_rqs.c:39: warning: function declaration isn't a prototype +list_rqs.c:51: warning: implicit declaration of function `sigblock' +list_rqs.c:51: warning: implicit declaration of function `sigmask' +list_rqs.c:53: warning: implicit declaration of function `ss_pager_create' +list_rqs.c:55: warning: implicit declaration of function `sigsetmask' +(export JUMP_DIR=`pwd`/jump; gcc -B/usr/dll/jump/ -I. -I.. -I../et -O2 -fomit-frame-pointer -ansi -D_POSIX_SOURCE -pedantic -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wenum-clash -Wcast-align -Wtraditional -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -DWAIT_USES_INT -DHAS_STDLIB_H -DHAS_UNISTD_H \ + -o jump/list_rqs.o -c list_rqs.c) +list_rqs.c:25: warning: function declaration isn't a prototype +list_rqs.c: In function `ss_list_requests': +list_rqs.c:39: warning: function declaration isn't a prototype +list_rqs.c:51: warning: implicit declaration of function `sigblock' +list_rqs.c:51: warning: implicit declaration of function `sigmask' +list_rqs.c:53: warning: implicit declaration of function `ss_pager_create' +list_rqs.c:55: warning: implicit declaration of function `sigsetmask' +gcc -I. -I.. -I../et -O2 -fomit-frame-pointer -ansi -D_POSIX_SOURCE -pedantic -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wenum-clash -Wcast-align -Wtraditional -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -DWAIT_USES_INT -DHAS_STDLIB_H -DHAS_UNISTD_H -c pager.c +pager.c:23: warning: function declaration isn't a prototype +pager.c:36: warning: function declaration isn't a prototype +pager.c: In function `ss_page_stdin': +pager.c:77: warning: implicit declaration of function `sigblock' +pager.c:78: warning: implicit declaration of function `sigmask' +pager.c:79: warning: implicit declaration of function `sigsetmask' +(export JUMP_DIR=`pwd`/jump; gcc -B/usr/dll/jump/ -I. -I.. -I../et -O2 -fomit-frame-pointer -ansi -D_POSIX_SOURCE -pedantic -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wenum-clash -Wcast-align -Wtraditional -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -DWAIT_USES_INT -DHAS_STDLIB_H -DHAS_UNISTD_H \ + -o jump/pager.o -c pager.c) +pager.c:23: warning: function declaration isn't a prototype +pager.c:36: warning: function declaration isn't a prototype +pager.c: In function `ss_page_stdin': +pager.c:77: warning: implicit declaration of function `sigblock' +pager.c:78: warning: implicit declaration of function `sigmask' +pager.c:79: warning: implicit declaration of function `sigsetmask' +gcc -I. -I.. -I../et -O2 -fomit-frame-pointer -ansi -D_POSIX_SOURCE -pedantic -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wenum-clash -Wcast-align -Wtraditional -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -DWAIT_USES_INT -DHAS_STDLIB_H -DHAS_UNISTD_H -c requests.c +requests.c:23: warning: no previous prototype for `ss_self_identify' +requests.c:33: warning: no previous prototype for `ss_subsystem_name' +requests.c:41: warning: no previous prototype for `ss_subsystem_version' +requests.c:50: warning: no previous prototype for `ss_unimplemented' +(export JUMP_DIR=`pwd`/jump; gcc -B/usr/dll/jump/ -I. -I.. -I../et -O2 -fomit-frame-pointer -ansi -D_POSIX_SOURCE -pedantic -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wenum-clash -Wcast-align -Wtraditional -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -DWAIT_USES_INT -DHAS_STDLIB_H -DHAS_UNISTD_H \ + -o jump/requests.o -c requests.c) +requests.c:23: warning: no previous prototype for `ss_self_identify' +requests.c:33: warning: no previous prototype for `ss_subsystem_name' +requests.c:41: warning: no previous prototype for `ss_subsystem_version' +requests.c:50: warning: no previous prototype for `ss_unimplemented' +gcc -I. -I.. -I../et -O2 -fomit-frame-pointer -ansi -D_POSIX_SOURCE -pedantic -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wenum-clash -Wcast-align -Wtraditional -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -DWAIT_USES_INT -DHAS_STDLIB_H -DHAS_UNISTD_H -c data.c +data.c:12: warning: `copyright' defined but not used +(export JUMP_DIR=`pwd`/jump; gcc -B/usr/dll/jump/ -I. -I.. -I../et -O2 -fomit-frame-pointer -ansi -D_POSIX_SOURCE -pedantic -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wenum-clash -Wcast-align -Wtraditional -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -DWAIT_USES_INT -DHAS_STDLIB_H -DHAS_UNISTD_H \ + -o jump/data.o -c data.c) +data.c:12: warning: `copyright' defined but not used +(cd jump; export JUMP_DIR=`pwd`; \ + /usr/dll/bin/mkimage -l libss -v 1.0.0 \ + -a 0x66880000 -j 0x1000 -g 0x1000 -- \ + ss_err.o std_rqs.o invocation.o help.o execute_cmd.o listen.o parse.o error.o prompt.o request_tbl.o list_rqs.o pager.o requests.o data.o -lc -L../.. -lcom_err "`gcc --print-libgcc-file-name`" -lc) +Warning - non-absolute pathname specified for library +listen.o: Undefined symbol _sigmask referenced from text segment +list_rqs.o: Undefined symbol _sigmask referenced from text segment +pager.o: Undefined symbol _sigmask referenced from text segment +system: No such file or directory + +/usr/dll/bin/mkimage: error running 'ld -x -T 66880000 -o libss.so.1.0.0 /u3/src/e2fsprogs-0.5b/lib/ss/jump/__jump.o ss_err.o std_rqs.o invocation.o help.o execute_cmd.o listen.o parse.o error.o prompt.o request_tbl.o list_rqs.o pager.o requests.o data.o -lc -L../.. -lcom_err /usr/lib/gcc-lib/i486-linux/2.5.8/libgcc.a -lc' + +mkimage v2.11 +Reading configuration files from /u3/src/e2fsprogs-0.5b/lib/ss/jump +executing:ld -x -T 66880000 -o libss.so.1.0.0 /u3/src/e2fsprogs-0.5b/lib/ss/jump/__jump.o ss_err.o std_rqs.o invocation.o help.o execute_cmd.o listen.o parse.o error.o prompt.o request_tbl.o list_rqs.o pager.o requests.o data.o -lc -L../.. -lcom_err /usr/lib/gcc-lib/i486-linux/2.5.8/libgcc.a -lc +make: *** [libss.so.1.0.0] Error 1 diff --git a/lib/ss/Makefile b/lib/ss/Makefile index af82f913..2f5ae92d 100644 --- a/lib/ss/Makefile +++ b/lib/ss/Makefile @@ -1,7 +1,21 @@ +# +# Makefile for lib/ss +# + include ../../MCONFIG -ARCHIVE=ar r -RANLIB=ranlib +ifdef BUILD_DLL_SHLIBS +DLL_ADDRESS = 0x66880000 +DLL_JUMPSIZE = 0x1000 +DLL_GOTSIZE = 0x1000 +DLL_VERSION = 1.0 +DLL_IMAGE = libss +DLL_STUB = libss +DLL_LIBS = -L../.. -lcom_err +DLL_MYDIR = ss +DLL_INSTALL_DIR = $(SHLIBDIR) +endif + RM=rm -f MV=mv LN=ln -s @@ -9,9 +23,11 @@ TAGS=etags COMPILE_ET=../et/compile_et MK_CMDS=../ss/mk_cmds +DEFS= -DWAIT_USES_INT -DHAS_STDLIB_H -DHAS_UNISTD_H -DPOSIX_SIGNALS + # hard coded .. is so that ss/ss_err.h works # hard coded ../et is so com_err.h works -CFLAGS= -I. -I.. -I../et $(OPT) +CFLAGS= -I. -I.. -I../et $(OPT) $(WFLAGS) $(DEFS) # hard coded for target install srcdir= . @@ -36,6 +52,10 @@ SRCS= invocation.c help.c \ ss_err.h # ss_err.h here, so that make depend catches it. +ifdef BUILD_DLL_SHLIBS +include ../Makefile.dll-lib +endif + CODE= $(SRCS) $(MKCMDSFILES) MKCMDSOBJS= mk_cmds.o utils.o options.o ct.tab.o cmd_tbl.lex.o @@ -61,25 +81,36 @@ FILES= $(SRCS) $(MKCMDSFILES) $(HFILES) \ # stuff to build # +.c.o: + $(CC) $(CFLAGS) -c $*.c +ifdef BUILD_DLL_SHLIBS + (export JUMP_DIR=`pwd`/jump; $(CC) -B$(JUMP_PREFIX) $(CFLAGS) \ + -o jump/$*.o -c $*.c) +endif + all:: mk_cmds libss.a # libss_p.a lint dist: archives -install:: all - $(INSTALLLIB) libss.a ${DESTDIR}$(LIBDIR)/libss.a - $(CHMOD) 644 ${DESTDIR}$(LIBDIR)/libss.a - $(RANLIB) ${DESTDIR}$(LIBDIR)/libss.a - $(CHMOD) $(LIBMODE) ${DESTDIR}$(LIBDIR)/libss.a +install:: + +install-libs:: all + $(INSTALLLIB) libss.a $(LIBDIR)/libss.a + $(CHMOD) 644 $(LIBDIR)/libss.a + $(RANLIB) $(LIBDIR)/libss.a + $(CHMOD) $(LIBMODE) $(LIBDIR)/libss.a -install:: $(HFILES) copyright.h - @rm -rf ${DESTDIR}$(INCLDIR)/ss - @mkdir ${DESTDIR}$(INCLDIR)/ss +install-libs:: $(HFILES) copyright.h + @rm -rf $(INCLDIR)/ss + @mkdir $(INCLDIR)/ss for i in $(HFILES) copyright.h; do \ - $(INSTALLINC) $(srcdir)/$$i ${DESTDIR}$(INCLDIR)/ss/$$i; \ + $(INSTALLINC) $(srcdir)/$$i $(INCLDIR)/ss/$$i; \ done -install:: copyright.h - $(INSTALLFILE) $(srcdir)/copyright.h ${DESTDIR}$(INCLDIR)/ss/mit-sipb-copyright.h +install-libs:: copyright.h + $(INSTALLINC) $(srcdir)/copyright.h $(INCLDIR)/ss/mit-sipb-copyright.h + +install-tree:: std_rqs.c: std_rqs.ct $(MK_CMDS) std_rqs.ct @@ -107,19 +138,19 @@ libss.a: $(OBJS) $(RM) ../$@ $(LN) ss/$@ ../$@ -clean: - $(RM) libss.a mk_cmds + +clean:: + $(RM) ../libss.a libss.a mk_cmds $(RM) *.o *~ \#* *.bak core -really-clean: clean - $(RM) .depend ss_err.h +really-clean:: clean + $(RM) .depend ss_err.h ss_err.c -#install:: -# $(INSTALLLIB) libss.a $(DESTDIR)$(LIBDIR)/libss.a -# $(CHMOD) 644 $(DESTDIR)$(LIBDIR)/libss.a -# $(RANLIB) $(DESTDIR)$(LIBDIR)/libss.a -# $(CHMOD) 444 $(DESTDIR)$(LIBDIR)/libss.a -## +install-libs:: + $(INSTALLLIB) libss.a $(LIBDIR)/libss.a + $(CHMOD) 644 $(LIBDIR)/libss.a + $(RANLIB) $(LIBDIR)/libss.a + $(CHMOD) 444 $(LIBDIR)/libss.a libss.o: $(OBJS) diff --git a/lib/ss/data.c b/lib/ss/data.c index dd6341c0..45e49d78 100644 --- a/lib/ss/data.c +++ b/lib/ss/data.c @@ -9,7 +9,7 @@ #include "ss_internal.h" #include "copyright.h" -const static char copyright[] = +static const char copyright[] = "Copyright 1987, 1988, 1989 by the Massachusetts Institute of Technology"; ss_data **_ss_table = (ss_data **)NULL; diff --git a/lib/ss/execute_cmd.c b/lib/ss/execute_cmd.c index 9442f339..be13dd83 100644 --- a/lib/ss/execute_cmd.c +++ b/lib/ss/execute_cmd.c @@ -4,15 +4,13 @@ * For copyright info, see copyright.h. */ +#ifdef HAS_STDLIB_H +#include <stdlib.h> +#endif #include "ss_internal.h" #include "copyright.h" #include <stdio.h> -#ifndef lint -static char const rcsid[] = - "$Header$"; -#endif - /* * get_request(tbl, idx) * diff --git a/lib/ss/help.c b/lib/ss/help.c index ad3b90b1..f956ca80 100644 --- a/lib/ss/help.c +++ b/lib/ss/help.c @@ -4,6 +4,12 @@ * For copyright info, see copyright.h. */ +#ifdef HAS_UNISTD_H +#include <unistd.h> +#endif +#ifdef HAS_STDLIB_H +#include <stdlib.h> +#endif #include <sys/param.h> #include <sys/types.h> #include <sys/file.h> @@ -79,7 +85,7 @@ got_it: ss_page_stdin(); default: (void) close(fd); /* what can we do if it fails? */ - while (wait((union wait *)NULL) != child) { + while (wait(0) != child) { /* do nothing if wrong pid */ }; } diff --git a/lib/ss/invocation.c b/lib/ss/invocation.c index 678bbcd8..c4c15ca8 100644 --- a/lib/ss/invocation.c +++ b/lib/ss/invocation.c @@ -3,15 +3,14 @@ * * For copyright information, see copyright.h. */ + +#ifdef HAS_STDLIB_H +#include <stdlib.h> +#endif #include "ss_internal.h" #include "copyright.h" #define size sizeof(ss_data *) -#ifndef lint -static char const rcsid[] = - "$Header$"; -#endif - int ss_create_invocation(subsystem_name, version_string, info_ptr, request_table_ptr, code_ptr) char *subsystem_name, *version_string; diff --git a/lib/ss/jump/jump.funcs b/lib/ss/jump/jump.funcs new file mode 100644 index 00000000..a8b08c62 --- /dev/null +++ b/lib/ss/jump/jump.funcs @@ -0,0 +1,26 @@ +00000000 T _initialize_ss_error_table libss jump/ss_err +00000000 T _ss_create_invocation libss jump/invocation +00000000 T _ss_delete_invocation libss jump/invocation +00000000 T _ss_help libss jump/help +00000000 T _ss_add_info_dir libss jump/help +00000000 T _ss_delete_info_dir libss jump/help +00000000 T _ss_execute_command libss jump/execute_cmd +00000000 T _ss_execute_line libss jump/execute_cmd +00000000 T _ss_listen libss jump/listen +00000000 T _ss_abort_subsystem libss jump/listen +00000000 T _ss_quit libss jump/listen +00000000 T _ss_parse libss jump/parse +00000000 T _ss_name libss jump/error +00000000 T _ss_error libss jump/error +00000000 T _ss_perror libss jump/error +00000000 T _ss_set_prompt libss jump/prompt +00000000 T _ss_get_prompt libss jump/prompt +00000000 T _ss_add_request_table libss jump/request_tbl +00000000 T _ss_delete_request_table libss jump/request_tbl +00000000 T _ss_list_requests libss jump/list_rqs +00000000 T _ss_pager_create libss jump/pager +00000000 T _ss_page_stdin libss jump/pager +00000000 T _ss_self_identify libss jump/requests +00000000 T _ss_subsystem_name libss jump/requests +00000000 T _ss_subsystem_version libss jump/requests +00000000 T _ss_unimplemented libss jump/requests diff --git a/lib/ss/jump/jump.import b/lib/ss/jump/jump.import new file mode 100644 index 00000000..53208d55 --- /dev/null +++ b/lib/ss/jump/jump.import @@ -0,0 +1,166 @@ +00000004 D __et_list libcom_err jump/error_message +00000004 D _com_err_hook libcom_err jump/com_err +/usr/lib/libc.sa(__libc.o):00001000 a __GOT_SIZE +/usr/lib/libc.sa(__libc.o):6008f0b0 A _AL +/usr/lib/libc.sa(__libc.o):6008f198 A _AL_PARM +/usr/lib/libc.sa(__libc.o):6008f060 A _AM +/usr/lib/libc.sa(__libc.o):6008f0b4 A _BC +/usr/lib/libc.sa(__libc.o):6008f064 A _BS +/usr/lib/libc.sa(__libc.o):6008f0bc A _BT +/usr/lib/libc.sa(__libc.o):6008f068 A _CA +/usr/lib/libc.sa(__libc.o):6008f0c0 A _CD +/usr/lib/libc.sa(__libc.o):6008f0c4 A _CE +/usr/lib/libc.sa(__libc.o):6008f0c8 A _CL +/usr/lib/libc.sa(__libc.o):6008f0cc A _CM +/usr/lib/libc.sa(__libc.o):6008f048 A _COLS +/usr/lib/libc.sa(__libc.o):6008f0d0 A _CR +/usr/lib/libc.sa(__libc.o):6008f0d4 A _CS +/usr/lib/libc.sa(__libc.o):6008f06c A _DA +/usr/lib/libc.sa(__libc.o):6008f070 A _DB +/usr/lib/libc.sa(__libc.o):6008f0d8 A _DC +/usr/lib/libc.sa(__libc.o):6008f0dc A _DL +/usr/lib/libc.sa(__libc.o):6008f19c A _DL_PARM +/usr/lib/libc.sa(__libc.o):6008f0e0 A _DM +/usr/lib/libc.sa(__libc.o):6008f0e4 A _DO +/usr/lib/libc.sa(__libc.o):6008f1a4 A _DOWN_PARM +/usr/lib/libc.sa(__libc.o):6008f03c A _Def_term +/usr/lib/libc.sa(__libc.o):6008f0e8 A _ED +/usr/lib/libc.sa(__libc.o):6008f0ec A _EI +/usr/lib/libc.sa(__libc.o):6008f074 A _EO +/usr/lib/libc.sa(__libc.o):6008f1b8 A _GT +/usr/lib/libc.sa(__libc.o):6008f078 A _HC +/usr/lib/libc.sa(__libc.o):6008f118 A _HO +/usr/lib/libc.sa(__libc.o):6008f07c A _HZ +/usr/lib/libc.sa(__libc.o):6008f11c A _IC +/usr/lib/libc.sa(__libc.o):6008f120 A _IM +/usr/lib/libc.sa(__libc.o):6008f080 A _IN +/usr/lib/libc.sa(__libc.o):6008f124 A _IP +/usr/lib/libc.sa(__libc.o):6008f0f0 A _K0 +/usr/lib/libc.sa(__libc.o):6008f0f4 A _K1 +/usr/lib/libc.sa(__libc.o):6008f0f8 A _K2 +/usr/lib/libc.sa(__libc.o):6008f0fc A _K3 +/usr/lib/libc.sa(__libc.o):6008f100 A _K4 +/usr/lib/libc.sa(__libc.o):6008f104 A _K5 +/usr/lib/libc.sa(__libc.o):6008f108 A _K6 +/usr/lib/libc.sa(__libc.o):6008f10c A _K7 +/usr/lib/libc.sa(__libc.o):6008f110 A _K8 +/usr/lib/libc.sa(__libc.o):6008f114 A _K9 +/usr/lib/libc.sa(__libc.o):6008f128 A _KD +/usr/lib/libc.sa(__libc.o):6008f12c A _KE +/usr/lib/libc.sa(__libc.o):6008f130 A _KH +/usr/lib/libc.sa(__libc.o):6008f134 A _KL +/usr/lib/libc.sa(__libc.o):6008f138 A _KR +/usr/lib/libc.sa(__libc.o):6008f13c A _KS +/usr/lib/libc.sa(__libc.o):6008f140 A _KU +/usr/lib/libc.sa(__libc.o):6008f1a8 A _LEFT_PARM +/usr/lib/libc.sa(__libc.o):6008f044 A _LINES +/usr/lib/libc.sa(__libc.o):6008f144 A _LL +/usr/lib/libc.sa(__libc.o):6008f148 A _MA +/usr/lib/libc.sa(__libc.o):6008f300 A _MCAppPath +/usr/lib/libc.sa(__libc.o):6008f084 A _MI +/usr/lib/libc.sa(__libc.o):6008f088 A _MS +/usr/lib/libc.sa(__libc.o):6008f030 A _My_term +/usr/lib/libc.sa(__libc.o):6008f08c A _NC +/usr/lib/libc.sa(__libc.o):6008f14c A _ND +/usr/lib/libc.sa(__libc.o):6008f150 A _NL +/usr/lib/libc.sa(__libc.o):6008f1bc A _NONL +/usr/lib/libc.sa(__libc.o):6008f090 A _NS +/usr/lib/libc.sa(__libc.o):6008f094 A _OS +/usr/lib/libc.sa(__libc.o):6008f1b0 A _PC +/usr/lib/libc.sa(__libc.o):6008f154 A _RC +/usr/lib/libc.sa(__libc.o):6008f1ac A _RIGHT_PARM +/usr/lib/libc.sa(__libc.o):6008f158 A _SC +/usr/lib/libc.sa(__libc.o):6008f15c A _SE +/usr/lib/libc.sa(__libc.o):6008f160 A _SF +/usr/lib/libc.sa(__libc.o):6008f164 A _SO +/usr/lib/libc.sa(__libc.o):6008f168 A _SR +/usr/lib/libc.sa(__libc.o):6008f16c A _TA +/usr/lib/libc.sa(__libc.o):6008f170 A _TE +/usr/lib/libc.sa(__libc.o):6008f174 A _TI +/usr/lib/libc.sa(__libc.o):6008f178 A _UC +/usr/lib/libc.sa(__libc.o):6008f17c A _UE +/usr/lib/libc.sa(__libc.o):6008f098 A _UL +/usr/lib/libc.sa(__libc.o):6008f180 A _UP +/usr/lib/libc.sa(__libc.o):6008f1c0 A _UPPERCASE +/usr/lib/libc.sa(__libc.o):6008f1a0 A _UP_PARM +/usr/lib/libc.sa(__libc.o):6008f188 A _US +/usr/lib/libc.sa(__libc.o):6008f18c A _VB +/usr/lib/libc.sa(__libc.o):6008f194 A _VE +/usr/lib/libc.sa(__libc.o):6008f190 A _VS +/usr/lib/libc.sa(__libc.o):6008f09c A _XB +/usr/lib/libc.sa(__libc.o):6008f0a0 A _XN +/usr/lib/libc.sa(__libc.o):6008f0a8 A _XS +/usr/lib/libc.sa(__libc.o):6008f0a4 A _XT +/usr/lib/libc.sa(__libc.o):6008f0ac A _XX +/usr/lib/libc.sa(__libc.o):6008f2a4 A __IO_file_jumps +/usr/lib/libc.sa(__libc.o):6008f1f4 A __IO_list_all +/usr/lib/libc.sa(__libc.o):6008f2a8 A __IO_proc_jumps +/usr/lib/libc.sa(__libc.o):6008f1ec A __IO_stderr_ +/usr/lib/libc.sa(__libc.o):6008f1e4 A __IO_stdin_ +/usr/lib/libc.sa(__libc.o):6008f1e8 A __IO_stdout_ +/usr/lib/libc.sa(__libc.o):6008f2ac A __IO_str_jumps +/usr/lib/libc.sa(__libc.o):6008f214 A ____brk_addr +/usr/lib/libc.sa(__libc.o):6008f01c A ___ctype_b +/usr/lib/libc.sa(__libc.o):6008f020 A ___ctype_tolower +/usr/lib/libc.sa(__libc.o):6008f024 A ___ctype_toupper +/usr/lib/libc.sa(__libc.o):6008f1fc A ___environ +/usr/lib/libc.sa(__libc.o):6008f250 A ___exit_funcs +/usr/lib/libc.sa(__libc.o):6008f2f0 A ___glob_closedir_hook +/usr/lib/libc.sa(__libc.o):6008f2f4 A ___glob_opendir_hook +/usr/lib/libc.sa(__libc.o):6008f2f8 A ___glob_readdir_hook +/usr/lib/libc.sa(__libc.o):6008f278 A ___ttyname +/usr/lib/libc.sa(__libc.o):6008f238 A __collate_info +/usr/lib/libc.sa(__libc.o):6008f23c A __ctype_info +/usr/lib/libc.sa(__libc.o):6008f028 A __echoit +/usr/lib/libc.sa(__libc.o):6008f034 A __endwin +/usr/lib/libc.sa(__libc.o):6008f288 A __gdbm_fetch_val +/usr/lib/libc.sa(__libc.o):6008f280 A __gdbm_file +/usr/lib/libc.sa(__libc.o):6008f284 A __gdbm_memory +/usr/lib/libc.sa(__libc.o):6008f240 A __monetary_info +/usr/lib/libc.sa(__libc.o):6008f234 A __null_auth +/usr/lib/libc.sa(__libc.o):6008f244 A __numeric_info +/usr/lib/libc.sa(__libc.o):6008f2ec A __obstack +/usr/lib/libc.sa(__libc.o):6008f1c8 A __pfast +/usr/lib/libc.sa(__libc.o):6008f02c A __rawmode +/usr/lib/libc.sa(__libc.o):6008f1dc A __res +/usr/lib/libc.sa(__libc.o):6008f04c A __res_iflg +/usr/lib/libc.sa(__libc.o):6008f050 A __res_lflg +/usr/lib/libc.sa(__libc.o):6008f270 A __res_opcodes +/usr/lib/libc.sa(__libc.o):6008f274 A __res_resultcodes +/usr/lib/libc.sa(__libc.o):6008f248 A __response_info +/usr/lib/libc.sa(__libc.o):6008f2fc A __sigintr +/usr/lib/libc.sa(__libc.o):6008f00c A __sys_errlist +/usr/lib/libc.sa(__libc.o):6008f010 A __sys_nerr +/usr/lib/libc.sa(__libc.o):6008f014 A __sys_siglist +/usr/lib/libc.sa(__libc.o):6008f24c A __time_info +/usr/lib/libc.sa(__libc.o):6008f05c A __tty +/usr/lib/libc.sa(__libc.o):6008f040 A __tty_ch +/usr/lib/libc.sa(__libc.o):6008f1cc A __unctrl +/usr/lib/libc.sa(__libc.o):6008f27c A __win +/usr/lib/libc.sa(__libc.o):6008f058 A _curscr +/usr/lib/libc.sa(__libc.o):6008f228 A _daylight +/usr/lib/libc.sa(__libc.o):6008f200 A _errno +/usr/lib/libc.sa(__libc.o):6008f1d0 A _gdbm_errno +/usr/lib/libc.sa(__libc.o):6008f28c A _gdbm_version +/usr/lib/libc.sa(__libc.o):6008f008 A _h_errlist +/usr/lib/libc.sa(__libc.o):6008f1d8 A _h_errno +/usr/lib/libc.sa(__libc.o):6008f2a0 A _h_nerr +/usr/lib/libc.sa(__libc.o):6008f1c4 A _normtty +/usr/lib/libc.sa(__libc.o):6008f204 A _optarg +/usr/lib/libc.sa(__libc.o):6008f20c A _opterr +/usr/lib/libc.sa(__libc.o):6008f208 A _optind +/usr/lib/libc.sa(__libc.o):6008f2e4 A _optopt +/usr/lib/libc.sa(__libc.o):6008f218 A _ospeed +/usr/lib/libc.sa(__libc.o):6008f26c A _re_max_failures +/usr/lib/libc.sa(__libc.o):6008f210 A _re_syntax_options +/usr/lib/libc.sa(__libc.o):6008f1e0 A _rexecoptions +/usr/lib/libc.sa(__libc.o):6008f230 A _rpc_createerr +/usr/lib/libc.sa(__libc.o):6008f25c A _stderr +/usr/lib/libc.sa(__libc.o):6008f254 A _stdin +/usr/lib/libc.sa(__libc.o):6008f258 A _stdout +/usr/lib/libc.sa(__libc.o):6008f054 A _stdscr +/usr/lib/libc.sa(__libc.o):6008f2e8 A _svc_fdset +/usr/lib/libc.sa(__libc.o):6008f224 A _timezone +/usr/lib/libc.sa(__libc.o):6008f21c A _tputs_baud_rate +/usr/lib/libc.sa(__libc.o):6008f038 A _ttytype +/usr/lib/libc.sa(__libc.o):6008f220 A _tzname diff --git a/lib/ss/jump/jump.params b/lib/ss/jump/jump.params new file mode 100644 index 00000000..2947e285 --- /dev/null +++ b/lib/ss/jump/jump.params @@ -0,0 +1,6 @@ +Name=libss +Text=0x66880000 +Data=0x00000000 +Jump=0x00001000 +GOT=0x00001000 +Version=1.0.0 diff --git a/lib/ss/jump/jump.undefs b/lib/ss/jump/jump.undefs new file mode 100644 index 00000000..1a2f89ac --- /dev/null +++ b/lib/ss/jump/jump.undefs @@ -0,0 +1,2 @@ +66885010 D __NEEDS_SHRLIB_libc_4 +66885024 D __NEEDS_SHRLIB_libet_1 diff --git a/lib/ss/jump/jump.vars b/lib/ss/jump/jump.vars new file mode 100644 index 00000000..95cd8e47 --- /dev/null +++ b/lib/ss/jump/jump.vars @@ -0,0 +1,3 @@ +00000020 K _ss_std_requests libss jump/std_rqs +00000004 D __ss_table libss jump/data +00000004 D __ss_pager_name libss jump/data diff --git a/lib/ss/list_rqs.c b/lib/ss/list_rqs.c index 14877bb1..8c797ad9 100644 --- a/lib/ss/list_rqs.c +++ b/lib/ss/list_rqs.c @@ -21,7 +21,7 @@ static char const twentyfive_spaces[26] = " "; static char const NL[2] = "\n"; -ss_list_requests(argc, argv, sci_idx, info_ptr) +void ss_list_requests(argc, argv, sci_idx, info_ptr) int argc; char **argv; int sci_idx; @@ -35,22 +35,38 @@ ss_list_requests(argc, argv, sci_idx, info_ptr) char buffer[BUFSIZ]; FILE *output; int fd; +#ifdef POSIX_SIGNALS + sigset_t omask, igmask; +#else int mask; +#endif sigret_t (*func)(); +#ifndef NO_FORK #ifndef WAIT_USES_INT union wait waitb; #else int waitb; #endif +#endif DONT_USE(argc); DONT_USE(argv); +#ifdef POSIX_SIGNALS + sigemptyset(&igmask); + sigaddset(&igmask, SIGINT); + sigprocmask(SIG_BLOCK, &igmask, &omask); +#else mask = sigblock(sigmask(SIGINT)); +#endif func = signal(SIGINT, SIG_IGN); fd = ss_pager_create(); output = fdopen(fd, "w"); +#ifdef POSIX_SIGNALS + sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0); +#else sigsetmask(mask); +#endif fprintf (output, "Available %s requests:\n\n", ss_info (sci_idx) -> subsystem_name); diff --git a/lib/ss/listen.c b/lib/ss/listen.c index 13844a09..765b7575 100644 --- a/lib/ss/listen.c +++ b/lib/ss/listen.c @@ -61,7 +61,11 @@ int ss_listen (sci_idx) char input[BUFSIZ]; char buffer[BUFSIZ]; char *end = buffer; +#ifdef POSIX_SIGNALS + sigset_t omask, igmask; +#else int mask; +#endif int code; jmp_buf old_jmpb; ss_data *old_info = current_info; @@ -69,11 +73,21 @@ int ss_listen (sci_idx) current_info = info = ss_info(sci_idx); sig_cont = (sigret_t (*)()) 0; info->abort = 0; +#ifdef POSIX_SIGNALS + sigemptyset(&igmask); + sigaddset(&igmask, SIGINT); + sigprocmask(SIG_BLOCK, &igmask, &omask); +#else mask = sigblock(sigmask(SIGINT)); +#endif memcpy(old_jmpb, listen_jmpb, sizeof(jmp_buf)); sig_int = signal(SIGINT, listen_int_handler); setjmp(listen_jmpb); +#ifdef POSIX_SIGNALS + sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0); +#else (void) sigsetmask(mask); +#endif while(!info->abort) { print_prompt(); *end = '\0'; diff --git a/lib/ss/pager.c b/lib/ss/pager.c index b951fa63..ff915dac 100644 --- a/lib/ss/pager.c +++ b/lib/ss/pager.c @@ -7,6 +7,10 @@ * For copyright information, see copyright.h. */ +#ifdef HAS_UNISTD_H +#include <unistd.h> +#endif + #include "ss_internal.h" #include "copyright.h" #include <stdio.h> @@ -26,7 +30,6 @@ extern int errno; * handle SIGINT sensibly * allow finer control -- put-page-break-here */ -void ss_page_stdin(); #ifndef NO_FORK int ss_pager_create() @@ -71,9 +74,17 @@ void ss_page_stdin() (void) close(i); (void) signal(SIGINT, SIG_DFL); { +#ifdef POSIX_SIGNALS + sigset_t mask; + + sigprocmask(SIG_BLOCK, 0, &mask); + sigdelset(&mask, SIGINT); + sigprocmask(SIG_SETMASK, &mask, 0); +#else int mask = sigblock(0); mask &= ~sigmask(SIGINT); sigsetmask(mask); +#endif } if (_ss_pager_name == (char *)NULL) { if ((_ss_pager_name = getenv("PAGER")) == (char *)NULL) diff --git a/lib/ss/parse.c b/lib/ss/parse.c index e1dec315..68a50649 100644 --- a/lib/ss/parse.c +++ b/lib/ss/parse.c @@ -4,14 +4,13 @@ * For copyright info, see copyright.h. */ +#ifdef HAS_STDLIB_H +#include <stdlib.h> +#endif + #include "ss_internal.h" #include "copyright.h" -#ifndef lint -static char const rcsid[] = - "$Header$"; -#endif - enum parse_mode { WHITESPACE, TOKEN, QUOTED_STRING }; /* diff --git a/lib/ss/prompt.c b/lib/ss/prompt.c index bc95d822..67d79eb3 100644 --- a/lib/ss/prompt.c +++ b/lib/ss/prompt.c @@ -13,19 +13,23 @@ #include <stdio.h> #include "ss_internal.h" -static const char rcsid[] = - "$Header$"; - -ss_set_prompt(sci_idx, new_prompt) +#ifdef __STDC__ +void ss_set_prompt(int sci_idx, char *new_prompt) +#else +void ss_set_prompt(sci_idx, new_prompt) int sci_idx; char *new_prompt; +#endif { ss_info(sci_idx)->prompt = new_prompt; } -char * -ss_get_prompt(sci_idx) +#ifdef __STDC__ +char *ss_get_prompt(int sci_idx) +#else +char *ss_get_prompt(sci_idx) int sci_idx; +#endif { return(ss_info(sci_idx)->prompt); } diff --git a/lib/ss/requests.c b/lib/ss/requests.c index bfe69f12..52053370 100644 --- a/lib/ss/requests.c +++ b/lib/ss/requests.c @@ -10,8 +10,12 @@ #include <stdio.h> #include "ss_internal.h" -#define DECLARE(name) name(argc,argv,sci_idx)int argc,sci_idx;char **argv; - +#ifdef __STDC__ +#define DECLARE(name) void name(int argc,char **argv, int sci_idx) +#else +#define DECLARE(name) void name(argc,argv,sci_idx)int argc,sci_idx;char **argv; +#endif + /* * ss_self_identify -- assigned by default to the "." request */ diff --git a/lib/ss/ss.h b/lib/ss/ss.h index 4fa3ebed..29aa9dcb 100644 --- a/lib/ss/ss.h +++ b/lib/ss/ss.h @@ -47,9 +47,11 @@ typedef struct _ss_rp_options { /* DEFAULT VALUES */ #define SS_OPT_DONT_SUMMARIZE 0x0002 void ss_help __SS_PROTO; -char *ss_current_request(); -char *ss_name(); +#if 0 +char *ss_current_request(); /* This is actually a macro */ +#endif #ifdef __STDC__ +char *ss_name(int sci_idx); void ss_error (int, long, char const *, ...); void ss_perror (int, long, char const *); int ss_create_invocation(char *, char *, char *, ss_request_table *, int *); @@ -57,7 +59,9 @@ void ss_delete_invocation(int); int ss_listen(int); void ss_add_request_table(int, ss_request_table *, int, int *); void ss_delete_request_table(int, ss_request_table *, int *); +void ss_abort_subsystem(int sci_idx, int code); #else +char *ss_name(); void ss_error (); void ss_perror (); int ss_create_invocation(); @@ -65,7 +69,7 @@ void ss_delete_invocation(); int ss_listen(); void ss_add_request_table(); void ss_delete_request_table(); -#endif void ss_abort_subsystem(); +#endif extern ss_request_table ss_std_requests; #endif /* _ss_h */ diff --git a/lib/ss/ss_internal.h b/lib/ss/ss_internal.h index 4b9ea23c..fc4a2adb 100644 --- a/lib/ss/ss_internal.h +++ b/lib/ss/ss_internal.h @@ -11,11 +11,13 @@ #ifdef __STDC__ +#define NOARGS void #define PROTOTYPE(p) p typedef void * pointer; #else +#define NOARGS #define const #define volatile #define PROTOTYPE(p) () @@ -95,12 +97,12 @@ typedef struct _ss_data { /* init values */ #define ss_info(sci_idx) (_ss_table[sci_idx]) #define ss_current_request(sci_idx,code_ptr) \ (*code_ptr=0,ss_info(sci_idx)->current_request) -void ss_unknown_function(); -void ss_delete_info_dir(); -int ss_execute_line(); -char **ss_parse(); +void ss_delete_info_dir PROTOTYPE((int sci_idx, char *info_dir, + int *code_ptr)); +int ss_execute_line PROTOTYPE((int sci_idx, char *line_ptr)); +char **ss_parse PROTOTYPE((int sci_idx, char *line_ptr, int *argc_ptr)); ss_abbrev_info *ss_abbrev_initialize PROTOTYPE((char *, int *)); -void ss_page_stdin(); +void ss_page_stdin(NOARGS); extern ss_data **_ss_table; extern char *ss_et_msgs[]; diff --git a/lib/ss/test_ss.c b/lib/ss/test_ss.c index 502256d2..ee9c087e 100644 --- a/lib/ss/test_ss.c +++ b/lib/ss/test_ss.c @@ -9,8 +9,8 @@ * $Locker$ * * $Log$ - * Revision 1.1 1997/04/26 13:21:42 tytso - * Checkin of e2fsprogs 0.5 + * Revision 1.2 1997/04/26 13:34:09 tytso + * Checkin of e2fsprogs 0.5b * * Revision 1.1 1993/06/03 12:31:25 tytso * Initial revision diff --git a/misc/.depend b/misc/.depend index 40b033a5..9466333b 100644 --- a/misc/.depend +++ b/misc/.depend @@ -1,98 +1,104 @@ badblocks.o : badblocks.c /usr/include/errno.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/linux/errno.h /usr/include/fcntl.h /usr/include/sys/types.h /usr/include/linux/types.h \ - /usr/include/linux/fcntl.h /usr/include/getopt.h /usr/include/signal.h /usr/include/linux/signal.h \ - /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h /usr/include/stdlib.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ - /usr/include/string.h /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h \ - /usr/include/sys/ioctl.h /usr/include/linux/ioctl.h /usr/include/termios.h /usr/include/linux/termios.h \ - /usr/include/linux/fd.h /usr/include/linux/fs.h /usr/include/linux/linkage.h \ - /usr/include/linux/limits.h /usr/include/linux/wait.h /usr/include/linux/dirent.h \ - /usr/include/linux/vfs.h /usr/include/linux/net.h /usr/include/linux/socket.h \ - /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h \ - /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h \ - /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h \ + /usr/include/asm/types.h /usr/include/linux/fcntl.h /usr/include/getopt.h /usr/include/signal.h \ + /usr/include/linux/signal.h /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/stdlib.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/string.h /usr/include/unistd.h /usr/include/posix_opt.h \ + /usr/include/gnu/types.h /usr/include/sys/ioctl.h /usr/include/linux/ioctl.h \ + /usr/include/termios.h /usr/include/linux/termios.h /usr/include/linux/fd.h \ + /usr/include/linux/fs.h /usr/include/linux/linkage.h /usr/include/linux/limits.h \ + /usr/include/linux/wait.h /usr/include/linux/dirent.h /usr/include/linux/vfs.h \ + /usr/include/linux/net.h /usr/include/linux/socket.h /usr/include/linux/sockios.h \ + /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h \ + /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h \ + /usr/include/linux/umsdos_fs_i.h /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h \ /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h \ - /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h /usr/include/linux/ext2_fs_sb.h \ - /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h /usr/include/linux/iso_fs_sb.h \ - /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h /usr/include/linux/sysv_fs_sb.h \ - ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h + ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../lib/ext2fs/io.h chattr.o : chattr.c /usr/include/dirent.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/gnu/types.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ - /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/linux/limits.h \ - /usr/include/linux/dirent.h /usr/include/fcntl.h /usr/include/linux/fcntl.h \ - /usr/include/getopt.h /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ - /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ - /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/sys/param.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/limits.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/syslimits.h /usr/include/limits.h \ - /usr/include/posix1_lim.h /usr/include/linux/param.h /usr/include/sys/stat.h \ - /usr/include/linux/stat.h /usr/include/linux/ext2_fs.h ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ - ../lib/e2p/e2p.h ../version.h + /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/asm/types.h \ + /usr/include/linux/limits.h /usr/include/linux/dirent.h /usr/include/posix1_lim.h \ + /usr/include/fcntl.h /usr/include/linux/fcntl.h /usr/include/getopt.h /usr/include/stdio.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/stdlib.h /usr/include/errno.h \ + /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/sys/param.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/limits.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/syslimits.h \ + /usr/include/limits.h /usr/include/posix2_lim.h /usr/include/linux/param.h /usr/include/asm/param.h \ + /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/linux/ext2_fs.h \ + ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../lib/e2p/e2p.h \ + ../version.h dumpe2fs.o : dumpe2fs.c /usr/include/getopt.h /usr/include/fcntl.h /usr/include/features.h \ /usr/include/sys/cdefs.h /usr/include/sys/types.h /usr/include/linux/types.h \ - /usr/include/linux/fcntl.h /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ - /usr/include/stdlib.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/errno.h \ - /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ - /usr/include/string.h /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h \ - /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ - ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h ../lib/e2p/e2p.h \ - /usr/include/dirent.h /usr/include/linux/limits.h /usr/include/linux/dirent.h \ + /usr/include/asm/types.h /usr/include/linux/fcntl.h /usr/include/stdio.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/stdlib.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ + /usr/include/errno.h /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/string.h /usr/include/unistd.h /usr/include/posix_opt.h \ + /usr/include/gnu/types.h /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h \ + ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../lib/ext2fs/io.h \ + ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h ../lib/e2p/e2p.h /usr/include/dirent.h \ + /usr/include/linux/limits.h /usr/include/linux/dirent.h /usr/include/posix1_lim.h \ ../version.h -fsck.o : fsck.c /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/sys/wait.h \ - /usr/include/features.h /usr/include/sys/cdefs.h /usr/include/gnu/types.h /usr/include/waitflags.h \ - /usr/include/waitstatus.h /usr/include/errno.h /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/limits.h \ +fsck.o : fsck.c /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/asm/types.h \ + /usr/include/sys/wait.h /usr/include/features.h /usr/include/sys/cdefs.h /usr/include/gnu/types.h \ + /usr/include/waitflags.h /usr/include/linux/wait.h /usr/include/waitstatus.h \ + /usr/include/endian.h /usr/include/bytesex.h /usr/include/sys/signal.h /usr/include/signal.h \ + /usr/include/linux/signal.h /usr/include/sys/stat.h /usr/include/linux/stat.h \ + /usr/include/errno.h /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/limits.h \ /usr/lib/gcc-lib/i486-linux/2.5.8/include/syslimits.h /usr/include/limits.h \ - /usr/include/posix1_lim.h /usr/include/linux/limits.h /usr/include/stdio.h /usr/include/libio.h \ - /usr/include/_G_config.h /usr/include/stdlib.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/string.h /usr/include/mntent.h \ - /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/getopt.h ../version.h \ - fsck.h + /usr/include/posix1_lim.h /usr/include/linux/limits.h /usr/include/posix2_lim.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h /usr/include/stdlib.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/string.h /usr/include/mntent.h /usr/include/unistd.h \ + /usr/include/posix_opt.h /usr/include/getopt.h ../version.h fsck.h lsattr.o : lsattr.c /usr/include/dirent.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/gnu/types.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ - /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/linux/limits.h \ - /usr/include/linux/dirent.h /usr/include/errno.h /usr/include/linux/errno.h \ - /usr/include/fcntl.h /usr/include/linux/fcntl.h /usr/include/getopt.h /usr/include/stdio.h \ - /usr/include/libio.h /usr/include/_G_config.h /usr/include/unistd.h /usr/include/posix_opt.h \ - /usr/include/sys/param.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/limits.h \ + /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/asm/types.h \ + /usr/include/linux/limits.h /usr/include/linux/dirent.h /usr/include/posix1_lim.h \ + /usr/include/errno.h /usr/include/linux/errno.h /usr/include/fcntl.h /usr/include/linux/fcntl.h \ + /usr/include/getopt.h /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/sys/param.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/limits.h \ /usr/lib/gcc-lib/i486-linux/2.5.8/include/syslimits.h /usr/include/limits.h \ - /usr/include/posix1_lim.h /usr/include/linux/param.h /usr/include/sys/stat.h \ - /usr/include/linux/stat.h /usr/include/linux/ext2_fs.h ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ - ../lib/e2p/e2p.h ../version.h + /usr/include/posix2_lim.h /usr/include/linux/param.h /usr/include/asm/param.h \ + /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/linux/ext2_fs.h \ + ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../lib/e2p/e2p.h \ + ../version.h mke2fs.o : mke2fs.c /usr/include/string.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/fcntl.h /usr/include/sys/types.h \ - /usr/include/linux/types.h /usr/include/linux/fcntl.h /usr/include/ctype.h /usr/include/termios.h \ - /usr/include/linux/termios.h /usr/include/time.h /usr/include/getopt.h /usr/include/unistd.h \ - /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/stdlib.h /usr/include/errno.h \ - /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ - /usr/include/mntent.h /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ - /usr/include/malloc.h /usr/include/sys/ioctl.h /usr/include/linux/ioctl.h /usr/include/linux/ext2_fs.h \ + /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/linux/fcntl.h \ + /usr/include/ctype.h /usr/include/termios.h /usr/include/linux/termios.h /usr/include/time.h \ + /usr/include/getopt.h /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h \ + /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ + /usr/include/alloca.h /usr/include/mntent.h /usr/include/stdio.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/malloc.h /usr/include/sys/ioctl.h /usr/include/linux/ioctl.h \ /usr/include/linux/fs.h /usr/include/linux/linkage.h /usr/include/linux/limits.h \ /usr/include/linux/wait.h /usr/include/linux/dirent.h /usr/include/linux/vfs.h \ /usr/include/linux/net.h /usr/include/linux/socket.h /usr/include/linux/sockios.h \ /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h \ /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h \ - /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h \ - /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h \ - /usr/include/linux/ext_fs_sb.h /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h \ - /usr/include/linux/msdos_fs_sb.h /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h \ - /usr/include/linux/xia_fs_sb.h /usr/include/linux/sysv_fs_sb.h ../lib/et/com_err.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../lib/ext2fs/ext2fs.h ../lib/ext2fs/io.h \ - ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h ../version.h + /usr/include/linux/umsdos_fs_i.h /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h \ + /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h \ + /usr/include/linux/ext2_fs.h ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ + ../lib/ext2fs/ext2fs.h ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h \ + ../version.h mklost+found.o : mklost+found.c /usr/include/errno.h /usr/include/features.h \ /usr/include/sys/cdefs.h /usr/include/linux/errno.h /usr/include/fcntl.h /usr/include/sys/types.h \ - /usr/include/linux/types.h /usr/include/linux/fcntl.h /usr/include/stdio.h /usr/include/libio.h \ - /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ - /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/param.h \ - /usr/lib/gcc-lib/i486-linux/2.5.8/include/limits.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/syslimits.h \ - /usr/include/limits.h /usr/include/posix1_lim.h /usr/include/linux/limits.h \ - /usr/include/linux/param.h /usr/include/sys/stat.h /usr/include/linux/stat.h \ - /usr/include/linux/ext2_fs.h ../version.h + /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/linux/fcntl.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/unistd.h /usr/include/posix_opt.h \ + /usr/include/gnu/types.h /usr/include/sys/param.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/limits.h \ + /usr/lib/gcc-lib/i486-linux/2.5.8/include/syslimits.h /usr/include/limits.h \ + /usr/include/posix1_lim.h /usr/include/linux/limits.h /usr/include/posix2_lim.h \ + /usr/include/linux/param.h /usr/include/asm/param.h /usr/include/sys/stat.h \ + /usr/include/linux/stat.h /usr/include/linux/ext2_fs.h ../version.h tune2fs.o : tune2fs.c /usr/include/fcntl.h /usr/include/features.h /usr/include/sys/cdefs.h \ - /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/linux/fcntl.h \ - /usr/include/getopt.h /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ - /usr/include/stdlib.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/errno.h \ + /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/asm/types.h \ + /usr/include/linux/fcntl.h /usr/include/grp.h /usr/include/gnu/types.h /usr/include/stdio.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \ + /usr/include/getopt.h /usr/include/pwd.h /usr/include/stdlib.h /usr/include/errno.h \ /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \ - /usr/include/string.h /usr/include/time.h /usr/include/unistd.h /usr/include/posix_opt.h \ - /usr/include/gnu/types.h /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h \ + /usr/include/alloca.h /usr/include/string.h /usr/include/time.h /usr/include/unistd.h \ + /usr/include/posix_opt.h /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h \ ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../lib/ext2fs/io.h \ ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h ../lib/e2p/e2p.h /usr/include/dirent.h \ - /usr/include/linux/limits.h /usr/include/linux/dirent.h ../version.h + /usr/include/linux/limits.h /usr/include/linux/dirent.h /usr/include/posix1_lim.h \ + ../version.h diff --git a/misc/ChangeLog b/misc/ChangeLog new file mode 100644 index 00000000..9550ab86 --- /dev/null +++ b/misc/ChangeLog @@ -0,0 +1,102 @@ +Sat Mar 11 10:59:58 1995 Theodore Y. Ts'o <tytso@localhost> + + * mke2fs.c (main, zap_bootblock): Added new function + zap_bootblock() which clears the first 512 bytes of the + filesystem. This protects the filesystem from being + misidentified as a MS-DOS FAT filesystem. + + * badblocks.c (alarm_intr, test_ro, test_rw): Increase the space + allocated for printing the block numbers, so that the + display doesn't get corrupted when running badblocks on a + very large partition. + + * badblocks.c (do_test, test_ro, test_rw): Added missing cast to + ext2_loff_t, so that when checking a large device, + spurious seek errors aren't reported. + + * mke2fs.c (count_blocks): Declare mid to be of type ext2_loff_t + instead of type int, so that it works for filesystems + greater than 2 GB. (Fortunately count_blocks is only + called if the device does not support the BLKGETSIZE + ioctl, which most do.) + + * fsck.c (ignore): Add check to ignore filesystems with a pass + number of zero. (This check was accidentally deleted at + during 0.5b development.) + +Sat Dec 31 00:47:16 1994 <tytso@rsx-11.mit.edu> + + * mke2fs.c (new_table_block, alloc_tables, PRS, main): Add a new + option, -S, which only writes the superblock and group + descriptors. Useful for recovering when all of the + superblocks are corrupted somehow (as a last ditch + measure). + + Also, don't bother initializing the bitmap blocks in + alloc_tables(), since they will be overwritten at the end + anyway. (Should speed up mke2fs by a little.) + +Tue Dec 6 02:20:55 1994 <tytso@rsx-11.mit.edu> + + * fsck.c (main): Fix stupid typo where a null inst would be freed. + + * fsck.c (wait_one): Check WIFEXITED on status before trying to + extract the exit status. In other cases, return + FSCK_ERROR if the back end processor exited with a signal. + +Tue Nov 15 10:20:00 1994 Remy Card <card@bbj> + + * tune2fs.c (main): Fixed a bug which prevented the use of the + new options. + Added the `w' (week) suffix recognition in the check interval. + +Sun Nov 13 15:58:48 1994 (tytso@rsx-11) + + * fsck.c (load_fs_info): If the user has an obviously old + /etc/fstab file, issue a warning message and assume that + all partitions should be checked. + +Sat Nov 12 00:33:18 1994 (tytso@rsx-11) + + * dumpe2fs.c (list_desc): Update to new inode and block bitmap + structures. + + * mke2fs.c (create_root_dir): Create the root directory owned by + the effective uid. + +Mon Nov 7 22:04:37 1994 Remy Card <card@bbj> + + * tune2fs.c (main.c): Added support for new options: + -r reserved_blocks_count, -g reserved_gid, -u reserved_uid. + +Sun Aug 21 00:57:33 1994 Theodore Y. Ts'o (tytso@rt-11) + + * fsck.c (ignore): If the pass number is 0, ignore the filesystem. + +Wed Aug 17 21:55:03 1994 Remy Card (card@bbj) + + * badblocks.c (test_rw): Added verbose output like in the + read-only test. + + (do_test and test_rw): Use the llseek system call if available. + + * chattr.c: Added support for new attributes. + + * lsattr.c: Added support for long format. + + * mke2fs.c (usage): Fixed bogus usage message. + + (valid_offset): Use the llseek system call if available. + +Wed Aug 17 10:50:57 1994 Theodore Y. Ts'o (tytso@rt-11) + + * mke2fs.c (handle_bad_blocks): Check to see if a bad block is + where a backup superblock/group descriptor is stored. If so, + print a warning message and adjust the superblock counts so that + they are correct. (Otherwise, the bad block will get counted + twice and the # of free blocks count will be wrong.) + + (alloc_tables): Removed code which calcualated the free block + statistics, which was moved to lib/ext2fs/initialize.c. This + allows the bad block code to adjust the group descriptor + statistics if necessary. diff --git a/misc/Makefile b/misc/Makefile index 3b37dc7c..4cb15b26 100644 --- a/misc/Makefile +++ b/misc/Makefile @@ -2,7 +2,8 @@ include ../MCONFIG CFLAGS= $(OPT) $(WFLAGS) -I../lib LDFLAGS= $(OPT) -SPROGS= tune2fs mklost+found mke2fs dumpe2fs badblocks fsck +SPROGS= mke2fs badblocks tune2fs dumpe2fs fsck +USPROGS= mklost+found SMANPAGES= tune2fs.8 mklost+found.8 mke2fs.8 dumpe2fs.8 badblocks.8 \ fsck.8 @@ -21,33 +22,39 @@ FSCK_OBJS= fsck.o LIBS= -L../lib -lext2fs -le2p -lcom_err DEPLIBS= ../lib/libext2fs.a ../lib/libe2p.a ../lib/libcom_err.a -all: $(SPROGS) $(UPROGS) +all: $(SPROGS) $(UPROGS) $(USPROGS) tune2fs: $(TUNE2FS_OBJS) $(DEPLIBS) - cc $(LDFLAGS) -o tune2fs $(TUNE2FS_OBJS) $(LIBS) + $(CC) $(LDFLAGS) -o tune2fs $(TUNE2FS_OBJS) $(LIBS) mklost+found: $(MKLPF_OBJS) - cc $(LDFLAGS) -o mklost+found $(MKLPF_OBJS) + $(CC) $(LDFLAGS) -o mklost+found $(MKLPF_OBJS) mke2fs: $(MKE2FS_OBJS) $(DEPLIBS) - cc $(LDFLAGS) -o mke2fs $(MKE2FS_OBJS) $(LIBS) + $(CC) $(LDFLAGS) -o mke2fs $(MKE2FS_OBJS) $(LIBS) + +mke2fs.static: $(MKE2FS_OBJS) $(DEPLIBS) + $(CC) $(LDFLAGS) -static -o mke2fs.static $(MKE2FS_OBJS) $(LIBS) chattr: $(CHATTR_OBJS) $(DEPLIBS) - cc $(LDFLAGS) -o chattr $(CHATTR_OBJS) $(LIBS) + $(CC) $(LDFLAGS) -o chattr $(CHATTR_OBJS) $(LIBS) lsattr: $(LSATTR_OBJS) $(DEPLIBS) - cc $(LDFLAGS) -o lsattr $(LSATTR_OBJS) $(LIBS) + $(CC) $(LDFLAGS) -o lsattr $(LSATTR_OBJS) $(LIBS) dumpe2fs: $(DUMPE2FS_OBJS) $(DEPLIBS) - cc $(LDFLAGS) -o dumpe2fs $(DUMPE2FS_OBJS) $(LIBS) + $(CC) $(LDFLAGS) -o dumpe2fs $(DUMPE2FS_OBJS) $(LIBS) badblocks: $(BADBLOCKS_OBJS) $(DEPLIBS) - cc $(LDFLAGS) -o badblocks $(BADBLOCKS_OBJS) $(LIBS) + $(CC) $(LDFLAGS) -o badblocks $(BADBLOCKS_OBJS) $(LIBS) install:: $(SPROGS) $(UPROGS) for i in $(SPROGS); do \ $(INSTALLBIN) $$i $(SBINDIR)/$$i; \ done + for i in $(USPROGS); do \ + $(INSTALLBIN) $$i $(USRSBINDIR)/$$i; \ + done ln -sf mke2fs $(SBINDIR)/mkfs.ext2 for i in $(UPROGS); do \ $(INSTALLBIN) $$i $(USRBINDIR)/$$i; \ @@ -61,8 +68,18 @@ install:: $(SMANPAGES) $(UMANPAGES) $(INSTALLMAN) $$i $(UMANDIR)/$$i; \ done +install-tree:: $(SPROGS) $(UPROGS) + for i in $(SPROGS) $(UPROGS); do \ + rm -f ../bin/$$i; \ + cp $$i ../bin; \ + strip ../bin/$$i; \ + chmod 555 ../bin/$$i; \ + done + ln -sf mke2fs ../bin/mkfs.ext2 + clean: - rm -f $(SPROGS) $(UPROGS) \#* *.s *.o *.a *~ core + rm -f $(SPROGS) $(USPROGS) $(UPROGS) mke2fs.static \ + \#* *.s *.o *.a *~ core really-clean: clean rm -f .depend diff --git a/misc/badblocks.8 b/misc/badblocks.8 index 080ca5ba..79a95c7c 100644 --- a/misc/badblocks.8 +++ b/misc/badblocks.8 @@ -1,5 +1,5 @@ .\" -*- nroff -*- -.TH BADBLOCKS 8 "March 1994" "Version 0.5" +.TH BADBLOCKS 8 "November 1994" "Version 0.5b" .SH NAME badblocks \- search a device for bad blocks .SH SYNOPSIS @@ -59,8 +59,8 @@ I had no chance to make reals tests of this program since I use IDE drives which remap bad blocks. I only made some tests on floppies. .SH AVAILABILITY .B badblocks -is available for anonymous ftp from ftp.ibp.fr (132.227.60.2) in -/pub/linux/BETA/ext2fs. +is available for anonymous ftp from ftp.ibp.fr and tsx-11.mit.edu in +/pub/linux/packages/ext2fs. .SH SEE ALSO .BR e2fsck (8), .BR mke2fs (8) diff --git a/misc/badblocks.c b/misc/badblocks.c index 0560e67c..b9bcaca8 100644 --- a/misc/badblocks.c +++ b/misc/badblocks.c @@ -28,11 +28,13 @@ #include <unistd.h> #include <sys/ioctl.h> +#include <sys/types.h> #include <linux/fd.h> #include <linux/fs.h> #include "et/com_err.h" +#include "ext2fs/io.h" const char * program_name = "badblocks"; @@ -42,7 +44,7 @@ int s_flag = 0; /* show progress of test */ static volatile void usage (void) { - fprintf (stderr, "Usage: %s [-b block_size] [-o output_file] [-w] device blocks_count\n", + fprintf (stderr, "Usage: %s [-b block_size] [-o output_file] [-svw] device blocks_count\n [start_count]\n", program_name); exit (1); } @@ -56,16 +58,18 @@ static long do_test (int dev, char * buffer, int try, unsigned long block_size, long got; /* Seek to the correct loc. */ - if (lseek (dev, current_block * block_size, SEEK_SET) != - current_block * block_size) - com_err (program_name, errno, "during seek"); + if (ext2_llseek (dev, (ext2_loff_t) current_block * block_size, + SEEK_SET) != (ext2_loff_t) current_block * block_size) + com_err (program_name, errno, "during seek"); /* Try the read */ got = read (dev, buffer, try * block_size); if (got < 0) got = 0; if (got & (block_size - 1)) - fprintf (stderr, "Weird values in do_test: probably bugs\n"); + fprintf (stderr, + "Weird value (%ld) in do_test: probably bugs\n", + got); got /= block_size; return got; } @@ -79,13 +83,14 @@ static void alarm_intr (int alnum) alarm(1); if (!num_blocks) return; - fprintf(stderr, "%6ld/%6ld", currently_testing, num_blocks); - fprintf(stderr, "\b\b\b\b\b\b\b\b\b\b\b\b\b"); + fprintf(stderr, "%9ld/%9ld", currently_testing, num_blocks); + fprintf(stderr, "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"); fflush (stderr); } static void test_ro (int dev, unsigned long blocks_count, - unsigned long block_size, FILE * out) + unsigned long block_size, FILE * out, + unsigned long from_count) { #define TEST_BUFFER_BLOCKS 16 char * blkbuf; @@ -103,11 +108,13 @@ static void test_ro (int dev, unsigned long blocks_count, fprintf (stderr, "Flushing buffers\n"); ioctl (dev, BLKFLSBUF, 0); /* In case this is a HD */ ioctl (dev, FDFLUSH, 0); /* In case this is floppy */ - if (v_flag) - fprintf (stderr, - "Checking for bad blocks in read-only mode\n"); + if (v_flag) { + fprintf (stderr, + "Checking for bad blocks in read-only mode\n"); + fprintf (stderr, "From block %lu to %lu\n", from_count, blocks_count); + } try = TEST_BUFFER_BLOCKS; - currently_testing = 0; + currently_testing = from_count; num_blocks = blocks_count; if (s_flag) { fprintf(stderr, "Checking for bad blocks (read-only test): "); @@ -131,15 +138,16 @@ static void test_ro (int dev, unsigned long blocks_count, num_blocks = 0; alarm(0); if (s_flag) - fprintf(stderr, "done \n"); + fprintf(stderr, "done \n"); + fflush (stderr); free (blkbuf); } static void test_rw (int dev, unsigned long blocks_count, - unsigned long block_size, FILE * out) + unsigned long block_size, FILE * out, + unsigned long from_count) { int i; - int j; char * buffer; unsigned char pattern[] = {0xaa, 0x55, 0xff, 0x00}; @@ -159,35 +167,60 @@ static void test_rw (int dev, unsigned long blocks_count, for (i = 0; i < sizeof (pattern); i++) { memset (buffer, pattern[i], block_size); - if (v_flag) - fprintf (stderr, "Writing pattern 0x%08x\n", + if (s_flag | v_flag) + fprintf (stderr, "Writing pattern 0x%08x: ", *((int *) buffer)); - for (j = 0; j < blocks_count; j++) + num_blocks = blocks_count; + currently_testing = from_count; + if (s_flag) + alarm_intr(SIGALRM); + for (; + currently_testing < blocks_count; + currently_testing++) { - if (lseek (dev, j * block_size, SEEK_SET) != j * block_size) + if (ext2_llseek (dev, (ext2_loff_t) currently_testing * + block_size, SEEK_SET) != + (ext2_loff_t) currently_testing * block_size) com_err (program_name, errno, - "during seek on block %d", j); + "during seek on block %d", + currently_testing); write (dev, buffer, block_size); } + num_blocks = 0; + alarm (0); + if (s_flag | v_flag) + fprintf(stderr, "done \n"); if (v_flag) fprintf (stderr, "Flushing buffers\n"); if (fsync (dev) == -1) com_err (program_name, errno, "during fsync"); ioctl (dev, BLKFLSBUF, 0); /* In case this is a HD */ ioctl (dev, FDFLUSH, 0); /* In case this is floppy */ - if (v_flag) - fprintf (stderr, "Reading and comparing\n"); - for (j = 0; j < blocks_count; j++) + if (s_flag | v_flag) + fprintf (stderr, "Reading and comparing: "); + num_blocks = blocks_count; + currently_testing = from_count; + if (s_flag) + alarm_intr(SIGALRM); + for (; + currently_testing < blocks_count; + currently_testing++) { - if (lseek (dev, j * block_size, SEEK_SET) != j * block_size) + if (ext2_llseek (dev, (ext2_loff_t) currently_testing * + block_size, SEEK_SET) != + (ext2_loff_t) currently_testing * block_size) com_err (program_name, errno, - "during seek on block %d", j); + "during seek on block %d", + currently_testing); if (read (dev, buffer + block_size, block_size) < block_size) - fprintf (out, "%d\n", j); + fprintf (out, "%ld\n", currently_testing); else if (memcmp (buffer, buffer + block_size, block_size)) - fprintf (out, "%d\n", j); - + fprintf (out, "%ld\n", currently_testing); } + num_blocks = 0; + alarm (0); + if (s_flag | v_flag) + fprintf(stderr, "done \n"); if (v_flag) fprintf (stderr, "Flushing buffers\n"); ioctl (dev, BLKFLSBUF, 0); /* In case this is a HD */ @@ -203,7 +236,7 @@ void main (int argc, char ** argv) char * output_file = NULL; FILE * out; unsigned long block_size = 1024; - unsigned long blocks_count; + unsigned long blocks_count, from_count; int dev; setbuf(stdout, NULL); @@ -247,6 +280,14 @@ void main (int argc, char ** argv) com_err (program_name, 0, "bad blocks count - %s", argv[optind]); exit (1); } + if (++optind <= argc-1) { + from_count = strtoul (argv[optind], &tmp, 0); + } else from_count = 0; + if (from_count >= blocks_count) { + com_err (program_name, 0, "bad blocks range: %lu-%lu", + from_count, blocks_count); + exit (1); + } dev = open (device_name, w_flag ? O_RDWR : O_RDONLY); if (dev == -1) { @@ -267,9 +308,9 @@ void main (int argc, char ** argv) else out = stdout; if (w_flag) - test_rw (dev, blocks_count, block_size, out); + test_rw (dev, blocks_count, block_size, out, from_count); else - test_ro (dev, blocks_count, block_size, out); + test_ro (dev, blocks_count, block_size, out, from_count); close (dev); if (out != stdout) fclose (out); diff --git a/misc/chattr.1 b/misc/chattr.1 index 6a8e1193..2a45667f 100644 --- a/misc/chattr.1 +++ b/misc/chattr.1 @@ -1,5 +1,5 @@ .\" -*- nroff -*- -.TH CHATTR 1 "March 1994" "Version 0.5" +.TH CHATTR 1 "November 1994" "Version 0.5b" .SH NAME chattr \- change file attributes on a Linux second extended file system .SH SYNOPSIS @@ -19,14 +19,15 @@ mode .B chattr changes the files attributes on an second extended file system. .PP -The format of a symbolic mode is +-=[Scsu]. +The format of a symbolic mode is +-=[Sacdisu]. .PP The operator `+' causes the selected attributes to be added to the existing attributes of the files; `-' causes them to be removed; and `=' causes them to be the only attributes that the files have. .PP -The letters `Scsu' select the new attributes for the files: synchronous -updates (S), compressed (c), secure deletion (s), and undeletable (u). +The letters `Sacdisu' select the new attributes for the files: synchronous +updates (S), append only (a), compressed (c), immutable (i), no dump (d), +secure deletion (s), and undeletable (u). .SH OPTIONS .TP .I -R @@ -37,21 +38,42 @@ Verbosely describe changed attributes. .TP .I -v version Set the files version. +.SH ATTRIBUTES +A file with the `a' attribute set can only be open in append mode for writing. + +A file with the `c' attribute set is automatically compressed on the disk +by the kernel. A read from this file returns uncompressed data. A write to +this file compresses data before storing them on the disk. + +A file with the `d' attribute set is not candidate for backup when the +.BR dump (8) +program is run. + +A file with the `i' attribute cannot be modified: it cannot be deleted or +renamed, no link can be created to this file and no data can be written +to the file. Only the superuser can set or clear this attribute. + +When a file with the `s' attribute set is deleted, its blocks are zeroed and +written back to the disk. + +When a file with the `S' attribute set is modified, +the changes are written synchronously on the disk; this is equivalent to +the `sync' mount option applied to a subset of the files. + +When a file with the `u' attribute set is deleted, its contents is saved. +This allows the user to ask for its undeletion. .SH AUTHOR .B chattr has been written by Remy Card <card@masi.ibp.fr>, the developer and maintainer of the ext2 fs. .SH BUGS AND LIMITATIONS -As of ext2 fs 0.4, the kernel code only honours the `s' and `S' attributes. When -a file with the `s' attribute set is deleted, its blocks are zeroed and -written back to the disk. When a file with the `S' attribute set is modified, -the changes are written synchronously on the disk; this is equivalent to -the `sync' mount option applied to a subset of the files. +As of ext2 fs 0.5a, the `c' and `u' attribute are not honoured by the kernel +code. .PP -The other attributes will be implemented in a next ext2 fs version. +These attributes will be implemented in a future ext2 fs version. .SH AVAILABILITY .B chattr -is available for anonymous ftp from ftp.ibp.fr (132.227.60.2) in -/pub/linux/BETA/ext2fs. +is available for anonymous ftp from ftp.ibp.fr and tsx-11.mit.edu in +/pub/linux/packages/ext2fs. .SH SEE ALSO .BR lsattr (1) diff --git a/misc/chattr.c b/misc/chattr.c index 63c8108c..8df57e9f 100644 --- a/misc/chattr.c +++ b/misc/chattr.c @@ -53,7 +53,7 @@ static void volatile fatal_error (const char * fmt_string, int errcode) exit (errcode); } -#define usage() fatal_error ("usage: %s [-RV] [-+=csu] [-v version] files...\n", \ +#define usage() fatal_error ("usage: %s [-RV] [-+=acdisSu] [-v version] files...\n", \ 1) static int decode_arg (int * i, int argc, char ** argv) @@ -77,10 +77,28 @@ static int decode_arg (int * i, int argc, char ** argv) case 'V': verbose = 1; break; +#ifdef EXT2_APPEND_FL + case 'a': + rf |= EXT2_APPEND_FL; + rem = 1; + break; +#endif case 'c': rf |= EXT2_COMPR_FL; rem = 1; break; +#ifdef EXT2_NODUMP_FL + case 'd': + rf |= EXT2_NODUMP_FL; + rem = 1; + break; +#endif +#ifdef EXT2_IMMUTABLE_FL + case 'i': + rf |= EXT2_IMMUTABLE_FL; + rem = 1; + break; +#endif case 's': rf |= EXT2_SECRM_FL; rem = 1; @@ -116,9 +134,24 @@ static int decode_arg (int * i, int argc, char ** argv) case 'S': af |= EXT2_SYNC_FL; break; +#ifdef EXT2_APPEND_FL + case 'a': + af |= EXT2_APPEND_FL; + break; +#endif case 'c': af |= EXT2_COMPR_FL; break; +#ifdef EXT2_NODUMP_FL + case 'd': + af |= EXT2_NODUMP_FL; + break; +#endif +#ifdef EXT2_IMMUTABLE_FL + case 'i': + af |= EXT2_IMMUTABLE_FL; + break; +#endif case 's': af |= EXT2_SECRM_FL; break; @@ -137,9 +170,24 @@ static int decode_arg (int * i, int argc, char ** argv) case 'S': sf |= EXT2_SYNC_FL; break; +#ifdef EXT2_APPEND_FL + case 'a': + sf |= EXT2_APPEND_FL; + break; +#endif case 'c': sf |= EXT2_COMPR_FL; break; +#ifdef EXT2_NODUMP_FL + case 'd': + sf |= EXT2_NODUMP_FL; + break; +#endif +#ifdef EXT2_IMMUTABLE_FL + case 'i': + sf |= EXT2_IMMUTABLE_FL; + break; +#endif case 's': sf |= EXT2_SECRM_FL; break; @@ -174,7 +222,7 @@ static void change_attributes (const char * name) if (verbose) { printf ("Flags of %s set as ", name); - print_flags (stdout, sf); + print_flags (stdout, sf, 0); printf ("\n"); } if (fsetflags (name, sf) == -1) @@ -194,7 +242,7 @@ static void change_attributes (const char * name) if (verbose) { printf ("Flags of %s set as ", name); - print_flags (stdout, flags); + print_flags (stdout, flags, 0); printf ("\n"); } if (fsetflags (name, flags) == -1) diff --git a/misc/dumpe2fs.8 b/misc/dumpe2fs.8 index 30a90b5c..8cb25cc6 100644 --- a/misc/dumpe2fs.8 +++ b/misc/dumpe2fs.8 @@ -1,4 +1,4 @@ -.TH DUMPE2FS 8 "March 1994" "Version 0.5" +.TH DUMPE2FS 8 "November 1994" "Version 0.5b" .SH NAME dumpe2fs \- dump filesystem information @@ -24,8 +24,8 @@ has been written by Remy Card <card@masi.ibp.fr>, the developer and maintainer of the ext2 fs. .SH AVAILABILITY .B dumpe2fs -is available for anonymous ftp from ftp.ibp.fr (132.227.60.2) in -/pub/linux/BETA/ext2fs. +is available for anonymous ftp from ftp.ibp.fr and tsx-11.mit.edu in +/pub/linux/packages/ext2fs. .SH SEE ALSO .BR e2fsck (8), .BR mke2fs (8), diff --git a/misc/dumpe2fs.c b/misc/dumpe2fs.c index fc0c45b7..d820613e 100644 --- a/misc/dumpe2fs.c +++ b/misc/dumpe2fs.c @@ -71,8 +71,8 @@ static void print_free (unsigned long group, char * bitmap, static void list_desc (ext2_filsys fs) { unsigned long i; - char * block_bitmap = fs->block_map; - char * inode_bitmap = fs->inode_map; + char * block_bitmap = fs->block_map->bitmap; + char * inode_bitmap = fs->inode_map->bitmap; printf ("\n"); for (i = 0; i < fs->group_desc_count; i++) @@ -125,38 +125,78 @@ static void list_bad_blocks(ext2_filsys fs) printf("\n"); } +static void dump_bad_blocks(ext2_filsys fs) +{ + badblocks_list bb_list = 0; + badblocks_iterate bb_iter; + blk_t blk; + errcode_t retval; + + retval = ext2fs_read_bb_inode(fs, &bb_list); + if (retval) { + com_err("ext2fs_read_bb_inode", retval, ""); + exit(1); + } + retval = badblocks_list_iterate_begin(bb_list, &bb_iter); + if (retval) { + com_err("badblocks_list_iterate_begin", retval, + "while printing bad block list"); + exit(1); + } + while (badblocks_list_iterate(bb_iter, &blk)) + printf("%ld\n", blk); + badblocks_list_iterate_end(bb_iter); +} + + void main (int argc, char ** argv) { errcode_t retval; ext2_filsys fs; + int print_badblocks = 0; + char c; fprintf (stderr, "dumpe2fs %s, %s for EXT2 FS %s, %s\n", E2FSPROGS_VERSION, E2FSPROGS_DATE, EXT2FS_VERSION, EXT2FS_DATE); if (argc && *argv) program_name = *argv; - if (argc != 2) + + while ((c = getopt (argc, argv, "b")) != EOF) { + switch (c) { + case 'b': + print_badblocks++; + break; + default: + usage (); + } + } + if (optind > argc - 1) usage (); - device_name = argv[1]; + device_name = argv[optind++]; + initialize_ext2_error_table(); retval = ext2fs_open (device_name, 0, 0, 0, unix_io_manager, &fs); - if (retval) - { + if (retval) { com_err (program_name, retval, "while trying to open %s", device_name); printf ("Couldn't find valid filesystem superblock.\n"); exit (1); } - retval = ext2fs_read_bitmaps (fs); - if (retval) - { - com_err (program_name, retval, "while trying to read the bitmaps", - device_name); - ext2fs_close (fs); - exit (1); + if (print_badblocks) { + dump_bad_blocks(fs); + } else { + retval = ext2fs_read_bitmaps (fs); + if (retval) { + com_err (program_name, retval, + "while trying to read the bitmaps", + device_name); + ext2fs_close (fs); + exit (1); + } + list_super (fs->super); + list_bad_blocks (fs); + list_desc (fs); } - list_super (fs->super); - list_bad_blocks (fs); - list_desc (fs); ext2fs_close (fs); exit (0); } diff --git a/misc/fsck.8 b/misc/fsck.8 index 620a7fcb..cfc88326 100644 --- a/misc/fsck.8 +++ b/misc/fsck.8 @@ -1,14 +1,14 @@ .\" -*- nroff -*- -.TH FSCK 8 "Mar 1994" "Version 0.5" +.TH FSCK 8 "November 1994" "Version 0.5b" .SH NAME fsck \- check and repair a Linux file system .SH SYNOPSIS .B fsck [ -.B \-A +.B \-AVRTN ] [ -.B \-V +.B \-s ] [ .B \-t @@ -69,10 +69,18 @@ file and try to check all file systems in one run. This option is typically used from the .I /etc/rc system initalization file, instead of multiple commands for checking -a single file system. Note, that with this option, you cannot give -the -.I filesys -argument as well. +a single file system. +.TP +.B -R +When checking all file systems with the +.B \-A +flag, skip the root file system (in case it's already mounted read-write). +.TP +.B -T +Don't show the title on startup. +.TP +.B -N +Don't execute, just show what would be done. .TP .B -s Serialize fsck operations. This is a good idea if you checking multiple @@ -92,19 +100,32 @@ option if you do not.) .B -V Produce verbose output, including all file system-specific commands that are executed. -Specifying this option more than once inhibits execution of any -file system-specific commands. -This is really only useful for testing. .TP .BI -t \ fstype -Specifies the type of file system to be checked. -If not specified, the type is deduced by searching for +Specifies the type of file system to be checked. When the +.B \-A +flag is specified, only filesystems that match +.I fstype +are checked. If +.I fstype +is prefixed with +.B no +only filesystems whose filesystem do not match +.I fstype +are checked. +.sp +Normally, the filesystem type is deduced by searching for .I filesys -in -.I /etc/fstab -and using the corresponding entry. -If the type can not be deduced, the default file system type -(currently ext2) is used. +in the +.I /etc/fstab +file and using the corresponding entry. +If the type can not be deduced, +.B fsck +will use the type specified by the +.B \-t +option if it specifies a unique filesystem type. If this type is not +available, the the default file system type +(currently ext2) is used. .TP .B fs-options Any options which are not understood by @@ -112,7 +133,7 @@ Any options which are not understood by or which follow the .B -- option are treated as file system-specific options to be passed to the -realm file system checker. +file system-specific checker. .PP Currently, standardized file system-specific options are somewhat in flux. Although not guaranteed, the following options are supported @@ -143,7 +164,10 @@ Theodore Ts'o (tytso@mit.edu) The manual page was shamelessly adapted from David Engel and Fred van Kempen's generic fsck front end program, which was in turn shamelessly adapted from Remy Card's version for the ext2 file system. +.SH FILES +.IR /etc/fstab . .SH SEE ALSO +.BR fstab (5), .BR mkfs (8), .BR fsck.minix (8), .BR fsck.ext2 (8) diff --git a/misc/fsck.c b/misc/fsck.c index eb01fc5b..40f715f1 100644 --- a/misc/fsck.c +++ b/misc/fsck.c @@ -8,14 +8,24 @@ * * Written by Theodore Ts'o, <tytso@mit.edu> * - * Usage: fsck [-AV] [-t fstype] [fs-options] device + * Usage: fsck [-AVRNTM] [-s] [-t fstype] [fs-options] device * + * Miquel van Smoorenburg (miquels@drinkel.ow.org) 20-Oct-1994: + * o Changed -t fstype to behave like with mount when -A (all file + * systems) or -M (like mount) is specified. + * o fsck looks if it can find the fsck.type program to decide + * if it should ignore the fs type. This way more fsck programs + * can be added without changing this front-end. + * o -R flag skip root file system. + * * Copyright (C) 1993, 1994 Theodore Ts'o. This file may be * redistributed under the terms of the GNU Public License. */ #include <sys/types.h> #include <sys/wait.h> +#include <sys/signal.h> +#include <sys/stat.h> #include <errno.h> #include <limits.h> #include <stdio.h> @@ -32,7 +42,6 @@ static const char *ignored_types[] = { "ignore", "iso9660", - "msdos", "nfs", "proc", "sw", @@ -40,11 +49,42 @@ static const char *ignored_types[] = { NULL }; +static const char *really_wanted[] = { + "minix", + "ext2", + "xiafs", + NULL +}; + +#ifdef DEV_DSK_DEVICES +static const char *base_devices[] = { + "/dev/dsk/hda", + "/dev/dsk/hdb", + "/dev/dsk/hdc", + "/dev/dsk/hdd", + "/dev/dsk/hd1a", + "/dev/dsk/hd1b", + "/dev/dsk/hd1c", + "/dev/dsk/hd1d", + "/dev/dsk/sda", + "/dev/dsk/sdb", + "/dev/dsk/sdc", + "/dev/dsk/sdd", + "/dev/dsk/sde", + "/dev/dsk/sdf", + "/dev/dsk/sdg", + NULL +}; +#else static const char *base_devices[] = { "/dev/hda", "/dev/hdb", "/dev/hdc", "/dev/hdd", + "/dev/hd1a", + "/dev/hd1b", + "/dev/hd1c", + "/dev/hd1d", "/dev/sda", "/dev/sdb", "/dev/sdc", @@ -54,6 +94,7 @@ static const char *base_devices[] = { "/dev/sdg", NULL }; +#endif /* * Global variables for options @@ -66,12 +107,17 @@ int verbose = 0; int doall = 0; int noexecute = 0; int serialize = 0; +int skip_root = 0; +int like_mount = 0; +int notitle = 0; char *progname; char *fstype = NULL; struct fs_info *filesys_info; struct fsck_instance *instance_list; +static char fsck_path[PATH_MAX + 32]; +static int ignore(struct fs_info *); -static char *strdup(char *s) +static char *strdup(const char *s) { char *ret; @@ -99,6 +145,7 @@ static void load_fs_info(NOARGS) FILE *mntfile; struct mntent *mp; struct fs_info *fs; + int old_fstab = 1; filesys_info = NULL; @@ -119,9 +166,24 @@ static void load_fs_info(NOARGS) fs->passno = mp->mnt_passno; fs->next = filesys_info; filesys_info = fs; + if (fs->passno) + old_fstab = 0; } (void) endmntent(mntfile); + + if (old_fstab) { + fprintf(stderr, "\007\007\007" + "WARNING: Your /etc/fstab does not contain the fsck passno\n"); + fprintf(stderr, + " field. I will kludge around things for you, but you\n"); + fprintf(stderr, + " should fix your /etc/fstab file as soon as you can.\n\n"); + + for (fs = filesys_info; fs; fs = fs->next) { + fs->passno = 1; + } + } } /* Lookup filesys in /etc/fstab and return the corresponding entry. */ @@ -142,13 +204,33 @@ static struct fs_info *lookup(char *filesys) return fs; } +/* Find fsck program for a given fs type. */ +static char *find_fsck(char *type) +{ + char *s; + const char *tpl; + static char prog[256]; + char *p = strdup(fsck_path); + struct stat st; + + /* Are we looking for a program or just a type? */ + tpl = (strncmp(type, "fsck.", 5) ? "%s/fsck.%s" : "%s/%s"); + + for(s = strtok(p, ":"); s; s = strtok(NULL, ":")) { + sprintf(prog, tpl, s, type); + if (stat(prog, &st) == 0) break; + } + free(p); + return(s ? prog : NULL); +} + /* * Execute a particular fsck program, and link it into the list of * child processes we are waiting for. */ static int execute(char *prog, char *device) { - char *argv[80]; + char *s, *argv[80]; int argc, i; struct fsck_instance *inst; pid_t pid; @@ -162,7 +244,14 @@ static int execute(char *prog, char *device) argv[argc++] = strdup(device); argv[argc] = 0; + s = find_fsck(prog); + if (s == NULL) { + fprintf(stderr, "fsck: %s: not found\n", prog); + return ENOENT; + } + if (verbose || noexecute) { + printf("[%s] ", s); for (i=0; i < argc; i++) printf("%s ", argv[i]); printf("\n"); @@ -175,8 +264,8 @@ static int execute(char *prog, char *device) perror("fork"); return errno; } else if (pid == 0) { - (void) execvp(prog, argv); - perror(args[0]); + (void) execv(s, argv); + perror(argv[0]); exit(EXIT_ERROR); } inst = malloc(sizeof(struct fsck_instance)); @@ -199,6 +288,7 @@ static int execute(char *prog, char *device) static struct fsck_instance *wait_one(NOARGS) { int status; + int sig; struct fsck_instance *inst, *prev; pid_t pid; @@ -207,7 +297,6 @@ static struct fsck_instance *wait_one(NOARGS) retry: pid = wait(&status); - status = WEXITSTATUS(status); if (pid < 0) { if ((errno == EINTR) || (errno == EAGAIN)) goto retry; @@ -231,7 +320,23 @@ retry: pid, status); goto retry; } - + if (WIFEXITED(status)) + status = WEXITSTATUS(status); + else if (WIFSIGNALED(status)) { + sig = WTERMSIG(status); + if (sig == SIGINT) { + status = EXIT_UNCORRECTED; + } else { + printf("Warning... %s for device %s exited " + "with signal %d.\n", + inst->prog, inst->device, sig); + status = EXIT_ERROR; + } + } else { + printf("%s %s: status is %x, should never happen.\n", + inst->prog, inst->device, status); + status = EXIT_ERROR; + } inst->exit_status = status; if (prev) prev->next = inst->next; @@ -269,12 +374,13 @@ static void fsck_device(char *device) int retval; char prog[80]; - if (fstype) - type = fstype; - else if ((fsent = lookup(device))) { + if ((fsent = lookup(device))) { device = fsent->device; type = fsent->type; - } else + } else if (fstype && strncmp(fstype, "no", 2) && + !strchr(fstype, ',')) + type = fstype; + else type = DEFAULT_FSTYPE; sprintf(prog, "fsck.%s", type); @@ -285,31 +391,77 @@ static void fsck_device(char *device) } } +/* See if filesystem type matches the list. */ +static int fs_match(char *type, char *fs_type) +{ + int ret = 0, negate = 0; + char list[128]; + char *s; + + if (!fs_type) return(1); + + if (strncmp(fs_type, "no", 2) == 0) { + fs_type += 2; + negate = 1; + } + strcpy(list, fs_type); + s = strtok(list, ","); + while(s) { + if (strcmp(s, type) == 0) { + ret = 1; + break; + } + s = strtok(NULL, ","); + } + return(negate ? !ret : ret); +} + + /* Check if we should ignore this filesystem. */ static int ignore(struct fs_info *fs) { const char *cp; const char **ip; + int wanted = 0; + + /* + * If the pass number is 0, ignore it. + */ + if (fs->passno == 0) + return 1; /* * If a specific fstype is specified, and it doesn't match, * ignore it. */ - if (fstype && strcmp(fstype, fs->type)) - return 1; + if (!fs_match(fs->type, fstype)) return 1; - ip = ignored_types; - while (*ip != NULL) { - if (!strcmp(fs->type, *ip)) - return 1; - ip++; - } - + /* Noauto never matches. */ for (cp = strtok(fs->opts, ","); cp != NULL; cp = strtok(NULL, ",")) { if (!strcmp(cp, "noauto")) return 1; } + /* Are we ignoring this type? */ + for(ip = ignored_types; *ip; ip++) + if (strcmp(fs->type, *ip) == 0) return(1); + + /* Do we really really want to check this fs? */ + for(ip = really_wanted; *ip; ip++) + if (strcmp(fs->type, *ip) == 0) { + wanted = 1; + break; + } + + /* See if the <fsck.fs> program is available. */ + if (find_fsck(fs->type) == NULL) { + if (wanted) + fprintf(stderr, "fsck: cannot check %s: fsck.%s not found\n", + fs->device, fs->type); + return(1); + } + + /* We can and want to check this file system type. */ return 0; } @@ -326,7 +478,6 @@ static const char *base_device(char *device) for (base = base_devices; *base; base++) { if (!strncmp(*base, device, strlen(*base))) return *base; - base++; } return device; } @@ -370,14 +521,14 @@ static int check_all(NOARGS) if (!strcmp(fs->mountpt, "/")) break; } - if (fs && - (!fstype || !strcmp(fstype, fs->type))) { + if (fs && !skip_root && !ignore(fs)) { fsck_device(fs->device); fs->flags |= FLAG_DONE; status |= wait_all(); if (status > EXIT_NONDESTRUCT) return status; } + if (fs) fs->flags |= FLAG_DONE; /* * Mark filesystems that should be ignored as done. @@ -498,6 +649,15 @@ static void PRS(int argc, char *argv[]) case 'N': noexecute++; break; + case 'R': + skip_root++; + break; + case 'T': + notitle++; + break; + case 'M': + like_mount++; + break; case 's': serialize++; break; @@ -539,20 +699,20 @@ static void PRS(int argc, char *argv[]) int main(int argc, char *argv[]) { - char *oldpath, newpath[PATH_MAX]; + char *oldpath; int status = 0; int i; PRS(argc, argv); - printf("Parallelizing fsck version %s (%s)\n", E2FSPROGS_VERSION, - E2FSPROGS_DATE); + if (!notitle) + printf("Parallelizing fsck version %s (%s)\n", + E2FSPROGS_VERSION, E2FSPROGS_DATE); - /* Update our PATH to include /sbin, /etc/fs, and /etc. */ - strcpy(newpath, "PATH=/sbin:/etc/fs:/etc:"); + /* Update our search path to include uncommon directories. */ + strcpy(fsck_path, "/sbin:/sbin/fs.d:/sbin/fs:/etc/fs:/etc:"); if ((oldpath = getenv("PATH")) != NULL) - strcat(newpath, oldpath); - putenv(newpath); + strcat(fsck_path, oldpath); /* If -A was specified ("check all"), do that! */ if (doall) @@ -564,7 +724,7 @@ int main(int argc, char *argv[]) struct fsck_instance *inst; inst = wait_one(); - if (!inst) { + if (inst) { status |= inst->exit_status; free_instance(inst); } diff --git a/misc/fsck.h b/misc/fsck.h index b79714bd..3e13e9c9 100644 --- a/misc/fsck.h +++ b/misc/fsck.h @@ -10,7 +10,7 @@ #endif #ifndef DEFAULT_FSTYPE -# define DEFAULT_FSTYPE "ext2" +#define DEFAULT_FSTYPE "ext2" #endif #define MAX_DEVICES 32 diff --git a/misc/lsattr.1 b/misc/lsattr.1 index 51a0d5a3..ea61acd0 100644 --- a/misc/lsattr.1 +++ b/misc/lsattr.1 @@ -1,5 +1,5 @@ .\" -*- nroff -*- -.TH LSATTR 1 "March 1994" "Version 0.5" +.TH LSATTR 1 "November 1994" "Version 0.5b" .SH NAME lsattr \- list file attributes on a Linux second extended file system .SH SYNOPSIS @@ -34,7 +34,7 @@ of the ext2 fs. There are none :-). .SH AVAILABILITY .B lsattr -is available for anonymous ftp from ftp.ibp.fr (132.227.60.2) in -/pub/linux/BETA/ext2fs. +is available for anonymous ftp from ftp.ibp.fr and tsx-11.mit.edu in +/pub/linux/packages/ext2fs. .SH SEE ALSO .BR chattr (1) diff --git a/misc/lsattr.c b/misc/lsattr.c index ae337d67..6ce190c4 100644 --- a/misc/lsattr.c +++ b/misc/lsattr.c @@ -35,12 +35,13 @@ const char * program_name = "lsattr"; int all = 0; int d_opt = 0; +int l_opt = 0; int recursive = 0; int v_opt = 0; static void volatile usage (void) { - fprintf (stderr, "Usage: %s [-Radv] [files...]\n", program_name); + fprintf (stderr, "Usage: %s [-Radlv] [files...]\n", program_name); exit (1); } @@ -59,7 +60,7 @@ static void list_attributes (const char * name) { if (v_opt) printf ("%5lu ", version); - print_flags (stdout, flags); + print_flags (stdout, flags, l_opt); printf (" %s\n", name); } } @@ -128,6 +129,9 @@ void main (int argc, char ** argv) case 'd': d_opt = 1; break; + case 'l': + l_opt = 1; + break; case 'v': v_opt = 1; break; diff --git a/misc/mke2fs.8 b/misc/mke2fs.8 index 5b1e5bc6..c398986b 100644 --- a/misc/mke2fs.8 +++ b/misc/mke2fs.8 @@ -1,5 +1,5 @@ .\" -*- nroff -*- -.TH MKE2FS 8 "March 1994" "Version 0.5" +.TH MKE2FS 8 "November 1994" "Version 0.5b" .SH NAME mke2fs \- create a Linux second extended file system .SH SYNOPSIS @@ -30,8 +30,14 @@ bytes-per-inode reserved-blocks-percentage ] [ +.B \-q +] +[ .B \-v ] +[ +.B \-S +] device [ blocks-count @@ -82,8 +88,21 @@ defaults to 5%. .\" Check the device for bad blocks before creating the file system .\" using the specified test. .TP +.I -q +Quiet execution. Useful if mke2fs is run in a script. +.TP .I -v Verbose execution. +.TP +.I -S +Write superblock and group descriptors only. This is useful if all of +the superblock and backup superblocks are corrupted, and a last-ditch +recovery method is desired. It causes mke2fs to reinitialize the +superblock and group descriptors, while not touching the inode table +and the block and inode bitmaps. The +.B e2fsck +program should be run immediately after this option is used, and there +is no gaurantee that any data will be salvageable. .SH AUTHOR This version of .B mke2fs @@ -96,9 +115,10 @@ extended file system does not support fragments yet. There may be some other ones. Please, report them to the author. .SH AVAILABILITY .B mke2fs -is available for anonymous ftp from ftp.ibp.fr (132.227.60.2) in -/pub/linux/BETA/ext2fs. +is available for anonymous ftp from ftp.ibp.fr and tsx-11.mit.edu in +/pub/linux/packages/ext2fs. .SH SEE ALSO +.BT badblocks (8), .BR dumpe2fs (8), .BR e2fsck (8), .BR tune2fs (8) diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 9d36ee92..13f536ab 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -22,8 +22,10 @@ #include <mntent.h> #include <malloc.h> #include <sys/ioctl.h> -#include <linux/ext2_fs.h> +#include <sys/types.h> + #include <linux/fs.h> +#include <linux/ext2_fs.h> #include "et/com_err.h" #include "ext2fs/ext2fs.h" @@ -32,6 +34,7 @@ #define STRIDE_LENGTH 8 extern int isatty(int); +extern FILE *fpopen(const char *cmd, const char *mode); const char * program_name = "mke2fs"; const char * device_name = NULL; @@ -40,6 +43,7 @@ const char * device_name = NULL; int cflag = 0; int verbose = 0; int quiet = 0; +int super_only = 0; char *bad_blocks_filename = 0; struct ext2_super_block param; @@ -49,8 +53,8 @@ static void usage(NOARGS) fprintf(stderr, "Usage: %s [-c|-t|-l filename] [-b block-size] " "[-f fragment-size]\n\t[-i bytes-per-inode] " - "[-m reserved-blocks-percentage] [-v]\n" - "\tdevice [blocks-count]\n", + "[-m reserved-blocks-percentage] [-qvS]\n" + "\t[-g blocks-per-group] device [blocks-count]\n", program_name); exit(1); } @@ -67,11 +71,11 @@ static int log2(int arg) return l; } -static long valid_offset (int fd, int offset) +static long valid_offset (int fd, ext2_loff_t offset) { char ch; - if (lseek (fd, offset, 0) < 0) + if (ext2_llseek (fd, offset, 0) < 0) return 0; if (read (fd, &ch, 1) < 1) return 0; @@ -80,14 +84,14 @@ static long valid_offset (int fd, int offset) static int count_blocks (int fd) { - int high, low; + ext2_loff_t high, low; low = 0; for (high = 1; valid_offset (fd, high); high *= 2) low = high; while (low < high - 1) { - const int mid = (low + high) / 2; + const ext2_loff_t mid = (low + high) / 2; if (valid_offset (fd, mid)) low = mid; @@ -192,7 +196,7 @@ static void test_disk(ext2_filsys fs, badblocks_list *bb_list) exit(1); } retval = ext2fs_read_bb_FILE(fs, f, bb_list, invalid_block); - fclose (f); + pclose(f); if (retval) { com_err("ext2fs_read_bb_FILE", retval, "while processing list of bad blocks from program"); @@ -202,11 +206,14 @@ static void test_disk(ext2_filsys fs, badblocks_list *bb_list) static void handle_bad_blocks(ext2_filsys fs, badblocks_list bb_list) { - int i; + int i, j; int must_be_good; blk_t blk; badblocks_iterate bb_iter; errcode_t retval; + blk_t group_block; + int group; + int group_bad; if (!bb_list) return; @@ -227,6 +234,33 @@ static void handle_bad_blocks(ext2_filsys fs, badblocks_list bb_list) exit(1); } } + + /* + * See if any of the bad blocks are showing up in the backup + * superblocks and/or group descriptors. If so, issue a + * warning and adjust the block counts appropriately. + */ + group_block = fs->super->s_first_data_block + + fs->super->s_blocks_per_group; + group_bad = 0; + + for (i = 1; i < fs->group_desc_count; i++) { + for (j=0; j < fs->desc_blocks+1; j++) { + if (badblocks_list_test(bb_list, group_block + + j)) { + if (!group_bad) + fprintf(stderr, +"Warning: the backup superblock/group descriptors at block %ld contain\n" +" bad blocks.\n\n", + group_block); + group_bad++; + group = ext2fs_group_of_blk(fs, group_block+j); + fs->group_desc[group].bg_free_blocks_count++; + fs->super->s_free_blocks_count++; + } + } + group_block += fs->super->s_blocks_per_group; + } /* * Mark all the bad blocks as used... @@ -238,13 +272,13 @@ static void handle_bad_blocks(ext2_filsys fs, badblocks_list bb_list) exit(1); } while (badblocks_list_iterate(bb_iter, &blk)) - ext2fs_mark_block_bitmap(fs, fs->block_map, blk); + ext2fs_mark_block_bitmap(fs->block_map, blk); badblocks_list_iterate_end(bb_iter); } static void new_table_block(ext2_filsys fs, blk_t first_block, - const char *name, int num, const char *buf, - blk_t *new_block) + const char *name, int num, int initialize, + const char *buf, blk_t *new_block) { errcode_t retval; blk_t blk; @@ -260,21 +294,24 @@ static void new_table_block(ext2_filsys fs, blk_t first_block, ext2fs_unmark_valid(fs); return; } - blk = *new_block; - for (i=0; i < num; i += STRIDE_LENGTH, blk += STRIDE_LENGTH) { - if (num-i > STRIDE_LENGTH) - count = STRIDE_LENGTH; - else - count = num - i; - retval = io_channel_write_blk(fs->io, blk, count, buf); - if (retval) - printf("Warning: could not write %d blocks starting " - "at %ld for %s: %s\n", - count, blk, name, error_message(retval)); + if (initialize) { + blk = *new_block; + for (i=0; i < num; i += STRIDE_LENGTH, blk += STRIDE_LENGTH) { + if (num-i > STRIDE_LENGTH) + count = STRIDE_LENGTH; + else + count = num - i; + retval = io_channel_write_blk(fs->io, blk, count, buf); + if (retval) + printf("Warning: could not write %d blocks " + "starting at %ld for %s: %s\n", + count, blk, name, + error_message(retval)); + } } blk = *new_block; for (i = 0; i < num; i++, blk++) - ext2fs_mark_block_bitmap(fs, fs->block_map, blk); + ext2fs_mark_block_bitmap(fs->block_map, blk); } static void alloc_tables(ext2_filsys fs) @@ -282,7 +319,6 @@ static void alloc_tables(ext2_filsys fs) blk_t group_blk; int i; char *buf; - int numblocks; buf = malloc(fs->blocksize * STRIDE_LENGTH); if (!buf) { @@ -297,28 +333,15 @@ static void alloc_tables(ext2_filsys fs) for (i = 0; i < fs->group_desc_count; i++) { if (!quiet) printf("%4d/%4ld", i, fs->group_desc_count); - new_table_block(fs, group_blk, "block bitmap", 1, buf, + new_table_block(fs, group_blk, "block bitmap", 1, 0, buf, &fs->group_desc[i].bg_block_bitmap); - new_table_block(fs, group_blk, "inode bitmap", 1, buf, + new_table_block(fs, group_blk, "inode bitmap", 1, 0, buf, &fs->group_desc[i].bg_inode_bitmap); new_table_block(fs, group_blk, "inode table", - fs->inode_blocks_per_group, buf, + fs->inode_blocks_per_group, + !super_only, buf, &fs->group_desc[i].bg_inode_table); - if (i == fs->group_desc_count-1) { - numblocks = (fs->super->s_blocks_count - - fs->super->s_first_data_block) % - fs->super->s_blocks_per_group; - if (!numblocks) - numblocks = fs->super->s_blocks_per_group; - } else - numblocks = fs->super->s_blocks_per_group; - numblocks -= 3 + fs->desc_blocks + fs->inode_blocks_per_group; - - fs->group_desc[i].bg_free_blocks_count = numblocks; - fs->group_desc[i].bg_free_inodes_count = - fs->super->s_inodes_per_group; - fs->group_desc[i].bg_used_dirs_count = 0; group_blk += fs->super->s_blocks_per_group; if (!quiet) printf("\b\b\b\b\b\b\b\b\b"); @@ -330,12 +353,28 @@ static void alloc_tables(ext2_filsys fs) static void create_root_dir(ext2_filsys fs) { errcode_t retval; + struct ext2_inode inode; retval = ext2fs_mkdir(fs, EXT2_ROOT_INO, EXT2_ROOT_INO, 0); if (retval) { com_err("ext2fs_mkdir", retval, "while creating root dir"); exit(1); } + if (geteuid()) { + retval = ext2fs_read_inode(fs, EXT2_ROOT_INO, &inode); + if (retval) { + com_err("ext2fs_read_inode", retval, + "while reading root inode"); + exit(1); + } + inode.i_uid = geteuid(); + retval = ext2fs_write_inode(fs, EXT2_ROOT_INO, &inode); + if (retval) { + com_err("ext2fs_write_inode", retval, + "while setting root inode ownership"); + exit(1); + } + } } static void create_lost_and_found(ext2_filsys fs) @@ -371,7 +410,7 @@ static void create_bad_block_inode(ext2_filsys fs, badblocks_list bb_list) { errcode_t retval; - ext2fs_mark_inode_bitmap(fs, fs->inode_map, EXT2_BAD_INO); + ext2fs_mark_inode_bitmap(fs->inode_map, EXT2_BAD_INO); fs->group_desc[0].bg_free_inodes_count--; fs->super->s_free_inodes_count--; retval = ext2fs_update_bb_inode(fs, bb_list); @@ -389,7 +428,7 @@ static void reserve_inodes(ext2_filsys fs) int group; for (i = EXT2_ROOT_INO + 1; i < EXT2_FIRST_INO; i++) { - ext2fs_mark_inode_bitmap (fs, fs->inode_map, i); + ext2fs_mark_inode_bitmap(fs->inode_map, i); group = ext2fs_group_of_ino(fs, i); fs->group_desc[group].bg_free_inodes_count--; fs->super->s_free_inodes_count--; @@ -397,6 +436,20 @@ static void reserve_inodes(ext2_filsys fs) ext2fs_mark_ib_dirty(fs); } +static void zap_bootblock(ext2_filsys fs) +{ + char buf[512]; + int retval; + + memset(buf, 0, 512); + + retval = io_channel_write_blk(fs->io, 0, -512, buf); + if (retval) + printf("Warning: could not erase block 0: %s\n", + error_message(retval)); +} + + static void show_stats(ext2_filsys fs) { struct ext2_super_block *s = fs->super; @@ -449,7 +502,8 @@ static void PRS(int argc, char *argv[]) char c; int size; char * tmp; - char *oldpath, newpath[PATH_MAX]; + char *oldpath; + static char newpath[PATH_MAX]; int inode_ratio = 4096; int reserved_ratio = 5; @@ -469,7 +523,7 @@ static void PRS(int argc, char *argv[]) EXT2FS_VERSION, EXT2FS_DATE); if (argc && *argv) program_name = *argv; - while ((c = getopt (argc, argv, "b:cf:g:i:l:m:qtv")) != EOF) + while ((c = getopt (argc, argv, "b:cf:g:i:l:m:qtvS")) != EOF) switch (c) { case 'b': size = strtoul(optarg, &tmp, 0); @@ -499,11 +553,20 @@ static void PRS(int argc, char *argv[]) break; case 'g': param.s_blocks_per_group = strtoul(optarg, &tmp, 0); + if (*tmp) { + com_err(program_name, 0, + "Illegal number for blocks per group"); + exit(1); + } if (param.s_blocks_per_group < 256 || param.s_blocks_per_group > 8192 || *tmp) { com_err(program_name, 0, - "bad blocks per group count - %s", - optarg); + "blocks per group count out of range"); + exit(1); + } + if ((param.s_blocks_per_group % 8) != 0) { + com_err(program_name, 0, + "blocks per group must be multiple of 8"); exit(1); } break; @@ -517,7 +580,13 @@ static void PRS(int argc, char *argv[]) } break; case 'l': - bad_blocks_filename = strdup(optarg); + bad_blocks_filename = malloc(strlen(optarg)+1); + if (!bad_blocks_filename) { + com_err(program_name, ENOMEM, + "in malloc for bad_blocks_filename"); + exit(1); + } + strcpy(bad_blocks_filename, optarg); break; case 'm': reserved_ratio = strtoul(optarg, &tmp, 0); @@ -534,6 +603,9 @@ static void PRS(int argc, char *argv[]) case 'q': quiet = 1; break; + case 'S': + super_only = 1; + break; default: usage(); } @@ -560,7 +632,8 @@ static void PRS(int argc, char *argv[]) * Calculate number of inodes based on the inode ratio */ param.s_inodes_count = - (param.s_blocks_count * EXT2_BLOCK_SIZE(¶m)) / inode_ratio; + ((long long) param.s_blocks_count * EXT2_BLOCK_SIZE(¶m)) + / inode_ratio; /* * Calculate number of blocks to reserve @@ -598,10 +671,16 @@ int main (int argc, char *argv[]) handle_bad_blocks(fs, bb_list); alloc_tables(fs); - create_root_dir(fs); - create_lost_and_found(fs); - reserve_inodes(fs); - create_bad_block_inode(fs, bb_list); + if (super_only) { + fs->super->s_state |= EXT2_ERROR_FS; + fs->flags &= ~(EXT2_FLAG_IB_DIRTY|EXT2_FLAG_BB_DIRTY); + } else { + create_root_dir(fs); + create_lost_and_found(fs); + reserve_inodes(fs); + create_bad_block_inode(fs, bb_list); + zap_bootblock(fs); + } if (!quiet) printf("Writing superblocks and " diff --git a/misc/mklost+found.8 b/misc/mklost+found.8 index b5663187..e757ff80 100644 --- a/misc/mklost+found.8 +++ b/misc/mklost+found.8 @@ -1,5 +1,5 @@ .\" -*- nroff -*- -.TH MKLOST+FOUND 8 "March 1994" "Version 0.5" +.TH MKLOST+FOUND 8 "November 1994" "Version 0.5b" .SH NAME mklost+found \- create a lost+found directory on a mounted Linux second extended file system @@ -23,8 +23,8 @@ of the ext2 fs. There are none :-) .SH AVAILABILITY .B mklost+found -is available for anonymous ftp from ftp.ibp.fr (132.227.60.2) in -/pub/linux/BETA/ext2fs. +is available for anonymous ftp from ftp.ibp.fr and tsx-11.mit.edu in +/pub/linux/packages/ext2fs. .SH SEE ALSO .BR e2fsck (8), .BR mke2fs (8) diff --git a/misc/tune2fs.8 b/misc/tune2fs.8 index 3d997041..a3cbf35b 100644 --- a/misc/tune2fs.8 +++ b/misc/tune2fs.8 @@ -2,14 +2,42 @@ .\" Initial revision .\" .\" -.TH TUNE2FS 8 "March 1994" "Version 0.5" +.TH TUNE2FS 8 "November 1994" "Version 0.5b" .SH NAME tune2fs \- adjust tunable filesystem parameters on second extended filesystems .SH SYNOPSIS .B tune2fs [ -.B options +.B -l +] +[ +.B -c +.I max-mount-counts +] +[ +.B -e +.I errors-behavior +] +[ +.B -i +.I interval-between-checks +] +[ +.B -m +.I reserved-blocks-percentage +] +[ +.B -r +.I reserved-blocks-count +] +[ +.B -u +.I user +] +[ +.B -g +.I group ] device .SH DESCRIPTION @@ -34,9 +62,15 @@ can be one of the followings: .br \ panic\ \ Causes a kernel panic. .TP -.I -i interval-between-checks[d|m] +.I -g group +set the user group which can benefit from the reserved blocks. +.br +.I group +can be a numerical gid or a group name. +.TP +.I -i interval-between-checks[d|m|w] adjust the maximal time between two filesystem checks. -No postfix or `d' result in days, and 'm' in months. +No postfix or `d' result in days, `m' in months, and `w' in weeks. A value of zero will disable the timedependent checking. .TP .I -l @@ -44,6 +78,14 @@ list the contents of the filesystem superblock. .TP .I -m reserved-blocks-percentage adjust the reserved blocks percentage on the given device. +.TP +.I -r reserved-blocks-count +adjust the reserved blocks count on the given device. +.TP +.I -u user +set the user who can benefit from the reserved blocks. +.I user +can be a numerical uid or a user name. .PP .SH BUGS We didn't find any bugs yet. Perhaps there are bugs but it's unlikely. @@ -63,8 +105,8 @@ This manual page was written by Christian Kuhtz <chk@data-hh.Hanse.DE>. Timedependent checking was added by Uwe Ohse <uwe@tirka.gun.de>. .SH AVAILABILITY .B tune2fs -is available for anonymous ftp from ftp.ibp.fr (132.227.60.2) in -/pub/linux/BETA/ext2fs. +is available for anonymous ftp from ftp.ibp.fr and tsx-11.mit.edu in +/pub/linux/packages/ext2fs. .SH SEE ALSO .BR dumpe2fs (8), .BR e2fsck (8), diff --git a/misc/tune2fs.c b/misc/tune2fs.c index 2f0d8602..cd2d622a 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -23,12 +23,15 @@ */ #include <fcntl.h> +#include <grp.h> #include <getopt.h> +#include <pwd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> +#include <sys/types.h> #include <linux/ext2_fs.h> @@ -42,19 +45,26 @@ const char * program_name = "tune2fs"; char * device_name = NULL; int c_flag = 0; int e_flag = 0; +int g_flag = 0; int i_flag = 0; int l_flag = 0; int m_flag = 0; +int r_flag = 0; +int u_flag = 0; int max_mount_count; unsigned long interval; unsigned long reserved_ratio = 0; +unsigned long reserved_blocks = 0; unsigned short errors; +unsigned long resgid = 0; +unsigned long resuid = 0; static volatile void usage (void) { fprintf (stderr, "Usage: %s [-c max-mounts-count] [-e errors-behavior] " - "[-i interval[d|m]]\n" - "\t[-l] [-m reserved-blocks-percent] device\n", program_name); + "[-g group]\n" + "\t[-i interval[d|m|w]] [-l] [-m reserved-blocks-percent]\n" + "\t[-r reserved-blocks-count] [-u user] device\n", program_name); exit (1); } @@ -64,6 +74,8 @@ void main (int argc, char ** argv) char * tmp; errcode_t retval; ext2_filsys fs; + struct group * gr; + struct passwd * pw; fprintf (stderr, "tune2fs %s, %s for EXT2 FS %s, %s\n", E2FSPROGS_VERSION, E2FSPROGS_DATE, @@ -71,7 +83,7 @@ void main (int argc, char ** argv) if (argc && *argv) program_name = *argv; initialize_ext2_error_table(); - while ((c = getopt (argc, argv, "c:e:i:lm:")) != EOF) + while ((c = getopt (argc, argv, "c:e:g:i:lm:r:u:")) != EOF) switch (c) { case 'c': @@ -101,6 +113,25 @@ void main (int argc, char ** argv) } e_flag = 1; break; + case 'g': + resgid = strtoul (optarg, &tmp, 0); + if (*tmp) + { + gr = getgrnam (optarg); + if (gr == NULL) + tmp = optarg; + else + resgid = gr->gr_gid; + } + if (*tmp) + { + com_err (program_name, 0, + "bad gid/group name - %s", + optarg); + usage (); + } + g_flag = 1; + break; case 'i': interval = strtoul (optarg, &tmp, 0); switch (*tmp) @@ -117,6 +148,11 @@ void main (int argc, char ** argv) interval *= 86400 * 30; tmp++; break; + case 'w': + case 'W': /* weeks */ + interval *= 86400 * 7; + tmp++; + break; } if (*tmp || interval > (365 * 86400)) { @@ -140,16 +176,48 @@ void main (int argc, char ** argv) } m_flag = 1; break; + case 'r': + reserved_blocks = strtoul (optarg, &tmp, 0); + if (*tmp) + { + com_err (program_name, 0, + "bad reserved blocks count - %s", + optarg); + usage (); + } + r_flag = 1; + break; + case 'u': + resuid = strtoul (optarg, &tmp, 0); + if (*tmp) + { + pw = getpwnam (optarg); + if (pw == NULL) + tmp = optarg; + else + resuid = pw->pw_uid; + } + if (*tmp) + { + com_err (program_name, 0, + "bad uid/user name - %s", + optarg); + usage (); + } + u_flag = 1; + break; default: usage (); } if (optind < argc - 1 || optind == argc) usage (); - if (!c_flag && !e_flag && !i_flag && !m_flag && !l_flag) + if (!c_flag && !e_flag && !g_flag && !i_flag && !l_flag && !m_flag + && !r_flag && !u_flag) usage (); device_name = argv[optind]; retval = ext2fs_open (device_name, - (c_flag || e_flag || i_flag || m_flag) ? EXT2_FLAG_RW : 0, + (c_flag || e_flag || g_flag || i_flag || m_flag + || r_flag || u_flag) ? EXT2_FLAG_RW : 0, 0, 0, unix_io_manager, &fs); if (retval) { @@ -171,6 +239,18 @@ void main (int argc, char ** argv) ext2fs_mark_super_dirty(fs); printf ("Setting error behavior to %d\n", errors); } + if (g_flag) +#ifdef EXT2_DEF_RESGID + { + fs->super->s_def_resgid = resgid; + ext2fs_mark_super_dirty(fs); + printf ("Setting reserved blocks gid to %lu\n", resgid); + } +#else + com_err (program_name, 0, + "The -g option is not supported by this version -- " + "Recompile with a newer kernel"); +#endif if (i_flag) { fs->super->s_checkinterval = interval; @@ -185,6 +265,32 @@ void main (int argc, char ** argv) printf ("Setting reserved blocks percentage to %lu (%lu blocks)\n", reserved_ratio, fs->super->s_r_blocks_count); } + if (r_flag) + { + if (reserved_blocks >= fs->super->s_blocks_count) + { + com_err (program_name, 0, + "reserved blocks count is too big (%ul)", + reserved_blocks); + exit (1); + } + fs->super->s_r_blocks_count = reserved_blocks; + ext2fs_mark_super_dirty(fs); + printf ("Setting reserved blocks count to %lu\n", + reserved_blocks); + } + if (u_flag) +#ifdef EXT2_DEF_RESUID + { + fs->super->s_def_resuid = resuid; + ext2fs_mark_super_dirty(fs); + printf ("Setting reserved blocks uid to %lu\n", resuid); + } +#else + com_err (program_name, 0, + "The -u option is not supported by this version -- " + "Recompile with a newer kernel"); +#endif if (l_flag) list_super (fs->super); ext2fs_close (fs); |