diff options
author | Theodore Ts'o <tytso@mit.edu> | 1997-04-26 13:58:21 +0000 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 1997-04-26 13:58:21 +0000 |
commit | 50e1e10fa0ac12a3e2a9d20a75ee9041873cda96 (patch) | |
tree | 7ef931607cf258793edffa5deb1ddb1f46469d04 /lib/ext2fs | |
parent | f3db3566b5e1342e49dffc5ec3f418a838584194 (diff) | |
download | e2fsprogs-50e1e10fa0ac12a3e2a9d20a75ee9041873cda96.tar.gz |
Many files:
Checked in e2fsprogs 0.5c
Diffstat (limited to 'lib/ext2fs')
43 files changed, 1771 insertions, 632 deletions
diff --git a/lib/ext2fs/.depend b/lib/ext2fs/.depend index dd371f65..19290096 100644 --- a/lib/ext2fs/.depend +++ b/lib/ext2fs/.depend @@ -1,198 +1,199 @@ -alloc.o : alloc.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ +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/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 \ + /usr/include/confname.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 \ +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/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/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/confname.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.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 \ +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/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/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/confname.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.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 \ +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/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/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/confname.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.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 \ +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/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 \ +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/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/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/confname.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 -check_desc.o : check_desc.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.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/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/confname.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.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 \ +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/confname.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/confname.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/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/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 \ +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/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/confname.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/gnu/types.h /usr/include/confname.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.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 \ +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/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/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/confname.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.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 \ +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/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/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/confname.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.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 \ +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/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/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/confname.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/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.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 \ +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/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/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/confname.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 -llseek.o : llseek.c /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/asm/types.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/confname.h ../et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ + ../ext2fs/io.h /usr/include/linux/unistd.h /usr/include/asm/unistd.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/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/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/confname.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.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 \ +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/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/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/confname.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 -newdir.o : newdir.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.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/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/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/confname.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 -openfs.o : openfs.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.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/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/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/confname.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.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 \ +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/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/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/confname.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.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 \ +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/gnu/types.h /usr/include/confname.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 \ + /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 \ +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/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/confname.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.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 \ +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/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/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/confname.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 ../et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \ - ext2_err.h io.h + ./ext2_err.h ./io.h diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index 5fd3bfed..4dd44ed4 100644 --- a/lib/ext2fs/ChangeLog +++ b/lib/ext2fs/ChangeLog @@ -1,3 +1,234 @@ +Thu Oct 26 12:09:16 1995 <tytso@rsts-11.mit.edu> + + * ext2_err.et: Updated message in EXT2_ET_BASE to say version 0.5c + + * swapfs.c (ext2fs_swap_super): Put an #ifdef check around + s_def_resuid and s_def_resgid for backwards compatibility. + +Fri Oct 20 23:33:31 1995 <tytso@rsts-11.mit.edu> + + * bitops.h: Added #ifdef's for Sparc. + +Wed Sep 6 22:14:46 1995 <tytso@rsts-11.mit.edu> + + * getsize.c: #include <sys/ioctl.h> under Linux to pick up ioctl() + declaration + + * closefs.c: #include <string.h> to pick up memset() declaration + +Mon Sep 4 21:45:29 1995 Remy Card <card@bbj> + + * Makefile.in: Added support for BSD shared libraries. + + * initialize.c (ext2fs_initialize): Correctly set the s_creator_os + flag. + +Mon Sep 4 09:55:30 1995 <tytso@rsts-11.mit.edu> + + * unix_io.c (unix_open): Add a double check; if the passed in name + is NULL, return EXT2_ET_BAD_DEVICE_NAME. + + * ext2_err.et (EXT2_ET_BAD_DEVICE_NAME): Added new error code + +Wed Aug 16 15:44:10 1995 <tytso@rsts-11.mit.edu> + + * inode.c (ext2fs_check_directory): Use LINUX_S_ISDIR instead of + S_ISDIR. + +Tue Aug 15 13:08:36 1995 <tytso@rsts-11.mit.edu> + + * getsize.c (ext2fs_get_device_size): Add support for reading the + partition size from a BSD disk label. + +Thu Aug 10 09:33:26 1995 Theodore Y. Ts'o <tytso@lurch.mit.edu> + + * getsize.c (ext2fs_get_device_size): New function that determins + the size of a device. Used by mke2fs and e2fsck. + +Sat Aug 12 03:09:54 1995 Remy Card <card@bbj> + + * Makefile.in (install): Install static libraries in $(ulibdir) + (/usr/lib on Linux) instead of $(libdir) (/lib on Linux). + +Wed Aug 9 17:04:23 1995 Theodore Y. Ts'o <tytso@dcl> + + * bitmaps.c (ext2fs_free_inode_bitmap, ext2fs_free_block_bitmap): + Move these functions to freefs.c. + + * closefs.c (ext2fs_flush): If swapping blocks, clear the group + descriptors shadow memory to keep purify quiet. (This + also has the nice benefit that the unused portion of the + shadow descriptors are zeroed out.) + + * dirblock.c (ext2fs_write_dir_block): We need to use + dirent->rec_len *before* it's byteswapped to find the + location of the next directory structure! + + * alloc.c (ext2fs_new_inode): Fix bug which could potentially + cause ext2fs_new_inode to loop infinitely if we're trying + to allocate an inode in group #0 and there are no free + inodes at all in the system. + + * closefs.c: #include <errno.h> if it exists. + +Sun Aug 6 13:27:50 1995 Theodore Y. Ts'o <tytso@lurch.mit.edu> + + * ext2fs.h (BLOCK_FLAG_HOLE): Added new definition for + BLOCK_FLAG_APPEND. Added documentation for the block + interator flags. + +Sat Aug 5 11:44:05 1995 Theodore Y. Ts'o <tytso@lurch.mit.edu> + + * Makefile.in (DLL_INSTALL_DIR, ELF_INSTALL_DIR): Set the + installation directories correctly. + +Tue Jul 18 09:27:38 1995 <tytso@rsx-11.mit.edu> + + * namei.c (process_dir_block): + * mkdir.c (ext2fs_mkdir): + * expanddir.c (expand_dir_proc): Use ext2fs_{read,write}_dir_block + to read/write the directory block. + + * dirblock.c (ext2fs_read_dir_block), ext2fs_write_dir_block): New + file containing functions for reading and writing + directory blocks (byte swapping if necesssary) + + * block.c (block_iterate_ind, block_iterate_dind, + block_iterate_tind): Byte swap the block addresses if + EXT2_SWAP_BYTES is set (and swap them back before writing + them out.) + + * inode.c (inocpy_with_swap): New function. + (ext2fs_get_next_inode, ext2fs_read_inode, ext2fs_write_inode): + Call inocpy_with_swap if EXT2_SWAP_BYTES if set. + + * closefs.c (ext2fs_flush): If EXT2_SWAP_BYTES is set, then swap + the superblock and group descriptors before writing it out. + + * openfs.c (ext2fs_open): If the magic number is byte-swapped, + then set the EXT2_SWAP_BYTES and byte-swap the superblock + and group descriptors. + + * swapfs.c (ext2fs_swap_super, ext2fs_swap_group_desc): New functions + to desp ext2 filesystem structures. + + * bitops.c (set_bit, clear_bit, test_bit): Use modifications + supplied by Pete A. Zaitcev so that the C language + versions of these functions are more portable. They will + now work on both little and big endian systems, and the + assumption that 32-bit integers are used is gone. + + * bitops.h (ext2_swab16, ext2_swab32): Added new functions for + doing byte swapping. + + * ext2fs.h (EXT2_SWAP_BYTES): Add new flag which indicates that + byte swapping should take place. + +Sun Jul 16 06:21:43 1995 <tytso@rsx-11.mit.edu> + + * Makefile.in, cmp_bitmaps.c (ext2fs_compare_block_bitmap_end, + ext2fs_compare_inode_bitmap_end): Added new file + containing routines to compare bitmaps. + + * ext2_err.et (EXT2_ET_NEQ_BLOCK_BITMAP, EXT2_ET_NEQ_INODE_BITMAP): + Added new error codes. + +Sat Jul 15 04:23:37 1995 <tytso@rsx-11.mit.edu> + + * inode.c (ext2fs_get_next_inode): Don't check scan->inode_buffer; + if the magic number is correct, it will be allocated. + +Fri Jul 14 19:02:59 1995 <tytso@rsx-11.mit.edu> + + * block.c (block_iterate_ind, block_iterate_dind, + block_iterate_tind): Don't recompute block_nr each loop; + just increment it! Factor check of BLOCK_FLAG_APPEND out + of the loop. Factor mask of BLOCK_CHANGED into changed + variable out of the loop. (block_iterate_ind, in + particular, gets called a lot, so every little + optimization helps.) + +Thu Jul 13 08:02:45 1995 <tytso@rsx-11.mit.edu> + + * block.c (block_iterate_ind, block_iterate_dind, + block_iterate_tind): Precompute limit of loop to speed up + block_iterate_ind and company. + + * bitops.h (ext2fs_fast_mark_block_bitmap, + ext2fs_fast_unmark_block_bitmap, ext2fs_fast_test_block_bitmap, + ext2fs_fast_mark_inode_bitmap, ext2fs_fast_unmark_inode_bitmap, + ext2fs_fast_test_inode_bitmap): Add fast version of these + functions, which don't do range checking. + + * bitops.h (ext2fs_get_block_bitmap_start, + ext2fs_get_inode_bitmap_start, ext2fs_get_block_bitmap_end, + ext2fs_get_inode_bitmap_end): Add new accessor functions + which return the start and end points of the bitmaps. + +Tue Jul 11 18:59:41 1995 <tytso@rsx-11.mit.edu> + + * llseek.c (ext2_llseek): If the offset is small enough, use lseek + instead of llseek. The errno if the offset is too large + and lseek is not supported should be EINVAL, not -EINVAL. + +Thu Jun 15 23:43:02 1995 Remy Card <card@bbj> + + * Makefile.in: Added support for ELF shared libraries. + Fixed typos in the compilation rules. + (distclean): Added Makefile. + + * llseek.c (llseek): New function, if llseek() does not exist in the + C library. + (ext2_llseek): Changed to call llseek(). + +Mon Jun 12 08:29:07 1995 Theodore Y. Ts'o <tytso@lurch.mit.edu> + + * ext2fs.h: Use __u32 to define blk_t, instead of unsigned long. + +Sun Jun 11 15:02:54 1995 Theodore Y. Ts'o <tytso@lurch.mit.edu> + + * mkdir.c (ext2fs_mkdir): Use LINUX_S_IFDIR instead of S_IFDIR. + + * ext2fs.h (LINUX_S_IFDIR): Define a linux specific versions of + the S_*, which are normally defined in <sys/stat.h>. This + allows us to compile e2fsprogs on a non-Linux system, + which may have a different value for S_IFDIR. + +Sat Jun 10 23:47:05 1995 Theodore Y. Ts'o <tytso@lurch.mit.edu> + + * bitops.c (clear_bit, set_bit): Remove calls to cli() and sti(); + this is a user-mode application! + +Thu Jun 8 13:13:22 1995 Miles Bader <miles@churchy.gnu.ai.mit.edu> + + * llseek.c: Put the include of <linux/unistd.h> inside the #ifdef + __linux__ so that non-linux systems won't see it. + + * alloc.c: Include <errno.h> if possible. + * badblocks.c: Ditto. + * bb_inode.c: Ditto. + * bitmaps.c: Ditto. + * block.c: Ditto. + * expanddir.c: Ditto. + * get_pathname.c: Ditto. + * initialize.c: Ditto. + * inode.c: Ditto. + * llseek.c: Ditto. + * mkdir.c: Ditto. + * namei.c: Ditto. + * newdir.c: Ditto. + * openfs.c: Ditto. + * rw_bitmaps.c: Ditto. + * unix_io.c: Ditto. + + * Makefile.in: Rewritten to conform to GNU coding standards and + support separate compilation directories. + +Thu May 11 04:13:12 1995 <tytso@rsx-11.mit.edu> + + * initialize.c (ext2fs_initialize): Don't allow more than one + bitmaps's worth of inodes in a group. + Sat Mar 11 14:07:11 1995 Theodore Y. Ts'o <tytso@localhost> * llseek.c (ext2_llseek): Added error checking to the llseek() diff --git a/lib/ext2fs/MAKELOG b/lib/ext2fs/MAKELOG deleted file mode 100644 index bb85c24a..00000000 --- a/lib/ext2fs/MAKELOG +++ /dev/null @@ -1,54 +0,0 @@ -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 deleted file mode 100644 index 5f991cfe..00000000 --- a/lib/ext2fs/Makefile +++ /dev/null @@ -1,107 +0,0 @@ -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) - -RM=rm -f -MV=mv -LN=ln -s - -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 -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 - -$(MV) $@ $@.bak - $(ARCHIVE) $@ $(OBJS) - $(RANLIB) $@ - $(RM) ../$@ - $(LN) ext2fs/$@ ../$@ - -libext2fs_p.a: $(OBJS) - $(RM) $@.bak - -$(MV) $@ $@.bak - (cd profiled; $(ARCHIVE) ../$@ $(OBJS)) - $(RANLIB) $@ - $(RM) ../$@ - $(LN) ext2fs/$@ ../$@ - -libext2fs_chk.a: $(OBJS) - $(RM) $@.bak - -$(MV) $@ $@.bak - (cd checker; $(ARCHIVE) ../$@ $(OBJS)) - $(RANLIB) $@ - $(RM) ../$@ - $(LN) ext2fs/$@ ../$@ - -ext2_err.c ext2_err.h: ext2_err.et - $(COMPILE_ET) ext2_err.et - -install-libs:: all - $(INSTALLLIB) libext2fs.a $(LIBDIR)/libext2fs.a - $(CHMOD) 644 $(LIBDIR)/libext2fs.a - $(RANLIB) $(LIBDIR)/libext2fs.a - $(CHMOD) $(LIBMODE) $(LIBDIR)/libext2fs.a - -install-libs:: $(HFILES) - @rm -rf $(INCLDIR)/ext2fs - @mkdir $(INCLDIR)/ext2fs - for i in $(HFILES); do \ - $(INSTALLINC) $$i $(INCLDIR)/ext2fs/$$i; \ - done - -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 - rm -f .depend ext2_err.c ext2_err.h - -dep depend .depend: ext2_err.h - $(CC) -M $(CFLAGS) *.c >.depend - -include .depend diff --git a/lib/ext2fs/Makefile.in b/lib/ext2fs/Makefile.in new file mode 100644 index 00000000..879ea814 --- /dev/null +++ b/lib/ext2fs/Makefile.in @@ -0,0 +1,289 @@ +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +top_builddir = ../.. +INSTALL = @INSTALL@ + +@MCONFIG@ + +OBJS= ext2_err.o \ + alloc.o \ + badblocks.o \ + bb_inode.o \ + bitmaps.o \ + bitops.o \ + block.o \ + check_desc.o \ + closefs.o \ + cmp_bitmaps.o \ + dirblock.o \ + expanddir.o \ + freefs.o \ + get_pathname.o \ + getsize.o \ + initialize.o \ + inline.o \ + inode.o \ + ismounted.o \ + link.o \ + llseek.o \ + mkdir.o \ + namei.o \ + newdir.o \ + openfs.o \ + read_bb.o \ + read_bb_file.o \ + rw_bitmaps.o \ + swapfs.o \ + unix_io.o + +SRCS= ext2_err.c \ + $(srcdir)/alloc.c \ + $(srcdir)/badblocks.c \ + $(srcdir)/bb_inode.c \ + $(srcdir)/bitmaps.c \ + $(srcdir)/bitops.c \ + $(srcdir)/block.c \ + $(srcdir)/check_desc.c \ + $(srcdir)/closefs.c \ + $(srcdir)/cmp_bitmaps.c \ + $(srcdir)/dirblock.c \ + $(srcdir)/expanddir.c \ + $(srcdir)/freefs.c \ + $(srcdir)/get_pathname.c \ + $(srcdir)/getsize.c \ + $(srcdir)/initialize.c \ + $(srcdir)/inline.c \ + $(srcdir)/inode.c \ + $(srcdir)/ismounted.c \ + $(srcdir)/link.c \ + $(srcdir)/llseek.c \ + $(srcdir)/mkdir.c \ + $(srcdir)/namei.c \ + $(srcdir)/newdir.c \ + $(srcdir)/openfs.c \ + $(srcdir)/read_bb.c \ + $(srcdir)/read_bb_file.c \ + $(srcdir)/rw_bitmaps.c \ + $(srcdir)/swapfs.c \ + $(srcdir)/unix_io.c + +HFILES= bitops.h ext2fs.h io.h + +LIBRARY= libext2fs +LIBDIR= ext2fs + +DLL_ADDRESS = 0x66900000 +DLL_JUMPSIZE = 0x1000 +DLL_GOTSIZE = 0x1000 +DLL_VERSION = 1.1 +DLL_IMAGE = libe2fs +DLL_STUB = libext2fs +DLL_LIBS = -L../.. -lcom_err +DLL_MYDIR = ext2fs +DLL_INSTALL_DIR = $(libdir) + +ELF_VERSION = 2.0 +ELF_IMAGE = libext2fs +ELF_MYDIR = ext2fs +ELF_INSTALL_DIR = $(libdir) + +BSDLIB_VERSION = 2.0 +BSDLIB_IMAGE = libext2fs +BSDLIB_MYDIR = ext2fs +BSDLIB_INSTALL_DIR = $(libdir) + +@MAKEFILE_LIBRARY@ +@MAKEFILE_DLL@ +@MAKEFILE_ELF@ +@MAKEFILE_BSDLIB@ +@MAKEFILE_PROFILE@ +@MAKEFILE_CHECKER@ + +.c.o: + $(CC) $(CFLAGS) -c $< -o $@ +@PROFILE_CMT@ $(CC) $(CFLAGS) -pg -o profiled/$*.o -c $< +@CHECKER_CMT@ $(CC) $(CFLAGS) -checker -g -o checker/$*.o -c $< +@DLL_CMT@ (export JUMP_DIR=`pwd`/jump; $(CC) -B$(JUMP_PREFIX) $(CFLAGS) \ +@DLL_CMT@ -o jump/$*.o -c $<) +@ELF_CMT@ $(CC) $(CFLAGS) -fPIC -o elfshared/$*.o -c $< +@BSDLIB_CMT@ $(CC) $(CFLAGS) -fpic -o pic/$*.o -c $< + +COMPILE_ET=../et/compile_et + +DISTFILES= Makefile *.c *.h image + +ext2_err.c ext2_err.h: $(srcdir)/ext2_err.et + $(COMPILE_ET) $(srcdir)/ext2_err.et + +installdirs:: + $(top_srcdir)/mkinstalldirs $(DESTDIR)$(ulibdir) \ + $(DESTDIR)$(includedir)/ext2fs + +install:: all $(HFILES) installdirs + $(INSTALL_DATA) libext2fs.a $(DESTDIR)$(ulibdir)/libext2fs.a + $(CHMOD) 644 $(DESTDIR)$(ulibdir)/libext2fs.a + -$(RANLIB) $(DESTDIR)$(ulibdir)/libext2fs.a + $(CHMOD) $(LIBMODE) $(DESTDIR)$(ulibdir)/libext2fs.a + for i in $(HFILES); do \ + $(INSTALL_DATA) $(srcdir)/$$i $(DESTDIR)$(includedir)/ext2fs/$$i; \ + done + $(INSTALL_DATA) ext2_err.h $(DESTDIR)$(includedir)/ext2fs/ext2_err.h + +uninstall:: + $(RM) -f $(ulibdir)/libext2fs.a + $(RM) -rf $(includedir)/ext2fs + +clean:: + $(RM) -f \#* *.s *.o *.a *~ *.bak core profiled/* checker/* \ + ext2_err.c ext2_err.h \ + ../libext2fs.a ../libext2fs_p.a ../libext2fs_chk.a + +mostlyclean:: clean +distclean:: clean + $(RM) -f .depend ext2_err.c ext2_err.h Makefile + +# +++ Dependency line eater +++ +# +# Makefile dependencies follow. This must be the last section in +# the Makefile.in file +# +ext2_err.o: ext2_err.c +alloc.o: $(srcdir)/alloc.c \ + $(srcdir)/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(srcdir)/bitops.h +badblocks.o: $(srcdir)/badblocks.c \ + $(srcdir)/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(srcdir)/bitops.h +bb_inode.o: $(srcdir)/bb_inode.c \ + $(srcdir)/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(srcdir)/bitops.h +bitmaps.o: $(srcdir)/bitmaps.c \ + $(srcdir)/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(srcdir)/bitops.h +bitops.o: $(srcdir)/bitops.c \ + $(srcdir)/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(srcdir)/bitops.h +block.o: $(srcdir)/block.c \ + $(srcdir)/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(srcdir)/bitops.h +check_desc.o: $(srcdir)/check_desc.c \ + $(srcdir)/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(srcdir)/bitops.h +closefs.o: $(srcdir)/closefs.c \ + $(srcdir)/ext2fs.h $(top_srcdir)/lib/et/com_err.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(srcdir)/bitops.h +cmp_bitmaps.o: $(srcdir)/cmp_bitmaps.c \ + $(srcdir)/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(srcdir)/bitops.h +dirblock.o: $(srcdir)/dirblock.c \ + $(srcdir)/ext2fs.h $(top_srcdir)/lib/et/com_err.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(srcdir)/bitops.h +expanddir.o: $(srcdir)/expanddir.c \ + $(srcdir)/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(srcdir)/bitops.h +freefs.o: $(srcdir)/freefs.c \ + $(srcdir)/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(srcdir)/bitops.h +get_pathname.o: $(srcdir)/get_pathname.c \ + $(srcdir)/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(srcdir)/bitops.h +getsize.o: $(srcdir)/getsize.c \ + $(srcdir)/ext2fs.h $(top_srcdir)/lib/et/com_err.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(srcdir)/bitops.h +initialize.o: $(srcdir)/initialize.c \ + $(srcdir)/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(srcdir)/bitops.h +inline.o: $(srcdir)/inline.c \ + $(srcdir)/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(srcdir)/bitops.h +inode.o: $(srcdir)/inode.c \ + $(srcdir)/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(srcdir)/bitops.h +ismounted.o: $(srcdir)/ismounted.c \ + $(srcdir)/ext2fs.h $(top_srcdir)/lib/et/com_err.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(srcdir)/bitops.h +link.o: $(srcdir)/link.c \ + $(srcdir)/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(srcdir)/bitops.h +llseek.o: $(srcdir)/llseek.c \ + $(top_srcdir)/lib/et/com_err.h \ + $(srcdir)/io.h \ + +mkdir.o: $(srcdir)/mkdir.c \ + $(srcdir)/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(srcdir)/bitops.h +namei.o: $(srcdir)/namei.c \ + $(srcdir)/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(srcdir)/bitops.h +newdir.o: $(srcdir)/newdir.c \ + $(srcdir)/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(srcdir)/bitops.h +openfs.o: $(srcdir)/openfs.c \ + $(srcdir)/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(srcdir)/bitops.h +read_bb.o: $(srcdir)/read_bb.c \ + $(srcdir)/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(srcdir)/bitops.h +read_bb_file.o: $(srcdir)/read_bb_file.c \ + $(srcdir)/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(srcdir)/bitops.h +rw_bitmaps.o: $(srcdir)/rw_bitmaps.c \ + $(srcdir)/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(srcdir)/bitops.h +swapfs.o: $(srcdir)/swapfs.c \ + $(srcdir)/ext2fs.h $(top_srcdir)/lib/et/com_err.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(srcdir)/bitops.h +unix_io.o: $(srcdir)/unix_io.c \ + $(top_srcdir)/lib/et/com_err.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/io.h + diff --git a/lib/ext2fs/alloc.c b/lib/ext2fs/alloc.c index 26c01118..5465e804 100644 --- a/lib/ext2fs/alloc.c +++ b/lib/ext2fs/alloc.c @@ -11,6 +11,9 @@ #include <time.h> #include <sys/stat.h> #include <sys/types.h> +#if HAVE_ERRNO_H +#include <errno.h> +#endif #include <linux/ext2_fs.h> @@ -40,9 +43,9 @@ errcode_t ext2fs_new_inode(ext2_filsys fs, ino_t dir, int mode, dir_group = (dir - 1) / EXT2_INODES_PER_GROUP(fs->super); start_inode = (dir_group * EXT2_INODES_PER_GROUP(fs->super)) + 1; + if (start_inode < EXT2_FIRST_INO) + start_inode = EXT2_FIRST_INO; i = start_inode; - if (i < EXT2_FIRST_INO) - i = EXT2_FIRST_INO; do { if (!ext2fs_test_inode_bitmap(map, i)) diff --git a/lib/ext2fs/badblocks.c b/lib/ext2fs/badblocks.c index 8a405012..f286747b 100644 --- a/lib/ext2fs/badblocks.c +++ b/lib/ext2fs/badblocks.c @@ -13,6 +13,9 @@ #include <time.h> #include <sys/stat.h> #include <sys/types.h> +#if HAVE_ERRNO_H +#include <errno.h> +#endif #include <linux/ext2_fs.h> diff --git a/lib/ext2fs/bb_inode.c b/lib/ext2fs/bb_inode.c index 2b0ea9f6..c8dfeba1 100644 --- a/lib/ext2fs/bb_inode.c +++ b/lib/ext2fs/bb_inode.c @@ -17,6 +17,9 @@ #include <time.h> #include <sys/stat.h> #include <sys/types.h> +#if HAVE_ERRNO_H +#include <errno.h> +#endif #include <linux/ext2_fs.h> diff --git a/lib/ext2fs/bitmaps.c b/lib/ext2fs/bitmaps.c index 8712e2d5..d5ef0ec7 100644 --- a/lib/ext2fs/bitmaps.c +++ b/lib/ext2fs/bitmaps.c @@ -14,6 +14,9 @@ #include <time.h> #include <sys/stat.h> #include <sys/types.h> +#if HAVE_ERRNO_H +#include <errno.h> +#endif #include <linux/ext2_fs.h> @@ -151,37 +154,3 @@ void ext2fs_clear_block_bitmap(ext2fs_block_bitmap bitmap) ((bitmap->real_end - bitmap->start) / 8) + 1); } -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 (bitmap->bitmap) { - free(bitmap->bitmap); - bitmap->bitmap = 0; - } - free(bitmap); -} - -void ext2fs_free_block_bitmap(ext2fs_block_bitmap bitmap) -{ - if (!bitmap || (bitmap->magic != EXT2_ET_MAGIC_BLOCK_BITMAP)) - return; - - bitmap->magic = 0; - if (bitmap->description) { - free(bitmap->description); - bitmap->description = 0; - } - if (bitmap->bitmap) { - free(bitmap->bitmap); - bitmap->bitmap = 0; - } - free(bitmap); -} - diff --git a/lib/ext2fs/bitops.c b/lib/ext2fs/bitops.c index c037199e..0dc89677 100644 --- a/lib/ext2fs/bitops.c +++ b/lib/ext2fs/bitops.c @@ -21,54 +21,46 @@ * For the benefit of those who are trying to port Linux to another * architecture, here are some C-language equivalents. You should * recode these in the native assmebly language, if at all possible. - * To guarantee atomicity, these routines call cli() and sti() to - * disable interrupts while they operate. (You have to provide inline - * routines to cli() and sti().) * - * Also note, these routines assume that you have 32 bit integers. - * You will have to change this if you are trying to port Linux to the - * Alpha architecture or to a Cray. :-) - * - * C language equivalents written by Theodore Ts'o, 9/26/92 + * C language equivalents written by Theodore Ts'o, 9/26/92. + * Modified by Pete A. Zaitcev 7/14/95 to be portable to big endian + * systems, as well as non-32 bit systems. */ int set_bit(int nr,void * addr) { - int mask, retval; - int *ADDR = (int *) addr; + int mask, retval; + unsigned char *ADDR = (unsigned char *) addr; - ADDR += nr >> 5; - mask = 1 << (nr & 0x1f); - cli(); + ADDR += nr >> 3; + mask = 1 << (nr & 0x07); retval = (mask & *ADDR) != 0; *ADDR |= mask; - sti(); return retval; } int clear_bit(int nr, void * addr) { - int mask, retval; - int *ADDR = (int *) addr; + int mask, retval; + unsigned char *ADDR = (unsigned char *) addr; - ADDR += nr >> 5; - mask = 1 << (nr & 0x1f); - cli(); + ADDR += nr >> 3; + mask = 1 << (nr & 0x07); retval = (mask & *ADDR) != 0; *ADDR &= ~mask; - sti(); return retval; } int test_bit(int nr, const void * addr) { - int mask; - const int *ADDR = (const int *) addr; + int mask; + const unsigned char *ADDR = (const unsigned char *) addr; - ADDR += nr >> 5; - mask = 1 << (nr & 0x1f); + ADDR += nr >> 3; + mask = 1 << (nr & 0x07); return ((mask & *ADDR) != 0); } + #endif /* !_EXT2_HAVE_ASM_BITOPS_ */ void ext2fs_warn_bitmap(errcode_t errcode, unsigned long arg, diff --git a/lib/ext2fs/bitops.h b/lib/ext2fs/bitops.h index 87e7d79e..4b0fa39a 100644 --- a/lib/ext2fs/bitops.h +++ b/lib/ext2fs/bitops.h @@ -1,7 +1,8 @@ /* - * bitops.h --- Bitmap frobbing code. + * bitops.h --- Bitmap frobbing code. The byte swapping routines are + * also included here. * - * Copyright (C) 1993, 1994 Theodore Ts'o. This file may be + * Copyright (C) 1993, 1994, 1995 Theodore Ts'o. This file may be * redistributed under the terms of the GNU Public License. * * Taken from <asm/bitops.h>, Copyright 1992, Linus Torvalds. @@ -11,6 +12,8 @@ extern int set_bit(int nr,void * addr); extern int clear_bit(int nr, void * addr); extern int test_bit(int nr, const void * addr); +extern __u16 ext2fs_swab16(__u16 val); +extern __u32 ext2fs_swab32(__u32 val); /* * EXT2FS bitmap manipulation routines. @@ -35,12 +38,40 @@ 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); +extern void ext2fs_fast_mark_block_bitmap(ext2fs_block_bitmap bitmap, + blk_t block); +extern void ext2fs_fast_unmark_block_bitmap(ext2fs_block_bitmap bitmap, + blk_t block); +extern int ext2fs_fast_test_block_bitmap(ext2fs_block_bitmap bitmap, + blk_t block); + +extern void ext2fs_fast_mark_inode_bitmap(ext2fs_inode_bitmap bitmap, + ino_t inode); +extern void ext2fs_fast_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap, + ino_t inode); +extern int ext2fs_fast_test_inode_bitmap(ext2fs_inode_bitmap bitmap, + ino_t inode); +extern blk_t ext2fs_get_block_bitmap_start(ext2fs_block_bitmap bitmap); +extern blk_t ext2fs_get_inode_bitmap_start(ext2fs_inode_bitmap bitmap); +extern blk_t ext2fs_get_block_bitmap_end(ext2fs_block_bitmap bitmap); +extern blk_t ext2fs_get_inode_bitmap_end(ext2fs_inode_bitmap bitmap); + /* * The inline routines themselves... * * If NO_INLINE_FUNCS is defined, then we won't try to do inline - * functions at all! + * functions at all; they will be included as normal functions in + * inline.c */ +#ifdef NO_INLINE_FUNCS +#if (defined(__i386__) || defined(__i486__) || defined(__i586__) || \ + defined(__mc68000__) || defined(__sparc__)) + /* This prevents bitops.c from trying to include the C */ + /* function version of these functions */ +#define _EXT2_HAVE_ASM_BITOPS_ +#endif +#endif /* NO_INLINE_FUNCS */ + #if (defined(INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS)) #ifdef INCLUDE_INLINE_FUNCS #define _INLINE_ extern @@ -137,6 +168,61 @@ _INLINE_ int test_bit(int nr, const void * addr) #endif /* __mc68000__ */ +#ifdef __sparc__ + +#define _EXT2_HAVE_ASM_BITOPS_ + +_INLINE_ int set_bit(int nr, void *addr) +{ + int mask, retval; + unsigned long *ADDR = (unsigned long *) addr; + + ADDR += nr >> 5; + mask = 1 << (nr & 31); + retval = ((mask & *ADDR) != 0); + *ADDR |= mask; + return retval; +} + +_INLINE_ int clear_bit(int nr, void *addr) +{ + int mask, retval; + unsigned long *ADDR = (unsigned long *) addr; + + ADDR += nr >> 5; + mask = 1 << (nr & 31); + retval = ((mask & *ADDR) != 0); + *ADDR &= ~mask; + return retval; +} + +_INLINE_ int test_bit(int nr, const void *addr) +{ + int mask; + const unsigned long *ADDR = (const unsigned long *) addr; + + ADDR += nr >> 5; + mask = 1 << (nr & 31); + return ((mask & *ADDR) != 0); +} + +#endif /* __sparc__ */ + +#ifndef _EXT2_HAVE_ASM_SWAB + +_INLINE_ __u16 ext2fs_swab16(__u16 val) +{ + return (val >> 8) | (val << 8); +} + +_INLINE_ __u32 ext2fs_swab32(__u32 val) +{ + return ((val>>24) | ((val>>8)&0xFF00) | + ((val<<8)&0xFF0000) | (val<<24)); +} + +#endif /* !_EXT2_HAVE_ASM_SWAB */ + _INLINE_ void ext2fs_mark_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block) { @@ -203,5 +289,104 @@ _INLINE_ int ext2fs_test_inode_bitmap(ext2fs_inode_bitmap bitmap, return test_bit(inode - bitmap->start, bitmap->bitmap); } +_INLINE_ void ext2fs_fast_mark_block_bitmap(ext2fs_block_bitmap bitmap, + blk_t block) +{ +#ifdef EXT2FS_DEBUG_FAST_OPS + if ((block < bitmap->start) || (block > bitmap->end)) { + ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_MARK, block, + bitmap->description); + return; + } +#endif + set_bit(block - bitmap->start, bitmap->bitmap); +} + +_INLINE_ void ext2fs_fast_unmark_block_bitmap(ext2fs_block_bitmap bitmap, + blk_t block) +{ +#ifdef EXT2FS_DEBUG_FAST_OPS + if ((block < bitmap->start) || (block > bitmap->end)) { + ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_UNMARK, + block, bitmap->description); + return; + } +#endif + clear_bit(block - bitmap->start, bitmap->bitmap); +} + +_INLINE_ int ext2fs_fast_test_block_bitmap(ext2fs_block_bitmap bitmap, + blk_t block) +{ +#ifdef EXT2FS_DEBUG_FAST_OPS + if ((block < bitmap->start) || (block > bitmap->end)) { + ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_TEST, + block, bitmap->description); + return 0; + } +#endif + return test_bit(block - bitmap->start, bitmap->bitmap); +} + +_INLINE_ void ext2fs_fast_mark_inode_bitmap(ext2fs_inode_bitmap bitmap, + ino_t inode) +{ +#ifdef EXT2FS_DEBUG_FAST_OPS + if ((inode < bitmap->start) || (inode > bitmap->end)) { + ext2fs_warn_bitmap(EXT2_ET_BAD_INODE_MARK, + inode, bitmap->description); + return; + } +#endif + set_bit(inode - bitmap->start, bitmap->bitmap); +} + +_INLINE_ void ext2fs_fast_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap, + ino_t inode) +{ +#ifdef EXT2FS_DEBUG_FAST_OPS + if ((inode < bitmap->start) || (inode > bitmap->end)) { + ext2fs_warn_bitmap(EXT2_ET_BAD_INODE_UNMARK, + inode, bitmap->description); + return; + } +#endif + clear_bit(inode - bitmap->start, bitmap->bitmap); +} + +_INLINE_ int ext2fs_fast_test_inode_bitmap(ext2fs_inode_bitmap bitmap, + ino_t inode) +{ +#ifdef EXT2FS_DEBUG_FAST_OPS + if ((inode < bitmap->start) || (inode > bitmap->end)) { + ext2fs_warn_bitmap(EXT2_ET_BAD_INODE_TEST, + inode, bitmap->description); + return 0; + } +#endif + return test_bit(inode - bitmap->start, bitmap->bitmap); +} + +_INLINE_ blk_t ext2fs_get_block_bitmap_start(ext2fs_block_bitmap bitmap) +{ + return bitmap->start; +} + +_INLINE_ blk_t ext2fs_get_inode_bitmap_start(ext2fs_inode_bitmap bitmap) +{ + return bitmap->start; +} + +_INLINE_ blk_t ext2fs_get_block_bitmap_end(ext2fs_block_bitmap bitmap) +{ + return bitmap->end; +} + +_INLINE_ blk_t ext2fs_get_inode_bitmap_end(ext2fs_inode_bitmap bitmap) +{ + return bitmap->end; +} + #undef _INLINE_ #endif + diff --git a/lib/ext2fs/block.c b/lib/ext2fs/block.c index 53c193c2..fe112b31 100644 --- a/lib/ext2fs/block.c +++ b/lib/ext2fs/block.c @@ -9,6 +9,9 @@ #include <string.h> #include <unistd.h> #include <stdlib.h> +#if HAVE_ERRNO_H +#include <errno.h> +#endif #include <linux/ext2_fs.h> @@ -33,7 +36,7 @@ struct block_context { static int block_iterate_ind(blk_t *ind_block, struct block_context *ctx) { int ret = 0, changed = 0; - int i, flags; + int i, flags, limit; blk_t *block_nr; if (!(ctx->flags & BLOCK_FLAG_DEPTH_TRAVERSE)) @@ -52,19 +55,42 @@ static int block_iterate_ind(blk_t *ind_block, struct block_context *ctx) ret |= BLOCK_ERROR; return ret; } - for (i = 0; i < (ctx->fs->blocksize >> 2); i++, ctx->bcount++) { - block_nr = (blk_t *) ctx->ind_buf + i; - if (*block_nr || (ctx->flags & BLOCK_FLAG_APPEND)) { + limit = ctx->fs->blocksize >> 2; + if (ctx->fs->flags & EXT2_SWAP_BYTES) { + block_nr = (blk_t *) ctx->ind_buf; + for (i = 0; i < limit; i++, block_nr++) + *block_nr = ext2fs_swab32(*block_nr); + } + block_nr = (blk_t *) ctx->ind_buf; + if (ctx->flags & BLOCK_FLAG_APPEND) { + for (i = 0; i < limit; i++, ctx->bcount++, block_nr++) { + flags = (*ctx->func)(ctx->fs, block_nr, ctx->bcount, + ctx->private); + changed |= flags; + if (flags & BLOCK_ABORT) { + ret |= BLOCK_ABORT; + break; + } + } + } else { + for (i = 0; i < limit; i++, ctx->bcount++, block_nr++) { + if (*block_nr == 0) + continue; flags = (*ctx->func)(ctx->fs, block_nr, ctx->bcount, ctx->private); - changed |= flags & BLOCK_CHANGED; + changed |= flags; if (flags & BLOCK_ABORT) { ret |= BLOCK_ABORT; break; } } } - if (changed) { + if (changed & BLOCK_CHANGED) { + if (ctx->fs->flags & EXT2_SWAP_BYTES) { + block_nr = (blk_t *) ctx->ind_buf; + for (i = 0; i < limit; i++, block_nr++) + *block_nr = ext2fs_swab32(*block_nr); + } ctx->errcode = io_channel_write_blk(ctx->fs->io, *ind_block, 1, ctx->ind_buf); if (ctx->errcode) @@ -79,7 +105,7 @@ static int block_iterate_ind(blk_t *ind_block, struct block_context *ctx) static int block_iterate_dind(blk_t *dind_block, struct block_context *ctx) { int ret = 0, changed = 0; - int i, flags; + int i, flags, limit; blk_t *block_nr; if (!(ctx->flags & BLOCK_FLAG_DEPTH_TRAVERSE)) @@ -98,18 +124,40 @@ static int block_iterate_dind(blk_t *dind_block, struct block_context *ctx) ret |= BLOCK_ERROR; return ret; } - for (i = 0; i < (ctx->fs->blocksize >> 2); i++) { - block_nr = (blk_t *) ctx->dind_buf + i; - if (*block_nr || (ctx->flags & BLOCK_FLAG_APPEND)) { + limit = ctx->fs->blocksize >> 2; + if (ctx->fs->flags & EXT2_SWAP_BYTES) { + block_nr = (blk_t *) ctx->dind_buf; + for (i = 0; i < limit; i++, block_nr++) + *block_nr = ext2fs_swab32(*block_nr); + } + block_nr = (blk_t *) ctx->dind_buf; + if (ctx->flags & BLOCK_FLAG_APPEND) { + for (i = 0; i < limit; i++, block_nr++) { + flags = block_iterate_ind(block_nr, ctx); + changed |= flags; + if (flags & (BLOCK_ABORT | BLOCK_ERROR)) { + ret |= flags & (BLOCK_ABORT | BLOCK_ERROR); + break; + } + } + } else { + for (i = 0; i < limit; i++, block_nr++) { + if (*block_nr == 0) + continue; flags = block_iterate_ind(block_nr, ctx); - changed |= flags & BLOCK_CHANGED; + changed |= flags; if (flags & (BLOCK_ABORT | BLOCK_ERROR)) { ret |= flags & (BLOCK_ABORT | BLOCK_ERROR); break; } } } - if (changed) { + if (changed & BLOCK_CHANGED) { + if (ctx->fs->flags & EXT2_SWAP_BYTES) { + block_nr = (blk_t *) ctx->dind_buf; + for (i = 0; i < limit; i++, block_nr++) + *block_nr = ext2fs_swab32(*block_nr); + } ctx->errcode = io_channel_write_blk(ctx->fs->io, *dind_block, 1, ctx->dind_buf); if (ctx->errcode) @@ -124,7 +172,7 @@ static int block_iterate_dind(blk_t *dind_block, struct block_context *ctx) static int block_iterate_tind(blk_t *tind_block, struct block_context *ctx) { int ret = 0, changed = 0; - int i, flags; + int i, flags, limit; blk_t *block_nr; if (!(ctx->flags & BLOCK_FLAG_DEPTH_TRAVERSE)) @@ -143,17 +191,40 @@ static int block_iterate_tind(blk_t *tind_block, struct block_context *ctx) ret |= BLOCK_ERROR; return ret; } - for (i = 0; i < (ctx->fs->blocksize >> 2); i++) { - block_nr = (blk_t *) ctx->tind_buf + i; - if (*block_nr || (ctx->flags & BLOCK_FLAG_APPEND)) { + limit = ctx->fs->blocksize >> 2; + if (ctx->fs->flags & EXT2_SWAP_BYTES) { + block_nr = (blk_t *) ctx->tind_buf; + for (i = 0; i < limit; i++, block_nr++) + *block_nr = ext2fs_swab32(*block_nr); + } + block_nr = (blk_t *) ctx->tind_buf; + if (ctx->flags & BLOCK_FLAG_APPEND) { + for (i = 0; i < limit; i++, block_nr++) { + flags = block_iterate_dind(block_nr, ctx); + changed |= flags; + if (flags & (BLOCK_ABORT | BLOCK_ERROR)) { + ret |= flags & (BLOCK_ABORT | BLOCK_ERROR); + break; + } + } + } else { + for (i = 0; i < limit; i++, block_nr++) { + if (*block_nr == 0) + continue; flags = block_iterate_dind(block_nr, ctx); + changed |= flags; if (flags & (BLOCK_ABORT | BLOCK_ERROR)) { ret |= flags & (BLOCK_ABORT | BLOCK_ERROR); break; } } } - if (changed) { + if (changed & BLOCK_CHANGED) { + if (ctx->fs->flags & EXT2_SWAP_BYTES) { + block_nr = (blk_t *) ctx->tind_buf; + for (i = 0; i < limit; i++, block_nr++) + *block_nr = ext2fs_swab32(*block_nr); + } ctx->errcode = io_channel_write_blk(ctx->fs->io, *tind_block, 1, ctx->tind_buf); if (ctx->errcode) diff --git a/lib/ext2fs/closefs.c b/lib/ext2fs/closefs.c index 41a5052c..d8b796e3 100644 --- a/lib/ext2fs/closefs.c +++ b/lib/ext2fs/closefs.c @@ -9,6 +9,10 @@ #include <unistd.h> #include <stdlib.h> #include <time.h> +#include <string.h> +#ifdef HAVE_ERRNO_H +#include <errno.h> +#endif #include <linux/ext2_fs.h> @@ -21,27 +25,60 @@ errcode_t ext2fs_flush(ext2_filsys fs) errcode_t retval; char *group_ptr; unsigned long fs_state; + struct ext2_super_block *super_shadow = 0; + struct ext2_group_desc *group_shadow = 0; + struct ext2_group_desc *s, *t; EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); + fs_state = fs->super->s_state; + + fs->super->s_wtime = time(NULL); + if (fs->flags & EXT2_SWAP_BYTES) { + retval = ENOMEM; + if (!(super_shadow = malloc(SUPERBLOCK_SIZE))) + goto errout; + if (!(group_shadow = malloc(fs->blocksize*fs->desc_blocks))) + goto errout; + memset(group_shadow, 0, fs->blocksize*fs->desc_blocks); + + /* swap the superblock */ + *super_shadow = *fs->super; + ext2fs_swap_super(super_shadow); + + /* swap the group descriptors */ + for (j=0, s=fs->group_desc, t=group_shadow; + j < fs->group_desc_count; j++, t++, s++) { + *t = *s; + ext2fs_swap_group_desc(t); + } + } else { + super_shadow = fs->super; + group_shadow = fs->group_desc; + } + /* * Write out master superblock. This has to be done * separately, since it is located at a fixed location * (SUPERBLOCK_OFFSET). */ - fs->super->s_wtime = time(NULL); io_channel_set_blksize(fs->io, SUPERBLOCK_OFFSET); - retval = io_channel_write_blk(fs->io, 1, -SUPERBLOCK_SIZE, fs->super); + retval = io_channel_write_blk(fs->io, 1, -SUPERBLOCK_SIZE, + super_shadow); if (retval) - return retval; + goto errout; io_channel_set_blksize(fs->io, fs->blocksize); /* - * Save the state of the FS and set it to non valid for the - * backup superblocks + * Set the state of the FS to be non-valid. (The state has + * already been backed up earlier, and will be restored when + * we exit.) */ - fs_state = fs->super->s_state; fs->super->s_state &= ~EXT2_VALID_FS; + if (fs->flags & EXT2_SWAP_BYTES) { + *super_shadow = *fs->super; + ext2fs_swap_super(super_shadow); + } /* * Write out the master group descriptors, and the backup @@ -52,28 +89,22 @@ errcode_t ext2fs_flush(ext2_filsys fs) if (i !=0 ) { retval = io_channel_write_blk(fs->io, group_block, -SUPERBLOCK_SIZE, - fs->super); - if (retval) { - fs->super->s_state = fs_state; - return retval; - } + super_shadow); + if (retval) + goto errout; } - group_ptr = (char *) fs->group_desc; + group_ptr = (char *) group_shadow; for (j=0; j < fs->desc_blocks; j++) { retval = io_channel_write_blk(fs->io, group_block+1+j, 1, group_ptr); - if (retval) { - fs->super->s_state = fs_state; - return retval; - } + if (retval) + goto errout; 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 @@ -83,10 +114,19 @@ errcode_t ext2fs_flush(ext2_filsys fs) if (fs->write_bitmaps) { retval = fs->write_bitmaps(fs); if (retval) - return retval; + goto errout; } - - return 0; + + retval = 0; +errout: + fs->super->s_state = fs_state; + if (fs->flags & EXT2_SWAP_BYTES) { + if (super_shadow) + free(super_shadow); + if (group_shadow) + free(group_shadow); + } + return retval; } errcode_t ext2fs_close(ext2_filsys fs) diff --git a/lib/ext2fs/cmp_bitmaps.c b/lib/ext2fs/cmp_bitmaps.c new file mode 100644 index 00000000..cc9eb6d7 --- /dev/null +++ b/lib/ext2fs/cmp_bitmaps.c @@ -0,0 +1,65 @@ +/* + * cmp_bitmaps.c --- routines to compare inode and block bitmaps. + * + * Copyright (C) 1995 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> +#if HAVE_ERRNO_H +#include <errno.h> +#endif + +#include <linux/ext2_fs.h> + +#include "ext2fs.h" + +errcode_t ext2fs_compare_block_bitmap(ext2fs_block_bitmap bm1, + ext2fs_block_bitmap bm2) +{ + int i; + + EXT2_CHECK_MAGIC(bm1, EXT2_ET_MAGIC_BLOCK_BITMAP); + EXT2_CHECK_MAGIC(bm2, EXT2_ET_MAGIC_BLOCK_BITMAP); + + if ((bm1->start != bm2->start) || + (bm1->end != bm2->end) || + (memcmp(bm1->bitmap, bm2->bitmap, (bm1->end - bm1->start)/8))) + return EXT2_ET_NEQ_BLOCK_BITMAP; + + for (i = bm1->end - ((bm1->end - bm1->start) % 8); i <= bm1->end; i++) + if (ext2fs_fast_test_block_bitmap(bm1, i) != + ext2fs_fast_test_block_bitmap(bm2, i)) + return EXT2_ET_NEQ_BLOCK_BITMAP; + + return 0; +} + +errcode_t ext2fs_compare_inode_bitmap(ext2fs_inode_bitmap bm1, + ext2fs_inode_bitmap bm2) +{ + int i; + + EXT2_CHECK_MAGIC(bm1, EXT2_ET_MAGIC_INODE_BITMAP); + EXT2_CHECK_MAGIC(bm2, EXT2_ET_MAGIC_INODE_BITMAP); + + if ((bm1->start != bm2->start) || + (bm1->end != bm2->end) || + (memcmp(bm1->bitmap, bm2->bitmap, (bm1->end - bm1->start)/8))) + return EXT2_ET_NEQ_INODE_BITMAP; + + for (i = bm1->end - ((bm1->end - bm1->start) % 8); i <= bm1->end; i++) + if (ext2fs_fast_test_inode_bitmap(bm1, i) != + ext2fs_fast_test_inode_bitmap(bm2, i)) + return EXT2_ET_NEQ_INODE_BITMAP; + + return 0; +} + diff --git a/lib/ext2fs/dirblock.c b/lib/ext2fs/dirblock.c new file mode 100644 index 00000000..bb2f7175 --- /dev/null +++ b/lib/ext2fs/dirblock.c @@ -0,0 +1,74 @@ +/* + * dirblock.c --- directory block routines. + * + * Copyright (C) 1995 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 <time.h> +#ifdef HAVE_ERRNO_H +#include <errno.h> +#endif + +#include <linux/ext2_fs.h> + +#include "ext2fs.h" + +errcode_t ext2fs_read_dir_block(ext2_filsys fs, blk_t block, + void *buf) +{ + errcode_t retval; + char *p, *end; + struct ext2_dir_entry *dirent; + + retval = io_channel_read_blk(fs->io, block, 1, buf); + if (retval) + return retval; + if ((fs->flags & EXT2_SWAP_BYTES) == 0) + return 0; + p = buf; + end = (char *) buf + fs->blocksize; + while (p < end) { + dirent = (struct ext2_dir_entry *) p; + dirent->inode = ext2fs_swab32(dirent->inode); + dirent->rec_len = ext2fs_swab16(dirent->rec_len); + dirent->name_len = ext2fs_swab16(dirent->name_len); + p += (dirent->rec_len < 8) ? 8 : dirent->rec_len; + } + return 0; +} + +errcode_t ext2fs_write_dir_block(ext2_filsys fs, blk_t block, + void *inbuf) +{ + errcode_t retval; + char *p, *end, *write_buf; + char *buf = 0; + struct ext2_dir_entry *dirent; + + if (fs->flags & EXT2_SWAP_BYTES) { + write_buf = buf = malloc(fs->blocksize); + if (!buf) + return ENOMEM; + memcpy(buf, inbuf, fs->blocksize); + p = buf; + end = buf + fs->blocksize; + while (p < end) { + dirent = (struct ext2_dir_entry *) p; + p += (dirent->rec_len < 8) ? 8 : dirent->rec_len; + dirent->inode = ext2fs_swab32(dirent->inode); + dirent->rec_len = ext2fs_swab16(dirent->rec_len); + dirent->name_len = ext2fs_swab16(dirent->name_len); + } + } else + write_buf = inbuf; + retval = io_channel_write_blk(fs->io, block, 1, write_buf); + if (buf) + free(buf); + return retval; +} + + diff --git a/lib/ext2fs/jump/jump.funcs b/lib/ext2fs/dll/jump.funcs index a8f5674b..730ee315 100644 --- a/lib/ext2fs/jump/jump.funcs +++ b/lib/ext2fs/dll/jump.funcs @@ -73,3 +73,23 @@ 00000000 T _initialize_ext2_error_table libext2fs ext2_err 00000000 T _ext2_llseek libext2fs llseek 00000000 T _ext2fs_set_inode_callback libext2fs inode +00000000 T _ext2fs_compare_block_bitmap libext2fs cmp_bitmaps +00000000 T _ext2fs_compare_inode_bitmap libext2fs cmp_bitmaps +00000000 T _ext2fs_read_dir_block libext2fs dirblock +00000000 T _ext2fs_write_dir_block libext2fs dirblock +00000000 T _ext2fs_swab16 libext2fs inline +00000000 T _ext2fs_swab32 libext2fs inline +00000000 T _ext2fs_fast_mark_block_bitmap libext2fs inline +00000000 T _ext2fs_fast_unmark_block_bitmap libext2fs inline +00000000 T _ext2fs_fast_test_block_bitmap libext2fs inline +00000000 T _ext2fs_fast_mark_inode_bitmap libext2fs inline +00000000 T _ext2fs_fast_unmark_inode_bitmap libext2fs inline +00000000 T _ext2fs_fast_test_inode_bitmap libext2fs inline +00000000 T _ext2fs_get_block_bitmap_start libext2fs inline +00000000 T _ext2fs_get_inode_bitmap_start libext2fs inline +00000000 T _ext2fs_get_block_bitmap_end libext2fs inline +00000000 T _ext2fs_get_inode_bitmap_end libext2fs inline +00000000 T _ext2fs_swap_super libext2fs swapfs +00000000 T _ext2fs_swap_group_desc libext2fs swapfs +00000000 T _ext2fs_get_device_size libext2fs getsize +00000000 T _ext2fs_check_if_mounted libext2fs ismounted diff --git a/lib/ext2fs/dll/jump.ignore b/lib/ext2fs/dll/jump.ignore new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/lib/ext2fs/dll/jump.ignore diff --git a/lib/ext2fs/jump/jump.import b/lib/ext2fs/dll/jump.import index 53208d55..53208d55 100644 --- a/lib/ext2fs/jump/jump.import +++ b/lib/ext2fs/dll/jump.import diff --git a/lib/ext2fs/jump/jump.params b/lib/ext2fs/dll/jump.params index ea74d630..cc96847c 100644 --- a/lib/ext2fs/jump/jump.params +++ b/lib/ext2fs/dll/jump.params @@ -3,4 +3,4 @@ Text=0x66900000 Data=0x00000000 Jump=0x00001000 GOT=0x00001000 -Version=1.0.0 +Version=1.1.0 diff --git a/lib/ext2fs/dll/jump.undefs b/lib/ext2fs/dll/jump.undefs new file mode 100644 index 00000000..294a0b7f --- /dev/null +++ b/lib/ext2fs/dll/jump.undefs @@ -0,0 +1,2 @@ +6690b080 D __NEEDS_SHRLIB_libc_4 +6690b098 D __NEEDS_SHRLIB_libet_1 diff --git a/lib/ext2fs/jump/jump.vars b/lib/ext2fs/dll/jump.vars index edbbf7c7..edbbf7c7 100644 --- a/lib/ext2fs/jump/jump.vars +++ b/lib/ext2fs/dll/jump.vars diff --git a/lib/ext2fs/expanddir.c b/lib/ext2fs/expanddir.c index 5af9853d..b2597c9f 100644 --- a/lib/ext2fs/expanddir.c +++ b/lib/ext2fs/expanddir.c @@ -9,6 +9,9 @@ #include <string.h> #include <unistd.h> #include <stdlib.h> +#if HAVE_ERRNO_H +#include <errno.h> +#endif #include <linux/ext2_fs.h> @@ -55,7 +58,7 @@ static int expand_dir_proc(ext2_filsys fs, } memset(block, 0, fs->blocksize); } - retval = io_channel_write_blk(fs->io, new_blk, 1, block); + retval = ext2fs_write_dir_block(fs, new_blk, block); if (retval) { es->err = retval; return BLOCK_ABORT; diff --git a/lib/ext2fs/ext2_err.c b/lib/ext2fs/ext2_err.c deleted file mode 100644 index f9759493..00000000 --- a/lib/ext2fs/ext2_err.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * ext2_err.c: - * This file is automatically generated; please do not edit it. - */ -#ifdef __STDC__ -#define NOARGS void -#else -#define NOARGS -#define const -#endif - -static const char * const text[] = { - "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", - "Attempt to write to filesystem opened read-only", - "Can't read group descriptors", - "Can't write group descriptors", - "Corrupt group descriptor: bad block for block bitmap", - "Corrupt group descriptor: bad block for inode bitmap", - "Corrupt group descriptor: bad block for inode table", - "Can't write an inode bitmap", - "Can't read an inode bitmap", - "Can't write an block bitmap", - "Can't read an block bitmap", - "Can't write an inode table", - "Can't read an inode table", - "Can't read next inode", - "Filesystem has unexpected block size", - "EXT2 directory corrupted", - "Attempt to read block from filesystem resulted in short read", - "Attempt to write block from filesystem resulted in short write", - "No free space in the directory", - "Inode bitmap not loaded", - "BLOCK bitmap not loaded", - "Illegal inode number", - "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 -}; - -struct error_table { - char const * const * msgs; - long base; - int n_msgs; -}; -struct et_list { - struct et_list *next; - const struct error_table * table; -}; -extern struct et_list *_et_list; - -static const struct error_table et = { text, 2133571328L, 59 }; - -static struct et_list link = { 0, 0 }; - -void initialize_ext2_error_table (NOARGS); - -void initialize_ext2_error_table (NOARGS) { - if (!link.table) { - link.next = _et_list; - link.table = &et; - _et_list = &link; - } -} diff --git a/lib/ext2fs/ext2_err.et b/lib/ext2fs/ext2_err.et index f439f5a2..71298b81 100644 --- a/lib/ext2fs/ext2_err.et +++ b/lib/ext2fs/ext2_err.et @@ -5,7 +5,7 @@ error_table ext2 ec EXT2_ET_BASE, - "EXT2FS Library version 0.5b" + "EXT2FS Library version 0.5c" ec EXT2_ET_MAGIC_EXT2FS_FILSYS, "Wrong magic number for ext2_filsys structure" @@ -181,5 +181,14 @@ ec EXT2_ET_BAD_DIND_BLOCK, ec EXT2_ET_BAD_TIND_BLOCK, "Illegal triply indirect block found" +ec EXT2_ET_NEQ_BLOCK_BITMAP, + "Block bitmaps are not the same" + +ec EXT2_ET_NEQ_INODE_BITMAP, + "Inode bitmaps are not the same" + +ec EXT2_ET_BAD_DEVICE_NAME, + "Illegal or malformed device name" + end diff --git a/lib/ext2fs/ext2_err.h b/lib/ext2fs/ext2_err.h deleted file mode 100644 index 0a93b1a1..00000000 --- a/lib/ext2fs/ext2_err.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * ext2_err.h: - * This file is automatically generated; please do not edit it. - */ -#ifdef __STDC__ -#define NOARGS void -#else -#define NOARGS -#define const -#endif - -#define EXT2_ET_BASE (2133571328L) -#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) - -/* for compatibility with older versions... */ -#define init_ext2_err_tbl initialize_ext2_error_table -#define ext2_err_base ERROR_TABLE_BASE_ext2 diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index 672466b3..140c1269 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -21,7 +21,9 @@ */ #define EXT2_LIB_CURRENT_REV 0 -typedef unsigned long blk_t; +#include <linux/types.h> + +typedef __u32 blk_t; typedef unsigned int dgrp_t; #include "et/com_err.h" @@ -64,6 +66,7 @@ typedef struct ext2fs_struct_block_bitmap *ext2fs_block_bitmap; #define EXT2_FLAG_VALID 0x08 #define EXT2_FLAG_IB_DIRTY 0x10 #define EXT2_FLAG_BB_DIRTY 0x20 +#define EXT2_SWAP_BYTES 0x40 struct struct_ext2_filsys { int magic; @@ -128,8 +131,21 @@ struct struct_badblocks_iterate { /* * Block interate flags + * + * BLOCK_FLAG_APPEND, or BLOCK_FLAG_HOLE, indicates that the interator + * function should be called on blocks where the block number is zero. + * This is used by ext2fs_expand_dir() to be able to add a new block + * to an inode. It can also be used for programs that want to be able + * to deal with files that contain "holes". + * + * BLOCK_FLAG_TRAVERSE indicates that the iterator function for the + * indirect, doubly indirect, etc. blocks should be called after all + * of the blocks containined in the indirect blocks are processed. + * This is useful if you are going to be deallocating blocks from an + * inode. */ #define BLOCK_FLAG_APPEND 1 +#define BLOCK_FLAG_HOLE 1 #define BLOCK_FLAG_DEPTH_TRAVERSE 2 /* @@ -169,6 +185,38 @@ struct ext2_struct_inode_scan { }; /* + * ext2fs_check_if_mounted flags + */ +#define EXT2_MF_MOUNTED 1 +#define EXT2_MF_ISROOT 2 +#define EXT2_MF_READONLY 4 + +/* + * Ext2/linux mode flags. We define them here so that we don't need + * to depend on the OS's sys/stat.h, since we may be compiling on a + * non-Linux system. + */ +#define LINUX_S_IFMT 00170000 +#define LINUX_S_IFSOCK 0140000 +#define LINUX_S_IFLNK 0120000 +#define LINUX_S_IFREG 0100000 +#define LINUX_S_IFBLK 0060000 +#define LINUX_S_IFDIR 0040000 +#define LINUX_S_IFCHR 0020000 +#define LINUX_S_IFIFO 0010000 +#define LINUX_S_ISUID 0004000 +#define LINUX_S_ISGID 0002000 +#define LINUX_S_ISVTX 0001000 + +#define LINUX_S_ISLNK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFLNK) +#define LINUX_S_ISREG(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFREG) +#define LINUX_S_ISDIR(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFDIR) +#define LINUX_S_ISCHR(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFCHR) +#define LINUX_S_ISBLK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFBLK) +#define LINUX_S_ISFIFO(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFIFO) +#define LINUX_S_ISSOCK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFSOCK) + +/* * For checking structure magic numbers... */ @@ -208,20 +256,18 @@ 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); -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_allocate_block_bitmap(ext2_filsys fs, + const char *descr, + ext2fs_block_bitmap *ret); +extern errcode_t ext2fs_allocate_inode_bitmap(ext2_filsys fs, + const char *descr, + ext2fs_inode_bitmap *ret); +extern errcode_t ext2fs_fudge_inode_bitmap_end(ext2fs_inode_bitmap bitmap, + ino_t end, ino_t *oend); +extern errcode_t ext2fs_fudge_block_bitmap_end(ext2fs_block_bitmap bitmap, + blk_t end, blk_t *oend); +extern void ext2fs_clear_inode_bitmap(ext2fs_inode_bitmap bitmap); +extern void ext2fs_clear_block_bitmap(ext2fs_block_bitmap bitmap); extern errcode_t ext2fs_read_bitmaps(ext2_filsys fs); extern errcode_t ext2fs_write_bitmaps(ext2_filsys fs); @@ -243,11 +289,30 @@ extern errcode_t ext2fs_check_desc(ext2_filsys fs); extern errcode_t ext2fs_close(ext2_filsys fs); extern errcode_t ext2fs_flush(ext2_filsys fs); +/* cmp_bitmaps.c */ +extern errcode_t ext2fs_compare_block_bitmap(ext2fs_block_bitmap bm1, + ext2fs_block_bitmap bm2); +extern errcode_t ext2fs_compare_inode_bitmap(ext2fs_inode_bitmap bm1, + ext2fs_inode_bitmap bm2); + + +/* dirblock.c */ +extern errcode_t ext2fs_read_dir_block(ext2_filsys fs, blk_t block, + void *buf); +extern errcode_t ext2fs_write_dir_block(ext2_filsys fs, blk_t block, + void *buf); + /* expanddir.c */ extern errcode_t ext2fs_expand_dir(ext2_filsys fs, ino_t dir); /* freefs.c */ extern void ext2fs_free(ext2_filsys fs); +extern void ext2fs_free_block_bitmap(ext2fs_block_bitmap bitmap); +extern void ext2fs_free_inode_bitmap(ext2fs_inode_bitmap bitmap); + +/* getsize.c */ +extern errcode_t ext2fs_get_device_size(const char *file, int blocksize, + blk_t *retblocks); /* initialize.c */ extern errcode_t ext2fs_initialize(const char *name, int flags, @@ -279,6 +344,9 @@ extern errcode_t ext2fs_write_inode(ext2_filsys fs, unsigned long ino, extern errcode_t ext2fs_get_blocks(ext2_filsys fs, ino_t ino, blk_t *blocks); extern errcode_t ext2fs_check_directory(ext2_filsys fs, ino_t ino); +/* ismounted.c */ +extern errcode_t ext2fs_check_if_mounted(const char *file, int *mount_flags); + /* namei.c */ extern errcode_t ext2fs_dir_iterate(ext2_filsys fs, ino_t dir, @@ -327,6 +395,10 @@ extern errcode_t ext2fs_read_bb_FILE(ext2_filsys fs, FILE *f, void (*invalid)(ext2_filsys fs, blk_t blk)); +/* swapfs.c */ +extern void ext2fs_swap_super(struct ext2_super_block * super); +extern void ext2fs_swap_group_desc(struct ext2_group_desc *gdp); + /* inline functions */ extern void ext2fs_mark_super_dirty(ext2_filsys fs); extern void ext2fs_mark_changed(ext2_filsys fs); diff --git a/lib/ext2fs/freefs.c b/lib/ext2fs/freefs.c index d9d4fe98..63b52356 100644 --- a/lib/ext2fs/freefs.c +++ b/lib/ext2fs/freefs.c @@ -27,9 +27,43 @@ void ext2fs_free(ext2_filsys fs) if (fs->group_desc) free(fs->group_desc); if (fs->block_map) - free(fs->block_map); + ext2fs_free_block_bitmap(fs->block_map); if (fs->inode_map) - free(fs->inode_map); + ext2fs_free_inode_bitmap(fs->inode_map); free(fs); } +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 (bitmap->bitmap) { + free(bitmap->bitmap); + bitmap->bitmap = 0; + } + free(bitmap); +} + +void ext2fs_free_block_bitmap(ext2fs_block_bitmap bitmap) +{ + if (!bitmap || (bitmap->magic != EXT2_ET_MAGIC_BLOCK_BITMAP)) + return; + + bitmap->magic = 0; + if (bitmap->description) { + free(bitmap->description); + bitmap->description = 0; + } + if (bitmap->bitmap) { + free(bitmap->bitmap); + bitmap->bitmap = 0; + } + free(bitmap); +} + diff --git a/lib/ext2fs/get_pathname.c b/lib/ext2fs/get_pathname.c index a5db2e09..da6b249a 100644 --- a/lib/ext2fs/get_pathname.c +++ b/lib/ext2fs/get_pathname.c @@ -9,6 +9,9 @@ #include <string.h> #include <unistd.h> #include <stdlib.h> +#if HAVE_ERRNO_H +#include <errno.h> +#endif #include <linux/ext2_fs.h> diff --git a/lib/ext2fs/getsize.c b/lib/ext2fs/getsize.c new file mode 100644 index 00000000..79186249 --- /dev/null +++ b/lib/ext2fs/getsize.c @@ -0,0 +1,123 @@ +/* + * getsize.c --- get the size of a partition. + * + * Copyright (C) 1995 Theodore Ts'o. This file may be + * redistributed under the terms of the GNU Public License. + */ + +#include <stdio.h> +#if HAVE_UNISTD_H +#include <unistd.h> +#endif +#if HAVE_STDLIB_H +#include <stdlib.h> +#endif +#ifdef HAVE_ERRNO_H +#include <errno.h> +#endif +#include <fcntl.h> +#ifdef HAVE_LINUX_FS_H +#include <linux/fs.h> +#endif +#ifdef HAVE_LINUX_FD_H +#include <sys/ioctl.h> +#include <linux/fd.h> +#endif +#ifdef HAVE_SYS_DISKLABEL_H +#include <sys/ioctl.h> +#include <sys/disklabel.h> +#endif /* HAVE_SYS_DISKLABEL_H */ + +#include <linux/ext2_fs.h> +#include "ext2fs.h" + +static int valid_offset (int fd, ext2_loff_t offset) +{ + char ch; + + if (ext2_llseek (fd, offset, 0) < 0) + return 0; + if (read (fd, &ch, 1) < 1) + return 0; + return 1; +} + +/* + * Returns the number of blocks in a partition + */ +errcode_t ext2fs_get_device_size(const char *file, int blocksize, + blk_t *retblocks) +{ + int fd; + int size; + ext2_loff_t high, low; +#ifdef FDGETPRM + struct floppy_struct this_floppy; +#endif +#ifdef HAVE_SYS_DISKLABEL_H + struct disklabel lab; + struct partition *pp; + char ch; +#endif /* HAVE_SYS_DISKLABEL_H */ + + fd = open(file, O_RDWR); + if (fd < 0) + return errno; + +#ifdef BLKGETSIZE + if (ioctl(fd, BLKGETSIZE, &size) >= 0) { + close(fd); + *retblocks = size / (blocksize / 512); + return 0; + } +#endif +#ifdef FDGETPRM + if (ioctl(fd, FDGETPRM, &this_floppy) >= 0) { + close(fd); + *retblocks = this_floppy.size / (blocksize / 512); + return 0; + } +#endif +#ifdef HAVE_SYS_DISKLABEL_H + size = strlen(file) - 1; + if (size >= 0) { + ch = file[size]; + if (isdigit(ch)) + size = 0; + else if (ch >= 'a' && ch <= 'h') + size = ch - 'a'; + else + size = -1; + } + if (size >= 0 && (ioctl(fd, DIOCGDINFO, (char *)&lab) >= 0)) { + pp = &lab.d_partitions[size]; + if (pp->p_size) { + close(fd); + *retblocks = pp->p_size / (blocksize / 512); + return 0; + } + } +#endif /* HAVE_SYS_DISKLABEL_H */ + + /* + * OK, we couldn't figure it out by using a specialized ioctl, + * which is generally the besy way. So do binary search to + * find the size of the partition. + */ + low = 0; + for (high = 1024; valid_offset (fd, high); high *= 2) + low = high; + while (low < high - 1) + { + const ext2_loff_t mid = (low + high) / 2; + + if (valid_offset (fd, mid)) + low = mid; + else + high = mid; + } + valid_offset (fd, 0); + close(fd); + *retblocks = (low + 1) / blocksize; + return 0; +} diff --git a/lib/ext2fs/initialize.c b/lib/ext2fs/initialize.c index 22e7eaf3..7428b0d4 100644 --- a/lib/ext2fs/initialize.c +++ b/lib/ext2fs/initialize.c @@ -11,11 +11,26 @@ #include <time.h> #include <sys/stat.h> #include <sys/types.h> +#if HAVE_ERRNO_H +#include <errno.h> +#endif #include <linux/ext2_fs.h> #include "ext2fs.h" +#if defined(__linux__) && defined(EXT2_OS_LINUX) +#define CREATOR_OS EXT2_OS_LINUX +#elif defined(__gnu__) && defined(EXT2_OS_HURD) +#define CREATOR_OS EXT2_OS_HURD +#elif defined(__FreeBSD__) && defined(EXT2_OS_FREEBSD) +#define CREATOR_OS EXT2_OS_FREEBSD +#elif defined(LITES) && defined(EXT2_OS_LITES) +#define CREATOR_OS EXT2_OS_LITES +#else +#define CREATOR_OS EXT2_OS_LINUX /* by default */ +#endif + errcode_t ext2fs_initialize(const char *name, int flags, struct ext2_super_block *param, io_manager manager, ext2_filsys *ret_fs) @@ -72,9 +87,7 @@ 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 + super->s_creator_os = CREATOR_OS; fs->blocksize = EXT2_BLOCK_SIZE(super); fs->fragsize = EXT2_FRAG_SIZE(super); @@ -104,11 +117,14 @@ retry: /* * There should be at least as many inodes as the user * requested. Figure out how many inodes per group that - * should be. + * should be. But make sure that we don't allocate more than + * one bitmap's worth of inodes */ super->s_inodes_per_group = (super->s_inodes_count + fs->group_desc_count - 1) / fs->group_desc_count; + if (super->s_inodes_per_group > fs->blocksize*8) + super->s_inodes_per_group = fs->blocksize*8; /* * Make sure the number of inodes per group completely fills diff --git a/lib/ext2fs/inode.c b/lib/ext2fs/inode.c index 6a9c1785..ae69bc21 100644 --- a/lib/ext2fs/inode.c +++ b/lib/ext2fs/inode.c @@ -11,11 +11,16 @@ #include <stdlib.h> #include <sys/stat.h> #include <sys/types.h> +#if HAVE_ERRNO_H +#include <errno.h> +#endif #include <linux/ext2_fs.h> #include "ext2fs.h" +static void inocpy_with_swap(struct ext2_inode *t, struct ext2_inode *f); + errcode_t ext2fs_open_inode_scan(ext2_filsys fs, int buffer_blocks, ext2_inode_scan *ret_scan) { @@ -77,9 +82,6 @@ errcode_t ext2fs_get_next_inode(ext2_inode_scan scan, ino_t *ino, 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->done_group) { @@ -120,7 +122,11 @@ errcode_t ext2fs_get_next_inode(ext2_inode_scan scan, ino_t *ino, return EXT2_ET_NEXT_INODE_READ; scan->inode_scan_ptr = (struct ext2_inode *) scan->inode_buffer; } - *inode = *scan->inode_scan_ptr++; + if (scan->fs->flags & EXT2_SWAP_BYTES) + inocpy_with_swap(inode, scan->inode_scan_ptr++); + else + *inode = *scan->inode_scan_ptr++; + scan->inodes_left--; scan->current_inode++; *ino = scan->current_inode; @@ -171,8 +177,12 @@ errcode_t ext2fs_read_inode (ext2_filsys fs, unsigned long ino, return retval; inode_buffer_block = block_nr; } - memcpy (inode, (struct ext2_inode *) inode_buffer + i, - sizeof (struct ext2_inode)); + if (fs->flags & EXT2_SWAP_BYTES) + inocpy_with_swap(inode, + (struct ext2_inode *) inode_buffer + i); + else + memcpy (inode, (struct ext2_inode *) inode_buffer + i, + sizeof (struct ext2_inode)); return 0; } @@ -217,8 +227,12 @@ errcode_t ext2fs_write_inode(ext2_filsys fs, unsigned long ino, return retval; inode_buffer_block = block_nr; } - memcpy ((struct ext2_inode *) inode_buffer + i, inode, - sizeof (struct ext2_inode)); + if (fs->flags & EXT2_SWAP_BYTES) + inocpy_with_swap((struct ext2_inode *) inode_buffer + i, + inode); + else + memcpy ((struct ext2_inode *) inode_buffer + i, inode, + sizeof (struct ext2_inode)); retval = io_channel_write_blk(fs->io, block_nr, 1, inode_buffer); if (retval) return retval; @@ -264,10 +278,33 @@ errcode_t ext2fs_check_directory(ext2_filsys fs, ino_t ino) retval = ext2fs_read_inode(fs, ino, &inode); if (retval) return retval; - if (!S_ISDIR(inode.i_mode)) + if (!LINUX_S_ISDIR(inode.i_mode)) return ENOTDIR; return 0; } +static void inocpy_with_swap(struct ext2_inode *t, struct ext2_inode *f) +{ + unsigned i; - + t->i_mode = ext2fs_swab16(f->i_mode); + t->i_uid = ext2fs_swab16(f->i_uid); + t->i_size = ext2fs_swab32(f->i_size); + t->i_atime = ext2fs_swab32(f->i_atime); + t->i_ctime = ext2fs_swab32(f->i_ctime); + t->i_mtime = ext2fs_swab32(f->i_mtime); + t->i_dtime = ext2fs_swab32(f->i_dtime); + t->i_gid = ext2fs_swab16(f->i_gid); + t->i_links_count = ext2fs_swab16(f->i_links_count); + t->i_blocks = ext2fs_swab32(f->i_blocks); + t->i_flags = ext2fs_swab32(f->i_flags); + for (i = 0; i < EXT2_N_BLOCKS; i++) + t->i_block[i] = ext2fs_swab32(f->i_block[i]); + t->i_version = ext2fs_swab32(f->i_version); + t->i_file_acl = ext2fs_swab32(f->i_file_acl); + t->i_dir_acl = ext2fs_swab32(f->i_dir_acl); + t->i_faddr = ext2fs_swab32(f->i_faddr); + t->osd2.linux2.l_i_frag = f->osd2.linux2.l_i_frag; + t->osd2.linux2.l_i_fsize = f->osd2.linux2.l_i_fsize; + t->osd2.linux2.i_pad1 = ext2fs_swab16(f->osd2.linux2.i_pad1); +} diff --git a/lib/ext2fs/ismounted.c b/lib/ext2fs/ismounted.c new file mode 100644 index 00000000..58c88fba --- /dev/null +++ b/lib/ext2fs/ismounted.c @@ -0,0 +1,121 @@ +/* + * getsize.c --- get the size of a partition. + * + * Copyright (C) 1995 Theodore Ts'o. This file may be + * redistributed under the terms of the GNU Public License. + */ + +#include <stdio.h> +#if HAVE_UNISTD_H +#include <unistd.h> +#endif +#if HAVE_STDLIB_H +#include <stdlib.h> +#endif +#ifdef HAVE_ERRNO_H +#include <errno.h> +#endif +#include <fcntl.h> +#ifdef HAVE_LINUX_FS_H +#include <linux/fs.h> +#endif +#ifdef HAVE_LINUX_FD_H +#include <linux/fd.h> +#endif +#ifdef HAVE_MNTENT_H +#include <mntent.h> +#endif +#ifdef HAVE_GETMNTINFO +#include <paths.h> +#include <sys/param.h> +#include <sys/mount.h> +#endif /* HAVE_GETMNTINFO */ + +#include <linux/ext2_fs.h> +#include "ext2fs.h" + +#ifdef HAVE_MNTENT_H +/* + * XXX we only check to see if the mount is readonly when it's the + * root filesystem EXT2_FS_READONLY. + */ +static errcode_t check_mntent(const char *file, int *mount_flags) +{ + FILE * f; + struct mntent * mnt; + int fd; + + *mount_flags = 0; + if ((f = setmntent (MOUNTED, "r")) == NULL) + return errno; + while ((mnt = getmntent (f)) != NULL) + if (strcmp(file, mnt->mnt_fsname) == 0) + break; + endmntent (f); + if (mnt == 0) + return 0; + *mount_flags = EXT2_MF_MOUNTED; + + if (!strcmp(mnt->mnt_dir, "/")) { + *mount_flags |= EXT2_MF_ISROOT; + fd = open(MOUNTED, O_RDWR); + if (fd < 0) { + if (errno == EROFS) + *mount_flags |= EXT2_MF_READONLY; + } else + close(fd); + } + return 0; +} +#endif + +#ifdef HAVE_GETMNTINFO +static errcode_t check_getmntinfo(const char *file, int *mount_flags) +{ + struct statfs *mp; + int len, n; + const char *s1; + char *s2; + + n = getmntinfo(&mp, MNT_NOWAIT); + if (n == 0) + return errno; + + len = sizeof(_PATH_DEV) - 1; + s1 = file; + if (strncmp(_PATH_DEV, s1, len) == 0) + s1 += len; + + *mount_flags = 0; + while (--n >= 0) { + s2 = mp->f_mntfromname; + if (strncmp(_PATH_DEV, s2, len) == 0) { + s2 += len - 1; + *s2 = 'r'; + } + if (strcmp(s1, s2) == 0 || strcmp(s1, &s2[1]) == 0) { + *mount_flags = EXT2_MF_MOUNTED; + break; + } + ++mp; + } + return 0; +} +#endif /* HAVE_GETMNTINFO */ + +/* + * Is_mounted is set to 1 if the device is mounted, 0 otherwise + */ +errcode_t ext2fs_check_if_mounted(const char *file, int *mount_flags) +{ +#ifdef HAVE_MNTENT_H + return check_mntent(file, mount_flags); +#else +#ifdef HAVE_GETMNTINFO + return check_getmntinfo(file, mount_flags); +#else + *mount_flags = 0; + return 0; +#endif /* HAVE_GETMNTINFO */ +#endif /* HAVE_MNTENT_H */ +} diff --git a/lib/ext2fs/jump/jump.undefs b/lib/ext2fs/jump/jump.undefs deleted file mode 100644 index 94699926..00000000 --- a/lib/ext2fs/jump/jump.undefs +++ /dev/null @@ -1,2 +0,0 @@ -66909078 D __NEEDS_SHRLIB_libc_4 -6690908c D __NEEDS_SHRLIB_libet_1 diff --git a/lib/ext2fs/llseek.c b/lib/ext2fs/llseek.c index 00fe3cdc..02e0ede8 100644 --- a/lib/ext2fs/llseek.c +++ b/lib/ext2fs/llseek.c @@ -9,12 +9,25 @@ #include <errno.h> #include <unistd.h> -#include <linux/unistd.h> #include "et/com_err.h" #include "ext2fs/io.h" #ifdef __linux__ +#ifdef HAVE_LLSEEK +#include <unistd.h> +#include <syscall.h> + +#else /* HAVE_LLSEEK */ + +#ifdef __alpha__ + +#define llseek lseek + +#else /* !__alpha__ */ + +#include <linux/unistd.h> + #ifndef __NR__llseek #define __NR__llseek 140 #endif @@ -26,54 +39,62 @@ static _syscall5(int,_llseek,unsigned int,fd,unsigned long,offset_high, unsigned long, offset_low,ext2_loff_t *,result, unsigned int, origin) +static ext2_loff_t llseek (unsigned int fd, ext2_loff_t offset, + unsigned int origin) +{ + ext2_loff_t result; + int retval; + + retval = _llseek (fd, ((unsigned long long) offset) >> 32, + ((unsigned long long) offset) & 0xffffffff, + &result, origin); + return (retval == -1 ? (ext2_loff_t) retval : result); +} + +#endif /* HAVE_LLSEEK */ + +#endif /* __alpha__ */ + 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 ((sizeof(off_t) >= sizeof(ext2_loff_t)) || + (offset < ((ext2_loff_t) 1 << ((sizeof(off_t)*8) -1)))) + return lseek(fd, (off_t) offset, origin); + 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); + errno = EINVAL; + return -1; } - 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) { + result = llseek (fd, offset, origin); + if (result == -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; + errno = EINVAL; } - if (retval == -1) - result = -1; return result; } -#else +#else /* !linux */ 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; + errno = EINVAL; return -1; } return lseek (fd, (off_t) offset, origin); } -#endif +#endif /* linux */ diff --git a/lib/ext2fs/mkdir.c b/lib/ext2fs/mkdir.c index 8bcb5426..af3b9b7b 100644 --- a/lib/ext2fs/mkdir.c +++ b/lib/ext2fs/mkdir.c @@ -13,6 +13,9 @@ #include <time.h> #include <sys/stat.h> #include <sys/types.h> +#if HAVE_ERRNO_H +#include <errno.h> +#endif #include <linux/ext2_fs.h> @@ -35,7 +38,8 @@ errcode_t ext2fs_mkdir(ext2_filsys fs, ino_t parent, ino_t inum, * Allocate an inode, if necessary */ if (!ino) { - retval = ext2fs_new_inode(fs, parent, S_IFDIR | 0755, 0, &ino); + retval = ext2fs_new_inode(fs, parent, LINUX_S_IFDIR | 0755, + 0, &ino); if (retval) goto cleanup; } @@ -58,7 +62,7 @@ errcode_t ext2fs_mkdir(ext2_filsys fs, ino_t parent, ino_t inum, * Create the inode structure.... */ memset(&inode, 0, sizeof(struct ext2_inode)); - inode.i_mode = S_IFDIR | 0755; + inode.i_mode = LINUX_S_IFDIR | 0755; inode.i_uid = inode.i_gid = 0; inode.i_blocks = fs->blocksize / 512; inode.i_block[0] = blk; @@ -69,7 +73,7 @@ errcode_t ext2fs_mkdir(ext2_filsys fs, ino_t parent, ino_t inum, /* * Write out the inode and inode data block */ - retval = io_channel_write_blk(fs->io, blk, 1, block); + retval = ext2fs_write_dir_block(fs, blk, block); if (retval) goto cleanup; retval = ext2fs_write_inode(fs, ino, &inode); diff --git a/lib/ext2fs/namei.c b/lib/ext2fs/namei.c index da382f71..496c7266 100644 --- a/lib/ext2fs/namei.c +++ b/lib/ext2fs/namei.c @@ -9,6 +9,9 @@ #include <string.h> #include <unistd.h> #include <stdlib.h> +#if HAVE_ERRNO_H +#include <errno.h> +#endif #include <linux/ext2_fs.h> @@ -87,7 +90,7 @@ static int process_dir_block(ext2_filsys fs, if (blockcnt < 0) return 0; - ctx->errcode = io_channel_read_blk(fs->io, *blocknr, 1, ctx->buf); + ctx->errcode = ext2fs_read_dir_block(fs, *blocknr, ctx->buf); if (ctx->errcode) return BLOCK_ABORT; @@ -116,8 +119,7 @@ next: } if (changed) { - ctx->errcode = io_channel_write_blk(fs->io, *blocknr, 1, - ctx->buf); + ctx->errcode = ext2fs_write_dir_block(fs, *blocknr, ctx->buf); if (ctx->errcode) return BLOCK_ABORT; } diff --git a/lib/ext2fs/newdir.c b/lib/ext2fs/newdir.c index d1018c17..22547266 100644 --- a/lib/ext2fs/newdir.c +++ b/lib/ext2fs/newdir.c @@ -9,6 +9,9 @@ #include <string.h> #include <unistd.h> #include <stdlib.h> +#if HAVE_ERRNO_H +#include <errno.h> +#endif #include <linux/ext2_fs.h> diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c index d6f5432d..b674ace0 100644 --- a/lib/ext2fs/openfs.c +++ b/lib/ext2fs/openfs.c @@ -1,16 +1,25 @@ /* * openfs.c --- open an ext2 filesystem * - * Copyright (C) 1993, 1994 Theodore Ts'o. This file may be redistributed - * under the terms of the GNU Public License. + * Copyright (C) 1993, 1994, 1995 Theodore Ts'o. + * + * This file may be redistributed under the terms of the GNU Public + * License. */ #include <stdio.h> #include <string.h> +#if HAVE_UNISTD_H #include <unistd.h> +#endif +#if HAVE_STDLIB_H #include <stdlib.h> +#endif #include <fcntl.h> #include <time.h> +#if HAVE_ERRNO_H +#include <errno.h> +#endif #include <sys/stat.h> #include <sys/types.h> @@ -27,8 +36,9 @@ errcode_t ext2fs_open(const char *name, int flags, int superblock, { ext2_filsys fs; errcode_t retval; - int i, group_block; + int i, j, group_block, groups_per_block; char *dest; + struct ext2_group_desc *gdp; EXT2_CHECK_MAGIC(manager, EXT2_ET_MAGIC_IO_MANAGER); @@ -77,6 +87,13 @@ errcode_t ext2fs_open(const char *name, int flags, int superblock, fs->super); if (retval) goto cleanup; + + if ((fs->super->s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC)) || + (fs->flags & EXT2_SWAP_BYTES)) { + fs->flags |= EXT2_SWAP_BYTES; + + ext2fs_swap_super(fs->super); + } if (fs->super->s_magic != EXT2_SUPER_MAGIC) { retval = EXT2_ET_BAD_MAGIC; @@ -126,6 +143,13 @@ errcode_t ext2fs_open(const char *name, int flags, int superblock, if (retval) goto cleanup; group_block++; + if (fs->flags & EXT2_SWAP_BYTES) { + gdp = (struct ext2_group_desc *) dest; + groups_per_block = fs->blocksize / + sizeof(struct ext2_group_desc); + for (j=0; j < groups_per_block; j++) + ext2fs_swap_group_desc(gdp++); + } dest += fs->blocksize; } diff --git a/lib/ext2fs/read_bb_file.c b/lib/ext2fs/read_bb_file.c index c24674ba..04e15819 100644 --- a/lib/ext2fs/read_bb_file.c +++ b/lib/ext2fs/read_bb_file.c @@ -41,7 +41,7 @@ errcode_t ext2fs_read_bb_FILE(ext2_filsys fs, FILE *f, while (!feof (f)) { if (fgets(buf, sizeof(buf), f) == NULL) break; - count = sscanf(buf, "%lu", &blockno); + count = sscanf(buf, "%u", &blockno); if (count <= 0) continue; if ((blockno < fs->super->s_first_data_block) || diff --git a/lib/ext2fs/rw_bitmaps.c b/lib/ext2fs/rw_bitmaps.c index 95232940..18b0d3e5 100644 --- a/lib/ext2fs/rw_bitmaps.c +++ b/lib/ext2fs/rw_bitmaps.c @@ -13,6 +13,9 @@ #include <time.h> #include <sys/stat.h> #include <sys/types.h> +#if HAVE_ERRNO_H +#include <errno.h> +#endif #include <linux/ext2_fs.h> @@ -100,7 +103,7 @@ errcode_t ext2fs_write_block_bitmap (ext2_filsys fs) static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) { int i; - char *block_bitmap, *inode_bitmap; + char *block_bitmap = 0, *inode_bitmap = 0; char *buf; errcode_t retval; int block_nbytes = EXT2_BLOCKS_PER_GROUP(fs->super) / 8; @@ -130,39 +133,31 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) 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) { + if (block_bitmap) { retval = io_channel_read_blk (fs->io, fs->group_desc[i].bg_block_bitmap, - 1, buf); + -block_nbytes, block_bitmap); if (retval) { retval = EXT2_ET_BLOCK_BITMAP_READ; goto cleanup; } - memcpy(block_bitmap, buf, block_nbytes); block_bitmap += block_nbytes; } - if (do_inode) { + if (inode_bitmap) { retval = io_channel_read_blk (fs->io, fs->group_desc[i].bg_inode_bitmap, - 1, buf); + -inode_nbytes, inode_bitmap); 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: diff --git a/lib/ext2fs/rw_bitmaps.size b/lib/ext2fs/rw_bitmaps.size deleted file mode 100644 index 5a3c9449..00000000 --- a/lib/ext2fs/rw_bitmaps.size +++ /dev/null @@ -1,2 +0,0 @@ -text data bss dec hex -1720 0 0 1720 6b8 diff --git a/lib/ext2fs/swapfs.c b/lib/ext2fs/swapfs.c new file mode 100644 index 00000000..371b8f9d --- /dev/null +++ b/lib/ext2fs/swapfs.c @@ -0,0 +1,58 @@ +/* + * swapfs.c --- swap ext2 filesystem data structures + * + * Copyright (C) 1995 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 <time.h> + +#include <linux/ext2_fs.h> + +#include "ext2fs.h" + +void ext2fs_swap_super(struct ext2_super_block * super) +{ + super->s_inodes_count = ext2fs_swab32(super->s_inodes_count); + super->s_blocks_count = ext2fs_swab32(super->s_blocks_count); + super->s_r_blocks_count = ext2fs_swab32(super->s_r_blocks_count); + super->s_free_blocks_count = ext2fs_swab32(super->s_free_blocks_count); + super->s_free_inodes_count = ext2fs_swab32(super->s_free_inodes_count); + super->s_first_data_block = ext2fs_swab32(super->s_first_data_block); + super->s_log_block_size = ext2fs_swab32(super->s_log_block_size); + super->s_log_frag_size = ext2fs_swab32(super->s_log_frag_size); + super->s_blocks_per_group = ext2fs_swab32(super->s_blocks_per_group); + super->s_frags_per_group = ext2fs_swab32(super->s_frags_per_group); + super->s_inodes_per_group = ext2fs_swab32(super->s_inodes_per_group); + super->s_mtime = ext2fs_swab32(super->s_mtime); + super->s_wtime = ext2fs_swab32(super->s_wtime); + super->s_mnt_count = ext2fs_swab16(super->s_mnt_count); + super->s_max_mnt_count = ext2fs_swab16(super->s_max_mnt_count); + super->s_magic = ext2fs_swab16(super->s_magic); + super->s_state = ext2fs_swab16(super->s_state); + super->s_errors = ext2fs_swab16(super->s_errors); + super->s_lastcheck = ext2fs_swab32(super->s_lastcheck); + super->s_checkinterval = ext2fs_swab32(super->s_checkinterval); + super->s_creator_os = ext2fs_swab32(super->s_creator_os); + super->s_rev_level = ext2fs_swab32(super->s_rev_level); +#ifdef EXT2_DEF_RESUID + super->s_def_resuid = ext2fs_swab16(super->s_def_resuid); + super->s_def_resgid = ext2fs_swab16(super->s_def_resgid); +#endif +} + +void ext2fs_swap_group_desc(struct ext2_group_desc *gdp) +{ + gdp->bg_block_bitmap = ext2fs_swab32(gdp->bg_block_bitmap); + gdp->bg_inode_bitmap = ext2fs_swab32(gdp->bg_inode_bitmap); + gdp->bg_inode_table = ext2fs_swab32(gdp->bg_inode_table); + gdp->bg_free_blocks_count = ext2fs_swab16(gdp->bg_free_blocks_count); + gdp->bg_free_inodes_count = ext2fs_swab16(gdp->bg_free_inodes_count); + gdp->bg_used_dirs_count = ext2fs_swab16(gdp->bg_used_dirs_count); +} + + + diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c index 5126583e..b9955150 100644 --- a/lib/ext2fs/unix_io.c +++ b/lib/ext2fs/unix_io.c @@ -15,9 +15,12 @@ #include <time.h> #include <sys/stat.h> #include <sys/types.h> +#if HAVE_ERRNO_H +#include <errno.h> +#endif #include "et/com_err.h" -#include "ext2_err.h" +#include "ext2fs/ext2_err.h" #include "io.h" /* @@ -63,6 +66,8 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel) struct unix_private_data *data = NULL; errcode_t retval; + if (name == 0) + return EXT2_ET_BAD_DEVICE_NAME; io = (io_channel) malloc(sizeof(struct struct_io_channel)); if (!io) return ENOMEM; |