aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJP Abgrall <jpa@google.com>2014-03-06 13:50:20 -0800
committerJP Abgrall <jpa@google.com>2014-03-06 13:50:20 -0800
commit65f0aab98b20b5994a726ab90d355248bcddfffd (patch)
tree2b7c0cf831d8255e3b0d1bab367609100a7e0f18 /lib
parent66b7b06812cc7ae835e0c0ed2656d1a27580c5ed (diff)
downloadandroid_external_e2fsprogs-65f0aab98b20b5994a726ab90d355248bcddfffd.tar.gz
android_external_e2fsprogs-65f0aab98b20b5994a726ab90d355248bcddfffd.tar.bz2
android_external_e2fsprogs-65f0aab98b20b5994a726ab90d355248bcddfffd.zip
Revert changes that moved from 1.41.14 to 1.42.9
Revert "e2fsck: Don't use e2fsck_global_ctx unless HAVE_SIGNAL_H" commit e80e74c41d85ff93f3d212ba6512340f48054a93. Revert "Merge remote-tracking branch 'linaro/linaro-1.42.9' into aosp_master" This reverts commit e97b2b6fc82f840e84dfc631b87f21be44ff2421, reversing changes made to 7e2fb9d09c245eba70ee008b78007315e9c0f1df. Revert "Prepare for upstream 1.42.9" This reverts commit 7e2fb9d09c245eba70ee008b78007315e9c0f1df. Bug: 13340735 Change-Id: If48b153a95ef5f69f7cdccb00e23524abff3c5a8 Signed-off-by: JP Abgrall <jpa@google.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.bsd-lib2
-rw-r--r--lib/Makefile.elf-lib16
-rw-r--r--lib/Makefile.solaris-lib3
-rw-r--r--lib/blkid/Android.mk4
-rw-r--r--lib/blkid/MODULE_LICENSE_LGPL0
-rw-r--r--lib/blkid/Makefile.in40
-rw-r--r--lib/blkid/blkid.pc.in2
-rw-r--r--lib/blkid/blkid_types.h24
-rw-r--r--lib/blkid/blkid_types.h.in16
-rw-r--r--lib/blkid/cache.c7
-rw-r--r--lib/blkid/getsize.c116
-rw-r--r--lib/blkid/list.h5
-rw-r--r--lib/blkid/probe.c23
-rw-r--r--lib/blkid/probe.h1
-rw-r--r--lib/config.h.in623
-rw-r--r--lib/dirpaths.h.in10
-rw-r--r--lib/e2p/MODULE_LICENSE_LGPL0
-rw-r--r--lib/e2p/Makefile.in71
-rw-r--r--lib/e2p/e2p.h1
-rw-r--r--lib/e2p/e2p.pc.in2
-rw-r--r--lib/e2p/feature.c25
-rw-r--r--lib/e2p/fgetflags.c8
-rw-r--r--lib/e2p/fsetflags.c15
-rw-r--r--lib/e2p/getflags.c5
-rw-r--r--lib/e2p/getversion.c2
-rw-r--r--lib/e2p/ls.c65
-rw-r--r--lib/e2p/mntopts.c3
-rw-r--r--lib/e2p/parse_num.c34
-rw-r--r--lib/e2p/pf.c1
-rw-r--r--lib/e2p/setflags.c12
-rw-r--r--lib/et/MODULE_LICENSE_MIT0
-rw-r--r--lib/et/Makefile.in56
-rw-r--r--lib/et/com_err.c5
-rw-r--r--lib/et/com_err.h2
-rw-r--r--lib/et/com_err.pc.in2
-rw-r--r--lib/et/com_err.texinfo43
-rw-r--r--lib/et/error_message.c31
-rw-r--r--lib/et/error_table.h2
-rw-r--r--lib/et/et_c.awk10
-rw-r--r--lib/et/et_name.c3
-rw-r--r--lib/et/test_cases/continuation.c4
-rw-r--r--lib/et/test_cases/heimdal.c166
-rw-r--r--lib/et/test_cases/heimdal2.c138
-rw-r--r--lib/et/test_cases/heimdal3.c6
-rw-r--r--lib/et/test_cases/imap_err.c62
-rw-r--r--lib/et/test_cases/simple.c46
-rw-r--r--lib/et/texinfo.tex8217
-rw-r--r--lib/ext2fs/Android.mk9
-rw-r--r--lib/ext2fs/MODULE_LICENSE_LGPL0
-rw-r--r--lib/ext2fs/Makefile.in456
-rw-r--r--lib/ext2fs/Makefile.pq49
-rw-r--r--lib/ext2fs/alloc.c168
-rw-r--r--lib/ext2fs/alloc_sb.c32
-rw-r--r--lib/ext2fs/alloc_stats.c38
-rw-r--r--lib/ext2fs/alloc_tables.c172
-rw-r--r--lib/ext2fs/badblocks.c2
-rw-r--r--lib/ext2fs/bb_inode.c13
-rw-r--r--lib/ext2fs/bitmaps.c176
-rw-r--r--lib/ext2fs/bitops.c79
-rw-r--r--lib/ext2fs/bitops.h362
-rw-r--r--lib/ext2fs/blkmap64_ba.c416
-rw-r--r--lib/ext2fs/blkmap64_rb.c886
-rw-r--r--lib/ext2fs/blknum.c494
-rw-r--r--lib/ext2fs/block.c178
-rw-r--r--lib/ext2fs/bmap.c224
-rw-r--r--lib/ext2fs/bmap64.h100
-rw-r--r--lib/ext2fs/bmove.c36
-rw-r--r--lib/ext2fs/brel.h18
-rw-r--r--lib/ext2fs/brel_ma.c24
-rw-r--r--lib/ext2fs/check_desc.c37
-rw-r--r--lib/ext2fs/closefs.c198
-rw-r--r--lib/ext2fs/crc32c.c1143
-rw-r--r--lib/ext2fs/crc32c_defs.h51
-rw-r--r--lib/ext2fs/csum.c155
-rw-r--r--lib/ext2fs/dblist.c217
-rw-r--r--lib/ext2fs/dblist_dir.c6
-rw-r--r--lib/ext2fs/dir_iterate.c31
-rw-r--r--lib/ext2fs/dirblock.c25
-rw-r--r--lib/ext2fs/dirhash.c3
-rw-r--r--lib/ext2fs/dupfs.c25
-rw-r--r--lib/ext2fs/e2image.h14
-rw-r--r--lib/ext2fs/expanddir.c36
-rw-r--r--lib/ext2fs/ext2_err.c297
-rw-r--r--lib/ext2fs/ext2_err.et.in79
-rw-r--r--lib/ext2fs/ext2_err.h27
-rw-r--r--lib/ext2fs/ext2_fs.h167
-rw-r--r--lib/ext2fs/ext2_io.h16
-rw-r--r--lib/ext2fs/ext2_types.h24
-rw-r--r--lib/ext2fs/ext2_types.h.in16
-rw-r--r--lib/ext2fs/ext2fs.h468
-rw-r--r--lib/ext2fs/ext2fs.pc.in2
-rw-r--r--lib/ext2fs/ext2fsP.h71
-rw-r--r--lib/ext2fs/ext_attr.c40
-rw-r--r--lib/ext2fs/extent.c536
-rw-r--r--lib/ext2fs/extent_dbg.ct74
-rw-r--r--lib/ext2fs/fiemap.h4
-rw-r--r--lib/ext2fs/fileio.c160
-rw-r--r--lib/ext2fs/finddev.c5
-rw-r--r--lib/ext2fs/flushb.c14
-rw-r--r--lib/ext2fs/freefs.c7
-rw-r--r--lib/ext2fs/gen_bitmap.c112
-rw-r--r--lib/ext2fs/gen_bitmap64.c849
-rw-r--r--lib/ext2fs/gen_crc32ctable.c123
-rw-r--r--lib/ext2fs/get_pathname.c21
-rw-r--r--lib/ext2fs/getsectsize.c38
-rw-r--r--lib/ext2fs/getsize.c139
-rw-r--r--lib/ext2fs/i_block.c20
-rw-r--r--lib/ext2fs/icount.c89
-rw-r--r--lib/ext2fs/imager.c35
-rw-r--r--lib/ext2fs/initialize.c187
-rw-r--r--lib/ext2fs/inline.c88
-rw-r--r--lib/ext2fs/inode.c60
-rw-r--r--lib/ext2fs/inode_io.c5
-rw-r--r--lib/ext2fs/io_manager.c28
-rw-r--r--lib/ext2fs/irel.h2
-rw-r--r--lib/ext2fs/ismounted.c83
-rw-r--r--lib/ext2fs/kernel-jbd.h9
-rw-r--r--lib/ext2fs/kernel-list.h3
-rw-r--r--lib/ext2fs/link.c7
-rw-r--r--lib/ext2fs/llseek.c18
-rw-r--r--lib/ext2fs/mkdir.c22
-rw-r--r--lib/ext2fs/mkjournal.c187
-rw-r--r--lib/ext2fs/mmp.c397
-rw-r--r--lib/ext2fs/namei.c13
-rw-r--r--lib/ext2fs/newdir.c8
-rw-r--r--lib/ext2fs/nt_io.c1
-rw-r--r--lib/ext2fs/openfs.c139
-rw-r--r--lib/ext2fs/progress.c96
-rw-r--r--lib/ext2fs/punch.c447
-rw-r--r--lib/ext2fs/qcow2.c255
-rw-r--r--lib/ext2fs/qcow2.h113
-rw-r--r--lib/ext2fs/rbtree.c451
-rw-r--r--lib/ext2fs/rbtree.h180
-rw-r--r--lib/ext2fs/read_bb.c2
-rw-r--r--lib/ext2fs/read_bb_file.c9
-rw-r--r--lib/ext2fs/res_gdt.c18
-rw-r--r--lib/ext2fs/rw_bitmaps.c127
-rw-r--r--lib/ext2fs/sparse.c78
-rw-r--r--lib/ext2fs/swapfs.c91
-rw-r--r--lib/ext2fs/symlink.c150
-rw-r--r--lib/ext2fs/tdb.c20
-rw-r--r--lib/ext2fs/tdb.h2
-rw-r--r--lib/ext2fs/test_io.c47
-rw-r--r--lib/ext2fs/tst_badblocks.c2
-rw-r--r--lib/ext2fs/tst_bitmaps.c652
-rw-r--r--lib/ext2fs/tst_bitmaps_cmd.ct45
-rw-r--r--lib/ext2fs/tst_bitmaps_cmds99
-rw-r--r--lib/ext2fs/tst_bitmaps_exp211
-rw-r--r--lib/ext2fs/tst_bitops.c120
-rw-r--r--lib/ext2fs/tst_fs_struct.c81
-rw-r--r--lib/ext2fs/tst_inode_size.c87
-rw-r--r--lib/ext2fs/tst_iscan.c48
-rw-r--r--lib/ext2fs/tst_super_size.c208
-rw-r--r--lib/ext2fs/undo_io.c64
-rw-r--r--lib/ext2fs/unix_io.c198
-rw-r--r--lib/ext2fs/valid_blk.c9
-rw-r--r--lib/quota/Android.mk61
-rw-r--r--lib/quota/Makefile.in162
-rw-r--r--lib/quota/common.h28
-rw-r--r--lib/quota/dqblk_v2.h31
-rw-r--r--lib/quota/mkquota.c560
-rw-r--r--lib/quota/mkquota.h64
-rw-r--r--lib/quota/quota.pc.in11
-rw-r--r--lib/quota/quotaio.c381
-rw-r--r--lib/quota/quotaio.h165
-rw-r--r--lib/quota/quotaio_tree.c655
-rw-r--r--lib/quota/quotaio_tree.h64
-rw-r--r--lib/quota/quotaio_v2.c282
-rw-r--r--lib/quota/quotaio_v2.h54
-rw-r--r--lib/ss/MODULE_LICENSE_MIT0
-rw-r--r--lib/ss/Makefile.in53
-rw-r--r--lib/ss/error.c10
-rw-r--r--lib/ss/execute_cmd.c20
-rw-r--r--lib/ss/help.c19
-rw-r--r--lib/ss/invocation.c17
-rw-r--r--lib/ss/list_rqs.c5
-rw-r--r--lib/ss/pager.c10
-rw-r--r--lib/ss/parse.c9
-rw-r--r--lib/ss/request_tbl.c13
-rw-r--r--lib/ss/ss.h1
-rw-r--r--lib/ss/ss.pc.in2
-rw-r--r--lib/ss/ss_internal.h1
-rw-r--r--lib/uuid/MODULE_LICENSE_BSD_LIKE0
-rw-r--r--lib/uuid/Makefile.in37
-rw-r--r--lib/uuid/gen_uuid.c25
-rw-r--r--lib/uuid/tst_uuid.c29
-rw-r--r--lib/uuid/uuid.pc.in2
-rw-r--r--lib/uuid/uuid_time.c2
188 files changed, 4489 insertions, 22686 deletions
diff --git a/lib/Makefile.bsd-lib b/lib/Makefile.bsd-lib
index 0ca09f8c..51e9dc77 100644
--- a/lib/Makefile.bsd-lib
+++ b/lib/Makefile.bsd-lib
@@ -22,7 +22,7 @@ BSDLIB_PIC_FLAG = -fpic
image: $(BSD_LIB)
$(BSD_LIB): $(OBJS)
- (cd pic; ld -Bshareable -o $(BSD_LIB) $(LDFLAGS) $(OBJS))
+ (cd pic; ld -Bshareable -o $(BSD_LIB) $(OBJS))
$(MV) pic/$(BSD_LIB) .
$(RM) -f ../$(BSD_LIB)
(cd ..; $(LN) $(LINK_BUILD_FLAGS) \
diff --git a/lib/Makefile.elf-lib b/lib/Makefile.elf-lib
index 78479d31..ea600c7a 100644
--- a/lib/Makefile.elf-lib
+++ b/lib/Makefile.elf-lib
@@ -24,8 +24,7 @@ image: $(ELF_LIB)
$(ELF_LIB): $(OBJS)
$(E) " GEN_ELF_SOLIB $(ELF_LIB)"
- $(Q) (cd elfshared; $(CC) --shared -o $(ELF_LIB) \
- -L$(top_builddir)/../lib $(LDFLAGS) \
+ $(Q) (cd elfshared; $(CC) --shared -o $(ELF_LIB) $(LDFLAGS) \
-Wl,-soname,$(ELF_SONAME) $(OBJS) $(ELF_OTHER_LIBS))
$(Q) $(MV) elfshared/$(ELF_LIB) .
$(Q) $(RM) -f ../$(ELF_LIB) ../$(ELF_IMAGE).so ../$(ELF_SONAME)
@@ -41,15 +40,18 @@ installdirs-elf-lib::
installdirs:: installdirs-elf-lib
-install-shlibs install:: $(ELF_LIB) installdirs-elf-lib $(DEP_INSTALL_SYMLINK)
+install-shlibs install:: $(ELF_LIB) installdirs-elf-lib
$(E) " INSTALL-ELF-LIB $(ELF_INSTALL_DIR)/$(ELF_LIB)"
$(Q) $(INSTALL_PROGRAM) $(ELF_LIB) $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_LIB)
$(E) " SYMLINK $(ELF_INSTALL_DIR)/$(ELF_SONAME)"
- $(Q) $(INSTALL_SYMLINK) $(ELF_INSTALL_DIR)/$(ELF_LIB) \
- $(ELF_INSTALL_DIR)/$(ELF_SONAME) $(DESTDIR)
+ $(Q) $(LN_S) -f $(ELF_LIB) $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_SONAME)
$(E) " SYMLINK $(libdir)/$(ELF_IMAGE).so"
- $(Q) $(INSTALL_SYMLINK) $(ELF_INSTALL_DIR)/$(ELF_SONAME) \
- $(libdir)/$(ELF_IMAGE).so $(DESTDIR)
+ $(Q) if test "$(ELF_INSTALL_DIR)" = "$(libdir)"; then \
+ $(LN_S) -f $(ELF_SONAME) $(DESTDIR)$(libdir)/$(ELF_IMAGE).so ; \
+ else \
+ $(LN_S) -f $(ELF_INSTALL_DIR)/$(ELF_SONAME) \
+ $(DESTDIR)$(libdir)/$(ELF_IMAGE).so; \
+ fi
$(E) " LDCONFIG"
$(Q) -$(LDCONFIG)
diff --git a/lib/Makefile.solaris-lib b/lib/Makefile.solaris-lib
index 5990be8a..92bdbe28 100644
--- a/lib/Makefile.solaris-lib
+++ b/lib/Makefile.solaris-lib
@@ -24,8 +24,7 @@ image: $(ELF_LIB)
$(ELF_LIB): $(OBJS)
$(E) " GEN_ELF_SOLIB $(ELF_LIB)"
- $(Q) (cd elfshared; $(CC) --shared -o $(ELF_LIB) \
- -L$(top_builddir)/../lib $(LDFLAGS) \
+ $(Q) (cd elfshared; $(CC) --shared -o $(ELF_LIB) $(LDFLAGS) \
-Wl,-h,$(ELF_SONAME) $(OBJS) $(ELF_OTHER_LIBS))
$(Q) $(MV) elfshared/$(ELF_LIB) .
$(Q) $(RM) -f ../$(ELF_LIB) ../$(ELF_IMAGE).so ../$(ELF_SONAME)
diff --git a/lib/blkid/Android.mk b/lib/blkid/Android.mk
index 92ef7764..e0494e32 100644
--- a/lib/blkid/Android.mk
+++ b/lib/blkid/Android.mk
@@ -21,7 +21,7 @@ libext2_blkid_system_shared_libraries := libc
libext2_blkid_c_includes := external/e2fsprogs/lib
-libext2_blkid_cflags := -O2 -g -W -Wall -fno-strict-aliasing \
+libext2_blkid_cflags := -O2 -g -W -Wall \
-DHAVE_UNISTD_H \
-DHAVE_ERRNO_H \
-DHAVE_NETINET_IN_H \
@@ -55,7 +55,7 @@ LOCAL_SRC_FILES := $(libext2_blkid_src_files)
LOCAL_SYSTEM_SHARED_LIBRARIES := $(libext2_blkid_system_shared_libraries)
LOCAL_SHARED_LIBRARIES := $(libext2_blkid_shared_libraries)
LOCAL_C_INCLUDES := $(libext2_blkid_c_includes)
-LOCAL_CFLAGS := $(libext2_blkid_cflags) $(libext2_blkid_cflags_linux) -fno-strict-aliasing
+LOCAL_CFLAGS := $(libext2_blkid_cflags) $(libext2_blkid_cflags_linux)
LOCAL_PRELINK_MODULE := false
LOCAL_MODULE := libext2_blkid
LOCAL_MODULE_TAGS := optional
diff --git a/lib/blkid/MODULE_LICENSE_LGPL b/lib/blkid/MODULE_LICENSE_LGPL
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/lib/blkid/MODULE_LICENSE_LGPL
diff --git a/lib/blkid/Makefile.in b/lib/blkid/Makefile.in
index 3f15c677..e89318e1 100644
--- a/lib/blkid/Makefile.in
+++ b/lib/blkid/Makefile.in
@@ -36,7 +36,7 @@ ELF_SO_VERSION = 1
ELF_IMAGE = libblkid
ELF_MYDIR = blkid
ELF_INSTALL_DIR = $(root_libdir)
-ELF_OTHER_LIBS = -luuid
+ELF_OTHER_LIBS = -L../.. -luuid
BSDLIB_VERSION = 2.0
BSDLIB_IMAGE = libblkid
@@ -55,7 +55,6 @@ DEPLIBS_BLKID= $(DEPSTATIC_LIBBLKID) $(DEPSTATIC_LIBUUID)
.c.o:
$(E) " CC $<"
$(Q) $(CC) $(ALL_CFLAGS) -c $< -o $@
- $(Q) $(CHECK_CMD) $(ALL_CFLAGS) $<
@PROFILE_CMT@ $(Q) $(CC) $(ALL_CFLAGS) -g -pg -o profiled/$*.o -c $<
@CHECKER_CMT@ $(Q) $(CC) $(ALL_CFLAGS) -checker -g -o checker/$*.o -c $<
@ELF_CMT@ $(Q) $(CC) $(ALL_CFLAGS) -fPIC -o elfshared/$*.o -c $<
@@ -196,28 +195,15 @@ $(OBJS): subdirs $(HFILES_IN)
# Makefile dependencies follow. This must be the last section in
# the Makefile.in file
#
-cache.o: $(srcdir)/cache.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/blkidP.h $(srcdir)/list.h
-dev.o: $(srcdir)/dev.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/blkidP.h $(srcdir)/list.h
-devname.o: $(srcdir)/devname.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/blkidP.h $(srcdir)/list.h
-devno.o: $(srcdir)/devno.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/blkidP.h $(srcdir)/list.h
-getsize.o: $(srcdir)/getsize.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/blkidP.h $(srcdir)/list.h
-llseek.o: $(srcdir)/llseek.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/blkidP.h $(srcdir)/list.h
-probe.o: $(srcdir)/probe.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/blkidP.h $(srcdir)/list.h \
- $(srcdir)/probe.h
-read.o: $(srcdir)/read.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/blkidP.h $(srcdir)/list.h
-resolve.o: $(srcdir)/resolve.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/blkidP.h $(srcdir)/list.h
-save.o: $(srcdir)/save.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/blkidP.h $(srcdir)/list.h
-tag.o: $(srcdir)/tag.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/blkidP.h $(srcdir)/list.h
-version.o: $(srcdir)/version.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(top_srcdir)/version.h
+cache.o: $(srcdir)/cache.c $(srcdir)/list.h
+dev.o: $(srcdir)/dev.c $(srcdir)/list.h
+devname.o: $(srcdir)/devname.c $(srcdir)/list.h
+devno.o: $(srcdir)/devno.c $(srcdir)/list.h
+getsize.o: $(srcdir)/getsize.c $(srcdir)/list.h
+llseek.o: $(srcdir)/llseek.c $(srcdir)/list.h
+probe.o: $(srcdir)/probe.c $(srcdir)/list.h $(srcdir)/probe.h
+read.o: $(srcdir)/read.c $(srcdir)/list.h
+resolve.o: $(srcdir)/resolve.c $(srcdir)/list.h
+save.o: $(srcdir)/save.c $(srcdir)/list.h
+tag.o: $(srcdir)/tag.c $(srcdir)/list.h
+version.o: $(srcdir)/version.c $(top_srcdir)/version.h
diff --git a/lib/blkid/blkid.pc.in b/lib/blkid/blkid.pc.in
index 808fe229..b984f6d0 100644
--- a/lib/blkid/blkid.pc.in
+++ b/lib/blkid/blkid.pc.in
@@ -7,5 +7,5 @@ Name: blkid
Description: Block device id library
Version: @E2FSPROGS_VERSION@
Requires.private: uuid
-Cflags: -I${includedir}/blkid -I${includedir}
+Cflags: -I${includedir}/blkid
Libs: -L${libdir} -lblkid
diff --git a/lib/blkid/blkid_types.h b/lib/blkid/blkid_types.h
index 3ffaee54..3e287125 100644
--- a/lib/blkid/blkid_types.h
+++ b/lib/blkid/blkid_types.h
@@ -7,6 +7,14 @@
!defined(_EXT2_TYPES_H))
#define _BLKID_TYPES_H
+#define __S8_TYPEDEF __signed__ char
+#define __U8_TYPEDEF unsigned char
+#define __S16_TYPEDEF __signed__ short
+#define __U16_TYPEDEF unsigned short
+#define __S32_TYPEDEF __signed__ int
+#define __U32_TYPEDEF unsigned int
+#define __S64_TYPEDEF __signed__ long long
+#define __U64_TYPEDEF unsigned long long
#ifdef __U8_TYPEDEF
typedef __U8_TYPEDEF __u8;
@@ -91,13 +99,13 @@ typedef __U64_TYPEDEF __u64;
#if (4 == 8)
typedef unsigned int __u64;
#else
-#if (8 == 8)
-typedef unsigned long long __u64;
-#else
#if (4 == 8)
typedef unsigned long __u64;
-#endif /* SIZEOF_LONG == 8 */
+#else
+#if (8 == 8)
+typedef unsigned long long __u64;
#endif /* SIZEOF_LONG_LONG == 8 */
+#endif /* SIZEOF_LONG == 8 */
#endif /* SIZEOF_INT == 8 */
#endif /* __U64_TYPEDEF */
@@ -107,17 +115,17 @@ typedef __S64_TYPEDEF __s64;
#if (4 == 8)
typedef int __s64;
#else
+#if (4 == 8)
+typedef long __s64;
+#else
#if (8 == 8)
#if defined(__GNUC__)
typedef __signed__ long long __s64;
#else
typedef signed long long __s64;
#endif /* __GNUC__ */
-#else
-#if (4 == 8)
-typedef long __s64;
-#endif /* SIZEOF_LONG == 8 */
#endif /* SIZEOF_LONG_LONG == 8 */
+#endif /* SIZEOF_LONG == 8 */
#endif /* SIZEOF_INT == 8 */
#endif /* __S64_TYPEDEF */
diff --git a/lib/blkid/blkid_types.h.in b/lib/blkid/blkid_types.h.in
index 2edc0dad..cb5b10d5 100644
--- a/lib/blkid/blkid_types.h.in
+++ b/lib/blkid/blkid_types.h.in
@@ -92,13 +92,13 @@ typedef __U64_TYPEDEF __u64;
#if (@SIZEOF_INT@ == 8)
typedef unsigned int __u64;
#else
-#if (@SIZEOF_LONG_LONG@ == 8)
-typedef unsigned long long __u64;
-#else
#if (@SIZEOF_LONG@ == 8)
typedef unsigned long __u64;
-#endif /* SIZEOF_LONG == 8 */
+#else
+#if (@SIZEOF_LONG_LONG@ == 8)
+typedef unsigned long long __u64;
#endif /* SIZEOF_LONG_LONG == 8 */
+#endif /* SIZEOF_LONG == 8 */
#endif /* SIZEOF_INT == 8 */
#endif /* __U64_TYPEDEF */
@@ -108,17 +108,17 @@ typedef __S64_TYPEDEF __s64;
#if (@SIZEOF_INT@ == 8)
typedef int __s64;
#else
+#if (@SIZEOF_LONG@ == 8)
+typedef long __s64;
+#else
#if (@SIZEOF_LONG_LONG@ == 8)
#if defined(__GNUC__)
typedef __signed__ long long __s64;
#else
typedef signed long long __s64;
#endif /* __GNUC__ */
-#else
-#if (@SIZEOF_LONG@ == 8)
-typedef long __s64;
-#endif /* SIZEOF_LONG == 8 */
#endif /* SIZEOF_LONG_LONG == 8 */
+#endif /* SIZEOF_LONG == 8 */
#endif /* SIZEOF_INT == 8 */
#endif /* __S64_TYPEDEF */
diff --git a/lib/blkid/cache.c b/lib/blkid/cache.c
index e2ccafd2..2b818868 100644
--- a/lib/blkid/cache.c
+++ b/lib/blkid/cache.c
@@ -10,9 +10,6 @@
* %End-Header%
*/
-#if HAVE_SECURE_GETENV
-#define _GNU_SOURCE
-#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
@@ -51,9 +48,7 @@ static char *safe_getenv(const char *arg)
#endif
#endif
-#if defined(HAVE_SECURE_GETENV)
- return secure_getenv(arg);
-#elif defined(HAVE___SECURE_GETENV)
+#ifdef HAVE___SECURE_GETENV
return __secure_getenv(arg);
#else
return getenv(arg);
diff --git a/lib/blkid/getsize.c b/lib/blkid/getsize.c
index ac4177e2..10ba7ecf 100644
--- a/lib/blkid/getsize.c
+++ b/lib/blkid/getsize.c
@@ -74,46 +74,52 @@ static int valid_offset(int fd, blkid_loff_t offset)
*/
blkid_loff_t blkid_get_dev_size(int fd)
{
+ int valid_blkgetsize64 = 1;
+#ifdef __linux__
+ struct utsname ut;
+#endif
unsigned long long size64;
+ unsigned long size;
blkid_loff_t high, low;
+#ifdef FDGETPRM
+ struct floppy_struct this_floppy;
+#endif
+#ifdef HAVE_SYS_DISKLABEL_H
+ int part = -1;
+ struct disklabel lab;
+ struct partition *pp;
+ char ch;
+ struct stat st;
+#endif /* HAVE_SYS_DISKLABEL_H */
#ifdef DKIOCGETBLOCKCOUNT /* For Apple Darwin */
if (ioctl(fd, DKIOCGETBLOCKCOUNT, &size64) >= 0) {
- if (sizeof(blkid_loff_t) < sizeof(unsigned long long) &&
- (size64 << 9) > 0xFFFFFFFF)
+ if ((sizeof(blkid_loff_t) < sizeof(unsigned long long))
+ && (size64 << 9 > 0xFFFFFFFF))
return 0; /* EFBIG */
- return (blkid_loff_t)size64 << 9;
+ return (blkid_loff_t) size64 << 9;
}
#endif
#ifdef BLKGETSIZE64
- {
- int valid_blkgetsize64 = 1;
#ifdef __linux__
- struct utsname ut;
-
- if ((uname(&ut) == 0) &&
- ((ut.release[0] == '2') && (ut.release[1] == '.') &&
- (ut.release[2] < '6') && (ut.release[3] == '.')))
- valid_blkgetsize64 = 0;
-#endif
- if (valid_blkgetsize64 &&
- ioctl(fd, BLKGETSIZE64, &size64) >= 0) {
- if (sizeof(blkid_loff_t) < sizeof(unsigned long long) &&
- (size64 > 0xFFFFFFFF))
- return 0; /* EFBIG */
- return size64;
- }
+ if ((uname(&ut) == 0) &&
+ ((ut.release[0] == '2') && (ut.release[1] == '.') &&
+ (ut.release[2] < '6') && (ut.release[3] == '.')))
+ valid_blkgetsize64 = 0;
+#endif
+ if (valid_blkgetsize64 &&
+ ioctl(fd, BLKGETSIZE64, &size64) >= 0) {
+ if ((sizeof(blkid_loff_t) < sizeof(unsigned long long))
+ && ((size64) > 0xFFFFFFFF))
+ return 0; /* EFBIG */
+ return size64;
}
-#endif /* BLKGETSIZE64 */
+#endif
#ifdef BLKGETSIZE
- {
- unsigned long size;
-
- if (ioctl(fd, BLKGETSIZE, &size) >= 0)
- return (blkid_loff_t)size << 9;
- }
+ if (ioctl(fd, BLKGETSIZE, &size) >= 0)
+ return (blkid_loff_t)size << 9;
#endif
/* tested on FreeBSD 6.1-RELEASE i386 */
@@ -123,43 +129,29 @@ blkid_loff_t blkid_get_dev_size(int fd)
#endif /* DIOCGMEDIASIZE */
#ifdef FDGETPRM
- {
- struct floppy_struct this_floppy;
-
- if (ioctl(fd, FDGETPRM, &this_floppy) >= 0)
- return (blkid_loff_t)this_floppy.size << 9;
- }
+ if (ioctl(fd, FDGETPRM, &this_floppy) >= 0)
+ return (blkid_loff_t)this_floppy.size << 9;
#endif
#ifdef HAVE_SYS_DISKLABEL_H
- {
- int part = -1;
- struct disklabel lab;
- struct partition *pp;
- char ch;
- struct stat st;
-
- /*
- * This code works for FreeBSD 4.11 i386, except for the full
- * device (such as /dev/ad0). It doesn't work properly for
- * newer FreeBSD though. FreeBSD >= 5.0 should be covered by
- * the DIOCGMEDIASIZE above however.
- *
- * Note that FreeBSD >= 4.0 has disk devices as unbuffered (raw,
- * character) devices, so we need to check for S_ISCHR, too.
- */
- if (fstat(fd, &st) >= 0 &&
- (S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode)))
- part = st.st_rdev & 7;
-
- if (part >= 0 && (ioctl(fd, DIOCGDINFO, (char *)&lab) >= 0)) {
- pp = &lab.d_partitions[part];
- if (pp->p_size)
- return pp->p_size << 9;
- }
+ /*
+ * This code works for FreeBSD 4.11 i386, except for the full device
+ * (such as /dev/ad0). It doesn't work properly for newer FreeBSD
+ * though. FreeBSD >= 5.0 should be covered by the DIOCGMEDIASIZE
+ * above however.
+ *
+ * Note that FreeBSD >= 4.0 has disk devices as unbuffered (raw,
+ * character) devices, so we need to check for S_ISCHR, too.
+ */
+ if ((fstat(fd, &st) >= 0) && (S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode)))
+ part = st.st_rdev & 7;
+ if (part >= 0 && (ioctl(fd, DIOCGDINFO, (char *)&lab) >= 0)) {
+ pp = &lab.d_partitions[part];
+ if (pp->p_size)
+ return pp->p_size << 9;
}
#endif /* HAVE_SYS_DISKLABEL_H */
{
-#if defined(HAVE_FSTAT64) && !defined(__OSX_AVAILABLE_BUT_DEPRECATED)
+#ifdef HAVE_FSTAT64
struct stat64 st;
if (fstat64(fd, &st) == 0)
#else
@@ -170,6 +162,7 @@ blkid_loff_t blkid_get_dev_size(int fd)
return st.st_size;
}
+
/*
* OK, we couldn't figure it out by using a specialized ioctl,
* which is generally the best way. So do binary search to
@@ -178,7 +171,8 @@ blkid_loff_t blkid_get_dev_size(int fd)
low = 0;
for (high = 1024; valid_offset(fd, high); high *= 2)
low = high;
- while (low < high - 1) {
+ while (low < high - 1)
+ {
const blkid_loff_t mid = (low + high) / 2;
if (valid_offset(fd, mid))
@@ -205,8 +199,8 @@ int main(int argc, char **argv)
perror(argv[0]);
bytes = blkid_get_dev_size(fd);
- printf("Device %s has %lld 1k blocks.\n", argv[1],
- (unsigned long long)bytes >> 10);
+ printf("Device %s has %Ld 1k blocks.\n", argv[1],
+ (unsigned long long) bytes >> 10);
return 0;
}
diff --git a/lib/blkid/list.h b/lib/blkid/list.h
index 26a5ac1b..c1cbfec5 100644
--- a/lib/blkid/list.h
+++ b/lib/blkid/list.h
@@ -1,4 +1,4 @@
-#if !defined(_BLKID_LIST_H) && !defined(LIST_HEAD_INIT)
+#if !defined(_BLKID_LIST_H) && !defined(LIST_HEAD)
#define _BLKID_LIST_H
#ifdef __cplusplus
@@ -27,6 +27,9 @@ struct list_head {
#define LIST_HEAD_INIT(name) { &(name), &(name) }
+#define LIST_HEAD(name) \
+ struct list_head name = LIST_HEAD_INIT(name)
+
#define INIT_LIST_HEAD(ptr) do { \
(ptr)->next = (ptr); (ptr)->prev = (ptr); \
} while (0)
diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c
index 84649df2..6ff942d0 100644
--- a/lib/blkid/probe.c
+++ b/lib/blkid/probe.c
@@ -42,8 +42,10 @@ static int figure_label_len(const unsigned char *label, int len)
while ((*end == ' ' || *end == 0) && end >= label)
--end;
- if (end >= label)
+ if (end >= label) {
+ label = label;
return end - label + 1;
+ }
return 0;
}
@@ -246,7 +248,7 @@ static int linux_version_code()
{
#ifdef __linux__
struct utsname ut;
- static int version_code = -1;
+ static version_code = -1;
int major, minor, rev;
char *endptr;
const char *cp;
@@ -1160,8 +1162,7 @@ static int probe_hfs(struct blkid_probe *probe __BLKID_ATTR((unused)),
struct blkid_magic *id __BLKID_ATTR((unused)),
unsigned char *buf)
{
- struct hfs_mdb *hfs = (struct hfs_mdb *)buf;
- unsigned long long *uuid_ptr;
+ struct hfs_mdb *hfs = (struct hfs_mdb *) buf;
char uuid_str[17];
__u64 uuid;
@@ -1169,13 +1170,12 @@ static int probe_hfs(struct blkid_probe *probe __BLKID_ATTR((unused)),
(memcmp(hfs->embed_sig, "HX", 2) == 0))
return 1; /* Not hfs, but an embedded HFS+ */
- uuid_ptr = (unsigned long long *)hfs->finder_info.id;
- uuid = blkid_le64(*uuid_ptr);
+ uuid = blkid_le64(*((unsigned long long *) hfs->finder_info.id));
if (uuid) {
sprintf(uuid_str, "%016llX", uuid);
blkid_set_tag(probe->dev, "UUID", uuid_str, 0);
}
- blkid_set_tag(probe->dev, "LABEL", (char *)hfs->label, hfs->label_len);
+ blkid_set_tag(probe->dev, "LABEL", hfs->label, hfs->label_len);
return 0;
}
@@ -1204,10 +1204,9 @@ static int probe_hfsplus(struct blkid_probe *probe,
unsigned int leaf_node_size;
unsigned int leaf_block;
unsigned int label_len;
- unsigned long long *uuid_ptr;
+ int ext;
__u64 leaf_off, uuid;
char uuid_str[17], label[512];
- int ext;
/* Check for a HFS+ volume embedded in a HFS volume */
if (memcmp(sbd->signature, "BD", 2) == 0) {
@@ -1235,8 +1234,7 @@ static int probe_hfsplus(struct blkid_probe *probe,
(memcmp(hfsplus->signature, "HX", 2) != 0))
return 1;
- uuid_ptr = (unsigned long long *)hfsplus->finder_info.id;
- uuid = blkid_le64(*uuid_ptr);
+ uuid = blkid_le64(*((unsigned long long *) hfsplus->finder_info.id));
if (uuid) {
sprintf(uuid_str, "%016llX", uuid);
blkid_set_tag(probe->dev, "UUID", uuid_str, 0);
@@ -1298,8 +1296,7 @@ static int probe_hfsplus(struct blkid_probe *probe,
return 0;
label_len = blkid_be16(key->unicode_len) * 2;
- unicode_16be_to_utf8((unsigned char *)label, sizeof(label),
- key->unicode, label_len);
+ unicode_16be_to_utf8(label, sizeof(label), key->unicode, label_len);
blkid_set_tag(probe->dev, "LABEL", label, 0);
return 0;
}
diff --git a/lib/blkid/probe.h b/lib/blkid/probe.h
index 37e80eff..37fc9c06 100644
--- a/lib/blkid/probe.h
+++ b/lib/blkid/probe.h
@@ -109,7 +109,6 @@ struct ext2_super_block {
#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010
#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020
#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
-#define EXT4_FEATURE_RO_COMPAT_QUOTA 0x0100
/* for s_feature_incompat */
#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
diff --git a/lib/config.h.in b/lib/config.h.in
deleted file mode 100644
index b500a2cb..00000000
--- a/lib/config.h.in
+++ /dev/null
@@ -1,623 +0,0 @@
-/* lib/config.h.in. Generated from configure.in by autoheader. */
-
-/* Define if building universal (internal helper macro) */
-#undef AC_APPLE_UNIVERSAL_BUILD
-
-/* Define to 1 if debugging the blkid library */
-#undef CONFIG_BLKID_DEBUG
-
-/* Define to 1 to compile findfs */
-#undef CONFIG_BUILD_FINDFS
-
-/* Define to 1 if debugging ext3/4 journal code */
-#undef CONFIG_JBD_DEBUG
-
-/* Define to 1 to enable quota support */
-#undef CONFIG_QUOTA
-
-/* Define to 1 if the testio I/O manager should be enabled */
-#undef CONFIG_TESTIO_DEBUG
-
-/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
- systems. This function is required for `alloca.c' support on those systems.
- */
-#undef CRAY_STACKSEG_END
-
-/* Define to 1 if using `alloca.c'. */
-#undef C_ALLOCA
-
-/* Define to 1 to disable use of backtrace */
-#undef DISABLE_BACKTRACE
-
-/* Define to 1 if ext2 compression enabled */
-#undef ENABLE_COMPRESSION
-
-/* Define to 1 if ext3/4 htree support enabled */
-#undef ENABLE_HTREE
-
-/* Define to 1 if translation of program messages to the user's native
- language is requested. */
-#undef ENABLE_NLS
-
-/* Define to 1 if you have `alloca', as a function or macro. */
-#undef HAVE_ALLOCA
-
-/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
- */
-#undef HAVE_ALLOCA_H
-
-/* Define to 1 if you have the <argz.h> header file. */
-#undef HAVE_ARGZ_H
-
-/* Define to 1 if you have the `asprintf' function. */
-#undef HAVE_ASPRINTF
-
-/* Define to 1 if you have the `backtrace' function. */
-#undef HAVE_BACKTRACE
-
-/* Define to 1 if you have the `blkid_probe_get_topology' function. */
-#undef HAVE_BLKID_PROBE_GET_TOPOLOGY
-
-/* Define to 1 if you have the `chflags' function. */
-#undef HAVE_CHFLAGS
-
-/* Define if the GNU dcgettext() function is already present or preinstalled.
- */
-#undef HAVE_DCGETTEXT
-
-/* Define to 1 if you have the declaration of `feof_unlocked', and to 0 if you
- don't. */
-#undef HAVE_DECL_FEOF_UNLOCKED
-
-/* Define to 1 if you have the declaration of `fgets_unlocked', and to 0 if
- you don't. */
-#undef HAVE_DECL_FGETS_UNLOCKED
-
-/* Define to 1 if you have the declaration of `getc_unlocked', and to 0 if you
- don't. */
-#undef HAVE_DECL_GETC_UNLOCKED
-
-/* Define to 1 if you have the declaration of `_snprintf', and to 0 if you
- don't. */
-#undef HAVE_DECL__SNPRINTF
-
-/* Define to 1 if you have the declaration of `_snwprintf', and to 0 if you
- don't. */
-#undef HAVE_DECL__SNWPRINTF
-
-/* Define to 1 if you have the <dirent.h> header file. */
-#undef HAVE_DIRENT_H
-
-/* Define to 1 if dlopen/libdl exists */
-#undef HAVE_DLOPEN
-
-/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
-#undef HAVE_DOPRNT
-
-/* Define to 1 if you have the <errno.h> header file. */
-#undef HAVE_ERRNO_H
-
-/* Define to 1 if you have the <execinfo.h> header file. */
-#undef HAVE_EXECINFO_H
-
-/* Define to 1 if Ext2 ioctls present */
-#undef HAVE_EXT2_IOCTLS
-
-/* Define to 1 if you have the `fallocate' function. */
-#undef HAVE_FALLOCATE
-
-/* Define to 1 if you have the `fallocate64' function. */
-#undef HAVE_FALLOCATE64
-
-/* Define to 1 if you have the `fchown' function. */
-#undef HAVE_FCHOWN
-
-/* Define to 1 if you have the `fdatasync' function. */
-#undef HAVE_FDATASYNC
-
-/* Define to 1 if you have the `fstat64' function. */
-#undef HAVE_FSTAT64
-
-/* Define to 1 if you have the `ftruncate64' function. */
-#undef HAVE_FTRUNCATE64
-
-/* Define to 1 if you have the `fwprintf' function. */
-#undef HAVE_FWPRINTF
-
-/* Define to 1 if you have the `getcwd' function. */
-#undef HAVE_GETCWD
-
-/* Define to 1 if you have the `getdtablesize' function. */
-#undef HAVE_GETDTABLESIZE
-
-/* Define to 1 if you have the `getegid' function. */
-#undef HAVE_GETEGID
-
-/* Define to 1 if you have the `geteuid' function. */
-#undef HAVE_GETEUID
-
-/* Define to 1 if you have the `getgid' function. */
-#undef HAVE_GETGID
-
-/* Define to 1 if you have the `getmntinfo' function. */
-#undef HAVE_GETMNTINFO
-
-/* Define to 1 if you have the <getopt.h> header file. */
-#undef HAVE_GETOPT_H
-
-/* Define to 1 if you have the `getpagesize' function. */
-#undef HAVE_GETPAGESIZE
-
-/* Define to 1 if you have the `getpwuid_r' function. */
-#undef HAVE_GETPWUID_R
-
-/* Define to 1 if you have the `getrlimit' function. */
-#undef HAVE_GETRLIMIT
-
-/* Define to 1 if you have the `getrusage' function. */
-#undef HAVE_GETRUSAGE
-
-/* Define if the GNU gettext() function is already present or preinstalled. */
-#undef HAVE_GETTEXT
-
-/* Define to 1 if you have the `getuid' function. */
-#undef HAVE_GETUID
-
-/* Define if you have the iconv() function. */
-#undef HAVE_ICONV
-
-/* Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>. */
-#undef HAVE_INTMAX_T
-
-/* Define to 1 if the system has the type `intptr_t'. */
-#undef HAVE_INTPTR_T
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
-
-/* Define if <inttypes.h> exists, doesn't clash with <sys/types.h>, and
- declares uintmax_t. */
-#undef HAVE_INTTYPES_H_WITH_UINTMAX
-
-/* Define to 1 if you have the `jrand48' function. */
-#undef HAVE_JRAND48
-
-/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
-#undef HAVE_LANGINFO_CODESET
-
-/* Define if your <locale.h> file defines LC_MESSAGES. */
-#undef HAVE_LC_MESSAGES
-
-/* Define to 1 if you have the <limits.h> header file. */
-#undef HAVE_LIMITS_H
-
-/* Define to 1 if you have the <linux/falloc.h> header file. */
-#undef HAVE_LINUX_FALLOC_H
-
-/* Define to 1 if you have the <linux/fd.h> header file. */
-#undef HAVE_LINUX_FD_H
-
-/* Define to 1 if you have the <linux/major.h> header file. */
-#undef HAVE_LINUX_MAJOR_H
-
-/* Define to 1 if you have the `llseek' function. */
-#undef HAVE_LLSEEK
-
-/* Define to 1 if llseek declared in unistd.h */
-#undef HAVE_LLSEEK_PROTOTYPE
-
-/* Define to 1 if you have the <locale.h> header file. */
-#undef HAVE_LOCALE_H
-
-/* Define if you have the 'long double' type. */
-#undef HAVE_LONG_DOUBLE
-
-/* Define if you have the 'long long' type. */
-#undef HAVE_LONG_LONG
-
-/* Define to 1 if you have the `lseek64' function. */
-#undef HAVE_LSEEK64
-
-/* Define to 1 if lseek64 declared in unistd.h */
-#undef HAVE_LSEEK64_PROTOTYPE
-
-/* Define to 1 if you have the `mallinfo' function. */
-#undef HAVE_MALLINFO
-
-/* Define to 1 if you have the <malloc.h> header file. */
-#undef HAVE_MALLOC_H
-
-/* Define to 1 if you have the `mbstowcs' function. */
-#undef HAVE_MBSTOWCS
-
-/* Define to 1 if you have the `memalign' function. */
-#undef HAVE_MEMALIGN
-
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* Define to 1 if you have the `mempcpy' function. */
-#undef HAVE_MEMPCPY
-
-/* Define to 1 if you have the `mmap' function. */
-#undef HAVE_MMAP
-
-/* Define to 1 if you have the <mntent.h> header file. */
-#undef HAVE_MNTENT_H
-
-/* Define to 1 if you have the `msync' function. */
-#undef HAVE_MSYNC
-
-/* Define to 1 if you have the `munmap' function. */
-#undef HAVE_MUNMAP
-
-/* Define to 1 if you have the `nanosleep' function. */
-#undef HAVE_NANOSLEEP
-
-/* Define to 1 if you have the <netinet/in.h> header file. */
-#undef HAVE_NETINET_IN_H
-
-/* Define to 1 if you have the <net/if_dl.h> header file. */
-#undef HAVE_NET_IF_DL_H
-
-/* Define to 1 if you have the <net/if.h> header file. */
-#undef HAVE_NET_IF_H
-
-/* Define to 1 if you have the <nl_types.h> header file. */
-#undef HAVE_NL_TYPES_H
-
-/* Define to 1 if you have the `open64' function. */
-#undef HAVE_OPEN64
-
-/* Define to 1 if optreset for getopt is present */
-#undef HAVE_OPTRESET
-
-/* Define to 1 if you have the `pathconf' function. */
-#undef HAVE_PATHCONF
-
-/* Define to 1 if you have the <paths.h> header file. */
-#undef HAVE_PATHS_H
-
-/* Define to 1 if you have the `posix_fadvise' function. */
-#undef HAVE_POSIX_FADVISE
-
-/* Define to 1 if you have the `posix_memalign' function. */
-#undef HAVE_POSIX_MEMALIGN
-
-/* Define if your printf() function supports format strings with positions. */
-#undef HAVE_POSIX_PRINTF
-
-/* Define to 1 if you have the `prctl' function. */
-#undef HAVE_PRCTL
-
-/* Define to 1 if you have the `putenv' function. */
-#undef HAVE_PUTENV
-
-/* Define to 1 if dirent has d_reclen */
-#undef HAVE_RECLEN_DIRENT
-
-/* Define to 1 if if struct sockaddr contains sa_len */
-#undef HAVE_SA_LEN
-
-/* Define to 1 if you have the `secure_getenv' function. */
-#undef HAVE_SECURE_GETENV
-
-/* Define to 1 if you have the <semaphore.h> header file. */
-#undef HAVE_SEMAPHORE_H
-
-/* Define to 1 if sem_init() exists */
-#undef HAVE_SEM_INIT
-
-/* Define to 1 if you have the `setenv' function. */
-#undef HAVE_SETENV
-
-/* Define to 1 if you have the <setjmp.h> header file. */
-#undef HAVE_SETJMP_H
-
-/* Define to 1 if you have the `setlocale' function. */
-#undef HAVE_SETLOCALE
-
-/* Define to 1 if you have the `setmntent' function. */
-#undef HAVE_SETMNTENT
-
-/* Define to 1 if you have the `setresgid' function. */
-#undef HAVE_SETRESGID
-
-/* Define to 1 if you have the `setresuid' function. */
-#undef HAVE_SETRESUID
-
-/* Define to 1 if you have the <signal.h> header file. */
-#undef HAVE_SIGNAL_H
-
-/* Define to 1 if you have the `snprintf' function. */
-#undef HAVE_SNPRINTF
-
-/* Define to 1 if you have the `srandom' function. */
-#undef HAVE_SRANDOM
-
-/* Define to 1 if struct stat has st_flags */
-#undef HAVE_STAT_FLAGS
-
-/* Define to 1 if you have the <stdarg.h> header file. */
-#undef HAVE_STDARG_H
-
-/* Define to 1 if you have the <stddef.h> header file. */
-#undef HAVE_STDDEF_H
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
-
-/* Define if <stdint.h> exists, doesn't clash with <sys/types.h>, and declares
- uintmax_t. */
-#undef HAVE_STDINT_H_WITH_UINTMAX
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
-
-/* Define to 1 if you have the `stpcpy' function. */
-#undef HAVE_STPCPY
-
-/* Define to 1 if you have the `strcasecmp' function. */
-#undef HAVE_STRCASECMP
-
-/* Define to 1 if you have the `strdup' function. */
-#undef HAVE_STRDUP
-
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#undef HAVE_STRING_H
-
-/* Define to 1 if you have the `strnlen' function. */
-#undef HAVE_STRNLEN
-
-/* Define to 1 if you have the `strptime' function. */
-#undef HAVE_STRPTIME
-
-/* Define to 1 if you have the `strtoul' function. */
-#undef HAVE_STRTOUL
-
-/* Define to 1 if you have the `strtoull' function. */
-#undef HAVE_STRTOULL
-
-/* Define to 1 if you have the `sync_file_range' function. */
-#undef HAVE_SYNC_FILE_RANGE
-
-/* Define to 1 if you have the `sysconf' function. */
-#undef HAVE_SYSCONF
-
-/* Define to 1 if you have the <sys/disklabel.h> header file. */
-#undef HAVE_SYS_DISKLABEL_H
-
-/* Define to 1 if you have the <sys/disk.h> header file. */
-#undef HAVE_SYS_DISK_H
-
-/* Define to 1 if you have the <sys/file.h> header file. */
-#undef HAVE_SYS_FILE_H
-
-/* Define to 1 if you have the <sys/ioctl.h> header file. */
-#undef HAVE_SYS_IOCTL_H
-
-/* Define to 1 if you have the <sys/mkdev.h> header file. */
-#undef HAVE_SYS_MKDEV_H
-
-/* Define to 1 if you have the <sys/mman.h> header file. */
-#undef HAVE_SYS_MMAN_H
-
-/* Define to 1 if you have the <sys/mount.h> header file. */
-#undef HAVE_SYS_MOUNT_H
-
-/* Define to 1 if you have the <sys/param.h> header file. */
-#undef HAVE_SYS_PARAM_H
-
-/* Define to 1 if you have the <sys/prctl.h> header file. */
-#undef HAVE_SYS_PRCTL_H
-
-/* Define to 1 if you have the <sys/queue.h> header file. */
-#undef HAVE_SYS_QUEUE_H
-
-/* Define to 1 if you have the <sys/resource.h> header file. */
-#undef HAVE_SYS_RESOURCE_H
-
-/* Define to 1 if you have the <sys/select.h> header file. */
-#undef HAVE_SYS_SELECT_H
-
-/* Define to 1 if you have the <sys/socket.h> header file. */
-#undef HAVE_SYS_SOCKET_H
-
-/* Define to 1 if you have the <sys/sockio.h> header file. */
-#undef HAVE_SYS_SOCKIO_H
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#undef HAVE_SYS_STAT_H
-
-/* Define to 1 if you have the <sys/syscall.h> header file. */
-#undef HAVE_SYS_SYSCALL_H
-
-/* Define to 1 if you have the <sys/sysmacros.h> header file. */
-#undef HAVE_SYS_SYSMACROS_H
-
-/* Define to 1 if you have the <sys/time.h> header file. */
-#undef HAVE_SYS_TIME_H
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#undef HAVE_SYS_TYPES_H
-
-/* Define to 1 if you have the <sys/un.h> header file. */
-#undef HAVE_SYS_UN_H
-
-/* Define to 1 if you have the <sys/wait.h> header file. */
-#undef HAVE_SYS_WAIT_H
-
-/* Define to 1 if you have the <termios.h> header file. */
-#undef HAVE_TERMIOS_H
-
-/* Define to 1 if you have the <termio.h> header file. */
-#undef HAVE_TERMIO_H
-
-/* Define to 1 if you have the `tsearch' function. */
-#undef HAVE_TSEARCH
-
-/* Define to 1 if ssize_t declared */
-#undef HAVE_TYPE_SSIZE_T
-
-/* Define if you have the 'uintmax_t' type in <stdint.h> or <inttypes.h>. */
-#undef HAVE_UINTMAX_T
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
-
-/* Define if you have the 'unsigned long long' type. */
-#undef HAVE_UNSIGNED_LONG_LONG
-
-/* Define to 1 if you have the `usleep' function. */
-#undef HAVE_USLEEP
-
-/* Define to 1 if you have the `utime' function. */
-#undef HAVE_UTIME
-
-/* Define to 1 if you have the <utime.h> header file. */
-#undef HAVE_UTIME_H
-
-/* Define to 1 if you have the `valloc' function. */
-#undef HAVE_VALLOC
-
-/* Define to 1 if you have the `vprintf' function. */
-#undef HAVE_VPRINTF
-
-/* Define if you have the 'wchar_t' type. */
-#undef HAVE_WCHAR_T
-
-/* Define to 1 if you have the `wcslen' function. */
-#undef HAVE_WCSLEN
-
-/* Define if you have the 'wint_t' type. */
-#undef HAVE_WINT_T
-
-/* Define to 1 if you have the `__argz_count' function. */
-#undef HAVE___ARGZ_COUNT
-
-/* Define to 1 if you have the `__argz_next' function. */
-#undef HAVE___ARGZ_NEXT
-
-/* Define to 1 if you have the `__argz_stringify' function. */
-#undef HAVE___ARGZ_STRINGIFY
-
-/* Define to 1 if you have the `__fsetlocking' function. */
-#undef HAVE___FSETLOCKING
-
-/* Define to 1 if you have the `__secure_getenv' function. */
-#undef HAVE___SECURE_GETENV
-
-/* Define as const if the declaration of iconv() needs const. */
-#undef ICONV_CONST
-
-/* Define if integer division by zero raises signal SIGFPE. */
-#undef INTDIV0_RAISES_SIGFPE
-
-/* package name for gettext */
-#undef PACKAGE
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the home page for this package. */
-#undef PACKAGE_URL
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
-/* Define if <inttypes.h> exists and defines unusable PRI* macros. */
-#undef PRI_MACROS_BROKEN
-
-/* The size of `int', as computed by sizeof. */
-#undef SIZEOF_INT
-
-/* The size of `long', as computed by sizeof. */
-#undef SIZEOF_LONG
-
-/* The size of `long long', as computed by sizeof. */
-#undef SIZEOF_LONG_LONG
-
-/* The size of `off_t', as computed by sizeof. */
-#undef SIZEOF_OFF_T
-
-/* The size of `short', as computed by sizeof. */
-#undef SIZEOF_SHORT
-
-/* Define as the maximum value of type 'size_t', if the system doesn't define
- it. */
-#undef SIZE_MAX
-
-/* If using the C implementation of alloca, define if you know the
- direction of stack growth for your system; otherwise it will be
- automatically deduced at runtime.
- STACK_DIRECTION > 0 => grows toward higher addresses
- STACK_DIRECTION < 0 => grows toward lower addresses
- STACK_DIRECTION = 0 => direction of growth unknown */
-#undef STACK_DIRECTION
-
-/* Define to 1 if you have the ANSI C header files. */
-#undef STDC_HEADERS
-
-/* If the compiler supports a TLS storage class define it to that here */
-#undef TLS
-
-/* Define to 1 to build uuidd */
-#undef USE_UUIDD
-
-/* version for gettext */
-#undef VERSION
-
-/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
- significant byte first (like Motorola and SPARC, unlike Intel). */
-#if defined AC_APPLE_UNIVERSAL_BUILD
-# if defined __BIG_ENDIAN__
-# define WORDS_BIGENDIAN 1
-# endif
-#else
-# ifndef WORDS_BIGENDIAN
-# undef WORDS_BIGENDIAN
-# endif
-#endif
-
-/* Define to 1 if Apple Darwin libintl workaround is needed */
-#undef _INTL_REDIRECT_MACROS
-
-/* Define to empty if `const' does not conform to ANSI C. */
-#undef const
-
-/* Define to `__inline__' or `__inline' if that's what the C compiler
- calls it, or to nothing if 'inline' is not supported under any name. */
-#ifndef __cplusplus
-#undef inline
-#endif
-
-/* Define to `long int' if <sys/types.h> does not define. */
-#undef off_t
-
-/* Define as the type of the result of subtracting two pointers, if the system
- doesn't define it. */
-#undef ptrdiff_t
-
-/* Define to empty if the C compiler doesn't support this keyword. */
-#undef signed
-
-/* Define to `unsigned int' if <sys/types.h> does not define. */
-#undef size_t
-
-/* Define to unsigned long or unsigned long long if <stdint.h> and
- <inttypes.h> don't define. */
-#undef uintmax_t
-
-#include "dirpaths.h"
diff --git a/lib/dirpaths.h.in b/lib/dirpaths.h.in
deleted file mode 100644
index 6ccb55be..00000000
--- a/lib/dirpaths.h.in
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * This file contains the path names for various directories as
- * controlled by the configure script.
- */
-
-/* Where to put the messages file for internationalization support */
-#define LOCALEDIR "@datadir@/locale"
-
-/* Where to find the mke2fs.conf and e2fsck.conf files */
-#define ROOT_SYSCONFDIR "@root_sysconfdir@"
diff --git a/lib/e2p/MODULE_LICENSE_LGPL b/lib/e2p/MODULE_LICENSE_LGPL
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/lib/e2p/MODULE_LICENSE_LGPL
diff --git a/lib/e2p/Makefile.in b/lib/e2p/Makefile.in
index d6992fc5..9775a987 100644
--- a/lib/e2p/Makefile.in
+++ b/lib/e2p/Makefile.in
@@ -55,7 +55,6 @@ BSDLIB_INSTALL_DIR = $(root_libdir)
.c.o:
$(E) " CC $<"
$(Q) $(CC) $(ALL_CFLAGS) -c $< -o $@
- $(Q) $(CHECK_CMD) $(ALL_CFLAGS) $<
@PROFILE_CMT@ $(Q) $(CC) $(ALL_CFLAGS) -g -pg -o profiled/$*.o -c $<
@CHECKER_CMT@ $(Q) $(CC) $(ALL_CFLAGS) -checker -g -o checker/$*.o -c $<
@ELF_CMT@ $(Q) $(CC) $(ALL_CFLAGS) -fPIC -o elfshared/$*.o -c $<
@@ -117,8 +116,7 @@ $(OBJS): subdirs
# Makefile dependencies follow. This must be the last section in
# the Makefile.in file
#
-feature.o: $(srcdir)/feature.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/e2p.h \
+feature.o: $(srcdir)/feature.c $(srcdir)/e2p.h \
$(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h \
$(top_srcdir)/lib/ext2fs/ext2fs.h $(top_srcdir)/lib/ext2fs/ext3_extents.h \
$(top_srcdir)/lib/et/com_err.h $(top_srcdir)/lib/ext2fs/ext2_io.h \
@@ -126,60 +124,41 @@ feature.o: $(srcdir)/feature.c $(top_builddir)/lib/config.h \
$(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h \
$(top_srcdir)/lib/ext2fs/jfs_user.h $(top_srcdir)/lib/ext2fs/kernel-jbd.h \
$(top_srcdir)/lib/ext2fs/jfs_compat.h $(top_srcdir)/lib/ext2fs/kernel-list.h
-fgetflags.o: $(srcdir)/fgetflags.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/e2p.h \
+fgetflags.o: $(srcdir)/fgetflags.c $(srcdir)/e2p.h \
$(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h
-fsetflags.o: $(srcdir)/fsetflags.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/e2p.h \
+fsetflags.o: $(srcdir)/fsetflags.c $(srcdir)/e2p.h \
$(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h
-fgetversion.o: $(srcdir)/fgetversion.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/e2p.h \
+fgetversion.o: $(srcdir)/fgetversion.c $(srcdir)/e2p.h \
$(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h
-fsetversion.o: $(srcdir)/fsetversion.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/e2p.h \
+fsetversion.o: $(srcdir)/fsetversion.c $(srcdir)/e2p.h \
$(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h
-getflags.o: $(srcdir)/getflags.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/e2p.h \
+getflags.o: $(srcdir)/getflags.c $(srcdir)/e2p.h \
$(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h
-getversion.o: $(srcdir)/getversion.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/e2p.h \
+getversion.o: $(srcdir)/getversion.c $(srcdir)/e2p.h \
$(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h
-hashstr.o: $(srcdir)/hashstr.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/e2p.h \
+hashstr.o: $(srcdir)/hashstr.c $(srcdir)/e2p.h \
$(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h
-iod.o: $(srcdir)/iod.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/e2p.h \
+iod.o: $(srcdir)/iod.c $(srcdir)/e2p.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \
+ $(top_builddir)/lib/ext2fs/ext2_types.h
+ls.o: $(srcdir)/ls.c $(srcdir)/e2p.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \
+ $(top_builddir)/lib/ext2fs/ext2_types.h
+mntopts.o: $(srcdir)/mntopts.c $(srcdir)/e2p.h \
$(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h
-ls.o: $(srcdir)/ls.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/e2p.h \
+parse_num.o: $(srcdir)/parse_num.c $(srcdir)/e2p.h \
$(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h
-mntopts.o: $(srcdir)/mntopts.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/e2p.h \
+pe.o: $(srcdir)/pe.c $(srcdir)/e2p.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \
+ $(top_builddir)/lib/ext2fs/ext2_types.h
+pf.o: $(srcdir)/pf.c $(srcdir)/e2p.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \
+ $(top_builddir)/lib/ext2fs/ext2_types.h
+ps.o: $(srcdir)/ps.c $(srcdir)/e2p.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \
+ $(top_builddir)/lib/ext2fs/ext2_types.h
+setflags.o: $(srcdir)/setflags.c $(srcdir)/e2p.h \
$(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h
-parse_num.o: $(srcdir)/parse_num.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/e2p.h \
+setversion.o: $(srcdir)/setversion.c $(srcdir)/e2p.h \
$(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h
-pe.o: $(srcdir)/pe.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/e2p.h \
- $(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h
-pf.o: $(srcdir)/pf.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/e2p.h \
- $(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h
-ps.o: $(srcdir)/ps.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/e2p.h \
- $(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h
-setflags.o: $(srcdir)/setflags.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/e2p.h \
- $(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h
-setversion.o: $(srcdir)/setversion.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/e2p.h \
- $(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h
-uuid.o: $(srcdir)/uuid.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(top_builddir)/lib/ext2fs/ext2_types.h \
+uuid.o: $(srcdir)/uuid.c $(top_builddir)/lib/ext2fs/ext2_types.h \
$(srcdir)/e2p.h $(top_srcdir)/lib/ext2fs/ext2_fs.h
-ostype.o: $(srcdir)/ostype.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/e2p.h \
+ostype.o: $(srcdir)/ostype.c $(srcdir)/e2p.h \
$(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h
-percent.o: $(srcdir)/percent.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/e2p.h \
+percent.o: $(srcdir)/percent.c $(srcdir)/e2p.h \
$(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h
diff --git a/lib/e2p/e2p.h b/lib/e2p/e2p.h
index 4a68dd9a..7a90c37e 100644
--- a/lib/e2p/e2p.h
+++ b/lib/e2p/e2p.h
@@ -66,7 +66,6 @@ int e2p_string2mntopt(char *string, unsigned int *mask);
int e2p_edit_mntopts(const char *str, __u32 *mntopts, __u32 ok);
unsigned long parse_num_blocks(const char *arg, int log_block_size);
-unsigned long long parse_num_blocks2(const char *arg, int log_block_size);
char *e2p_os2string(int os_type);
int e2p_string2os(char *str);
diff --git a/lib/e2p/e2p.pc.in b/lib/e2p/e2p.pc.in
index c171ae67..98ee9fb7 100644
--- a/lib/e2p/e2p.pc.in
+++ b/lib/e2p/e2p.pc.in
@@ -7,5 +7,5 @@ Name: e2p
Description: Ext2fs userpace programs utility library
Version: @E2FSPROGS_VERSION@
Requires:
-Cflags: -I${includedir}/e2p -I${includedir}
+Cflags: -I${includedir}/e2p
Libs: -L${libdir} -le2p
diff --git a/lib/e2p/feature.c b/lib/e2p/feature.c
index bd8a64af..c7f8a359 100644
--- a/lib/e2p/feature.c
+++ b/lib/e2p/feature.c
@@ -40,8 +40,6 @@ static struct feature feature_list[] = {
"resize_inode" },
{ E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_LAZY_BG,
"lazy_bg" },
- { E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP,
- "snapshot_bitmap" },
{ E2P_FEATURE_RO_INCOMPAT, EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER,
"sparse_super" },
@@ -57,14 +55,6 @@ static struct feature feature_list[] = {
"dir_nlink" },
{ E2P_FEATURE_RO_INCOMPAT, EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE,
"extra_isize" },
- { E2P_FEATURE_RO_INCOMPAT, EXT4_FEATURE_RO_COMPAT_QUOTA,
- "quota" },
- { E2P_FEATURE_RO_INCOMPAT, EXT4_FEATURE_RO_COMPAT_BIGALLOC,
- "bigalloc"},
- { E2P_FEATURE_RO_INCOMPAT, EXT4_FEATURE_RO_COMPAT_METADATA_CSUM,
- "metadata_csum"},
- { E2P_FEATURE_RO_INCOMPAT, EXT4_FEATURE_RO_COMPAT_REPLICA,
- "replica" },
{ E2P_FEATURE_INCOMPAT, EXT2_FEATURE_INCOMPAT_COMPRESSION,
"compression" },
@@ -82,18 +72,8 @@ static struct feature feature_list[] = {
"meta_bg" },
{ E2P_FEATURE_INCOMPAT, EXT4_FEATURE_INCOMPAT_64BIT,
"64bit" },
- { E2P_FEATURE_INCOMPAT, EXT4_FEATURE_INCOMPAT_MMP,
- "mmp" },
{ E2P_FEATURE_INCOMPAT, EXT4_FEATURE_INCOMPAT_FLEX_BG,
- "flex_bg"},
- { E2P_FEATURE_INCOMPAT, EXT4_FEATURE_INCOMPAT_EA_INODE,
- "ea_inode"},
- { E2P_FEATURE_INCOMPAT, EXT4_FEATURE_INCOMPAT_DIRDATA,
- "dirdata"},
- { E2P_FEATURE_INCOMPAT, EXT4_FEATURE_INCOMPAT_LARGEDIR,
- "large_dir"},
- { E2P_FEATURE_INCOMPAT, EXT4_FEATURE_INCOMPAT_INLINEDATA,
- "inline_data"},
+ "flex_bg"},
{ 0, 0, 0 },
};
@@ -103,8 +83,6 @@ static struct feature jrnl_feature_list[] = {
{ E2P_FEATURE_INCOMPAT, JFS_FEATURE_INCOMPAT_REVOKE,
"journal_incompat_revoke" },
- { E2P_FEATURE_INCOMPAT, JFS_FEATURE_INCOMPAT_64BIT,
- "journal_64bit" },
{ E2P_FEATURE_INCOMPAT, JFS_FEATURE_INCOMPAT_ASYNC_COMMIT,
"journal_async_commit" },
{ 0, 0, 0 },
@@ -321,7 +299,6 @@ int e2p_edit_feature2(const char *str, __u32 *compat_array, __u32 *ok_array,
case '-':
case '^':
neg++;
- /* fallthrough */
case '+':
cp++;
break;
diff --git a/lib/e2p/fgetflags.c b/lib/e2p/fgetflags.c
index ca3ea166..d66f8e18 100644
--- a/lib/e2p/fgetflags.c
+++ b/lib/e2p/fgetflags.c
@@ -63,7 +63,7 @@ int fgetflags (const char * name, unsigned long * flags)
#endif
return 0;
-#else /* !HAVE_STAT_FLAGS || (APPLE_DARWIN && HAVE_EXT2_IOCTLS) */
+#else
#if HAVE_EXT2_IOCTLS
int fd, r, f, save_errno = 0;
@@ -83,15 +83,15 @@ int fgetflags (const char * name, unsigned long * flags)
if (save_errno)
errno = save_errno;
return r;
-#else /* APPLE_DARWIN */
+#else
f = -1;
save_errno = syscall(SYS_fsctl, name, EXT2_IOC_GETFLAGS, &f, 0);
*flags = f;
return (save_errno);
-#endif /* !APPLE_DARWIN */
-notsupp:
+#endif
#endif /* HAVE_EXT2_IOCTLS */
#endif
+notsupp:
errno = EOPNOTSUPP;
return -1;
}
diff --git a/lib/e2p/fsetflags.c b/lib/e2p/fsetflags.c
index 08dd114d..30437a20 100644
--- a/lib/e2p/fsetflags.c
+++ b/lib/e2p/fsetflags.c
@@ -51,6 +51,7 @@
int fsetflags (const char * name, unsigned long flags)
{
+ struct stat buf;
#if HAVE_CHFLAGS && !(APPLE_DARWIN && HAVE_EXT2_IOCTLS)
unsigned long bsd_flags = 0;
@@ -68,10 +69,9 @@ int fsetflags (const char * name, unsigned long flags)
#endif
return chflags (name, bsd_flags);
-#else /* !HAVE_CHFLAGS || (APPLE_DARWIN && HAVE_EXT2_IOCTLS) */
+#else
#if HAVE_EXT2_IOCTLS
int fd, r, f, save_errno = 0;
- struct stat buf;
if (!lstat(name, &buf) &&
!S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode)) {
@@ -88,15 +88,14 @@ int fsetflags (const char * name, unsigned long flags)
close (fd);
if (save_errno)
errno = save_errno;
-#else /* APPLE_DARWIN */
- f = (int) flags;
- return syscall(SYS_fsctl, name, EXT2_IOC_SETFLAGS, &f, 0);
-#endif /* !APPLE_DARWIN */
+#else
+ f = (int) flags;
+ return syscall(SYS_fsctl, name, EXT2_IOC_SETFLAGS, &f, 0);
+#endif
return r;
-
-notsupp:
#endif /* HAVE_EXT2_IOCTLS */
#endif
+notsupp:
errno = EOPNOTSUPP;
return -1;
}
diff --git a/lib/e2p/getflags.c b/lib/e2p/getflags.c
index e8716848..a738fed3 100644
--- a/lib/e2p/getflags.c
+++ b/lib/e2p/getflags.c
@@ -57,13 +57,12 @@ int getflags (int fd, unsigned long * flags)
if (!fstat(fd, &buf) &&
!S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode))
goto notsupp;
- r = ioctl(fd, EXT2_IOC_GETFLAGS, &f);
+ r = ioctl (fd, EXT2_IOC_GETFLAGS, &f);
*flags = f;
-
return r;
-notsupp:
#endif /* HAVE_EXT2_IOCTLS */
#endif
+notsupp:
errno = EOPNOTSUPP;
return -1;
}
diff --git a/lib/e2p/getversion.c b/lib/e2p/getversion.c
index ec6621dc..eb0e5202 100644
--- a/lib/e2p/getversion.c
+++ b/lib/e2p/getversion.c
@@ -30,7 +30,7 @@ int getversion (int fd, unsigned long * version)
r = ioctl (fd, EXT2_IOC_GETVERSION, &ver);
*version = ver;
- return r;
+ return 0;
#else /* ! HAVE_EXT2_IOCTLS */
extern int errno;
errno = EOPNOTSUPP;
diff --git a/lib/e2p/ls.c b/lib/e2p/ls.c
index 78cd335e..5ef80988 100644
--- a/lib/e2p/ls.c
+++ b/lib/e2p/ls.c
@@ -166,26 +166,6 @@ static void print_super_flags(struct ext2_super_block * s, FILE *f)
fputs("(none)\n", f);
}
-static __u64 e2p_blocks_count(struct ext2_super_block *super)
-{
- return super->s_blocks_count |
- (super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT ?
- (__u64) super->s_blocks_count_hi << 32 : 0);
-}
-
-static __u64 e2p_r_blocks_count(struct ext2_super_block *super)
-{
- return super->s_r_blocks_count |
- (super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT ?
- (__u64) super->s_r_blocks_count_hi << 32 : 0);
-}
-
-static __u64 e2p_free_blocks_count(struct ext2_super_block *super)
-{
- return super->s_free_blocks_count |
- (super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT ?
- (__u64) super->s_free_blocks_hi << 32 : 0);
-}
#ifndef EXT2_INODE_SIZE
#define EXT2_INODE_SIZE(s) sizeof(struct ext2_inode)
@@ -243,33 +223,18 @@ void list_super2(struct ext2_super_block * sb, FILE *f)
fprintf(f, "Filesystem OS type: %s\n", str);
free(str);
fprintf(f, "Inode count: %u\n", sb->s_inodes_count);
- fprintf(f, "Block count: %llu\n", e2p_blocks_count(sb));
- fprintf(f, "Reserved block count: %llu\n", e2p_r_blocks_count(sb));
- if (sb->s_overhead_blocks)
- fprintf(f, "Overhead blocks: %u\n",
- sb->s_overhead_blocks);
- fprintf(f, "Free blocks: %llu\n", e2p_free_blocks_count(sb));
+ fprintf(f, "Block count: %u\n", sb->s_blocks_count);
+ fprintf(f, "Reserved block count: %u\n", sb->s_r_blocks_count);
+ fprintf(f, "Free blocks: %u\n", sb->s_free_blocks_count);
fprintf(f, "Free inodes: %u\n", sb->s_free_inodes_count);
fprintf(f, "First block: %u\n", sb->s_first_data_block);
fprintf(f, "Block size: %u\n", EXT2_BLOCK_SIZE(sb));
- if (sb->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_BIGALLOC)
- fprintf(f, "Cluster size: %u\n",
- EXT2_CLUSTER_SIZE(sb));
- else
- fprintf(f, "Fragment size: %u\n",
- EXT2_CLUSTER_SIZE(sb));
- if (sb->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT)
- fprintf(f, "Group descriptor size: %u\n", sb->s_desc_size);
+ fprintf(f, "Fragment size: %u\n", EXT2_FRAG_SIZE(sb));
if (sb->s_reserved_gdt_blocks)
fprintf(f, "Reserved GDT blocks: %u\n",
sb->s_reserved_gdt_blocks);
fprintf(f, "Blocks per group: %u\n", sb->s_blocks_per_group);
- if (sb->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_BIGALLOC)
- fprintf(f, "Clusters per group: %u\n",
- sb->s_clusters_per_group);
- else
- fprintf(f, "Fragments per group: %u\n",
- sb->s_clusters_per_group);
+ fprintf(f, "Fragments per group: %u\n", sb->s_frags_per_group);
fprintf(f, "Inodes per group: %u\n", sb->s_inodes_per_group);
fprintf(f, "Inode blocks per group: %u\n", inode_blocks_per_group);
if (sb->s_raid_stride)
@@ -385,7 +350,7 @@ void list_super2(struct ext2_super_block * sb, FILE *f)
tm = sb->s_first_error_time;
fprintf(f, "First error time: %s", ctime(&tm));
memset(buf, 0, sizeof(buf));
- strncpy(buf, (char *)sb->s_first_error_func,
+ strncpy(buf, sb->s_first_error_func,
sizeof(sb->s_first_error_func));
fprintf(f, "First error function: %s\n", buf);
fprintf(f, "First error line #: %u\n",
@@ -399,7 +364,7 @@ void list_super2(struct ext2_super_block * sb, FILE *f)
tm = sb->s_last_error_time;
fprintf(f, "Last error time: %s", ctime(&tm));
memset(buf, 0, sizeof(buf));
- strncpy(buf, (char *)sb->s_last_error_func,
+ strncpy(buf, sb->s_last_error_func,
sizeof(sb->s_last_error_func));
fprintf(f, "Last error function: %s\n", buf);
fprintf(f, "Last error line #: %u\n",
@@ -409,22 +374,6 @@ void list_super2(struct ext2_super_block * sb, FILE *f)
fprintf(f, "Last error block #: %llu\n",
sb->s_last_error_block);
}
- if (sb->s_feature_incompat & EXT4_FEATURE_INCOMPAT_MMP) {
- fprintf(f, "MMP block number: %llu\n",
- (long long)sb->s_mmp_block);
- fprintf(f, "MMP update interval: %u\n",
- sb->s_mmp_update_interval);
- }
- if (sb->s_usr_quota_inum)
- fprintf(f, "User quota inode: %u\n",
- sb->s_usr_quota_inum);
- if (sb->s_grp_quota_inum)
- fprintf(f, "Group quota inode: %u\n",
- sb->s_grp_quota_inum);
-
- if (sb->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)
- fprintf(f, "Checksum: 0x%08x\n",
- sb->s_checksum);
}
void list_super (struct ext2_super_block * s)
diff --git a/lib/e2p/mntopts.c b/lib/e2p/mntopts.c
index 9d3879e3..ebab7fdf 100644
--- a/lib/e2p/mntopts.c
+++ b/lib/e2p/mntopts.c
@@ -65,7 +65,7 @@ int e2p_string2mntopt(char *string, unsigned int *mask)
return 0;
}
}
- if (strncasecmp(string, "MNTOPT_", 7))
+ if (strncasecmp(string, "MNTOPT_", 8))
return 1;
if (string[8] == 0)
@@ -122,7 +122,6 @@ int e2p_edit_mntopts(const char *str, __u32 *mntopts, __u32 ok)
case '-':
case '^':
neg++;
- /* fallthrough */
case '+':
cp++;
break;
diff --git a/lib/e2p/parse_num.c b/lib/e2p/parse_num.c
index 4caa3a3c..47f0b5bd 100644
--- a/lib/e2p/parse_num.c
+++ b/lib/e2p/parse_num.c
@@ -13,7 +13,7 @@
#include <stdlib.h>
-unsigned long long parse_num_blocks2(const char *arg, int log_block_size)
+unsigned long parse_num_blocks(const char *arg, int log_block_size)
{
char *p;
unsigned long long num;
@@ -26,24 +26,15 @@ unsigned long long parse_num_blocks2(const char *arg, int log_block_size)
switch (*p) { /* Using fall-through logic */
case 'T': case 't':
num <<= 10;
- /* fallthrough */
case 'G': case 'g':
num <<= 10;
- /* fallthrough */
case 'M': case 'm':
num <<= 10;
- /* fallthrough */
case 'K': case 'k':
- if (log_block_size < 0)
- num <<= 10;
- else
- num >>= log_block_size;
+ num >>= log_block_size;
break;
case 's':
- if (log_block_size < 0)
- num <<= 9;
- else
- num >>= (1+log_block_size);
+ num >>= (1+log_block_size);
break;
case '\0':
break;
@@ -53,11 +44,6 @@ unsigned long long parse_num_blocks2(const char *arg, int log_block_size)
return num;
}
-unsigned long parse_num_blocks(const char *arg, int log_block_size)
-{
- return parse_num_blocks2(arg, log_block_size);
-}
-
#ifdef DEBUG
#include <unistd.h>
#include <stdio.h>
@@ -67,21 +53,11 @@ main(int argc, char **argv)
unsigned long num;
int log_block_size = 0;
- if (argc != 2 && argc != 3) {
- fprintf(stderr, "Usage: %s arg [log_block_size]\n", argv[0]);
+ if (argc != 2) {
+ fprintf(stderr, "Usage: %s arg\n", argv[0]);
exit(1);
}
- if (argc == 3) {
- char *p;
-
- log_block_size = strtol(argv[2], &p, 0);
- if (*p) {
- fprintf(stderr, "Bad log_block_size: %s\n", argv[2]);
- exit(1);
- }
- }
-
num = parse_num_blocks(argv[1], log_block_size);
printf("Parsed number: %lu\n", num);
diff --git a/lib/e2p/pf.c b/lib/e2p/pf.c
index 6dd29f63..f34a5cc3 100644
--- a/lib/e2p/pf.c
+++ b/lib/e2p/pf.c
@@ -48,7 +48,6 @@ static struct flags_name flags_array[] = {
{ EXT2_TOPDIR_FL, "T", "Top_of_Directory_Hierarchies" },
{ EXT4_EXTENTS_FL, "e", "Extents" },
{ EXT4_HUGE_FILE_FL, "h", "Huge_file" },
- { FS_NOCOW_FL, "C", "No_COW" },
{ 0, NULL, NULL }
};
diff --git a/lib/e2p/setflags.c b/lib/e2p/setflags.c
index b203606f..cc00b203 100644
--- a/lib/e2p/setflags.c
+++ b/lib/e2p/setflags.c
@@ -38,6 +38,7 @@
int setflags (int fd, unsigned long flags)
{
+ struct stat buf;
#if HAVE_CHFLAGS
unsigned long bsd_flags = 0;
@@ -55,9 +56,8 @@ int setflags (int fd, unsigned long flags)
#endif
return fchflags (fd, bsd_flags);
-#else /* ! HAVE_CHFLAGS */
+#else
#if HAVE_EXT2_IOCTLS
- struct stat buf;
int f;
if (!fstat(fd, &buf) &&
@@ -66,11 +66,9 @@ int setflags (int fd, unsigned long flags)
return -1;
}
f = (int) flags;
-
- return ioctl(fd, EXT2_IOC_SETFLAGS, &f);
-#else
+ return ioctl (fd, EXT2_IOC_SETFLAGS, &f);
+#endif /* HAVE_EXT2_IOCTLS */
+#endif
errno = EOPNOTSUPP;
return -1;
-#endif /* HAVE_EXT2_IOCTLS */
-#endif /* HAVE_CHFLAGS */
}
diff --git a/lib/et/MODULE_LICENSE_MIT b/lib/et/MODULE_LICENSE_MIT
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/lib/et/MODULE_LICENSE_MIT
diff --git a/lib/et/Makefile.in b/lib/et/Makefile.in
index ff99f5d0..a7e273cd 100644
--- a/lib/et/Makefile.in
+++ b/lib/et/Makefile.in
@@ -43,7 +43,6 @@ BSDLIB_INSTALL_DIR = $(root_libdir)
.c.o:
$(E) " CC $<"
$(Q) $(CC) $(ALL_CFLAGS) -c $< -o $@
- $(Q) $(CHECK_CMD) $(ALL_CFLAGS) $<
@PROFILE_CMT@ $(Q) $(CC) $(ALL_CFLAGS) -g -pg -o profiled/$*.o -c $<
@CHECKER_CMT@ $(Q) $(CC) $(ALL_CFLAGS) -checker -g -o checker/$*.o -c $<
@ELF_CMT@ $(Q) $(CC) $(ALL_CFLAGS) -fPIC -o elfshared/$*.o -c $<
@@ -60,34 +59,15 @@ compile_et: $(DEP_SUBSTITUTE) $(srcdir)/compile_et.sh.in
$(Q) $(SUBSTITUTE) $(srcdir)/compile_et.sh.in compile_et
$(Q) $(CHMOD) +x compile_et
-DVI=texi2dvi
-DVIPS=dvips -o "$@"
-INFO=@MAKEINFO@
-HTML=makeinfo --html --no-split
-PS2PDF=ps2pdf
-
com_err.ps : com_err.dvi
com_err.dvi: com_err.texinfo
-com_err.info: $(srcdir)/com_err.texinfo
- $(E) " MAKEINFO $@"
- -$(Q) $(INFO) $(srcdir)/com_err.texinfo
-
-com_err.dvi: $(srcdir)/com_err.texinfo
- $(E) " TEXI2DVI $@"
- -$(Q) $(DVI) $(srcdir)/com_err.texinfo
-
-com_err.ps: com_err.dvi
- $(E) " DVIPS $@"
- -$(Q) $(DVIPS) com_err.dvi
-
-com_err.pdf: com_err.ps
- $(E) " PS2PDF $@"
- -$(Q) $(PS2PDF) com_err.ps
-
-com_err.html: $(srcdir)/com_err.texinfo
- $(E) " MAKEINFO $@"
- -$(Q) $(HTML) $(srcdir)/com_err.texinfo
+com_err_abt.html: $(srcdir)/com_err.texinfo
+ $(E) " TEXI2HTML $@"
+ -$(Q) texi2html -split_chapter $(srcdir)/com_err.texinfo
+ -$(Q) if test -d com_err ; then \
+ mv com_err/* . ; rmdir com_err ; \
+ fi
com_err.pc: $(srcdir)/com_err.pc.in $(top_builddir)/config.status
$(E) " CONFIG.STATUS $@"
@@ -116,8 +96,6 @@ install:: compile_et libcom_err.a $(HFILES) installdirs com_err.pc
echo " INSTALL_DATA $(includedir)/et/$$i"; \
$(INSTALL_DATA) $(srcdir)/$$i $(DESTDIR)$(includedir)/et/$$i; \
done
- $(Q) (cd $(DESTDIR)$(includedir) ;\
- $(LN) $(LINK_INSTALL_FLAGS) et/com_err.h . )
$(Q) for i in $(SHARE_FILES); do \
echo " INSTALL_DATA $(datadir)/et/$$i"; \
$(INSTALL_DATA) $(srcdir)/$$i $(DESTDIR)$(datadir)/et/$$i; \
@@ -153,9 +131,7 @@ check:: compile_et
clean::
$(RM) -f compile_et libcom_err.a libcom_err_p.a com_err.info
$(RM) -f $(OBJS) profiled/*
- $(RM) -f *~ \#* *.bak *.otl *.aux *.toc *.PS *.dvi *.ps TAGS *.ln \
- *.html *.cp *.fn *.fns *.ky *.log *.pc *.pg *.toc *.tp *.vr \
- *.pdf
+ $(RM) -f *~ \#* *.bak *.otl *.aux *.toc *.PS *.dvi *.ps TAGS *.ln *.html
$(RM) -f ../libcom_err.a ../libcom_err_p.a
mostlyclean:: clean
@@ -170,16 +146,12 @@ $(OBJS): subdirs
# Makefile dependencies follow. This must be the last section in
# the Makefile.in file
#
-error_message.o: $(srcdir)/error_message.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/com_err.h $(srcdir)/error_table.h \
- $(srcdir)/internal.h
-et_name.o: $(srcdir)/et_name.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/com_err.h $(srcdir)/error_table.h \
+error_message.o: $(srcdir)/error_message.c $(srcdir)/com_err.h \
+ $(srcdir)/error_table.h $(srcdir)/internal.h
+et_name.o: $(srcdir)/et_name.c $(srcdir)/com_err.h $(srcdir)/error_table.h \
$(srcdir)/internal.h
-init_et.o: $(srcdir)/init_et.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/com_err.h $(srcdir)/error_table.h
-com_err.o: $(srcdir)/com_err.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/com_err.h $(srcdir)/error_table.h \
+init_et.o: $(srcdir)/init_et.c $(srcdir)/com_err.h $(srcdir)/error_table.h
+com_err.o: $(srcdir)/com_err.c $(srcdir)/com_err.h $(srcdir)/error_table.h \
$(srcdir)/internal.h
-com_right.o: $(srcdir)/com_right.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/com_err.h $(srcdir)/error_table.h
+com_right.o: $(srcdir)/com_right.c $(srcdir)/com_err.h \
+ $(srcdir)/error_table.h
diff --git a/lib/et/com_err.c b/lib/et/com_err.c
index 5cc5c089..e5af13cd 100644
--- a/lib/et/com_err.c
+++ b/lib/et/com_err.c
@@ -84,7 +84,8 @@ void com_err (const char *whoami,
va_end(pvar);
}
-errf set_com_err_hook(errf new_proc)
+errf set_com_err_hook (new_proc)
+ errf new_proc;
{
errf x = com_err_hook;
@@ -96,7 +97,7 @@ errf set_com_err_hook(errf new_proc)
return x;
}
-errf reset_com_err_hook(void) {
+errf reset_com_err_hook () {
errf x = com_err_hook;
com_err_hook = default_com_err_proc;
return x;
diff --git a/lib/et/com_err.h b/lib/et/com_err.h
index 27a36ea0..eb2106fa 100644
--- a/lib/et/com_err.h
+++ b/lib/et/com_err.h
@@ -43,8 +43,6 @@ extern void (*set_com_err_hook (void (*) (const char *, long,
extern void (*reset_com_err_hook (void)) (const char *, long,
const char *, va_list);
extern int init_error_table(const char * const *msgs, long base, int count);
-extern char *(*set_com_err_gettext (char *(*) (const char *)))
- (const char *);
extern errcode_t add_error_table(const struct error_table * et);
extern errcode_t remove_error_table(const struct error_table * et);
diff --git a/lib/et/com_err.pc.in b/lib/et/com_err.pc.in
index 86df8a2a..772efa1c 100644
--- a/lib/et/com_err.pc.in
+++ b/lib/et/com_err.pc.in
@@ -7,6 +7,6 @@ Name: com_err
Description: Common error description library
Version: @E2FSPROGS_VERSION@
Requires:
-Cflags: -I${includedir}/et -I${includedir}
+Cflags: -I${includedir}/et
Libs: -L${libdir} -lcom_err
Libs.private: @SEM_INIT_LIB@
diff --git a/lib/et/com_err.texinfo b/lib/et/com_err.texinfo
index c9d3fcaf..7e6a4944 100644
--- a/lib/et/com_err.texinfo
+++ b/lib/et/com_err.texinfo
@@ -14,7 +14,7 @@
@c Software Foundation, and is under different copyright restrictions
@c from the rest of this package.)
-@setfilename com_err.info
+@setfilename com_err
@settitle A Common Error Description Library for UNIX
@ifinfo
@@ -24,10 +24,14 @@
@end direntry
@end ifinfo
-@c smallbook
-
@iftex
-@finalout
+@tolerance 10000
+
+@c Mutate section headers...
+@begingroup
+ @catcode#=6
+ @gdef@secheading#1#2#3{@secheadingi {#3@enspace #1}}
+@endgroup
@end iftex
@ifinfo
@@ -57,7 +61,6 @@ notice identical to this one except for the removal of this paragraph
(this paragraph not being relevant to the printed manual).
@end ignore
-@end ifinfo
@setchapternewpage odd
@@ -111,6 +114,7 @@ from the remainder of this package.
@end titlepage
+
@node Top, Why com_err?, (dir), (dir)
@top A Common Error Description Library for UNIX
@@ -129,10 +133,12 @@ This manual documents the com_err library.
* Acknowledgements::
@end menu
+@end ifinfo
+
@page
@node Why com_err?, Error codes, Top, Top
-@chapter Why com_err?
+@section Why com_err?
In building application software packages, a programmer often has to
deal with a number of libraries, each of which can use a different
@@ -168,7 +174,7 @@ of the form @samp{unknown code foo 32}, where @samp{foo} would be the name
of the table.
@node Error codes, Error table source file, Why com_err?, Top
-@chapter Error codes
+@section Error codes
Error codes themselves are 32 bit (signed) integers, of which the high
order 24 bits are an identifier of which error table the error code is
@@ -197,7 +203,7 @@ much other software that assumes an ANSI-C environment base) without
significant effort.
@node Error table source file, The error-table compiler, Error codes, Top
-@chapter Error table source file
+@section Error table source file
The error table source file begins with the declaration of the table name,
as
@@ -235,7 +241,7 @@ error table might be:
@end example
@node The error-table compiler, Run-time support routines, Error table source file, Top
-@chapter The error-table compiler
+@section The error-table compiler
The error table compiler is named @code{compile_et}. It takes one
argument, the pathname of a file (ending in @samp{.et}, e.g.,
@@ -249,7 +255,7 @@ codes defined; the object module generated from the C code may be linked in
to a program which wishes to use the printed forms of the error codes.
@node Run-time support routines, Coding Conventions, The error-table compiler, Top
-@chapter Run-time support routines
+@section Run-time support routines
Any source file which uses the routines supplied with or produced by the
com_err package should include the header file @file{<com_err.h>}. It
@@ -300,7 +306,9 @@ left to circumstances which render @code{com_err} (below) unusable.
@end deftypefun
-@deftypefun void com_err (const char *@var{whoami}, long @var{error_code}, const char *@var{format}, ...);
+@deftypefun
+void com_err (const char *@var{whoami}, long @var{error_code},
+ const char *@var{format}, ...);
This routine provides an alternate way to print error messages to
standard error; it allows the error message to be passed in as a
@@ -313,7 +321,8 @@ printed. @var{format} may not be omitted.
@end deftypefun
-@deftypefun void com_err_va (const char *@var{whoami}, long @var{error_code}, const char *@var{format}, va_list @var{args});
+@deftypefun
+void com_err_va (const char *@var{whoami}, long @var{error_code}, const char *@var{format}, va_list @var{args});
This routine provides an interface, equivalent to @code{com_err} above,
which may be used by higher-level variadic functions (functions which
@@ -321,7 +330,7 @@ accept variable numbers of arguments).
@end deftypefun
-@deftypefun void *set_com_err_hook (void (*@var{proc}) (const char *@var{whoami}, long @var{error_code}, va_list @var{args}) (const char *@var{whoami}, long @var{error_code}, va_list @var{args}));
+@deftypefun void (*set_com_err_hook (void (*@var{proc}) (const char *@var{whoami}, long @var{error_code}, va_list @var{args}))) (const char *@var{whoami}, long @var{error_code}, va_list @var{args});
@deftypefunx void reset_com_err_hook ();
@@ -381,7 +390,7 @@ the ANSI C library).
@end deftypefun
@node Coding Conventions, Building and Installation, Run-time support routines, Top
-@chapter Coding Conventions
+@section Coding Conventions
The following conventions are just some general stylistic conventions
to follow when writing robust libraries and programs. Conventions
@@ -492,7 +501,7 @@ error:
@end example
@node Building and Installation, Bug Reports, Coding Conventions, Top
-@chapter Building and Installation
+@section Building and Installation
The distribution of this package will probably be done as a compressed
``tar''-format file available via anonymous FTP from SIPB.MIT.EDU.
@@ -505,7 +514,7 @@ installed for use; @samp{com_err.3} and @samp{compile_et.1} can also be
installed as manual pages.
@node Bug Reports, Acknowledgements, Building and Installation, Top
-@chapter Bug Reports
+@section Bug Reports
The principal author of this library is: Ken
Raeburn, @t{raeburn@@MIT.EDU}.
@@ -515,7 +524,7 @@ Ts'o, and so bugs and comments should be sent to @t{tytso@@thunk.org}.
@node Acknowledgements, , Bug Reports, Top
-@chapter Acknowledgements
+@section Acknowledgements
I would like to thank: Bill Sommerfeld, for his help with some of this
documentation, and catching some of the bugs the first time around;
diff --git a/lib/et/error_message.c b/lib/et/error_message.c
index 16a4bcfb..1b08c166 100644
--- a/lib/et/error_message.c
+++ b/lib/et/error_message.c
@@ -16,9 +16,6 @@
* express or implied warranty.
*/
-#if HAVE_SECURE_GETENV
-#define _GNU_SOURCE
-#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -100,20 +97,6 @@ int et_list_unlock(void)
return 0;
}
-typedef char *(*gettextf) (const char *);
-
-static gettextf com_err_gettext = NULL;
-
-gettextf set_com_err_gettext(gettextf new_proc)
-{
- gettextf x = com_err_gettext;
-
- com_err_gettext = new_proc;
-
- return x;
-}
-
-
const char * error_message (errcode_t code)
{
int offset;
@@ -147,10 +130,7 @@ const char * error_message (errcode_t code)
} else {
const char *msg = et->table->msgs[offset];
et_list_unlock();
- if (com_err_gettext)
- return (*com_err_gettext)(msg);
- else
- return msg;
+ return msg;
}
}
}
@@ -162,10 +142,7 @@ const char * error_message (errcode_t code)
} else {
const char *msg = et->table->msgs[offset];
et_list_unlock();
- if (com_err_gettext)
- return (*com_err_gettext)(msg);
- else
- return msg;
+ return msg;
}
}
}
@@ -210,9 +187,7 @@ static char *safe_getenv(const char *arg)
#endif
#endif
-#if defined(HAVE_SECURE_GETENV)
- return secure_getenv(arg);
-#elif defined(HAVE___SECURE_GETENV)
+#ifdef HAVE___SECURE_GETENV
return __secure_getenv(arg);
#else
return getenv(arg);
diff --git a/lib/et/error_table.h b/lib/et/error_table.h
index 24e4762a..4f109911 100644
--- a/lib/et/error_table.h
+++ b/lib/et/error_table.h
@@ -18,7 +18,7 @@ struct et_list {
struct et_list *next;
const struct error_table *table;
};
-extern struct et_list *_et_list, *_et_dynamic_list;
+extern struct et_list * _et_list;
#define ERRCODE_RANGE 8 /* # of bits to shift table number */
#define BITS_PER_CHAR 6 /* # bits to shift per character in name */
diff --git a/lib/et/et_c.awk b/lib/et/et_c.awk
index 99c33baf..ea2e6095 100644
--- a/lib/et/et_c.awk
+++ b/lib/et/et_c.awk
@@ -129,8 +129,6 @@ c2n["_"]=63
print "" > outfile
print "#include <stdlib.h>" > outfile
print "" > outfile
- print "#define N_(a) a" > outfile
- print "" > outfile
print "static const char * const text[] = {" > outfile
table_item_count = 0
}
@@ -143,7 +141,7 @@ c2n["_"]=63
(continuation == 1) && ($0 ~ /"[ \t]*$/) {
# printf "\t\t\"%s,\n", $0 > outfile
- printf "\tN_(%s),\n", cont_buf $0 > outfile
+ printf "\t%s,\n", cont_buf $0 > outfile
continuation = 0;
}
@@ -164,7 +162,7 @@ c2n["_"]=63
text = text FS $i
}
text=substr(text,2,length(text)-1);
- printf "\tN_(%s),\n", text > outfile
+ printf "\t%s,\n", text > outfile
table_item_count++
}
@@ -192,7 +190,7 @@ c2n["_"]=63
{
if (skipone) {
- printf "\tN_(%s),\n", $0 > outfile
+ printf "\t%s,\n", $0 > outfile
}
skipone=0
}
@@ -208,7 +206,7 @@ c2n["_"]=63
/^[ \t]*(index)[ \t]+[A-Z_0-9]+/ {
new_idx = $2
for (i = table_item_count ; i < new_idx; i++) {
- printf "\tN_(\"Reserved %s error (%d)\"),\n", \
+ printf "\t\"Reserved %s error (%d)\",\n", \
table_name, table_item_count++ > outfile
}
}
diff --git a/lib/et/et_name.c b/lib/et/et_name.c
index 3a0790e2..18883269 100644
--- a/lib/et/et_name.c
+++ b/lib/et/et_name.c
@@ -20,7 +20,8 @@ static const char char_set[] =
static char buf[6];
-const char * error_table_name(errcode_t num)
+const char * error_table_name(num)
+ errcode_t num;
{
int ch;
int i;
diff --git a/lib/et/test_cases/continuation.c b/lib/et/test_cases/continuation.c
index 12078977..0529dd08 100644
--- a/lib/et/test_cases/continuation.c
+++ b/lib/et/test_cases/continuation.c
@@ -5,10 +5,8 @@
#include <stdlib.h>
-#define N_(a) a
-
static const char * const text[] = {
- N_("New password was found in a dictionary of possible passwords and\ntherefore may be easily guessed. Please choose another password.\nSee the ovpasswd man page for help in choosing a good password."),
+ "New password was found in a dictionary of possible passwords and\ntherefore may be easily guessed. Please choose another password.\nSee the ovpasswd man page for help in choosing a good password.",
0
};
diff --git a/lib/et/test_cases/heimdal.c b/lib/et/test_cases/heimdal.c
index d9be4ce1..22c75738 100644
--- a/lib/et/test_cases/heimdal.c
+++ b/lib/et/test_cases/heimdal.c
@@ -5,91 +5,89 @@
#include <stdlib.h>
-#define N_(a) a
-
static const char * const text[] = {
- N_("Kerberos successful"),
- N_("Kerberos principal expired"),
- N_("Kerberos service expired"),
- N_("Kerberos auth expired"),
- N_("Incorrect kerberos master key version"),
- N_("Incorrect kerberos master key version"),
- N_("Incorrect kerberos master key version"),
- N_("Kerberos error: byte order unknown"),
- N_("Kerberos principal unknown"),
- N_("Kerberos principal not unique"),
- N_("Kerberos principal has null key"),
- N_("Reserved krb error (11)"),
- N_("Reserved krb error (12)"),
- N_("Reserved krb error (13)"),
- N_("Reserved krb error (14)"),
- N_("Reserved krb error (15)"),
- N_("Reserved krb error (16)"),
- N_("Reserved krb error (17)"),
- N_("Reserved krb error (18)"),
- N_("Reserved krb error (19)"),
- N_("Generic error from Kerberos KDC"),
- N_("Can't read Kerberos ticket file"),
- N_("Can't find Kerberos ticket or TGT"),
- N_("Reserved krb error (23)"),
- N_("Reserved krb error (24)"),
- N_("Reserved krb error (25)"),
- N_("Kerberos TGT Expired"),
- N_("Reserved krb error (27)"),
- N_("Reserved krb error (28)"),
- N_("Reserved krb error (29)"),
- N_("Reserved krb error (30)"),
- N_("Kerberos error: Can't decode authenticator"),
- N_("Kerberos ticket expired"),
- N_("Kerberos ticket not yet valid"),
- N_("Kerberos error: Repeated request"),
- N_("The kerberos ticket isn't for us"),
- N_("Kerberos request inconsistent"),
- N_("Kerberos error: delta_t too big"),
- N_("Kerberos error: incorrect net address"),
- N_("Kerberos protocol version mismatch"),
- N_("Kerberos error: invalid msg type"),
- N_("Kerberos error: message stream modified"),
- N_("Kerberos error: message out of order"),
- N_("Kerberos error: unauthorized request"),
- N_("Reserved krb error (44)"),
- N_("Reserved krb error (45)"),
- N_("Reserved krb error (46)"),
- N_("Reserved krb error (47)"),
- N_("Reserved krb error (48)"),
- N_("Reserved krb error (49)"),
- N_("Reserved krb error (50)"),
- N_("Kerberos error: current PW is null"),
- N_("Kerberos error: Incorrect current password"),
- N_("Kerberos protocol error"),
- N_("Error returned by Kerberos KDC"),
- N_("Null Kerberos ticket returned by KDC"),
- N_("Kerberos error: Retry count exceeded"),
- N_("Kerberos error: Can't send request"),
- N_("Reserved krb error (58)"),
- N_("Reserved krb error (59)"),
- N_("Reserved krb error (60)"),
- N_("Kerberos error: not all tickets returned"),
- N_("Kerberos error: incorrect password"),
- N_("Kerberos error: Protocol Error"),
- N_("Reserved krb error (64)"),
- N_("Reserved krb error (65)"),
- N_("Reserved krb error (66)"),
- N_("Reserved krb error (67)"),
- N_("Reserved krb error (68)"),
- N_("Reserved krb error (69)"),
- N_("Other error"),
- N_("Don't have Kerberos ticket-granting ticket"),
- N_("Reserved krb error (72)"),
- N_("Reserved krb error (73)"),
- N_("Reserved krb error (74)"),
- N_("Reserved krb error (75)"),
- N_("No ticket file found"),
- N_("Couldn't access ticket file"),
- N_("Couldn't lock ticket file"),
- N_("Bad ticket file format"),
- N_("tf_init not called first"),
- N_("Bad Kerberos name format"),
+ "Kerberos successful",
+ "Kerberos principal expired",
+ "Kerberos service expired",
+ "Kerberos auth expired",
+ "Incorrect kerberos master key version",
+ "Incorrect kerberos master key version",
+ "Incorrect kerberos master key version",
+ "Kerberos error: byte order unknown",
+ "Kerberos principal unknown",
+ "Kerberos principal not unique",
+ "Kerberos principal has null key",
+ "Reserved krb error (11)",
+ "Reserved krb error (12)",
+ "Reserved krb error (13)",
+ "Reserved krb error (14)",
+ "Reserved krb error (15)",
+ "Reserved krb error (16)",
+ "Reserved krb error (17)",
+ "Reserved krb error (18)",
+ "Reserved krb error (19)",
+ "Generic error from Kerberos KDC",
+ "Can't read Kerberos ticket file",
+ "Can't find Kerberos ticket or TGT",
+ "Reserved krb error (23)",
+ "Reserved krb error (24)",
+ "Reserved krb error (25)",
+ "Kerberos TGT Expired",
+ "Reserved krb error (27)",
+ "Reserved krb error (28)",
+ "Reserved krb error (29)",
+ "Reserved krb error (30)",
+ "Kerberos error: Can't decode authenticator",
+ "Kerberos ticket expired",
+ "Kerberos ticket not yet valid",
+ "Kerberos error: Repeated request",
+ "The kerberos ticket isn't for us",
+ "Kerberos request inconsistent",
+ "Kerberos error: delta_t too big",
+ "Kerberos error: incorrect net address",
+ "Kerberos protocol version mismatch",
+ "Kerberos error: invalid msg type",
+ "Kerberos error: message stream modified",
+ "Kerberos error: message out of order",
+ "Kerberos error: unauthorized request",
+ "Reserved krb error (44)",
+ "Reserved krb error (45)",
+ "Reserved krb error (46)",
+ "Reserved krb error (47)",
+ "Reserved krb error (48)",
+ "Reserved krb error (49)",
+ "Reserved krb error (50)",
+ "Kerberos error: current PW is null",
+ "Kerberos error: Incorrect current password",
+ "Kerberos protocol error",
+ "Error returned by Kerberos KDC",
+ "Null Kerberos ticket returned by KDC",
+ "Kerberos error: Retry count exceeded",
+ "Kerberos error: Can't send request",
+ "Reserved krb error (58)",
+ "Reserved krb error (59)",
+ "Reserved krb error (60)",
+ "Kerberos error: not all tickets returned",
+ "Kerberos error: incorrect password",
+ "Kerberos error: Protocol Error",
+ "Reserved krb error (64)",
+ "Reserved krb error (65)",
+ "Reserved krb error (66)",
+ "Reserved krb error (67)",
+ "Reserved krb error (68)",
+ "Reserved krb error (69)",
+ "Other error",
+ "Don't have Kerberos ticket-granting ticket",
+ "Reserved krb error (72)",
+ "Reserved krb error (73)",
+ "Reserved krb error (74)",
+ "Reserved krb error (75)",
+ "No ticket file found",
+ "Couldn't access ticket file",
+ "Couldn't lock ticket file",
+ "Bad ticket file format",
+ "tf_init not called first",
+ "Bad Kerberos name format",
0
};
diff --git a/lib/et/test_cases/heimdal2.c b/lib/et/test_cases/heimdal2.c
index a8d4c111..eba3d62e 100644
--- a/lib/et/test_cases/heimdal2.c
+++ b/lib/et/test_cases/heimdal2.c
@@ -5,77 +5,75 @@
#include <stdlib.h>
-#define N_(a) a
-
static const char * const text[] = {
- N_("$Id: kadm_err.et,v 1.5 1998/01/16 23:11:27 joda Exp $"),
- N_("Cannot fetch local realm"),
- N_("Unable to fetch credentials"),
- N_("Bad key supplied"),
- N_("Can't encrypt data"),
- N_("Cannot encode/decode authentication info"),
- N_("Principal attemping change is in wrong realm"),
- N_("Packet is too large"),
- N_("Version number is incorrect"),
- N_("Checksum does not match"),
- N_("Unsealing private data failed"),
- N_("Unsupported operation"),
- N_("Could not find administrating host"),
- N_("Administrating host name is unknown"),
- N_("Could not find service name in services database"),
- N_("Could not create socket"),
- N_("Could not connect to server"),
- N_("Could not fetch local socket address"),
- N_("Could not fetch master key"),
- N_("Could not verify master key"),
- N_("Entry already exists in database"),
- N_("Database store error"),
- N_("Database read error"),
- N_("Insufficient access to perform requested operation"),
- N_("Data is available for return to client"),
- N_("No such entry in the database"),
- N_("Memory exhausted"),
- N_("Could not fetch system hostname"),
- N_("Could not bind port"),
- N_("Length mismatch problem"),
- N_("Illegal use of wildcard"),
- N_("Database is locked or in use--try again later"),
- N_("Insecure password rejected"),
- N_("Cleartext password and DES key did not match"),
- N_("Invalid principal for change srvtab request"),
- N_("Attempt do delete immutable principal"),
- N_("Reserved kadm error (36)"),
- N_("Reserved kadm error (37)"),
- N_("Reserved kadm error (38)"),
- N_("Reserved kadm error (39)"),
- N_("Reserved kadm error (40)"),
- N_("Reserved kadm error (41)"),
- N_("Reserved kadm error (42)"),
- N_("Reserved kadm error (43)"),
- N_("Reserved kadm error (44)"),
- N_("Reserved kadm error (45)"),
- N_("Reserved kadm error (46)"),
- N_("Reserved kadm error (47)"),
- N_("Reserved kadm error (48)"),
- N_("Reserved kadm error (49)"),
- N_("Reserved kadm error (50)"),
- N_("Reserved kadm error (51)"),
- N_("Reserved kadm error (52)"),
- N_("Reserved kadm error (53)"),
- N_("Reserved kadm error (54)"),
- N_("Reserved kadm error (55)"),
- N_("Reserved kadm error (56)"),
- N_("Reserved kadm error (57)"),
- N_("Reserved kadm error (58)"),
- N_("Reserved kadm error (59)"),
- N_("Reserved kadm error (60)"),
- N_("Reserved kadm error (61)"),
- N_("Reserved kadm error (62)"),
- N_("Reserved kadm error (63)"),
- N_("Null passwords are not allowed"),
- N_("Password is too short"),
- N_("Too few character classes in password"),
- N_("Password is in the password dictionary"),
+ "$Id: kadm_err.et,v 1.5 1998/01/16 23:11:27 joda Exp $",
+ "Cannot fetch local realm",
+ "Unable to fetch credentials",
+ "Bad key supplied",
+ "Can't encrypt data",
+ "Cannot encode/decode authentication info",
+ "Principal attemping change is in wrong realm",
+ "Packet is too large",
+ "Version number is incorrect",
+ "Checksum does not match",
+ "Unsealing private data failed",
+ "Unsupported operation",
+ "Could not find administrating host",
+ "Administrating host name is unknown",
+ "Could not find service name in services database",
+ "Could not create socket",
+ "Could not connect to server",
+ "Could not fetch local socket address",
+ "Could not fetch master key",
+ "Could not verify master key",
+ "Entry already exists in database",
+ "Database store error",
+ "Database read error",
+ "Insufficient access to perform requested operation",
+ "Data is available for return to client",
+ "No such entry in the database",
+ "Memory exhausted",
+ "Could not fetch system hostname",
+ "Could not bind port",
+ "Length mismatch problem",
+ "Illegal use of wildcard",
+ "Database is locked or in use--try again later",
+ "Insecure password rejected",
+ "Cleartext password and DES key did not match",
+ "Invalid principal for change srvtab request",
+ "Attempt do delete immutable principal",
+ "Reserved kadm error (36)",
+ "Reserved kadm error (37)",
+ "Reserved kadm error (38)",
+ "Reserved kadm error (39)",
+ "Reserved kadm error (40)",
+ "Reserved kadm error (41)",
+ "Reserved kadm error (42)",
+ "Reserved kadm error (43)",
+ "Reserved kadm error (44)",
+ "Reserved kadm error (45)",
+ "Reserved kadm error (46)",
+ "Reserved kadm error (47)",
+ "Reserved kadm error (48)",
+ "Reserved kadm error (49)",
+ "Reserved kadm error (50)",
+ "Reserved kadm error (51)",
+ "Reserved kadm error (52)",
+ "Reserved kadm error (53)",
+ "Reserved kadm error (54)",
+ "Reserved kadm error (55)",
+ "Reserved kadm error (56)",
+ "Reserved kadm error (57)",
+ "Reserved kadm error (58)",
+ "Reserved kadm error (59)",
+ "Reserved kadm error (60)",
+ "Reserved kadm error (61)",
+ "Reserved kadm error (62)",
+ "Reserved kadm error (63)",
+ "Null passwords are not allowed",
+ "Password is too short",
+ "Too few character classes in password",
+ "Password is in the password dictionary",
0
};
diff --git a/lib/et/test_cases/heimdal3.c b/lib/et/test_cases/heimdal3.c
index b8b9b735..18a9ccc6 100644
--- a/lib/et/test_cases/heimdal3.c
+++ b/lib/et/test_cases/heimdal3.c
@@ -5,11 +5,9 @@
#include <stdlib.h>
-#define N_(a) a
-
static const char * const text[] = {
- N_("Test message 1"),
- N_("Test message 2"),
+ "Test message 1",
+ "Test message 2",
0
};
diff --git a/lib/et/test_cases/imap_err.c b/lib/et/test_cases/imap_err.c
index 6f576d33..82a6ad06 100644
--- a/lib/et/test_cases/imap_err.c
+++ b/lib/et/test_cases/imap_err.c
@@ -5,39 +5,37 @@
#include <stdlib.h>
-#define N_(a) a
-
static const char * const text[] = {
- N_( "System I/O error"),
- N_( "Permission denied"),
- N_( "Over quota"),
- N_( "Too many user flags in mailbox"),
- N_( "Mailbox has an invalid format"),
- N_( "Operation is not supported on mailbox"),
- N_( "Mailbox does not exist"),
- N_( "Mailbox already exists"),
- N_( "Invalid mailbox name"),
- N_( "Mailbox is locked by POP server"),
- N_( "Unknown/invalid partition"),
- N_( "Invalid identifier"),
- N_( "Message contains NUL characters"),
- N_( "Message contains bare newlines"),
- N_( "Message contains non-ASCII characters in headers"),
- N_( "Message contains invalid header"),
- N_( "Message has no header/body separator"),
- N_( "Quota root does not exist"),
- N_( "Unrecognized character set"),
- N_( "Invalid user"),
- N_( "Login incorrect"),
- N_( "Anonymous login is not permitted"),
- N_( "Unsupported quota resource"),
- N_( "Mailbox is over quota"),
- N_( "Mailbox is at %d%% of quota"),
- N_( "Message %d no longer exists"),
- N_( "Unable to checkpoint \\Seen state"),
- N_( "Unable to preserve \\Seen state"),
- N_( "LOGOUT received"),
- N_( "Completed"),
+ "System I/O error",
+ "Permission denied",
+ "Over quota",
+ "Too many user flags in mailbox",
+ "Mailbox has an invalid format",
+ "Operation is not supported on mailbox",
+ "Mailbox does not exist",
+ "Mailbox already exists",
+ "Invalid mailbox name",
+ "Mailbox is locked by POP server",
+ "Unknown/invalid partition",
+ "Invalid identifier",
+ "Message contains NUL characters",
+ "Message contains bare newlines",
+ "Message contains non-ASCII characters in headers",
+ "Message contains invalid header",
+ "Message has no header/body separator",
+ "Quota root does not exist",
+ "Unrecognized character set",
+ "Invalid user",
+ "Login incorrect",
+ "Anonymous login is not permitted",
+ "Unsupported quota resource",
+ "Mailbox is over quota",
+ "Mailbox is at %d%% of quota",
+ "Message %d no longer exists",
+ "Unable to checkpoint \\Seen state",
+ "Unable to preserve \\Seen state",
+ "LOGOUT received",
+ "Completed",
0
};
diff --git a/lib/et/test_cases/simple.c b/lib/et/test_cases/simple.c
index 10ab1a36..f182c6f9 100644
--- a/lib/et/test_cases/simple.c
+++ b/lib/et/test_cases/simple.c
@@ -5,31 +5,29 @@
#include <stdlib.h>
-#define N_(a) a
-
static const char * const text[] = {
- N_( "Can't read ticket file"),
- N_( "Can't find ticket or TGT"),
- N_( "TGT expired"),
- N_( "Can't decode authenticator"),
- N_( "Ticket expired"),
- N_( "Repeated request"),
- N_( "The ticket isn't for us"),
- N_( "Request is inconsistent"),
- N_( "Delta-T too big"),
- N_( "Incorrect net address"),
- N_( "Protocol version mismatch"),
- N_( "Invalid message type"),
- N_( "Message stream modified"),
- N_( "Message out of order"),
- N_( "Unauthorized request"),
- N_( "Current password is null"),
- N_( "Incorrect current password"),
- N_( "Protocol error"),
- N_( "Error returned by KDC"),
- N_( "Null ticket returned by KDC"),
- N_( "Retry count exceeded"),
- N_( "Can't send request"),
+ "Can't read ticket file",
+ "Can't find ticket or TGT",
+ "TGT expired",
+ "Can't decode authenticator",
+ "Ticket expired",
+ "Repeated request",
+ "The ticket isn't for us",
+ "Request is inconsistent",
+ "Delta-T too big",
+ "Incorrect net address",
+ "Protocol version mismatch",
+ "Invalid message type",
+ "Message stream modified",
+ "Message out of order",
+ "Unauthorized request",
+ "Current password is null",
+ "Incorrect current password",
+ "Protocol error",
+ "Error returned by KDC",
+ "Null ticket returned by KDC",
+ "Retry count exceeded",
+ "Can't send request",
0
};
diff --git a/lib/et/texinfo.tex b/lib/et/texinfo.tex
index dddd0140..838160c9 100644
--- a/lib/et/texinfo.tex
+++ b/lib/et/texinfo.tex
@@ -1,373 +1,209 @@
-% texinfo.tex -- TeX macros to handle Texinfo files.
-%
-% Load plain if necessary, i.e., if running under initex.
-\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
-%
-\def\texinfoversion{2006-02-13.16}
-%
-% Copyright (C) 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
-% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free
-% Software Foundation, Inc.
-%
-% This texinfo.tex file is free software; you can redistribute it and/or
-% modify it under the terms of the GNU General Public License as
-% published by the Free Software Foundation; either version 2, or (at
-% your option) any later version.
-%
-% This texinfo.tex file is distributed in the hope that it will be
-% useful, but WITHOUT ANY WARRANTY; without even the implied warranty
-% of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-% General Public License for more details.
-%
-% You should have received a copy of the GNU General Public License
-% along with this texinfo.tex file; see the file COPYING. If not, write
-% to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-% Boston, MA 02110-1301, USA.
-%
-% As a special exception, when this file is read by TeX when processing
-% a Texinfo source document, you may use the result without
-% restriction. (This has been our intent since Texinfo was invented.)
-%
-% Please try the latest version of texinfo.tex before submitting bug
-% reports; you can get the latest version from:
-% http://www.gnu.org/software/texinfo/ (the Texinfo home page), or
-% ftp://tug.org/tex/texinfo.tex
-% (and all CTAN mirrors, see http://www.ctan.org).
-% The texinfo.tex in any given distribution could well be out
-% of date, so if that's what you're using, please check.
-%
-% Send bug reports to bug-texinfo@gnu.org. Please include including a
-% complete document in each bug report with which we can reproduce the
-% problem. Patches are, of course, greatly appreciated.
-%
-% To process a Texinfo manual with TeX, it's most reliable to use the
-% texi2dvi shell script that comes with the distribution. For a simple
-% manual foo.texi, however, you can get away with this:
-% tex foo.texi
-% texindex foo.??
-% tex foo.texi
-% tex foo.texi
-% dvips foo.dvi -o # or whatever; this makes foo.ps.
-% The extra TeX runs get the cross-reference information correct.
-% Sometimes one run after texindex suffices, and sometimes you need more
-% than two; texi2dvi does it as many times as necessary.
-%
-% It is possible to adapt texinfo.tex for other languages, to some
-% extent. You can get the existing language-specific files from the
-% full Texinfo distribution.
-%
-% The GNU Texinfo home page is http://www.gnu.org/software/texinfo.
-
-
-\message{Loading texinfo [version \texinfoversion]:}
+%% TeX macros to handle texinfo files
+
+% Copyright (C) 1985, 1986, 1988 Richard M. Stallman
+
+% NO WARRANTY
+
+% BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
+%NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT
+%WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
+%RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS"
+%WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+%BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+%FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY
+%AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
+%DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
+%CORRECTION.
+
+% IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
+%STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
+%WHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
+%LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
+%OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+%USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
+%DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
+%A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
+%PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
+%DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
+
+% GENERAL PUBLIC LICENSE TO COPY
+
+% 1. You may copy and distribute verbatim copies of this source file
+%as you receive it, in any medium, provided that you conspicuously
+%and appropriately publish on each copy a valid copyright notice
+%"Copyright (C) 1986 Richard M. Stallman"; and include
+%following the copyright notice a verbatim copy of the above disclaimer
+%of warranty and of this License.
+
+% 2. You may modify your copy or copies of this source file or
+%any portion of it, and copy and distribute such modifications under
+%the terms of Paragraph 1 above, provided that you also do the following:
+
+% a) cause the modified files to carry prominent notices stating
+% that you changed the files and the date of any change; and
+
+% b) cause the whole of any work that you distribute or publish,
+% that in whole or in part contains or is a derivative of this
+% program or any part thereof, to be licensed at no charge to all
+% third parties on terms identical to those contained in this
+% License Agreement (except that you may choose to grant more extensive
+% warranty protection to some or all third parties, at your option).
+
+% c) You may charge a distribution fee for the physical act of
+% transferring a copy, and you may at your option offer warranty
+% protection in exchange for a fee.
+
+%Mere aggregation of another unrelated program with this program (or its
+%derivative) on a volume of a storage or distribution medium does not bring
+%the other program under the scope of these terms.
+
+% 3. You may copy and distribute this program (or a portion or derivative
+%of it, under Paragraph 2) in object code or executable form under the terms
+%of Paragraphs 1 and 2 above provided that you also do one of the following:
+
+% a) accompany it with the complete corresponding machine-readable
+% source code, which must be distributed under the terms of
+% Paragraphs 1 and 2 above; or,
+
+% b) accompany it with a written offer, valid for at least three
+% years, to give any third party free (except for a nominal
+% shipping charge) a complete machine-readable copy of the
+% corresponding source code, to be distributed under the terms of
+% Paragraphs 1 and 2 above; or,
+
+% c) accompany it with the information you received as to where the
+% corresponding source code may be obtained. (This alternative is
+% allowed only for noncommercial distribution and only if you
+% received the program in object code or executable form alone.)
+
+%For an executable file, complete source code means all the source code for
+%all modules it contains; but, as a special exception, it need not include
+%source code for modules which are standard libraries that accompany the
+%operating system on which the executable file runs.
+
+% 4. You may not copy, sublicense, distribute or transfer this program
+%except as expressly provided under this License Agreement. Any attempt
+%otherwise to copy, sublicense, distribute or transfer this program is void and
+%your rights to use the program under this License agreement shall be
+%automatically terminated. However, parties who have received computer
+%software programs from you with this License Agreement will not have
+%their licenses terminated so long as such parties remain in full compliance.
+
+% 5. If you wish to incorporate parts of this program into other free
+%programs whose distribution conditions are different, write to the Free
+%Software Foundation at 675 Mass Ave, Cambridge, MA 02139. We have not yet
+%worked out a simple rule that can be stated here, but we will often permit
+%this. We will be guided by the two goals of preserving the free status of
+%all derivatives of our free software and of promoting the sharing and reuse of
+%software.
+
+%In other words, you are welcome to use, share and improve this program.
+%You are forbidden to forbid anyone else to use, share and improve
+%what you give them. Help stamp out software-hoarding!
+
+\def\texinfoversion{1.18}
+\message{Loading texinfo package [Version \texinfoversion]:}
+\message{}
+
+% Save some parts of plain tex whose names we will redefine.
-% If in a .fmt file, print the version number
-% and turn on active characters that we couldn't do earlier because
-% they might have appeared in the input file name.
-\everyjob{\message{[Texinfo version \texinfoversion]}%
- \catcode`+=\active \catcode`\_=\active}
-
-\message{Basics,}
-\chardef\other=12
-
-% We never want plain's \outer definition of \+ in Texinfo.
-% For @tex, we can use \tabalign.
-\let\+ = \relax
-
-% Save some plain tex macros whose names we will redefine.
-\let\ptexb=\b
-\let\ptexbullet=\bullet
-\let\ptexc=\c
-\let\ptexcomma=\,
-\let\ptexdot=\.
-\let\ptexdots=\dots
-\let\ptexend=\end
-\let\ptexequiv=\equiv
-\let\ptexexclam=\!
-\let\ptexfootnote=\footnote
-\let\ptexgtr=>
-\let\ptexhat=^
-\let\ptexi=\i
-\let\ptexindent=\indent
-\let\ptexinsert=\insert
\let\ptexlbrace=\{
-\let\ptexless=<
-\let\ptexnewwrite\newwrite
-\let\ptexnoindent=\noindent
-\let\ptexplus=+
\let\ptexrbrace=\}
-\let\ptexslash=\/
+\let\ptexdot=\.
\let\ptexstar=\*
+\let\ptexend=\end
+\let\ptexbullet=\bullet
+\let\ptexb=\b
+\let\ptexc=\c
+\let\ptexi=\i
\let\ptext=\t
+\let\ptexl=\l
+\let\ptexL=\L
-% If this character appears in an error message or help string, it
-% starts a new line in the output.
-\newlinechar = `^^J
-
-% Use TeX 3.0's \inputlineno to get the line number, for better error
-% messages, but if we're using an old version of TeX, don't do anything.
-%
-\ifx\inputlineno\thisisundefined
- \let\linenumber = \empty % Pre-3.0.
-\else
- \def\linenumber{l.\the\inputlineno:\space}
-\fi
+\def\tie{\penalty 10000\ } % Save plain tex definition of ~.
-% Set up fixed words for English if not already set.
-\ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi
-\ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi
-\ifx\putwordfile\undefined \gdef\putwordfile{file}\fi
-\ifx\putwordin\undefined \gdef\putwordin{in}\fi
-\ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi
-\ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi
-\ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi
-\ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi
-\ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi
-\ifx\putwordNoTitle\undefined \gdef\putwordNoTitle{No Title}\fi
-\ifx\putwordof\undefined \gdef\putwordof{of}\fi
-\ifx\putwordon\undefined \gdef\putwordon{on}\fi
-\ifx\putwordpage\undefined \gdef\putwordpage{page}\fi
-\ifx\putwordsection\undefined \gdef\putwordsection{section}\fi
-\ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi
-\ifx\putwordsee\undefined \gdef\putwordsee{see}\fi
-\ifx\putwordSee\undefined \gdef\putwordSee{See}\fi
-\ifx\putwordShortTOC\undefined \gdef\putwordShortTOC{Short Contents}\fi
-\ifx\putwordTOC\undefined \gdef\putwordTOC{Table of Contents}\fi
-%
-\ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi
-\ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi
-\ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi
-\ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi
-\ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi
-\ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi
-\ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi
-\ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi
-\ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi
-\ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi
-\ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi
-\ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi
-%
-\ifx\putwordDefmac\undefined \gdef\putwordDefmac{Macro}\fi
-\ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi
-\ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi
-\ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi
-\ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi
+\message{Basics,}
+\chardef\other=12
-% Since the category of space is not known, we have to be careful.
-\chardef\spacecat = 10
-\def\spaceisspace{\catcode`\ =\spacecat}
-
-% Ignore a token.
-%
-\def\gobble#1{}
-
-% The following is used inside several \edef's.
-\def\makecsname#1{\expandafter\noexpand\csname#1\endcsname}
-
-% Hyphenation fixes.
-\hyphenation{
- Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script
- ap-pen-dix bit-map bit-maps
- data-base data-bases eshell fall-ing half-way long-est man-u-script
- man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm
- par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces
- spell-ing spell-ings
- stand-alone strong-est time-stamp time-stamps which-ever white-space
- wide-spread wrap-around
-}
+\hyphenation{ap-pen-dix}
+\hyphenation{mini-buf-fer mini-buf-fers}
+\hyphenation{eshell}
% Margin to add to right of even pages, to left of odd pages.
-\newdimen\bindingoffset
-\newdimen\normaloffset
+\newdimen \bindingoffset \bindingoffset=0pt
+\newdimen \normaloffset \normaloffset=\hoffset
\newdimen\pagewidth \newdimen\pageheight
+\pagewidth=\hsize \pageheight=\vsize
-% For a final copy, take out the rectangles
-% that mark overfull boxes (in case you have decided
-% that the text looks ok even though it passes the margin).
+%---------------------Begin change-----------------------
%
-\def\finalout{\overfullrule=0pt}
-
-% @| inserts a changebar to the left of the current line. It should
-% surround any changed text. This approach does *not* work if the
-% change spans more than two lines of output. To handle that, we would
-% have adopt a much more difficult approach (putting marks into the main
-% vertical list for the beginning and end of each change).
+% Dimensions to add cropmarks at corners Added by P. A. MacKay, 12 Nov. 1986
%
-\def\|{%
- % \vadjust can only be used in horizontal mode.
- \leavevmode
- %
- % Append this vertical mode material after the current line in the output.
- \vadjust{%
- % We want to insert a rule with the height and depth of the current
- % leading; that is exactly what \strutbox is supposed to record.
- \vskip-\baselineskip
- %
- % \vadjust-items are inserted at the left edge of the type. So
- % the \llap here moves out into the left-hand margin.
- \llap{%
- %
- % For a thicker or thinner bar, change the `1pt'.
- \vrule height\baselineskip width1pt
- %
- % This is the space between the bar and the text.
- \hskip 12pt
- }%
- }%
-}
-
-% Sometimes it is convenient to have everything in the transcript file
-% and nothing on the terminal. We don't just call \tracingall here,
-% since that produces some useless output on the terminal. We also make
-% some effort to order the tracing commands to reduce output in the log
-% file; cf. trace.sty in LaTeX.
+\newdimen\cornerlong \newdimen\cornerthick
+\newdimen \topandbottommargin
+\newdimen \outerhsize \newdimen \outervsize
+\cornerlong=1pc\cornerthick=.3pt % These set size of cropmarks
+\outerhsize=7in
+\outervsize=9.5in
+\topandbottommargin=.75in
%
-\def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
-\def\loggingall{%
- \tracingstats2
- \tracingpages1
- \tracinglostchars2 % 2 gives us more in etex
- \tracingparagraphs1
- \tracingoutput1
- \tracingmacros2
- \tracingrestores1
- \showboxbreadth\maxdimen \showboxdepth\maxdimen
- \ifx\eTeXversion\undefined\else % etex gives us more logging
- \tracingscantokens1
- \tracingifs1
- \tracinggroups1
- \tracingnesting2
- \tracingassigns1
- \fi
- \tracingcommands3 % 3 gives us more in etex
- \errorcontextlines16
-}%
-
-% add check for \lastpenalty to plain's definitions. If the last thing
-% we did was a \nobreak, we don't want to insert more space.
-%
-\def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount
- \removelastskip\penalty-50\smallskip\fi\fi}
-\def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount
- \removelastskip\penalty-100\medskip\fi\fi}
-\def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount
- \removelastskip\penalty-200\bigskip\fi\fi}
-
-% For @cropmarks command.
-% Do @cropmarks to get crop marks.
-%
-\newif\ifcropmarks
-\let\cropmarks = \cropmarkstrue
-%
-% Dimensions to add cropmarks at corners.
-% Added by P. A. MacKay, 12 Nov. 1986
-%
-\newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
-\newdimen\cornerlong \cornerlong=1pc
-\newdimen\cornerthick \cornerthick=.3pt
-\newdimen\topandbottommargin \topandbottommargin=.75in
-
-% Main output routine.
-\chardef\PAGE = 255
-\output = {\onepageout{\pagecontents\PAGE}}
-
-\newbox\headlinebox
-\newbox\footlinebox
+%---------------------End change-----------------------
% \onepageout takes a vbox as an argument. Note that \pagecontents
-% does insertions, but you have to call it yourself.
-\def\onepageout#1{%
- \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi
- %
- \ifodd\pageno \advance\hoffset by \bindingoffset
- \else \advance\hoffset by -\bindingoffset\fi
- %
- % Do this outside of the \shipout so @code etc. will be expanded in
- % the headline as they should be, not taken literally (outputting ''code).
- \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}%
- \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}%
- %
- {%
- % Have to do this stuff outside the \shipout because we want it to
- % take effect in \write's, yet the group defined by the \vbox ends
- % before the \shipout runs.
- %
- \indexdummies % don't expand commands in the output.
- \normalturnoffactive % \ in index entries must not stay \, e.g., if
- % the page break happens to be in the middle of an example.
- % We don't want .vr (or whatever) entries like this:
- % \entry{{\tt \indexbackslash }acronym}{32}{\code {\acronym}}
- % "\acronym" won't work when it's read back in;
- % it needs to be
- % {\code {{\tt \backslashcurfont }acronym}
- \shipout\vbox{%
- % Do this early so pdf references go to the beginning of the page.
- \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
- %
- \ifcropmarks \vbox to \outervsize\bgroup
- \hsize = \outerhsize
- \vskip-\topandbottommargin
- \vtop to0pt{%
- \line{\ewtop\hfil\ewtop}%
- \nointerlineskip
- \line{%
- \vbox{\moveleft\cornerthick\nstop}%
- \hfill
- \vbox{\moveright\cornerthick\nstop}%
- }%
- \vss}%
- \vskip\topandbottommargin
- \line\bgroup
- \hfil % center the page within the outer (page) hsize.
- \ifodd\pageno\hskip\bindingoffset\fi
- \vbox\bgroup
- \fi
- %
- \unvbox\headlinebox
- \pagebody{#1}%
- \ifdim\ht\footlinebox > 0pt
- % Only leave this space if the footline is nonempty.
- % (We lessened \vsize for it in \oddfootingxxx.)
- % The \baselineskip=24pt in plain's \makefootline has no effect.
- \vskip 2\baselineskip
- \unvbox\footlinebox
- \fi
- %
- \ifcropmarks
- \egroup % end of \vbox\bgroup
- \hfil\egroup % end of (centering) \line\bgroup
- \vskip\topandbottommargin plus1fill minus1fill
- \boxmaxdepth = \cornerthick
- \vbox to0pt{\vss
- \line{%
- \vbox{\moveleft\cornerthick\nsbot}%
- \hfill
- \vbox{\moveright\cornerthick\nsbot}%
- }%
- \nointerlineskip
- \line{\ewbot\hfil\ewbot}%
- }%
- \egroup % \vbox from first cropmarks clause
- \fi
- }% end of \shipout\vbox
- }% end of group with \indexdummies
- \advancepageno
- \ifnum\outputpenalty>-20000 \else\dosupereject\fi
-}
-
-\newinsert\margin \dimen\margin=\maxdimen
+% does insertions itself, but you have to call it yourself.
+\chardef\PAGE=255 \output={\onepageout{\pagecontents\PAGE}}
+\def\onepageout#1{\hoffset=\normaloffset
+\ifodd\pageno \advance\hoffset by \bindingoffset
+\else \advance\hoffset by -\bindingoffset\fi
+\shipout\vbox{{\let\hsize=\pagewidth \makeheadline} \pagebody{#1}%
+ {\let\hsize=\pagewidth \makefootline}}
+\advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
+
+
+% Here is a modification of the main output routine for Near East Publications
+% This provides right-angle cropmarks at all four corners.
+% The contents of the page are centerlined into the cropmarks,
+% and any desired binding offset is added as an \hskip on either
+% site of the centerlined box. (P. A. MacKay, 12 November, 1986)
+%
+\def\croppageout#1{\hoffset=0pt % make sure this doesn't mess things up
+ \shipout
+ \vbox to \outervsize{\hsize=\outerhsize
+ \vbox{\line{\ewtop\hfill\ewtop}}
+ \nointerlineskip
+ \line{\vbox{\moveleft\cornerthick\nstop}
+ \hfill
+ \vbox{\moveright\cornerthick\nstop}}
+ \vskip \topandbottommargin
+ \centerline{\ifodd\pageno\hskip\bindingoffset\fi
+ \vbox{
+ {\let\hsize=\pagewidth \makeheadline}
+ \pagebody{#1}
+ {\let\hsize=\pagewidth \makefootline}}
+ \ifodd\pageno\else\hskip\bindingoffset\fi}
+ \vskip \topandbottommargin plus1fill minus1fill
+ \boxmaxdepth\cornerthick
+ \line{\vbox{\moveleft\cornerthick\nsbot}
+ \hfill
+ \vbox{\moveright\cornerthick\nsbot}}
+ \nointerlineskip
+ \vbox{\line{\ewbot\hfill\ewbot}}
+ }
+ \advancepageno
+ \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
+%
+% Do @cropmarks to get crop marks
+\def\cropmarks{\let\onepageout=\croppageout }
\def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
{\catcode`\@ =11
\gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
-% marginal hacks, juha@viisa.uucp (Juha Takala)
-\ifvoid\margin\else % marginal info is present
- \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
\dimen@=\dp#1 \unvbox#1
\ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
\ifr@ggedbottom \kern-\dimen@ \vfil \fi}
}
+%
% Here are the rules for the cropmarks. Note that they are
% offset so that the space between them is truly \outerhsize or \outervsize
% (P. A. MacKay, 12 November, 1986)
@@ -379,1891 +215,317 @@
\def\nsbot{\vbox
{\hrule height\cornerlong depth\cornerthick width\cornerthick}}
-% Parse an argument, then pass it to #1. The argument is the rest of
-% the input line (except we remove a trailing comment). #1 should be a
-% macro which expects an ordinary undelimited TeX argument.
-%
-\def\parsearg{\parseargusing{}}
-\def\parseargusing#1#2{%
- \def\next{#2}%
- \begingroup
- \obeylines
- \spaceisspace
- #1%
- \parseargline\empty% Insert the \empty token, see \finishparsearg below.
-}
+% Parse an argument, then pass it to #1.
+% The argument can be delimited with [...] or with "..." or braces
+% or it can be a whole line.
+% #1 should be a macro which expects
+% an ordinary undelimited TeX argument.
-{\obeylines %
- \gdef\parseargline#1^^M{%
- \endgroup % End of the group started in \parsearg.
- \argremovecomment #1\comment\ArgTerm%
- }%
-}
+\def\parsearg #1{\let\next=#1\begingroup\obeylines\futurelet\temp\parseargx}
-% First remove any @comment, then any @c comment.
-\def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
-\def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
+\def\parseargx{%
+\ifx \obeyedspace\temp \aftergroup\parseargdiscardspace \else%
+\aftergroup \parseargline %
+\fi \endgroup}
-% Each occurence of `\^^M' or `<space>\^^M' is replaced by a single space.
-%
-% \argremovec might leave us with trailing space, e.g.,
-% @end itemize @c foo
-% This space token undergoes the same procedure and is eventually removed
-% by \finishparsearg.
-%
-\def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M}
-\def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M}
-\def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{%
- \def\temp{#3}%
- \ifx\temp\empty
- % We cannot use \next here, as it holds the macro to run;
- % thus we reuse \temp.
- \let\temp\finishparsearg
- \else
- \let\temp\argcheckspaces
- \fi
- % Put the space token in:
- \temp#1 #3\ArgTerm
-}
+{\obeyspaces %
+\gdef\parseargdiscardspace {\begingroup\obeylines\futurelet\temp\parseargx}}
-% If a _delimited_ argument is enclosed in braces, they get stripped; so
-% to get _exactly_ the rest of the line, we had to prevent such situation.
-% We prepended an \empty token at the very beginning and we expand it now,
-% just before passing the control to \next.
-% (Similarily, we have to think about #3 of \argcheckspacesY above: it is
-% either the null string, or it ends with \^^M---thus there is no danger
-% that a pair of braces would be stripped.
-%
-% But first, we have to remove the trailing space token.
-%
-\def\finishparsearg#1 \ArgTerm{\expandafter\next\expandafter{#1}}
+\gdef\obeyedspace{\ }
-% \parseargdef\foo{...}
-% is roughly equivalent to
-% \def\foo{\parsearg\Xfoo}
-% \def\Xfoo#1{...}
-%
-% Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my
-% favourite TeX trick. --kasal, 16nov03
+\def\parseargline{\begingroup \obeylines \parsearglinex}
+{\obeylines %
+\gdef\parsearglinex #1^^M{\endgroup \next {#1}}}
-\def\parseargdef#1{%
- \expandafter \doparseargdef \csname\string#1\endcsname #1%
-}
-\def\doparseargdef#1#2{%
- \def#2{\parsearg#1}%
- \def#1##1%
-}
+\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
-% Several utility definitions with active space:
-{
- \obeyspaces
- \gdef\obeyedspace{ }
-
- % Make each space character in the input produce a normal interword
- % space in the output. Don't allow a line break at this space, as this
- % is used only in environments like @example, where each line of input
- % should produce a line of output anyway.
- %
- \gdef\sepspaces{\obeyspaces\let =\tie}
-
- % If an index command is used in an @example environment, any spaces
- % therein should become regular spaces in the raw index file, not the
- % expansion of \tie (\leavevmode \penalty \@M \ ).
- \gdef\unsepspaces{\let =\space}
-}
+%% These are used to keep @begin/@end levels from running away
+%% Call \inENV within environments (after a \begingroup)
+\newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi}
+\def\ENVcheck{%
+\ifENV\errmessage{Still within an environment. Type Return to continue.}
+\endgroup\fi} % This is not perfect, but it should reduce lossage
+% @begin foo is the same as @foo, for now.
+\newhelp\EMsimple{Type <Return> to continue}
-\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
+\outer\def\begin{\parsearg\beginxxx}
-% Define the framework for environments in texinfo.tex. It's used like this:
-%
-% \envdef\foo{...}
-% \def\Efoo{...}
-%
-% It's the responsibility of \envdef to insert \begingroup before the
-% actual body; @end closes the group after calling \Efoo. \envdef also
-% defines \thisenv, so the current environment is known; @end checks
-% whether the environment name matches. The \checkenv macro can also be
-% used to check whether the current environment is the one expected.
-%
-% Non-false conditionals (@iftex, @ifset) don't fit into this, so they
-% are not treated as enviroments; they don't open a group. (The
-% implementation of @end takes care not to call \endgroup in this
-% special case.)
-
-
-% At runtime, environments start with this:
-\def\startenvironment#1{\begingroup\def\thisenv{#1}}
-% initialize
-\let\thisenv\empty
-
-% ... but they get defined via ``\envdef\foo{...}'':
-\long\def\envdef#1#2{\def#1{\startenvironment#1#2}}
-\def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}}
-
-% Check whether we're in the right environment:
-\def\checkenv#1{%
- \def\temp{#1}%
- \ifx\thisenv\temp
- \else
- \badenverr
- \fi
-}
+\def\beginxxx #1{%
+\expandafter\ifx\csname #1\endcsname\relax
+{\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else
+\csname #1\endcsname\fi}
-% Evironment mismatch, #1 expected:
-\def\badenverr{%
- \errhelp = \EMsimple
- \errmessage{This command can appear only \inenvironment\temp,
- not \inenvironment\thisenv}%
-}
-\def\inenvironment#1{%
- \ifx#1\empty
- out of any environment%
- \else
- in environment \expandafter\string#1%
- \fi
-}
+%% @end foo executes the definition of \Efoo.
+%% foo can be delimited by doublequotes or brackets.
-% @end foo executes the definition of \Efoo.
-% But first, it executes a specialized version of \checkenv
-%
-\parseargdef\end{%
- \if 1\csname iscond.#1\endcsname
- \else
- % The general wording of \badenverr may not be ideal, but... --kasal, 06nov03
- \expandafter\checkenv\csname#1\endcsname
- \csname E#1\endcsname
- \endgroup
- \fi
-}
+\def\end{\parsearg\endxxx}
+
+\def\endxxx #1{%
+\expandafter\ifx\csname E#1\endcsname\relax
+\expandafter\ifx\csname #1\endcsname\relax
+\errmessage{Undefined command @end #1}\else
+\errorE{#1}\fi\fi
+\csname E#1\endcsname}
+\def\errorE#1{
+{\errhelp=\EMsimple \errmessage{@end #1 not within #1 environment}}}
-\newhelp\EMsimple{Press RETURN to continue.}
+% Single-spacing is done by various environments.
+\newskip\singlespaceskip \singlespaceskip = \baselineskip
+\def\singlespace{%
+{\advance \baselineskip by -\singlespaceskip
+\kern \baselineskip}%
+\baselineskip=\singlespaceskip
+}
%% Simple single-character @ commands
% @@ prints an @
% Kludge this until the fonts are right (grr).
-\def\@{{\tt\char64}}
+\def\@{{\sf \char '100}}
-% This is turned off because it was never documented
-% and you can use @w{...} around a quote to suppress ligatures.
-%% Define @` and @' to be the same as ` and '
-%% but suppressing ligatures.
-%\def\`{{`}}
-%\def\'{{'}}
+% Define @` and @' to be the same as ` and '
+% but suppressing ligatures.
+\def\`{{`}}
+\def\'{{'}}
% Used to generate quoted braces.
-\def\mylbrace {{\tt\char123}}
-\def\myrbrace {{\tt\char125}}
+
+\def\mylbrace {{\tt \char '173}}
+\def\myrbrace {{\tt \char '175}}
\let\{=\mylbrace
\let\}=\myrbrace
-\begingroup
- % Definitions to produce \{ and \} commands for indices,
- % and @{ and @} for the aux/toc files.
- \catcode`\{ = \other \catcode`\} = \other
- \catcode`\[ = 1 \catcode`\] = 2
- \catcode`\! = 0 \catcode`\\ = \other
- !gdef!lbracecmd[\{]%
- !gdef!rbracecmd[\}]%
- !gdef!lbraceatcmd[@{]%
- !gdef!rbraceatcmd[@}]%
-!endgroup
-
-% @comma{} to avoid , parsing problems.
-\let\comma = ,
-
-% Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
-% Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H.
-\let\, = \c
-\let\dotaccent = \.
-\def\ringaccent#1{{\accent23 #1}}
-\let\tieaccent = \t
-\let\ubaraccent = \b
-\let\udotaccent = \d
-
-% Other special characters: @questiondown @exclamdown @ordf @ordm
-% Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
-\def\questiondown{?`}
-\def\exclamdown{!`}
-\def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}}
-\def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}}
-
-% Dotless i and dotless j, used for accents.
-\def\imacro{i}
-\def\jmacro{j}
-\def\dotless#1{%
- \def\temp{#1}%
- \ifx\temp\imacro \ptexi
- \else\ifx\temp\jmacro \j
- \else \errmessage{@dotless can be used only with i or j}%
- \fi\fi
-}
-
-% The \TeX{} logo, as in plain, but resetting the spacing so that a
-% period following counts as ending a sentence. (Idea found in latex.)
-%
-\edef\TeX{\TeX \spacefactor=1000 }
-
-% @LaTeX{} logo. Not quite the same results as the definition in
-% latex.ltx, since we use a different font for the raised A; it's most
-% convenient for us to use an explicitly smaller font, rather than using
-% the \scriptstyle font (since we don't reset \scriptstyle and
-% \scriptscriptstyle).
-%
-\def\LaTeX{%
- L\kern-.36em
- {\setbox0=\hbox{T}%
- \vbox to \ht0{\hbox{\selectfonts\lllsize A}\vss}}%
- \kern-.15em
- \TeX
-}
-
-% Be sure we're in horizontal mode when doing a tie, since we make space
-% equivalent to this in @example-like environments. Otherwise, a space
-% at the beginning of a line will start with \penalty -- and
-% since \penalty is valid in vertical mode, we'd end up putting the
-% penalty on the vertical list instead of in the new paragraph.
-{\catcode`@ = 11
- % Avoid using \@M directly, because that causes trouble
- % if the definition is written into an index file.
- \global\let\tiepenalty = \@M
- \gdef\tie{\leavevmode\penalty\tiepenalty\ }
-}
% @: forces normal size whitespace following.
\def\:{\spacefactor=1000 }
% @* forces a line break.
-\def\*{\hfil\break\hbox{}\ignorespaces}
-
-% @/ allows a line break.
-\let\/=\allowbreak
+\def\*{\hfil\break}
% @. is an end-of-sentence period.
-\def\.{.\spacefactor=\endofsentencespacefactor\space}
+\def\.{.\spacefactor=3000 }
-% @! is an end-of-sentence bang.
-\def\!{!\spacefactor=\endofsentencespacefactor\space}
+% @w prevents a word break
+\def\w #1{\hbox{#1}}
-% @? is an end-of-sentence query.
-\def\?{?\spacefactor=\endofsentencespacefactor\space}
+% @group ... @end group forces ... to be all on one page.
-% @frenchspacing on|off says whether to put extra space after punctuation.
-%
-\def\onword{on}
-\def\offword{off}
-%
-\parseargdef\frenchspacing{%
- \def\temp{#1}%
- \ifx\temp\onword \plainfrenchspacing
- \else\ifx\temp\offword \plainnonfrenchspacing
- \else
- \errhelp = \EMsimple
- \errmessage{Unknown @frenchspacing option `\temp', must be on/off}%
- \fi\fi
-}
+\def\group{\begingroup% \inENV ???
+\def \Egroup{\egroup\endgroup}
+\vbox\bgroup}
-% @w prevents a word break. Without the \leavevmode, @w at the
-% beginning of a paragraph, when TeX is still in vertical mode, would
-% produce a whole line of output instead of starting the paragraph.
-\def\w#1{\leavevmode\hbox{#1}}
-
-% @group ... @end group forces ... to be all on one page, by enclosing
-% it in a TeX vbox. We use \vtop instead of \vbox to construct the box
-% to keep its height that of a normal line. According to the rules for
-% \topskip (p.114 of the TeXbook), the glue inserted is
-% max (\topskip - \ht (first item), 0). If that height is large,
-% therefore, no glue is inserted, and the space between the headline and
-% the text is small, which looks bad.
-%
-% Another complication is that the group might be very large. This can
-% cause the glue on the previous page to be unduly stretched, because it
-% does not have much material. In this case, it's better to add an
-% explicit \vfill so that the extra space is at the bottom. The
-% threshold for doing this is if the group is more than \vfilllimit
-% percent of a page (\vfilllimit can be changed inside of @tex).
-%
-\newbox\groupbox
-\def\vfilllimit{0.7}
-%
-\envdef\group{%
- \ifnum\catcode`\^^M=\active \else
- \errhelp = \groupinvalidhelp
- \errmessage{@group invalid in context where filling is enabled}%
- \fi
- \startsavinginserts
- %
- \setbox\groupbox = \vtop\bgroup
- % Do @comment since we are called inside an environment such as
- % @example, where each end-of-line in the input causes an
- % end-of-line in the output. We don't want the end-of-line after
- % the `@group' to put extra space in the output. Since @group
- % should appear on a line by itself (according to the Texinfo
- % manual), we don't worry about eating any user text.
- \comment
-}
-%
-% The \vtop produces a box with normal height and large depth; thus, TeX puts
-% \baselineskip glue before it, and (when the next line of text is done)
-% \lineskip glue after it. Thus, space below is not quite equal to space
-% above. But it's pretty close.
-\def\Egroup{%
- % To get correct interline space between the last line of the group
- % and the first line afterwards, we have to propagate \prevdepth.
- \endgraf % Not \par, as it may have been set to \lisppar.
- \global\dimen1 = \prevdepth
- \egroup % End the \vtop.
- % \dimen0 is the vertical size of the group's box.
- \dimen0 = \ht\groupbox \advance\dimen0 by \dp\groupbox
- % \dimen2 is how much space is left on the page (more or less).
- \dimen2 = \pageheight \advance\dimen2 by -\pagetotal
- % if the group doesn't fit on the current page, and it's a big big
- % group, force a page break.
- \ifdim \dimen0 > \dimen2
- \ifdim \pagetotal < \vfilllimit\pageheight
- \page
- \fi
- \fi
- \box\groupbox
- \prevdepth = \dimen1
- \checkinserts
-}
-%
-% TeX puts in an \escapechar (i.e., `@') at the beginning of the help
-% message, so this ends up printing `@group can only ...'.
-%
-\newhelp\groupinvalidhelp{%
-group can only be used in environments such as @example,^^J%
-where each line of input produces a line of output.}
-
-% @need space-in-mils
-% forces a page break if there is not space-in-mils remaining.
-
-\newdimen\mil \mil=0.001in
-
-% Old definition--didn't work.
-%\parseargdef\need{\par %
-%% This method tries to make TeX break the page naturally
-%% if the depth of the box does not fit.
-%{\baselineskip=0pt%
-%\vtop to #1\mil{\vfil}\kern -#1\mil\nobreak
-%\prevdepth=-1000pt
-%}}
-
-\parseargdef\need{%
- % Ensure vertical mode, so we don't make a big box in the middle of a
- % paragraph.
- \par
- %
- % If the @need value is less than one line space, it's useless.
- \dimen0 = #1\mil
- \dimen2 = \ht\strutbox
- \advance\dimen2 by \dp\strutbox
- \ifdim\dimen0 > \dimen2
- %
- % Do a \strut just to make the height of this box be normal, so the
- % normal leading is inserted relative to the preceding line.
- % And a page break here is fine.
- \vtop to #1\mil{\strut\vfil}%
- %
- % TeX does not even consider page breaks if a penalty added to the
- % main vertical list is 10000 or more. But in order to see if the
- % empty box we just added fits on the page, we must make it consider
- % page breaks. On the other hand, we don't want to actually break the
- % page after the empty box. So we use a penalty of 9999.
- %
- % There is an extremely small chance that TeX will actually break the
- % page at this \penalty, if there are no other feasible breakpoints in
- % sight. (If the user is using lots of big @group commands, which
- % almost-but-not-quite fill up a page, TeX will have a hard time doing
- % good page breaking, for example.) However, I could not construct an
- % example where a page broke at this \penalty; if it happens in a real
- % document, then we can reconsider our strategy.
- \penalty9999
- %
- % Back up by the size of the box, whether we did a page break or not.
- \kern -#1\mil
- %
- % Do not allow a page break right after this kern.
- \nobreak
- \fi
-}
-
-% @br forces paragraph break (and is undocumented).
+% @br forces paragraph break
\let\br = \par
-% @page forces the start of a new page.
-%
+% @dots{} output some dots
+
+\def\dots{$\ldots$}
+
+% @page forces the start of a new page
+
\def\page{\par\vfill\supereject}
% @exdent text....
% outputs text on separate line in roman font, starting at standard page margin
-% This records the amount of indent in the innermost environment.
-% That's how much \exdent should take out.
-\newskip\exdentamount
-
-% This defn is used inside fill environments such as @defun.
-\parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}
+\def\exdent{\errmessage{@exdent in filled text}}
+ % @lisp, etc, define \exdent locally from \internalexdent
-% This defn is used inside nofill environments such as @example.
-\parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount
- \leftline{\hskip\leftskip{\rm#1}}}}
+{\obeyspaces
+\gdef\internalexdent{\parsearg\exdentzzz}}
-% @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
-% paragraph. For more general purposes, use the \margin insertion
-% class. WHICH is `l' or `r'.
-%
-\newskip\inmarginspacing \inmarginspacing=1cm
-\def\strutdepth{\dp\strutbox}
-%
-\def\doinmargin#1#2{\strut\vadjust{%
- \nobreak
- \kern-\strutdepth
- \vtop to \strutdepth{%
- \baselineskip=\strutdepth
- \vss
- % if you have multiple lines of stuff to put here, you'll need to
- % make the vbox yourself of the appropriate size.
- \ifx#1l%
- \llap{\ignorespaces #2\hskip\inmarginspacing}%
- \else
- \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
- \fi
- \null
- }%
-}}
-\def\inleftmargin{\doinmargin l}
-\def\inrightmargin{\doinmargin r}
-%
-% @inmargin{TEXT [, RIGHT-TEXT]}
-% (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right;
-% else use TEXT for both).
-%
-\def\inmargin#1{\parseinmargin #1,,\finish}
-\def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing.
- \setbox0 = \hbox{\ignorespaces #2}%
- \ifdim\wd0 > 0pt
- \def\lefttext{#1}% have both texts
- \def\righttext{#2}%
- \else
- \def\lefttext{#1}% have only one text
- \def\righttext{#1}%
- \fi
- %
- \ifodd\pageno
- \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin
- \else
- \def\temp{\inleftmargin\lefttext}%
- \fi
- \temp
-}
+\def\exdentzzz #1{{\advance \leftskip by -\lispnarrowing
+\advance \hsize by -\leftskip
+\advance \hsize by -\rightskip
+\leftline{{\rm#1}}}}
% @include file insert text of that file as input.
-%
-\def\include{\parseargusing\filenamecatcodes\includezzz}
-\def\includezzz#1{%
- \pushthisfilestack
- \def\thisfile{#1}%
- {%
- \makevalueexpandable
- \def\temp{\input #1 }%
- \expandafter
- }\temp
- \popthisfilestack
-}
-\def\filenamecatcodes{%
- \catcode`\\=\other
- \catcode`~=\other
- \catcode`^=\other
- \catcode`_=\other
- \catcode`|=\other
- \catcode`<=\other
- \catcode`>=\other
- \catcode`+=\other
- \catcode`-=\other
-}
-\def\pushthisfilestack{%
- \expandafter\pushthisfilestackX\popthisfilestack\StackTerm
-}
-\def\pushthisfilestackX{%
- \expandafter\pushthisfilestackY\thisfile\StackTerm
-}
-\def\pushthisfilestackY #1\StackTerm #2\StackTerm {%
- \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}%
-}
-
-\def\popthisfilestack{\errthisfilestackempty}
-\def\errthisfilestackempty{\errmessage{Internal error:
- the stack of filenames is empty.}}
+\def\include{\parsearg\includezzz}
+\def\includezzz #1{{\def\thisfile{#1}\input #1
+}}
\def\thisfile{}
-% @center line
-% outputs that line, centered.
-%
-\parseargdef\center{%
- \ifhmode
- \let\next\centerH
- \else
- \let\next\centerV
- \fi
- \next{\hfil \ignorespaces#1\unskip \hfil}%
-}
-\def\centerH#1{%
- {%
- \hfil\break
- \advance\hsize by -\leftskip
- \advance\hsize by -\rightskip
- \line{#1}%
- \break
- }%
-}
-\def\centerV#1{\line{\kern\leftskip #1\kern\rightskip}}
+% @center line outputs that line, centered
+
+\def\center{\parsearg\centerzzz}
+\def\centerzzz #1{{\advance\hsize by -\leftskip
+\advance\hsize by -\rightskip
+\centerline{#1}}}
% @sp n outputs n lines of vertical space
-\parseargdef\sp{\vskip #1\baselineskip}
+\def\sp{\parsearg\spxxx}
+\def\spxxx #1{\par \vskip #1\baselineskip}
% @comment ...line which is ignored...
% @c is the same as @comment
% @ignore ... @end ignore is another way to write a comment
-\def\comment{\begingroup \catcode`\^^M=\other%
-\catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
-\commentxxx}
-{\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}}
+\def\comment{\parsearg \commentxxx}
+
+\def\commentxxx #1{}
\let\c=\comment
-% @paragraphindent NCHARS
-% We'll use ems for NCHARS, close enough.
-% NCHARS can also be the word `asis' or `none'.
-% We cannot feasibly implement @paragraphindent asis, though.
-%
-\def\asisword{asis} % no translation, these are keywords
-\def\noneword{none}
-%
-\parseargdef\paragraphindent{%
- \def\temp{#1}%
- \ifx\temp\asisword
- \else
- \ifx\temp\noneword
- \defaultparindent = 0pt
- \else
- \defaultparindent = #1em
- \fi
- \fi
- \parindent = \defaultparindent
-}
+\long\def\ignore #1\end ignore{}
-% @exampleindent NCHARS
-% We'll use ems for NCHARS like @paragraphindent.
-% It seems @exampleindent asis isn't necessary, but
-% I preserve it to make it similar to @paragraphindent.
-\parseargdef\exampleindent{%
- \def\temp{#1}%
- \ifx\temp\asisword
- \else
- \ifx\temp\noneword
- \lispnarrowing = 0pt
- \else
- \lispnarrowing = #1em
- \fi
- \fi
-}
+\outer\def\ifset{\parsearg\ifsetxxx}
-% @firstparagraphindent WORD
-% If WORD is `none', then suppress indentation of the first paragraph
-% after a section heading. If WORD is `insert', then do indent at such
-% paragraphs.
-%
-% The paragraph indentation is suppressed or not by calling
-% \suppressfirstparagraphindent, which the sectioning commands do.
-% We switch the definition of this back and forth according to WORD.
-% By default, we suppress indentation.
-%
-\def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent}
-\def\insertword{insert}
-%
-\parseargdef\firstparagraphindent{%
- \def\temp{#1}%
- \ifx\temp\noneword
- \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent
- \else\ifx\temp\insertword
- \let\suppressfirstparagraphindent = \relax
- \else
- \errhelp = \EMsimple
- \errmessage{Unknown @firstparagraphindent option `\temp'}%
- \fi\fi
-}
+\def\ifsetxxx #1#2\end ifset{%
+\expandafter\ifx\csname IF#1\endcsname\relax \else #2\fi}
-% Here is how we actually suppress indentation. Redefine \everypar to
-% \kern backwards by \parindent, and then reset itself to empty.
-%
-% We also make \indent itself not actually do anything until the next
-% paragraph.
-%
-\gdef\dosuppressfirstparagraphindent{%
- \gdef\indent{%
- \restorefirstparagraphindent
- \indent
- }%
- \gdef\noindent{%
- \restorefirstparagraphindent
- \noindent
- }%
- \global\everypar = {%
- \kern -\parindent
- \restorefirstparagraphindent
- }%
-}
+\outer\def\ifclear{\parsearg\ifclearxxx}
-\gdef\restorefirstparagraphindent{%
- \global \let \indent = \ptexindent
- \global \let \noindent = \ptexnoindent
- \global \everypar = {}%
-}
+\def\ifclearxxx #1#2\end ifclear{%
+\expandafter\ifx\csname IF#1\endcsname\relax #2\fi}
+% Some texinfo constructs that are trivial in tex
-% @asis just yields its argument. Used with @table, for example.
-%
+\def\iftex{}
+\def\Eiftex{}
+\long\def\ifinfo #1\end ifinfo{}
+\long\def\menu #1\end menu{}
\def\asis#1{#1}
-% @math outputs its argument in math mode.
-%
-% One complication: _ usually means subscripts, but it could also mean
-% an actual _ character, as in @math{@var{some_variable} + 1}. So make
-% _ active, and distinguish by seeing if the current family is \slfam,
-% which is what @var uses.
-{
- \catcode`\_ = \active
- \gdef\mathunderscore{%
- \catcode`\_=\active
- \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
- }
-}
-% Another complication: we want \\ (and @\) to output a \ character.
-% FYI, plain.tex uses \\ as a temporary control sequence (why?), but
-% this is not advertised and we don't care. Texinfo does not
-% otherwise define @\.
-%
-% The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
-\def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
-%
-\def\math{%
- \tex
- \mathunderscore
- \let\\ = \mathbackslash
- \mathactive
- $\finishmath
-}
-\def\finishmath#1{#1$\endgroup} % Close the group opened by \tex.
-
-% Some active characters (such as <) are spaced differently in math.
-% We have to reset their definitions in case the @math was an argument
-% to a command which sets the catcodes (such as @item or @section).
-%
-{
- \catcode`^ = \active
- \catcode`< = \active
- \catcode`> = \active
- \catcode`+ = \active
- \gdef\mathactive{%
- \let^ = \ptexhat
- \let< = \ptexless
- \let> = \ptexgtr
- \let+ = \ptexplus
- }
-}
+\def\node{\parsearg\nodezzz}
+\def\nodezzz#1{\nodexxx [#1,]}
+\def\nodexxx[#1,#2]{\gdef\lastnode{#1}}
+\let\lastnode=\relax
-% @bullet and @minus need the same treatment as @math, just above.
-\def\bullet{$\ptexbullet$}
-\def\minus{$-$}
-
-% @dots{} outputs an ellipsis using the current font.
-% We do .5em per period so that it has the same spacing in a typewriter
-% font as three actual period characters.
-%
-\def\dots{%
- \leavevmode
- \hbox to 1.5em{%
- \hskip 0pt plus 0.25fil
- .\hfil.\hfil.%
- \hskip 0pt plus 0.5fil
- }%
-}
-
-% @enddots{} is an end-of-sentence ellipsis.
-%
-\def\enddots{%
- \dots
- \spacefactor=\endofsentencespacefactor
-}
+\def\donoderef{\ifx\lastnode\relax\else
+\expandafter\expandafter\expandafter\setref{\lastnode}\fi
+\let\lastnode=\relax}
-% @comma{} is so commas can be inserted into text without messing up
-% Texinfo's parsing.
-%
-\let\comma = ,
+\def\unnumbnoderef{\ifx\lastnode\relax\else
+\expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi
+\let\lastnode=\relax}
-% @refill is a no-op.
\let\refill=\relax
-% If working on a large document in chapters, it is convenient to
-% be able to disable indexing, cross-referencing, and contents, for test runs.
-% This is done with @novalidate (before @setfilename).
-%
-\newif\iflinks \linkstrue % by default we want the aux files.
-\let\novalidate = \linksfalse
-
-% @setfilename is done at the beginning of every texinfo file.
-% So open here the files we need to have open while reading the input.
-% This makes it possible to make a .fmt file for texinfo.
-\def\setfilename{%
- \fixbackslash % Turn off hack to swallow `\input texinfo'.
- \iflinks
- \tryauxfile
- % Open the new aux file. TeX will close it automatically at exit.
- \immediate\openout\auxfile=\jobname.aux
- \fi % \openindices needs to do some work in any case.
- \openindices
- \let\setfilename=\comment % Ignore extra @setfilename cmds.
- %
- % If texinfo.cnf is present on the system, read it.
- % Useful for site-wide @afourpaper, etc.
- \openin 1 texinfo.cnf
- \ifeof 1 \else \input texinfo.cnf \fi
- \closein 1
- %
- \comment % Ignore the actual filename.
-}
-
-% Called from \setfilename.
-%
-\def\openindices{%
- \newindex{cp}%
- \newcodeindex{fn}%
- \newcodeindex{vr}%
- \newcodeindex{tp}%
- \newcodeindex{ky}%
- \newcodeindex{pg}%
-}
-
-% @bye.
-\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
-
-
-\message{pdf,}
-% adobe `portable' document format
-\newcount\tempnum
-\newcount\lnkcount
-\newtoks\filename
-\newcount\filenamelength
-\newcount\pgn
-\newtoks\toksA
-\newtoks\toksB
-\newtoks\toksC
-\newtoks\toksD
-\newbox\boxA
-\newcount\countA
-\newif\ifpdf
-\newif\ifpdfmakepagedest
-
-% when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
-% can be set). So we test for \relax and 0 as well as \undefined,
-% borrowed from ifpdf.sty.
-\ifx\pdfoutput\undefined
-\else
- \ifx\pdfoutput\relax
- \else
- \ifcase\pdfoutput
- \else
- \pdftrue
- \fi
- \fi
-\fi
-
-% PDF uses PostScript string constants for the names of xref targets,
-% for display in the outlines, and in other places. Thus, we have to
-% double any backslashes. Otherwise, a name like "\node" will be
-% interpreted as a newline (\n), followed by o, d, e. Not good.
-% http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html
-% (and related messages, the final outcome is that it is up to the TeX
-% user to double the backslashes and otherwise make the string valid, so
-% that's what we do).
-
-% double active backslashes.
-%
-{\catcode`\@=0 \catcode`\\=\active
- @gdef@activebackslashdouble{%
- @catcode`@\=@active
- @let\=@doublebackslash}
-}
-
-% To handle parens, we must adopt a different approach, since parens are
-% not active characters. hyperref.dtx (which has the same problem as
-% us) handles it with this amazing macro to replace tokens. I've
-% tinkered with it a little for texinfo, but it's definitely from there.
-%
-% #1 is the tokens to replace.
-% #2 is the replacement.
-% #3 is the control sequence with the string.
-%
-\def\HyPsdSubst#1#2#3{%
- \def\HyPsdReplace##1#1##2\END{%
- ##1%
- \ifx\\##2\\%
- \else
- #2%
- \HyReturnAfterFi{%
- \HyPsdReplace##2\END
- }%
- \fi
- }%
- \xdef#3{\expandafter\HyPsdReplace#3#1\END}%
-}
-\long\def\HyReturnAfterFi#1\fi{\fi#1}
-
-% #1 is a control sequence in which to do the replacements.
-\def\backslashparens#1{%
- \xdef#1{#1}% redefine it as its expansion; the definition is simply
- % \lastnode when called from \setref -> \pdfmkdest.
- \HyPsdSubst{(}{\realbackslash(}{#1}%
- \HyPsdSubst{)}{\realbackslash)}{#1}%
-}
-
-\ifpdf
- \input pdfcolor
- \pdfcatalog{/PageMode /UseOutlines}%
- \def\dopdfimage#1#2#3{%
- \def\imagewidth{#2}%
- \def\imageheight{#3}%
- % without \immediate, pdftex seg faults when the same image is
- % included twice. (Version 3.14159-pre-1.0-unofficial-20010704.)
- \ifnum\pdftexversion < 14
- \immediate\pdfimage
- \else
- \immediate\pdfximage
- \fi
- \ifx\empty\imagewidth\else width \imagewidth \fi
- \ifx\empty\imageheight\else height \imageheight \fi
- \ifnum\pdftexversion<13
- #1.pdf%
- \else
- {#1.pdf}%
- \fi
- \ifnum\pdftexversion < 14 \else
- \pdfrefximage \pdflastximage
- \fi}
- \def\pdfmkdest#1{{%
- % We have to set dummies so commands such as @code, and characters
- % such as \, aren't expanded when present in a section title.
- \atdummies
- \activebackslashdouble
- \def\pdfdestname{#1}%
- \backslashparens\pdfdestname
- \pdfdest name{\pdfdestname} xyz%
- }}%
- %
- % used to mark target names; must be expandable.
- \def\pdfmkpgn#1{#1}%
- %
- \let\linkcolor = \Blue % was Cyan, but that seems light?
- \def\endlink{\Black\pdfendlink}
- % Adding outlines to PDF; macros for calculating structure of outlines
- % come from Petr Olsak
- \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
- \else \csname#1\endcsname \fi}
- \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
- \advance\tempnum by 1
- \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
- %
- % #1 is the section text, which is what will be displayed in the
- % outline by the pdf viewer. #2 is the pdf expression for the number
- % of subentries (or empty, for subsubsections). #3 is the node text,
- % which might be empty if this toc entry had no corresponding node.
- % #4 is the page number
- %
- \def\dopdfoutline#1#2#3#4{%
- % Generate a link to the node text if that exists; else, use the
- % page number. We could generate a destination for the section
- % text in the case where a section has no node, but it doesn't
- % seem worth the trouble, since most documents are normally structured.
- \def\pdfoutlinedest{#3}%
- \ifx\pdfoutlinedest\empty
- \def\pdfoutlinedest{#4}%
- \else
- % Doubled backslashes in the name.
- {\activebackslashdouble \xdef\pdfoutlinedest{#3}%
- \backslashparens\pdfoutlinedest}%
- \fi
- %
- % Also double the backslashes in the display string.
- {\activebackslashdouble \xdef\pdfoutlinetext{#1}%
- \backslashparens\pdfoutlinetext}%
- %
- \pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{\pdfoutlinetext}%
- }
- %
- \def\pdfmakeoutlines{%
- \begingroup
- % Thanh's hack / proper braces in bookmarks
- \edef\mylbrace{\iftrue \string{\else}\fi}\let\{=\mylbrace
- \edef\myrbrace{\iffalse{\else\string}\fi}\let\}=\myrbrace
- %
- % Read toc silently, to get counts of subentries for \pdfoutline.
- \def\numchapentry##1##2##3##4{%
- \def\thischapnum{##2}%
- \def\thissecnum{0}%
- \def\thissubsecnum{0}%
- }%
- \def\numsecentry##1##2##3##4{%
- \advancenumber{chap\thischapnum}%
- \def\thissecnum{##2}%
- \def\thissubsecnum{0}%
- }%
- \def\numsubsecentry##1##2##3##4{%
- \advancenumber{sec\thissecnum}%
- \def\thissubsecnum{##2}%
- }%
- \def\numsubsubsecentry##1##2##3##4{%
- \advancenumber{subsec\thissubsecnum}%
- }%
- \def\thischapnum{0}%
- \def\thissecnum{0}%
- \def\thissubsecnum{0}%
- %
- % use \def rather than \let here because we redefine \chapentry et
- % al. a second time, below.
- \def\appentry{\numchapentry}%
- \def\appsecentry{\numsecentry}%
- \def\appsubsecentry{\numsubsecentry}%
- \def\appsubsubsecentry{\numsubsubsecentry}%
- \def\unnchapentry{\numchapentry}%
- \def\unnsecentry{\numsecentry}%
- \def\unnsubsecentry{\numsubsecentry}%
- \def\unnsubsubsecentry{\numsubsubsecentry}%
- \readdatafile{toc}%
- %
- % Read toc second time, this time actually producing the outlines.
- % The `-' means take the \expnumber as the absolute number of
- % subentries, which we calculated on our first read of the .toc above.
- %
- % We use the node names as the destinations.
- \def\numchapentry##1##2##3##4{%
- \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}%
- \def\numsecentry##1##2##3##4{%
- \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}%
- \def\numsubsecentry##1##2##3##4{%
- \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}%
- \def\numsubsubsecentry##1##2##3##4{% count is always zero
- \dopdfoutline{##1}{}{##3}{##4}}%
- %
- % PDF outlines are displayed using system fonts, instead of
- % document fonts. Therefore we cannot use special characters,
- % since the encoding is unknown. For example, the eogonek from
- % Latin 2 (0xea) gets translated to a | character. Info from
- % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
- %
- % xx to do this right, we have to translate 8-bit characters to
- % their "best" equivalent, based on the @documentencoding. Right
- % now, I guess we'll just let the pdf reader have its way.
- \indexnofonts
- \setupdatafile
- \catcode`\\=\active \otherbackslash
- \input \jobname.toc
- \endgroup
- }
- %
- \def\skipspaces#1{\def\PP{#1}\def\D{|}%
- \ifx\PP\D\let\nextsp\relax
- \else\let\nextsp\skipspaces
- \ifx\p\space\else\addtokens{\filename}{\PP}%
- \advance\filenamelength by 1
- \fi
- \fi
- \nextsp}
- \def\getfilename#1{\filenamelength=0\expandafter\skipspaces#1|\relax}
- \ifnum\pdftexversion < 14
- \let \startlink \pdfannotlink
- \else
- \let \startlink \pdfstartlink
- \fi
- % make a live url in pdf output.
- \def\pdfurl#1{%
- \begingroup
- % it seems we really need yet another set of dummies; have not
- % tried to figure out what each command should do in the context
- % of @url. for now, just make @/ a no-op, that's the only one
- % people have actually reported a problem with.
- %
- \normalturnoffactive
- \def\@{@}%
- \let\/=\empty
- \makevalueexpandable
- \leavevmode\Red
- \startlink attr{/Border [0 0 0]}%
- user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
- \endgroup}
- \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
- \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
- \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
- \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
- \def\maketoks{%
- \expandafter\poptoks\the\toksA|ENDTOKS|\relax
- \ifx\first0\adn0
- \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
- \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
- \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
- \else
- \ifnum0=\countA\else\makelink\fi
- \ifx\first.\let\next=\done\else
- \let\next=\maketoks
- \addtokens{\toksB}{\the\toksD}
- \ifx\first,\addtokens{\toksB}{\space}\fi
- \fi
- \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
- \next}
- \def\makelink{\addtokens{\toksB}%
- {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
- \def\pdflink#1{%
- \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
- \linkcolor #1\endlink}
- \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
-\else
- \let\pdfmkdest = \gobble
- \let\pdfurl = \gobble
- \let\endlink = \relax
- \let\linkcolor = \relax
- \let\pdfmakeoutlines = \relax
-\fi % \ifx\pdfoutput
+\let\setfilename=\comment
+\def\inforef #1{\inforefzzz #1,,,,**}
+\def\inforefzzz #1,#2,#3,#4**{See Info file \file{\losespace#3{}}, node `\losespace#1{}'}
+\def\losespace #1{#1}
\message{fonts,}
-% Change the current font style to #1, remembering it in \curfontstyle.
-% For now, we do not accumulate font styles: @b{@i{foo}} prints foo in
-% italics, not bold italics.
-%
-\def\setfontstyle#1{%
- \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd.
- \csname ten#1\endcsname % change the current font
-}
-
-% Select #1 fonts with the current style.
-%
-\def\selectfonts#1{\csname #1fonts\endcsname \csname\curfontstyle\endcsname}
-
-\def\rm{\fam=0 \setfontstyle{rm}}
-\def\it{\fam=\itfam \setfontstyle{it}}
-\def\sl{\fam=\slfam \setfontstyle{sl}}
-\def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
-\def\tt{\fam=\ttfam \setfontstyle{tt}}
-
-% Texinfo sort of supports the sans serif font style, which plain TeX does not.
-% So we set up a \sf.
-\newfam\sffam
-\def\sf{\fam=\sffam \setfontstyle{sf}}
-\let\li = \sf % Sometimes we call it \li, not \sf.
-
-% We don't need math for this font style.
-\def\ttsl{\setfontstyle{ttsl}}
-
-% Default leading.
-\newdimen\textleading \textleading = 13.2pt
-
-% Set the baselineskip to #1, and the lineskip and strut size
-% correspondingly. There is no deep meaning behind these magic numbers
-% used as factors; they just match (closely enough) what Knuth defined.
-%
-\def\lineskipfactor{.08333}
-\def\strutheightpercent{.70833}
-\def\strutdepthpercent {.29167}
-%
-\def\setleading#1{%
- \normalbaselineskip = #1\relax
- \normallineskip = \lineskipfactor\normalbaselineskip
- \normalbaselines
- \setbox\strutbox =\hbox{%
- \vrule width0pt height\strutheightpercent\baselineskip
- depth \strutdepthpercent \baselineskip
- }%
-}
-
-% Set the font macro #1 to the font named #2, adding on the
-% specified font prefix (normally `cm').
-% #3 is the font's design size, #4 is a scale factor
-\def\setfont#1#2#3#4{\font#1=\fontprefix#2#3 scaled #4}
-
-% Use cm as the default font prefix.
-% To specify the font prefix, you must define \fontprefix
-% before you read in texinfo.tex.
-\ifx\fontprefix\undefined
-\def\fontprefix{cm}
-\fi
-% Support font families that don't use the same naming scheme as CM.
-\def\rmshape{r}
-\def\rmbshape{bx} %where the normal face is bold
-\def\bfshape{b}
-\def\bxshape{bx}
-\def\ttshape{tt}
-\def\ttbshape{tt}
-\def\ttslshape{sltt}
-\def\itshape{ti}
-\def\itbshape{bxti}
-\def\slshape{sl}
-\def\slbshape{bxsl}
-\def\sfshape{ss}
-\def\sfbshape{ss}
-\def\scshape{csc}
-\def\scbshape{csc}
-
-% Text fonts (11.2pt, magstep1).
-\def\textnominalsize{11pt}
-\edef\mainmagstep{\magstephalf}
-\setfont\textrm\rmshape{10}{\mainmagstep}
-\setfont\texttt\ttshape{10}{\mainmagstep}
-\setfont\textbf\bfshape{10}{\mainmagstep}
-\setfont\textit\itshape{10}{\mainmagstep}
-\setfont\textsl\slshape{10}{\mainmagstep}
-\setfont\textsf\sfshape{10}{\mainmagstep}
-\setfont\textsc\scshape{10}{\mainmagstep}
-\setfont\textttsl\ttslshape{10}{\mainmagstep}
-\font\texti=cmmi10 scaled \mainmagstep
-\font\textsy=cmsy10 scaled \mainmagstep
-
-% A few fonts for @defun names and args.
-\setfont\defbf\bfshape{10}{\magstep1}
-\setfont\deftt\ttshape{10}{\magstep1}
-\setfont\defttsl\ttslshape{10}{\magstep1}
-\def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf}
-
-% Fonts for indices, footnotes, small examples (9pt).
-\def\smallnominalsize{9pt}
-\setfont\smallrm\rmshape{9}{1000}
-\setfont\smalltt\ttshape{9}{1000}
-\setfont\smallbf\bfshape{10}{900}
-\setfont\smallit\itshape{9}{1000}
-\setfont\smallsl\slshape{9}{1000}
-\setfont\smallsf\sfshape{9}{1000}
-\setfont\smallsc\scshape{10}{900}
-\setfont\smallttsl\ttslshape{10}{900}
-\font\smalli=cmmi9
-\font\smallsy=cmsy9
-
-% Fonts for small examples (8pt).
-\def\smallernominalsize{8pt}
-\setfont\smallerrm\rmshape{8}{1000}
-\setfont\smallertt\ttshape{8}{1000}
-\setfont\smallerbf\bfshape{10}{800}
-\setfont\smallerit\itshape{8}{1000}
-\setfont\smallersl\slshape{8}{1000}
-\setfont\smallersf\sfshape{8}{1000}
-\setfont\smallersc\scshape{10}{800}
-\setfont\smallerttsl\ttslshape{10}{800}
-\font\smalleri=cmmi8
-\font\smallersy=cmsy8
-
-% Fonts for title page (20.4pt):
-\def\titlenominalsize{20pt}
-\setfont\titlerm\rmbshape{12}{\magstep3}
-\setfont\titleit\itbshape{10}{\magstep4}
-\setfont\titlesl\slbshape{10}{\magstep4}
-\setfont\titlett\ttbshape{12}{\magstep3}
-\setfont\titlettsl\ttslshape{10}{\magstep4}
-\setfont\titlesf\sfbshape{17}{\magstep1}
-\let\titlebf=\titlerm
-\setfont\titlesc\scbshape{10}{\magstep4}
-\font\titlei=cmmi12 scaled \magstep3
-\font\titlesy=cmsy10 scaled \magstep4
-\def\authorrm{\secrm}
-\def\authortt{\sectt}
-
-% Chapter (and unnumbered) fonts (17.28pt).
-\def\chapnominalsize{17pt}
-\setfont\chaprm\rmbshape{12}{\magstep2}
-\setfont\chapit\itbshape{10}{\magstep3}
-\setfont\chapsl\slbshape{10}{\magstep3}
-\setfont\chaptt\ttbshape{12}{\magstep2}
-\setfont\chapttsl\ttslshape{10}{\magstep3}
-\setfont\chapsf\sfbshape{17}{1000}
+% Font-change commands.
+
+%% Try out Computer Modern fonts at \magstephalf
+\font\tenrm=cmr10 scaled \magstephalf
+\font\tentt=cmtt10 scaled \magstephalf
+% Instead of cmb10, you many want to use cmbx10.
+% cmbx10 is a prettier font on its own, but cmb10
+% looks better when embedded in a line with cmr10.
+\font\tenbf=cmb10 scaled \magstephalf
+\font\tenit=cmti10 scaled \magstephalf
+\font\tensl=cmsl10 scaled \magstephalf
+\font\tensf=cmss10 scaled \magstephalf
+\def\li{\sf}
+\font\tensc=cmcsc10 scaled \magstephalf
+
+% Fonts for @defun, etc.
+\font\defbf=cmbx10 scaled \magstep1 %was 1314
+\let\deftt=\tentt
+\def\df{\let\tt=\deftt \defbf}
+
+% Font for title
+\font\titlerm = cmbx10 scaled \magstep5
+
+% Fonts for indices
+\font\indit=cmti9 \font\indrm=cmr9
+\def\indbf{\indrm} \def\indsl{\indit}
+\def\indexfonts{\let\it=\indit \let\sl=\indsl \let\bf=\indbf \let\rm=\indrm}
+
+% Fonts for headings
+\font\chaprm=cmbx10 scaled \magstep3
+\font\chapit=cmti10 scaled \magstep3
+\font\chapsl=cmsl10 scaled \magstep3
+\font\chaptt=cmtt10 scaled \magstep3
+\font\chapsf=cmss10 scaled \magstep3
\let\chapbf=\chaprm
-\setfont\chapsc\scbshape{10}{\magstep3}
-\font\chapi=cmmi12 scaled \magstep2
-\font\chapsy=cmsy10 scaled \magstep3
-
-% Section fonts (14.4pt).
-\def\secnominalsize{14pt}
-\setfont\secrm\rmbshape{12}{\magstep1}
-\setfont\secit\itbshape{10}{\magstep2}
-\setfont\secsl\slbshape{10}{\magstep2}
-\setfont\sectt\ttbshape{12}{\magstep1}
-\setfont\secttsl\ttslshape{10}{\magstep2}
-\setfont\secsf\sfbshape{12}{\magstep1}
-\let\secbf\secrm
-\setfont\secsc\scbshape{10}{\magstep2}
-\font\seci=cmmi12 scaled \magstep1
-\font\secsy=cmsy10 scaled \magstep2
-
-% Subsection fonts (13.15pt).
-\def\ssecnominalsize{13pt}
-\setfont\ssecrm\rmbshape{12}{\magstephalf}
-\setfont\ssecit\itbshape{10}{1315}
-\setfont\ssecsl\slbshape{10}{1315}
-\setfont\ssectt\ttbshape{12}{\magstephalf}
-\setfont\ssecttsl\ttslshape{10}{1315}
-\setfont\ssecsf\sfbshape{12}{\magstephalf}
-\let\ssecbf\ssecrm
-\setfont\ssecsc\scbshape{10}{1315}
-\font\sseci=cmmi12 scaled \magstephalf
-\font\ssecsy=cmsy10 scaled 1315
-
-% Reduced fonts for @acro in text (10pt).
-\def\reducednominalsize{10pt}
-\setfont\reducedrm\rmshape{10}{1000}
-\setfont\reducedtt\ttshape{10}{1000}
-\setfont\reducedbf\bfshape{10}{1000}
-\setfont\reducedit\itshape{10}{1000}
-\setfont\reducedsl\slshape{10}{1000}
-\setfont\reducedsf\sfshape{10}{1000}
-\setfont\reducedsc\scshape{10}{1000}
-\setfont\reducedttsl\ttslshape{10}{1000}
-\font\reducedi=cmmi10
-\font\reducedsy=cmsy10
-
-% In order for the font changes to affect most math symbols and letters,
-% we have to define the \textfont of the standard families. Since
-% texinfo doesn't allow for producing subscripts and superscripts except
-% in the main text, we don't bother to reset \scriptfont and
-% \scriptscriptfont (which would also require loading a lot more fonts).
-%
-\def\resetmathfonts{%
- \textfont0=\tenrm \textfont1=\teni \textfont2=\tensy
- \textfont\itfam=\tenit \textfont\slfam=\tensl \textfont\bffam=\tenbf
- \textfont\ttfam=\tentt \textfont\sffam=\tensf
-}
-
-% The font-changing commands redefine the meanings of \tenSTYLE, instead
-% of just \STYLE. We do this because \STYLE needs to also set the
-% current \fam for math mode. Our \STYLE (e.g., \rm) commands hardwire
-% \tenSTYLE to set the current font.
-%
-% Each font-changing command also sets the names \lsize (one size lower)
-% and \lllsize (three sizes lower). These relative commands are used in
-% the LaTeX logo and acronyms.
-%
-% This all needs generalizing, badly.
-%
-\def\textfonts{%
- \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
- \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
- \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy
- \let\tenttsl=\textttsl
- \def\curfontsize{text}%
- \def\lsize{reduced}\def\lllsize{smaller}%
- \resetmathfonts \setleading{\textleading}}
-\def\titlefonts{%
- \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl
- \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc
- \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy
- \let\tenttsl=\titlettsl
- \def\curfontsize{title}%
- \def\lsize{chap}\def\lllsize{subsec}%
- \resetmathfonts \setleading{25pt}}
-\def\titlefont#1{{\titlefonts\rm #1}}
-\def\chapfonts{%
- \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
- \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
- \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy
- \let\tenttsl=\chapttsl
- \def\curfontsize{chap}%
- \def\lsize{sec}\def\lllsize{text}%
- \resetmathfonts \setleading{19pt}}
-\def\secfonts{%
- \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
- \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
- \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy
- \let\tenttsl=\secttsl
- \def\curfontsize{sec}%
- \def\lsize{subsec}\def\lllsize{reduced}%
- \resetmathfonts \setleading{16pt}}
-\def\subsecfonts{%
- \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
- \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
- \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy
- \let\tenttsl=\ssecttsl
- \def\curfontsize{ssec}%
- \def\lsize{text}\def\lllsize{small}%
- \resetmathfonts \setleading{15pt}}
-\let\subsubsecfonts = \subsecfonts
-\def\reducedfonts{%
- \let\tenrm=\reducedrm \let\tenit=\reducedit \let\tensl=\reducedsl
- \let\tenbf=\reducedbf \let\tentt=\reducedtt \let\reducedcaps=\reducedsc
- \let\tensf=\reducedsf \let\teni=\reducedi \let\tensy=\reducedsy
- \let\tenttsl=\reducedttsl
- \def\curfontsize{reduced}%
- \def\lsize{small}\def\lllsize{smaller}%
- \resetmathfonts \setleading{10.5pt}}
-\def\smallfonts{%
- \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl
- \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc
- \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy
- \let\tenttsl=\smallttsl
- \def\curfontsize{small}%
- \def\lsize{smaller}\def\lllsize{smaller}%
- \resetmathfonts \setleading{10.5pt}}
-\def\smallerfonts{%
- \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl
- \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc
- \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy
- \let\tenttsl=\smallerttsl
- \def\curfontsize{smaller}%
- \def\lsize{smaller}\def\lllsize{smaller}%
- \resetmathfonts \setleading{9.5pt}}
-
-% Set the fonts to use with the @small... environments.
-\let\smallexamplefonts = \smallfonts
-
-% About \smallexamplefonts. If we use \smallfonts (9pt), @smallexample
-% can fit this many characters:
-% 8.5x11=86 smallbook=72 a4=90 a5=69
-% If we use \scriptfonts (8pt), then we can fit this many characters:
-% 8.5x11=90+ smallbook=80 a4=90+ a5=77
-% For me, subjectively, the few extra characters that fit aren't worth
-% the additional smallness of 8pt. So I'm making the default 9pt.
-%
-% By the way, for comparison, here's what fits with @example (10pt):
-% 8.5x11=71 smallbook=60 a4=75 a5=58
-%
-% I wish the USA used A4 paper.
-% --karl, 24jan03.
-
-
-% Set up the default fonts, so we can use them for creating boxes.
-%
-\textfonts \rm
-
-% Define these so they can be easily changed for other fonts.
-\def\angleleft{$\langle$}
-\def\angleright{$\rangle$}
+\font\secrm=cmbx10 scaled \magstep2
+\font\secit=cmti10 scaled \magstep2
+\font\secsl=cmsl10 scaled \magstep2
+\font\sectt=cmtt10 scaled \magstep2
+\font\secsf=cmss10 scaled \magstep2
+\let\secbf=\secrm
+
+\font\ssecrm=cmbx10 scaled \magstep1
+\font\ssecit=cmti10 scaled \magstep1
+\font\ssecsl=cmsl10 scaled \magstep1
+\font\ssectt=cmtt10 scaled \magstep1
+\font\ssecsf=cmss10 scaled \magstep1
+\let\ssecbf=\ssecrm
+
+\def\textfonts{\let\rm=\tenrm\let\it=\tenit\let\sl=\tensl\let\bf=\tenbf%
+\let\sc=\tensc\let\sf=\tensf}
+\def\chapfonts{\let\rm=\chaprm\let\it=\chapit\let\sl=\chapsl\let\bf=\chapbf\let\tt=\chaptt\let\sf=\chapsf}
+\def\secfonts{\let\rm=\secrm\let\it=\secit\let\sl=\secsl\let\bf=\secbf\let\tt=\sectt\let\sf=\secsf}
+\def\subsecfonts{\let\rm=\ssecrm\let\it=\ssecit\let\sl=\ssecsl\let\bf=\ssecbf\let\tt=\ssectt\let\sf=\ssecsf}
% Count depth in font-changes, for error checks
\newcount\fontdepth \fontdepth=0
-% Fonts for short table of contents.
-\setfont\shortcontrm\rmshape{12}{1000}
-\setfont\shortcontbf\bfshape{10}{\magstep1} % no cmb12
-\setfont\shortcontsl\slshape{12}{1000}
-\setfont\shortconttt\ttshape{12}{1000}
-
%% Add scribe-like font environments, plus @l for inline lisp (usually sans
%% serif) and @ii for TeX italic
-% \smartitalic{ARG} outputs arg in italics, followed by an italic correction
-% unless the following character is such as not to need one.
-\def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else
- \ptexslash\fi\fi\fi}
-\def\smartslanted#1{{\ifusingtt\ttsl\sl #1}\futurelet\next\smartitalicx}
-\def\smartitalic#1{{\ifusingtt\ttsl\it #1}\futurelet\next\smartitalicx}
+\def\i#1{{\sl #1}}
+\let\var=\i
+\let\dfn=\i
+\let\emph=\i
+\let\cite=\i
-% like \smartslanted except unconditionally uses \ttsl.
-% @var is set to this for defun arguments.
-\def\ttslanted#1{{\ttsl #1}\futurelet\next\smartitalicx}
-
-% like \smartslanted except unconditionally use \sl. We never want
-% ttsl for book titles, do we?
-\def\cite#1{{\sl #1}\futurelet\next\smartitalicx}
-
-\let\i=\smartitalic
-\let\slanted=\smartslanted
-\let\var=\smartslanted
-\let\dfn=\smartslanted
-\let\emph=\smartitalic
-
-% @b, explicit bold.
\def\b#1{{\bf #1}}
\let\strong=\b
-% @sansserif, explicit sans.
-\def\sansserif#1{{\sf #1}}
-
-% We can't just use \exhyphenpenalty, because that only has effect at
-% the end of a paragraph. Restore normal hyphenation at the end of the
-% group within which \nohyphenation is presumably called.
-%
-\def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation}
-\def\restorehyphenation{\hyphenchar\font = `- }
-
-% Set sfcode to normal for the chars that usually have another value.
-% Can't use plain's \frenchspacing because it uses the `\x notation, and
-% sometimes \x has an active definition that messes things up.
-%
-\chardef\colonChar = `\:
-\chardef\commaChar = `\,
-\chardef\dotChar = `\.
-\chardef\exclamChar= `\!
-\chardef\questChar = `\?
-\chardef\semiChar = `\;
-%
-\catcode`@=11
- \def\plainfrenchspacing{%
- \sfcode\dotChar =\@m \sfcode\questChar=\@m \sfcode\exclamChar=\@m
- \sfcode\colonChar=\@m \sfcode\semiChar =\@m \sfcode\commaChar =\@m
- \def\endofsentencespacefactor{1000}% for @. and friends
- }
- \def\plainnonfrenchspacing{%
- \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000
- \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250
- \def\endofsentencespacefactor{3000}% for @. and friends
- }
-\catcode`@=\other
-\def\endofsentencespacefactor{3000}% default
-
-\def\t#1{%
- {\tt \rawbackslash \plainfrenchspacing #1}%
- \null
-}
-\def\samp#1{`\tclose{#1}'\null}
-\setfont\keyrm\rmshape{8}{1000}
-\font\keysy=cmsy9
-\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
- \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
- \vbox{\hrule\kern-0.4pt
- \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
- \kern-0.4pt\hrule}%
- \kern-.06em\raise0.4pt\hbox{\angleright}}}}
-% The old definition, with no lozenge:
-%\def\key #1{{\ttsl \nohyphenation \uppercase{#1}}\null}
+\def\t#1{{\tt \rawbackslash \frenchspacing #1}\null}
+\let\ttfont = \t
+\let\kbd=\t
+\let\code=\t
+\def\samp #1{`{\tt \rawbackslash \frenchspacing #1}'\null}
+\def\key #1{{\tt \uppercase{#1}}\null}
\def\ctrl #1{{\tt \rawbackslash \hat}#1}
-% @file, @option are the same as @samp.
\let\file=\samp
-\let\option=\samp
-
-% @code is a modification of @t,
-% which makes spaces the same size as normal in the surrounding text.
-\def\tclose#1{%
- {%
- % Change normal interword space to be same as for the current font.
- \spaceskip = \fontdimen2\font
- %
- % Switch to typewriter.
- \tt
- %
- % But `\ ' produces the large typewriter interword space.
- \def\ {{\spaceskip = 0pt{} }}%
- %
- % Turn off hyphenation.
- \nohyphenation
- %
- \rawbackslash
- \plainfrenchspacing
- #1%
- }%
- \null
-}
-% We *must* turn on hyphenation at `-' and `_' in @code.
-% Otherwise, it is too hard to avoid overfull hboxes
-% in the Emacs manual, the Library manual, etc.
+\def\l#1{{\li #1}\null}
-% Unfortunately, TeX uses one parameter (\hyphenchar) to control
-% both hyphenation at - and hyphenation within words.
-% We must therefore turn them both off (\tclose does that)
-% and arrange explicitly to hyphenate at a dash.
-% -- rms.
-{
- \catcode`\-=\active
- \catcode`\_=\active
- %
- \global\def\code{\begingroup
- \catcode`\-=\active \catcode`\_=\active
- \ifallowcodebreaks
- \let-\codedash
- \let_\codeunder
- \else
- \let-\realdash
- \let_\realunder
- \fi
- \codex
- }
-}
+\def\r#1{{\rm #1}}
+\def\s#1{{\sc #1}}
+\def\ii#1{{\it #1}}
-\def\realdash{-}
-\def\codedash{-\discretionary{}{}{}}
-\def\codeunder{%
- % this is all so @math{@code{var_name}+1} can work. In math mode, _
- % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
- % will therefore expand the active definition of _, which is us
- % (inside @code that is), therefore an endless loop.
- \ifusingtt{\ifmmode
- \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_.
- \else\normalunderscore \fi
- \discretionary{}{}{}}%
- {\_}%
-}
-\def\codex #1{\tclose{#1}\endgroup}
-
-% An additional complication: the above will allow breaks after, e.g.,
-% each of the four underscores in __typeof__. This is undesirable in
-% some manuals, especially if they don't have long identifiers in
-% general. @allowcodebreaks provides a way to control this.
-%
-\newif\ifallowcodebreaks \allowcodebreakstrue
-
-\def\keywordtrue{true}
-\def\keywordfalse{false}
-
-\parseargdef\allowcodebreaks{%
- \def\txiarg{#1}%
- \ifx\txiarg\keywordtrue
- \allowcodebreakstrue
- \else\ifx\txiarg\keywordfalse
- \allowcodebreaksfalse
- \else
- \errhelp = \EMsimple
- \errmessage{Unknown @allowcodebreaks option `\txiarg'}%
- \fi\fi
-}
+\def\titlefont#1{{\titlerm #1}}
-% @kbd is like @code, except that if the argument is just one @key command,
-% then @kbd has no effect.
-
-% @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
-% `example' (@kbd uses ttsl only inside of @example and friends),
-% or `code' (@kbd uses normal tty font always).
-\parseargdef\kbdinputstyle{%
- \def\txiarg{#1}%
- \ifx\txiarg\worddistinct
- \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
- \else\ifx\txiarg\wordexample
- \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
- \else\ifx\txiarg\wordcode
- \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
- \else
- \errhelp = \EMsimple
- \errmessage{Unknown @kbdinputstyle option `\txiarg'}%
- \fi\fi\fi
-}
-\def\worddistinct{distinct}
-\def\wordexample{example}
-\def\wordcode{code}
-
-% Default is `distinct.'
-\kbdinputstyle distinct
-
-\def\xkey{\key}
-\def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
-\ifx\one\xkey\ifx\threex\three \key{#2}%
-\else{\tclose{\kbdfont\look}}\fi
-\else{\tclose{\kbdfont\look}}\fi}
-
-% For @indicateurl, @env, @command quotes seem unnecessary, so use \code.
-\let\indicateurl=\code
-\let\env=\code
-\let\command=\code
-
-% @uref (abbreviation for `urlref') takes an optional (comma-separated)
-% second argument specifying the text to display and an optional third
-% arg as text to display instead of (rather than in addition to) the url
-% itself. First (mandatory) arg is the url. Perhaps eventually put in
-% a hypertex \special here.
-%
-\def\uref#1{\douref #1,,,\finish}
-\def\douref#1,#2,#3,#4\finish{\begingroup
- \unsepspaces
- \pdfurl{#1}%
- \setbox0 = \hbox{\ignorespaces #3}%
- \ifdim\wd0 > 0pt
- \unhbox0 % third arg given, show only that
- \else
- \setbox0 = \hbox{\ignorespaces #2}%
- \ifdim\wd0 > 0pt
- \ifpdf
- \unhbox0 % PDF: 2nd arg given, show only it
- \else
- \unhbox0\ (\code{#1})% DVI: 2nd arg given, show both it and url
- \fi
- \else
- \code{#1}% only url given, so show it
- \fi
- \fi
- \endlink
-\endgroup}
-
-% @url synonym for @uref, since that's how everyone uses it.
-%
-\let\url=\uref
+\def\titlepage{\begingroup \parindent=0pt \hbox{}%
+\let\oldpage=\page
+\def\page{\oldpage \hbox{}}}
-% rms does not like angle brackets --karl, 17may97.
-% So now @email is just like @uref, unless we are pdf.
-%
-%\def\email#1{\angleleft{\tt #1}\angleright}
-\ifpdf
- \def\email#1{\doemail#1,,\finish}
- \def\doemail#1,#2,#3\finish{\begingroup
- \unsepspaces
- \pdfurl{mailto:#1}%
- \setbox0 = \hbox{\ignorespaces #2}%
- \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
- \endlink
- \endgroup}
-\else
- \let\email=\uref
-\fi
+\def\Etitlepage{\endgroup\page\HEADINGSon}
-% Check if we are currently using a typewriter font. Since all the
-% Computer Modern typewriter fonts have zero interword stretch (and
-% shrink), and it is reasonable to expect all typewriter fonts to have
-% this property, we can check that font parameter.
-%
-\def\ifmonospace{\ifdim\fontdimen3\font=0pt }
-
-% Typeset a dimension, e.g., `in' or `pt'. The only reason for the
-% argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
-%
-\def\dmn#1{\thinspace #1}
-
-\def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par}
-
-% @l was never documented to mean ``switch to the Lisp font'',
-% and it is not used as such in any manual I can find. We need it for
-% Polish suppressed-l. --karl, 22sep96.
-%\def\l#1{{\li #1}\null}
-
-% Explicit font changes: @r, @sc, undocumented @ii.
-\def\r#1{{\rm #1}} % roman font
-\def\sc#1{{\smallcaps#1}} % smallcaps font
-\def\ii#1{{\it #1}} % italic font
-
-% @acronym for "FBI", "NATO", and the like.
-% We print this one point size smaller, since it's intended for
-% all-uppercase.
-%
-\def\acronym#1{\doacronym #1,,\finish}
-\def\doacronym#1,#2,#3\finish{%
- {\selectfonts\lsize #1}%
- \def\temp{#2}%
- \ifx\temp\empty \else
- \space ({\unsepspaces \ignorespaces \temp \unskip})%
- \fi
-}
-
-% @abbr for "Comput. J." and the like.
-% No font change, but don't do end-of-sentence spacing.
-%
-\def\abbr#1{\doabbr #1,,\finish}
-\def\doabbr#1,#2,#3\finish{%
- {\plainfrenchspacing #1}%
- \def\temp{#2}%
- \ifx\temp\empty \else
- \space ({\unsepspaces \ignorespaces \temp \unskip})%
- \fi
-}
-
-% @pounds{} is a sterling sign, which Knuth put in the CM italic font.
-%
-\def\pounds{{\it\$}}
-
-% @euro{} comes from a separate font, depending on the current style.
-% We use the free feym* fonts from the eurosym package by Henrik
-% Theiling, which support regular, slanted, bold and bold slanted (and
-% "outlined" (blackboard board, sort of) versions, which we don't need).
-% It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
-%
-% Although only regular is the truly official Euro symbol, we ignore
-% that. The Euro is designed to be slightly taller than the regular
-% font height.
-%
-% feymr - regular
-% feymo - slanted
-% feybr - bold
-% feybo - bold slanted
-%
-% There is no good (free) typewriter version, to my knowledge.
-% A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
-% Hmm.
-%
-% Also doesn't work in math. Do we need to do math with euro symbols?
-% Hope not.
-%
-%
-\def\euro{{\eurofont e}}
-\def\eurofont{%
- % We set the font at each command, rather than predefining it in
- % \textfonts and the other font-switching commands, so that
- % installations which never need the symbol don't have to have the
- % font installed.
- %
- % There is only one designed size (nominal 10pt), so we always scale
- % that to the current nominal size.
- %
- % By the way, simply using "at 1em" works for cmr10 and the like, but
- % does not work for cmbx10 and other extended/shrunken fonts.
- %
- \def\eurosize{\csname\curfontsize nominalsize\endcsname}%
- %
- \ifx\curfontstyle\bfstylename
- % bold:
- \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
- \else
- % regular:
- \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
- \fi
- \thiseurofont
-}
-
-% @registeredsymbol - R in a circle. The font for the R should really
-% be smaller yet, but lllsize is the best we can do for now.
-% Adapted from the plain.tex definition of \copyright.
-%
-\def\registeredsymbol{%
- $^{{\ooalign{\hfil\raise.07ex\hbox{\selectfonts\lllsize R}%
- \hfil\crcr\Orb}}%
- }$%
-}
-
-% Laurent Siebenmann reports \Orb undefined with:
-% Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38
-% so we'll define it if necessary.
-%
-\ifx\Orb\undefined
-\def\Orb{\mathhexbox20D}
-\fi
+% Make altmode in file print out right
+\catcode `\^^[=\active \def^^[{$\diamondsuit$}
\message{page headings,}
-\newskip\titlepagetopglue \titlepagetopglue = 1.5in
-\newskip\titlepagebottomglue \titlepagebottomglue = 2pc
-
-% First the title page. Must do @settitle before @titlepage.
-\newif\ifseenauthor
-\newif\iffinishedtitlepage
-
-% Do an implicit @contents or @shortcontents after @end titlepage if the
-% user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage.
-%
-\newif\ifsetcontentsaftertitlepage
- \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue
-\newif\ifsetshortcontentsaftertitlepage
- \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue
-
-\parseargdef\shorttitlepage{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}%
- \endgroup\page\hbox{}\page}
-
-\envdef\titlepage{%
- % Open one extra group, as we want to close it in the middle of \Etitlepage.
- \begingroup
- \parindent=0pt \textfonts
- % Leave some space at the very top of the page.
- \vglue\titlepagetopglue
- % No rule at page bottom unless we print one at the top with @title.
- \finishedtitlepagetrue
- %
- % Most title ``pages'' are actually two pages long, with space
- % at the top of the second. We don't want the ragged left on the second.
- \let\oldpage = \page
- \def\page{%
- \iffinishedtitlepage\else
- \finishtitlepage
- \fi
- \let\page = \oldpage
- \page
- \null
- }%
-}
-
-\def\Etitlepage{%
- \iffinishedtitlepage\else
- \finishtitlepage
- \fi
- % It is important to do the page break before ending the group,
- % because the headline and footline are only empty inside the group.
- % If we use the new definition of \page, we always get a blank page
- % after the title page, which we certainly don't want.
- \oldpage
- \endgroup
- %
- % Need this before the \...aftertitlepage checks so that if they are
- % in effect the toc pages will come out with page numbers.
- \HEADINGSon
- %
- % If they want short, they certainly want long too.
- \ifsetshortcontentsaftertitlepage
- \shortcontents
- \contents
- \global\let\shortcontents = \relax
- \global\let\contents = \relax
- \fi
- %
- \ifsetcontentsaftertitlepage
- \contents
- \global\let\contents = \relax
- \global\let\shortcontents = \relax
- \fi
-}
-
-\def\finishtitlepage{%
- \vskip4pt \hrule height 2pt width \hsize
- \vskip\titlepagebottomglue
- \finishedtitlepagetrue
-}
-
-%%% Macros to be used within @titlepage:
-
-\let\subtitlerm=\tenrm
-\def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
-
-\def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines
- \let\tt=\authortt}
-
-\parseargdef\title{%
- \checkenv\titlepage
- \leftline{\titlefonts\rm #1}
- % print a rule at the page bottom also.
- \finishedtitlepagefalse
- \vskip4pt \hrule height 4pt width \hsize \vskip4pt
-}
-
-\parseargdef\subtitle{%
- \checkenv\titlepage
- {\subtitlefont \rightline{#1}}%
-}
-
-% @author should come last, but may come many times.
-% It can also be used inside @quotation.
-%
-\parseargdef\author{%
- \def\temp{\quotation}%
- \ifx\thisenv\temp
- \def\quotationauthor{#1}% printed in \Equotation.
- \else
- \checkenv\titlepage
- \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
- {\authorfont \leftline{#1}}%
- \fi
-}
-
-
%%% Set up page headings and footings.
\let\thispage=\folio
-\newtoks\evenheadline % headline on even pages
-\newtoks\oddheadline % headline on odd pages
-\newtoks\evenfootline % footline on even pages
-\newtoks\oddfootline % footline on odd pages
+\newtoks \evenheadline % Token sequence for heading line of even pages
+\newtoks \oddheadline % Token sequence for heading line of odd pages
+\newtoks \evenfootline % Token sequence for footing line of even pages
+\newtoks \oddfootline % Token sequence for footing line of odd pages
-% Now make TeX use those variables
-\headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
- \else \the\evenheadline \fi}}
-\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
- \else \the\evenfootline \fi}\HEADINGShook}
-\let\HEADINGShook=\relax
+% Now make Tex use those variables
+\headline={{\textfonts\rm \ifodd\pageno \the\oddheadline \else \the\evenheadline \fi}}
+\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline \else \the\evenfootline \fi}}
% Commands to set those variables.
% For example, this is what @headings on does
@@ -2272,123 +534,92 @@ where each line of input produces a line of output.}
% @evenfooting @thisfile||
% @oddfooting ||@thisfile
-
\def\evenheading{\parsearg\evenheadingxxx}
-\def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish}
-\def\evenheadingyyy #1\|#2\|#3\|#4\finish{%
+\def\oddheading{\parsearg\oddheadingxxx}
+\def\everyheading{\parsearg\everyheadingxxx}
+
+\def\evenfooting{\parsearg\evenfootingxxx}
+\def\oddfooting{\parsearg\oddfootingxxx}
+\def\everyfooting{\parsearg\everyfootingxxx}
+
+{\catcode`\@=0 %
+
+\gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish}
+\gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{%
\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
-\def\oddheading{\parsearg\oddheadingxxx}
-\def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish}
-\def\oddheadingyyy #1\|#2\|#3\|#4\finish{%
+\gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish}
+\gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{%
\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
-\parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
+\gdef\everyheadingxxx #1{\everyheadingyyy #1@|@|@|@|\finish}
+\gdef\everyheadingyyy #1@|#2@|#3@|#4\finish{%
+\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
+\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
-\def\evenfooting{\parsearg\evenfootingxxx}
-\def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish}
-\def\evenfootingyyy #1\|#2\|#3\|#4\finish{%
+\gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish}
+\gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{%
\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
-\def\oddfooting{\parsearg\oddfootingxxx}
-\def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish}
-\def\oddfootingyyy #1\|#2\|#3\|#4\finish{%
- \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
- %
- % Leave some space for the footline. Hopefully ok to assume
- % @evenfooting will not be used by itself.
- \global\advance\pageheight by -\baselineskip
- \global\advance\vsize by -\baselineskip
-}
-
-\parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}}
+\gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish}
+\gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{%
+\global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
+\gdef\everyfootingxxx #1{\everyfootingyyy #1@|@|@|@|\finish}
+\gdef\everyfootingyyy #1@|#2@|#3@|#4\finish{%
+\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
+\global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
+%
+}% unbind the catcode of @.
-% @headings double turns headings on for double-sided printing.
-% @headings single turns headings on for single-sided printing.
-% @headings off turns them off.
-% @headings on same as @headings double, retained for compatibility.
-% @headings after turns on double-sided headings after this page.
-% @headings doubleafter turns on double-sided headings after this page.
-% @headings singleafter turns on single-sided headings after this page.
-% By default, they are off at the start of a document,
-% and turned `on' after @end titlepage.
+% @headings on turns them on.
+% @headings off turns them off.
+% By default, they are off.
\def\headings #1 {\csname HEADINGS#1\endcsname}
-\def\HEADINGSoff{%
+\def\HEADINGSoff{
\global\evenheadline={\hfil} \global\evenfootline={\hfil}
\global\oddheadline={\hfil} \global\oddfootline={\hfil}}
\HEADINGSoff
-% When we turn headings on, set the page number to 1.
-% For double-sided printing, put current file name in lower left corner,
-% chapter name on inside top of right hand pages, document
+% When we turn headings on, set the page number to 1,
+% Put current file name in lower left corner,
+% Put chapter name on inside top of right hand pages, document
% title on inside top of left hand pages, and page numbers on outside top
% edge of all pages.
-\def\HEADINGSdouble{%
+\def\HEADINGSon{
+\pagealignmacro
\global\pageno=1
\global\evenfootline={\hfil}
\global\oddfootline={\hfil}
\global\evenheadline={\line{\folio\hfil\thistitle}}
\global\oddheadline={\line{\thischapter\hfil\folio}}
-\global\let\contentsalignmacro = \chapoddpage
-}
-\let\contentsalignmacro = \chappager
-
-% For single-sided printing, chapter title goes across top left of page,
-% page number on top right.
-\def\HEADINGSsingle{%
-\global\pageno=1
-\global\evenfootline={\hfil}
-\global\oddfootline={\hfil}
-\global\evenheadline={\line{\thischapter\hfil\folio}}
-\global\oddheadline={\line{\thischapter\hfil\folio}}
-\global\let\contentsalignmacro = \chappager
-}
-\def\HEADINGSon{\HEADINGSdouble}
-
-\def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
-\let\HEADINGSdoubleafter=\HEADINGSafter
-\def\HEADINGSdoublex{%
-\global\evenfootline={\hfil}
-\global\oddfootline={\hfil}
-\global\evenheadline={\line{\folio\hfil\thistitle}}
-\global\oddheadline={\line{\thischapter\hfil\folio}}
-\global\let\contentsalignmacro = \chapoddpage
-}
-
-\def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
-\def\HEADINGSsinglex{%
-\global\evenfootline={\hfil}
-\global\oddfootline={\hfil}
-\global\evenheadline={\line{\thischapter\hfil\folio}}
-\global\oddheadline={\line{\thischapter\hfil\folio}}
-\global\let\contentsalignmacro = \chappager
}
% Subroutines used in generating headings
-% This produces Day Month Year style of output.
-% Only define if not already defined, in case a txi-??.tex file has set
-% up a different format (e.g., txi-cs.tex does this).
-\ifx\today\undefined
-\def\today{%
- \number\day\space
- \ifcase\month
- \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
- \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
- \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
- \fi
- \space\number\year}
-\fi
-
-% @settitle line... specifies the title of the document, for headings.
-% It generates no output of its own.
-\def\thistitle{\putwordNoTitle}
-\def\settitle{\parsearg{\gdef\thistitle}}
-
+% Produces Day Month Year style of output.
+\def\today{\number\day\space
+\ifcase\month\or
+January\or February\or March\or April\or May\or June\or
+July\or August\or September\or October\or November\or December\fi
+\space\number\year}
+
+% Use this if you want the Month Day, Year style of output.
+%\def\today{\ifcase\month\or
+%January\or February\or March\or April\or May\or June\or
+%July\or August\or September\or October\or November\or December\fi
+%\space\number\day, \number\year}
+
+% @settitle line... specifies the title of the document, for headings
+% It generates no output of its own
+
+\def\thistitle{No Title}
+\def\settitle{\parsearg\settitlezzz}
+\def\settitlezzz #1{\gdef\thistitle{#1}}
\message{tables,}
-% Tables -- @table, @ftable, @vtable, @item(x).
+
+% Tables -- @table, @ftable, @item(x), @kitem(x), @xitem(x).
% default indentation of table text
\newdimen\tableindent \tableindent=.8in
@@ -2400,804 +631,178 @@ where each line of input produces a line of output.}
% used internally for \itemindent minus \itemmargin
\newdimen\itemmax
-% Note @table, @ftable, and @vtable define @item, @itemx, etc., with
-% these defs.
+% Note @table and @ftable define @item, @itemx, etc., with these defs.
% They also define \itemindex
% to index the item name in whatever manner is desired (perhaps none).
-\newif\ifitemxneedsnegativevskip
+\def\internalBitem{\smallbreak \parsearg\itemzzz}
+\def\internalBitemx{\par \parsearg\itemzzz}
-\def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
+\def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz}
+\def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \par \parsearg\xitemzzz}
-\def\internalBitem{\smallbreak \parsearg\itemzzz}
-\def\internalBitemx{\itemxpar \parsearg\itemzzz}
+\def\internalBkitem{\smallbreak \parsearg\kitemzzz}
+\def\internalBkitemx{\par \parsearg\kitemzzz}
-\def\itemzzz #1{\begingroup %
- \advance\hsize by -\rightskip
- \advance\hsize by -\tableindent
- \setbox0=\hbox{\itemindicate{#1}}%
- \itemindex{#1}%
- \nobreak % This prevents a break before @itemx.
- %
- % If the item text does not fit in the space we have, put it on a line
- % by itself, and do not allow a page break either before or after that
- % line. We do not start a paragraph here because then if the next
- % command is, e.g., @kindex, the whatsit would get put into the
- % horizontal list on a line by itself, resulting in extra blank space.
- \ifdim \wd0>\itemmax
- %
- % Make this a paragraph so we get the \parskip glue and wrapping,
- % but leave it ragged-right.
- \begingroup
- \advance\leftskip by-\tableindent
- \advance\hsize by\tableindent
- \advance\rightskip by0pt plus1fil
- \leavevmode\unhbox0\par
- \endgroup
- %
- % We're going to be starting a paragraph, but we don't want the
- % \parskip glue -- logically it's part of the @item we just started.
- \nobreak \vskip-\parskip
- %
- % Stop a page break at the \parskip glue coming up. However, if
- % what follows is an environment such as @example, there will be no
- % \parskip glue; then the negative vskip we just inserted would
- % cause the example and the item to crash together. So we use this
- % bizarre value of 10001 as a signal to \aboveenvbreak to insert
- % \parskip glue after all. Section titles are handled this way also.
- %
- \penalty 10001
- \endgroup
- \itemxneedsnegativevskipfalse
- \else
- % The item text fits into the space. Start a paragraph, so that the
- % following text (if any) will end up on the same line.
- \noindent
- % Do this with kerns and \unhbox so that if there is a footnote in
- % the item text, it can migrate to the main vertical list and
- % eventually be printed.
- \nobreak\kern-\tableindent
- \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
- \unhbox0
- \nobreak\kern\dimen0
- \endgroup
- \itemxneedsnegativevskiptrue
- \fi
-}
+\def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}\itemzzz {#1}}
-\def\item{\errmessage{@item while not in a list environment}}
-\def\itemx{\errmessage{@itemx while not in a list environment}}
+\def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}\itemzzz {#1}}
-% @table, @ftable, @vtable.
-\envdef\table{%
- \let\itemindex\gobble
- \tablecheck{table}%
-}
-\envdef\ftable{%
- \def\itemindex ##1{\doind {fn}{\code{##1}}}%
- \tablecheck{ftable}%
-}
-\envdef\vtable{%
- \def\itemindex ##1{\doind {vr}{\code{##1}}}%
- \tablecheck{vtable}%
-}
-\def\tablecheck#1{%
- \ifnum \the\catcode`\^^M=\active
- \endgroup
- \errmessage{This command won't work in this context; perhaps the problem is
- that we are \inenvironment\thisenv}%
- \def\next{\doignore{#1}}%
- \else
- \let\next\tablex
- \fi
- \next
-}
-\def\tablex#1{%
- \def\itemindicate{#1}%
- \parsearg\tabley
-}
-\def\tabley#1{%
- {%
- \makevalueexpandable
- \edef\temp{\noexpand\tablez #1\space\space\space}%
- \expandafter
- }\temp \endtablez
-}
-\def\tablez #1 #2 #3 #4\endtablez{%
- \aboveenvbreak
- \ifnum 0#1>0 \advance \leftskip by #1\mil \fi
- \ifnum 0#2>0 \tableindent=#2\mil \fi
- \ifnum 0#3>0 \advance \rightskip by #3\mil \fi
- \itemmax=\tableindent
- \advance \itemmax by -\itemmargin
- \advance \leftskip by \tableindent
- \exdentamount=\tableindent
- \parindent = 0pt
- \parskip = \smallskipamount
- \ifdim \parskip=0pt \parskip=2pt \fi
- \let\item = \internalBitem
- \let\itemx = \internalBitemx
+\def\itemzzz #1{\begingroup %
+\advance \hsize by -\rightskip %
+\advance \hsize by -\leftskip %
+\setbox0=\hbox{\itemfont{#1}}%
+\itemindex{#1}%
+\parskip=0in %
+\noindent %
+\ifdim \wd0>\itemmax %
+\vadjust{\penalty 10000}%
+\hbox to \hsize{\hskip -\tableindent\box0\hss}\ %
+\else %
+\hbox to 0pt{\hskip -\tableindent\box0\hss}%
+\fi %
+\endgroup %
+}
+
+\def\item{\errmessage{@item while not in a table}}
+\def\itemx{\errmessage{@itemx while not in a table}}
+\def\kitem{\errmessage{@kitem while not in a table}}
+\def\kitemx{\errmessage{@kitemx while not in a table}}
+\def\xitem{\errmessage{@xitem while not in a table}}
+\def\xitemx{\errmessage{@xitemx while not in a table}}
+
+%% Contains a kludge to get @end[description] to work
+\def\description{\tablez{\dontindex}{1}{}{}{}{}}
+
+\def\table{\begingroup\inENV\obeylines\obeyspaces\tablex}
+{\obeylines\obeyspaces%
+\gdef\tablex #1^^M{%
+\tabley\dontindex#1 \endtabley}}
+
+\def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex}
+{\obeylines\obeyspaces%
+\gdef\ftablex #1^^M{%
+\tabley\fnitemindex#1 \endtabley}}
+
+\def\dontindex #1{}
+\def\fnitemindex #1{\doind {fn}{\code{#1}}}%
+
+{\obeyspaces %
+\gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup%
+\tablez{#1}{#2}{#3}{#4}{#5}{#6}}}
+
+\def\tablez #1#2#3#4#5#6{%
+\aboveenvbreak %
+\begingroup %
+\def\Edescription{\Etable}% Neccessary kludge.
+\let\itemindex=#1%
+\ifnum 0#3>0 \advance \leftskip by #3\mil \fi %
+\ifnum 0#4>0 \tableindent=#4\mil \fi %
+\ifnum 0#5>0 \advance \rightskip by #5\mil \fi %
+\def\itemfont{#2}%
+\itemmax=\tableindent %
+\advance \itemmax by -\itemmargin %
+\advance \leftskip by \tableindent %
+\parindent = 0pt
+\parskip = \smallskipamount
+\ifdim \parskip=0pt \parskip=2pt \fi%
+\def\Etable{\endgraf\endgroup\afterenvbreak}%
+\let\item = \internalBitem %
+\let\itemx = \internalBitemx %
+\let\kitem = \internalBkitem %
+\let\kitemx = \internalBkitemx %
+\let\xitem = \internalBxitem %
+\let\xitemx = \internalBxitemx %
}
-\def\Etable{\endgraf\afterenvbreak}
-\let\Eftable\Etable
-\let\Evtable\Etable
-\let\Eitemize\Etable
-\let\Eenumerate\Etable
% This is the counter used by @enumerate, which is really @itemize
\newcount \itemno
-\envdef\itemize{\parsearg\doitemize}
-
-\def\doitemize#1{%
- \aboveenvbreak
- \itemmax=\itemindent
- \advance\itemmax by -\itemmargin
- \advance\leftskip by \itemindent
- \exdentamount=\itemindent
- \parindent=0pt
- \parskip=\smallskipamount
- \ifdim\parskip=0pt \parskip=2pt \fi
- \def\itemcontents{#1}%
- % @itemize with no arg is equivalent to @itemize @bullet.
- \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi
- \let\item=\itemizeitem
-}
-
-% Definition of @item while inside @itemize and @enumerate.
-%
-\def\itemizeitem{%
- \advance\itemno by 1 % for enumerations
- {\let\par=\endgraf \smallbreak}% reasonable place to break
- {%
- % If the document has an @itemize directly after a section title, a
- % \nobreak will be last on the list, and \sectionheading will have
- % done a \vskip-\parskip. In that case, we don't want to zero
- % parskip, or the item text will crash with the heading. On the
- % other hand, when there is normal text preceding the item (as there
- % usually is), we do want to zero parskip, or there would be too much
- % space. In that case, we won't have a \nobreak before. At least
- % that's the theory.
- \ifnum\lastpenalty<10000 \parskip=0in \fi
- \noindent
- \hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
- \vadjust{\penalty 1200}}% not good to break after first line of item.
- \flushcr
-}
-
-% \splitoff TOKENS\endmark defines \first to be the first token in
-% TOKENS, and \rest to be the remainder.
-%
-\def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
-
-% Allow an optional argument of an uppercase letter, lowercase letter,
-% or number, to specify the first label in the enumerated list. No
-% argument is the same as `1'.
-%
-\envparseargdef\enumerate{\enumeratey #1 \endenumeratey}
-\def\enumeratey #1 #2\endenumeratey{%
- % If we were given no argument, pretend we were given `1'.
- \def\thearg{#1}%
- \ifx\thearg\empty \def\thearg{1}\fi
- %
- % Detect if the argument is a single token. If so, it might be a
- % letter. Otherwise, the only valid thing it can be is a number.
- % (We will always have one token, because of the test we just made.
- % This is a good thing, since \splitoff doesn't work given nothing at
- % all -- the first parameter is undelimited.)
- \expandafter\splitoff\thearg\endmark
- \ifx\rest\empty
- % Only one token in the argument. It could still be anything.
- % A ``lowercase letter'' is one whose \lccode is nonzero.
- % An ``uppercase letter'' is one whose \lccode is both nonzero, and
- % not equal to itself.
- % Otherwise, we assume it's a number.
- %
- % We need the \relax at the end of the \ifnum lines to stop TeX from
- % continuing to look for a <number>.
- %
- \ifnum\lccode\expandafter`\thearg=0\relax
- \numericenumerate % a number (we hope)
- \else
- % It's a letter.
- \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
- \lowercaseenumerate % lowercase letter
- \else
- \uppercaseenumerate % uppercase letter
- \fi
- \fi
- \else
- % Multiple tokens in the argument. We hope it's a number.
- \numericenumerate
- \fi
-}
-
-% An @enumerate whose labels are integers. The starting integer is
-% given in \thearg.
-%
-\def\numericenumerate{%
- \itemno = \thearg
- \startenumeration{\the\itemno}%
-}
-
-% The starting (lowercase) letter is in \thearg.
-\def\lowercaseenumerate{%
- \itemno = \expandafter`\thearg
- \startenumeration{%
- % Be sure we're not beyond the end of the alphabet.
- \ifnum\itemno=0
- \errmessage{No more lowercase letters in @enumerate; get a bigger
- alphabet}%
- \fi
- \char\lccode\itemno
- }%
-}
-
-% The starting (uppercase) letter is in \thearg.
-\def\uppercaseenumerate{%
- \itemno = \expandafter`\thearg
- \startenumeration{%
- % Be sure we're not beyond the end of the alphabet.
- \ifnum\itemno=0
- \errmessage{No more uppercase letters in @enumerate; get a bigger
- alphabet}
- \fi
- \char\uccode\itemno
- }%
-}
-
-% Call \doitemize, adding a period to the first argument and supplying the
-% common last two arguments. Also subtract one from the initial value in
-% \itemno, since @item increments \itemno.
-%
-\def\startenumeration#1{%
- \advance\itemno by -1
- \doitemize{#1.}\flushcr
-}
-
-% @alphaenumerate and @capsenumerate are abbreviations for giving an arg
-% to @enumerate.
-%
-\def\alphaenumerate{\enumerate{a}}
-\def\capsenumerate{\enumerate{A}}
-\def\Ealphaenumerate{\Eenumerate}
-\def\Ecapsenumerate{\Eenumerate}
-
-
-% @multitable macros
-% Amy Hendrickson, 8/18/94, 3/6/96
-%
-% @multitable ... @end multitable will make as many columns as desired.
-% Contents of each column will wrap at width given in preamble. Width
-% can be specified either with sample text given in a template line,
-% or in percent of \hsize, the current width of text on page.
-
-% Table can continue over pages but will only break between lines.
-
-% To make preamble:
-%
-% Either define widths of columns in terms of percent of \hsize:
-% @multitable @columnfractions .25 .3 .45
-% @item ...
-%
-% Numbers following @columnfractions are the percent of the total
-% current hsize to be used for each column. You may use as many
-% columns as desired.
-
-
-% Or use a template:
-% @multitable {Column 1 template} {Column 2 template} {Column 3 template}
-% @item ...
-% using the widest term desired in each column.
-
-% Each new table line starts with @item, each subsequent new column
-% starts with @tab. Empty columns may be produced by supplying @tab's
-% with nothing between them for as many times as empty columns are needed,
-% ie, @tab@tab@tab will produce two empty columns.
-
-% @item, @tab do not need to be on their own lines, but it will not hurt
-% if they are.
-
-% Sample multitable:
-
-% @multitable {Column 1 template} {Column 2 template} {Column 3 template}
-% @item first col stuff @tab second col stuff @tab third col
-% @item
-% first col stuff
-% @tab
-% second col stuff
-% @tab
-% third col
-% @item first col stuff @tab second col stuff
-% @tab Many paragraphs of text may be used in any column.
-%
-% They will wrap at the width determined by the template.
-% @item@tab@tab This will be in third column.
-% @end multitable
-
-% Default dimensions may be reset by user.
-% @multitableparskip is vertical space between paragraphs in table.
-% @multitableparindent is paragraph indent in table.
-% @multitablecolmargin is horizontal space to be left between columns.
-% @multitablelinespace is space to leave between table items, baseline
-% to baseline.
-% 0pt means it depends on current normal line spacing.
-%
-\newskip\multitableparskip
-\newskip\multitableparindent
-\newdimen\multitablecolspace
-\newskip\multitablelinespace
-\multitableparskip=0pt
-\multitableparindent=6pt
-\multitablecolspace=12pt
-\multitablelinespace=0pt
-
-% Macros used to set up halign preamble:
-%
-\let\endsetuptable\relax
-\def\xendsetuptable{\endsetuptable}
-\let\columnfractions\relax
-\def\xcolumnfractions{\columnfractions}
-\newif\ifsetpercent
-
-% #1 is the @columnfraction, usually a decimal number like .5, but might
-% be just 1. We just use it, whatever it is.
-%
-\def\pickupwholefraction#1 {%
- \global\advance\colcount by 1
- \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}%
- \setuptable
-}
-
-\newcount\colcount
-\def\setuptable#1{%
- \def\firstarg{#1}%
- \ifx\firstarg\xendsetuptable
- \let\go = \relax
- \else
- \ifx\firstarg\xcolumnfractions
- \global\setpercenttrue
- \else
- \ifsetpercent
- \let\go\pickupwholefraction
- \else
- \global\advance\colcount by 1
- \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a
- % separator; typically that is always in the input, anyway.
- \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
- \fi
- \fi
- \ifx\go\pickupwholefraction
- % Put the argument back for the \pickupwholefraction call, so
- % we'll always have a period there to be parsed.
- \def\go{\pickupwholefraction#1}%
- \else
- \let\go = \setuptable
- \fi%
- \fi
- \go
-}
-
-% multitable-only commands.
-%
-% @headitem starts a heading row, which we typeset in bold.
-% Assignments have to be global since we are inside the implicit group
-% of an alignment entry. Note that \everycr resets \everytab.
-\def\headitem{\checkenv\multitable \crcr \global\everytab={\bf}\the\everytab}%
-%
-% A \tab used to include \hskip1sp. But then the space in a template
-% line is not enough. That is bad. So let's go back to just `&' until
-% we encounter the problem it was intended to solve again.
-% --karl, nathan@acm.org, 20apr99.
-\def\tab{\checkenv\multitable &\the\everytab}%
-
-% @multitable ... @end multitable definitions:
-%
-\newtoks\everytab % insert after every tab.
-%
-\envdef\multitable{%
- \vskip\parskip
- \startsavinginserts
- %
- % @item within a multitable starts a normal row.
- % We use \def instead of \let so that if one of the multitable entries
- % contains an @itemize, we don't choke on the \item (seen as \crcr aka
- % \endtemplate) expanding \doitemize.
- \def\item{\crcr}%
- %
- \tolerance=9500
- \hbadness=9500
- \setmultitablespacing
- \parskip=\multitableparskip
- \parindent=\multitableparindent
- \overfullrule=0pt
- \global\colcount=0
- %
- \everycr = {%
- \noalign{%
- \global\everytab={}%
- \global\colcount=0 % Reset the column counter.
- % Check for saved footnotes, etc.
- \checkinserts
- % Keeps underfull box messages off when table breaks over pages.
- %\filbreak
- % Maybe so, but it also creates really weird page breaks when the
- % table breaks over pages. Wouldn't \vfil be better? Wait until the
- % problem manifests itself, so it can be fixed for real --karl.
- }%
- }%
- %
- \parsearg\domultitable
-}
-\def\domultitable#1{%
- % To parse everything between @multitable and @item:
- \setuptable#1 \endsetuptable
- %
- % This preamble sets up a generic column definition, which will
- % be used as many times as user calls for columns.
- % \vtop will set a single line and will also let text wrap and
- % continue for many paragraphs if desired.
- \halign\bgroup &%
- \global\advance\colcount by 1
- \multistrut
- \vtop{%
- % Use the current \colcount to find the correct column width:
- \hsize=\expandafter\csname col\the\colcount\endcsname
- %
- % In order to keep entries from bumping into each other
- % we will add a \leftskip of \multitablecolspace to all columns after
- % the first one.
- %
- % If a template has been used, we will add \multitablecolspace
- % to the width of each template entry.
- %
- % If the user has set preamble in terms of percent of \hsize we will
- % use that dimension as the width of the column, and the \leftskip
- % will keep entries from bumping into each other. Table will start at
- % left margin and final column will justify at right margin.
- %
- % Make sure we don't inherit \rightskip from the outer environment.
- \rightskip=0pt
- \ifnum\colcount=1
- % The first column will be indented with the surrounding text.
- \advance\hsize by\leftskip
- \else
- \ifsetpercent \else
- % If user has not set preamble in terms of percent of \hsize
- % we will advance \hsize by \multitablecolspace.
- \advance\hsize by \multitablecolspace
- \fi
- % In either case we will make \leftskip=\multitablecolspace:
- \leftskip=\multitablecolspace
- \fi
- % Ignoring space at the beginning and end avoids an occasional spurious
- % blank line, when TeX decides to break the line at the space before the
- % box from the multistrut, so the strut ends up on a line by itself.
- % For example:
- % @multitable @columnfractions .11 .89
- % @item @code{#}
- % @tab Legal holiday which is valid in major parts of the whole country.
- % Is automatically provided with highlighting sequences respectively
- % marking characters.
- \noindent\ignorespaces##\unskip\multistrut
- }\cr
-}
-\def\Emultitable{%
- \crcr
- \egroup % end the \halign
- \global\setpercentfalse
-}
-
-\def\setmultitablespacing{%
- \def\multistrut{\strut}% just use the standard line spacing
- %
- % Compute \multitablelinespace (if not defined by user) for use in
- % \multitableparskip calculation. We used define \multistrut based on
- % this, but (ironically) that caused the spacing to be off.
- % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100.
-\ifdim\multitablelinespace=0pt
-\setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
-\global\advance\multitablelinespace by-\ht0
-\fi
-%% Test to see if parskip is larger than space between lines of
-%% table. If not, do nothing.
-%% If so, set to same dimension as multitablelinespace.
-\ifdim\multitableparskip>\multitablelinespace
-\global\multitableparskip=\multitablelinespace
-\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
- %% than skip between lines in the table.
-\fi%
-\ifdim\multitableparskip=0pt
-\global\multitableparskip=\multitablelinespace
-\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
- %% than skip between lines in the table.
-\fi}
-
-
-\message{conditionals,}
-
-% @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext,
-% @ifnotxml always succeed. They currently do nothing; we don't
-% attempt to check whether the conditionals are properly nested. But we
-% have to remember that they are conditionals, so that @end doesn't
-% attempt to close an environment group.
-%
-\def\makecond#1{%
- \expandafter\let\csname #1\endcsname = \relax
- \expandafter\let\csname iscond.#1\endcsname = 1
-}
-\makecond{iftex}
-\makecond{ifnotdocbook}
-\makecond{ifnothtml}
-\makecond{ifnotinfo}
-\makecond{ifnotplaintext}
-\makecond{ifnotxml}
-
-% Ignore @ignore, @ifhtml, @ifinfo, and the like.
-%
-\def\direntry{\doignore{direntry}}
-\def\documentdescription{\doignore{documentdescription}}
-\def\docbook{\doignore{docbook}}
-\def\html{\doignore{html}}
-\def\ifdocbook{\doignore{ifdocbook}}
-\def\ifhtml{\doignore{ifhtml}}
-\def\ifinfo{\doignore{ifinfo}}
-\def\ifnottex{\doignore{ifnottex}}
-\def\ifplaintext{\doignore{ifplaintext}}
-\def\ifxml{\doignore{ifxml}}
-\def\ignore{\doignore{ignore}}
-\def\menu{\doignore{menu}}
-\def\xml{\doignore{xml}}
-
-% Ignore text until a line `@end #1', keeping track of nested conditionals.
-%
-% A count to remember the depth of nesting.
-\newcount\doignorecount
-
-\def\doignore#1{\begingroup
- % Scan in ``verbatim'' mode:
- \obeylines
- \catcode`\@ = \other
- \catcode`\{ = \other
- \catcode`\} = \other
- %
- % Make sure that spaces turn into tokens that match what \doignoretext wants.
- \spaceisspace
- %
- % Count number of #1's that we've seen.
- \doignorecount = 0
- %
- % Swallow text until we reach the matching `@end #1'.
- \dodoignore{#1}%
-}
-
-{ \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source.
- \obeylines %
- %
- \gdef\dodoignore#1{%
- % #1 contains the command name as a string, e.g., `ifinfo'.
- %
- % Define a command to find the next `@end #1'.
- \long\def\doignoretext##1^^M@end #1{%
- \doignoretextyyy##1^^M@#1\_STOP_}%
- %
- % And this command to find another #1 command, at the beginning of a
- % line. (Otherwise, we would consider a line `@c @ifset', for
- % example, to count as an @ifset for nesting.)
- \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}%
- %
- % And now expand that command.
- \doignoretext ^^M%
- }%
-}
-
-\def\doignoreyyy#1{%
- \def\temp{#1}%
- \ifx\temp\empty % Nothing found.
- \let\next\doignoretextzzz
- \else % Found a nested condition, ...
- \advance\doignorecount by 1
- \let\next\doignoretextyyy % ..., look for another.
- % If we're here, #1 ends with ^^M\ifinfo (for example).
- \fi
- \next #1% the token \_STOP_ is present just after this macro.
-}
-
-% We have to swallow the remaining "\_STOP_".
-%
-\def\doignoretextzzz#1{%
- \ifnum\doignorecount = 0 % We have just found the outermost @end.
- \let\next\enddoignore
- \else % Still inside a nested condition.
- \advance\doignorecount by -1
- \let\next\doignoretext % Look for the next @end.
- \fi
- \next
-}
-
-% Finish off ignored text.
-{ \obeylines%
- % Ignore anything after the last `@end #1'; this matters in verbatim
- % environments, where otherwise the newline after an ignored conditional
- % would result in a blank line in the output.
- \gdef\enddoignore#1^^M{\endgroup\ignorespaces}%
-}
-
+\def\itemize{\parsearg\itemizezzz}
-% @set VAR sets the variable VAR to an empty value.
-% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
-%
-% Since we want to separate VAR from REST-OF-LINE (which might be
-% empty), we can't just use \parsearg; we have to insert a space of our
-% own to delimit the rest of the line, and then take it out again if we
-% didn't need it.
-% We rely on the fact that \parsearg sets \catcode`\ =10.
-%
-\parseargdef\set{\setyyy#1 \endsetyyy}
-\def\setyyy#1 #2\endsetyyy{%
- {%
- \makevalueexpandable
- \def\temp{#2}%
- \edef\next{\gdef\makecsname{SET#1}}%
- \ifx\temp\empty
- \next{}%
- \else
- \setzzz#2\endsetzzz
- \fi
- }%
-}
-% Remove the trailing space \setxxx inserted.
-\def\setzzz#1 \endsetzzz{\next{#1}}
-
-% @clear VAR clears (i.e., unsets) the variable VAR.
-%
-\parseargdef\clear{%
- {%
- \makevalueexpandable
- \global\expandafter\let\csname SET#1\endcsname=\relax
- }%
-}
-
-% @value{foo} gets the text saved in variable foo.
-\def\value{\begingroup\makevalueexpandable\valuexxx}
-\def\valuexxx#1{\expandablevalue{#1}\endgroup}
-{
- \catcode`\- = \active \catcode`\_ = \active
- %
- \gdef\makevalueexpandable{%
- \let\value = \expandablevalue
- % We don't want these characters active, ...
- \catcode`\-=\other \catcode`\_=\other
- % ..., but we might end up with active ones in the argument if
- % we're called from @code, as @code{@value{foo-bar_}}, though.
- % So \let them to their normal equivalents.
- \let-\realdash \let_\normalunderscore
- }
-}
+\def\itemizezzz #1{\itemizey {#1}{\Eitemize}}
-% We have this subroutine so that we can handle at least some @value's
-% properly in indexes (we call \makevalueexpandable in \indexdummies).
-% The command has to be fully expandable (if the variable is set), since
-% the result winds up in the index file. This means that if the
-% variable's value contains other Texinfo commands, it's almost certain
-% it will fail (although perhaps we could fix that with sufficient work
-% to do a one-level expansion on the result, instead of complete).
-%
-\def\expandablevalue#1{%
- \expandafter\ifx\csname SET#1\endcsname\relax
- {[No value for ``#1'']}%
- \message{Variable `#1', used in @value, is not set.}%
- \else
- \csname SET#1\endcsname
- \fi
-}
+\def\itemizey #1#2{%
+\aboveenvbreak %
+\begingroup %
+\itemno = 0 %
+\itemmax=\itemindent %
+\advance \itemmax by -\itemmargin %
+\advance \leftskip by \itemindent %
+\parindent = 0pt
+\parskip = \smallskipamount
+\ifdim \parskip=0pt \parskip=2pt \fi%
+\def#2{\endgraf\endgroup\afterenvbreak}%
+\def\itemcontents{#1}%
+\let\item=\itemizeitem}
-% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
-% with @set.
-%
-% To get special treatment of `@end ifset,' call \makeond and the redefine.
-%
-\makecond{ifset}
-\def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}}
-\def\doifset#1#2{%
- {%
- \makevalueexpandable
- \let\next=\empty
- \expandafter\ifx\csname SET#2\endcsname\relax
- #1% If not set, redefine \next.
- \fi
- \expandafter
- }\next
-}
-\def\ifsetfail{\doignore{ifset}}
-
-% @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been
-% defined with @set, or has been undefined with @clear.
-%
-% The `\else' inside the `\doifset' parameter is a trick to reuse the
-% above code: if the variable is not set, do nothing, if it is set,
-% then redefine \next to \ifclearfail.
-%
-\makecond{ifclear}
-\def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}}
-\def\ifclearfail{\doignore{ifclear}}
+\def\bullet{$\ptexbullet$}
+\def\minus{$-$}
-% @dircategory CATEGORY -- specify a category of the dir file
-% which this file should belong to. Ignore this in TeX.
-\let\dircategory=\comment
+\def\enumerate{\itemizey{\the\itemno.}\Eenumerate\flushcr}
-% @defininfoenclose.
-\let\definfoenclose=\comment
+% Definition of @item while inside @itemize.
+\def\itemizeitem{%
+\advance\itemno by 1
+{\let\par=\endgraf \smallbreak}%
+\ifhmode \errmessage{\in hmode at itemizeitem}\fi
+{\parskip=0in \hskip 0pt
+\hbox to 0pt{\hss \itemcontents\hskip \itemmargin}%
+\vadjust{\penalty 300}}%
+\flushcr}
\message{indexing,}
% Index generation facilities
% Define \newwrite to be identical to plain tex's \newwrite
-% except not \outer, so it can be used within macros and \if's.
-\edef\newwrite{\makecsname{ptexnewwrite}}
+% except not \outer, so it can be used within \newindex.
+{\catcode`\@=11
+\gdef\newwrite{\alloc@7\write\chardef\sixt@@n}}
% \newindex {foo} defines an index named foo.
% It automatically defines \fooindex such that
% \fooindex ...rest of line... puts an entry in the index foo.
% It also defines \fooindfile to be the number of the output channel for
-% the file that accumulates this index. The file's extension is foo.
+% the file that accumulates this index. The file's extension is foo.
% The name of an index should be no more than 2 characters long
% for the sake of vms.
-%
-\def\newindex#1{%
- \iflinks
- \expandafter\newwrite \csname#1indfile\endcsname
- \openout \csname#1indfile\endcsname \jobname.#1 % Open the file
- \fi
- \expandafter\xdef\csname#1index\endcsname{% % Define @#1index
- \noexpand\doindex{#1}}
+
+\def\newindex #1{
+\expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
+\openout \csname#1indfile\endcsname \jobname.#1 % Open the file
+\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex
+\noexpand\doindex {#1}}
}
% @defindex foo == \newindex{foo}
-%
+
\def\defindex{\parsearg\newindex}
% Define @defcodeindex, like @defindex except put all entries in @code.
-%
-\def\defcodeindex{\parsearg\newcodeindex}
-%
-\def\newcodeindex#1{%
- \iflinks
- \expandafter\newwrite \csname#1indfile\endcsname
- \openout \csname#1indfile\endcsname \jobname.#1
- \fi
- \expandafter\xdef\csname#1index\endcsname{%
- \noexpand\docodeindex{#1}}%
+
+\def\newcodeindex #1{
+\expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
+\openout \csname#1indfile\endcsname \jobname.#1 % Open the file
+\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex
+\noexpand\docodeindex {#1}}
}
+\def\defcodeindex{\parsearg\newcodeindex}
% @synindex foo bar makes index foo feed into index bar.
% Do this instead of @defindex foo if you don't want it as a separate index.
-%
+\def\synindex #1 #2 {%
+\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex
+\noexpand\doindex {#2}}%
+}
+
% @syncodeindex foo bar similar, but put all entries made for index foo
% inside @code.
-%
-\def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}}
-\def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}}
-
-% #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
-% #3 the target index (bar).
-\def\dosynindex#1#2#3{%
- % Only do \closeout if we haven't already done it, else we'll end up
- % closing the target index.
- \expandafter \ifx\csname donesynindex#2\endcsname \undefined
- % The \closeout helps reduce unnecessary open files; the limit on the
- % Acorn RISC OS is a mere 16 files.
- \expandafter\closeout\csname#2indfile\endcsname
- \expandafter\let\csname\donesynindex#2\endcsname = 1
- \fi
- % redefine \fooindfile:
- \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
- \expandafter\let\csname#2indfile\endcsname=\temp
- % redefine \fooindex:
- \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
+\def\syncodeindex #1 #2 {%
+\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex
+\noexpand\docodeindex {#2}}%
}
% Define \doindex, the driver for all \fooindex macros.
@@ -3217,394 +822,74 @@ where each line of input produces a line of output.}
\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
-% Take care of Texinfo commands that can appear in an index entry.
-% Since there are some commands we want to expand, and others we don't,
-% we have to laboriously prevent expansion for those that we don't.
-%
\def\indexdummies{%
- \escapechar = `\\ % use backslash in output files.
- \def\@{@}% change to @@ when we switch to @ as escape char in index files.
- \def\ {\realbackslash\space }%
- % Need these in case \tex is in effect and \{ is a \delimiter again.
- % But can't use \lbracecmd and \rbracecmd because texindex assumes
- % braces and backslashes are used only as delimiters.
- \let\{ = \mylbrace
- \let\} = \myrbrace
- %
- % Do the redefinitions.
- \commondummies
-}
-
-% For the aux and toc files, @ is the escape character. So we want to
-% redefine everything using @ as the escape character (instead of
-% \realbackslash, still used for index files). When everything uses @,
-% this will be simpler.
-%
-\def\atdummies{%
- \def\@{@@}%
- \def\ {@ }%
- \let\{ = \lbraceatcmd
- \let\} = \rbraceatcmd
- %
- % Do the redefinitions.
- \commondummies
- \otherbackslash
-}
-
-% Called from \indexdummies and \atdummies.
-%
-\def\commondummies{%
- %
- % \definedummyword defines \#1 as \string\#1\space, thus effectively
- % preventing its expansion. This is used only for control% words,
- % not control letters, because the \space would be incorrect for
- % control characters, but is needed to separate the control word
- % from whatever follows.
- %
- % For control letters, we have \definedummyletter, which omits the
- % space.
- %
- % These can be used both for control words that take an argument and
- % those that do not. If it is followed by {arg} in the input, then
- % that will dutifully get written to the index (or wherever).
- %
- \def\definedummyword ##1{\def##1{\string##1\space}}%
- \def\definedummyletter##1{\def##1{\string##1}}%
- \let\definedummyaccent\definedummyletter
- %
- \commondummiesnofonts
- %
- \definedummyletter\_%
- %
- % Non-English letters.
- \definedummyword\AA
- \definedummyword\AE
- \definedummyword\L
- \definedummyword\OE
- \definedummyword\O
- \definedummyword\aa
- \definedummyword\ae
- \definedummyword\l
- \definedummyword\oe
- \definedummyword\o
- \definedummyword\ss
- \definedummyword\exclamdown
- \definedummyword\questiondown
- \definedummyword\ordf
- \definedummyword\ordm
- %
- % Although these internal commands shouldn't show up, sometimes they do.
- \definedummyword\bf
- \definedummyword\gtr
- \definedummyword\hat
- \definedummyword\less
- \definedummyword\sf
- \definedummyword\sl
- \definedummyword\tclose
- \definedummyword\tt
- %
- \definedummyword\LaTeX
- \definedummyword\TeX
- %
- % Assorted special characters.
- \definedummyword\bullet
- \definedummyword\comma
- \definedummyword\copyright
- \definedummyword\registeredsymbol
- \definedummyword\dots
- \definedummyword\enddots
- \definedummyword\equiv
- \definedummyword\error
- \definedummyword\euro
- \definedummyword\expansion
- \definedummyword\minus
- \definedummyword\pounds
- \definedummyword\point
- \definedummyword\print
- \definedummyword\result
- %
- % We want to disable all macros so that they are not expanded by \write.
- \macrolist
- %
- \normalturnoffactive
- %
- % Handle some cases of @value -- where it does not contain any
- % (non-fully-expandable) commands.
- \makevalueexpandable
-}
-
-% \commondummiesnofonts: common to \commondummies and \indexnofonts.
-%
-\def\commondummiesnofonts{%
- % Control letters and accents.
- \definedummyletter\!%
- \definedummyaccent\"%
- \definedummyaccent\'%
- \definedummyletter\*%
- \definedummyaccent\,%
- \definedummyletter\.%
- \definedummyletter\/%
- \definedummyletter\:%
- \definedummyaccent\=%
- \definedummyletter\?%
- \definedummyaccent\^%
- \definedummyaccent\`%
- \definedummyaccent\~%
- \definedummyword\u
- \definedummyword\v
- \definedummyword\H
- \definedummyword\dotaccent
- \definedummyword\ringaccent
- \definedummyword\tieaccent
- \definedummyword\ubaraccent
- \definedummyword\udotaccent
- \definedummyword\dotless
- %
- % Texinfo font commands.
- \definedummyword\b
- \definedummyword\i
- \definedummyword\r
- \definedummyword\sc
- \definedummyword\t
- %
- % Commands that take arguments.
- \definedummyword\acronym
- \definedummyword\cite
- \definedummyword\code
- \definedummyword\command
- \definedummyword\dfn
- \definedummyword\emph
- \definedummyword\env
- \definedummyword\file
- \definedummyword\kbd
- \definedummyword\key
- \definedummyword\math
- \definedummyword\option
- \definedummyword\pxref
- \definedummyword\ref
- \definedummyword\samp
- \definedummyword\strong
- \definedummyword\tie
- \definedummyword\uref
- \definedummyword\url
- \definedummyword\var
- \definedummyword\verb
- \definedummyword\w
- \definedummyword\xref
+\def\bf{\realbackslash bf }%
+\def\rm{\realbackslash rm }%
+\def\sl{\realbackslash sl }%
+\def\dots{\realbackslash dots }%
+\def\copyright{\realbackslash copyright }%
}
-% \indexnofonts is used when outputting the strings to sort the index
-% by, and when constructing control sequence names. It eliminates all
-% control sequences and just writes whatever the best ASCII sort string
-% would be for a given command (usually its argument).
-%
+% \indexnofonts no-ops all font-change commands.
+% This is used when outputting the strings to sort the index by.
+\def\indexdummyfont#1{#1}
\def\indexnofonts{%
- % Accent commands should become @asis.
- \def\definedummyaccent##1{\let##1\asis}%
- % We can just ignore other control letters.
- \def\definedummyletter##1{\let##1\empty}%
- % Hopefully, all control words can become @asis.
- \let\definedummyword\definedummyaccent
- %
- \commondummiesnofonts
- %
- % Don't no-op \tt, since it isn't a user-level command
- % and is used in the definitions of the active chars like <, >, |, etc.
- % Likewise with the other plain tex font commands.
- %\let\tt=\asis
- %
- \def\ { }%
- \def\@{@}%
- % how to handle braces?
- \def\_{\normalunderscore}%
- %
- % Non-English letters.
- \def\AA{AA}%
- \def\AE{AE}%
- \def\L{L}%
- \def\OE{OE}%
- \def\O{O}%
- \def\aa{aa}%
- \def\ae{ae}%
- \def\l{l}%
- \def\oe{oe}%
- \def\o{o}%
- \def\ss{ss}%
- \def\exclamdown{!}%
- \def\questiondown{?}%
- \def\ordf{a}%
- \def\ordm{o}%
- %
- \def\LaTeX{LaTeX}%
- \def\TeX{TeX}%
- %
- % Assorted special characters.
- % (The following {} will end up in the sort string, but that's ok.)
- \def\bullet{bullet}%
- \def\comma{,}%
- \def\copyright{copyright}%
- \def\registeredsymbol{R}%
- \def\dots{...}%
- \def\enddots{...}%
- \def\equiv{==}%
- \def\error{error}%
- \def\euro{euro}%
- \def\expansion{==>}%
- \def\minus{-}%
- \def\pounds{pounds}%
- \def\point{.}%
- \def\print{-|}%
- \def\result{=>}%
- %
- % We need to get rid of all macros, leaving only the arguments (if present).
- % Of course this is not nearly correct, but it is the best we can do for now.
- % makeinfo does not expand macros in the argument to @deffn, which ends up
- % writing an index entry, and texindex isn't prepared for an index sort entry
- % that starts with \.
- %
- % Since macro invocations are followed by braces, we can just redefine them
- % to take a single TeX argument. The case of a macro invocation that
- % goes to end-of-line is not handled.
- %
- \macrolist
+\let\code=\indexdummyfont
+\let\samp=\indexdummyfont
+\let\kbd=\indexdummyfont
+\let\key=\indexdummyfont
+\let\var=\indexdummyfont
}
-\let\indexbackslash=0 %overridden during \printindex.
-\let\SETmarginindex=\relax % put index entries in margin (undocumented)?
+% To define \realbackslash, we must make \ not be an escape.
+% We must first make another character (@) an escape
+% so we do not become unable to do a definition.
-% Most index entries go through here, but \dosubind is the general case.
-% #1 is the index name, #2 is the entry text.
-\def\doind#1#2{\dosubind{#1}{#2}{}}
+{\catcode`\@=0 \catcode`\\=\other
+@gdef@realbackslash{\}}
-% Workhorse for all \fooindexes.
-% #1 is name of index, #2 is stuff to put there, #3 is subentry --
-% empty if called from \doind, as we usually are (the main exception
-% is with most defuns, which call us directly).
-%
-\def\dosubind#1#2#3{%
- \iflinks
- {%
- % Store the main index entry text (including the third arg).
- \toks0 = {#2}%
- % If third arg is present, precede it with a space.
- \def\thirdarg{#3}%
- \ifx\thirdarg\empty \else
- \toks0 = \expandafter{\the\toks0 \space #3}%
- \fi
- %
- \edef\writeto{\csname#1indfile\endcsname}%
- %
- \ifvmode
- \dosubindsanitize
- \else
- \dosubindwrite
- \fi
- }%
- \fi
-}
-
-% Write the entry in \toks0 to the index file:
-%
-\def\dosubindwrite{%
- % Put the index entry in the margin if desired.
- \ifx\SETmarginindex\relax\else
- \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}%
- \fi
- %
- % Remember, we are within a group.
- \indexdummies % Must do this here, since \bf, etc expand at this stage
- \def\backslashcurfont{\indexbackslash}% \indexbackslash isn't defined now
- % so it will be output as is; and it will print as backslash.
- %
- % Process the index entry with all font commands turned off, to
- % get the string to sort by.
- {\indexnofonts
- \edef\temp{\the\toks0}% need full expansion
- \xdef\indexsorttmp{\temp}%
- }%
- %
- % Set up the complete index entry, with both the sort key and
- % the original text, including any font commands. We write
- % three arguments to \entry to the .?? file (four in the
- % subentry case), texindex reduces to two when writing the .??s
- % sorted result.
- \edef\temp{%
- \write\writeto{%
- \string\entry{\indexsorttmp}{\noexpand\folio}{\the\toks0}}%
- }%
- \temp
-}
+\let\indexbackslash=0 %overridden during \printindex.
-% Take care of unwanted page breaks:
-%
-% If a skip is the last thing on the list now, preserve it
-% by backing up by \lastskip, doing the \write, then inserting
-% the skip again. Otherwise, the whatsit generated by the
-% \write will make \lastskip zero. The result is that sequences
-% like this:
-% @end defun
-% @tindex whatever
-% @defun ...
-% will have extra space inserted, because the \medbreak in the
-% start of the @defun won't see the skip inserted by the @end of
-% the previous defun.
-%
-% But don't do any of this if we're not in vertical mode. We
-% don't want to do a \vskip and prematurely end a paragraph.
-%
-% Avoid page breaks due to these extra skips, too.
-%
-% But wait, there is a catch there:
-% We'll have to check whether \lastskip is zero skip. \ifdim is not
-% sufficient for this purpose, as it ignores stretch and shrink parts
-% of the skip. The only way seems to be to check the textual
-% representation of the skip.
-%
-% The following is almost like \def\zeroskipmacro{0.0pt} except that
-% the ``p'' and ``t'' characters have catcode \other, not 11 (letter).
-%
-\edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname}
-%
-% ..., ready, GO:
-%
-\def\dosubindsanitize{%
- % \lastskip and \lastpenalty cannot both be nonzero simultaneously.
- \skip0 = \lastskip
- \edef\lastskipmacro{\the\lastskip}%
- \count255 = \lastpenalty
- %
- % If \lastskip is nonzero, that means the last item was a
- % skip. And since a skip is discardable, that means this
- % -\skip0 glue we're inserting is preceded by a
- % non-discardable item, therefore it is not a potential
- % breakpoint, therefore no \nobreak needed.
- \ifx\lastskipmacro\zeroskipmacro
- \else
- \vskip-\skip0
- \fi
- %
- \dosubindwrite
- %
- \ifx\lastskipmacro\zeroskipmacro
- % If \lastskip was zero, perhaps the last item was a penalty, and
- % perhaps it was >=10000, e.g., a \nobreak. In that case, we want
- % to re-insert the same penalty (values >10000 are used for various
- % signals); since we just inserted a non-discardable item, any
- % following glue (such as a \parskip) would be a breakpoint. For example:
- %
- % @deffn deffn-whatever
- % @vindex index-whatever
- % Description.
- % would allow a break between the index-whatever whatsit
- % and the "Description." paragraph.
- \ifnum\count255>9999 \penalty\count255 \fi
- \else
- % On the other hand, if we had a nonzero \lastskip,
- % this make-up glue would be preceded by a non-discardable item
- % (the whatsit from the \write), so we must insert a \nobreak.
- \nobreak\vskip\skip0
- \fi
-}
+\def\doind #1#2{%
+{\indexdummies % Must do this here, since \bf, etc expand at this stage
+\count10=\lastpenalty %
+\escapechar=`\\%
+{\let\folio=0% Expand all macros now EXCEPT \folio
+\def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now
+% so it will be output as is; and it will print as backslash in the indx.
+%
+% Now process the index-string once, with all font commands turned off,
+% to get the string to sort the index by.
+{\indexnofonts
+\xdef\temp1{#2}%
+}%
+% Now produce the complete index entry. We process the index-string again,
+% this time with font commands expanded, to get what to print in the index.
+\edef\temp{%
+\write \csname#1indfile\endcsname{%
+\realbackslash entry {\temp1}{\folio}{#2}}}%
+\temp }%
+\penalty\count10}}
+
+\def\dosubind #1#2#3{%
+{\indexdummies % Must do this here, since \bf, etc expand at this stage
+\count10=\lastpenalty %
+\escapechar=`\\%
+{\let\folio=0%
+\def\rawbackslashxx{\indexbackslash}%
+%
+% Now process the index-string once, with all font commands turned off,
+% to get the string to sort the index by.
+{\indexnofonts
+\xdef\temp1{#2 #3}%
+}%
+% Now produce the complete index entry. We process the index-string again,
+% this time with font commands expanded, to get what to print in the index.
+\edef\temp{%
+\write \csname#1indfile\endcsname{%
+\realbackslash entry {\temp1}{\folio}{#2}{#3}}}%
+\temp }%
+\penalty\count10}}
% The index entry written in the file actually looks like
% \entry {sortstring}{page}{topic}
@@ -3621,7 +906,7 @@ where each line of input produces a line of output.}
% \secondary {subtopic}{pagelist}
% for each subtopic.
-% Define the user-accessible indexing commands
+% Define the user-accessible indexing commands
% @findex, @vindex, @kindex, @cindex.
\def\findex {\fnindex}
@@ -3638,682 +923,284 @@ where each line of input produces a line of output.}
% Define the macros used in formatting output of the sorted index material.
-% @printindex causes a particular index (the ??s file) to get printed.
-% It does not print any chapter heading (usually an @unnumbered).
-%
-\parseargdef\printindex{\begingroup
- \dobreak \chapheadingskip{10000}%
- %
- \smallfonts \rm
- \tolerance = 9500
- \everypar = {}% don't want the \kern\-parindent from indentation suppression.
- %
- % See if the index file exists and is nonempty.
- % Change catcode of @ here so that if the index file contains
- % \initial {@}
- % as its first line, TeX doesn't complain about mismatched braces
- % (because it thinks @} is a control sequence).
- \catcode`\@ = 11
- \openin 1 \jobname.#1s
- \ifeof 1
- % \enddoublecolumns gets confused if there is no text in the index,
- % and it loses the chapter title and the aux file entries for the
- % index. The easiest way to prevent this problem is to make sure
- % there is some text.
- \putwordIndexNonexistent
- \else
- %
- % If the index file exists but is empty, then \openin leaves \ifeof
- % false. We have to make TeX try to read something from the file, so
- % it can discover if there is anything in it.
- \read 1 to \temp
- \ifeof 1
- \putwordIndexIsEmpty
- \else
- % Index files are almost Texinfo source, but we use \ as the escape
- % character. It would be better to use @, but that's too big a change
- % to make right now.
- \def\indexbackslash{\backslashcurfont}%
- \catcode`\\ = 0
- \escapechar = `\\
- \begindoublecolumns
- \input \jobname.#1s
- \enddoublecolumns
- \fi
- \fi
- \closein 1
-\endgroup}
+% This is what you call to cause a particular index to get printed.
+% Write
+% @unnumbered Function Index
+% @printindex fn
+
+\def\printindex{\parsearg\doprintindex}
+
+\def\doprintindex#1{\tex %
+\catcode`\%=\other\catcode`\&=\other\catcode`\#=\other
+\catcode`\$=\other\catcode`\_=\other
+\catcode`\~=\other
+\def\indexbackslash{\rawbackslashxx}
+\indexfonts\rm \tolerance=9500 \advance\baselineskip -1pt
+\begindoublecolumns
+\openin 1 \jobname.#1s
+\ifeof 1 \else \closein 1 \input \jobname.#1s
+\fi
+\enddoublecolumns
+\Etex}
% These macros are used by the sorted index file itself.
% Change them to control the appearance of the index.
-\def\initial#1{{%
- % Some minor font changes for the special characters.
- \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
- %
- % Remove any glue we may have, we'll be inserting our own.
- \removelastskip
- %
- % We like breaks before the index initials, so insert a bonus.
- \nobreak
- \vskip 0pt plus 3\baselineskip
- \penalty 0
- \vskip 0pt plus -3\baselineskip
- %
- % Typeset the initial. Making this add up to a whole number of
- % baselineskips increases the chance of the dots lining up from column
- % to column. It still won't often be perfect, because of the stretch
- % we need before each entry, but it's better.
- %
- % No shrink because it confuses \balancecolumns.
- \vskip 1.67\baselineskip plus .5\baselineskip
- \leftline{\secbf #1}%
- % Do our best not to break after the initial.
- \nobreak
- \vskip .33\baselineskip plus .1\baselineskip
-}}
+% Same as \bigskipamount except no shrink.
+% \balancecolumns gets confused if there is any shrink.
+\newskip\initialskipamount \initialskipamount 12pt plus4pt
-% \entry typesets a paragraph consisting of the text (#1), dot leaders, and
-% then page number (#2) flushed to the right margin. It is used for index
-% and table of contents entries. The paragraph is indented by \leftskip.
-%
-% A straightforward implementation would start like this:
-% \def\entry#1#2{...
-% But this frozes the catcodes in the argument, and can cause problems to
-% @code, which sets - active. This problem was fixed by a kludge---
-% ``-'' was active throughout whole index, but this isn't really right.
-%
-% The right solution is to prevent \entry from swallowing the whole text.
-% --kasal, 21nov03
-\def\entry{%
- \begingroup
- %
- % Start a new paragraph if necessary, so our assignments below can't
- % affect previous text.
- \par
- %
- % Do not fill out the last line with white space.
- \parfillskip = 0in
- %
- % No extra space above this paragraph.
- \parskip = 0in
- %
- % Do not prefer a separate line ending with a hyphen to fewer lines.
- \finalhyphendemerits = 0
- %
- % \hangindent is only relevant when the entry text and page number
- % don't both fit on one line. In that case, bob suggests starting the
- % dots pretty far over on the line. Unfortunately, a large
- % indentation looks wrong when the entry text itself is broken across
- % lines. So we use a small indentation and put up with long leaders.
- %
- % \hangafter is reset to 1 (which is the value we want) at the start
- % of each paragraph, so we need not do anything with that.
- \hangindent = 2em
- %
- % When the entry text needs to be broken, just fill out the first line
- % with blank space.
- \rightskip = 0pt plus1fil
- %
- % A bit of stretch before each entry for the benefit of balancing
- % columns.
- \vskip 0pt plus1pt
- %
- % Swallow the left brace of the text (first parameter):
- \afterassignment\doentry
- \let\temp =
-}
-\def\doentry{%
- \bgroup % Instead of the swallowed brace.
- \noindent
- \aftergroup\finishentry
- % And now comes the text of the entry.
-}
-\def\finishentry#1{%
- % #1 is the page number.
- %
- % The following is kludged to not output a line of dots in the index if
- % there are no page numbers. The next person who breaks this will be
- % cursed by a Unix daemon.
- \def\tempa{{\rm }}%
- \def\tempb{#1}%
- \edef\tempc{\tempa}%
- \edef\tempd{\tempb}%
- \ifx\tempc\tempd
- \ %
- \else
- %
- % If we must, put the page number on a line of its own, and fill out
- % this line with blank space. (The \hfil is overwhelmed with the
- % fill leaders glue in \indexdotfill if the page number does fit.)
- \hfil\penalty50
- \null\nobreak\indexdotfill % Have leaders before the page number.
- %
- % The `\ ' here is removed by the implicit \unskip that TeX does as
- % part of (the primitive) \par. Without it, a spurious underfull
- % \hbox ensues.
- \ifpdf
- \pdfgettoks#1.%
- \ \the\toksA
- \else
- \ #1%
- \fi
- \fi
- \par
- \endgroup
-}
+\outer\def\initial #1{%
+{\let\tentt=\sectt \let\sf=\sectt
+\ifdim\lastskip<\initialskipamount
+\removelastskip \penalty-200 \vskip \initialskipamount\fi
+\line{\secbf#1\hfill}\kern 2pt\penalty3000}}
-% Like \dotfill except takes at least 1 em.
-\def\indexdotfill{\cleaders
- \hbox{$\mathsurround=0pt \mkern1.5mu ${\it .}$ \mkern1.5mu$}\hskip 1em plus 1fill}
+\outer\def\entry #1#2{
+{\parfillskip=0in \parskip=0in \parindent=0in
+\hangindent=1in \hangafter=1%
+\noindent\hbox{#1}\leaders\Dotsbox\hskip 0pt plus 1filll #2\par
+}}
\def\primary #1{\line{#1\hfil}}
\newskip\secondaryindent \secondaryindent=0.5cm
-\def\secondary#1#2{{%
- \parfillskip=0in
- \parskip=0in
- \hangindent=1in
- \hangafter=1
- \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill
- \ifpdf
- \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
- \else
- #2
- \fi
- \par
+
+\def\secondary #1#2{
+{\parfillskip=0in \parskip=0in
+\hangindent =1in \hangafter=1
+\noindent\hskip\secondaryindent\hbox{#1}\leaders\Dotsbox\hskip 0pt plus 1filll#2\par
}}
-% Define two-column mode, which we use to typeset indexes.
-% Adapted from the TeXbook, page 416, which is to say,
-% the manmac.tex format used to print the TeXbook itself.
-\catcode`\@=11
+%% Define two-column mode, which is used in indexes.
+%% Adapted from the TeXBook, page 416
+\catcode `\@=11
\newbox\partialpage
-\newdimen\doublecolumnhsize
-
-\def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
- % Grab any single-column material above us.
- \output = {%
- %
- % Here is a possibility not foreseen in manmac: if we accumulate a
- % whole lot of material, we might end up calling this \output
- % routine twice in a row (see the doublecol-lose test, which is
- % essentially a couple of indexes with @setchapternewpage off). In
- % that case we just ship out what is in \partialpage with the normal
- % output routine. Generally, \partialpage will be empty when this
- % runs and this will be a no-op. See the indexspread.tex test case.
- \ifvoid\partialpage \else
- \onepageout{\pagecontents\partialpage}%
- \fi
- %
- \global\setbox\partialpage = \vbox{%
- % Unvbox the main output page.
- \unvbox\PAGE
- \kern-\topskip \kern\baselineskip
- }%
- }%
- \eject % run that output routine to set \partialpage
- %
- % Use the double-column output routine for subsequent pages.
- \output = {\doublecolumnout}%
- %
- % Change the page size parameters. We could do this once outside this
- % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
- % format, but then we repeat the same computation. Repeating a couple
- % of assignments once per index is clearly meaningless for the
- % execution time, so we may as well do it in one place.
- %
- % First we halve the line length, less a little for the gutter between
- % the columns. We compute the gutter based on the line length, so it
- % changes automatically with the paper format. The magic constant
- % below is chosen so that the gutter has the same value (well, +-<1pt)
- % as it did when we hard-coded it.
- %
- % We put the result in a separate register, \doublecolumhsize, so we
- % can restore it in \pagesofar, after \hsize itself has (potentially)
- % been clobbered.
- %
- \doublecolumnhsize = \hsize
- \advance\doublecolumnhsize by -.04154\hsize
- \divide\doublecolumnhsize by 2
- \hsize = \doublecolumnhsize
- %
- % Double the \vsize as well. (We don't need a separate register here,
- % since nobody clobbers \vsize.)
- \vsize = 2\vsize
-}
-% The double-column output routine for all double-column pages except
-% the last.
-%
-\def\doublecolumnout{%
- \splittopskip=\topskip \splitmaxdepth=\maxdepth
- % Get the available space for the double columns -- the normal
- % (undoubled) page height minus any material left over from the
- % previous page.
- \dimen@ = \vsize
- \divide\dimen@ by 2
- \advance\dimen@ by -\ht\partialpage
- %
- % box0 will be the left-hand column, box2 the right.
- \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
- \onepageout\pagesofar
- \unvbox255
- \penalty\outputpenalty
-}
-%
-% Re-output the contents of the output page -- any previous material,
-% followed by the two boxes we just split, in box0 and box2.
-\def\pagesofar{%
- \unvbox\partialpage
- %
- \hsize = \doublecolumnhsize
- \wd0=\hsize \wd2=\hsize
- \hbox to\pagewidth{\box0\hfil\box2}%
-}
-%
-% All done with double columns.
-\def\enddoublecolumns{%
- \output = {%
- % Split the last of the double-column material. Leave it on the
- % current page, no automatic page break.
- \balancecolumns
- %
- % If we end up splitting too much material for the current page,
- % though, there will be another page break right after this \output
- % invocation ends. Having called \balancecolumns once, we do not
- % want to call it again. Therefore, reset \output to its normal
- % definition right away. (We hope \balancecolumns will never be
- % called on to balance too much material, but if it is, this makes
- % the output somewhat more palatable.)
- \global\output = {\onepageout{\pagecontents\PAGE}}%
- }%
- \eject
- \endgroup % started in \begindoublecolumns
- %
- % \pagegoal was set to the doubled \vsize above, since we restarted
- % the current page. We're now back to normal single-column
- % typesetting, so reset \pagegoal to the normal \vsize (after the
- % \endgroup where \vsize got restored).
- \pagegoal = \vsize
-}
-%
-% Called at the end of the double column material.
-\def\balancecolumns{%
- \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120.
- \dimen@ = \ht0
- \advance\dimen@ by \topskip
- \advance\dimen@ by-\baselineskip
- \divide\dimen@ by 2 % target to split to
- %debug\message{final 2-column material height=\the\ht0, target=\the\dimen@.}%
- \splittopskip = \topskip
- % Loop until we get a decent breakpoint.
- {%
- \vbadness = 10000
- \loop
- \global\setbox3 = \copy0
- \global\setbox1 = \vsplit3 to \dimen@
- \ifdim\ht3>\dimen@
- \global\advance\dimen@ by 1pt
- \repeat
- }%
- %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}%
- \setbox0=\vbox to\dimen@{\unvbox1}%
- \setbox2=\vbox to\dimen@{\unvbox3}%
- %
- \pagesofar
-}
-\catcode`\@ = \other
+\newdimen\doublecolumnhsize \doublecolumnhsize = 3.11in
+\newdimen\doublecolumnvsize \doublecolumnvsize = 19.1in
+\def\begindoublecolumns{\begingroup
+ \output={\global\setbox\partialpage=\vbox{\unvbox255\kern -\topskip \kern \baselineskip}}\eject
+ \output={\doublecolumnout} \hsize=\doublecolumnhsize \vsize=\doublecolumnvsize}
+\def\enddoublecolumns{\output={\balancecolumns}\eject
+ \endgroup \pagegoal=\vsize}
+\def\doublecolumnout{\splittopskip=\topskip \splitmaxdepth=\maxdepth
+ \dimen@=\pageheight \advance\dimen@ by-\ht\partialpage
+ \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
+ \onepageout\pagesofar \unvbox255 \penalty\outputpenalty}
+\def\pagesofar{\unvbox\partialpage %
+ \hsize=\doublecolumnhsize % have to restore this since output routine
+% changes it to set cropmarks (P. A. MacKay, 12 Nov. 1986)
+ \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}}
+\def\balancecolumns{\setbox0=\vbox{\unvbox255} \dimen@=\ht0
+ \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip
+ \divide\dimen@ by2 \splittopskip=\topskip
+ {\vbadness=10000 \loop \global\setbox3=\copy0
+ \global\setbox1=\vsplit3 to\dimen@
+ \ifdim\ht3>\dimen@ \global\advance\dimen@ by1pt \repeat}
+ \setbox0=\vbox to\dimen@{\unvbox1} \setbox2=\vbox to\dimen@{\unvbox3}
+ \pagesofar}
+
+\catcode `\@=\other
\message{sectioning,}
-% Chapters, sections, etc.
-
-% \unnumberedno is an oxymoron, of course. But we count the unnumbered
-% sections so that we can refer to them unambiguously in the pdf
-% outlines by their "section number". We avoid collisions with chapter
-% numbers by starting them at 10000. (If a document ever has 10000
-% chapters, we're in trouble anyway, I'm sure.)
-\newcount\unnumberedno \unnumberedno = 10000
-\newcount\chapno
-\newcount\secno \secno=0
-\newcount\subsecno \subsecno=0
-\newcount\subsubsecno \subsubsecno=0
-
-% This counter is funny since it counts through charcodes of letters A, B, ...
-\newcount\appendixno \appendixno = `\@
-%
-% \def\appendixletter{\char\the\appendixno}
-% We do the following ugly conditional instead of the above simple
-% construct for the sake of pdftex, which needs the actual
-% letter in the expansion, not just typeset.
-%
-\def\appendixletter{%
- \ifnum\appendixno=`A A%
- \else\ifnum\appendixno=`B B%
- \else\ifnum\appendixno=`C C%
- \else\ifnum\appendixno=`D D%
- \else\ifnum\appendixno=`E E%
- \else\ifnum\appendixno=`F F%
- \else\ifnum\appendixno=`G G%
- \else\ifnum\appendixno=`H H%
- \else\ifnum\appendixno=`I I%
- \else\ifnum\appendixno=`J J%
- \else\ifnum\appendixno=`K K%
- \else\ifnum\appendixno=`L L%
- \else\ifnum\appendixno=`M M%
- \else\ifnum\appendixno=`N N%
- \else\ifnum\appendixno=`O O%
- \else\ifnum\appendixno=`P P%
- \else\ifnum\appendixno=`Q Q%
- \else\ifnum\appendixno=`R R%
- \else\ifnum\appendixno=`S S%
- \else\ifnum\appendixno=`T T%
- \else\ifnum\appendixno=`U U%
- \else\ifnum\appendixno=`V V%
- \else\ifnum\appendixno=`W W%
- \else\ifnum\appendixno=`X X%
- \else\ifnum\appendixno=`Y Y%
- \else\ifnum\appendixno=`Z Z%
- % The \the is necessary, despite appearances, because \appendixletter is
- % expanded while writing the .toc file. \char\appendixno is not
- % expandable, thus it is written literally, thus all appendixes come out
- % with the same letter (or @) in the toc without it.
- \else\char\the\appendixno
- \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
- \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
-
-% Each @chapter defines this as the name of the chapter.
-% page headings and footings can use it. @section does likewise.
-% However, they are not reliable, because we don't use marks.
-\def\thischapter{}
-\def\thissection{}
-
-\newcount\absseclevel % used to calculate proper heading level
-\newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count
-
-% @raisesections: treat @section as chapter, @subsection as section, etc.
-\def\raisesections{\global\advance\secbase by -1}
-\let\up=\raisesections % original BFox name
-
-% @lowersections: treat @chapter as section, @section as subsection, etc.
-\def\lowersections{\global\advance\secbase by 1}
-\let\down=\lowersections % original BFox name
-
-% we only have subsub.
-\chardef\maxseclevel = 3
-%
-% A numbered section within an unnumbered changes to unnumbered too.
-% To achive this, remember the "biggest" unnum. sec. we are currently in:
-\chardef\unmlevel = \maxseclevel
-%
-% Trace whether the current chapter is an appendix or not:
-% \chapheadtype is "N" or "A", unnumbered chapters are ignored.
-\def\chapheadtype{N}
-
-% Choose a heading macro
-% #1 is heading type
-% #2 is heading level
-% #3 is text for heading
-\def\genhead#1#2#3{%
- % Compute the abs. sec. level:
- \absseclevel=#2
- \advance\absseclevel by \secbase
- % Make sure \absseclevel doesn't fall outside the range:
- \ifnum \absseclevel < 0
- \absseclevel = 0
- \else
- \ifnum \absseclevel > 3
- \absseclevel = 3
- \fi
- \fi
- % The heading type:
- \def\headtype{#1}%
- \if \headtype U%
- \ifnum \absseclevel < \unmlevel
- \chardef\unmlevel = \absseclevel
- \fi
- \else
- % Check for appendix sections:
- \ifnum \absseclevel = 0
- \edef\chapheadtype{\headtype}%
- \else
- \if \headtype A\if \chapheadtype N%
- \errmessage{@appendix... within a non-appendix chapter}%
- \fi\fi
- \fi
- % Check for numbered within unnumbered:
- \ifnum \absseclevel > \unmlevel
- \def\headtype{U}%
- \else
- \chardef\unmlevel = 3
- \fi
- \fi
- % Now print the heading:
- \if \headtype U%
- \ifcase\absseclevel
- \unnumberedzzz{#3}%
- \or \unnumberedseczzz{#3}%
- \or \unnumberedsubseczzz{#3}%
- \or \unnumberedsubsubseczzz{#3}%
- \fi
- \else
- \if \headtype A%
- \ifcase\absseclevel
- \appendixzzz{#3}%
- \or \appendixsectionzzz{#3}%
- \or \appendixsubseczzz{#3}%
- \or \appendixsubsubseczzz{#3}%
- \fi
- \else
- \ifcase\absseclevel
- \chapterzzz{#3}%
- \or \seczzz{#3}%
- \or \numberedsubseczzz{#3}%
- \or \numberedsubsubseczzz{#3}%
- \fi
- \fi
- \fi
- \suppressfirstparagraphindent
-}
-
-% an interface:
-\def\numhead{\genhead N}
-\def\apphead{\genhead A}
-\def\unnmhead{\genhead U}
-
-% @chapter, @appendix, @unnumbered. Increment top-level counter, reset
-% all lower-level sectioning counters to zero.
-%
-% Also set \chaplevelprefix, which we prepend to @float sequence numbers
-% (e.g., figures), q.v. By default (before any chapter), that is empty.
-\let\chaplevelprefix = \empty
-%
-\outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
-\def\chapterzzz#1{%
- % section resetting is \global in case the chapter is in a group, such
- % as an @include file.
- \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
- \global\advance\chapno by 1
- %
- % Used for \float.
- \gdef\chaplevelprefix{\the\chapno.}%
- \resetallfloatnos
- %
- \message{\putwordChapter\space \the\chapno}%
- %
- % Write the actual heading.
- \chapmacro{#1}{Ynumbered}{\the\chapno}%
- %
- % So @section and the like are numbered underneath this chapter.
- \global\let\section = \numberedsec
- \global\let\subsection = \numberedsubsec
- \global\let\subsubsection = \numberedsubsubsec
-}
+% Define chapters, sections, etc.
-\outer\parseargdef\appendix{\apphead0{#1}} % normally apphead0 calls appendixzzz
-\def\appendixzzz#1{%
- \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
- \global\advance\appendixno by 1
- \gdef\chaplevelprefix{\appendixletter.}%
- \resetallfloatnos
- %
- \def\appendixnum{\putwordAppendix\space \appendixletter}%
- \message{\appendixnum}%
- %
- \chapmacro{#1}{Yappendix}{\appendixletter}%
- %
- \global\let\section = \appendixsec
- \global\let\subsection = \appendixsubsec
- \global\let\subsubsection = \appendixsubsubsec
-}
-
-\outer\parseargdef\unnumbered{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz
-\def\unnumberedzzz#1{%
- \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
- \global\advance\unnumberedno by 1
- %
- % Since an unnumbered has no number, no prefix for figures.
- \global\let\chaplevelprefix = \empty
- \resetallfloatnos
- %
- % This used to be simply \message{#1}, but TeX fully expands the
- % argument to \message. Therefore, if #1 contained @-commands, TeX
- % expanded them. For example, in `@unnumbered The @cite{Book}', TeX
- % expanded @cite (which turns out to cause errors because \cite is meant
- % to be executed, not expanded).
- %
- % Anyway, we don't want the fully-expanded definition of @cite to appear
- % as a result of the \message, we just want `@cite' itself. We use
- % \the<toks register> to achieve this: TeX expands \the<toks> only once,
- % simply yielding the contents of <toks register>. (We also do this for
- % the toc entries.)
- \toks0 = {#1}%
- \message{(\the\toks0)}%
- %
- \chapmacro{#1}{Ynothing}{\the\unnumberedno}%
- %
- \global\let\section = \unnumberedsec
- \global\let\subsection = \unnumberedsubsec
- \global\let\subsubsection = \unnumberedsubsubsec
-}
-
-% @centerchap is like @unnumbered, but the heading is centered.
-\outer\parseargdef\centerchap{%
- % Well, we could do the following in a group, but that would break
- % an assumption that \chapmacro is called at the outermost level.
- % Thus we are safer this way: --kasal, 24feb04
- \let\centerparametersmaybe = \centerparameters
- \unnmhead0{#1}%
- \let\centerparametersmaybe = \relax
-}
-
-% @top is like @unnumbered.
-\let\top\unnumbered
-
-% Sections.
-\outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
-\def\seczzz#1{%
- \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
- \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
-}
-
-\outer\parseargdef\appendixsection{\apphead1{#1}} % normally calls appendixsectionzzz
-\def\appendixsectionzzz#1{%
- \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
- \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
-}
-\let\appendixsec\appendixsection
-
-\outer\parseargdef\unnumberedsec{\unnmhead1{#1}} % normally calls unnumberedseczzz
-\def\unnumberedseczzz#1{%
- \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
- \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
-}
-
-% Subsections.
-\outer\parseargdef\numberedsubsec{\numhead2{#1}} % normally calls numberedsubseczzz
-\def\numberedsubseczzz#1{%
- \global\subsubsecno=0 \global\advance\subsecno by 1
- \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
-}
+\newcount \chapno
+\newcount \secno
+\newcount \subsecno
+\newcount \subsubsecno
-\outer\parseargdef\appendixsubsec{\apphead2{#1}} % normally calls appendixsubseczzz
-\def\appendixsubseczzz#1{%
- \global\subsubsecno=0 \global\advance\subsecno by 1
- \sectionheading{#1}{subsec}{Yappendix}%
- {\appendixletter.\the\secno.\the\subsecno}%
-}
-
-\outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}} %normally calls unnumberedsubseczzz
-\def\unnumberedsubseczzz#1{%
- \global\subsubsecno=0 \global\advance\subsecno by 1
- \sectionheading{#1}{subsec}{Ynothing}%
- {\the\unnumberedno.\the\secno.\the\subsecno}%
-}
-
-% Subsubsections.
-\outer\parseargdef\numberedsubsubsec{\numhead3{#1}} % normally numberedsubsubseczzz
-\def\numberedsubsubseczzz#1{%
- \global\advance\subsubsecno by 1
- \sectionheading{#1}{subsubsec}{Ynumbered}%
- {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
-}
+% This counter is funny since it counts through charcodes of letters A, B, ...
+\newcount \appendixno \appendixno = `\@
+\def\appendixletter{\char\the\appendixno}
-\outer\parseargdef\appendixsubsubsec{\apphead3{#1}} % normally appendixsubsubseczzz
-\def\appendixsubsubseczzz#1{%
- \global\advance\subsubsecno by 1
- \sectionheading{#1}{subsubsec}{Yappendix}%
- {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
-}
+\newwrite \contentsfile
+\openout \contentsfile = \jobname.toc
-\outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}} %normally unnumberedsubsubseczzz
-\def\unnumberedsubsubseczzz#1{%
- \global\advance\subsubsecno by 1
- \sectionheading{#1}{subsubsec}{Ynothing}%
- {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
+% Each @chapter defines this as the name of the chapter.
+% page headings and footings can use it. @section does likewise
+
+\def\thischapter{} \def\thissection{}
+\def\seccheck#1{\if \pageno<0 %
+\errmessage{@#1 not allowed after generating table of contents}\fi
+%
+}
+
+\outer\def\chapter{\parsearg\chapterzzz}
+\def\chapterzzz #1{\seccheck{chapter}%
+\secno=0 \subsecno=0 \subsubsecno=0 \global\advance \chapno by 1 \message{Chapter \the\chapno}%
+\chapmacro {#1}{\the\chapno}%
+\gdef\thissection{#1}\gdef\thischapter{#1}%
+\let\rawbackslash=\relax%
+\let\frenchspacing=\relax%
+\edef\temp{{\realbackslash chapentry {#1}{\the\chapno}{\noexpand\folio}}}%
+\escapechar=`\\%
+\write \contentsfile \temp %
+\donoderef %
+}
+
+\outer\def\appendix{\parsearg\appendixzzz}
+\def\appendixzzz #1{\seccheck{appendix}%
+\secno=0 \subsecno=0 \subsubsecno=0 \global\advance \appendixno by 1 \message{Appendix \appendixletter}%
+\chapmacro {#1}{Appendix \appendixletter}%
+\gdef\thischapter{#1}\gdef\thissection{#1}%
+\let\rawbackslash=\relax%
+\let\frenchspacing=\relax%
+\edef\temp{{\realbackslash chapentry {#1}{Appendix \appendixletter}{\noexpand\folio}}}%
+\escapechar=`\\%
+\write \contentsfile \temp %
+\unnumbnoderef %
+}
+
+\outer\def\unnumbered{\parsearg\unnumberedzzz}
+\def\unnumberedzzz #1{\seccheck{unnumbered}%
+\secno=0 \subsecno=0 \subsubsecno=0 \message{(#1)}
+\unnumbchapmacro {#1}%
+\gdef\thischapter{#1}\gdef\thissection{#1}%
+\let\rawbackslash=\relax%
+\let\frenchspacing=\relax%
+\edef\temp{{\realbackslash unnumbchapentry {#1}{\noexpand\folio}}}%
+\escapechar=`\\%
+\write \contentsfile \temp %
+\unnumbnoderef %
+}
+
+\outer\def\section{\parsearg\sectionzzz}
+\def\sectionzzz #1{\seccheck{section}%
+\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
+\gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
+\let\rawbackslash=\relax%
+\let\frenchspacing=\relax%
+\edef\temp{{\realbackslash secentry %
+{#1}{\the\chapno}{\the\secno}{\noexpand\folio}}}%
+\escapechar=`\\%
+\write \contentsfile \temp %
+\donoderef %
+\penalty 10000 %
+}
+
+\outer\def\appendixsection{\parsearg\appendixsectionzzz}
+\outer\def\appendixsec{\parsearg\appendixsectionzzz}
+\def\appendixsectionzzz #1{\seccheck{appendixsection}%
+\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
+\gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
+\let\rawbackslash=\relax%
+\let\frenchspacing=\relax%
+\edef\temp{{\realbackslash secentry %
+{#1}{\appendixletter}{\the\secno}{\noexpand\folio}}}%
+\escapechar=`\\%
+\write \contentsfile \temp %
+\unnumbnoderef %
+\penalty 10000 %
+}
+
+\outer\def\unnumberedsec{\parsearg\unnumberedseczzz}
+\def\unnumberedseczzz #1{\seccheck{unnumberedsec}%
+\plainsecheading {#1}\gdef\thissection{#1}%
+\let\rawbackslash=\relax%
+\let\frenchspacing=\relax%
+\edef\temp{{\realbackslash unnumbsecentry{#1}{\noexpand\folio}}}%
+\escapechar=`\\%
+\write \contentsfile \temp %
+\unnumbnoderef %
+\penalty 10000 %
+}
+
+\outer\def\subsection{\parsearg\subsectionzzz}
+\def\subsectionzzz #1{\seccheck{subsection}%
+\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
+\subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
+\let\rawbackslash=\relax%
+\let\frenchspacing=\relax%
+\edef\temp{{\realbackslash subsecentry %
+{#1}{\the\chapno}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
+\escapechar=`\\%
+\write \contentsfile \temp %
+\donoderef %
+\penalty 10000 %
+}
+
+\outer\def\appendixsubsec{\parsearg\appendixsubseczzz}
+\def\appendixsubseczzz #1{\seccheck{appendixsubsec}%
+\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
+\subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
+\let\rawbackslash=\relax%
+\let\frenchspacing=\relax%
+\edef\temp{{\realbackslash subsecentry %
+{#1}{\appendixletter}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
+\escapechar=`\\%
+\write \contentsfile \temp %
+\unnumbnoderef %
+\penalty 10000 %
+}
+
+\outer\def\unnumberedsubsec{\parsearg\unnumberedsubseczzz}
+\def\unnumberedsubseczzz #1{\seccheck{unnumberedsubsec}%
+\plainsecheading {#1}\gdef\thissection{#1}%
+\let\rawbackslash=\relax%
+\let\frenchspacing=\relax%
+\edef\temp{{\realbackslash unnumbsubsecentry{#1}{\noexpand\folio}}}%
+\escapechar=`\\%
+\write \contentsfile \temp %
+\unnumbnoderef %
+\penalty 10000 %
+}
+
+\outer\def\subsubsection{\parsearg\subsubsectionzzz}
+\def\subsubsectionzzz #1{\seccheck{subsubsection}%
+\gdef\thissection{#1}\global\advance \subsubsecno by 1 %
+\subsubsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
+\let\rawbackslash=\relax%
+\let\frenchspacing=\relax%
+\edef\temp{{\realbackslash subsubsecentry %
+{#1}{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}%\
+\escapechar=`\\%
+\write \contentsfile \temp %
+\donoderef %
+\penalty 10000 %
+}
+
+\outer\def\appendixsubsubsec{\parsearg\appendixsubsubseczzz}
+\def\appendixsubsubseczzz #1{\seccheck{appendixsubsubsec}%
+\gdef\thissection{#1}\global\advance \subsubsecno by 1 %
+\subsubsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
+\let\rawbackslash=\relax%
+\let\frenchspacing=\relax%
+\edef\temp{{\realbackslash subsubsecentry{#1}%
+{\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}%\
+\escapechar=`\\%
+\write \contentsfile \temp %
+\unnumbnoderef %
+\penalty 10000 %
+}
+
+\outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
+\def\unnumberedsubsubseczzz #1{\seccheck{unnumberedsubsubsec}%
+\plainsecheading {#1}\gdef\thissection{#1}%
+\let\rawbackslash=\relax%
+\let\frenchspacing=\relax%
+\edef\temp{{\realbackslash unnumbsubsubsecentry{#1}{\noexpand\folio}}}%
+\escapechar=`\\%
+\write \contentsfile \temp %
+\unnumbnoderef %
+\penalty 10000 %
}
-% These macros control what the section commands do, according
-% to what kind of chapter we are in (ordinary, appendix, or unnumbered).
-% Define them by default for a numbered chapter.
-\let\section = \numberedsec
-\let\subsection = \numberedsubsec
-\let\subsubsection = \numberedsubsubsec
-
% Define @majorheading, @heading and @subheading
-% NOTE on use of \vbox for chapter headings, section headings, and such:
-% 1) We use \vbox rather than the earlier \line to permit
-% overlong headings to fold.
-% 2) \hyphenpenalty is set to 10000 because hyphenation in a
-% heading is obnoxious; this forbids it.
-% 3) Likewise, headings look best if no \parindent is used, and
-% if justification is not attempted. Hence \raggedright.
-
+\outer\def\majorheading #1{%
+{\advance\chapheadingskip by 10pt \chapbreak }%
+{\chapfonts \line{\chaprm #1\hfill}}\bigskip \par\penalty 200}
-\def\majorheading{%
- {\advance\chapheadingskip by 10pt \chapbreak }%
- \parsearg\chapheadingzzz
-}
-
-\def\chapheading{\chapbreak \parsearg\chapheadingzzz}
-\def\chapheadingzzz#1{%
- {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
- \parindent=0pt\raggedright
- \rm #1\hfill}}%
- \bigskip \par\penalty 200\relax
- \suppressfirstparagraphindent
-}
+\outer\def\chapheading #1{\chapbreak %
+{\chapfonts \line{\chaprm #1\hfill}}\bigskip \par\penalty 200}
-% @heading, @subheading, @subsubheading.
-\parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{}
- \suppressfirstparagraphindent}
-\parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{}
- \suppressfirstparagraphindent}
-\parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{}
- \suppressfirstparagraphindent}
+\let\heading=\secheadingi
+\let\subheading=\subsecheadingi
+\let\subsubheading=\subsubsecheadingi
% These macros generate a chapter, section, etc. heading only
% (including whitespace, linebreaking, etc. around it),
@@ -4322,10 +1209,12 @@ where each line of input produces a line of output.}
%%% Args are the skip and penalty (usually negative)
\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
+\def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
+
%%% Define plain chapter starts, and page on/off switching for it
% Parameter controlling skip before chapter headings (if needed)
-\newskip\chapheadingskip
+\newskip \chapheadingskip \chapheadingskip = 30pt plus 8pt minus 4pt
\def\chapbreak{\dobreak \chapheadingskip {-4000}}
\def\chappager{\par\vfill\supereject}
@@ -4333,2894 +1222,856 @@ where each line of input produces a line of output.}
\def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
-\def\CHAPPAGoff{%
-\global\let\contentsalignmacro = \chappager
+\def\CHAPPAGoff{
\global\let\pchapsepmacro=\chapbreak
\global\let\pagealignmacro=\chappager}
-\def\CHAPPAGon{%
-\global\let\contentsalignmacro = \chappager
+\def\CHAPPAGon{
\global\let\pchapsepmacro=\chappager
-\global\let\pagealignmacro=\chappager
-\global\def\HEADINGSon{\HEADINGSsingle}}
+\global\let\pagealignmacro=\chappager}
-\def\CHAPPAGodd{%
-\global\let\contentsalignmacro = \chapoddpage
+\def\CHAPPAGodd{
\global\let\pchapsepmacro=\chapoddpage
-\global\let\pagealignmacro=\chapoddpage
-\global\def\HEADINGSon{\HEADINGSdouble}}
+\global\let\pagealignmacro=\chapoddpage}
\CHAPPAGon
-% Chapter opening.
-%
-% #1 is the text, #2 is the section type (Ynumbered, Ynothing,
-% Yappendix, Yomitfromtoc), #3 the chapter number.
-%
-% To test against our argument.
-\def\Ynothingkeyword{Ynothing}
-\def\Yomitfromtockeyword{Yomitfromtoc}
-\def\Yappendixkeyword{Yappendix}
-%
-\def\chapmacro#1#2#3{%
- \pchapsepmacro
- {%
- \chapfonts \rm
- %
- % Have to define \thissection before calling \donoderef, because the
- % xref code eventually uses it. On the other hand, it has to be called
- % after \pchapsepmacro, or the headline will change too soon.
- \gdef\thissection{#1}%
- \gdef\thischaptername{#1}%
- %
- % Only insert the separating space if we have a chapter/appendix
- % number, and don't print the unnumbered ``number''.
- \def\temptype{#2}%
- \ifx\temptype\Ynothingkeyword
- \setbox0 = \hbox{}%
- \def\toctype{unnchap}%
- \gdef\thischapter{#1}%
- \else\ifx\temptype\Yomitfromtockeyword
- \setbox0 = \hbox{}% contents like unnumbered, but no toc entry
- \def\toctype{omit}%
- \gdef\thischapter{}%
- \else\ifx\temptype\Yappendixkeyword
- \setbox0 = \hbox{\putwordAppendix{} #3\enspace}%
- \def\toctype{app}%
- % We don't substitute the actual chapter name into \thischapter
- % because we don't want its macros evaluated now. And we don't
- % use \thissection because that changes with each section.
- %
- \xdef\thischapter{\putwordAppendix{} \appendixletter:
- \noexpand\thischaptername}%
- \else
- \setbox0 = \hbox{#3\enspace}%
- \def\toctype{numchap}%
- \xdef\thischapter{\putwordChapter{} \the\chapno:
- \noexpand\thischaptername}%
- \fi\fi\fi
- %
- % Write the toc entry for this chapter. Must come before the
- % \donoderef, because we include the current node name in the toc
- % entry, and \donoderef resets it to empty.
- \writetocentry{\toctype}{#1}{#3}%
- %
- % For pdftex, we have to write out the node definition (aka, make
- % the pdfdest) after any page break, but before the actual text has
- % been typeset. If the destination for the pdf outline is after the
- % text, then jumping from the outline may wind up with the text not
- % being visible, for instance under high magnification.
- \donoderef{#2}%
- %
- % Typeset the actual heading.
- \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
- \hangindent=\wd0 \centerparametersmaybe
- \unhbox0 #1\par}%
- }%
- \nobreak\bigskip % no page break after a chapter title
- \nobreak
-}
+\def\CHAPFplain{
+\global\let\chapmacro=\chfplain
+\global\let\unnumbchapmacro=\unnchfplain}
-% @centerchap -- centered and unnumbered.
-\let\centerparametersmaybe = \relax
-\def\centerparameters{%
- \advance\rightskip by 3\rightskip
- \leftskip = \rightskip
- \parfillskip = 0pt
+\def\chfplain #1#2{%
+\pchapsepmacro %
+{\chapfonts \line{\chaprm #2.\enspace #1\hfill}}\bigskip \par\penalty 5000 %
}
+\def\unnchfplain #1{%
+\pchapsepmacro %
+{\chapfonts \line{\chaprm #1\hfill}}\bigskip \par\penalty 10000 %
+}
+\CHAPFplain % The default
-% I don't think this chapter style is supported any more, so I'm not
-% updating it with the new noderef stuff. We'll see. --karl, 11aug03.
-%
-\def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
-%
\def\unnchfopen #1{%
-\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
- \parindent=0pt\raggedright
- \rm #1\hfill}}\bigskip \par\nobreak
+\chapoddpage {\chapfonts \line{\chaprm #1\hfill}}\bigskip \par\penalty 10000 %
}
+
\def\chfopen #1#2{\chapoddpage {\chapfonts
\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
\par\penalty 5000 %
}
-\def\centerchfopen #1{%
-\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
- \parindent=0pt
- \hfill {\rm #1}\hfill}}\bigskip \par\nobreak
-}
-\def\CHAPFopen{%
- \global\let\chapmacro=\chfopen
- \global\let\centerchapmacro=\centerchfopen}
+\def\CHAPFopen{
+\global\let\chapmacro=\chfopen
+\global\let\unnumbchapmacro=\unnchfopen}
-% Section titles. These macros combine the section number parts and
-% call the generic \sectionheading to do the printing.
-%
-\newskip\secheadingskip
-\def\secheadingbreak{\dobreak \secheadingskip{-1000}}
-
-% Subsection titles.
-\newskip\subsecheadingskip
-\def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}}
-
-% Subsubsection titles.
-\def\subsubsecheadingskip{\subsecheadingskip}
-\def\subsubsecheadingbreak{\subsecheadingbreak}
-
+% Parameter controlling skip before section headings.
-% Print any size, any type, section title.
-%
-% #1 is the text, #2 is the section level (sec/subsec/subsubsec), #3 is
-% the section type for xrefs (Ynumbered, Ynothing, Yappendix), #4 is the
-% section number.
-%
-\def\sectionheading#1#2#3#4{%
- {%
- % Switch to the right set of fonts.
- \csname #2fonts\endcsname \rm
- %
- % Insert space above the heading.
- \csname #2headingbreak\endcsname
- %
- % Only insert the space after the number if we have a section number.
- \def\sectionlevel{#2}%
- \def\temptype{#3}%
- %
- \ifx\temptype\Ynothingkeyword
- \setbox0 = \hbox{}%
- \def\toctype{unn}%
- \gdef\thissection{#1}%
- \else\ifx\temptype\Yomitfromtockeyword
- % for @headings -- no section number, don't include in toc,
- % and don't redefine \thissection.
- \setbox0 = \hbox{}%
- \def\toctype{omit}%
- \let\sectionlevel=\empty
- \else\ifx\temptype\Yappendixkeyword
- \setbox0 = \hbox{#4\enspace}%
- \def\toctype{app}%
- \gdef\thissection{#1}%
- \else
- \setbox0 = \hbox{#4\enspace}%
- \def\toctype{num}%
- \gdef\thissection{#1}%
- \fi\fi\fi
- %
- % Write the toc entry (before \donoderef). See comments in \chapmacro.
- \writetocentry{\toctype\sectionlevel}{#1}{#4}%
- %
- % Write the node reference (= pdf destination for pdftex).
- % Again, see comments in \chapmacro.
- \donoderef{#3}%
- %
- % Interline glue will be inserted when the vbox is completed.
- % That glue will be a valid breakpoint for the page, since it'll be
- % preceded by a whatsit (usually from the \donoderef, or from the
- % \writetocentry if there was no node). We don't want to allow that
- % break, since then the whatsits could end up on page n while the
- % section is on page n+1, thus toc/etc. are wrong. Debian bug 276000.
- \nobreak
- %
- % Output the actual section heading.
- \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
- \hangindent=\wd0 % zero if no section number
- \unhbox0 #1}%
- }%
- % Add extra space after the heading -- half of whatever came above it.
- % Don't allow stretch, though.
- \kern .5 \csname #2headingskip\endcsname
- %
- % Do not let the kern be a potential breakpoint, as it would be if it
- % was followed by glue.
- \nobreak
- %
- % We'll almost certainly start a paragraph next, so don't let that
- % glue accumulate. (Not a breakpoint because it's preceded by a
- % discardable item.)
- \vskip-\parskip
- %
- % This is purely so the last item on the list is a known \penalty >
- % 10000. This is so \startdefun can avoid allowing breakpoints after
- % section headings. Otherwise, it would insert a valid breakpoint between:
- %
- % @section sec-whatever
- % @deffn def-whatever
- \penalty 10001
-}
+\newskip \subsecheadingskip \subsecheadingskip = 17pt plus 8pt minus 4pt
+\def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}}
+\newskip \secheadingskip \secheadingskip = 21pt plus 8pt minus 4pt
+\def\secheadingbreak{\dobreak \secheadingskip {-1000}}
-\message{toc,}
-% Table of contents.
-\newwrite\tocfile
-
-% Write an entry to the toc file, opening it if necessary.
-% Called from @chapter, etc.
-%
-% Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
-% We append the current node name (if any) and page number as additional
-% arguments for the \{chap,sec,...}entry macros which will eventually
-% read this. The node name is used in the pdf outlines as the
-% destination to jump to.
-%
-% We open the .toc file for writing here instead of at @setfilename (or
-% any other fixed time) so that @contents can be anywhere in the document.
-% But if #1 is `omit', then we don't do anything. This is used for the
-% table of contents chapter openings themselves.
-%
-\newif\iftocfileopened
-\def\omitkeyword{omit}%
-%
-\def\writetocentry#1#2#3{%
- \edef\writetoctype{#1}%
- \ifx\writetoctype\omitkeyword \else
- \iftocfileopened\else
- \immediate\openout\tocfile = \jobname.toc
- \global\tocfileopenedtrue
- \fi
- %
- \iflinks
- {\atdummies
- \edef\temp{%
- \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}%
- \temp
- }%
- \fi
- \fi
- %
- % Tell \shipout to create a pdf destination on each page, if we're
- % writing pdf. These are used in the table of contents. We can't
- % just write one on every page because the title pages are numbered
- % 1 and 2 (the page numbers aren't printed), and so are the first
- % two pages of the document. Thus, we'd have two destinations named
- % `1', and two named `2'.
- \ifpdf \global\pdfmakepagedesttrue \fi
-}
-
+\def\secheading #1#2#3{\secheadingi {#2.#3\enspace #1}}
+\def\plainsecheading #1{\secheadingi {#1}}
+\def\secheadingi #1{{\advance \secheadingskip by \parskip %
+\secheadingbreak}%
+{\secfonts \line{\secrm #1\hfill}}%
+\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
-% These characters do not print properly in the Computer Modern roman
-% fonts, so we must take special care. This is more or less redundant
-% with the Texinfo input format setup at the end of this file.
-%
-\def\activecatcodes{%
- \catcode`\"=\active
- \catcode`\$=\active
- \catcode`\<=\active
- \catcode`\>=\active
- \catcode`\\=\active
- \catcode`\^=\active
- \catcode`\_=\active
- \catcode`\|=\active
- \catcode`\~=\active
-}
+\def\subsecheading #1#2#3#4{{\advance \subsecheadingskip by \parskip %
+\subsecheadingbreak}%
+{\secfonts \line{\secrm#2.#3.#4\enspace #1\hfill}}%
+\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
+\def\subsubsecfonts{\subsecfonts} % Maybe this should change
-% Read the toc file, which is essentially Texinfo input.
-\def\readtocfile{%
- \setupdatafile
- \activecatcodes
- \input \jobname.toc
-}
+\def\subsubsecheading #1#2#3#4#5{{\advance \subsecheadingskip by \parskip %
+\subsecheadingbreak}%
+{\secfonts \line{\secrm#2.#3.#4.#5\enspace #1\hfill}}%
+\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000}
-\newskip\contentsrightmargin \contentsrightmargin=1in
-\newcount\savepageno
-\newcount\lastnegativepageno \lastnegativepageno = -1
+\message{toc printing,}
-% Prepare to read what we've written to \tocfile.
-%
-\def\startcontents#1{%
- % If @setchapternewpage on, and @headings double, the contents should
- % start on an odd page, unlike chapters. Thus, we maintain
- % \contentsalignmacro in parallel with \pagealignmacro.
- % From: Torbjorn Granlund <tege@matematik.su.se>
- \contentsalignmacro
- \immediate\closeout\tocfile
- %
- % Don't need to put `Contents' or `Short Contents' in the headline.
- % It is abundantly clear what they are.
- \def\thischapter{}%
- \chapmacro{#1}{Yomitfromtoc}{}%
- %
- \savepageno = \pageno
- \begingroup % Set up to handle contents files properly.
- \raggedbottom % Worry more about breakpoints than the bottom.
- \advance\hsize by -\contentsrightmargin % Don't use the full line length.
- %
- % Roman numerals for page numbers.
- \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
-}
+\def\Dotsbox{\hbox to 1em{\hss.\hss}} % Used by index macros
+\def\finishcontents{%
+\ifnum\pageno>0 %
+\pagealignmacro %
+\immediate\closeout \contentsfile%
+\pageno=-1 % Request roman numbered pages
+\fi}
-% Normal (long) toc.
-\def\contents{%
- \startcontents{\putwordTOC}%
- \openin 1 \jobname.toc
- \ifeof 1 \else
- \readtocfile
- \fi
- \vfill \eject
- \contentsalignmacro % in case @setchapternewpage odd is in effect
- \ifeof 1 \else
- \pdfmakeoutlines
- \fi
- \closein 1
- \endgroup
- \lastnegativepageno = \pageno
- \global\pageno = \savepageno
+\outer\def\contents{%
+\finishcontents %
+\unnumbchapmacro{Table of Contents}
+\def\thischapter{Table of Contents}
+{\catcode`\\=0
+\catcode`\{=1 % Set up to handle contents files properly
+\catcode`\}=2
+\catcode`\@=11
+\input \jobname.toc
}
+\vfill \eject}
-% And just the chapters.
-\def\summarycontents{%
- \startcontents{\putwordShortTOC}%
- %
- \let\numchapentry = \shortchapentry
- \let\appentry = \shortchapentry
- \let\unnchapentry = \shortunnchapentry
- % We want a true roman here for the page numbers.
- \secfonts
- \let\rm=\shortcontrm \let\bf=\shortcontbf
- \let\sl=\shortcontsl \let\tt=\shortconttt
- \rm
- \hyphenpenalty = 10000
- \advance\baselineskip by 1pt % Open it up a little.
- \def\numsecentry##1##2##3##4{}
- \let\appsecentry = \numsecentry
- \let\unnsecentry = \numsecentry
- \let\numsubsecentry = \numsecentry
- \let\appsubsecentry = \numsecentry
- \let\unnsubsecentry = \numsecentry
- \let\numsubsubsecentry = \numsecentry
- \let\appsubsubsecentry = \numsecentry
- \let\unnsubsubsecentry = \numsecentry
- \openin 1 \jobname.toc
- \ifeof 1 \else
- \readtocfile
- \fi
- \closein 1
- \vfill \eject
- \contentsalignmacro % in case @setchapternewpage odd is in effect
- \endgroup
- \lastnegativepageno = \pageno
- \global\pageno = \savepageno
-}
-\let\shortcontents = \summarycontents
+\outer\def\summarycontents{%
+\finishcontents %
+\unnumbchapmacro{Summary Table of Contents}
+\def\thischapter{Summary Table of Contents}
+{\catcode`\\=0
+\catcode`\{=1 % Set up to handle contents files properly
+\catcode`\}=2
+\catcode`\@=11
+\def\smallbreak{}
+\def\secentry ##1##2##3##4{}
+\def\subsecentry ##1##2##3##4##5{}
+\def\subsubsecentry ##1##2##3##4##5##6{}
+\def\unnumbsecentry ##1##2{}
+\def\unnumbsubsecentry ##1##2{}
+\def\unnumbsubsubsecentry ##1##2{}
+\let\medbreak=\smallbreak
+\input \jobname.toc
+}
+\vfill \eject}
-% Typeset the label for a chapter or appendix for the short contents.
-% The arg is, e.g., `A' for an appendix, or `3' for a chapter.
-%
-\def\shortchaplabel#1{%
- % This space should be enough, since a single number is .5em, and the
- % widest letter (M) is 1em, at least in the Computer Modern fonts.
- % But use \hss just in case.
- % (This space doesn't include the extra space that gets added after
- % the label; that gets put in by \shortchapentry above.)
- %
- % We'd like to right-justify chapter numbers, but that looks strange
- % with appendix letters. And right-justifying numbers and
- % left-justifying letters looks strange when there is less than 10
- % chapters. Have to read the whole toc once to know how many chapters
- % there are before deciding ...
- \hbox to 1em{#1\hss}%
-}
+\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
-% These macros generate individual entries in the table of contents.
+% These macros generate individual entries in the table of contents
% The first argument is the chapter or section name.
% The last argument is the page number.
% The arguments in between are the chapter number, section number, ...
-% Chapters, in the main contents.
-\def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}}
-%
-% Chapters, in the short toc.
-% See comments in \dochapentry re vbox and related settings.
-\def\shortchapentry#1#2#3#4{%
- \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}%
-}
-
-% Appendices, in the main contents.
-% Need the word Appendix, and a fixed-size box.
-%
-\def\appendixbox#1{%
- % We use M since it's probably the widest letter.
- \setbox0 = \hbox{\putwordAppendix{} M}%
- \hbox to \wd0{\putwordAppendix{} #1\hss}}
-%
-\def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\labelspace#1}{#4}}
-
-% Unnumbered chapters.
-\def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
-\def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}}
-
-% Sections.
-\def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}}
-\let\appsecentry=\numsecentry
-\def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}}
-
-% Subsections.
-\def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}}
-\let\appsubsecentry=\numsubsecentry
-\def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}}
-
-% And subsubsections.
-\def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}}
-\let\appsubsubsecentry=\numsubsubsecentry
-\def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}}
-
-% This parameter controls the indentation of the various levels.
-% Same as \defaultparindent.
-\newdimen\tocindent \tocindent = 15pt
-
-% Now for the actual typesetting. In all these, #1 is the text and #2 is the
-% page number.
-%
-% If the toc has to be broken over pages, we want it to be at chapters
-% if at all possible; hence the \penalty.
-\def\dochapentry#1#2{%
- \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
- \begingroup
- \chapentryfonts
- \tocentry{#1}{\dopageno\bgroup#2\egroup}%
- \endgroup
- \nobreak\vskip .25\baselineskip plus.1\baselineskip
-}
-
-\def\dosecentry#1#2{\begingroup
- \secentryfonts \leftskip=\tocindent
- \tocentry{#1}{\dopageno\bgroup#2\egroup}%
-\endgroup}
-
-\def\dosubsecentry#1#2{\begingroup
- \subsecentryfonts \leftskip=2\tocindent
- \tocentry{#1}{\dopageno\bgroup#2\egroup}%
-\endgroup}
-
-\def\dosubsubsecentry#1#2{\begingroup
- \subsubsecentryfonts \leftskip=3\tocindent
- \tocentry{#1}{\dopageno\bgroup#2\egroup}%
-\endgroup}
-
-% We use the same \entry macro as for the index entries.
-\let\tocentry = \entry
-
-% Space between chapter (or whatever) number and the title.
-\def\labelspace{\hskip1em \relax}
-
-\def\dopageno#1{{\rm #1}}
-\def\doshortpageno#1{{\rm #1}}
-
-\def\chapentryfonts{\secfonts \rm}
-\def\secentryfonts{\textfonts}
-\def\subsecentryfonts{\textfonts}
-\def\subsubsecentryfonts{\textfonts}
-
-
-\message{environments,}
-% @foo ... @end foo.
-
-% @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
-%
-% Since these characters are used in examples, it should be an even number of
-% \tt widths. Each \tt character is 1en, so two makes it 1em.
-%
-\def\point{$\star$}
-\def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
-\def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}}
-\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
-\def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}}
-
-% The @error{} command.
-% Adapted from the TeXbook's \boxit.
-%
-\newbox\errorbox
-%
-{\tentt \global\dimen0 = 3em}% Width of the box.
-\dimen2 = .55pt % Thickness of rules
-% The text. (`r' is open on the right, `e' somewhat less so on the left.)
-\setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt}
-%
-\setbox\errorbox=\hbox to \dimen0{\hfil
- \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
- \advance\hsize by -2\dimen2 % Rules.
- \vbox{%
- \hrule height\dimen2
- \hbox{\vrule width\dimen2 \kern3pt % Space to left of text.
- \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
- \kern3pt\vrule width\dimen2}% Space to right.
- \hrule height\dimen2}
- \hfil}
-%
-\def\error{\leavevmode\lower.7ex\copy\errorbox}
-
-% @tex ... @end tex escapes into raw Tex temporarily.
-% One exception: @ is still an escape character, so that @end tex works.
-% But \@ or @@ will get a plain tex @ character.
-
-\envdef\tex{%
- \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
- \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
- \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
- \catcode `\%=14
- \catcode `\+=\other
- \catcode `\"=\other
- \catcode `\|=\other
- \catcode `\<=\other
- \catcode `\>=\other
- \escapechar=`\\
- %
- \let\b=\ptexb
- \let\bullet=\ptexbullet
- \let\c=\ptexc
- \let\,=\ptexcomma
- \let\.=\ptexdot
- \let\dots=\ptexdots
- \let\equiv=\ptexequiv
- \let\!=\ptexexclam
- \let\i=\ptexi
- \let\indent=\ptexindent
- \let\noindent=\ptexnoindent
- \let\{=\ptexlbrace
- \let\+=\tabalign
- \let\}=\ptexrbrace
- \let\/=\ptexslash
- \let\*=\ptexstar
- \let\t=\ptext
- \let\frenchspacing=\plainfrenchspacing
- %
- \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
- \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
- \def\@{@}%
-}
-% There is no need to define \Etex.
-
-% Define @lisp ... @end lisp.
-% @lisp environment forms a group so it can rebind things,
-% including the definition of @end lisp (which normally is erroneous).
-
-% Amount to narrow the margins by for @lisp.
-\newskip\lispnarrowing \lispnarrowing=0.4in
-
-% This is the definition that ^^M gets inside @lisp, @example, and other
-% such environments. \null is better than a space, since it doesn't
-% have any width.
-\def\lisppar{\null\endgraf}
-
-% This space is always present above and below environments.
-\newskip\envskipamount \envskipamount = 0pt
-
-% Make spacing and below environment symmetrical. We use \parskip here
-% to help in doing that, since in @example-like environments \parskip
-% is reset to zero; thus the \afterenvbreak inserts no space -- but the
-% start of the next paragraph will insert \parskip.
-%
-\def\aboveenvbreak{{%
- % =10000 instead of <10000 because of a special case in \itemzzz and
- % \sectionheading, q.v.
- \ifnum \lastpenalty=10000 \else
- \advance\envskipamount by \parskip
- \endgraf
- \ifdim\lastskip<\envskipamount
- \removelastskip
- % it's not a good place to break if the last penalty was \nobreak
- % or better ...
- \ifnum\lastpenalty<10000 \penalty-50 \fi
- \vskip\envskipamount
- \fi
- \fi
-}}
-
-\let\afterenvbreak = \aboveenvbreak
-
-% \nonarrowing is a flag. If "set", @lisp etc don't narrow margins; it will
-% also clear it, so that its embedded environments do the narrowing again.
-\let\nonarrowing=\relax
-
-% @cartouche ... @end cartouche: draw rectangle w/rounded corners around
-% environment contents.
-\font\circle=lcircle10
-\newdimen\circthick
-\newdimen\cartouter\newdimen\cartinner
-\newskip\normbskip\newskip\normpskip\newskip\normlskip
-\circthick=\fontdimen8\circle
-%
-\def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
-\def\ctr{{\hskip 6pt\circle\char'010}}
-\def\cbl{{\circle\char'012\hskip -6pt}}
-\def\cbr{{\hskip 6pt\circle\char'011}}
-\def\carttop{\hbox to \cartouter{\hskip\lskip
- \ctl\leaders\hrule height\circthick\hfil\ctr
- \hskip\rskip}}
-\def\cartbot{\hbox to \cartouter{\hskip\lskip
- \cbl\leaders\hrule height\circthick\hfil\cbr
- \hskip\rskip}}
-%
-\newskip\lskip\newskip\rskip
-
-\envdef\cartouche{%
- \ifhmode\par\fi % can't be in the midst of a paragraph.
- \startsavinginserts
- \lskip=\leftskip \rskip=\rightskip
- \leftskip=0pt\rightskip=0pt % we want these *outside*.
- \cartinner=\hsize \advance\cartinner by-\lskip
- \advance\cartinner by-\rskip
- \cartouter=\hsize
- \advance\cartouter by 18.4pt % allow for 3pt kerns on either
- % side, and for 6pt waste from
- % each corner char, and rule thickness
- \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
- % Flag to tell @lisp, etc., not to narrow margin.
- \let\nonarrowing = t%
- \vbox\bgroup
- \baselineskip=0pt\parskip=0pt\lineskip=0pt
- \carttop
- \hbox\bgroup
- \hskip\lskip
- \vrule\kern3pt
- \vbox\bgroup
- \kern3pt
- \hsize=\cartinner
- \baselineskip=\normbskip
- \lineskip=\normlskip
- \parskip=\normpskip
- \vskip -\parskip
- \comment % For explanation, see the end of \def\group.
+\def\chapentry #1#2#3{%
+\medbreak
+\line{#2.\space#1\leaders\hbox to 1em{\hss.\hss}\hfill #3}
}
-\def\Ecartouche{%
- \ifhmode\par\fi
- \kern3pt
- \egroup
- \kern3pt\vrule
- \hskip\rskip
- \egroup
- \cartbot
- \egroup
- \checkinserts
-}
-
-% This macro is called at the beginning of all the @example variants,
-% inside a group.
-\def\nonfillstart{%
- \aboveenvbreak
- \hfuzz = 12pt % Don't be fussy
- \sepspaces % Make spaces be word-separators rather than space tokens.
- \let\par = \lisppar % don't ignore blank lines
- \obeylines % each line of input is a line of output
- \parskip = 0pt
- \parindent = 0pt
- \emergencystretch = 0pt % don't try to avoid overfull boxes
- \ifx\nonarrowing\relax
- \advance \leftskip by \lispnarrowing
- \exdentamount=\lispnarrowing
- \else
- \let\nonarrowing = \relax
- \fi
- \let\exdent=\nofillexdent
+\def\unnumbchapentry #1#2{%
+\medbreak
+\line{#1\leaders\Dotsbox\hfill #2}
}
-% If you want all examples etc. small: @set dispenvsize small.
-% If you want even small examples the full size: @set dispenvsize nosmall.
-% This affects the following displayed environments:
-% @example, @display, @format, @lisp
-%
-\def\smallword{small}
-\def\nosmallword{nosmall}
-\let\SETdispenvsize\relax
-\def\setnormaldispenv{%
- \ifx\SETdispenvsize\smallword
- \smallexamplefonts \rm
- \fi
-}
-\def\setsmalldispenv{%
- \ifx\SETdispenvsize\nosmallword
- \else
- \smallexamplefonts \rm
- \fi
+\def\secentry #1#2#3#4{%
+\line{\enspace\enspace#2.#3\space#1\leaders\Dotsbox\hfill#4}
}
-% We often define two environments, @foo and @smallfoo.
-% Let's do it by one command:
-\def\makedispenv #1#2{
- \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}
- \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}
- \expandafter\let\csname E#1\endcsname \afterenvbreak
- \expandafter\let\csname Esmall#1\endcsname \afterenvbreak
+\def\unnumbsecentry #1#2{%
+\line{\enspace\enspace#1\leaders\Dotsbox\hfill #2}
}
-% Define two synonyms:
-\def\maketwodispenvs #1#2#3{
- \makedispenv{#1}{#3}
- \makedispenv{#2}{#3}
+\def\subsecentry #1#2#3#4#5{%
+\line{\enspace\enspace\enspace\enspace
+#2.#3.#4\space#1\leaders\Dotsbox\hfill #5}
}
-% @lisp: indented, narrowed, typewriter font; @example: same as @lisp.
-%
-% @smallexample and @smalllisp: use smaller fonts.
-% Originally contributed by Pavel@xerox.
-%
-\maketwodispenvs {lisp}{example}{%
- \nonfillstart
- \tt
- \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
- \gobble % eat return
+\def\unnumbsubsecentry #1#2{%
+\line{\enspace\enspace\enspace\enspace#1\leaders\Dotsbox\hfill #2}
}
-% @display/@smalldisplay: same as @lisp except keep current font.
-%
-\makedispenv {display}{%
- \nonfillstart
- \gobble
+\def\subsubsecentry #1#2#3#4#5#6{%
+\line{\enspace\enspace\enspace\enspace\enspace\enspace
+#2.#3.#4.#5\space#1\leaders\Dotsbox\hfill #6}
}
-% @format/@smallformat: same as @display except don't narrow margins.
-%
-\makedispenv{format}{%
- \let\nonarrowing = t%
- \nonfillstart
- \gobble
+\def\unnumbsubsubsecentry #1#2{%
+\line{\enspace\enspace\enspace\enspace\enspace\enspace#1\leaders\Dotsbox\hfill #2}
}
-% @flushleft: same as @format, but doesn't obey \SETdispenvsize.
-\envdef\flushleft{%
- \let\nonarrowing = t%
- \nonfillstart
- \gobble
-}
-\let\Eflushleft = \afterenvbreak
-
-% @flushright.
-%
-\envdef\flushright{%
- \let\nonarrowing = t%
- \nonfillstart
- \advance\leftskip by 0pt plus 1fill
- \gobble
-}
-\let\Eflushright = \afterenvbreak
-
-
-% @quotation does normal linebreaking (hence we can't use \nonfillstart)
-% and narrows the margins. We keep \parskip nonzero in general, since
-% we're doing normal filling. So, when using \aboveenvbreak and
-% \afterenvbreak, temporarily make \parskip 0.
-%
-\envdef\quotation{%
- {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
- \parindent=0pt
- %
- % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
- \ifx\nonarrowing\relax
- \advance\leftskip by \lispnarrowing
- \advance\rightskip by \lispnarrowing
- \exdentamount = \lispnarrowing
- \else
- \let\nonarrowing = \relax
- \fi
- \parsearg\quotationlabel
-}
-
-% We have retained a nonzero parskip for the environment, since we're
-% doing normal filling.
-%
-\def\Equotation{%
- \par
- \ifx\quotationauthor\undefined\else
- % indent a bit.
- \leftline{\kern 2\leftskip \sl ---\quotationauthor}%
- \fi
- {\parskip=0pt \afterenvbreak}%
-}
-
-% If we're given an argument, typeset it in bold with a colon after.
-\def\quotationlabel#1{%
- \def\temp{#1}%
- \ifx\temp\empty \else
- {\bf #1: }%
- \fi
-}
-
-
-% LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
-% If we want to allow any <char> as delimiter,
-% we need the curly braces so that makeinfo sees the @verb command, eg:
-% `@verbx...x' would look like the '@verbx' command. --janneke@gnu.org
-%
-% [Knuth]: Donald Ervin Knuth, 1996. The TeXbook.
-%
-% [Knuth] p.344; only we need to do the other characters Texinfo sets
-% active too. Otherwise, they get lost as the first character on a
-% verbatim line.
-\def\dospecials{%
- \do\ \do\\\do\{\do\}\do\$\do\&%
- \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
- \do\<\do\>\do\|\do\@\do+\do\"%
-}
-%
-% [Knuth] p. 380
-\def\uncatcodespecials{%
- \def\do##1{\catcode`##1=\other}\dospecials}
-%
-% [Knuth] pp. 380,381,391
-% Disable Spanish ligatures ?` and !` of \tt font
-\begingroup
- \catcode`\`=\active\gdef`{\relax\lq}
-\endgroup
-%
-% Setup for the @verb command.
-%
-% Eight spaces for a tab
-\begingroup
- \catcode`\^^I=\active
- \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
-\endgroup
-%
-\def\setupverb{%
- \tt % easiest (and conventionally used) font for verbatim
- \def\par{\leavevmode\endgraf}%
- \catcode`\`=\active
- \tabeightspaces
- % Respect line breaks,
- % print special symbols as themselves, and
- % make each space count
- % must do in this order:
- \obeylines \uncatcodespecials \sepspaces
-}
-
-% Setup for the @verbatim environment
-%
-% Real tab expansion
-\newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
-%
-\def\starttabbox{\setbox0=\hbox\bgroup}
-\begingroup
- \catcode`\^^I=\active
- \gdef\tabexpand{%
- \catcode`\^^I=\active
- \def^^I{\leavevmode\egroup
- \dimen0=\wd0 % the width so far, or since the previous tab
- \divide\dimen0 by\tabw
- \multiply\dimen0 by\tabw % compute previous multiple of \tabw
- \advance\dimen0 by\tabw % advance to next multiple of \tabw
- \wd0=\dimen0 \box0 \starttabbox
- }%
- }
-\endgroup
-\def\setupverbatim{%
- \let\nonarrowing = t%
- \nonfillstart
- % Easiest (and conventionally used) font for verbatim
- \tt
- \def\par{\leavevmode\egroup\box0\endgraf}%
- \catcode`\`=\active
- \tabexpand
- % Respect line breaks,
- % print special symbols as themselves, and
- % make each space count
- % must do in this order:
- \obeylines \uncatcodespecials \sepspaces
- \everypar{\starttabbox}%
-}
+\message{environments,}
-% Do the @verb magic: verbatim text is quoted by unique
-% delimiter characters. Before first delimiter expect a
-% right brace, after last delimiter expect closing brace:
-%
-% \def\doverb'{'<char>#1<char>'}'{#1}
-%
-% [Knuth] p. 382; only eat outer {}
-\begingroup
- \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other
- \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
-\endgroup
-%
-\def\verb{\begingroup\setupverb\doverb}
-%
-%
-% Do the @verbatim magic: define the macro \doverbatim so that
-% the (first) argument ends when '@end verbatim' is reached, ie:
-%
-% \def\doverbatim#1@end verbatim{#1}
-%
-% For Texinfo it's a lot easier than for LaTeX,
-% because texinfo's \verbatim doesn't stop at '\end{verbatim}':
-% we need not redefine '\', '{' and '}'.
-%
-% Inspired by LaTeX's verbatim command set [latex.ltx]
-%
-\begingroup
- \catcode`\ =\active
- \obeylines %
- % ignore everything up to the first ^^M, that's the newline at the end
- % of the @verbatim input line itself. Otherwise we get an extra blank
- % line in the output.
- \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}%
- % We really want {...\end verbatim} in the body of the macro, but
- % without the active space; thus we have to use \xdef and \gobble.
-\endgroup
-%
-\envdef\verbatim{%
- \setupverbatim\doverbatim
-}
-\let\Everbatim = \afterenvbreak
+% @tex ... @end tex escapes into raw Tex temporarily.
+% One exception: @ is still an escape character, so that @end tex works.
+% But \@ or @@ will get a plain tex @ character.
+\def\tex{\begingroup
+\catcode `\\=0 \catcode `\{=1 \catcode `\}=2
+\catcode `\$=3 \catcode `\&=4 \catcode `\#=6
+\catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie
+\catcode `\%=14
+\catcode`\"=12
+\catcode`\|=12
+\catcode`\<=12
+\catcode`\>=12
+\escapechar=`\\
+%
+\let\{=\ptexlbrace
+\let\}=\ptexrbrace
+\let\.=\ptexdot
+\let\*=\ptexstar
+\def\@={@}%
+\let\bullet=\ptexbullet
+\let\b=\ptexb \let\c=\ptexc \let\i=\ptexi \let\t=\ptext \let\l=\ptexl
+\let\L=\ptexL
+%
+\let\Etex=\endgroup}
+
+% Define @lisp ... @endlisp.
+% @lisp does a \begingroup so it can rebind things,
+% including the definition of @endlisp (which normally is erroneous).
-% @verbatiminclude FILE - insert text of file in verbatim environment.
-%
-\def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude}
-%
-\def\doverbatiminclude#1{%
- {%
- \makevalueexpandable
- \setupverbatim
- \input #1
- \afterenvbreak
- }%
-}
+% Amount to narrow the margins by for @lisp.
+\newskip\lispnarrowing \lispnarrowing=0.4in
-% @copying ... @end copying.
-% Save the text away for @insertcopying later.
-%
-% We save the uninterpreted tokens, rather than creating a box.
-% Saving the text in a box would be much easier, but then all the
-% typesetting commands (@smallbook, font changes, etc.) have to be done
-% beforehand -- and a) we want @copying to be done first in the source
-% file; b) letting users define the frontmatter in as flexible order as
-% possible is very desirable.
-%
-\def\copying{\checkenv{}\begingroup\scanargctxt\docopying}
-\def\docopying#1@end copying{\endgroup\def\copyingtext{#1}}
-%
-\def\insertcopying{%
- \begingroup
- \parindent = 0pt % paragraph indentation looks wrong on title page
- \scanexp\copyingtext
- \endgroup
-}
+% This is the definition that ^M gets inside @lisp
+% phr: changed space to \null, to avoid overfull hbox problems.
+{\obeyspaces%
+\gdef\lisppar{\null\endgraf}}
+
+% Cause \obeyspaces to make each Space cause a word-separation
+% rather than the default which is that it acts punctuation.
+% This is because space in tt font looks funny.
+{\obeyspaces %
+\gdef\sepspaces{\def {\ }}}
+
+\newskip\aboveenvskipamount \aboveenvskipamount= 0pt
+\def\aboveenvbreak{{\advance\aboveenvskipamount by \parskip
+\endgraf \ifdim\lastskip<\aboveenvskipamount
+\removelastskip \penalty-50 \vskip\aboveenvskipamount \fi}}
+
+\def\afterenvbreak{\endgraf \ifdim\lastskip<\aboveenvskipamount
+\removelastskip \penalty-50 \vskip\aboveenvskipamount \fi}
+
+\def\lisp{\aboveenvbreak\begingroup\inENV %This group ends at the end of the @lisp body
+\hfuzz=12truept % Don't be fussy
+% Make spaces be word-separators rather than space tokens.
+\sepspaces %
+% Single space lines
+\singlespace %
+% The following causes blank lines not to be ignored
+% by adding a space to the end of each line.
+\let\par=\lisppar
+\def\Elisp{\endgroup\afterenvbreak}%
+\parskip=0pt \advance \rightskip by \lispnarrowing
+\advance \leftskip by \lispnarrowing
+\parindent=0pt
+\let\exdent=\internalexdent
+\obeyspaces \obeylines \tt \rawbackslash
+\def\next##1{}\next}
+
+
+\let\example=\lisp
+\def\Eexample{\Elisp}
+
+\let\smallexample=\lisp
+\def\Esmallexample{\Elisp}
+
+% Macro for 9 pt. examples, necessary to print with 5" lines.
+% From Pavel@xerox. This is not really used unless the
+% @smallbook command is given.
+
+\def\smalllispx{\aboveenvbreak\begingroup\inENV
+% This group ends at the end of the @lisp body
+\hfuzz=12truept % Don't be fussy
+% Make spaces be word-separators rather than space tokens.
+\sepspaces %
+% Single space lines
+\singlespace %
+% The following causes blank lines not to be ignored
+% by adding a space to the end of each line.
+\let\par=\lisppar
+\def\Esmalllisp{\endgroup\afterenvbreak}%
+\parskip=0pt \advance \rightskip by \lispnarrowing
+\advance \leftskip by \lispnarrowing
+\parindent=0pt
+\let\exdent=\internalexdent
+\obeyspaces \obeylines \ninett \rawbackslash
+\def\next##1{}\next}
+
+% This is @display; same as @lisp except use roman font.
+
+\def\display{\begingroup\inENV %This group ends at the end of the @display body
+\aboveenvbreak
+% Make spaces be word-separators rather than space tokens.
+\sepspaces %
+% Single space lines
+\singlespace %
+% The following causes blank lines not to be ignored
+% by adding a space to the end of each line.
+\let\par=\lisppar
+\def\Edisplay{\endgroup\afterenvbreak}%
+\parskip=0pt \advance \rightskip by \lispnarrowing
+\advance \leftskip by \lispnarrowing
+\parindent=0pt
+\let\exdent=\internalexdent
+\obeyspaces \obeylines
+\def\next##1{}\next}
+
+% This is @format; same as @lisp except use roman font and don't narrow margins
+
+\def\format{\begingroup\inENV %This group ends at the end of the @format body
+\aboveenvbreak
+% Make spaces be word-separators rather than space tokens.
+\sepspaces %
+\singlespace %
+% The following causes blank lines not to be ignored
+% by adding a space to the end of each line.
+\let\par=\lisppar
+\def\Eformat{\endgroup\afterenvbreak}
+\parskip=0pt \parindent=0pt
+\obeyspaces \obeylines
+\def\next##1{}\next}
+
+% @flushleft and @flushright
+
+\def\flushleft{\begingroup\inENV %This group ends at the end of the @format body
+\aboveenvbreak
+% Make spaces be word-separators rather than space tokens.
+\sepspaces %
+% The following causes blank lines not to be ignored
+% by adding a space to the end of each line.
+% This also causes @ to work when the directive name
+% is terminated by end of line.
+\let\par=\lisppar
+\def\Eflushleft{\endgroup\afterenvbreak}%
+\parskip=0pt \parindent=0pt
+\obeyspaces \obeylines
+\def\next##1{}\next}
+
+\def\flushright{\begingroup\inENV %This group ends at the end of the @format body
+\aboveenvbreak
+% Make spaces be word-separators rather than space tokens.
+\sepspaces %
+% The following causes blank lines not to be ignored
+% by adding a space to the end of each line.
+% This also causes @ to work when the directive name
+% is terminated by end of line.
+\let\par=\lisppar
+\def\Eflushright{\endgroup\afterenvbreak}%
+\parskip=0pt \parindent=0pt
+\advance \leftskip by 0pt plus 1fill
+\obeyspaces \obeylines
+\def\next##1{}\next}
+
+% @quotation - narrow the margins.
+
+\def\quotation{\begingroup\inENV %This group ends at the end of the @quotation body
+{\parskip=0pt % because we will skip by \parskip too, later
+\aboveenvbreak}%
+\singlespace
+\parindent=0pt
+\def\Equotation{\par\endgroup\afterenvbreak}%
+\advance \rightskip by \lispnarrowing
+\advance \leftskip by \lispnarrowing}
\message{defuns,}
-% @defun etc.
+% Define formatter for defuns
+% First, allow user to change definition object font (\df) internally
+\def\setdeffont #1 {\csname DEF#1\endcsname}
-\newskip\defbodyindent \defbodyindent=.4in
+\newskip\defbodyindent \defbodyindent=36pt
\newskip\defargsindent \defargsindent=50pt
+\newskip\deftypemargin \deftypemargin=12pt
\newskip\deflastargmargin \deflastargmargin=18pt
-% Start the processing of @deffn:
-\def\startdefun{%
- \ifnum\lastpenalty<10000
- \medbreak
- \else
- % If there are two @def commands in a row, we'll have a \nobreak,
- % which is there to keep the function description together with its
- % header. But if there's nothing but headers, we need to allow a
- % break somewhere. Check specifically for penalty 10002, inserted
- % by \defargscommonending, instead of 10000, since the sectioning
- % commands also insert a nobreak penalty, and we don't want to allow
- % a break between a section heading and a defun.
- %
- \ifnum\lastpenalty=10002 \penalty2000 \fi
- %
- % Similarly, after a section heading, do not allow a break.
- % But do insert the glue.
- \medskip % preceded by discardable penalty, so not a breakpoint
- \fi
- %
- \parindent=0in
- \advance\leftskip by \defbodyindent
- \exdentamount=\defbodyindent
-}
-
-\def\dodefunx#1{%
- % First, check whether we are in the right environment:
- \checkenv#1%
- %
- % As above, allow line break if we have multiple x headers in a row.
- % It's not a great place, though.
- \ifnum\lastpenalty=10002 \penalty3000 \fi
- %
- % And now, it's time to reuse the body of the original defun:
- \expandafter\gobbledefun#1%
-}
-\def\gobbledefun#1\startdefun{}
-
-% \printdefunline \deffnheader{text}
-%
-\def\printdefunline#1#2{%
- \begingroup
- % call \deffnheader:
- #1#2 \endheader
- % common ending:
- \interlinepenalty = 10000
- \advance\rightskip by 0pt plus 1fil
- \endgraf
- \nobreak\vskip -\parskip
- \penalty 10002 % signal to \startdefun and \dodefunx
- % Some of the @defun-type tags do not enable magic parentheses,
- % rendering the following check redundant. But we don't optimize.
- \checkparencounts
- \endgroup
-}
-
-\def\Edefun{\endgraf\medbreak}
-
-% \makedefun{deffn} creates \deffn, \deffnx and \Edeffn;
-% the only thing remainnig is to define \deffnheader.
-%
-\def\makedefun#1{%
- \expandafter\let\csname E#1\endcsname = \Edefun
- \edef\temp{\noexpand\domakedefun
- \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
- \temp
-}
-
-% \domakedefun \deffn \deffnx \deffnheader
-%
-% Define \deffn and \deffnx, without parameters.
-% \deffnheader has to be defined explicitly.
-%
-\def\domakedefun#1#2#3{%
- \envdef#1{%
- \startdefun
- \parseargusing\activeparens{\printdefunline#3}%
- }%
- \def#2{\dodefunx#1}%
- \def#3%
-}
-
-%%% Untyped functions:
-
-% @deffn category name args
-\makedefun{deffn}{\deffngeneral{}}
-
-% @deffn category class name args
-\makedefun{defop}#1 {\defopon{#1\ \putwordon}}
+\newcount\parencount
+% define \functionparens, which makes ( and ) and & do special things.
+% \functionparens affects the group it is contained in.
+\def\activeparens{%
+\catcode`\(=\active \catcode`\)=\active \catcode`\&=\active
+\catcode`\[=\active \catcode`\]=\active}
+{\activeparens % Now, smart parens don't turn on until &foo (see \amprm)
+\gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 }
+\gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
+
+% Definitions of (, ) and & used in args for functions.
+% This is the definition of ( outside of all parentheses.
+\gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested %
+\global\advance\parencount by 1 }
+%
+% This is the definition of ( when already inside a level of parens.
+\gdef\opnested{\char`\(\global\advance\parencount by 1 }
+%
+\gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0.
+% also in that case restore the outer-level definition of (.
+\ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi
+\global\advance \parencount by -1 }
+% If we encounter &foo, then turn on ()-hacking afterwards
+\gdef\amprm#1 {{\rm\&#1}\let(=\oprm \let)=\clrm\ }
+%
+\gdef\normalparens{\boldbrax\let&=\ampnr}
+} % End of definition inside \activeparens
+%% These parens (in \boldbrax) actually are a little bolder than the
+%% contained text. This is especially needed for [ and ]
+\def\opnr{{\sf\char`\(}} \def\clnr{{\sf\char`\)}} \def\ampnr{\&}
+\def\lbrb{{\tt\char`\[}} \def\rbrb{{\tt\char`\]}}
-% \defopon {category on}class name args
-\def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
+% First, defname, which formats the header line itself.
+% #1 should be the function name.
+% #2 should be the type of definition, such as "Function".
-% \deffngeneral {subind}category name args
-%
-\def\deffngeneral#1#2 #3 #4\endheader{%
- % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}.
- \dosubind{fn}{\code{#3}}{#1}%
- \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
+\def\defname #1#2{%
+\leftskip = 0in %
+\noindent %
+\setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}%
+\dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line
+\dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations
+\parshape 2 0in \dimen0 \defargsindent \dimen1 %
+% Now output arg 2 ("Function" or some such)
+% ending at \deftypemargin from the right margin,
+% but stuck inside a box of width 0 so it does not interfere with linebreaking
+\rlap{\rightline{{\rm #2}\hskip \deftypemargin}}%
+\tolerance=10000 \hbadness=10000 % Make all lines underfull and no complaints
+{\df #1}\enskip % Generate function name
}
-%%% Typed functions:
+% Actually process the body of a definition
+% #1 should be the terminating control sequence, such as \Edefun.
+% #2 should be the "another name" control sequence, such as \defunx.
+% #3 should be the control sequence that actually processes the header,
+% such as \defunheader.
-% @deftypefn category type name args
-\makedefun{deftypefn}{\deftypefngeneral{}}
+\def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
+\medbreak %
+% Define the end token that this defining construct specifies
+% so that it will exit this group.
+\def#1{\endgraf\endgroup\medbreak}%
+\def#2{\begingroup\obeylines\activeparens\spacesplit#3}%
+\parindent=0in \leftskip=\defbodyindent %
+\begingroup\obeylines\activeparens\spacesplit#3}
-% @deftypeop category class type name args
-\makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}}
-
-% \deftypeopon {category on}class type name args
-\def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
-
-% \deftypefngeneral {subind}category type name args
-%
-\def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
- \dosubind{fn}{\code{#4}}{#1}%
- \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
-}
+\def\defmethparsebody #1#2#3#4 {\begingroup\inENV %
+\medbreak %
+% Define the end token that this defining construct specifies
+% so that it will exit this group.
+\def#1{\endgraf\endgroup\medbreak}%
+\def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}%
+\parindent=0in \leftskip=\defbodyindent %
+\begingroup\obeylines\activeparens\spacesplit{#3{#4}}}
-%%% Typed variables:
+% Split up #2 at the first space token.
+% call #1 with two arguments:
+% the first is all of #2 before the space token,
+% the second is all of #2 after that space token.
+% If #2 contains no space token, all of it is passed as the first arg
+% and the second is passed as empty.
-% @deftypevr category type var args
-\makedefun{deftypevr}{\deftypecvgeneral{}}
+{\obeylines
+\gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}%
+\long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{%
+\ifx\relax #3%
+#1{#2}{}\else #1{#2}{#3#4}\fi}}
-% @deftypecv category class type var args
-\makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}}
+% So much for the things common to all kinds of definitions.
-% \deftypecvof {category of}class type var args
-\def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} }
+% Define @defun.
-% \deftypecvgeneral {subind}category type var args
-%
-\def\deftypecvgeneral#1#2 #3 #4 #5\endheader{%
- \dosubind{vr}{\code{#4}}{#1}%
- \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
-}
+% First, define the processing that is wanted for arguments of \defun
+% Use this to expand the args and terminate the paragraph they make up
-%%% Untyped variables:
+\def\defunargs #1{\functionparens \sl #1%
+\ifnum\parencount=0 \else \errmessage{unbalanced parens in @def arguments}\fi%
+\interlinepenalty=10000
+\endgraf\vskip -\parskip \penalty 10000}
-% @defvr category var args
-\makedefun{defvr}#1 {\deftypevrheader{#1} {} }
+% Do complete processing of one @defun or @defunx line already parsed.
-% @defcv category class var args
-\makedefun{defcv}#1 {\defcvof{#1\ \putwordof}}
+% @deffn Command forward-char nchars
-% \defcvof {category of}class var args
-\def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
+\def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader}
-%%% Type:
-% @deftp category name args
-\makedefun{deftp}#1 #2 #3\endheader{%
- \doind{tp}{\code{#2}}%
- \defname{#1}{}{#2}\defunargs{#3\unskip}%
-}
+\def\deffnheader #1#2#3{\doind {fn}{\code{#2}}%
+\begingroup\defname {#2}{#1}\defunargs{#3}\endgroup}
-% Remaining @defun-like shortcuts:
-\makedefun{defun}{\deffnheader{\putwordDeffunc} }
-\makedefun{defmac}{\deffnheader{\putwordDefmac} }
-\makedefun{defspec}{\deffnheader{\putwordDefspec} }
-\makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
-\makedefun{defvar}{\defvrheader{\putwordDefvar} }
-\makedefun{defopt}{\defvrheader{\putwordDefopt} }
-\makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
-\makedefun{defmethod}{\defopon\putwordMethodon}
-\makedefun{deftypemethod}{\deftypeopon\putwordMethodon}
-\makedefun{defivar}{\defcvof\putwordInstanceVariableof}
-\makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof}
-
-% \defname, which formats the name of the @def (not the args).
-% #1 is the category, such as "Function".
-% #2 is the return type, if any.
-% #3 is the function name.
-%
-% We are followed by (but not passed) the arguments, if any.
-%
-\def\defname#1#2#3{%
- % Get the values of \leftskip and \rightskip as they were outside the @def...
- \advance\leftskip by -\defbodyindent
- %
- % How we'll format the type name. Putting it in brackets helps
- % distinguish it from the body text that may end up on the next line
- % just below it.
- \def\temp{#1}%
- \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
- %
- % Figure out line sizes for the paragraph shape.
- % The first line needs space for \box0; but if \rightskip is nonzero,
- % we need only space for the part of \box0 which exceeds it:
- \dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip
- % The continuations:
- \dimen2=\hsize \advance\dimen2 by -\defargsindent
- % (plain.tex says that \dimen1 should be used only as global.)
- \parshape 2 0in \dimen0 \defargsindent \dimen2
- %
- % Put the type name to the right margin.
- \noindent
- \hbox to 0pt{%
- \hfil\box0 \kern-\hsize
- % \hsize has to be shortened this way:
- \kern\leftskip
- % Intentionally do not respect \rightskip, since we need the space.
- }%
- %
- % Allow all lines to be underfull without complaint:
- \tolerance=10000 \hbadness=10000
- \exdentamount=\defbodyindent
- {%
- % defun fonts. We use typewriter by default (used to be bold) because:
- % . we're printing identifiers, they should be in tt in principle.
- % . in languages with many accents, such as Czech or French, it's
- % common to leave accents off identifiers. The result looks ok in
- % tt, but exceedingly strange in rm.
- % . we don't want -- and --- to be treated as ligatures.
- % . this still does not fix the ?` and !` ligatures, but so far no
- % one has made identifiers using them :).
- \df \tt
- \def\temp{#2}% return value type
- \ifx\temp\empty\else \tclose{\temp} \fi
- #3% output function name
- }%
- {\rm\enskip}% hskip 0.5 em of \tenrm
- %
- \boldbrax
- % arguments will be output next, if any.
-}
+% @defun == @deffn Function
-% Print arguments in slanted roman (not ttsl), inconsistently with using
-% tt for the name. This is because literal text is sometimes needed in
-% the argument list (groff manual), and ttsl and tt are not very
-% distinguishable. Prevent hyphenation at `-' chars.
-%
-\def\defunargs#1{%
- % use sl by default (not ttsl),
- % tt for the names.
- \df \sl \hyphenchar\font=0
- %
- % On the other hand, if an argument has two dashes (for instance), we
- % want a way to get ttsl. Let's try @var for that.
- \let\var=\ttslanted
- #1%
- \sl\hyphenchar\font=45
-}
+\def\defun{\defparsebody\Edefun\defunx\defunheader}
-% We want ()&[] to print specially on the defun line.
-%
-\def\activeparens{%
- \catcode`\(=\active \catcode`\)=\active
- \catcode`\[=\active \catcode`\]=\active
- \catcode`\&=\active
+\def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
+\begingroup\defname {#1}{Function}%
+\defunargs {#2}\endgroup %
}
-% Make control sequences which act like normal parenthesis chars.
-\let\lparen = ( \let\rparen = )
-
-% Be sure that we always have a definition for `(', etc. For example,
-% if the fn name has parens in it, \boldbrax will not be in effect yet,
-% so TeX would otherwise complain about undefined control sequence.
-{
- \activeparens
- \global\let(=\lparen \global\let)=\rparen
- \global\let[=\lbrack \global\let]=\rbrack
- \global\let& = \&
-
- \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
- \gdef\magicamp{\let&=\amprm}
-}
+% @defmac == @deffn Macro
-\newcount\parencount
+\def\defmac{\defparsebody\Edefmac\defmacx\defmacheader}
-% If we encounter &foo, then turn on ()-hacking afterwards
-\newif\ifampseen
-\def\amprm#1 {\ampseentrue{\bf\&#1 }}
-
-\def\parenfont{%
- \ifampseen
- % At the first level, print parens in roman,
- % otherwise use the default font.
- \ifnum \parencount=1 \rm \fi
- \else
- % The \sf parens (in \boldbrax) actually are a little bolder than
- % the contained text. This is especially needed for [ and ] .
- \sf
- \fi
+\def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
+\begingroup\defname {#1}{Macro}%
+\defunargs {#2}\endgroup %
}
-\def\infirstlevel#1{%
- \ifampseen
- \ifnum\parencount=1
- #1%
- \fi
- \fi
-}
-\def\bfafterword#1 {#1 \bf}
-\def\opnr{%
- \global\advance\parencount by 1
- {\parenfont(}%
- \infirstlevel \bfafterword
-}
-\def\clnr{%
- {\parenfont)}%
- \infirstlevel \sl
- \global\advance\parencount by -1
-}
+% @defspec == @deffn Special Form
-\newcount\brackcount
-\def\lbrb{%
- \global\advance\brackcount by 1
- {\bf[}%
-}
-\def\rbrb{%
- {\bf]}%
- \global\advance\brackcount by -1
-}
+\def\defspec{\defparsebody\Edefspec\defspecx\defspecheader}
-\def\checkparencounts{%
- \ifnum\parencount=0 \else \badparencount \fi
- \ifnum\brackcount=0 \else \badbrackcount \fi
-}
-\def\badparencount{%
- \errmessage{Unbalanced parentheses in @def}%
- \global\parencount=0
-}
-\def\badbrackcount{%
- \errmessage{Unbalanced square braces in @def}%
- \global\brackcount=0
+\def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
+\begingroup\defname {#1}{Special form}%
+\defunargs {#2}\endgroup %
}
+% This definition is run if you use @defunx
+% anywhere other than immediately after a @defun or @defunx.
-\message{macros,}
-% @macro.
-
-% To do this right we need a feature of e-TeX, \scantokens,
-% which we arrange to emulate with a temporary file in ordinary TeX.
-\ifx\eTeXversion\undefined
- \newwrite\macscribble
- \def\scantokens#1{%
- \toks0={#1}%
- \immediate\openout\macscribble=\jobname.tmp
- \immediate\write\macscribble{\the\toks0}%
- \immediate\closeout\macscribble
- \input \jobname.tmp
- }
-\fi
+\def\deffnx #1 {\errmessage{@deffnx in invalid context}}
+\def\defunx #1 {\errmessage{@defunx in invalid context}}
+\def\defmacx #1 {\errmessage{@defmacx in invalid context}}
+\def\defspecx #1 {\errmessage{@defspecx in invalid context}}
-\def\scanmacro#1{%
- \begingroup
- \newlinechar`\^^M
- \let\xeatspaces\eatspaces
- % Undo catcode changes of \startcontents and \doprintindex
- % When called from @insertcopying or (short)caption, we need active
- % backslash to get it printed correctly. Previously, we had
- % \catcode`\\=\other instead. We'll see whether a problem appears
- % with macro expansion. --kasal, 19aug04
- \catcode`\@=0 \catcode`\\=\active \escapechar=`\@
- % ... and \example
- \spaceisspace
- %
- % Append \endinput to make sure that TeX does not see the ending newline.
- %
- % I've verified that it is necessary both for e-TeX and for ordinary TeX
- % --kasal, 29nov03
- \scantokens{#1\endinput}%
- \endgroup
-}
+% @defmethod, and so on
-\def\scanexp#1{%
- \edef\temp{\noexpand\scanmacro{#1}}%
- \temp
-}
+% @defop {Funny Method} foo-class frobnicate argument
-\newcount\paramno % Count of parameters
-\newtoks\macname % Macro name
-\newif\ifrecursive % Is it recursive?
-
-% List of all defined macros in the form
-% \definedummyword\macro1\definedummyword\macro2...
-% Currently is also contains all @aliases; the list can be split
-% if there is a need.
-\def\macrolist{}
-
-% Add the macro to \macrolist
-\def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname}
-\def\addtomacrolistxxx#1{%
- \toks0 = \expandafter{\macrolist\definedummyword#1}%
- \xdef\macrolist{\the\toks0}%
-}
+\def\defop #1 {\def\defoptype{#1}%
+\defmethparsebody\Edefop\defopx\defopheader}
-% Utility routines.
-% This does \let #1 = #2, with \csnames; that is,
-% \let \csname#1\endcsname = \csname#2\endcsname
-% (except of course we have to play expansion games).
-%
-\def\cslet#1#2{%
- \expandafter\let
- \csname#1\expandafter\endcsname
- \csname#2\endcsname
+\def\defopheader #1#2#3{\dosubind {fn}{\code{#2}}{on #1}% Make entry in function index
+\begingroup\defname {#2}{\defoptype{} on #1}%
+\defunargs {#3}\endgroup %
}
-% Trim leading and trailing spaces off a string.
-% Concepts from aro-bend problem 15 (see CTAN).
-{\catcode`\@=11
-\gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
-\gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
-\gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
-\def\unbrace#1{#1}
-\unbrace{\gdef\trim@@@ #1 } #2@{#1}
-}
+% @defmethod == @defop Method
-% Trim a single trailing ^^M off a string.
-{\catcode`\^^M=\other \catcode`\Q=3%
-\gdef\eatcr #1{\eatcra #1Q^^MQ}%
-\gdef\eatcra#1^^MQ{\eatcrb#1Q}%
-\gdef\eatcrb#1Q#2Q{#1}%
-}
+\def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader}
-% Macro bodies are absorbed as an argument in a context where
-% all characters are catcode 10, 11 or 12, except \ which is active
-% (as in normal texinfo). It is necessary to change the definition of \.
-
-% It's necessary to have hard CRs when the macro is executed. This is
-% done by making ^^M (\endlinechar) catcode 12 when reading the macro
-% body, and then making it the \newlinechar in \scanmacro.
-
-\def\scanctxt{%
- \catcode`\"=\other
- \catcode`\+=\other
- \catcode`\<=\other
- \catcode`\>=\other
- \catcode`\@=\other
- \catcode`\^=\other
- \catcode`\_=\other
- \catcode`\|=\other
- \catcode`\~=\other
+\def\defmethodheader #1#2#3{\dosubind {fn}{\code{#2}}{on #1}% entry in function index
+\begingroup\defname {#2}{Operation on #1}%
+\defunargs {#3}\endgroup %
}
-\def\scanargctxt{%
- \scanctxt
- \catcode`\\=\other
- \catcode`\^^M=\other
-}
+% @defcv {Class Option} foo-class foo-flag
-\def\macrobodyctxt{%
- \scanctxt
- \catcode`\{=\other
- \catcode`\}=\other
- \catcode`\^^M=\other
- \usembodybackslash
-}
+\def\defcv #1 {\def\defcvtype{#1}%
+\defmethparsebody\Edefcv\defcvx\defcvheader}
-\def\macroargctxt{%
- \scanctxt
- \catcode`\\=\other
+\def\defcvarheader #1#2#3{%
+\dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
+\begingroup\defname {#2}{\defcvtype of #1}%
+\defvarargs {#3}\endgroup %
}
-% \mbodybackslash is the definition of \ in @macro bodies.
-% It maps \foo\ => \csname macarg.foo\endcsname => #N
-% where N is the macro parameter number.
-% We define \csname macarg.\endcsname to be \realbackslash, so
-% \\ in macro replacement text gets you a backslash.
+% @defivar == @defcv {Instance Variable}
-{\catcode`@=0 @catcode`@\=@active
- @gdef@usembodybackslash{@let\=@mbodybackslash}
- @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
-}
-\expandafter\def\csname macarg.\endcsname{\realbackslash}
-
-\def\macro{\recursivefalse\parsearg\macroxxx}
-\def\rmacro{\recursivetrue\parsearg\macroxxx}
-
-\def\macroxxx#1{%
- \getargs{#1}% now \macname is the macname and \argl the arglist
- \ifx\argl\empty % no arguments
- \paramno=0%
- \else
- \expandafter\parsemargdef \argl;%
- \fi
- \if1\csname ismacro.\the\macname\endcsname
- \message{Warning: redefining \the\macname}%
- \else
- \expandafter\ifx\csname \the\macname\endcsname \relax
- \else \errmessage{Macro name \the\macname\space already defined}\fi
- \global\cslet{macsave.\the\macname}{\the\macname}%
- \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
- \addtomacrolist{\the\macname}%
- \fi
- \begingroup \macrobodyctxt
- \ifrecursive \expandafter\parsermacbody
- \else \expandafter\parsemacbody
- \fi}
-
-\parseargdef\unmacro{%
- \if1\csname ismacro.#1\endcsname
- \global\cslet{#1}{macsave.#1}%
- \global\expandafter\let \csname ismacro.#1\endcsname=0%
- % Remove the macro name from \macrolist:
- \begingroup
- \expandafter\let\csname#1\endcsname \relax
- \let\definedummyword\unmacrodo
- \xdef\macrolist{\macrolist}%
- \endgroup
- \else
- \errmessage{Macro #1 not defined}%
- \fi
-}
+\def\defivar{\defmethparsebody\Edefivar\defivarx\defivarheader}
-% Called by \do from \dounmacro on each macro. The idea is to omit any
-% macro definitions that have been changed to \relax.
-%
-\def\unmacrodo#1{%
- \ifx #1\relax
- % remove this
- \else
- \noexpand\definedummyword \noexpand#1%
- \fi
+\def\defivarheader #1#2#3{%
+\dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
+\begingroup\defname {#2}{Instance variable of #1}%
+\defvarargs {#3}\endgroup %
}
-% This makes use of the obscure feature that if the last token of a
-% <parameter list> is #, then the preceding argument is delimited by
-% an opening brace, and that opening brace is not consumed.
-\def\getargs#1{\getargsxxx#1{}}
-\def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
-\def\getmacname #1 #2\relax{\macname={#1}}
-\def\getmacargs#1{\def\argl{#1}}
-
-% Parse the optional {params} list. Set up \paramno and \paramlist
-% so \defmacro knows what to do. Define \macarg.blah for each blah
-% in the params list, to be ##N where N is the position in that list.
-% That gets used by \mbodybackslash (above).
-
-% We need to get `macro parameter char #' into several definitions.
-% The technique used is stolen from LaTeX: let \hash be something
-% unexpandable, insert that wherever you need a #, and then redefine
-% it to # just before using the token list produced.
-%
-% The same technique is used to protect \eatspaces till just before
-% the macro is used.
-
-\def\parsemargdef#1;{\paramno=0\def\paramlist{}%
- \let\hash\relax\let\xeatspaces\relax\parsemargdefxxx#1,;,}
-\def\parsemargdefxxx#1,{%
- \if#1;\let\next=\relax
- \else \let\next=\parsemargdefxxx
- \advance\paramno by 1%
- \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
- {\xeatspaces{\hash\the\paramno}}%
- \edef\paramlist{\paramlist\hash\the\paramno,}%
- \fi\next}
-
-% These two commands read recursive and nonrecursive macro bodies.
-% (They're different since rec and nonrec macros end differently.)
-
-\long\def\parsemacbody#1@end macro%
-{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
-\long\def\parsermacbody#1@end rmacro%
-{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
-
-% This defines the macro itself. There are six cases: recursive and
-% nonrecursive macros of zero, one, and many arguments.
-% Much magic with \expandafter here.
-% \xdef is used so that macro definitions will survive the file
-% they're defined in; @include reads the file inside a group.
-\def\defmacro{%
- \let\hash=##% convert placeholders to macro parameter chars
- \ifrecursive
- \ifcase\paramno
- % 0
- \expandafter\xdef\csname\the\macname\endcsname{%
- \noexpand\scanmacro{\temp}}%
- \or % 1
- \expandafter\xdef\csname\the\macname\endcsname{%
- \bgroup\noexpand\macroargctxt
- \noexpand\braceorline
- \expandafter\noexpand\csname\the\macname xxx\endcsname}%
- \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
- \egroup\noexpand\scanmacro{\temp}}%
- \else % many
- \expandafter\xdef\csname\the\macname\endcsname{%
- \bgroup\noexpand\macroargctxt
- \noexpand\csname\the\macname xx\endcsname}%
- \expandafter\xdef\csname\the\macname xx\endcsname##1{%
- \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
- \expandafter\expandafter
- \expandafter\xdef
- \expandafter\expandafter
- \csname\the\macname xxx\endcsname
- \paramlist{\egroup\noexpand\scanmacro{\temp}}%
- \fi
- \else
- \ifcase\paramno
- % 0
- \expandafter\xdef\csname\the\macname\endcsname{%
- \noexpand\norecurse{\the\macname}%
- \noexpand\scanmacro{\temp}\egroup}%
- \or % 1
- \expandafter\xdef\csname\the\macname\endcsname{%
- \bgroup\noexpand\macroargctxt
- \noexpand\braceorline
- \expandafter\noexpand\csname\the\macname xxx\endcsname}%
- \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
- \egroup
- \noexpand\norecurse{\the\macname}%
- \noexpand\scanmacro{\temp}\egroup}%
- \else % many
- \expandafter\xdef\csname\the\macname\endcsname{%
- \bgroup\noexpand\macroargctxt
- \expandafter\noexpand\csname\the\macname xx\endcsname}%
- \expandafter\xdef\csname\the\macname xx\endcsname##1{%
- \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
- \expandafter\expandafter
- \expandafter\xdef
- \expandafter\expandafter
- \csname\the\macname xxx\endcsname
- \paramlist{%
- \egroup
- \noexpand\norecurse{\the\macname}%
- \noexpand\scanmacro{\temp}\egroup}%
- \fi
- \fi}
-
-\def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
-
-% \braceorline decides whether the next nonwhitespace character is a
-% {. If so it reads up to the closing }, if not, it reads the whole
-% line. Whatever was read is then fed to the next control sequence
-% as an argument (by \parsebrace or \parsearg)
-\def\braceorline#1{\let\next=#1\futurelet\nchar\braceorlinexxx}
-\def\braceorlinexxx{%
- \ifx\nchar\bgroup\else
- \expandafter\parsearg
- \fi \next}
-
-
-% @alias.
-% We need some trickery to remove the optional spaces around the equal
-% sign. Just make them active and then expand them all to nothing.
-\def\alias{\parseargusing\obeyspaces\aliasxxx}
-\def\aliasxxx #1{\aliasyyy#1\relax}
-\def\aliasyyy #1=#2\relax{%
- {%
- \expandafter\let\obeyedspace=\empty
- \addtomacrolist{#1}%
- \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}%
- }%
- \next
-}
+% These definitions are run if you use @defmethodx, etc.,
+% anywhere other than immediately after a @defmethod, etc.
+\def\defopx #1 {\errmessage{@defopx in invalid context}}
+\def\defmethodx #1 {\errmessage{@defmethodx in invalid context}}
+\def\defcvx #1 {\errmessage{@defcvx in invalid context}}
+\def\defivarx #1 {\errmessage{@defivarx in invalid context}}
-\message{cross references,}
+% Now @defvar
-\newwrite\auxfile
+% First, define the processing that is wanted for arguments of @defvar.
+% This is actually simple: just print them in roman.
+% This must expand the args and terminate the paragraph they make up
+\def\defvarargs #1{\normalparens #1%
+\interlinepenalty=10000
+\endgraf\vskip -\parskip \penalty 10000}
-\newif\ifhavexrefs % True if xref values are known.
-\newif\ifwarnedxrefs % True if we warned once that they aren't known.
+% @defvr Counter foo-count
-% @inforef is relatively simple.
-\def\inforef #1{\inforefzzz #1,,,,**}
-\def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
- node \samp{\ignorespaces#1{}}}
-
-% @node's only job in TeX is to define \lastnode, which is used in
-% cross-references. The @node line might or might not have commas, and
-% might or might not have spaces before the first comma, like:
-% @node foo , bar , ...
-% We don't want such trailing spaces in the node name.
-%
-\parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse}
-%
-% also remove a trailing comma, in case of something like this:
-% @node Help-Cross, , , Cross-refs
-\def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse}
-\def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}}
+\def\defvr{\defmethparsebody\Edefvr\defvrx\defvrheader}
-\let\nwnode=\node
-\let\lastnode=\empty
+\def\defvrheader #1#2#3{\doind {vr}{\code{#2}}%
+\begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup}
-% Write a cross-reference definition for the current node. #1 is the
-% type (Ynumbered, Yappendix, Ynothing).
-%
-\def\donoderef#1{%
- \ifx\lastnode\empty\else
- \setref{\lastnode}{#1}%
- \global\let\lastnode=\empty
- \fi
-}
+% @defvar == @defvr Variable
-% @anchor{NAME} -- define xref target at arbitrary point.
-%
-\newcount\savesfregister
-%
-\def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
-\def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
-\def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
-
-% \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
-% anchor), which consists of three parts:
-% 1) NAME-title - the current sectioning name taken from \thissection,
-% or the anchor name.
-% 2) NAME-snt - section number and type, passed as the SNT arg, or
-% empty for anchors.
-% 3) NAME-pg - the page number.
-%
-% This is called from \donoderef, \anchor, and \dofloat. In the case of
-% floats, there is an additional part, which is not written here:
-% 4) NAME-lof - the text as it should appear in a @listoffloats.
-%
-\def\setref#1#2{%
- \pdfmkdest{#1}%
- \iflinks
- {%
- \atdummies % preserve commands, but don't expand them
- \edef\writexrdef##1##2{%
- \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
- ##1}{##2}}% these are parameters of \writexrdef
- }%
- \toks0 = \expandafter{\thissection}%
- \immediate \writexrdef{title}{\the\toks0 }%
- \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
- \writexrdef{pg}{\folio}% will be written later, during \shipout
- }%
- \fi
-}
-
-% @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is
-% the node name, #2 the name of the Info cross-reference, #3 the printed
-% node name, #4 the name of the Info file, #5 the name of the printed
-% manual. All but the node name can be omitted.
-%
-\def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]}
-\def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]}
-\def\ref#1{\xrefX[#1,,,,,,,]}
-\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
- \unsepspaces
- \def\printedmanual{\ignorespaces #5}%
- \def\printedrefname{\ignorespaces #3}%
- \setbox1=\hbox{\printedmanual\unskip}%
- \setbox0=\hbox{\printedrefname\unskip}%
- \ifdim \wd0 = 0pt
- % No printed node name was explicitly given.
- \expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax
- % Use the node name inside the square brackets.
- \def\printedrefname{\ignorespaces #1}%
- \else
- % Use the actual chapter/section title appear inside
- % the square brackets. Use the real section title if we have it.
- \ifdim \wd1 > 0pt
- % It is in another manual, so we don't have it.
- \def\printedrefname{\ignorespaces #1}%
- \else
- \ifhavexrefs
- % We know the real title if we have the xref values.
- \def\printedrefname{\refx{#1-title}{}}%
- \else
- % Otherwise just copy the Info node name.
- \def\printedrefname{\ignorespaces #1}%
- \fi%
- \fi
- \fi
- \fi
- %
- % Make link in pdf output.
- \ifpdf
- \leavevmode
- \getfilename{#4}%
- {\turnoffactive
- % See comments at \activebackslashdouble.
- {\activebackslashdouble \xdef\pdfxrefdest{#1}%
- \backslashparens\pdfxrefdest}%
- %
- \ifnum\filenamelength>0
- \startlink attr{/Border [0 0 0]}%
- goto file{\the\filename.pdf} name{\pdfxrefdest}%
- \else
- \startlink attr{/Border [0 0 0]}%
- goto name{\pdfmkpgn{\pdfxrefdest}}%
- \fi
- }%
- \linkcolor
- \fi
- %
- % Float references are printed completely differently: "Figure 1.2"
- % instead of "[somenode], p.3". We distinguish them by the
- % LABEL-title being set to a magic string.
- {%
- % Have to otherify everything special to allow the \csname to
- % include an _ in the xref name, etc.
- \indexnofonts
- \turnoffactive
- \expandafter\global\expandafter\let\expandafter\Xthisreftitle
- \csname XR#1-title\endcsname
- }%
- \iffloat\Xthisreftitle
- % If the user specified the print name (third arg) to the ref,
- % print it instead of our usual "Figure 1.2".
- \ifdim\wd0 = 0pt
- \refx{#1-snt}{}%
- \else
- \printedrefname
- \fi
- %
- % if the user also gave the printed manual name (fifth arg), append
- % "in MANUALNAME".
- \ifdim \wd1 > 0pt
- \space \putwordin{} \cite{\printedmanual}%
- \fi
- \else
- % node/anchor (non-float) references.
- %
- % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not
- % insert empty discretionaries after hyphens, which means that it will
- % not find a line break at a hyphen in a node names. Since some manuals
- % are best written with fairly long node names, containing hyphens, this
- % is a loss. Therefore, we give the text of the node name again, so it
- % is as if TeX is seeing it for the first time.
- \ifdim \wd1 > 0pt
- \putwordsection{} ``\printedrefname'' \putwordin{} \cite{\printedmanual}%
- \else
- % _ (for example) has to be the character _ for the purposes of the
- % control sequence corresponding to the node, but it has to expand
- % into the usual \leavevmode...\vrule stuff for purposes of
- % printing. So we \turnoffactive for the \refx-snt, back on for the
- % printing, back off for the \refx-pg.
- {\turnoffactive
- % Only output a following space if the -snt ref is nonempty; for
- % @unnumbered and @anchor, it won't be.
- \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
- \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
- }%
- % output the `[mynode]' via a macro so it can be overridden.
- \xrefprintnodename\printedrefname
- %
- % But we always want a comma and a space:
- ,\space
- %
- % output the `page 3'.
- \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
- \fi
- \fi
- \endlink
-\endgroup}
-
-% This macro is called from \xrefX for the `[nodename]' part of xref
-% output. It's a separate macro only so it can be changed more easily,
-% since square brackets don't work well in some documents. Particularly
-% one that Bob is working on :).
-%
-\def\xrefprintnodename#1{[#1]}
-
-% Things referred to by \setref.
-%
-\def\Ynothing{}
-\def\Yomitfromtoc{}
-\def\Ynumbered{%
- \ifnum\secno=0
- \putwordChapter@tie \the\chapno
- \else \ifnum\subsecno=0
- \putwordSection@tie \the\chapno.\the\secno
- \else \ifnum\subsubsecno=0
- \putwordSection@tie \the\chapno.\the\secno.\the\subsecno
- \else
- \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno
- \fi\fi\fi
-}
-\def\Yappendix{%
- \ifnum\secno=0
- \putwordAppendix@tie @char\the\appendixno{}%
- \else \ifnum\subsecno=0
- \putwordSection@tie @char\the\appendixno.\the\secno
- \else \ifnum\subsubsecno=0
- \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno
- \else
- \putwordSection@tie
- @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
- \fi\fi\fi
-}
+\def\defvar{\defparsebody\Edefvar\defvarx\defvarheader}
-% Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
-% If its value is nonempty, SUFFIX is output afterward.
-%
-\def\refx#1#2{%
- {%
- \indexnofonts
- \otherbackslash
- \expandafter\global\expandafter\let\expandafter\thisrefX
- \csname XR#1\endcsname
- }%
- \ifx\thisrefX\relax
- % If not defined, say something at least.
- \angleleft un\-de\-fined\angleright
- \iflinks
- \ifhavexrefs
- \message{\linenumber Undefined cross reference `#1'.}%
- \else
- \ifwarnedxrefs\else
- \global\warnedxrefstrue
- \message{Cross reference values unknown; you must run TeX again.}%
- \fi
- \fi
- \fi
- \else
- % It's defined, so just use it.
- \thisrefX
- \fi
- #2% Output the suffix in any case.
+\def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
+\begingroup\defname {#1}{Variable}%
+\defvarargs {#2}\endgroup %
}
-% This is the macro invoked by entries in the aux file. Usually it's
-% just a \def (we prepend XR to the control sequence name to avoid
-% collisions). But if this is a float type, we have more work to do.
-%
-\def\xrdef#1#2{%
- \expandafter\gdef\csname XR#1\endcsname{#2}% remember this xref value.
- %
- % Was that xref control sequence that we just defined for a float?
- \expandafter\iffloat\csname XR#1\endcsname
- % it was a float, and we have the (safe) float type in \iffloattype.
- \expandafter\let\expandafter\floatlist
- \csname floatlist\iffloattype\endcsname
- %
- % Is this the first time we've seen this float type?
- \expandafter\ifx\floatlist\relax
- \toks0 = {\do}% yes, so just \do
- \else
- % had it before, so preserve previous elements in list.
- \toks0 = \expandafter{\floatlist\do}%
- \fi
- %
- % Remember this xref in the control sequence \floatlistFLOATTYPE,
- % for later use in \listoffloats.
- \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0{#1}}%
- \fi
-}
+% @defopt == @defvr {User Option}
-% Read the last existing aux file, if any. No error if none exists.
-%
-\def\tryauxfile{%
- \openin 1 \jobname.aux
- \ifeof 1 \else
- \readdatafile{aux}%
- \global\havexrefstrue
- \fi
- \closein 1
-}
+\def\defopt{\defparsebody\Edefopt\defoptx\defoptheader}
-\def\setupdatafile{%
- \catcode`\^^@=\other
- \catcode`\^^A=\other
- \catcode`\^^B=\other
- \catcode`\^^C=\other
- \catcode`\^^D=\other
- \catcode`\^^E=\other
- \catcode`\^^F=\other
- \catcode`\^^G=\other
- \catcode`\^^H=\other
- \catcode`\^^K=\other
- \catcode`\^^L=\other
- \catcode`\^^N=\other
- \catcode`\^^P=\other
- \catcode`\^^Q=\other
- \catcode`\^^R=\other
- \catcode`\^^S=\other
- \catcode`\^^T=\other
- \catcode`\^^U=\other
- \catcode`\^^V=\other
- \catcode`\^^W=\other
- \catcode`\^^X=\other
- \catcode`\^^Z=\other
- \catcode`\^^[=\other
- \catcode`\^^\=\other
- \catcode`\^^]=\other
- \catcode`\^^^=\other
- \catcode`\^^_=\other
- % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc.
- % in xref tags, i.e., node names. But since ^^e4 notation isn't
- % supported in the main text, it doesn't seem desirable. Furthermore,
- % that is not enough: for node names that actually contain a ^
- % character, we would end up writing a line like this: 'xrdef {'hat
- % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first
- % argument, and \hat is not an expandable control sequence. It could
- % all be worked out, but why? Either we support ^^ or we don't.
- %
- % The other change necessary for this was to define \auxhat:
- % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
- % and then to call \auxhat in \setq.
- %
- \catcode`\^=\other
- %
- % Special characters. Should be turned off anyway, but...
- \catcode`\~=\other
- \catcode`\[=\other
- \catcode`\]=\other
- \catcode`\"=\other
- \catcode`\_=\other
- \catcode`\|=\other
- \catcode`\<=\other
- \catcode`\>=\other
- \catcode`\$=\other
- \catcode`\#=\other
- \catcode`\&=\other
- \catcode`\%=\other
- \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
- %
- % This is to support \ in node names and titles, since the \
- % characters end up in a \csname. It's easier than
- % leaving it active and making its active definition an actual \
- % character. What I don't understand is why it works in the *value*
- % of the xrdef. Seems like it should be a catcode12 \, and that
- % should not typeset properly. But it works, so I'm moving on for
- % now. --karl, 15jan04.
- \catcode`\\=\other
- %
- % Make the characters 128-255 be printing characters.
- {%
- \count1=128
- \def\loop{%
- \catcode\count1=\other
- \advance\count1 by 1
- \ifnum \count1<256 \loop \fi
- }%
- }%
- %
- % @ is our escape character in .aux files, and we need braces.
- \catcode`\{=1
- \catcode`\}=2
- \catcode`\@=0
+\def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
+\begingroup\defname {#1}{User Option}%
+\defvarargs {#2}\endgroup %
}
-\def\readdatafile#1{%
-\begingroup
- \setupdatafile
- \input\jobname.#1
-\endgroup}
-
-\message{insertions,}
-% including footnotes.
-
-\newcount \footnoteno
-
-% The trailing space in the following definition for supereject is
-% vital for proper filling; pages come out unaligned when you do a
-% pagealignmacro call if that space before the closing brace is
-% removed. (Generally, numeric constants should always be followed by a
-% space to prevent strange expansion errors.)
-\def\supereject{\par\penalty -20000\footnoteno =0 }
+% This definition is run if you use @defvarx
+% anywhere other than immediately after a @defvar or @defvarx.
-% @footnotestyle is meaningful for info output only.
-\let\footnotestyle=\comment
+\def\defvrx #1 {\errmessage{@defvrx in invalid context}}
+\def\defvarx #1 {\errmessage{@defvarx in invalid context}}
+\def\defoptx #1 {\errmessage{@defoptx in invalid context}}
-{\catcode `\@=11
-%
-% Auto-number footnotes. Otherwise like plain.
-\gdef\footnote{%
- \let\indent=\ptexindent
- \let\noindent=\ptexnoindent
- \global\advance\footnoteno by \@ne
- \edef\thisfootno{$^{\the\footnoteno}$}%
- %
- % In case the footnote comes at the end of a sentence, preserve the
- % extra spacing after we do the footnote number.
- \let\@sf\empty
- \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi
- %
- % Remove inadvertent blank space before typesetting the footnote number.
- \unskip
- \thisfootno\@sf
- \dofootnote
-}%
+% Now define @deftp
+% Args are printed in bold, a slight difference from @defvar.
-% Don't bother with the trickery in plain.tex to not require the
-% footnote text as a parameter. Our footnotes don't need to be so general.
-%
-% Oh yes, they do; otherwise, @ifset (and anything else that uses
-% \parseargline) fails inside footnotes because the tokens are fixed when
-% the footnote is read. --karl, 16nov96.
-%
-\gdef\dofootnote{%
- \insert\footins\bgroup
- % We want to typeset this text as a normal paragraph, even if the
- % footnote reference occurs in (for example) a display environment.
- % So reset some parameters.
- \hsize=\pagewidth
- \interlinepenalty\interfootnotelinepenalty
- \splittopskip\ht\strutbox % top baseline for broken footnotes
- \splitmaxdepth\dp\strutbox
- \floatingpenalty\@MM
- \leftskip\z@skip
- \rightskip\z@skip
- \spaceskip\z@skip
- \xspaceskip\z@skip
- \parindent\defaultparindent
- %
- \smallfonts \rm
- %
- % Because we use hanging indentation in footnotes, a @noindent appears
- % to exdent this text, so make it be a no-op. makeinfo does not use
- % hanging indentation so @noindent can still be needed within footnote
- % text after an @example or the like (not that this is good style).
- \let\noindent = \relax
- %
- % Hang the footnote text off the number. Use \everypar in case the
- % footnote extends for more than one paragraph.
- \everypar = {\hang}%
- \textindent{\thisfootno}%
- %
- % Don't crash into the line above the footnote text. Since this
- % expands into a box, it must come within the paragraph, lest it
- % provide a place where TeX can split the footnote.
- \footstrut
- \futurelet\next\fo@t
-}
-}%end \catcode `\@=11
+\def\deftpargs #1{\bf \defvarargs{#1}}
-% In case a @footnote appears in a vbox, save the footnote text and create
-% the real \insert just after the vbox finished. Otherwise, the insertion
-% would be lost.
-% Similarily, if a @footnote appears inside an alignment, save the footnote
-% text to a box and make the \insert when a row of the table is finished.
-% And the same can be done for other insert classes. --kasal, 16nov03.
+% @deftp Class window height width ...
-% Replace the \insert primitive by a cheating macro.
-% Deeper inside, just make sure that the saved insertions are not spilled
-% out prematurely.
-%
-\def\startsavinginserts{%
- \ifx \insert\ptexinsert
- \let\insert\saveinsert
- \else
- \let\checkinserts\relax
- \fi
-}
+\def\deftp{\defmethparsebody\Edeftp\deftpx\deftpheader}
-% This \insert replacement works for both \insert\footins{foo} and
-% \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}.
-%
-\def\saveinsert#1{%
- \edef\next{\noexpand\savetobox \makeSAVEname#1}%
- \afterassignment\next
- % swallow the left brace
- \let\temp =
-}
-\def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}}
-\def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1}
+\def\deftpheader #1#2#3{\doind {tp}{\code{#2}}%
+\begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup}
-\def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi}
+% This definition is run if you use @deftpx, etc
+% anywhere other than immediately after a @deftp, etc.
-\def\placesaveins#1{%
- \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname
- {\box#1}%
-}
+\def\deftpx #1 {\errmessage{@deftpx in invalid context}}
-% eat @SAVE -- beware, all of them have catcode \other:
-{
- \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials % ;-)
- \gdef\gobblesave @SAVE{}
-}
+\message{cross reference,}
+% Define cross-reference macros
+\newwrite \auxfile
-% initialization:
-\def\newsaveins #1{%
- \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}%
- \next
-}
-\def\newsaveinsX #1{%
- \csname newbox\endcsname #1%
- \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts
- \checksaveins #1}%
-}
+% \setref{foo} defines a cross-reference point named foo.
-% initialize:
-\let\checkinserts\empty
-\newsaveins\footins
-\newsaveins\margin
+\def\setref#1{%
+\dosetq{#1-pg}{Ypagenumber}%
+\dosetq{#1-snt}{Ysectionnumberandtype}}
+\def\unnumbsetref#1{%
+\dosetq{#1-pg}{Ypagenumber}%
+\dosetq{#1-snt}{Ynothing}}
-% @image. We use the macros from epsf.tex to support this.
-% If epsf.tex is not installed and @image is used, we complain.
-%
-% Check for and read epsf.tex up front. If we read it only at @image
-% time, we might be inside a group, and then its definitions would get
-% undone and the next image would fail.
-\openin 1 = epsf.tex
-\ifeof 1 \else
- % Do not bother showing banner with epsf.tex v2.7k (available in
- % doc/epsf.tex and on ctan).
- \def\epsfannounce{\toks0 = }%
- \input epsf.tex
-\fi
-\closein 1
-%
-% We will only complain once about lack of epsf.tex.
-\newif\ifwarnednoepsf
-\newhelp\noepsfhelp{epsf.tex must be installed for images to
- work. It is also included in the Texinfo distribution, or you can get
- it from ftp://tug.org/tex/epsf.tex.}
-%
-\def\image#1{%
- \ifx\epsfbox\undefined
- \ifwarnednoepsf \else
- \errhelp = \noepsfhelp
- \errmessage{epsf.tex not found, images will be ignored}%
- \global\warnednoepsftrue
- \fi
- \else
- \imagexxx #1,,,,,\finish
- \fi
-}
-%
-% Arguments to @image:
-% #1 is (mandatory) image filename; we tack on .eps extension.
-% #2 is (optional) width, #3 is (optional) height.
-% #4 is (ignored optional) html alt text.
-% #5 is (ignored optional) extension.
-% #6 is just the usual extra ignored arg for parsing this stuff.
-\newif\ifimagevmode
-\def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
- \catcode`\^^M = 5 % in case we're inside an example
- \normalturnoffactive % allow _ et al. in names
- % If the image is by itself, center it.
- \ifvmode
- \imagevmodetrue
- \nobreak\bigskip
- % Usually we'll have text after the image which will insert
- % \parskip glue, so insert it here too to equalize the space
- % above and below.
- \nobreak\vskip\parskip
- \nobreak
- \line\bgroup
- \fi
- %
- % Output the image.
- \ifpdf
- \dopdfimage{#1}{#2}{#3}%
- \else
- % \epsfbox itself resets \epsf?size at each figure.
- \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
- \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
- \epsfbox{#1.eps}%
- \fi
- %
- \ifimagevmode \egroup \bigbreak \fi % space after the image
-\endgroup}
-
-
-% @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables,
-% etc. We don't actually implement floating yet, we always include the
-% float "here". But it seemed the best name for the future.
-%
-\envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish}
+% \xref and \pxref generate cross references to specified points.
-% There may be a space before second and/or third parameter; delete it.
-\def\eatcommaspace#1, {#1,}
+\def\pxref #1{see \xrefX [#1,,,,,,,]}
+\def\xref #1{See \xrefX [#1,,,,,,,]}
+\def\xrefX [#1,#2,#3,#4,#5,#6]{%
+\setbox1=\hbox{\i{\losespace#5{}}}%
+\setbox0=\hbox{\losespace#3{}}%
+\ifdim \wd0 =0pt \setbox0=\hbox{\losespace#1{}}\fi%
+\ifdim \wd1 >0pt%
+section \unhbox0{} in \unhbox1%
+\else%
+\refx{#1-snt} [\unhbox0], page\tie \refx{#1-pg}%
+\fi }
-% #1 is the optional FLOATTYPE, the text label for this float, typically
-% "Figure", "Table", "Example", etc. Can't contain commas. If omitted,
-% this float will not be numbered and cannot be referred to.
-%
-% #2 is the optional xref label. Also must be present for the float to
-% be referable.
-%
-% #3 is the optional positioning argument; for now, it is ignored. It
-% will somehow specify the positions allowed to float to (here, top, bottom).
-%
-% We keep a separate counter for each FLOATTYPE, which we reset at each
-% chapter-level command.
-\let\resetallfloatnos=\empty
-%
-\def\dofloat#1,#2,#3,#4\finish{%
- \let\thiscaption=\empty
- \let\thisshortcaption=\empty
- %
- % don't lose footnotes inside @float.
- %
- % BEWARE: when the floats start float, we have to issue warning whenever an
- % insert appears inside a float which could possibly float. --kasal, 26may04
- %
- \startsavinginserts
- %
- % We can't be used inside a paragraph.
- \par
- %
- \vtop\bgroup
- \def\floattype{#1}%
- \def\floatlabel{#2}%
- \def\floatloc{#3}% we do nothing with this yet.
- %
- \ifx\floattype\empty
- \let\safefloattype=\empty
- \else
- {%
- % the floattype might have accents or other special characters,
- % but we need to use it in a control sequence name.
- \indexnofonts
- \turnoffactive
- \xdef\safefloattype{\floattype}%
- }%
- \fi
- %
- % If label is given but no type, we handle that as the empty type.
- \ifx\floatlabel\empty \else
- % We want each FLOATTYPE to be numbered separately (Figure 1,
- % Table 1, Figure 2, ...). (And if no label, no number.)
- %
- \expandafter\getfloatno\csname\safefloattype floatno\endcsname
- \global\advance\floatno by 1
- %
- {%
- % This magic value for \thissection is output by \setref as the
- % XREFLABEL-title value. \xrefX uses it to distinguish float
- % labels (which have a completely different output format) from
- % node and anchor labels. And \xrdef uses it to construct the
- % lists of floats.
- %
- \edef\thissection{\floatmagic=\safefloattype}%
- \setref{\floatlabel}{Yfloat}%
- }%
- \fi
- %
- % start with \parskip glue, I guess.
- \vskip\parskip
- %
- % Don't suppress indentation if a float happens to start a section.
- \restorefirstparagraphindent
-}
+% \dosetq is the interface for calls from other macros
-% we have these possibilities:
-% @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
-% @float Foo,lbl & no caption: Foo 1.1
-% @float Foo & @caption{Cap}: Foo: Cap
-% @float Foo & no caption: Foo
-% @float ,lbl & Caption{Cap}: 1.1: Cap
-% @float ,lbl & no caption: 1.1
-% @float & @caption{Cap}: Cap
-% @float & no caption:
-%
-\def\Efloat{%
- \let\floatident = \empty
- %
- % In all cases, if we have a float type, it comes first.
- \ifx\floattype\empty \else \def\floatident{\floattype}\fi
- %
- % If we have an xref label, the number comes next.
- \ifx\floatlabel\empty \else
- \ifx\floattype\empty \else % if also had float type, need tie first.
- \appendtomacro\floatident{\tie}%
- \fi
- % the number.
- \appendtomacro\floatident{\chaplevelprefix\the\floatno}%
- \fi
- %
- % Start the printed caption with what we've constructed in
- % \floatident, but keep it separate; we need \floatident again.
- \let\captionline = \floatident
- %
- \ifx\thiscaption\empty \else
- \ifx\floatident\empty \else
- \appendtomacro\captionline{: }% had ident, so need a colon between
- \fi
- %
- % caption text.
- \appendtomacro\captionline{\scanexp\thiscaption}%
- \fi
- %
- % If we have anything to print, print it, with space before.
- % Eventually this needs to become an \insert.
- \ifx\captionline\empty \else
- \vskip.5\parskip
- \captionline
- %
- % Space below caption.
- \vskip\parskip
- \fi
- %
- % If have an xref label, write the list of floats info. Do this
- % after the caption, to avoid chance of it being a breakpoint.
- \ifx\floatlabel\empty \else
- % Write the text that goes in the lof to the aux file as
- % \floatlabel-lof. Besides \floatident, we include the short
- % caption if specified, else the full caption if specified, else nothing.
- {%
- \atdummies
- %
- % since we read the caption text in the macro world, where ^^M
- % is turned into a normal character, we have to scan it back, so
- % we don't write the literal three characters "^^M" into the aux file.
- \scanexp{%
- \xdef\noexpand\gtemp{%
- \ifx\thisshortcaption\empty
- \thiscaption
- \else
- \thisshortcaption
- \fi
- }%
- }%
- \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
- \ifx\gtemp\empty \else : \gtemp \fi}}%
- }%
- \fi
- \egroup % end of \vtop
- %
- % place the captured inserts
- %
- % BEWARE: when the floats start floating, we have to issue warning
- % whenever an insert appears inside a float which could possibly
- % float. --kasal, 26may04
- %
- \checkinserts
-}
+\def\dosetq #1#2{{\let\folio=0%
+\edef\next{\write\auxfile{\internalsetq {#1}{#2}}}%
+\next}}
-% Append the tokens #2 to the definition of macro #1, not expanding either.
-%
-\def\appendtomacro#1#2{%
- \expandafter\def\expandafter#1\expandafter{#1#2}%
-}
+% \internalsetq {foo}{page} expands into CHARACTERS 'xrdef {foo}{...expansion of \Ypage...}
+% When the aux file is read, ' is the escape character
-% @caption, @shortcaption
-%
-\def\caption{\docaption\thiscaption}
-\def\shortcaption{\docaption\thisshortcaption}
-\def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption}
-\def\defcaption#1#2{\egroup \def#1{#2}}
-
-% The parameter is the control sequence identifying the counter we are
-% going to use. Create it if it doesn't exist and assign it to \floatno.
-\def\getfloatno#1{%
- \ifx#1\relax
- % Haven't seen this figure type before.
- \csname newcount\endcsname #1%
- %
- % Remember to reset this floatno at the next chap.
- \expandafter\gdef\expandafter\resetallfloatnos
- \expandafter{\resetallfloatnos #1=0 }%
- \fi
- \let\floatno#1%
-}
-
-% \setref calls this to get the XREFLABEL-snt value. We want an @xref
-% to the FLOATLABEL to expand to "Figure 3.1". We call \setref when we
-% first read the @float command.
-%
-\def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}%
+\def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}}
-% Magic string used for the XREFLABEL-title value, so \xrefX can
-% distinguish floats from other xref types.
-\def\floatmagic{!!float!!}
+% Things to be expanded by \internalsetq
-% #1 is the control sequence we are passed; we expand into a conditional
-% which is true if #1 represents a float ref. That is, the magic
-% \thissection value which we \setref above.
-%
-\def\iffloat#1{\expandafter\doiffloat#1==\finish}
-%
-% #1 is (maybe) the \floatmagic string. If so, #2 will be the
-% (safe) float type for this float. We set \iffloattype to #2.
-%
-\def\doiffloat#1=#2=#3\finish{%
- \def\temp{#1}%
- \def\iffloattype{#2}%
- \ifx\temp\floatmagic
-}
+\def\Ypagenumber{\folio}
-% @listoffloats FLOATTYPE - print a list of floats like a table of contents.
-%
-\parseargdef\listoffloats{%
- \def\floattype{#1}% floattype
- {%
- % the floattype might have accents or other special characters,
- % but we need to use it in a control sequence name.
- \indexnofonts
- \turnoffactive
- \xdef\safefloattype{\floattype}%
- }%
- %
- % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
- \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
- \ifhavexrefs
- % if the user said @listoffloats foo but never @float foo.
- \message{\linenumber No `\safefloattype' floats to list.}%
- \fi
- \else
- \begingroup
- \leftskip=\tocindent % indent these entries like a toc
- \let\do=\listoffloatsdo
- \csname floatlist\safefloattype\endcsname
- \endgroup
- \fi
-}
+\def\Ynothing{}
-% This is called on each entry in a list of floats. We're passed the
-% xref label, in the form LABEL-title, which is how we save it in the
-% aux file. We strip off the -title and look up \XRLABEL-lof, which
-% has the text we're supposed to typeset here.
-%
-% Figures without xref labels will not be included in the list (since
-% they won't appear in the aux file).
-%
-\def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
-\def\listoffloatsdoentry#1-title\finish{{%
- % Can't fully expand XR#1-lof because it can contain anything. Just
- % pass the control sequence. On the other hand, XR#1-pg is just the
- % page number, and we want to fully expand that so we can get a link
- % in pdf output.
- \toksA = \expandafter{\csname XR#1-lof\endcsname}%
- %
- % use the same \entry macro we use to generate the TOC and index.
- \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
- \writeentry
+\def\Ysectionnumberandtype{%
+\ifnum\secno=0 chapter\xreftie\the\chapno %
+\else \ifnum \subsecno=0 section\xreftie\the\chapno.\the\secno %
+\else \ifnum \subsubsecno=0 %
+section\xreftie\the\chapno.\the\secno.\the\subsecno %
+\else %
+section\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno %
+\fi \fi \fi }
+
+\gdef\xreftie{'tie}
+
+% Define @refx to reference a specific cross-reference string.
+
+\def\refx#1{%
+{%
+\expandafter\ifx\csname X#1\endcsname\relax
+% If not defined, say something at least.
+\expandafter\gdef\csname X#1\endcsname {$<$undefined$>$}%
+\message {WARNING: Cross-reference "#1" used but not yet defined}%
+\message {}%
+\fi %
+\csname X#1\endcsname %It's defined, so just use it.
}}
-\message{localization,}
-% and i18n.
-
-% @documentlanguage is usually given very early, just after
-% @setfilename. If done too late, it may not override everything
-% properly. Single argument is the language abbreviation.
-% It would be nice if we could set up a hyphenation file here.
-%
-\parseargdef\documentlanguage{%
- \tex % read txi-??.tex file in plain TeX.
- % Read the file if it exists.
- \openin 1 txi-#1.tex
- \ifeof 1
- \errhelp = \nolanghelp
- \errmessage{Cannot read language file txi-#1.tex}%
- \else
- \input txi-#1.tex
- \fi
- \closein 1
- \endgroup
-}
-\newhelp\nolanghelp{The given language definition file cannot be found or
-is empty. Maybe you need to install it? In the current directory
-should work if nowhere else does.}
-
-
-% @documentencoding should change something in TeX eventually, most
-% likely, but for now just recognize it.
-\let\documentencoding = \comment
-
-
-% Page size parameters.
-%
-\newdimen\defaultparindent \defaultparindent = 15pt
+% Read the last existing aux file, if any. No error if none exists.
-\chapheadingskip = 15pt plus 4pt minus 2pt
-\secheadingskip = 12pt plus 3pt minus 2pt
-\subsecheadingskip = 9pt plus 2pt minus 2pt
+% This is the macro invoked by entries in the aux file.
+\def\xrdef #1#2{
+{\catcode`\'=\other\expandafter \gdef \csname X#1\endcsname {#2}}}
-% Prevent underfull vbox error messages.
-\vbadness = 10000
+{
+\catcode `\^^@=\other
+\catcode `\=\other
+\catcode `\=\other
+\catcode `\^^C=\other
+\catcode `\^^D=\other
+\catcode `\^^E=\other
+\catcode `\^^F=\other
+\catcode `\^^G=\other
+\catcode `\^^H=\other
+\catcode `\ =\other
+\catcode `\^^L=\other
+\catcode `\=\other
+\catcode `\=\other
+\catcode `\=\other
+\catcode `\=\other
+\catcode `\=\other
+\catcode `\=\other
+\catcode `\=\other
+\catcode `\=\other
+\catcode `\=\other
+\catcode `\=\other
+\catcode `\=\other
+\catcode `\=\other
+\catcode `\=\other
+\catcode `\^^[=\other
+\catcode `\^^\=\other
+\catcode `\^^]=\other
+\catcode `\^^^=\other
+\catcode `\^^_=\other
+\catcode `\@=\other
+\catcode `\^=\other
+\catcode `\~=\other
+\catcode `\[=\other
+\catcode `\]=\other
+\catcode`\"=\other
+\catcode`\_=\other
+\catcode`\|=\other
+\catcode`\<=\other
+\catcode`\>=\other
+\catcode `\$=\other
+\catcode `\#=\other
+\catcode `\&=\other
-% Don't be so finicky about underfull hboxes, either.
-\hbadness = 2000
+% the aux file uses ' as the escape.
+% Turn off \ as an escape so we do not lose on
+% entries which were dumped with control sequences in their names.
+% For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^
+% Reference to such entries still does not work the way one would wish,
+% but at least they do not bomb out when the aux file is read in.
-% Following George Bush, just get rid of widows and orphans.
-\widowpenalty=10000
-\clubpenalty=10000
+\catcode `\{=1 \catcode `\}=2
+\catcode `\%=\other
+\catcode `\'=0
+\catcode `\\=\other
-% Use TeX 3.0's \emergencystretch to help line breaking, but if we're
-% using an old version of TeX, don't do anything. We want the amount of
-% stretch added to depend on the line length, hence the dependence on
-% \hsize. We call this whenever the paper size is set.
-%
-\def\setemergencystretch{%
- \ifx\emergencystretch\thisisundefined
- % Allow us to assign to \emergencystretch anyway.
- \def\emergencystretch{\dimen0}%
- \else
- \emergencystretch = .15\hsize
- \fi
+'openin 1 'jobname.aux
+'ifeof 1 'else 'closein 1 'input 'jobname.aux
+'fi
}
-% Parameters in order: 1) textheight; 2) textwidth;
-% 3) voffset; 4) hoffset; 5) binding offset; 6) topskip;
-% 7) physical page height; 8) physical page width.
-%
-% We also call \setleading{\textleading}, so the caller should define
-% \textleading. The caller should also set \parskip.
-%
-\def\internalpagesizes#1#2#3#4#5#6#7#8{%
- \voffset = #3\relax
- \topskip = #6\relax
- \splittopskip = \topskip
- %
- \vsize = #1\relax
- \advance\vsize by \topskip
- \outervsize = \vsize
- \advance\outervsize by 2\topandbottommargin
- \pageheight = \vsize
- %
- \hsize = #2\relax
- \outerhsize = \hsize
- \advance\outerhsize by 0.5in
- \pagewidth = \hsize
- %
- \normaloffset = #4\relax
- \bindingoffset = #5\relax
- %
- \ifpdf
- \pdfpageheight #7\relax
- \pdfpagewidth #8\relax
- \fi
- %
- \setleading{\textleading}
- %
- \parindent = \defaultparindent
- \setemergencystretch
-}
+% Open the new aux file. Tex will close it automatically at exit.
-% @letterpaper (the default).
-\def\letterpaper{{\globaldefs = 1
- \parskip = 3pt plus 2pt minus 1pt
- \textleading = 13.2pt
- %
- % If page is nothing but text, make it come out even.
- \internalpagesizes{46\baselineskip}{6in}%
- {\voffset}{.25in}%
- {\bindingoffset}{36pt}%
- {11in}{8.5in}%
-}}
+\openout \auxfile=\jobname.aux
-% Use @smallbook to reset parameters for 7x9.25 trim size.
-\def\smallbook{{\globaldefs = 1
- \parskip = 2pt plus 1pt
- \textleading = 12pt
- %
- \internalpagesizes{7.5in}{5in}%
- {\voffset}{.25in}%
- {\bindingoffset}{16pt}%
- {9.25in}{7in}%
- %
- \lispnarrowing = 0.3in
- \tolerance = 700
- \hfuzz = 1pt
- \contentsrightmargin = 0pt
- \defbodyindent = .5cm
-}}
+% Footnotes.
-% Use @smallerbook to reset parameters for 6x9 trim size.
-% (Just testing, parameters still in flux.)
-\def\smallerbook{{\globaldefs = 1
- \parskip = 1.5pt plus 1pt
- \textleading = 12pt
- %
- \internalpagesizes{7.4in}{4.8in}%
- {-.2in}{-.4in}%
- {0pt}{14pt}%
- {9in}{6in}%
- %
- \lispnarrowing = 0.25in
- \tolerance = 700
- \hfuzz = 1pt
- \contentsrightmargin = 0pt
- \defbodyindent = .4cm
-}}
+\newcount \footnoteno
-% Use @afourpaper to print on European A4 paper.
-\def\afourpaper{{\globaldefs = 1
- \parskip = 3pt plus 2pt minus 1pt
- \textleading = 13.2pt
- %
- % Double-side printing via postscript on Laserjet 4050
- % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm.
- % To change the settings for a different printer or situation, adjust
- % \normaloffset until the front-side and back-side texts align. Then
- % do the same for \bindingoffset. You can set these for testing in
- % your texinfo source file like this:
- % @tex
- % \global\normaloffset = -6mm
- % \global\bindingoffset = 10mm
- % @end tex
- \internalpagesizes{51\baselineskip}{160mm}
- {\voffset}{\hoffset}%
- {\bindingoffset}{44pt}%
- {297mm}{210mm}%
- %
- \tolerance = 700
- \hfuzz = 1pt
- \contentsrightmargin = 0pt
- \defbodyindent = 5mm
-}}
+\def\supereject{\par\penalty -20000\footnoteno =0 }
-% Use @afivepaper to print on European A5 paper.
-% From romildo@urano.iceb.ufop.br, 2 July 2000.
-% He also recommends making @example and @lisp be small.
-\def\afivepaper{{\globaldefs = 1
- \parskip = 2pt plus 1pt minus 0.1pt
- \textleading = 12.5pt
- %
- \internalpagesizes{160mm}{120mm}%
- {\voffset}{\hoffset}%
- {\bindingoffset}{8pt}%
- {210mm}{148mm}%
- %
- \lispnarrowing = 0.2in
- \tolerance = 800
- \hfuzz = 1.2pt
- \contentsrightmargin = 0pt
- \defbodyindent = 2mm
- \tableindent = 12mm
-}}
+\let\ptexfootnote=\footnote
-% A specific text layout, 24x15cm overall, intended for A4 paper.
-\def\afourlatex{{\globaldefs = 1
- \afourpaper
- \internalpagesizes{237mm}{150mm}%
- {\voffset}{4.6mm}%
- {\bindingoffset}{7mm}%
- {297mm}{210mm}%
- %
- % Must explicitly reset to 0 because we call \afourpaper.
- \globaldefs = 0
-}}
+{\catcode `\@=11
+\gdef\footnote{\global\advance \footnoteno by \@ne
+\edef\thisfootno{$^{\the\footnoteno}$}%
+\let\@sf\empty
+\ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi
+\thisfootno\@sf\parsearg\footnotezzz}
+
+\gdef\footnotezzz #1{\insert\footins{
+\interlinepenalty\interfootnotelinepenalty
+\splittopskip\ht\strutbox % top baseline for broken footnotes
+\splitmaxdepth\dp\strutbox \floatingpenalty\@MM
+\leftskip\z@skip \rightskip\z@skip \spaceskip\z@skip \xspaceskip\z@skip
+\footstrut\hang\textindent{\thisfootno}#1\strut}}
-% Use @afourwide to print on A4 paper in landscape format.
-\def\afourwide{{\globaldefs = 1
- \afourpaper
- \internalpagesizes{241mm}{165mm}%
- {\voffset}{-2.95mm}%
- {\bindingoffset}{7mm}%
- {297mm}{210mm}%
- \globaldefs = 0
-}}
+}%end \catcode `\@=11
-% @pagesizes TEXTHEIGHT[,TEXTWIDTH]
-% Perhaps we should allow setting the margins, \topskip, \parskip,
-% and/or leading, also. Or perhaps we should compute them somehow.
-%
-\parseargdef\pagesizes{\pagesizesyyy #1,,\finish}
-\def\pagesizesyyy#1,#2,#3\finish{{%
- \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
- \globaldefs = 1
- %
- \parskip = 3pt plus 2pt minus 1pt
- \setleading{\textleading}%
- %
- \dimen0 = #1
- \advance\dimen0 by \voffset
- %
- \dimen2 = \hsize
- \advance\dimen2 by \normaloffset
- %
- \internalpagesizes{#1}{\hsize}%
- {\voffset}{\normaloffset}%
- {\bindingoffset}{44pt}%
- {\dimen0}{\dimen2}%
-}}
+% End of control word definitions.
-% Set default to letter.
-%
-\letterpaper
+\message{and turning on texinfo input format.}
+\newindex{cp}
+\newcodeindex{fn}
+\newcodeindex{vr}
+\newcodeindex{tp}
+\newcodeindex{ky}
+\newcodeindex{pg}
-\message{and turning on texinfo input format.}
+% Set some numeric style parameters, for 8.5 x 11 format.
-% Define macros to output various characters with catcode for normal text.
-\catcode`\"=\other
-\catcode`\~=\other
-\catcode`\^=\other
-\catcode`\_=\other
-\catcode`\|=\other
-\catcode`\<=\other
-\catcode`\>=\other
-\catcode`\+=\other
-\catcode`\$=\other
-\def\normaldoublequote{"}
-\def\normaltilde{~}
-\def\normalcaret{^}
-\def\normalunderscore{_}
-\def\normalverticalbar{|}
-\def\normalless{<}
-\def\normalgreater{>}
-\def\normalplus{+}
-\def\normaldollar{$}%$ font-lock fix
-
-% This macro is used to make a character print one way in \tt
-% (where it can probably be output as-is), and another way in other fonts,
-% where something hairier probably needs to be done.
-%
-% #1 is what to print if we are indeed using \tt; #2 is what to print
-% otherwise. Since all the Computer Modern typewriter fonts have zero
-% interword stretch (and shrink), and it is reasonable to expect all
-% typewriter fonts to have this, we can check that font parameter.
-%
-\def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi}
+\hsize = 6.5in
+\parindent 15pt
+\parskip 18pt plus 1pt
+\baselineskip 15pt
+\advance\topskip by 1.2cm
-% Same as above, but check for italic font. Actually this also catches
-% non-italic slanted fonts since it is impossible to distinguish them from
-% italic fonts. But since this is only used by $ and it uses \sl anyway
-% this is not a problem.
-\def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
+% Prevent underfull vbox error messages.
+\vbadness=10000
+
+% Use @smallbook to reset parameters for 7x9.5 format
+\def\smallbook{
+\global\lispnarrowing = 0.3in
+\global\baselineskip 12pt
+\global\parskip 3pt plus 1pt
+\global\hsize = 5in
+\global\doublecolumnhsize=2.4in \global\doublecolumnvsize=15.0in
+\global\vsize=7.5in
+\global\tolerance=700
+\global\hfuzz=1pt
+
+\global\pagewidth=\hsize
+\global\pageheight=\vsize
+\global\font\ninett=cmtt9
+
+\global\let\smalllisp=\smalllispx
+\global\let\smallexample=\smalllispx
+\global\def\Esmallexample{\Esmalllisp}
+}
+
+%% For a final copy, take out the rectangles
+%% that mark overfull boxes (in case you have decided
+%% that the text looks ok even though it passes the margin).
+\def\finalout{\overfullrule=0pt}
% Turn off all special characters except @
-% (and those which the user can use as if they were ordinary).
-% Most of these we simply print from the \tt font, but for some, we can
-% use math or other variants that look better in normal text.
+% (and those which the user can use as if they were ordinary)
+% Define certain chars to be always in tt font.
\catcode`\"=\active
-\def\activedoublequote{{\tt\char34}}
+\def\activedoublequote{{\tt \char '042}}
\let"=\activedoublequote
\catcode`\~=\active
-\def~{{\tt\char126}}
+\def~{{\tt \char '176}}
\chardef\hat=`\^
\catcode`\^=\active
\def^{{\tt \hat}}
-
\catcode`\_=\active
-\def_{\ifusingtt\normalunderscore\_}
-\let\realunder=_
-% Subroutine for the previous macro.
-\def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
-
+\def_{{\tt \char '137}}
\catcode`\|=\active
-\def|{{\tt\char124}}
+\def|{{\tt \char '174}}
\chardef \less=`\<
\catcode`\<=\active
\def<{{\tt \less}}
\chardef \gtr=`\>
\catcode`\>=\active
\def>{{\tt \gtr}}
-\catcode`\+=\active
-\def+{{\tt \char 43}}
-\catcode`\$=\active
-\def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
-
-% If a .fmt file is being used, characters that might appear in a file
-% name cannot be active until we have parsed the command line.
-% So turn them off again, and have \everyjob (or @setfilename) turn them on.
-% \otherifyactive is called near the end of this file.
-\def\otherifyactive{\catcode`+=\other \catcode`\_=\other}
-
-% Used sometimes to turn off (effectively) the active characters even after
-% parsing them.
-\def\turnoffactive{%
- \normalturnoffactive
- \otherbackslash
-}
\catcode`\@=0
-% \backslashcurfont outputs one backslash character in current font,
-% as in \char`\\.
-\global\chardef\backslashcurfont=`\\
-\global\let\rawbackslashxx=\backslashcurfont % let existing .??s files work
+% \rawbackslashxx output one backslash character in current font
+{\catcode`\\=\other
+@gdef@rawbackslashxx{\}}
-% \realbackslash is an actual character `\' with catcode other, and
-% \doublebackslash is two of them (for the pdf outlines).
-{\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}}
+% \rawbackslash redefines \ as input to do \rawbackslashxx.
+{\catcode`\\=\active
+@gdef@rawbackslash{@let\=@rawbackslashxx }}
-% In texinfo, backslash is an active character; it prints the backslash
-% in fixed width font.
-\catcode`\\=\active
-@def@normalbackslash{{@tt@backslashcurfont}}
-% On startup, @fixbackslash assigns:
-% @let \ = @normalbackslash
-
-% \rawbackslash defines an active \ to do \backslashcurfont.
-% \otherbackslash defines an active \ to be a literal `\' character with
-% catcode other.
-@gdef@rawbackslash{@let\=@backslashcurfont}
-@gdef@otherbackslash{@let\=@realbackslash}
-
-% Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
-% the literal character `\'.
-%
-@def@normalturnoffactive{%
- @let\=@normalbackslash
- @let"=@normaldoublequote
- @let~=@normaltilde
- @let^=@normalcaret
- @let_=@normalunderscore
- @let|=@normalverticalbar
- @let<=@normalless
- @let>=@normalgreater
- @let+=@normalplus
- @let$=@normaldollar %$ font-lock fix
- @unsepspaces
-}
-
-% Make _ and + \other characters, temporarily.
-% This is canceled by @fixbackslash.
-@otherifyactive
-
-% If a .fmt file is being used, we don't want the `\input texinfo' to show up.
-% That is what \eatinput is for; after that, the `\' should revert to printing
-% a backslash.
-%
-@gdef@eatinput input texinfo{@fixbackslash}
-@global@let\ = @eatinput
-
-% On the other hand, perhaps the file did not have a `\input texinfo'. Then
-% the first `\' in the file would cause an error. This macro tries to fix
-% that, assuming it is called before the first `\' could plausibly occur.
-% Also turn back on active characters that might appear in the input
-% file name, in case not using a pre-dumped format.
-%
-@gdef@fixbackslash{%
- @ifx\@eatinput @let\ = @normalbackslash @fi
- @catcode`+=@active
- @catcode`@_=@active
-}
+% \normalbackslash outputs one backslash in fixed width font.
+\def\normalbackslash{{\tt\rawbackslashxx}}
% Say @foo, not \foo, in error messages.
-@escapechar = `@@
+\escapechar=`\@
-% These look ok in all fonts, so just make them not special.
-@catcode`@& = @other
-@catcode`@# = @other
-@catcode`@% = @other
+%% These look ok in all fonts, so just make them not special. The @rm below
+%% makes sure that the current font starts out as the newly loaded cmr10
+\catcode`\$=\other \catcode`\%=\other \catcode`\&=\other \catcode`\#=\other
+\catcode 17=0 @c Define control-q
+\catcode`\\=\active
+@let\=@normalbackslash
-@c Local variables:
-@c eval: (add-hook 'write-file-hooks 'time-stamp)
-@c page-delimiter: "^\\\\message"
-@c time-stamp-start: "def\\\\texinfoversion{"
-@c time-stamp-format: "%:y-%02m-%02d.%02H"
-@c time-stamp-end: "}"
-@c End:
-
-@c vim:sw=2:
-
-@ignore
- arch-tag: e1b36e32-c96e-4135-a41a-0b2efa2ea115
-@end ignore
+@textfonts
+@rm
diff --git a/lib/ext2fs/Android.mk b/lib/ext2fs/Android.mk
index 5cf6eb03..c34efd37 100644
--- a/lib/ext2fs/Android.mk
+++ b/lib/ext2fs/Android.mk
@@ -10,9 +10,6 @@ libext2fs_src_files := \
bb_inode.c \
bitmaps.c \
bitops.c \
- blkmap64_ba.c \
- blkmap64_rb.c \
- blknum.c \
block.c \
bmap.c \
check_desc.c \
@@ -28,12 +25,10 @@ libext2fs_src_files := \
expanddir.c \
ext_attr.c \
extent.c \
- fileio.c \
finddev.c \
flushb.c \
freefs.c \
gen_bitmap.c \
- gen_bitmap64.c \
get_pathname.c \
getsize.c \
getsectsize.c \
@@ -48,15 +43,11 @@ libext2fs_src_files := \
link.c \
llseek.c \
lookup.c \
- mmp.c \
mkdir.c \
mkjournal.c \
native.c \
newdir.c \
openfs.c \
- progress.c \
- punch.c \
- rbtree.c \
read_bb.c \
read_bb_file.c \
res_gdt.c \
diff --git a/lib/ext2fs/MODULE_LICENSE_LGPL b/lib/ext2fs/MODULE_LICENSE_LGPL
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/lib/ext2fs/MODULE_LICENSE_LGPL
diff --git a/lib/ext2fs/Makefile.in b/lib/ext2fs/Makefile.in
index 87678c6a..26b7ed9e 100644
--- a/lib/ext2fs/Makefile.in
+++ b/lib/ext2fs/Makefile.in
@@ -26,15 +26,11 @@ OBJS= $(DEBUGFS_LIB_OBJS) $(RESIZE_LIB_OBJS) $(E2IMAGE_LIB_OBJS) \
bb_inode.o \
bitmaps.o \
bitops.o \
- blkmap64_ba.o \
- blkmap64_rb.o \
- blknum.o \
block.o \
bmap.o \
check_desc.o \
closefs.o \
crc16.o \
- crc32c.o \
csum.o \
dblist.o \
dblist_dir.o \
@@ -49,7 +45,6 @@ OBJS= $(DEBUGFS_LIB_OBJS) $(RESIZE_LIB_OBJS) $(E2IMAGE_LIB_OBJS) \
flushb.o \
freefs.o \
gen_bitmap.o \
- gen_bitmap64.o \
get_pathname.o \
getsize.o \
getsectsize.o \
@@ -66,27 +61,21 @@ OBJS= $(DEBUGFS_LIB_OBJS) $(RESIZE_LIB_OBJS) $(E2IMAGE_LIB_OBJS) \
lookup.o \
mkdir.o \
mkjournal.o \
- mmp.o \
namei.o \
native.o \
newdir.o \
openfs.o \
- progress.o \
- punch.o \
- qcow2.o \
read_bb.o \
read_bb_file.o \
res_gdt.o \
rw_bitmaps.o \
swapfs.o \
- symlink.o \
tdb.o \
undo_io.o \
unix_io.o \
unlink.o \
valid_blk.o \
- version.o \
- rbtree.o
+ version.o
SRCS= ext2_err.c \
$(srcdir)/alloc.c \
@@ -98,15 +87,11 @@ SRCS= ext2_err.c \
$(srcdir)/bb_inode.c \
$(srcdir)/bitmaps.c \
$(srcdir)/bitops.c \
- $(srcdir)/blkmap64_ba.c \
- $(srcdir)/blkmap64_rb.c \
$(srcdir)/block.c \
$(srcdir)/bmap.c \
$(srcdir)/check_desc.c \
$(srcdir)/closefs.c \
$(srcdir)/crc16.c \
- $(srcdir)/crc32c.c \
- $(srcdir)/gen_crc32ctable.c \
$(srcdir)/csum.c \
$(srcdir)/dblist.c \
$(srcdir)/dblist_dir.c \
@@ -122,7 +107,6 @@ SRCS= ext2_err.c \
$(srcdir)/flushb.c \
$(srcdir)/freefs.c \
$(srcdir)/gen_bitmap.c \
- $(srcdir)/gen_bitmap64.c \
$(srcdir)/get_pathname.c \
$(srcdir)/getsize.c \
$(srcdir)/getsectsize.c \
@@ -141,20 +125,15 @@ SRCS= ext2_err.c \
$(srcdir)/lookup.c \
$(srcdir)/mkdir.c \
$(srcdir)/mkjournal.c \
- $(srcdir)/mmp.c \
$(srcdir)/namei.c \
$(srcdir)/native.c \
$(srcdir)/newdir.c \
$(srcdir)/openfs.c \
- $(srcdir)/progress.c \
- $(srcdir)/punch.c \
- $(srcdir)/qcow2.c \
$(srcdir)/read_bb.c \
$(srcdir)/read_bb_file.c \
$(srcdir)/res_gdt.c \
$(srcdir)/rw_bitmaps.c \
$(srcdir)/swapfs.c \
- $(srcdir)/symlink.c \
$(srcdir)/tdb.c \
$(srcdir)/test_io.c \
$(srcdir)/tst_badblocks.c \
@@ -167,11 +146,10 @@ SRCS= ext2_err.c \
$(srcdir)/unlink.c \
$(srcdir)/valid_blk.c \
$(srcdir)/version.c \
- $(srcdir)/write_bb_file.c \
- $(srcdir)/rbtree.c \
+ $(srcdir)/write_bb_file.c
HFILES= bitops.h ext2fs.h ext2_io.h ext2_fs.h ext2_ext_attr.h ext3_extents.h \
- tdb.h qcow2.h
+ tdb.h
HFILES_IN= ext2_err.h ext2_types.h
LIBRARY= libext2fs
@@ -182,7 +160,7 @@ ELF_SO_VERSION = 2
ELF_IMAGE = libext2fs
ELF_MYDIR = ext2fs
ELF_INSTALL_DIR = $(root_libdir)
-ELF_OTHER_LIBS = -lcom_err
+ELF_OTHER_LIBS = -L../.. -lcom_err
BSDLIB_VERSION = 2.1
BSDLIB_IMAGE = libext2fs
@@ -200,7 +178,6 @@ all:: ext2fs.pc
.c.o:
$(E) " CC $<"
$(Q) $(CC) $(ALL_CFLAGS) -c $< -o $@
- $(Q) $(CHECK_CMD) $(ALL_CFLAGS) $<
@PROFILE_CMT@ $(Q) $(CC) $(ALL_CFLAGS) -g -pg -o profiled/$*.o -c $<
@CHECKER_CMT@ $(Q) $(CC) $(ALL_CFLAGS) -checker -g -o checker/$*.o -c $<
@ELF_CMT@ $(Q) $(CC) $(ALL_CFLAGS) -fPIC -o elfshared/$*.o -c $<
@@ -222,47 +199,45 @@ ext2fs.pc: $(srcdir)/ext2fs.pc.in $(top_builddir)/config.status
$(E) " CONFIG.STATUS $@"
$(Q) cd $(top_builddir); CONFIG_FILES=lib/ext2fs/ext2fs.pc ./config.status
-tst_badblocks: tst_badblocks.o $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR)
+tst_badblocks: tst_badblocks.o $(STATIC_LIBEXT2FS) $(DEPLIBCOM_ERR)
$(E) " LD $@"
$(Q) $(CC) -o tst_badblocks tst_badblocks.o $(STATIC_LIBEXT2FS) \
- $(STATIC_LIBCOM_ERR)
+ $(LIBCOM_ERR)
-tst_icount: $(srcdir)/icount.c $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR)
+tst_icount: $(srcdir)/icount.c $(STATIC_LIBEXT2FS) $(DEPLIBCOM_ERR)
$(E) " LD $@"
$(Q) $(CC) -o tst_icount $(srcdir)/icount.c -DDEBUG $(ALL_CFLAGS) \
- $(STATIC_LIBEXT2FS) $(STATIC_LIBCOM_ERR)
+ $(STATIC_LIBEXT2FS) $(LIBCOM_ERR)
-tst_iscan: tst_iscan.o $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR)
+tst_iscan: tst_iscan.o $(STATIC_LIBEXT2FS) $(DEPLIBCOM_ERR)
$(E) " LD $@"
- $(Q) $(CC) -o tst_iscan tst_iscan.o $(STATIC_LIBEXT2FS) \
- $(STATIC_LIBCOM_ERR)
+ $(Q) $(CC) -o tst_iscan tst_iscan.o $(STATIC_LIBEXT2FS) $(LIBCOM_ERR)
-tst_getsize: tst_getsize.o $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR)
+tst_getsize: tst_getsize.o $(STATIC_LIBEXT2FS) $(DEPLIBCOM_ERR)
$(E) " LD $@"
$(Q) $(CC) -o tst_getsize tst_getsize.o $(STATIC_LIBEXT2FS) \
- $(STATIC_LIBCOM_ERR)
+ $(LIBCOM_ERR)
-tst_ismounted: $(srcdir)/ismounted.c $(STATIC_LIBEXT2FS) \
- $(DEPSTATIC_LIBCOM_ERR)
+tst_ismounted: $(srcdir)/ismounted.c $(STATIC_LIBEXT2FS) $(DEPLIBCOM_ERR)
$(E) " LD $@"
$(Q) $(CC) -o tst_ismounted $(srcdir)/ismounted.c \
$(STATIC_LIBEXT2FS) -DDEBUG $(ALL_CFLAGS) \
- $(STATIC_LIBCOM_ERR)
+ $(LIBCOM_ERR)
-tst_byteswap: tst_byteswap.o $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR)
+tst_byteswap: tst_byteswap.o $(STATIC_LIBEXT2FS) $(DEPLIBCOM_ERR)
$(E) " LD $@"
$(Q) $(CC) -o tst_byteswap tst_byteswap.o $(STATIC_LIBEXT2FS) \
- $(STATIC_LIBCOM_ERR)
+ $(LIBCOM_ERR)
-tst_bitops: tst_bitops.o $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR)
+tst_bitops: tst_bitops.o $(STATIC_LIBEXT2FS) $(DEPLIBCOM_ERR)
$(E) " LD $@"
$(Q) $(CC) -o tst_bitops tst_bitops.o $(ALL_CFLAGS) \
- $(STATIC_LIBEXT2FS) $(STATIC_LIBCOM_ERR)
+ $(STATIC_LIBEXT2FS) $(LIBCOM_ERR)
-tst_getsectsize: tst_getsectsize.o $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR)
+tst_getsectsize: tst_getsectsize.o $(STATIC_LIBEXT2FS) $(DEPLIBCOM_ERR)
$(E) " LD $@"
$(Q) $(CC) -o tst_sectgetsize tst_getsectsize.o \
- $(STATIC_LIBEXT2FS) $(STATIC_LIBCOM_ERR)
+ $(STATIC_LIBEXT2FS) $(LIBCOM_ERR)
tst_types.o: $(srcdir)/tst_types.c ext2_types.h
@@ -276,18 +251,6 @@ tst_super_size: tst_super_size.o
$(E) " LD $@"
$(Q) $(CC) -o tst_super_size tst_super_size.o
-tst_fs_struct.o: $(srcdir)/tst_fs_struct.c $(srcdir)/ext2fs.h
-
-tst_fs_struct: tst_fs_struct.o
- $(E) " LD $@"
- $(Q) $(CC) -o tst_fs_struct tst_fs_struct.o
-
-tst_inode_size.o: $(srcdir)/tst_inode_size.c $(srcdir)/ext2_fs.h
-
-tst_inode_size: tst_inode_size.o
- $(E) " LD $@"
- $(Q) $(CC) -o tst_inode_size tst_inode_size.o
-
ext2_tdbtool: tdbtool.o
$(E) " LD $@"
$(Q) $(CC) -o ext2_tdbtool tdbtool.o tdb.o
@@ -297,25 +260,16 @@ extent_dbg.c: $(srcdir)/extent_dbg.ct
$(Q) $(MK_CMDS) $(srcdir)/extent_dbg.ct
debug_cmds.c debug_cmds.h: $(top_srcdir)/debugfs/debug_cmds.ct
- $(E) " MK_CMDS $<"
+ $(E) " MK_CMDS $<@"
$(Q) $(MK_CMDS) $(top_srcdir)/debugfs/debug_cmds.ct
-extent_cmds.c extent_cmds.h: $(top_srcdir)/debugfs/extent_cmds.ct
- $(E) " MK_CMDS $<"
- $(Q) $(MK_CMDS) $(top_srcdir)/debugfs/extent_cmds.ct
-
DEBUG_OBJS= debug_cmds.o debugfs.o util.o ncheck.o icheck.o ls.o \
- lsdel.o dump.o set_fields.o logdump.o htree.o unused.o \
- e2freefrag.o filefrag.o extent_inode.o extent_cmds.o zap.o
+ lsdel.o dump.o set_fields.o logdump.o htree.o unused.o
debugfs.o: $(top_srcdir)/debugfs/debugfs.c
$(E) " CC $<"
$(Q) $(CC) $(ALL_CFLAGS) -c $< -o $@
-extent_inode.o: $(top_srcdir)/debugfs/extent_inode.c
- $(E) " CC $<"
- $(Q) $(CC) $(ALL_CFLAGS) -c $< -o $@
-
util.o: $(top_srcdir)/debugfs/util.c
$(E) " CC $<"
$(Q) $(CC) $(ALL_CFLAGS) -c $< -o $@
@@ -356,81 +310,32 @@ unused.o: $(top_srcdir)/debugfs/unused.c
$(E) " CC $<"
$(Q) $(CC) $(ALL_CFLAGS) -c $< -o $@
-zap.o: $(top_srcdir)/debugfs/zap.c
- $(E) " CC $<"
- $(Q) $(CC) $(ALL_CFLAGS) -c $< -o $@
-
-e2freefrag.o: $(top_srcdir)/misc/e2freefrag.c
- $(E) " CC $<"
- $(Q) $(CC) $(ALL_CFLAGS) -DDEBUGFS -I$(top_srcdir)/debugfs -c $< -o $@
-
-filefrag.o: $(top_srcdir)/debugfs/filefrag.c
- $(E) " CC $<"
- $(Q) $(CC) $(ALL_CFLAGS) -c $< -o $@
-
-tst_bitmaps_cmd.c: tst_bitmaps_cmd.ct
- $(E) " MK_CMDS $@"
- $(Q) DIR=$(srcdir) $(MK_CMDS) $(srcdir)/tst_bitmaps_cmd.ct
-
-tst_bitmaps: tst_bitmaps.o tst_bitmaps_cmd.o $(STATIC_LIBEXT2FS) \
- $(DEPSTATIC_LIBSS) $(DEPSTATIC_LIBCOM_ERR)
+tst_extents: $(srcdir)/extent.c extent_dbg.c $(DEBUG_OBJS) $(DEPLIBSS) \
+ $(LIBE2P) $(DEPLIBUUID) $(DEPLIBBLKID) $(DEPLIBCOM_ERR)
$(E) " LD $@"
- $(Q) $(CC) -o $@ tst_bitmaps.o tst_bitmaps_cmd.o $(ALL_CFLAGS) \
- $(STATIC_LIBEXT2FS) $(STATIC_LIBSS) $(STATIC_LIBCOM_ERR)
+ $(Q) $(CC) -o tst_extents $(srcdir)/extent.c extent_dbg.c \
+ $(ALL_CFLAGS) -DDEBUG $(DEBUG_OBJS) $(LIBSS) $(LIBE2P) \
+ $(STATIC_LIBEXT2FS) $(LIBBLKID) $(LIBUUID) $(LIBCOM_ERR) \
+ -I $(top_srcdir)/debugfs
-tst_extents: $(srcdir)/extent.c $(DEBUG_OBJS) $(DEPSTATIC_LIBSS) \
- $(STATIC_LIBE2P) $(DEPLIBUUID) $(DEPLIBBLKID) $(DEPSTATIC_LIBCOM_ERR)
- $(E) " LD $@"
- $(Q) $(CC) -o tst_extents $(srcdir)/extent.c \
- $(ALL_CFLAGS) -DDEBUG $(DEBUG_OBJS) $(STATIC_LIBSS) \
- $(STATIC_LIBE2P) $(STATIC_LIBEXT2FS) $(LIBBLKID) $(LIBUUID) \
- $(STATIC_LIBCOM_ERR) -I $(top_srcdir)/debugfs
-
-tst_inline: $(srcdir)/inline.c $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR)
- $(E) " LD $@"
- $(Q) $(CC) -o tst_inline $(srcdir)/inline.c $(ALL_CFLAGS) -DDEBUG \
- $(STATIC_LIBEXT2FS) $(STATIC_LIBCOM_ERR)
-
-tst_csum: csum.c $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR) $(STATIC_LIBE2P) \
+tst_csum: csum.c $(STATIC_LIBEXT2FS) $(DEPLIBCOM_ERR) \
$(top_srcdir)/lib/e2p/e2p.h
$(E) " LD $@"
$(Q) $(CC) -o tst_csum $(srcdir)/csum.c -DDEBUG \
- $(ALL_CFLAGS) $(STATIC_LIBEXT2FS) $(STATIC_LIBCOM_ERR) \
- $(STATIC_LIBE2P)
-
-tst_crc32c: $(srcdir)/crc32c.c $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR)
- $(Q) $(CC) $(BUILD_LDFLAGS) $(ALL_CFLAGS) -o tst_crc32c $(srcdir)/crc32c.c \
- -DUNITTEST $(STATIC_LIBEXT2FS) $(STATIC_LIBCOM_ERR)
+ $(ALL_CFLAGS) $(STATIC_LIBEXT2FS) $(LIBCOM_ERR) $(LIBE2P)
mkjournal: mkjournal.c $(STATIC_LIBEXT2FS) $(DEPLIBCOM_ERR)
$(E) " LD $@"
$(Q) $(CC) -o mkjournal $(srcdir)/mkjournal.c -DDEBUG $(STATIC_LIBEXT2FS) $(LIBCOM_ERR) $(ALL_CFLAGS)
-check:: tst_bitops tst_badblocks tst_iscan tst_types tst_icount \
- tst_super_size tst_types tst_inode_size tst_csum tst_crc32c tst_bitmaps \
- tst_inline
+check:: tst_bitops tst_badblocks tst_iscan tst_types tst_icount tst_super_size tst_types tst_csum
LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./tst_bitops
LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./tst_badblocks
LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./tst_iscan
LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./tst_types
LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./tst_icount
LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./tst_super_size
- LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./tst_inode_size
LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./tst_csum
- LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./tst_inline
- LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./tst_crc32c
- LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) \
- ./tst_bitmaps -f $(srcdir)/tst_bitmaps_cmds > tst_bitmaps_out
- diff $(srcdir)/tst_bitmaps_exp tst_bitmaps_out
- LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) \
- ./tst_bitmaps -t 2 -f $(srcdir)/tst_bitmaps_cmds > tst_bitmaps_out
- diff $(srcdir)/tst_bitmaps_exp tst_bitmaps_out
- LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) \
- ./tst_bitmaps -t 3 -f $(srcdir)/tst_bitmaps_cmds > tst_bitmaps_out
- diff $(srcdir)/tst_bitmaps_exp tst_bitmaps_out
- LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) \
- ./tst_bitmaps -l -f $(srcdir)/tst_bitmaps_cmds > tst_bitmaps_out
- diff $(srcdir)/tst_bitmaps_exp tst_bitmaps_out
installdirs::
$(E) " MKINSTALLDIRS $(libdir) $(includedir)/ext2fs"
@@ -463,11 +368,8 @@ clean::
tst_badblocks tst_iscan ext2_err.et ext2_err.c ext2_err.h \
tst_byteswap tst_ismounted tst_getsize tst_sectgetsize \
tst_bitops tst_types tst_icount tst_super_size tst_csum \
- tst_bitmaps tst_bitmaps_out tst_extents tst_inline \
- tst_inline_data tst_inode_size tst_bitmaps_cmd.c \
- ext2_tdbtool mkjournal debug_cmds.c extent_cmds.c \
- ../libext2fs.a ../libext2fs_p.a ../libext2fs_chk.a \
- crc32c_table.h gen_crc32ctable tst_crc32c
+ ext2_tdbtool mkjournal debug_cmds.c \
+ ../libext2fs.a ../libext2fs_p.a ../libext2fs_chk.a
mostlyclean:: clean
distclean:: clean
@@ -480,495 +382,357 @@ $(top_builddir)/lib/ext2fs/ext2_err.h: ext2_err.h
$(OBJS): subdirs
-gen_crc32ctable: $(srcdir)/gen_crc32ctable.c
- $(E) " CC $@"
- $(Q) $(BUILD_CC) $(BUILD_CFLAGS) $(BUILD_LDFLAGS) -o gen_crc32ctable \
- $(srcdir)/gen_crc32ctable.c
-
-crc32c_table.h: gen_crc32ctable
- $(E) " GEN32CTABLE $@"
- $(Q) ./gen_crc32ctable > crc32c_table.h
-
# +++ 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 $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+alloc.o: $(srcdir)/alloc.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-alloc_sb.o: $(srcdir)/alloc_sb.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+alloc_sb.o: $(srcdir)/alloc_sb.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-alloc_stats.o: $(srcdir)/alloc_stats.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+alloc_stats.o: $(srcdir)/alloc_stats.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-alloc_tables.o: $(srcdir)/alloc_tables.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+alloc_tables.o: $(srcdir)/alloc_tables.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
- $(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h $(srcdir)/ext2fsP.h
-badblocks.o: $(srcdir)/badblocks.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+ $(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
+badblocks.o: $(srcdir)/badblocks.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fsP.h \
$(srcdir)/ext2fs.h $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h \
$(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_io.h \
$(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \
$(srcdir)/bitops.h
-bb_compat.o: $(srcdir)/bb_compat.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+bb_compat.o: $(srcdir)/bb_compat.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fsP.h \
$(srcdir)/ext2fs.h $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h \
$(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_io.h \
$(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \
$(srcdir)/bitops.h
-bb_inode.o: $(srcdir)/bb_inode.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+bb_inode.o: $(srcdir)/bb_inode.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-bitmaps.o: $(srcdir)/bitmaps.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+bitmaps.o: $(srcdir)/bitmaps.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
- $(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h $(srcdir)/ext2fsP.h \
- $(srcdir)/bmap64.h
-bitops.o: $(srcdir)/bitops.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+ $(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
+bitops.o: $(srcdir)/bitops.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-blkmap64_ba.o: $(srcdir)/blkmap64_ba.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
- $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fsP.h \
- $(srcdir)/ext2fs.h $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h \
- $(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_io.h \
- $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \
- $(srcdir)/bitops.h $(srcdir)/bmap64.h
-blkmap64_rb.o: $(srcdir)/blkmap64_rb.c $(srcdir)/ext2_fs.h \
- $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fsP.h \
- $(srcdir)/ext2fs.h $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h \
- $(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_io.h \
- $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \
- $(srcdir)/bitops.h $(srcdir)/bmap64.h $(srcdir)/rbtree.h
-block.o: $(srcdir)/block.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+block.o: $(srcdir)/block.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-bmap.o: $(srcdir)/bmap.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+bmap.o: $(srcdir)/bmap.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-check_desc.o: $(srcdir)/check_desc.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+check_desc.o: $(srcdir)/check_desc.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-closefs.o: $(srcdir)/closefs.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+closefs.o: $(srcdir)/closefs.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fsP.h \
$(srcdir)/ext2fs.h $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h \
$(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_io.h \
$(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \
$(srcdir)/bitops.h
-crc16.o: $(srcdir)/crc16.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(top_builddir)/lib/ext2fs/ext2_types.h \
+crc16.o: $(srcdir)/crc16.c $(top_builddir)/lib/ext2fs/ext2_types.h \
$(srcdir)/crc16.h
-crc32c.o: $(srcdir)/crc32c.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/crc32c_defs.h $(srcdir)/ext2fs.h \
- $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2_fs.h \
- $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_io.h \
- $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \
- $(srcdir)/bitops.h crc32c_table.h
-gen_crc32ctable.o: $(srcdir)/gen_crc32ctable.c $(srcdir)/crc32c_defs.h
-csum.o: $(srcdir)/csum.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+csum.o: $(srcdir)/csum.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h $(srcdir)/crc16.h
-dblist.o: $(srcdir)/dblist.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+dblist.o: $(srcdir)/dblist.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fsP.h \
$(srcdir)/ext2fs.h $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h \
$(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_io.h \
$(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \
$(srcdir)/bitops.h
-dblist_dir.o: $(srcdir)/dblist_dir.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+dblist_dir.o: $(srcdir)/dblist_dir.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fsP.h \
$(srcdir)/ext2fs.h $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h \
$(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_io.h \
$(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \
$(srcdir)/bitops.h
-dirblock.o: $(srcdir)/dirblock.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+dirblock.o: $(srcdir)/dirblock.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-dirhash.o: $(srcdir)/dirhash.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+dirhash.o: $(srcdir)/dirhash.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-dir_iterate.o: $(srcdir)/dir_iterate.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+dir_iterate.o: $(srcdir)/dir_iterate.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fsP.h \
$(srcdir)/ext2fs.h $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h \
$(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_io.h \
$(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \
$(srcdir)/bitops.h
-dupfs.o: $(srcdir)/dupfs.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+dupfs.o: $(srcdir)/dupfs.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fsP.h \
$(srcdir)/ext2fs.h $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h \
$(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_io.h \
$(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \
$(srcdir)/bitops.h
-expanddir.o: $(srcdir)/expanddir.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+expanddir.o: $(srcdir)/expanddir.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-ext_attr.o: $(srcdir)/ext_attr.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+ext_attr.o: $(srcdir)/ext_attr.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2_ext_attr.h \
$(srcdir)/ext2fs.h $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h \
$(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_io.h \
$(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \
$(srcdir)/bitops.h
-extent.o: $(srcdir)/extent.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+extent.o: $(srcdir)/extent.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fsP.h \
$(srcdir)/ext2fs.h $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h \
$(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_io.h \
$(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \
$(srcdir)/bitops.h $(srcdir)/e2image.h
-fileio.o: $(srcdir)/fileio.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+fileio.o: $(srcdir)/fileio.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-finddev.o: $(srcdir)/finddev.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+finddev.o: $(srcdir)/finddev.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
- $(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h $(srcdir)/ext2fsP.h
-flushb.o: $(srcdir)/flushb.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+ $(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
+flushb.o: $(srcdir)/flushb.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-freefs.o: $(srcdir)/freefs.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+freefs.o: $(srcdir)/freefs.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fsP.h \
$(srcdir)/ext2fs.h $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h \
$(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_io.h \
$(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \
$(srcdir)/bitops.h
-gen_bitmap.o: $(srcdir)/gen_bitmap.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
- $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fsP.h \
- $(srcdir)/ext2fs.h $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h \
- $(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_io.h \
- $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \
- $(srcdir)/bitops.h
-gen_bitmap64.o: $(srcdir)/gen_bitmap64.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
- $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fsP.h \
- $(srcdir)/ext2fs.h $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h \
- $(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_io.h \
- $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \
- $(srcdir)/bitops.h $(srcdir)/bmap64.h
-get_pathname.o: $(srcdir)/get_pathname.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+gen_bitmap.o: $(srcdir)/gen_bitmap.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-getsize.o: $(srcdir)/getsize.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+get_pathname.o: $(srcdir)/get_pathname.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-getsectsize.o: $(srcdir)/getsectsize.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+getsize.o: $(srcdir)/getsize.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-i_block.o: $(srcdir)/i_block.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+getsectsize.o: $(srcdir)/getsectsize.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-icount.o: $(srcdir)/icount.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+i_block.o: $(srcdir)/i_block.c $(srcdir)/ext2_fs.h \
+ $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
+ $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
+ $(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
+ $(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
+icount.o: $(srcdir)/icount.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h $(srcdir)/tdb.h
-ind_block.o: $(srcdir)/ind_block.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+ind_block.o: $(srcdir)/ind_block.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-initialize.o: $(srcdir)/initialize.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+initialize.o: $(srcdir)/initialize.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-inline.o: $(srcdir)/inline.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+inline.o: $(srcdir)/inline.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-inode.o: $(srcdir)/inode.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+inode.o: $(srcdir)/inode.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fsP.h \
$(srcdir)/ext2fs.h $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h \
$(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_io.h \
$(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \
$(srcdir)/bitops.h $(srcdir)/e2image.h
-inode_io.o: $(srcdir)/inode_io.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+inode_io.o: $(srcdir)/inode_io.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-imager.o: $(srcdir)/imager.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+imager.o: $(srcdir)/imager.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-io_manager.o: $(srcdir)/io_manager.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+io_manager.o: $(srcdir)/io_manager.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-ismounted.o: $(srcdir)/ismounted.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+ismounted.o: $(srcdir)/ismounted.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-link.o: $(srcdir)/link.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+link.o: $(srcdir)/link.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-llseek.o: $(srcdir)/llseek.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(top_srcdir)/lib/et/com_err.h \
+llseek.o: $(srcdir)/llseek.c $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h
-lookup.o: $(srcdir)/lookup.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+lookup.o: $(srcdir)/lookup.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-mkdir.o: $(srcdir)/mkdir.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+mkdir.o: $(srcdir)/mkdir.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-mkjournal.o: $(srcdir)/mkjournal.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+mkjournal.o: $(srcdir)/mkjournal.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/lib/e2p/e2p.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext2fs.h $(srcdir)/ext3_extents.h \
$(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_io.h \
$(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \
$(srcdir)/bitops.h $(srcdir)/jfs_user.h $(srcdir)/kernel-jbd.h \
$(srcdir)/jfs_compat.h $(srcdir)/kernel-list.h
-mmp.o: $(srcdir)/mmp.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
- $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
- $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_io.h \
- $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \
- $(srcdir)/bitops.h
-namei.o: $(srcdir)/namei.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+namei.o: $(srcdir)/namei.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
- $(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h $(srcdir)/ext2fsP.h
-native.o: $(srcdir)/native.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+ $(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
+native.o: $(srcdir)/native.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-newdir.o: $(srcdir)/newdir.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+newdir.o: $(srcdir)/newdir.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-openfs.o: $(srcdir)/openfs.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+openfs.o: $(srcdir)/openfs.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h $(srcdir)/e2image.h
-progress.o: $(srcdir)/progress.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2fs.h \
- $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2_fs.h \
- $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_io.h \
- $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \
- $(srcdir)/bitops.h $(srcdir)/ext2fsP.h
-punch.o: $(srcdir)/punch.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
- $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
- $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
- $(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
- $(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-qcow2.o: $(srcdir)/qcow2.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2fs.h \
- $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2_fs.h \
- $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_io.h \
- $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \
- $(srcdir)/bitops.h $(srcdir)/qcow2.h
-read_bb.o: $(srcdir)/read_bb.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+read_bb.o: $(srcdir)/read_bb.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-read_bb_file.o: $(srcdir)/read_bb_file.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+read_bb_file.o: $(srcdir)/read_bb_file.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-res_gdt.o: $(srcdir)/res_gdt.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+res_gdt.o: $(srcdir)/res_gdt.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-rw_bitmaps.o: $(srcdir)/rw_bitmaps.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+rw_bitmaps.o: $(srcdir)/rw_bitmaps.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h $(srcdir)/e2image.h
-swapfs.o: $(srcdir)/swapfs.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
- $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
- $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
- $(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
- $(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-symlink.o: $(srcdir)/symlink.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+swapfs.o: $(srcdir)/swapfs.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-tdb.o: $(srcdir)/tdb.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/tdb.h
-test_io.o: $(srcdir)/test_io.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+tdb.o: $(srcdir)/tdb.c $(srcdir)/tdb.h
+test_io.o: $(srcdir)/test_io.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-tst_badblocks.o: $(srcdir)/tst_badblocks.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+tst_badblocks.o: $(srcdir)/tst_badblocks.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-tst_bitops.o: $(srcdir)/tst_bitops.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+tst_bitops.o: $(srcdir)/tst_bitops.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-tst_byteswap.o: $(srcdir)/tst_byteswap.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+tst_byteswap.o: $(srcdir)/tst_byteswap.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-tst_getsize.o: $(srcdir)/tst_getsize.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+tst_getsize.o: $(srcdir)/tst_getsize.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-tst_iscan.o: $(srcdir)/tst_iscan.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+tst_iscan.o: $(srcdir)/tst_iscan.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-undo_io.o: $(srcdir)/undo_io.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/tdb.h $(srcdir)/ext2_fs.h \
+undo_io.o: $(srcdir)/undo_io.c $(srcdir)/tdb.h $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-unix_io.o: $(srcdir)/unix_io.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+unix_io.o: $(srcdir)/unix_io.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-unlink.o: $(srcdir)/unlink.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+unlink.o: $(srcdir)/unlink.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-valid_blk.o: $(srcdir)/valid_blk.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+valid_blk.o: $(srcdir)/valid_blk.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-version.o: $(srcdir)/version.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+version.o: $(srcdir)/version.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h $(top_srcdir)/version.h
-write_bb_file.o: $(srcdir)/write_bb_file.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ext2_fs.h \
+write_bb_file.o: $(srcdir)/write_bb_file.c $(srcdir)/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
$(srcdir)/ext2_ext_attr.h $(srcdir)/bitops.h
-rbtree.o: $(srcdir)/rbtree.c $(srcdir)/rbtree.h
diff --git a/lib/ext2fs/Makefile.pq b/lib/ext2fs/Makefile.pq
deleted file mode 100644
index 2f7b654b..00000000
--- a/lib/ext2fs/Makefile.pq
+++ /dev/null
@@ -1,49 +0,0 @@
-TOPSRC=..\..
-LIBNAME=EXT2.LIB
-OBJFILE=EXT2.LST
-
-OBJS= alloc.obj \
- alloc_tables.obj \
- badblocks.obj \
- bb_compat.obj \
- bb_inode.obj \
- bitmaps.obj \
- bitops.obj \
- block.obj \
- bmap.obj \
- bmove.obj \
- check_desc.obj \
- closefs.obj \
- cmp_bitmaps.obj \
- dblist.obj \
- dblist_dir.obj \
- dirblock.obj \
- dir_iterate.obj \
- dupfs.obj \
- expanddir.obj \
- fileio.obj \
- freefs.obj \
- get_pathname.obj \
- icount.obj \
- initialize.obj \
- inline.obj \
- inode.obj \
- ismounted.obj \
- link.obj \
- lookup.obj \
- mkdir.obj \
- namei.obj \
- native.obj \
- newdir.obj \
- openfs.obj \
- read_bb.obj \
- read_bb_file.obj \
- rs_bitmap.obj \
- rw_bitmaps.obj \
- swapfs.obj \
- unlink.obj \
- valid_blk.obj \
- version.obj
-
-!include $(TOPSRC)\powerquest\MCONFIG
-
diff --git a/lib/ext2fs/alloc.c b/lib/ext2fs/alloc.c
index 21d3e5ef..59d10890 100644
--- a/lib/ext2fs/alloc.c
+++ b/lib/ext2fs/alloc.c
@@ -29,21 +29,22 @@
* Check for uninit block bitmaps and deal with them appropriately
*/
static void check_block_uninit(ext2_filsys fs, ext2fs_block_bitmap map,
- dgrp_t group)
+ dgrp_t group)
{
blk_t i;
- blk64_t blk, super_blk, old_desc_blk, new_desc_blk;
+ blk_t blk, super_blk, old_desc_blk, new_desc_blk;
int old_desc_blocks;
if (!(EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) ||
- !(ext2fs_bg_flags_test(fs, group, EXT2_BG_BLOCK_UNINIT)))
+ !(fs->group_desc[group].bg_flags & EXT2_BG_BLOCK_UNINIT))
return;
- blk = ext2fs_group_first_block2(fs, group);
+ blk = (group * fs->super->s_blocks_per_group) +
+ fs->super->s_first_data_block;
- ext2fs_super_and_bgd_loc2(fs, group, &super_blk,
- &old_desc_blk, &new_desc_blk, 0);
+ ext2fs_super_and_bgd_loc(fs, group, &super_blk,
+ &old_desc_blk, &new_desc_blk, 0);
if (fs->super->s_feature_incompat &
EXT2_FEATURE_INCOMPAT_META_BG)
@@ -51,27 +52,23 @@ static void check_block_uninit(ext2_filsys fs, ext2fs_block_bitmap map,
else
old_desc_blocks = fs->desc_blocks + fs->super->s_reserved_gdt_blocks;
- for (i=0; i < fs->super->s_blocks_per_group; i++, blk++)
- ext2fs_fast_unmark_block_bitmap2(map, blk);
-
- blk = ext2fs_group_first_block2(fs, group);
for (i=0; i < fs->super->s_blocks_per_group; i++, blk++) {
if ((blk == super_blk) ||
(old_desc_blk && old_desc_blocks &&
(blk >= old_desc_blk) &&
(blk < old_desc_blk + old_desc_blocks)) ||
(new_desc_blk && (blk == new_desc_blk)) ||
- (blk == ext2fs_block_bitmap_loc(fs, group)) ||
- (blk == ext2fs_inode_bitmap_loc(fs, group)) ||
- (blk >= ext2fs_inode_table_loc(fs, group) &&
- (blk < ext2fs_inode_table_loc(fs, group)
+ (blk == fs->group_desc[group].bg_block_bitmap) ||
+ (blk == fs->group_desc[group].bg_inode_bitmap) ||
+ (blk >= fs->group_desc[group].bg_inode_table &&
+ (blk < fs->group_desc[group].bg_inode_table
+ fs->inode_blocks_per_group)))
- ext2fs_fast_mark_block_bitmap2(map, blk);
+ ext2fs_fast_mark_block_bitmap(map, blk);
+ else
+ ext2fs_fast_unmark_block_bitmap(map, blk);
}
- ext2fs_bg_flags_clear(fs, group, EXT2_BG_BLOCK_UNINIT);
+ fs->group_desc[group].bg_flags &= ~EXT2_BG_BLOCK_UNINIT;
ext2fs_group_desc_csum_set(fs, group);
- ext2fs_mark_super_dirty(fs);
- ext2fs_mark_bb_dirty(fs);
}
/*
@@ -84,17 +81,14 @@ static void check_inode_uninit(ext2_filsys fs, ext2fs_inode_bitmap map,
if (!(EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) ||
- !(ext2fs_bg_flags_test(fs, group, EXT2_BG_INODE_UNINIT)))
+ !(fs->group_desc[group].bg_flags & EXT2_BG_INODE_UNINIT))
return;
ino = (group * fs->super->s_inodes_per_group) + 1;
for (i=0; i < fs->super->s_inodes_per_group; i++, ino++)
- ext2fs_fast_unmark_inode_bitmap2(map, ino);
+ ext2fs_fast_unmark_inode_bitmap(map, ino);
- ext2fs_bg_flags_clear(fs, group, EXT2_BG_INODE_UNINIT);
- ext2fs_group_desc_csum_set(fs, group);
- ext2fs_mark_ib_dirty(fs);
- ext2fs_mark_super_dirty(fs);
+ fs->group_desc[group].bg_flags &= ~EXT2_BG_INODE_UNINIT;
check_block_uninit(fs, fs->block_map, group);
}
@@ -108,10 +102,9 @@ errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir,
int mode EXT2FS_ATTR((unused)),
ext2fs_inode_bitmap map, ext2_ino_t *ret)
{
- ext2_ino_t start_inode = 0;
- ext2_ino_t i, ino_in_group, upto, first_zero;
- errcode_t retval;
- dgrp_t group;
+ ext2_ino_t dir_group = 0;
+ ext2_ino_t i;
+ ext2_ino_t start_inode;
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
@@ -120,40 +113,29 @@ errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir,
if (!map)
return EXT2_ET_NO_INODE_BITMAP;
- if (dir > 0) {
- group = (dir - 1) / EXT2_INODES_PER_GROUP(fs->super);
- start_inode = (group * EXT2_INODES_PER_GROUP(fs->super)) + 1;
- }
+ if (dir > 0)
+ 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_INODE(fs->super))
start_inode = EXT2_FIRST_INODE(fs->super);
if (start_inode > fs->super->s_inodes_count)
return EXT2_ET_INODE_ALLOC_FAIL;
i = start_inode;
+
do {
- ino_in_group = (i - 1) % EXT2_INODES_PER_GROUP(fs->super);
- group = (i - 1) / EXT2_INODES_PER_GROUP(fs->super);
-
- check_inode_uninit(fs, map, group);
- upto = i + (EXT2_INODES_PER_GROUP(fs->super) - ino_in_group);
- if (i < start_inode && upto >= start_inode)
- upto = start_inode - 1;
- if (upto > fs->super->s_inodes_count)
- upto = fs->super->s_inodes_count;
-
- retval = ext2fs_find_first_zero_inode_bitmap2(map, i, upto,
- &first_zero);
- if (retval == 0) {
- i = first_zero;
+ if (((i - 1) % EXT2_INODES_PER_GROUP(fs->super)) == 0)
+ check_inode_uninit(fs, map, (i - 1) /
+ EXT2_INODES_PER_GROUP(fs->super));
+
+ if (!ext2fs_fast_test_inode_bitmap(map, i))
break;
- }
- if (retval != ENOENT)
- return EXT2_ET_INODE_ALLOC_FAIL;
- i = upto + 1;
+ i++;
if (i > fs->super->s_inodes_count)
i = EXT2_FIRST_INODE(fs->super);
} while (i != start_inode);
- if (ext2fs_test_inode_bitmap2(map, i))
+ if (ext2fs_test_inode_bitmap(map, i))
return EXT2_ET_INODE_ALLOC_FAIL;
*ret = i;
return 0;
@@ -163,11 +145,10 @@ errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir,
* Stupid algorithm --- we now just search forward starting from the
* goal. Should put in a smarter one someday....
*/
-errcode_t ext2fs_new_block2(ext2_filsys fs, blk64_t goal,
- ext2fs_block_bitmap map, blk64_t *ret)
+errcode_t ext2fs_new_block(ext2_filsys fs, blk_t goal,
+ ext2fs_block_bitmap map, blk_t *ret)
{
- blk64_t i;
- int c_ratio;
+ blk_t i;
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
@@ -175,12 +156,9 @@ errcode_t ext2fs_new_block2(ext2_filsys fs, blk64_t goal,
map = fs->block_map;
if (!map)
return EXT2_ET_NO_BLOCK_BITMAP;
- if (!goal || (goal >= ext2fs_blocks_count(fs->super)))
+ if (!goal || (goal >= fs->super->s_blocks_count))
goal = fs->super->s_first_data_block;
i = goal;
- c_ratio = 1 << ext2fs_get_bitmap_granularity(map);
- if (c_ratio > 1)
- goal &= ~EXT2FS_CLUSTER_MASK(fs);
check_block_uninit(fs, map,
(i - fs->super->s_first_data_block) /
EXT2_BLOCKS_PER_GROUP(fs->super));
@@ -191,37 +169,26 @@ errcode_t ext2fs_new_block2(ext2_filsys fs, blk64_t goal,
(i - fs->super->s_first_data_block) /
EXT2_BLOCKS_PER_GROUP(fs->super));
- if (!ext2fs_fast_test_block_bitmap2(map, i)) {
+ if (!ext2fs_fast_test_block_bitmap(map, i)) {
*ret = i;
return 0;
}
- i = (i + c_ratio) & ~(c_ratio - 1);
- if (i >= ext2fs_blocks_count(fs->super))
+ i++;
+ if (i >= fs->super->s_blocks_count)
i = fs->super->s_first_data_block;
} while (i != goal);
return EXT2_ET_BLOCK_ALLOC_FAIL;
}
-errcode_t ext2fs_new_block(ext2_filsys fs, blk_t goal,
- ext2fs_block_bitmap map, blk_t *ret)
-{
- errcode_t retval;
- blk64_t val;
- retval = ext2fs_new_block2(fs, goal, map, &val);
- if (!retval)
- *ret = (blk_t) val;
- return retval;
-}
-
/*
* This function zeros out the allocated block, and updates all of the
* appropriate filesystem records.
*/
-errcode_t ext2fs_alloc_block2(ext2_filsys fs, blk64_t goal,
- char *block_buf, blk64_t *ret)
+errcode_t ext2fs_alloc_block(ext2_filsys fs, blk_t goal,
+ char *block_buf, blk_t *ret)
{
errcode_t retval;
- blk64_t block;
+ blk_t block;
char *buf = 0;
if (!block_buf) {
@@ -233,9 +200,12 @@ errcode_t ext2fs_alloc_block2(ext2_filsys fs, blk64_t goal,
memset(block_buf, 0, fs->blocksize);
if (fs->get_alloc_block) {
- retval = (fs->get_alloc_block)(fs, goal, &block);
+ blk64_t new;
+
+ retval = (fs->get_alloc_block)(fs, (blk64_t) goal, &new);
if (retval)
goto fail;
+ block = (blk_t) new;
} else {
if (!fs->block_map) {
retval = ext2fs_read_block_bitmap(fs);
@@ -243,16 +213,16 @@ errcode_t ext2fs_alloc_block2(ext2_filsys fs, blk64_t goal,
goto fail;
}
- retval = ext2fs_new_block2(fs, goal, 0, &block);
+ retval = ext2fs_new_block(fs, goal, 0, &block);
if (retval)
goto fail;
}
- retval = io_channel_write_blk64(fs->io, block, 1, block_buf);
+ retval = io_channel_write_blk(fs->io, block, 1, block_buf);
if (retval)
goto fail;
- ext2fs_block_alloc_stats2(fs, block, +1);
+ ext2fs_block_alloc_stats(fs, block, +1);
*ret = block;
fail:
@@ -261,22 +231,10 @@ fail:
return retval;
}
-errcode_t ext2fs_alloc_block(ext2_filsys fs, blk_t goal,
- char *block_buf, blk_t *ret)
-{
- errcode_t retval;
- blk64_t val;
- retval = ext2fs_alloc_block2(fs, goal, block_buf, &val);
- if (!retval)
- *ret = (blk_t) val;
- return retval;
-}
-
-errcode_t ext2fs_get_free_blocks2(ext2_filsys fs, blk64_t start, blk64_t finish,
- int num, ext2fs_block_bitmap map, blk64_t *ret)
+errcode_t ext2fs_get_free_blocks(ext2_filsys fs, blk_t start, blk_t finish,
+ int num, ext2fs_block_bitmap map, blk_t *ret)
{
- blk64_t b = start;
- int c_ratio;
+ blk_t b = start;
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
@@ -290,32 +248,18 @@ errcode_t ext2fs_get_free_blocks2(ext2_filsys fs, blk64_t start, blk64_t finish,
finish = start;
if (!num)
num = 1;
- c_ratio = 1 << ext2fs_get_bitmap_granularity(map);
- b &= ~(c_ratio - 1);
- finish &= ~(c_ratio -1);
do {
- if (b+num-1 > ext2fs_blocks_count(fs->super))
+ if (b+num-1 > fs->super->s_blocks_count)
b = fs->super->s_first_data_block;
- if (ext2fs_fast_test_block_bitmap_range2(map, b, num)) {
+ if (ext2fs_fast_test_block_bitmap_range(map, b, num)) {
*ret = b;
return 0;
}
- b += c_ratio;
+ b++;
} while (b != finish);
return EXT2_ET_BLOCK_ALLOC_FAIL;
}
-errcode_t ext2fs_get_free_blocks(ext2_filsys fs, blk_t start, blk_t finish,
- int num, ext2fs_block_bitmap map, blk_t *ret)
-{
- errcode_t retval;
- blk64_t val;
- retval = ext2fs_get_free_blocks2(fs, start, finish, num, map, &val);
- if(!retval)
- *ret = (blk_t) val;
- return retval;
-}
-
void ext2fs_set_alloc_block_callback(ext2_filsys fs,
errcode_t (*func)(ext2_filsys fs,
blk64_t goal,
diff --git a/lib/ext2fs/alloc_sb.c b/lib/ext2fs/alloc_sb.c
index 73ef2cea..b491a9f6 100644
--- a/lib/ext2fs/alloc_sb.c
+++ b/lib/ext2fs/alloc_sb.c
@@ -44,12 +44,11 @@ int ext2fs_reserve_super_and_bgd(ext2_filsys fs,
dgrp_t group,
ext2fs_block_bitmap bmap)
{
- blk64_t super_blk, old_desc_blk, new_desc_blk;
- blk_t used_blks;
- int old_desc_blocks, num_blocks;
+ blk_t super_blk, old_desc_blk, new_desc_blk;
+ int j, old_desc_blocks, num_blocks;
- ext2fs_super_and_bgd_loc2(fs, group, &super_blk,
- &old_desc_blk, &new_desc_blk, &used_blks);
+ num_blocks = ext2fs_super_and_bgd_loc(fs, group, &super_blk,
+ &old_desc_blk, &new_desc_blk, 0);
if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG)
old_desc_blocks = fs->super->s_first_meta_bg;
@@ -58,25 +57,18 @@ int ext2fs_reserve_super_and_bgd(ext2_filsys fs,
fs->desc_blocks + fs->super->s_reserved_gdt_blocks;
if (super_blk || (group == 0))
- ext2fs_mark_block_bitmap2(bmap, super_blk);
- if ((group == 0) && (fs->blocksize == 1024) &&
- EXT2FS_CLUSTER_RATIO(fs) > 1)
- ext2fs_mark_block_bitmap2(bmap, 0);
+ ext2fs_mark_block_bitmap(bmap, super_blk);
if (old_desc_blk) {
if (fs->super->s_reserved_gdt_blocks && fs->block_map == bmap)
- ext2fs_bg_flags_clear(fs, group, EXT2_BG_BLOCK_UNINIT);
- num_blocks = old_desc_blocks;
- if (old_desc_blk + num_blocks >= ext2fs_blocks_count(fs->super))
- num_blocks = ext2fs_blocks_count(fs->super) -
- old_desc_blk;
- ext2fs_mark_block_bitmap_range2(bmap, old_desc_blk, num_blocks);
+ fs->group_desc[group].bg_flags &= ~EXT2_BG_BLOCK_UNINIT;
+ for (j=0; j < old_desc_blocks; j++)
+ if (old_desc_blk + j < fs->super->s_blocks_count)
+ ext2fs_mark_block_bitmap(bmap,
+ old_desc_blk + j);
}
if (new_desc_blk)
- ext2fs_mark_block_bitmap2(bmap, new_desc_blk);
+ ext2fs_mark_block_bitmap(bmap, new_desc_blk);
- num_blocks = ext2fs_group_blocks_count(fs, group);
- num_blocks -= 2 + fs->inode_blocks_per_group + used_blks;
-
- return num_blocks ;
+ return num_blocks;
}
diff --git a/lib/ext2fs/alloc_stats.c b/lib/ext2fs/alloc_stats.c
index 9a6697e0..5ac52050 100644
--- a/lib/ext2fs/alloc_stats.c
+++ b/lib/ext2fs/alloc_stats.c
@@ -27,24 +27,26 @@ void ext2fs_inode_alloc_stats2(ext2_filsys fs, ext2_ino_t ino,
}
#endif
if (inuse > 0)
- ext2fs_mark_inode_bitmap2(fs->inode_map, ino);
+ ext2fs_mark_inode_bitmap(fs->inode_map, ino);
else
- ext2fs_unmark_inode_bitmap2(fs->inode_map, ino);
- ext2fs_bg_free_inodes_count_set(fs, group, ext2fs_bg_free_inodes_count(fs, group) - inuse);
+ ext2fs_unmark_inode_bitmap(fs->inode_map, ino);
+ fs->group_desc[group].bg_free_inodes_count -= inuse;
if (isdir)
- ext2fs_bg_used_dirs_count_set(fs, group, ext2fs_bg_used_dirs_count(fs, group) + inuse);
+ fs->group_desc[group].bg_used_dirs_count += inuse;
/* We don't strictly need to be clearing the uninit flag if inuse < 0
* (i.e. freeing inodes) but it also means something is bad. */
- ext2fs_bg_flags_clear(fs, group, EXT2_BG_INODE_UNINIT);
+ fs->group_desc[group].bg_flags &= ~EXT2_BG_INODE_UNINIT;
if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) {
ext2_ino_t first_unused_inode = fs->super->s_inodes_per_group -
- ext2fs_bg_itable_unused(fs, group) +
+ fs->group_desc[group].bg_itable_unused +
group * fs->super->s_inodes_per_group + 1;
if (ino >= first_unused_inode)
- ext2fs_bg_itable_unused_set(fs, group, group * fs->super->s_inodes_per_group + fs->super->s_inodes_per_group - ino);
+ fs->group_desc[group].bg_itable_unused =
+ group * fs->super->s_inodes_per_group +
+ fs->super->s_inodes_per_group - ino;
ext2fs_group_desc_csum_set(fs, group);
}
@@ -58,38 +60,32 @@ void ext2fs_inode_alloc_stats(ext2_filsys fs, ext2_ino_t ino, int inuse)
ext2fs_inode_alloc_stats2(fs, ino, inuse, 0);
}
-void ext2fs_block_alloc_stats2(ext2_filsys fs, blk64_t blk, int inuse)
+void ext2fs_block_alloc_stats(ext2_filsys fs, blk_t blk, int inuse)
{
- int group = ext2fs_group_of_blk2(fs, blk);
+ int group = ext2fs_group_of_blk(fs, blk);
#ifndef OMIT_COM_ERR
- if (blk >= ext2fs_blocks_count(fs->super)) {
+ if (blk >= fs->super->s_blocks_count) {
com_err("ext2fs_block_alloc_stats", 0,
"Illegal block number: %lu", (unsigned long) blk);
return;
}
#endif
if (inuse > 0)
- ext2fs_mark_block_bitmap2(fs->block_map, blk);
+ ext2fs_mark_block_bitmap(fs->block_map, blk);
else
- ext2fs_unmark_block_bitmap2(fs->block_map, blk);
- ext2fs_bg_free_blocks_count_set(fs, group, ext2fs_bg_free_blocks_count(fs, group) - inuse);
- ext2fs_bg_flags_clear(fs, group, EXT2_BG_BLOCK_UNINIT);
+ ext2fs_unmark_block_bitmap(fs->block_map, blk);
+ fs->group_desc[group].bg_free_blocks_count -= inuse;
+ fs->group_desc[group].bg_flags &= ~EXT2_BG_BLOCK_UNINIT;
ext2fs_group_desc_csum_set(fs, group);
- ext2fs_free_blocks_count_add(fs->super,
- -inuse * EXT2FS_CLUSTER_RATIO(fs));
+ fs->super->s_free_blocks_count -= inuse;
ext2fs_mark_super_dirty(fs);
ext2fs_mark_bb_dirty(fs);
if (fs->block_alloc_stats)
(fs->block_alloc_stats)(fs, (blk64_t) blk, inuse);
}
-void ext2fs_block_alloc_stats(ext2_filsys fs, blk_t blk, int inuse)
-{
- ext2fs_block_alloc_stats2(fs, blk, inuse);
-}
-
void ext2fs_set_block_alloc_stats_callback(ext2_filsys fs,
void (*func)(ext2_filsys fs,
blk64_t blk,
diff --git a/lib/ext2fs/alloc_tables.c b/lib/ext2fs/alloc_tables.c
index 885d2b23..46465af4 100644
--- a/lib/ext2fs/alloc_tables.c
+++ b/lib/ext2fs/alloc_tables.c
@@ -26,7 +26,6 @@
#include "ext2_fs.h"
#include "ext2fs.h"
-#include "ext2fsP.h"
/*
* This routine searches for free blocks that can allocate a full
@@ -34,46 +33,46 @@
* block number with a correct offset were the bitmaps and inode
* tables can be allocated continously and in order.
*/
-static blk64_t flexbg_offset(ext2_filsys fs, dgrp_t group, blk64_t start_blk,
- ext2fs_block_bitmap bmap, int rem_grp,
- int elem_size)
+static blk_t flexbg_offset(ext2_filsys fs, dgrp_t group, blk_t start_blk,
+ ext2fs_block_bitmap bmap, int offset, int size,
+ int elem_size)
{
- int flexbg, flexbg_size, size;
- blk64_t last_blk, first_free = 0;
+ int flexbg, flexbg_size;
+ blk_t last_blk, first_free = 0;
dgrp_t last_grp;
flexbg_size = 1 << fs->super->s_log_groups_per_flex;
flexbg = group / flexbg_size;
- size = rem_grp * elem_size;
if (size > (int) (fs->super->s_blocks_per_group / 8))
size = (int) fs->super->s_blocks_per_group / 8;
+ if (offset)
+ offset -= 1;
+
/*
* Don't do a long search if the previous block
* search is still valid.
*/
- if (start_blk && ext2fs_test_block_bitmap_range2(bmap, start_blk,
- elem_size))
- return start_blk;
+ if (start_blk && group % flexbg_size) {
+ if (ext2fs_test_block_bitmap_range(bmap, start_blk + elem_size,
+ size))
+ return start_blk + elem_size;
+ }
- start_blk = ext2fs_group_first_block2(fs, flexbg_size * flexbg);
+ start_blk = ext2fs_group_first_block(fs, flexbg_size * flexbg);
last_grp = group | (flexbg_size - 1);
- if (last_grp > fs->group_desc_count-1)
- last_grp = fs->group_desc_count-1;
- last_blk = ext2fs_group_last_block2(fs, last_grp);
+ if (last_grp > fs->group_desc_count)
+ last_grp = fs->group_desc_count;
+ last_blk = ext2fs_group_last_block(fs, last_grp);
/* Find the first available block */
- if (ext2fs_get_free_blocks2(fs, start_blk, last_blk, size,
- bmap, &first_free) == 0)
+ if (ext2fs_get_free_blocks(fs, start_blk, last_blk, 1, bmap,
+ &first_free))
return first_free;
- if (ext2fs_get_free_blocks2(fs, start_blk, last_blk, elem_size,
- bmap, &first_free) == 0)
- return first_free;
-
- if (ext2fs_get_free_blocks2(fs, 0, last_blk, elem_size, bmap,
- &first_free) == 0)
+ if (ext2fs_get_free_blocks(fs, first_free + offset, last_blk, size,
+ bmap, &first_free))
return first_free;
return first_free;
@@ -82,14 +81,13 @@ static blk64_t flexbg_offset(ext2_filsys fs, dgrp_t group, blk64_t start_blk,
errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
ext2fs_block_bitmap bmap)
{
- unsigned int j;
errcode_t retval;
- blk64_t group_blk, start_blk, last_blk, new_blk, blk;
+ blk_t group_blk, start_blk, last_blk, new_blk, blk;
dgrp_t last_grp = 0;
- int rem_grps = 0, flexbg_size = 0;
+ int j, rem_grps = 0, flexbg_size = 0;
- group_blk = ext2fs_group_first_block2(fs, group);
- last_blk = ext2fs_group_last_block2(fs, group);
+ group_blk = ext2fs_group_first_block(fs, group);
+ last_blk = ext2fs_group_last_block(fs, group);
if (!bmap)
bmap = fs->block_map;
@@ -99,17 +97,17 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
fs->super->s_log_groups_per_flex) {
flexbg_size = 1 << fs->super->s_log_groups_per_flex;
last_grp = group | (flexbg_size - 1);
- if (last_grp > fs->group_desc_count-1)
- last_grp = fs->group_desc_count-1;
- rem_grps = last_grp - group + 1;
+ rem_grps = last_grp - group;
+ if (last_grp > fs->group_desc_count)
+ last_grp = fs->group_desc_count;
}
/*
* Allocate the block and inode bitmaps, if necessary
*/
if (fs->stride) {
- retval = ext2fs_get_free_blocks2(fs, group_blk, last_blk,
- 1, bmap, &start_blk);
+ retval = ext2fs_get_free_blocks(fs, group_blk, last_blk,
+ 1, bmap, &start_blk);
if (retval)
return retval;
start_blk += fs->inode_blocks_per_group;
@@ -121,61 +119,57 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
start_blk = group_blk;
if (flexbg_size) {
- blk64_t prev_block = 0;
-
- if (group % flexbg_size)
- prev_block = ext2fs_block_bitmap_loc(fs, group - 1) + 1;
+ blk_t prev_block = 0;
+ if (group && fs->group_desc[group-1].bg_block_bitmap)
+ prev_block = fs->group_desc[group-1].bg_block_bitmap;
start_blk = flexbg_offset(fs, group, prev_block, bmap,
- rem_grps, 1);
- last_blk = ext2fs_group_last_block2(fs, last_grp);
+ 0, rem_grps, 1);
+ last_blk = ext2fs_group_last_block(fs, last_grp);
}
- if (!ext2fs_block_bitmap_loc(fs, group)) {
- retval = ext2fs_get_free_blocks2(fs, start_blk, last_blk,
- 1, bmap, &new_blk);
+ if (!fs->group_desc[group].bg_block_bitmap) {
+ retval = ext2fs_get_free_blocks(fs, start_blk, last_blk,
+ 1, bmap, &new_blk);
if (retval == EXT2_ET_BLOCK_ALLOC_FAIL)
- retval = ext2fs_get_free_blocks2(fs, group_blk,
+ retval = ext2fs_get_free_blocks(fs, group_blk,
last_blk, 1, bmap, &new_blk);
if (retval)
return retval;
- ext2fs_mark_block_bitmap2(bmap, new_blk);
- ext2fs_block_bitmap_loc_set(fs, group, new_blk);
+ ext2fs_mark_block_bitmap(bmap, new_blk);
+ fs->group_desc[group].bg_block_bitmap = new_blk;
if (flexbg_size) {
- dgrp_t gr = ext2fs_group_of_blk2(fs, new_blk);
- ext2fs_bg_free_blocks_count_set(fs, gr, ext2fs_bg_free_blocks_count(fs, gr) - 1);
- ext2fs_free_blocks_count_add(fs->super, -1);
- ext2fs_bg_flags_clear(fs, gr, EXT2_BG_BLOCK_UNINIT);
+ dgrp_t gr = ext2fs_group_of_blk(fs, new_blk);
+ fs->group_desc[gr].bg_free_blocks_count--;
+ fs->super->s_free_blocks_count--;
+ fs->group_desc[gr].bg_flags &= ~EXT2_BG_BLOCK_UNINIT;
ext2fs_group_desc_csum_set(fs, gr);
}
}
if (flexbg_size) {
- blk64_t prev_block = 0;
- if (group % flexbg_size)
- prev_block = ext2fs_inode_bitmap_loc(fs, group - 1) + 1;
- else
- prev_block = ext2fs_block_bitmap_loc(fs, group) +
- flexbg_size;
+ blk_t prev_block = 0;
+ if (group && fs->group_desc[group-1].bg_inode_bitmap)
+ prev_block = fs->group_desc[group-1].bg_inode_bitmap;
start_blk = flexbg_offset(fs, group, prev_block, bmap,
- rem_grps, 1);
- last_blk = ext2fs_group_last_block2(fs, last_grp);
+ flexbg_size, rem_grps, 1);
+ last_blk = ext2fs_group_last_block(fs, last_grp);
}
- if (!ext2fs_inode_bitmap_loc(fs, group)) {
- retval = ext2fs_get_free_blocks2(fs, start_blk, last_blk,
- 1, bmap, &new_blk);
+ if (!fs->group_desc[group].bg_inode_bitmap) {
+ retval = ext2fs_get_free_blocks(fs, start_blk, last_blk,
+ 1, bmap, &new_blk);
if (retval == EXT2_ET_BLOCK_ALLOC_FAIL)
- retval = ext2fs_get_free_blocks2(fs, group_blk,
- last_blk, 1, bmap, &new_blk);
+ retval = ext2fs_get_free_blocks(fs, group_blk,
+ last_blk, 1, bmap, &new_blk);
if (retval)
return retval;
- ext2fs_mark_block_bitmap2(bmap, new_blk);
- ext2fs_inode_bitmap_loc_set(fs, group, new_blk);
+ ext2fs_mark_block_bitmap(bmap, new_blk);
+ fs->group_desc[group].bg_inode_bitmap = new_blk;
if (flexbg_size) {
- dgrp_t gr = ext2fs_group_of_blk2(fs, new_blk);
- ext2fs_bg_free_blocks_count_set(fs, gr, ext2fs_bg_free_blocks_count(fs, gr) - 1);
- ext2fs_free_blocks_count_add(fs->super, -1);
- ext2fs_bg_flags_clear(fs, gr, EXT2_BG_BLOCK_UNINIT);
+ dgrp_t gr = ext2fs_group_of_blk(fs, new_blk);
+ fs->group_desc[gr].bg_free_blocks_count--;
+ fs->super->s_free_blocks_count--;
+ fs->group_desc[gr].bg_flags &= ~EXT2_BG_BLOCK_UNINIT;
ext2fs_group_desc_csum_set(fs, gr);
}
}
@@ -184,22 +178,21 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
* Allocate the inode table
*/
if (flexbg_size) {
- blk64_t prev_block = 0;
-
- if (group % flexbg_size)
- prev_block = ext2fs_inode_table_loc(fs, group - 1) +
- fs->inode_blocks_per_group;
- else
- prev_block = ext2fs_inode_bitmap_loc(fs, group) +
- flexbg_size;
-
+ blk_t prev_block = 0;
+ if (group && fs->group_desc[group-1].bg_inode_table)
+ prev_block = fs->group_desc[group-1].bg_inode_table;
+ if (last_grp == fs->group_desc_count)
+ rem_grps = last_grp - group;
group_blk = flexbg_offset(fs, group, prev_block, bmap,
- rem_grps, fs->inode_blocks_per_group);
- last_blk = ext2fs_group_last_block2(fs, last_grp);
+ flexbg_size * 2,
+ fs->inode_blocks_per_group *
+ rem_grps,
+ fs->inode_blocks_per_group);
+ last_blk = ext2fs_group_last_block(fs, last_grp);
}
- if (!ext2fs_inode_table_loc(fs, group)) {
- retval = ext2fs_get_free_blocks2(fs, group_blk, last_blk,
+ if (!fs->group_desc[group].bg_inode_table) {
+ retval = ext2fs_get_free_blocks(fs, group_blk, last_blk,
fs->inode_blocks_per_group,
bmap, &new_blk);
if (retval)
@@ -207,17 +200,16 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
for (j=0, blk = new_blk;
j < fs->inode_blocks_per_group;
j++, blk++) {
- ext2fs_mark_block_bitmap2(bmap, blk);
+ ext2fs_mark_block_bitmap(bmap, blk);
if (flexbg_size) {
- dgrp_t gr = ext2fs_group_of_blk2(fs, blk);
- ext2fs_bg_free_blocks_count_set(fs, gr, ext2fs_bg_free_blocks_count(fs, gr) - 1);
- ext2fs_free_blocks_count_add(fs->super, -1);
- ext2fs_bg_flags_clear(fs, gr,
- EXT2_BG_BLOCK_UNINIT);
+ dgrp_t gr = ext2fs_group_of_blk(fs, blk);
+ fs->group_desc[gr].bg_free_blocks_count--;
+ fs->super->s_free_blocks_count--;
+ fs->group_desc[gr].bg_flags &= ~EXT2_BG_BLOCK_UNINIT;
ext2fs_group_desc_csum_set(fs, gr);
}
}
- ext2fs_inode_table_loc_set(fs, group, new_blk);
+ fs->group_desc[group].bg_inode_table = new_blk;
}
ext2fs_group_desc_csum_set(fs, group);
return 0;
@@ -227,18 +219,12 @@ errcode_t ext2fs_allocate_tables(ext2_filsys fs)
{
errcode_t retval;
dgrp_t i;
- struct ext2fs_numeric_progress_struct progress;
-
- ext2fs_numeric_progress_init(fs, &progress, NULL,
- fs->group_desc_count);
for (i = 0; i < fs->group_desc_count; i++) {
- ext2fs_numeric_progress_update(fs, &progress, i);
retval = ext2fs_allocate_group_table(fs, i, fs->block_map);
if (retval)
return retval;
}
- ext2fs_numeric_progress_close(fs, &progress, NULL);
return 0;
}
diff --git a/lib/ext2fs/badblocks.c b/lib/ext2fs/badblocks.c
index 4312e190..5eb28b78 100644
--- a/lib/ext2fs/badblocks.c
+++ b/lib/ext2fs/badblocks.c
@@ -177,7 +177,7 @@ int ext2fs_u32_list_find(ext2_u32_list bb, __u32 blk)
return high;
while (low < high) {
- mid = ((unsigned)low + (unsigned)high)/2;
+ mid = (low+high)/2;
if (mid == low || mid == high)
break;
if (blk == bb->list[mid])
diff --git a/lib/ext2fs/bb_inode.c b/lib/ext2fs/bb_inode.c
index 0b6c3dd2..26266869 100644
--- a/lib/ext2fs/bb_inode.c
+++ b/lib/ext2fs/bb_inode.c
@@ -65,7 +65,8 @@ errcode_t ext2fs_update_bb_inode(ext2_filsys fs, ext2_badblocks_list bb_list)
if (!fs->block_map)
return EXT2_ET_NO_BLOCK_BITMAP;
- memset(&rec, 0, sizeof(rec));
+ rec.bad_block_count = 0;
+ rec.ind_blocks_size = rec.ind_blocks_ptr = 0;
rec.max_ind_blocks = 10;
retval = ext2fs_get_array(rec.max_ind_blocks, sizeof(blk_t),
&rec.ind_blocks);
@@ -165,7 +166,7 @@ static int clear_bad_block_proc(ext2_filsys fs, blk_t *block_nr,
/*
* If the block number is outrageous, clear it and ignore it.
*/
- if (*block_nr >= ext2fs_blocks_count(fs->super) ||
+ if (*block_nr >= fs->super->s_blocks_count ||
*block_nr < fs->super->s_first_data_block) {
*block_nr = 0;
return BLOCK_CHANGED;
@@ -190,7 +191,7 @@ static int clear_bad_block_proc(ext2_filsys fs, blk_t *block_nr,
/*
* Mark the block as unused, and update accounting information
*/
- ext2fs_block_alloc_stats2(fs, *block_nr, -1);
+ ext2fs_block_alloc_stats(fs, *block_nr, -1);
*block_nr = 0;
return BLOCK_CHANGED;
@@ -234,7 +235,7 @@ static int set_bad_block_proc(ext2_filsys fs, blk_t *block_nr,
retry:
if (rec->ind_blocks_ptr < rec->ind_blocks_size) {
blk = rec->ind_blocks[rec->ind_blocks_ptr++];
- if (ext2fs_test_block_bitmap2(fs->block_map, blk))
+ if (ext2fs_test_block_bitmap(fs->block_map, blk))
goto retry;
} else {
retval = ext2fs_new_block(fs, 0, 0, &blk);
@@ -243,7 +244,7 @@ static int set_bad_block_proc(ext2_filsys fs, blk_t *block_nr,
return BLOCK_ABORT;
}
}
- retval = io_channel_write_blk64(fs->io, blk, 1, rec->block_buf);
+ retval = io_channel_write_blk(fs->io, blk, 1, rec->block_buf);
if (retval) {
rec->err = retval;
return BLOCK_ABORT;
@@ -253,7 +254,7 @@ static int set_bad_block_proc(ext2_filsys fs, blk_t *block_nr,
/*
* Update block counts
*/
- ext2fs_block_alloc_stats2(fs, blk, +1);
+ ext2fs_block_alloc_stats(fs, blk, +1);
*block_nr = blk;
return BLOCK_CHANGED;
diff --git a/lib/ext2fs/bitmaps.c b/lib/ext2fs/bitmaps.c
index f215122f..649c524f 100644
--- a/lib/ext2fs/bitmaps.c
+++ b/lib/ext2fs/bitmaps.c
@@ -26,34 +26,33 @@
#include "ext2_fs.h"
#include "ext2fs.h"
-#include "ext2fsP.h"
-#include "bmap64.h"
void ext2fs_free_inode_bitmap(ext2fs_inode_bitmap bitmap)
{
- ext2fs_free_generic_bmap(bitmap);
+ ext2fs_free_generic_bitmap(bitmap);
}
void ext2fs_free_block_bitmap(ext2fs_block_bitmap bitmap)
{
- ext2fs_free_generic_bmap(bitmap);
+ ext2fs_free_generic_bitmap(bitmap);
}
errcode_t ext2fs_copy_bitmap(ext2fs_generic_bitmap src,
ext2fs_generic_bitmap *dest)
{
- return (ext2fs_copy_generic_bmap(src, dest));
+ return (ext2fs_copy_generic_bitmap(src, dest));
}
+
void ext2fs_set_bitmap_padding(ext2fs_generic_bitmap map)
{
- ext2fs_set_generic_bmap_padding(map);
+ ext2fs_set_generic_bitmap_padding(map);
}
errcode_t ext2fs_allocate_inode_bitmap(ext2_filsys fs,
const char *descr,
ext2fs_inode_bitmap *ret)
{
- __u64 start, end, real_end;
+ __u32 start, end, real_end;
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
@@ -63,116 +62,39 @@ errcode_t ext2fs_allocate_inode_bitmap(ext2_filsys fs,
end = fs->super->s_inodes_count;
real_end = (EXT2_INODES_PER_GROUP(fs->super) * fs->group_desc_count);
- /* Are we permitted to use new-style bitmaps? */
- if (fs->flags & EXT2_FLAG_64BITS)
- return (ext2fs_alloc_generic_bmap(fs,
- EXT2_ET_MAGIC_INODE_BITMAP64,
- fs->default_bitmap_type,
- start, end, real_end, descr, ret));
-
- /* Otherwise, check to see if the file system is small enough
- * to use old-style 32-bit bitmaps */
- if ((end > ~0U) || (real_end > ~0U))
- return EXT2_ET_CANT_USE_LEGACY_BITMAPS;
-
return (ext2fs_make_generic_bitmap(EXT2_ET_MAGIC_INODE_BITMAP, fs,
- start, end, real_end,
- descr, 0,
- (ext2fs_generic_bitmap *) ret));
+ start, end, real_end,
+ descr, 0, ret));
}
errcode_t ext2fs_allocate_block_bitmap(ext2_filsys fs,
const char *descr,
ext2fs_block_bitmap *ret)
{
- __u64 start, end, real_end;
+ __u32 start, end, real_end;
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
fs->write_bitmaps = ext2fs_write_bitmaps;
- start = EXT2FS_B2C(fs, fs->super->s_first_data_block);
- end = EXT2FS_B2C(fs, ext2fs_blocks_count(fs->super)-1);
- real_end = ((__u64) EXT2_CLUSTERS_PER_GROUP(fs->super)
- * (__u64) fs->group_desc_count)-1 + start;
-
- if (fs->flags & EXT2_FLAG_64BITS)
- return (ext2fs_alloc_generic_bmap(fs,
- EXT2_ET_MAGIC_BLOCK_BITMAP64,
- fs->default_bitmap_type,
- start, end, real_end, descr, ret));
-
- if ((end > ~0U) || (real_end > ~0U))
- return EXT2_ET_CANT_USE_LEGACY_BITMAPS;
+ start = fs->super->s_first_data_block;
+ end = fs->super->s_blocks_count-1;
+ real_end = (EXT2_BLOCKS_PER_GROUP(fs->super)
+ * fs->group_desc_count)-1 + start;
return (ext2fs_make_generic_bitmap(EXT2_ET_MAGIC_BLOCK_BITMAP, fs,
start, end, real_end,
- descr, 0,
- (ext2fs_generic_bitmap *) ret));
-}
-
-/*
- * ext2fs_allocate_block_bitmap() really allocates a per-cluster
- * bitmap for backwards compatibility. This function allocates a
- * block bitmap which is truly per-block, even if clusters/bigalloc
- * are enabled. mke2fs and e2fsck need this for tracking the
- * allocation of the file system metadata blocks.
- */
-errcode_t ext2fs_allocate_subcluster_bitmap(ext2_filsys fs,
- const char *descr,
- ext2fs_block_bitmap *ret)
-{
- __u64 start, end, real_end;
- ext2fs_generic_bitmap bmap;
- errcode_t retval;
-
- EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
-
- fs->write_bitmaps = ext2fs_write_bitmaps;
-
- if (!fs->cluster_ratio_bits)
- return ext2fs_allocate_block_bitmap(fs, descr, ret);
-
- if ((fs->flags & EXT2_FLAG_64BITS) == 0)
- return EXT2_ET_CANT_USE_LEGACY_BITMAPS;
-
- start = fs->super->s_first_data_block;
- end = ext2fs_blocks_count(fs->super)-1;
- real_end = ((__u64) EXT2_BLOCKS_PER_GROUP(fs->super)
- * (__u64) fs->group_desc_count)-1 + start;
-
- retval = ext2fs_alloc_generic_bmap(fs, EXT2_ET_MAGIC_BLOCK_BITMAP64,
- fs->default_bitmap_type, start,
- end, real_end, descr, &bmap);
- if (retval)
- return retval;
- bmap->cluster_bits = 0;
- *ret = bmap;
- return 0;
-}
-
-int ext2fs_get_bitmap_granularity(ext2fs_block_bitmap bitmap)
-{
- ext2fs_generic_bitmap bmap = bitmap;
-
- if (!EXT2FS_IS_64_BITMAP(bmap))
- return 0;
-
- return bmap->cluster_bits;
+ descr, 0, ret));
}
errcode_t ext2fs_fudge_inode_bitmap_end(ext2fs_inode_bitmap bitmap,
ext2_ino_t end, ext2_ino_t *oend)
{
- __u64 tmp_oend;
- int retval;
- retval = ext2fs_fudge_generic_bmap_end((ext2fs_generic_bitmap) bitmap,
- EXT2_ET_FUDGE_INODE_BITMAP_END,
- end, &tmp_oend);
- if (oend)
- *oend = tmp_oend;
- return retval;
+ return (ext2fs_fudge_generic_bitmap_end(bitmap,
+ EXT2_ET_MAGIC_INODE_BITMAP,
+ EXT2_ET_FUDGE_INODE_BITMAP_END,
+ end, oend));
}
errcode_t ext2fs_fudge_block_bitmap_end(ext2fs_block_bitmap bitmap,
@@ -184,22 +106,14 @@ errcode_t ext2fs_fudge_block_bitmap_end(ext2fs_block_bitmap bitmap,
end, oend));
}
-errcode_t ext2fs_fudge_block_bitmap_end2(ext2fs_block_bitmap bitmap,
- blk64_t end, blk64_t *oend)
-{
- return (ext2fs_fudge_generic_bmap_end(bitmap,
- EXT2_ET_FUDGE_BLOCK_BITMAP_END,
- end, oend));
-}
-
void ext2fs_clear_inode_bitmap(ext2fs_inode_bitmap bitmap)
{
- ext2fs_clear_generic_bmap(bitmap);
+ ext2fs_clear_generic_bitmap(bitmap);
}
void ext2fs_clear_block_bitmap(ext2fs_block_bitmap bitmap)
{
- ext2fs_clear_generic_bmap(bitmap);
+ ext2fs_clear_generic_bitmap(bitmap);
}
errcode_t ext2fs_resize_inode_bitmap(__u32 new_end, __u32 new_real_end,
@@ -209,12 +123,6 @@ errcode_t ext2fs_resize_inode_bitmap(__u32 new_end, __u32 new_real_end,
new_end, new_real_end, bmap));
}
-errcode_t ext2fs_resize_inode_bitmap2(__u64 new_end, __u64 new_real_end,
- ext2fs_inode_bitmap bmap)
-{
- return (ext2fs_resize_generic_bmap(bmap, new_end, new_real_end));
-}
-
errcode_t ext2fs_resize_block_bitmap(__u32 new_end, __u32 new_real_end,
ext2fs_block_bitmap bmap)
{
@@ -222,24 +130,20 @@ errcode_t ext2fs_resize_block_bitmap(__u32 new_end, __u32 new_real_end,
new_end, new_real_end, bmap));
}
-errcode_t ext2fs_resize_block_bitmap2(__u64 new_end, __u64 new_real_end,
- ext2fs_block_bitmap bmap)
-{
- return (ext2fs_resize_generic_bmap(bmap, new_end, new_real_end));
-}
-
errcode_t ext2fs_compare_block_bitmap(ext2fs_block_bitmap bm1,
ext2fs_block_bitmap bm2)
{
- return (ext2fs_compare_generic_bmap(EXT2_ET_NEQ_BLOCK_BITMAP,
- bm1, bm2));
+ return (ext2fs_compare_generic_bitmap(EXT2_ET_MAGIC_BLOCK_BITMAP,
+ EXT2_ET_NEQ_BLOCK_BITMAP,
+ bm1, bm2));
}
errcode_t ext2fs_compare_inode_bitmap(ext2fs_inode_bitmap bm1,
ext2fs_inode_bitmap bm2)
{
- return (ext2fs_compare_generic_bmap(EXT2_ET_NEQ_INODE_BITMAP,
- bm1, bm2));
+ return (ext2fs_compare_generic_bitmap(EXT2_ET_MAGIC_INODE_BITMAP,
+ EXT2_ET_NEQ_INODE_BITMAP,
+ bm1, bm2));
}
errcode_t ext2fs_set_inode_bitmap_range(ext2fs_inode_bitmap bmap,
@@ -251,13 +155,6 @@ errcode_t ext2fs_set_inode_bitmap_range(ext2fs_inode_bitmap bmap,
start, num, in));
}
-errcode_t ext2fs_set_inode_bitmap_range2(ext2fs_inode_bitmap bmap,
- __u64 start, size_t num,
- void *in)
-{
- return (ext2fs_set_generic_bmap_range(bmap, start, num, in));
-}
-
errcode_t ext2fs_get_inode_bitmap_range(ext2fs_inode_bitmap bmap,
ext2_ino_t start, unsigned int num,
void *out)
@@ -267,13 +164,6 @@ errcode_t ext2fs_get_inode_bitmap_range(ext2fs_inode_bitmap bmap,
start, num, out));
}
-errcode_t ext2fs_get_inode_bitmap_range2(ext2fs_inode_bitmap bmap,
- __u64 start, size_t num,
- void *out)
-{
- return (ext2fs_get_generic_bmap_range(bmap, start, num, out));
-}
-
errcode_t ext2fs_set_block_bitmap_range(ext2fs_block_bitmap bmap,
blk_t start, unsigned int num,
void *in)
@@ -283,13 +173,6 @@ errcode_t ext2fs_set_block_bitmap_range(ext2fs_block_bitmap bmap,
start, num, in));
}
-errcode_t ext2fs_set_block_bitmap_range2(ext2fs_block_bitmap bmap,
- blk64_t start, size_t num,
- void *in)
-{
- return (ext2fs_set_generic_bmap_range(bmap, start, num, in));
-}
-
errcode_t ext2fs_get_block_bitmap_range(ext2fs_block_bitmap bmap,
blk_t start, unsigned int num,
void *out)
@@ -298,10 +181,3 @@ errcode_t ext2fs_get_block_bitmap_range(ext2fs_block_bitmap bmap,
EXT2_ET_MAGIC_BLOCK_BITMAP,
start, num, out));
}
-
-errcode_t ext2fs_get_block_bitmap_range2(ext2fs_block_bitmap bmap,
- blk64_t start, size_t num,
- void *out)
-{
- return (ext2fs_get_generic_bmap_range(bmap, start, num, out));
-}
diff --git a/lib/ext2fs/bitops.c b/lib/ext2fs/bitops.c
index 42328478..d7db9049 100644
--- a/lib/ext2fs/bitops.c
+++ b/lib/ext2fs/bitops.c
@@ -76,82 +76,3 @@ void ext2fs_warn_bitmap(errcode_t errcode, unsigned long arg,
com_err(0, errcode, "#%lu", arg);
#endif
}
-
-/*
- * C-only 64 bit ops.
- */
-
-int ext2fs_set_bit64(__u64 nr, void * addr)
-{
- int mask, retval;
- unsigned char *ADDR = (unsigned char *) addr;
-
- ADDR += nr >> 3;
- mask = 1 << (nr & 0x07);
- retval = mask & *ADDR;
- *ADDR |= mask;
- return retval;
-}
-
-int ext2fs_clear_bit64(__u64 nr, void * addr)
-{
- int mask, retval;
- unsigned char *ADDR = (unsigned char *) addr;
-
- ADDR += nr >> 3;
- mask = 1 << (nr & 0x07);
- retval = mask & *ADDR;
- *ADDR &= ~mask;
- return retval;
-}
-
-int ext2fs_test_bit64(__u64 nr, const void * addr)
-{
- int mask;
- const unsigned char *ADDR = (const unsigned char *) addr;
-
- ADDR += nr >> 3;
- mask = 1 << (nr & 0x07);
- return (mask & *ADDR);
-}
-
-static unsigned int popcount8(unsigned int w)
-{
- unsigned int res = w - ((w >> 1) & 0x55);
- res = (res & 0x33) + ((res >> 2) & 0x33);
- return (res + (res >> 4)) & 0x0F;
-}
-
-static unsigned int popcount32(unsigned int w)
-{
- unsigned int res = w - ((w >> 1) & 0x55555555);
- res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
- res = (res + (res >> 4)) & 0x0F0F0F0F;
- res = res + (res >> 8);
- return (res + (res >> 16)) & 0x000000FF;
-}
-
-unsigned int ext2fs_bitcount(const void *addr, unsigned int nbytes)
-{
- const unsigned char *cp = addr;
- const __u32 *p;
- unsigned int res = 0;
-
- while (((((unsigned long) cp) & 3) != 0) && (nbytes > 0)) {
- res += popcount8(*cp++);
- nbytes--;
- }
- p = (const __u32 *) cp;
-
- while (nbytes > 4) {
- res += popcount32(*p++);
- nbytes -= 4;
- }
- cp = (const unsigned char *) p;
-
- while (nbytes > 0) {
- res += popcount8(*cp++);
- nbytes--;
- }
- return res;
-}
diff --git a/lib/ext2fs/bitops.h b/lib/ext2fs/bitops.h
index 3e8132de..ce705394 100644
--- a/lib/ext2fs/bitops.h
+++ b/lib/ext2fs/bitops.h
@@ -10,6 +10,15 @@
* %End-Header%
*/
+extern int ext2fs_set_bit(unsigned int nr,void * addr);
+extern int ext2fs_clear_bit(unsigned int nr, void * addr);
+extern int ext2fs_test_bit(unsigned int nr, const void * addr);
+extern void ext2fs_fast_set_bit(unsigned int nr,void * addr);
+extern void ext2fs_fast_clear_bit(unsigned int nr, void * addr);
+extern __u16 ext2fs_swab16(__u16 val);
+extern __u32 ext2fs_swab32(__u32 val);
+extern __u64 ext2fs_swab64(__u64 val);
+
#ifdef WORDS_BIGENDIAN
#define ext2fs_cpu_to_le64(x) ext2fs_swab64((x))
#define ext2fs_le64_to_cpu(x) ext2fs_swab64((x))
@@ -17,8 +26,6 @@
#define ext2fs_le32_to_cpu(x) ext2fs_swab32((x))
#define ext2fs_cpu_to_le16(x) ext2fs_swab16((x))
#define ext2fs_le16_to_cpu(x) ext2fs_swab16((x))
-#define ext2fs_cpu_to_be64(x) ((__u64)(x))
-#define ext2fs_be64_to_cpu(x) ((__u64)(x))
#define ext2fs_cpu_to_be32(x) ((__u32)(x))
#define ext2fs_be32_to_cpu(x) ((__u32)(x))
#define ext2fs_cpu_to_be16(x) ((__u16)(x))
@@ -30,8 +37,6 @@
#define ext2fs_le32_to_cpu(x) ((__u32)(x))
#define ext2fs_cpu_to_le16(x) ((__u16)(x))
#define ext2fs_le16_to_cpu(x) ((__u16)(x))
-#define ext2fs_cpu_to_be64(x) ext2fs_swab64((x))
-#define ext2fs_be64_to_cpu(x) ext2fs_swab64((x))
#define ext2fs_cpu_to_be32(x) ext2fs_swab32((x))
#define ext2fs_be32_to_cpu(x) ext2fs_swab32((x))
#define ext2fs_cpu_to_be16(x) ext2fs_swab16((x))
@@ -53,15 +58,6 @@ extern void ext2fs_warn_bitmap(errcode_t errcode, unsigned long arg,
extern void ext2fs_warn_bitmap2(ext2fs_generic_bitmap bitmap,
int code, unsigned long arg);
-#ifdef NO_INLINE_FUNCS
-extern void ext2fs_fast_set_bit(unsigned int nr,void * addr);
-extern void ext2fs_fast_clear_bit(unsigned int nr, void * addr);
-extern void ext2fs_fast_set_bit64(__u64 nr,void * addr);
-extern void ext2fs_fast_clear_bit64(__u64 nr, void * addr);
-extern __u16 ext2fs_swab16(__u16 val);
-extern __u32 ext2fs_swab32(__u32 val);
-extern __u64 ext2fs_swab64(__u64 val);
-
extern int ext2fs_mark_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block);
extern int ext2fs_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
blk_t block);
@@ -90,15 +86,6 @@ extern ext2_ino_t ext2fs_get_inode_bitmap_start(ext2fs_inode_bitmap bitmap);
extern blk_t ext2fs_get_block_bitmap_end(ext2fs_block_bitmap bitmap);
extern ext2_ino_t ext2fs_get_inode_bitmap_end(ext2fs_inode_bitmap bitmap);
-extern void ext2fs_fast_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
- blk_t block, int num);
-extern void ext2fs_fast_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
- blk_t block, int num);
-extern int ext2fs_fast_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
- blk_t block, int num);
-#endif
-
-/* These functions routines moved to gen_bitmap.c */
extern void ext2fs_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
blk_t block, int num);
extern void ext2fs_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
@@ -107,6 +94,15 @@ extern int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
blk_t block, int num);
extern int ext2fs_test_inode_bitmap_range(ext2fs_inode_bitmap bitmap,
ino_t inode, int num);
+extern void ext2fs_fast_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
+ blk_t block, int num);
+extern void ext2fs_fast_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
+ blk_t block, int num);
+extern int ext2fs_fast_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
+ blk_t block, int num);
+extern void ext2fs_set_bitmap_padding(ext2fs_generic_bitmap map);
+
+/* These routines moved to gen_bitmap.c */
extern int ext2fs_mark_generic_bitmap(ext2fs_generic_bitmap bitmap,
__u32 bitno);
extern int ext2fs_unmark_generic_bitmap(ext2fs_generic_bitmap bitmap,
@@ -115,90 +111,9 @@ extern int ext2fs_test_generic_bitmap(ext2fs_generic_bitmap bitmap,
blk_t bitno);
extern int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
blk_t block, int num);
-extern void ext2fs_set_bitmap_padding(ext2fs_generic_bitmap map);
extern __u32 ext2fs_get_generic_bitmap_start(ext2fs_generic_bitmap bitmap);
extern __u32 ext2fs_get_generic_bitmap_end(ext2fs_generic_bitmap bitmap);
-/* 64-bit versions */
-
-#ifdef NO_INLINE_FUNCS
-extern int ext2fs_mark_block_bitmap2(ext2fs_block_bitmap bitmap,
- blk64_t block);
-extern int ext2fs_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,
- blk64_t block);
-extern int ext2fs_test_block_bitmap2(ext2fs_block_bitmap bitmap,
- blk64_t block);
-
-extern int ext2fs_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
- ext2_ino_t inode);
-extern int ext2fs_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
- ext2_ino_t inode);
-extern int ext2fs_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,
- ext2_ino_t inode);
-
-extern void ext2fs_fast_mark_block_bitmap2(ext2fs_block_bitmap bitmap,
- blk64_t block);
-extern void ext2fs_fast_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,
- blk64_t block);
-extern int ext2fs_fast_test_block_bitmap2(ext2fs_block_bitmap bitmap,
- blk64_t block);
-
-extern void ext2fs_fast_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
- ext2_ino_t inode);
-extern void ext2fs_fast_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
- ext2_ino_t inode);
-extern int ext2fs_fast_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,
- ext2_ino_t inode);
-extern errcode_t ext2fs_find_first_zero_block_bitmap2(ext2fs_block_bitmap bitmap,
- blk64_t start,
- blk64_t end,
- blk64_t *out);
-extern errcode_t ext2fs_find_first_zero_inode_bitmap2(ext2fs_inode_bitmap bitmap,
- ext2_ino_t start,
- ext2_ino_t end,
- ext2_ino_t *out);
-extern blk64_t ext2fs_get_block_bitmap_start2(ext2fs_block_bitmap bitmap);
-extern ext2_ino_t ext2fs_get_inode_bitmap_start2(ext2fs_inode_bitmap bitmap);
-extern blk64_t ext2fs_get_block_bitmap_end2(ext2fs_block_bitmap bitmap);
-extern ext2_ino_t ext2fs_get_inode_bitmap_end2(ext2fs_inode_bitmap bitmap);
-
-extern int ext2fs_fast_test_block_bitmap_range2(ext2fs_block_bitmap bitmap,
- blk64_t block,
- unsigned int num);
-extern void ext2fs_fast_mark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
- blk64_t block,
- unsigned int num);
-extern void ext2fs_fast_unmark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
- blk64_t block,
- unsigned int num);
-#endif
-
-/* These routines moved to gen_bitmap64.c */
-extern void ext2fs_clear_generic_bmap(ext2fs_generic_bitmap bitmap);
-extern errcode_t ext2fs_compare_generic_bmap(errcode_t neq,
- ext2fs_generic_bitmap bm1,
- ext2fs_generic_bitmap bm2);
-extern void ext2fs_set_generic_bmap_padding(ext2fs_generic_bitmap bmap);
-extern int ext2fs_mark_generic_bmap(ext2fs_generic_bitmap bitmap,
- blk64_t bitno);
-extern int ext2fs_unmark_generic_bmap(ext2fs_generic_bitmap bitmap,
- blk64_t bitno);
-extern int ext2fs_test_generic_bmap(ext2fs_generic_bitmap bitmap,
- blk64_t bitno);
-extern int ext2fs_test_block_bitmap_range2(ext2fs_block_bitmap bitmap,
- blk64_t block, unsigned int num);
-extern __u64 ext2fs_get_generic_bmap_start(ext2fs_generic_bitmap bitmap);
-extern __u64 ext2fs_get_generic_bmap_end(ext2fs_generic_bitmap bitmap);
-extern int ext2fs_test_block_bitmap_range2(ext2fs_block_bitmap bitmap,
- blk64_t block, unsigned int num);
-extern void ext2fs_mark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
- blk64_t block, unsigned int num);
-extern void ext2fs_unmark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
- blk64_t block, unsigned int num);
-extern errcode_t ext2fs_find_first_zero_generic_bmap(ext2fs_generic_bitmap bitmap,
- __u64 start, __u64 end,
- __u64 *out);
-
/*
* The inline routines themselves...
*
@@ -208,7 +123,7 @@ extern errcode_t ext2fs_find_first_zero_generic_bmap(ext2fs_generic_bitmap bitma
*/
#ifdef NO_INLINE_FUNCS
#if (defined(__GNUC__) && (defined(__i386__) || defined(__i486__) || \
- defined(__i586__)))
+ defined(__i586__) || defined(__mc68000__)))
/* This prevents bitops.c from trying to include the C */
/* function version of these functions */
#define _EXT2_HAVE_ASM_BITOPS_
@@ -217,22 +132,14 @@ extern errcode_t ext2fs_find_first_zero_generic_bmap(ext2fs_generic_bitmap bitma
#if (defined(INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS))
#ifdef INCLUDE_INLINE_FUNCS
-#if (__STDC_VERSION__ >= 199901L)
-#define _INLINE_ extern inline
+#define _INLINE_ extern
#else
-#define _INLINE_ inline
-#endif
-#else /* !INCLUDE_INLINE FUNCS */
-#if (__STDC_VERSION__ >= 199901L)
-#define _INLINE_ inline
-#else /* not C99 */
#ifdef __GNUC__
#define _INLINE_ extern __inline__
#else /* For Watcom C */
#define _INLINE_ extern inline
-#endif /* __GNUC__ */
-#endif /* __STDC_VERSION__ >= 199901L */
-#endif /* INCLUDE_INLINE_FUNCS */
+#endif
+#endif
/*
* Fast bit set/clear functions that doesn't need to return the
@@ -244,7 +151,7 @@ _INLINE_ void ext2fs_fast_set_bit(unsigned int nr,void * addr)
unsigned char *ADDR = (unsigned char *) addr;
ADDR += nr >> 3;
- *ADDR |= (unsigned char) (1 << (nr & 0x07));
+ *ADDR |= (1 << (nr & 0x07));
}
_INLINE_ void ext2fs_fast_clear_bit(unsigned int nr, void * addr)
@@ -252,24 +159,7 @@ _INLINE_ void ext2fs_fast_clear_bit(unsigned int nr, void * addr)
unsigned char *ADDR = (unsigned char *) addr;
ADDR += nr >> 3;
- *ADDR &= (unsigned char) ~(1 << (nr & 0x07));
-}
-
-
-_INLINE_ void ext2fs_fast_set_bit64(__u64 nr, void * addr)
-{
- unsigned char *ADDR = (unsigned char *) addr;
-
- ADDR += nr >> 3;
- *ADDR |= (unsigned char) (1 << (nr & 0x07));
-}
-
-_INLINE_ void ext2fs_fast_clear_bit64(__u64 nr, void * addr)
-{
- unsigned char *ADDR = (unsigned char *) addr;
-
- ADDR += nr >> 3;
- *ADDR &= (unsigned char) ~(1 << (nr & 0x07));
+ *ADDR &= ~(1 << (nr & 0x07));
}
@@ -353,12 +243,49 @@ _INLINE_ __u16 ext2fs_swab16(__u16 val)
#endif /* i386 */
+#if ((defined __GNUC__) && !defined(_EXT2_USE_C_VERSIONS_) && \
+ (defined(__mc68000__)))
+
+#define _EXT2_HAVE_ASM_BITOPS_
+
+_INLINE_ int ext2fs_set_bit(unsigned int nr,void * addr)
+{
+ char retval;
+
+ __asm__ __volatile__ ("bfset %2@{%1:#1}; sne %0"
+ : "=d" (retval) : "d" (nr^7), "a" (addr));
+
+ return retval;
+}
+
+_INLINE_ int ext2fs_clear_bit(unsigned int nr, void * addr)
+{
+ char retval;
+
+ __asm__ __volatile__ ("bfclr %2@{%1:#1}; sne %0"
+ : "=d" (retval) : "d" (nr^7), "a" (addr));
+
+ return retval;
+}
+
+_INLINE_ int ext2fs_test_bit(unsigned int nr, const void * addr)
+{
+ char retval;
+
+ __asm__ __volatile__ ("bftst %2@{%1:#1}; sne %0"
+ : "=d" (retval) : "d" (nr^7), "a" (addr));
+
+ return retval;
+}
+
+#endif /* __mc68000__ */
+
#if !defined(_EXT2_HAVE_ASM_SWAB_)
_INLINE_ __u16 ext2fs_swab16(__u16 val)
{
- return (val >> 8) | (__u16) (val << 8);
+ return (val >> 8) | (val << 8);
}
_INLINE_ __u32 ext2fs_swab32(__u32 val)
@@ -371,7 +298,7 @@ _INLINE_ __u32 ext2fs_swab32(__u32 val)
_INLINE_ __u64 ext2fs_swab64(__u64 val)
{
- return (ext2fs_swab32((__u32) (val >> 32)) |
+ return (ext2fs_swab32(val >> 32) |
(((__u64)ext2fs_swab32(val & 0xFFFFFFFFUL)) << 32));
}
@@ -492,169 +419,6 @@ _INLINE_ void ext2fs_fast_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
{
ext2fs_unmark_block_bitmap_range(bitmap, block, num);
}
-
-/* 64-bit versions */
-
-_INLINE_ int ext2fs_mark_block_bitmap2(ext2fs_block_bitmap bitmap,
- blk64_t block)
-{
- return ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap,
- block);
-}
-
-_INLINE_ int ext2fs_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,
- blk64_t block)
-{
- return ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap, block);
-}
-
-_INLINE_ int ext2fs_test_block_bitmap2(ext2fs_block_bitmap bitmap,
- blk64_t block)
-{
- return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap,
- block);
-}
-
-_INLINE_ int ext2fs_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
- ext2_ino_t inode)
-{
- return ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap,
- inode);
-}
-
-_INLINE_ int ext2fs_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
- ext2_ino_t inode)
-{
- return ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap,
- inode);
-}
-
-_INLINE_ int ext2fs_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,
- ext2_ino_t inode)
-{
- return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap,
- inode);
-}
-
-_INLINE_ void ext2fs_fast_mark_block_bitmap2(ext2fs_block_bitmap bitmap,
- blk64_t block)
-{
- ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap, block);
-}
-
-_INLINE_ void ext2fs_fast_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,
- blk64_t block)
-{
- ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap, block);
-}
-
-_INLINE_ int ext2fs_fast_test_block_bitmap2(ext2fs_block_bitmap bitmap,
- blk64_t block)
-{
- return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap,
- block);
-}
-
-_INLINE_ void ext2fs_fast_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
- ext2_ino_t inode)
-{
- ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap, inode);
-}
-
-_INLINE_ void ext2fs_fast_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
- ext2_ino_t inode)
-{
- ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap, inode);
-}
-
-_INLINE_ int ext2fs_fast_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,
- ext2_ino_t inode)
-{
- return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap,
- inode);
-}
-
-_INLINE_ errcode_t ext2fs_find_first_zero_block_bitmap2(ext2fs_block_bitmap bitmap,
- blk64_t start,
- blk64_t end,
- blk64_t *out)
-{
- __u64 o;
- errcode_t rv;
-
- rv = ext2fs_find_first_zero_generic_bmap((ext2fs_generic_bitmap) bitmap,
- start, end, &o);
- if (!rv)
- *out = o;
- return rv;
-}
-
-_INLINE_ errcode_t ext2fs_find_first_zero_inode_bitmap2(ext2fs_inode_bitmap bitmap,
- ext2_ino_t start,
- ext2_ino_t end,
- ext2_ino_t *out)
-{
- __u64 o;
- errcode_t rv;
-
- rv = ext2fs_find_first_zero_generic_bmap((ext2fs_generic_bitmap) bitmap,
- start, end, &o);
- if (!rv)
- *out = (ext2_ino_t) o;
- return rv;
-}
-
-_INLINE_ blk64_t ext2fs_get_block_bitmap_start2(ext2fs_block_bitmap bitmap)
-{
- return ext2fs_get_generic_bmap_start((ext2fs_generic_bitmap) bitmap);
-}
-
-_INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_start2(ext2fs_inode_bitmap bitmap)
-{
- return (ext2_ino_t) ext2fs_get_generic_bmap_start((ext2fs_generic_bitmap) bitmap);
-}
-
-_INLINE_ blk64_t ext2fs_get_block_bitmap_end2(ext2fs_block_bitmap bitmap)
-{
- return ext2fs_get_generic_bmap_end((ext2fs_generic_bitmap) bitmap);
-}
-
-_INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_end2(ext2fs_inode_bitmap bitmap)
-{
- return (ext2_ino_t) ext2fs_get_generic_bmap_end((ext2fs_generic_bitmap) bitmap);
-}
-
-_INLINE_ int ext2fs_fast_test_block_bitmap_range2(ext2fs_block_bitmap bitmap,
- blk64_t block,
- unsigned int num)
-{
- return ext2fs_test_block_bitmap_range2(bitmap, block, num);
-}
-
-_INLINE_ void ext2fs_fast_mark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
- blk64_t block,
- unsigned int num)
-{
- ext2fs_mark_block_bitmap_range2(bitmap, block, num);
-}
-
-_INLINE_ void ext2fs_fast_unmark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
- blk64_t block,
- unsigned int num)
-{
- ext2fs_unmark_block_bitmap_range2(bitmap, block, num);
-}
-
#undef _INLINE_
#endif
-#ifndef _EXT2_HAVE_ASM_BITOPS_
-extern int ext2fs_set_bit(unsigned int nr,void * addr);
-extern int ext2fs_clear_bit(unsigned int nr, void * addr);
-extern int ext2fs_test_bit(unsigned int nr, const void * addr);
-#endif
-
-extern int ext2fs_set_bit64(__u64 nr,void * addr);
-extern int ext2fs_clear_bit64(__u64 nr, void * addr);
-extern int ext2fs_test_bit64(__u64 nr, const void * addr);
-extern unsigned int ext2fs_bitcount(const void *addr, unsigned int nbytes);
diff --git a/lib/ext2fs/blkmap64_ba.c b/lib/ext2fs/blkmap64_ba.c
deleted file mode 100644
index 72ef3ebd..00000000
--- a/lib/ext2fs/blkmap64_ba.c
+++ /dev/null
@@ -1,416 +0,0 @@
-/*
- * blkmap64_ba.c --- Simple bitarray implementation for bitmaps
- *
- * Copyright (C) 2008 Theodore Ts'o.
- *
- * %Begin-Header%
- * This file may be redistributed under the terms of the GNU Public
- * License.
- * %End-Header%
- */
-
-#include <stdio.h>
-#include <string.h>
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <fcntl.h>
-#include <time.h>
-#if HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#include "ext2_fs.h"
-#include "ext2fsP.h"
-#include "bmap64.h"
-
-/*
- * Private data for bit array implementation of bitmap ops.
- * Currently, this is just a pointer to our big flat hunk of memory,
- * exactly equivalent to the old-skool char * bitmap member.
- */
-
-struct ext2fs_ba_private_struct {
- char *bitarray;
-};
-
-typedef struct ext2fs_ba_private_struct *ext2fs_ba_private;
-
-static errcode_t ba_alloc_private_data (ext2fs_generic_bitmap bitmap)
-{
- ext2fs_ba_private bp;
- errcode_t retval;
- size_t size;
-
- /*
- * Since we only have the one pointer, we could just shove our
- * private data in the void *private field itself, but then
- * we'd have to do a fair bit of rewriting if we ever added a
- * field. I'm agnostic.
- */
- retval = ext2fs_get_mem(sizeof (ext2fs_ba_private), &bp);
- if (retval)
- return retval;
-
- size = (size_t) (((bitmap->real_end - bitmap->start) / 8) + 1);
-
- retval = ext2fs_get_mem(size, &bp->bitarray);
- if (retval) {
- ext2fs_free_mem(&bp);
- bp = 0;
- return retval;
- }
- bitmap->private = (void *) bp;
- return 0;
-}
-
-static errcode_t ba_new_bmap(ext2_filsys fs EXT2FS_ATTR((unused)),
- ext2fs_generic_bitmap bitmap)
-{
- ext2fs_ba_private bp;
- errcode_t retval;
- size_t size;
-
- retval = ba_alloc_private_data (bitmap);
- if (retval)
- return retval;
-
- bp = (ext2fs_ba_private) bitmap->private;
- size = (size_t) (((bitmap->real_end - bitmap->start) / 8) + 1);
- memset(bp->bitarray, 0, size);
-
- return 0;
-}
-
-static void ba_free_bmap(ext2fs_generic_bitmap bitmap)
-{
- ext2fs_ba_private bp = (ext2fs_ba_private) bitmap->private;
-
- if (!bp)
- return;
-
- if (bp->bitarray) {
- ext2fs_free_mem (&bp->bitarray);
- bp->bitarray = 0;
- }
- ext2fs_free_mem (&bp);
- bp = 0;
-}
-
-static errcode_t ba_copy_bmap(ext2fs_generic_bitmap src,
- ext2fs_generic_bitmap dest)
-{
- ext2fs_ba_private src_bp = (ext2fs_ba_private) src->private;
- ext2fs_ba_private dest_bp;
- errcode_t retval;
- size_t size;
-
- retval = ba_alloc_private_data (dest);
- if (retval)
- return retval;
-
- dest_bp = (ext2fs_ba_private) dest->private;
-
- size = (size_t) (((src->real_end - src->start) / 8) + 1);
- memcpy (dest_bp->bitarray, src_bp->bitarray, size);
-
- return 0;
-}
-
-static errcode_t ba_resize_bmap(ext2fs_generic_bitmap bmap,
- __u64 new_end, __u64 new_real_end)
-{
- ext2fs_ba_private bp = (ext2fs_ba_private) bmap->private;
- errcode_t retval;
- size_t size, new_size;
- __u64 bitno;
-
- /*
- * If we're expanding the bitmap, make sure all of the new
- * parts of the bitmap are zero.
- */
- if (new_end > bmap->end) {
- bitno = bmap->real_end;
- if (bitno > new_end)
- bitno = new_end;
- for (; bitno > bmap->end; bitno--)
- ext2fs_clear_bit64(bitno - bmap->start, bp->bitarray);
- }
- if (new_real_end == bmap->real_end) {
- bmap->end = new_end;
- return 0;
- }
-
- size = ((bmap->real_end - bmap->start) / 8) + 1;
- new_size = ((new_real_end - bmap->start) / 8) + 1;
-
- if (size != new_size) {
- retval = ext2fs_resize_mem(size, new_size, &bp->bitarray);
- if (retval)
- return retval;
- }
- if (new_size > size)
- memset(bp->bitarray + size, 0, new_size - size);
-
- bmap->end = new_end;
- bmap->real_end = new_real_end;
- return 0;
-
-}
-
-static int ba_mark_bmap(ext2fs_generic_bitmap bitmap, __u64 arg)
-{
- ext2fs_ba_private bp = (ext2fs_ba_private) bitmap->private;
- blk64_t bitno = (blk64_t) arg;
-
- return ext2fs_set_bit64(bitno - bitmap->start, bp->bitarray);
-}
-
-static int ba_unmark_bmap(ext2fs_generic_bitmap bitmap, __u64 arg)
-{
- ext2fs_ba_private bp = (ext2fs_ba_private) bitmap->private;
- blk64_t bitno = (blk64_t) arg;
-
- return ext2fs_clear_bit64(bitno - bitmap->start, bp->bitarray);
-}
-
-static int ba_test_bmap(ext2fs_generic_bitmap bitmap, __u64 arg)
-{
- ext2fs_ba_private bp = (ext2fs_ba_private) bitmap->private;
- blk64_t bitno = (blk64_t) arg;
-
- return ext2fs_test_bit64(bitno - bitmap->start, bp->bitarray);
-}
-
-static void ba_mark_bmap_extent(ext2fs_generic_bitmap bitmap, __u64 arg,
- unsigned int num)
-{
- ext2fs_ba_private bp = (ext2fs_ba_private) bitmap->private;
- blk64_t bitno = (blk64_t) arg;
- unsigned int i;
-
- for (i = 0; i < num; i++)
- ext2fs_fast_set_bit64(bitno + i - bitmap->start, bp->bitarray);
-}
-
-static void ba_unmark_bmap_extent(ext2fs_generic_bitmap bitmap, __u64 arg,
- unsigned int num)
-{
- ext2fs_ba_private bp = (ext2fs_ba_private) bitmap->private;
- blk64_t bitno = (blk64_t) arg;
- unsigned int i;
-
- for (i = 0; i < num; i++)
- ext2fs_fast_clear_bit64(bitno + i - bitmap->start, bp->bitarray);
-}
-
-static int ba_test_clear_bmap_extent(ext2fs_generic_bitmap bitmap,
- __u64 start, unsigned int len)
-{
- ext2fs_ba_private bp = (ext2fs_ba_private) bitmap->private;
- __u64 start_byte, len_byte = len >> 3;
- unsigned int start_bit, len_bit = len % 8;
- unsigned int first_bit = 0;
- unsigned int last_bit = 0;
- int mark_count = 0;
- int mark_bit = 0;
- int i;
- const char *ADDR;
-
- ADDR = bp->bitarray;
- start -= bitmap->start;
- start_byte = start >> 3;
- start_bit = start % 8;
-
- if (start_bit != 0) {
- /*
- * The compared start block number or start inode number
- * is not the first bit in a byte.
- */
- mark_count = 8 - start_bit;
- if (len < 8 - start_bit) {
- mark_count = (int)len;
- mark_bit = len + start_bit - 1;
- } else
- mark_bit = 7;
-
- for (i = mark_count; i > 0; i--, mark_bit--)
- first_bit |= 1 << mark_bit;
-
- /*
- * Compare blocks or inodes in the first byte.
- * If there is any marked bit, this function returns 0.
- */
- if (first_bit & ADDR[start_byte])
- return 0;
- else if (len <= 8 - start_bit)
- return 1;
-
- start_byte++;
- len_bit = (len - mark_count) % 8;
- len_byte = (len - mark_count) >> 3;
- }
-
- /*
- * The compared start block number or start inode number is
- * the first bit in a byte.
- */
- if (len_bit != 0) {
- /*
- * The compared end block number or end inode number is
- * not the last bit in a byte.
- */
- for (mark_bit = len_bit - 1; mark_bit >= 0; mark_bit--)
- last_bit |= 1 << mark_bit;
-
- /*
- * Compare blocks or inodes in the last byte.
- * If there is any marked bit, this function returns 0.
- */
- if (last_bit & ADDR[start_byte + len_byte])
- return 0;
- else if (len_byte == 0)
- return 1;
- }
-
- /* Check whether all bytes are 0 */
- return ext2fs_mem_is_zero(ADDR + start_byte, len_byte);
-}
-
-
-static errcode_t ba_set_bmap_range(ext2fs_generic_bitmap bitmap,
- __u64 start, size_t num, void *in)
-{
- ext2fs_ba_private bp = (ext2fs_ba_private) bitmap->private;
-
- memcpy (bp->bitarray + (start >> 3), in, (num + 7) >> 3);
-
- return 0;
-}
-
-static errcode_t ba_get_bmap_range(ext2fs_generic_bitmap bitmap,
- __u64 start, size_t num, void *out)
-{
- ext2fs_ba_private bp = (ext2fs_ba_private) bitmap->private;
-
- memcpy (out, bp->bitarray + (start >> 3), (num + 7) >> 3);
-
- return 0;
-}
-
-static void ba_clear_bmap(ext2fs_generic_bitmap bitmap)
-{
- ext2fs_ba_private bp = (ext2fs_ba_private) bitmap->private;
-
- memset(bp->bitarray, 0,
- (size_t) (((bitmap->real_end - bitmap->start) / 8) + 1));
-}
-
-static void ba_print_stats(ext2fs_generic_bitmap bitmap)
-{
- fprintf(stderr, "%16llu Bytes used by bitarray\n",
- ((bitmap->real_end - bitmap->start) >> 3) + 1 +
- sizeof(struct ext2fs_ba_private_struct));
-}
-
-/* Find the first zero bit between start and end, inclusive. */
-static errcode_t ba_find_first_zero(ext2fs_generic_bitmap bitmap,
- __u64 start, __u64 end, __u64 *out)
-{
- ext2fs_ba_private bp = (ext2fs_ba_private)bitmap->private;
- unsigned long bitpos = start - bitmap->start;
- unsigned long count = end - start + 1;
- int byte_found = 0; /* whether a != 0xff byte has been found */
- const unsigned char *pos;
- unsigned long max_loop_count, i;
-
- if (start < bitmap->start || end > bitmap->end || start > end)
- return EINVAL;
-
- if (bitmap->cluster_bits)
- return EINVAL;
-
- /* scan bits until we hit a byte boundary */
- while ((bitpos & 0x7) != 0 && count > 0) {
- if (!ext2fs_test_bit64(bitpos, bp->bitarray)) {
- *out = bitpos + bitmap->start;
- return 0;
- }
- bitpos++;
- count--;
- }
-
- if (!count)
- return ENOENT;
-
- pos = ((unsigned char *)bp->bitarray) + (bitpos >> 3);
- /* scan bytes until 8-byte (64-bit) aligned */
- while (count >= 8 && (((unsigned long)pos) & 0x07)) {
- if (*pos != 0xff) {
- byte_found = 1;
- break;
- }
- pos++;
- count -= 8;
- bitpos += 8;
- }
-
- if (!byte_found) {
- max_loop_count = count >> 6; /* 8-byte blocks */
- i = max_loop_count;
- while (i) {
- if (*((const __u64 *)pos) != ((__u64)-1))
- break;
- pos += 8;
- i--;
- }
- count -= 64 * (max_loop_count - i);
- bitpos += 64 * (max_loop_count - i);
-
- max_loop_count = count >> 3;
- i = max_loop_count;
- while (i) {
- if (*pos != 0xff) {
- byte_found = 1;
- break;
- }
- pos++;
- i--;
- }
- count -= 8 * (max_loop_count - i);
- bitpos += 8 * (max_loop_count - i);
- }
-
- /* Here either count < 8 or byte_found == 1. */
- while (count-- > 0) {
- if (!ext2fs_test_bit64(bitpos, bp->bitarray)) {
- *out = bitpos + bitmap->start;
- return 0;
- }
- bitpos++;
- }
-
- return ENOENT;
-}
-
-struct ext2_bitmap_ops ext2fs_blkmap64_bitarray = {
- .type = EXT2FS_BMAP64_BITARRAY,
- .new_bmap = ba_new_bmap,
- .free_bmap = ba_free_bmap,
- .copy_bmap = ba_copy_bmap,
- .resize_bmap = ba_resize_bmap,
- .mark_bmap = ba_mark_bmap,
- .unmark_bmap = ba_unmark_bmap,
- .test_bmap = ba_test_bmap,
- .test_clear_bmap_extent = ba_test_clear_bmap_extent,
- .mark_bmap_extent = ba_mark_bmap_extent,
- .unmark_bmap_extent = ba_unmark_bmap_extent,
- .set_bmap_range = ba_set_bmap_range,
- .get_bmap_range = ba_get_bmap_range,
- .clear_bmap = ba_clear_bmap,
- .print_stats = ba_print_stats,
- .find_first_zero = ba_find_first_zero
-};
diff --git a/lib/ext2fs/blkmap64_rb.c b/lib/ext2fs/blkmap64_rb.c
deleted file mode 100644
index a22682e8..00000000
--- a/lib/ext2fs/blkmap64_rb.c
+++ /dev/null
@@ -1,886 +0,0 @@
-/*
- * blkmap64_rb.c --- Simple rb-tree implementation for bitmaps
- *
- * (C)2010 Red Hat, Inc., Lukas Czerner <lczerner@redhat.com>
- *
- * %Begin-Header%
- * This file may be redistributed under the terms of the GNU Public
- * License.
- * %End-Header%
- */
-
-#include <stdio.h>
-#include <string.h>
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <fcntl.h>
-#include <time.h>
-#if HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#include "ext2_fs.h"
-#include "ext2fsP.h"
-#include "bmap64.h"
-#include "rbtree.h"
-
-#include <limits.h>
-
-struct bmap_rb_extent {
- struct rb_node node;
- __u64 start;
- __u64 count;
-};
-
-struct ext2fs_rb_private {
- struct rb_root root;
- struct bmap_rb_extent *wcursor;
- struct bmap_rb_extent *rcursor;
- struct bmap_rb_extent *rcursor_next;
-#ifdef BMAP_STATS_OPS
- __u64 mark_hit;
- __u64 test_hit;
-#endif
-};
-
-inline static struct bmap_rb_extent *node_to_extent(struct rb_node *node)
-{
- /*
- * This depends on the fact the struct rb_node is at the
- * beginning of the bmap_rb_extent structure. We use this
- * instead of the ext2fs_rb_entry macro because it causes gcc
- * -Wall to generate a huge amount of noise.
- */
- return (struct bmap_rb_extent *) node;
-}
-
-static int rb_insert_extent(__u64 start, __u64 count,
- struct ext2fs_rb_private *);
-static void rb_get_new_extent(struct bmap_rb_extent **, __u64, __u64);
-
-/* #define DEBUG_RB */
-
-#ifdef DEBUG_RB
-static void print_tree(struct rb_root *root)
-{
- struct rb_node *node = NULL;
- struct bmap_rb_extent *ext;
-
- printf("\t\t\t=================================\n");
- node = ext2fs_rb_first(root);
- for (node = ext2fs_rb_first(root); node != NULL;
- node = ext2fs_rb_next(node)) {
- ext = node_to_extent(node);
- printf("\t\t\t--> (%llu -> %llu)\n",
- ext->start, ext->start + ext->count);
- }
- printf("\t\t\t=================================\n");
-}
-
-static void check_tree(struct rb_root *root, const char *msg)
-{
- struct rb_node *new_node, *node, *next;
- struct bmap_rb_extent *ext, *old = NULL;
-
- for (node = ext2fs_rb_first(root); node;
- node = ext2fs_rb_next(node)) {
- ext = node_to_extent(node);
- if (ext->count <= 0) {
- printf("Tree Error: count is crazy\n");
- printf("extent: %llu -> %llu (%u)\n", ext->start,
- ext->start + ext->count, ext->count);
- goto err_out;
- }
- if (ext->start < 0) {
- printf("Tree Error: start is crazy\n");
- printf("extent: %llu -> %llu (%u)\n", ext->start,
- ext->start + ext->count, ext->count);
- goto err_out;
- }
-
- if (old) {
- if (old->start > ext->start) {
- printf("Tree Error: start is crazy\n");
- printf("extent: %llu -> %llu (%u)\n",
- old->start, old->start + old->count,
- old->count);
- printf("extent next: %llu -> %llu (%u)\n",
- ext->start, ext->start + ext->count,
- ext->count);
- goto err_out;
- }
- if ((old->start + old->count) >= ext->start) {
- printf("Tree Error: extent is crazy\n");
- printf("extent: %llu -> %llu (%u)\n",
- old->start, old->start + old->count,
- old->count);
- printf("extent next: %llu -> %llu (%u)\n",
- ext->start, ext->start + ext->count,
- ext->count);
- goto err_out;
- }
- }
- old = ext;
- }
- return;
-
-err_out:
- printf("%s\n", msg);
- print_tree(root);
- exit(1);
-}
-#else
-#define check_tree(root, msg) do {} while (0)
-#define print_tree(root, msg) do {} while (0)
-#endif
-
-static void rb_get_new_extent(struct bmap_rb_extent **ext, __u64 start,
- __u64 count)
-{
- struct bmap_rb_extent *new_ext;
- int retval;
-
- retval = ext2fs_get_mem(sizeof (struct bmap_rb_extent),
- &new_ext);
- if (retval) {
- perror("ext2fs_get_mem");
- exit(1);
- }
-
- new_ext->start = start;
- new_ext->count = count;
- *ext = new_ext;
-}
-
-inline
-static void rb_free_extent(struct ext2fs_rb_private *bp,
- struct bmap_rb_extent *ext)
-{
- if (bp->wcursor == ext)
- bp->wcursor = NULL;
- if (bp->rcursor == ext)
- bp->rcursor = NULL;
- if (bp->rcursor_next == ext)
- bp->rcursor_next = NULL;
- ext2fs_free_mem(&ext);
-}
-
-static errcode_t rb_alloc_private_data (ext2fs_generic_bitmap bitmap)
-{
- struct ext2fs_rb_private *bp;
- errcode_t retval;
-
- retval = ext2fs_get_mem(sizeof (struct ext2fs_rb_private), &bp);
- if (retval)
- return retval;
-
- bp->root = RB_ROOT;
- bp->rcursor = NULL;
- bp->rcursor_next = NULL;
- bp->wcursor = NULL;
-
-#ifdef BMAP_STATS_OPS
- bp->test_hit = 0;
- bp->mark_hit = 0;
-#endif
-
- bitmap->private = (void *) bp;
- return 0;
-}
-
-static errcode_t rb_new_bmap(ext2_filsys fs EXT2FS_ATTR((unused)),
- ext2fs_generic_bitmap bitmap)
-{
- errcode_t retval;
-
- retval = rb_alloc_private_data (bitmap);
- if (retval)
- return retval;
-
- return 0;
-}
-
-static void rb_free_tree(struct rb_root *root)
-{
- struct bmap_rb_extent *ext;
- struct rb_node *node, *next;
-
- for (node = ext2fs_rb_first(root); node; node = next) {
- next = ext2fs_rb_next(node);
- ext = node_to_extent(node);
- ext2fs_rb_erase(node, root);
- ext2fs_free_mem(&ext);
- }
-}
-
-static void rb_free_bmap(ext2fs_generic_bitmap bitmap)
-{
- struct ext2fs_rb_private *bp;
-
- bp = (struct ext2fs_rb_private *) bitmap->private;
-
- rb_free_tree(&bp->root);
- ext2fs_free_mem(&bp);
- bp = 0;
-}
-
-static errcode_t rb_copy_bmap(ext2fs_generic_bitmap src,
- ext2fs_generic_bitmap dest)
-{
- struct ext2fs_rb_private *src_bp, *dest_bp;
- struct bmap_rb_extent *src_ext, *dest_ext;
- struct rb_node *dest_node, *src_node, *dest_last, **n;
- errcode_t retval = 0;
-
- retval = rb_alloc_private_data (dest);
- if (retval)
- return retval;
-
- src_bp = (struct ext2fs_rb_private *) src->private;
- dest_bp = (struct ext2fs_rb_private *) dest->private;
- src_bp->rcursor = NULL;
- dest_bp->rcursor = NULL;
-
- src_node = ext2fs_rb_first(&src_bp->root);
- while (src_node) {
- src_ext = node_to_extent(src_node);
- retval = ext2fs_get_mem(sizeof (struct bmap_rb_extent),
- &dest_ext);
- if (retval)
- break;
-
- memcpy(dest_ext, src_ext, sizeof(struct bmap_rb_extent));
-
- dest_node = &dest_ext->node;
- n = &dest_bp->root.rb_node;
-
- dest_last = NULL;
- if (*n) {
- dest_last = ext2fs_rb_last(&dest_bp->root);
- n = &(dest_last)->rb_right;
- }
-
- ext2fs_rb_link_node(dest_node, dest_last, n);
- ext2fs_rb_insert_color(dest_node, &dest_bp->root);
-
- src_node = ext2fs_rb_next(src_node);
- }
-
- return retval;
-}
-
-static void rb_truncate(__u64 new_max, struct rb_root *root)
-{
- struct bmap_rb_extent *ext;
- struct rb_node *node;
-
- node = ext2fs_rb_last(root);
- while (node) {
- ext = node_to_extent(node);
-
- if ((ext->start + ext->count - 1) <= new_max)
- break;
- else if (ext->start > new_max) {
- ext2fs_rb_erase(node, root);
- ext2fs_free_mem(&ext);
- node = ext2fs_rb_last(root);
- continue;
- } else
- ext->count = new_max - ext->start + 1;
- }
-}
-
-static errcode_t rb_resize_bmap(ext2fs_generic_bitmap bmap,
- __u64 new_end, __u64 new_real_end)
-{
- struct ext2fs_rb_private *bp;
-
- if (new_real_end >= bmap->real_end) {
- bmap->end = new_end;
- bmap->real_end = new_real_end;
- return 0;
- }
-
- bp = (struct ext2fs_rb_private *) bmap->private;
- bp->rcursor = NULL;
- bp->wcursor = NULL;
-
- /* truncate tree to new_real_end size */
- rb_truncate(new_real_end, &bp->root);
-
- bmap->end = new_end;
- bmap->real_end = new_real_end;
- return 0;
-
-}
-
-inline static int
-rb_test_bit(struct ext2fs_rb_private *bp, __u64 bit)
-{
- struct bmap_rb_extent *rcursor, *next_ext = NULL;
- struct rb_node *parent = NULL, *next;
- struct rb_node **n = &bp->root.rb_node;
- struct bmap_rb_extent *ext;
-
- rcursor = bp->rcursor;
- if (!rcursor)
- goto search_tree;
-
- if (bit >= rcursor->start && bit < rcursor->start + rcursor->count) {
-#ifdef BMAP_STATS_OPS
- bp->test_hit++;
-#endif
- return 1;
- }
-
- next_ext = bp->rcursor_next;
- if (!next_ext) {
- next = ext2fs_rb_next(&rcursor->node);
- if (next)
- next_ext = node_to_extent(next);
- bp->rcursor_next = next_ext;
- }
- if (next_ext) {
- if ((bit >= rcursor->start + rcursor->count) &&
- (bit < next_ext->start)) {
-#ifdef BMAP_STATS_OPS
- bp->test_hit++;
-#endif
- return 0;
- }
- }
- bp->rcursor = NULL;
- bp->rcursor_next = NULL;
-
- rcursor = bp->wcursor;
- if (!rcursor)
- goto search_tree;
-
- if (bit >= rcursor->start && bit < rcursor->start + rcursor->count)
- return 1;
-
-search_tree:
-
- while (*n) {
- parent = *n;
- ext = node_to_extent(parent);
- if (bit < ext->start)
- n = &(*n)->rb_left;
- else if (bit >= (ext->start + ext->count))
- n = &(*n)->rb_right;
- else {
- bp->rcursor = ext;
- bp->rcursor_next = NULL;
- return 1;
- }
- }
- return 0;
-}
-
-static int rb_insert_extent(__u64 start, __u64 count,
- struct ext2fs_rb_private *bp)
-{
- struct rb_root *root = &bp->root;
- struct rb_node *parent = NULL, **n = &root->rb_node;
- struct rb_node *new_node, *node, *next;
- struct bmap_rb_extent *new_ext;
- struct bmap_rb_extent *ext;
- int retval = 0;
-
- bp->rcursor_next = NULL;
- ext = bp->wcursor;
- if (ext) {
- if (start >= ext->start &&
- start <= (ext->start + ext->count)) {
-#ifdef BMAP_STATS_OPS
- bp->mark_hit++;
-#endif
- goto got_extent;
- }
- }
-
- while (*n) {
- parent = *n;
- ext = node_to_extent(parent);
-
- if (start < ext->start) {
- n = &(*n)->rb_left;
- } else if (start > (ext->start + ext->count)) {
- n = &(*n)->rb_right;
- } else {
-got_extent:
- if ((start + count) <= (ext->start + ext->count))
- return 1;
-
- if ((ext->start + ext->count) == start)
- retval = 0;
- else
- retval = 1;
-
- count += (start - ext->start);
- start = ext->start;
- new_ext = ext;
- new_node = &ext->node;
-
- goto skip_insert;
- }
- }
-
- rb_get_new_extent(&new_ext, start, count);
-
- new_node = &new_ext->node;
- ext2fs_rb_link_node(new_node, parent, n);
- ext2fs_rb_insert_color(new_node, root);
- bp->wcursor = new_ext;
-
- node = ext2fs_rb_prev(new_node);
- if (node) {
- ext = node_to_extent(node);
- if ((ext->start + ext->count) == start) {
- start = ext->start;
- count += ext->count;
- ext2fs_rb_erase(node, root);
- rb_free_extent(bp, ext);
- }
- }
-
-skip_insert:
- /* See if we can merge extent to the right */
- for (node = ext2fs_rb_next(new_node); node != NULL; node = next) {
- next = ext2fs_rb_next(node);
- ext = node_to_extent(node);
-
- if ((ext->start + ext->count) <= start)
- continue;
-
- /* No more merging */
- if ((start + count) < ext->start)
- break;
-
- /* ext is embedded in new_ext interval */
- if ((start + count) >= (ext->start + ext->count)) {
- ext2fs_rb_erase(node, root);
- rb_free_extent(bp, ext);
- continue;
- } else {
- /* merge ext with new_ext */
- count += ((ext->start + ext->count) -
- (start + count));
- ext2fs_rb_erase(node, root);
- rb_free_extent(bp, ext);
- break;
- }
- }
-
- new_ext->start = start;
- new_ext->count = count;
-
- return retval;
-}
-
-static int rb_remove_extent(__u64 start, __u64 count,
- struct ext2fs_rb_private *bp)
-{
- struct rb_root *root = &bp->root;
- struct rb_node *parent = NULL, **n = &root->rb_node;
- struct rb_node *node;
- struct bmap_rb_extent *ext;
- __u64 new_start, new_count;
- int retval = 0;
-
- if (EXT2FS_RB_EMPTY_ROOT(root))
- return 0;
-
- while (*n) {
- parent = *n;
- ext = node_to_extent(parent);
- if (start < ext->start) {
- n = &(*n)->rb_left;
- continue;
- } else if (start >= (ext->start + ext->count)) {
- n = &(*n)->rb_right;
- continue;
- }
-
- if ((start > ext->start) &&
- (start + count) < (ext->start + ext->count)) {
- /* We have to split extent into two */
- new_start = start + count;
- new_count = (ext->start + ext->count) - new_start;
-
- ext->count = start - ext->start;
-
- rb_insert_extent(new_start, new_count, bp);
- return 1;
- }
-
- if ((start + count) >= (ext->start + ext->count)) {
- ext->count = start - ext->start;
- retval = 1;
- }
-
- if (0 == ext->count) {
- parent = ext2fs_rb_next(&ext->node);
- ext2fs_rb_erase(&ext->node, root);
- rb_free_extent(bp, ext);
- break;
- }
-
- if (start == ext->start) {
- ext->start += count;
- ext->count -= count;
- return 1;
- }
- }
-
- /* See if we should delete or truncate extent on the right */
- for (; parent != NULL; parent = node) {
- node = ext2fs_rb_next(parent);
- ext = node_to_extent(parent);
- if ((ext->start + ext->count) <= start)
- continue;
-
- /* No more extents to be removed/truncated */
- if ((start + count) < ext->start)
- break;
-
- /* The entire extent is within the region to be removed */
- if ((start + count) >= (ext->start + ext->count)) {
- ext2fs_rb_erase(parent, root);
- rb_free_extent(bp, ext);
- retval = 1;
- continue;
- } else {
- /* modify the last extent in reigon to be removed */
- ext->count -= ((start + count) - ext->start);
- ext->start = start + count;
- retval = 1;
- break;
- }
- }
-
- return retval;
-}
-
-static int rb_mark_bmap(ext2fs_generic_bitmap bitmap, __u64 arg)
-{
- struct ext2fs_rb_private *bp;
-
- bp = (struct ext2fs_rb_private *) bitmap->private;
- arg -= bitmap->start;
-
- return rb_insert_extent(arg, 1, bp);
-}
-
-static int rb_unmark_bmap(ext2fs_generic_bitmap bitmap, __u64 arg)
-{
- struct ext2fs_rb_private *bp;
- int retval;
-
- bp = (struct ext2fs_rb_private *) bitmap->private;
- arg -= bitmap->start;
-
- retval = rb_remove_extent(arg, 1, bp);
- check_tree(&bp->root, __func__);
-
- return retval;
-}
-
-inline
-static int rb_test_bmap(ext2fs_generic_bitmap bitmap, __u64 arg)
-{
- struct ext2fs_rb_private *bp;
-
- bp = (struct ext2fs_rb_private *) bitmap->private;
- arg -= bitmap->start;
-
- return rb_test_bit(bp, arg);
-}
-
-static void rb_mark_bmap_extent(ext2fs_generic_bitmap bitmap, __u64 arg,
- unsigned int num)
-{
- struct ext2fs_rb_private *bp;
-
- bp = (struct ext2fs_rb_private *) bitmap->private;
- arg -= bitmap->start;
-
- rb_insert_extent(arg, num, bp);
-}
-
-static void rb_unmark_bmap_extent(ext2fs_generic_bitmap bitmap, __u64 arg,
- unsigned int num)
-{
- struct ext2fs_rb_private *bp;
-
- bp = (struct ext2fs_rb_private *) bitmap->private;
- arg -= bitmap->start;
-
- rb_remove_extent(arg, num, bp);
- check_tree(&bp->root, __func__);
-}
-
-static int rb_test_clear_bmap_extent(ext2fs_generic_bitmap bitmap,
- __u64 start, unsigned int len)
-{
- struct rb_node *parent = NULL, **n;
- struct rb_node *node, *next;
- struct ext2fs_rb_private *bp;
- struct bmap_rb_extent *ext;
- int retval = 1;
-
- bp = (struct ext2fs_rb_private *) bitmap->private;
- n = &bp->root.rb_node;
- start -= bitmap->start;
-
- if ((len == 0) || EXT2FS_RB_EMPTY_ROOT(&bp->root))
- return 1;
-
- /*
- * If we find nothing, we should examine whole extent, but
- * when we find match, the extent is not clean, thus be return
- * false.
- */
- while (*n) {
- parent = *n;
- ext = node_to_extent(parent);
- if (start < ext->start) {
- n = &(*n)->rb_left;
- } else if (start >= (ext->start + ext->count)) {
- n = &(*n)->rb_right;
- } else {
- /*
- * We found extent int the tree -> extent is not
- * clean
- */
- return 0;
- }
- }
-
- node = parent;
- while (node) {
- next = ext2fs_rb_next(node);
- ext = node_to_extent(node);
- node = next;
-
- if ((ext->start + ext->count) <= start)
- continue;
-
- /* No more merging */
- if ((start + len) <= ext->start)
- break;
-
- retval = 0;
- break;
- }
- return retval;
-}
-
-static errcode_t rb_set_bmap_range(ext2fs_generic_bitmap bitmap,
- __u64 start, size_t num, void *in)
-{
- struct ext2fs_rb_private *bp;
- unsigned char *cp = in;
- size_t i;
- int first_set = -1;
-
- bp = (struct ext2fs_rb_private *) bitmap->private;
-
- for (i = 0; i < num; i++) {
- if ((i & 7) == 0) {
- unsigned char c = cp[i/8];
- if (c == 0xFF) {
- if (first_set == -1)
- first_set = i;
- i += 7;
- continue;
- }
- if ((c == 0x00) && (first_set == -1)) {
- i += 7;
- continue;
- }
- }
- if (ext2fs_test_bit(i, in)) {
- if (first_set == -1)
- first_set = i;
- continue;
- }
- if (first_set == -1)
- continue;
-
- rb_insert_extent(start + first_set - bitmap->start,
- i - first_set, bp);
- first_set = -1;
- }
- if (first_set != -1)
- rb_insert_extent(start + first_set - bitmap->start,
- num - first_set, bp);
-
- return 0;
-}
-
-static errcode_t rb_get_bmap_range(ext2fs_generic_bitmap bitmap,
- __u64 start, size_t num, void *out)
-{
-
- struct rb_node *parent = NULL, *next, **n;
- struct ext2fs_rb_private *bp;
- struct bmap_rb_extent *ext;
- int count;
- __u64 pos;
-
- bp = (struct ext2fs_rb_private *) bitmap->private;
- n = &bp->root.rb_node;
- start -= bitmap->start;
-
- if (EXT2FS_RB_EMPTY_ROOT(&bp->root))
- return 0;
-
- while (*n) {
- parent = *n;
- ext = node_to_extent(parent);
- if (start < ext->start) {
- n = &(*n)->rb_left;
- } else if (start >= (ext->start + ext->count)) {
- n = &(*n)->rb_right;
- } else
- break;
- }
-
- memset(out, 0, (num + 7) >> 3);
-
- for (; parent != NULL; parent = next) {
- next = ext2fs_rb_next(parent);
- ext = node_to_extent(parent);
-
- pos = ext->start;
- count = ext->count;
- if (pos >= start + num)
- break;
- if (pos < start) {
- count -= start - pos;
- if (count < 0)
- continue;
- pos = start;
- }
- if (pos + count > start + num)
- count = start + num - pos;
-
- while (count > 0) {
- if ((count >= 8) &&
- ((pos - start) % 8) == 0) {
- int nbytes = count >> 3;
- int offset = (pos - start) >> 3;
-
- memset(((char *) out) + offset, 0xFF, nbytes);
- pos += nbytes << 3;
- count -= nbytes << 3;
- continue;
- }
- ext2fs_fast_set_bit64((pos - start), out);
- pos++;
- count--;
- }
- }
- return 0;
-}
-
-static void rb_clear_bmap(ext2fs_generic_bitmap bitmap)
-{
- struct ext2fs_rb_private *bp;
-
- bp = (struct ext2fs_rb_private *) bitmap->private;
-
- rb_free_tree(&bp->root);
- bp->rcursor = NULL;
- bp->rcursor_next = NULL;
- bp->wcursor = NULL;
-}
-
-#ifdef BMAP_STATS
-static void rb_print_stats(ext2fs_generic_bitmap bitmap)
-{
- struct ext2fs_rb_private *bp;
- struct rb_node *node = NULL;
- struct bmap_rb_extent *ext;
- __u64 count = 0;
- __u64 max_size = 0;
- __u64 min_size = ULONG_MAX;
- __u64 size = 0, avg_size = 0;
- double eff;
-#ifdef BMAP_STATS_OPS
- __u64 mark_all, test_all;
- double m_hit = 0.0, t_hit = 0.0;
-#endif
-
- bp = (struct ext2fs_rb_private *) bitmap->private;
-
- node = ext2fs_rb_first(&bp->root);
- for (node = ext2fs_rb_first(&bp->root); node != NULL;
- node = ext2fs_rb_next(node)) {
- ext = node_to_extent(node);
- count++;
- if (ext->count > max_size)
- max_size = ext->count;
- if (ext->count < min_size)
- min_size = ext->count;
- size += ext->count;
- }
-
- if (count)
- avg_size = size / count;
- if (min_size == ULONG_MAX)
- min_size = 0;
- eff = (double)((count * sizeof(struct bmap_rb_extent)) << 3) /
- (bitmap->real_end - bitmap->start);
-#ifdef BMAP_STATS_OPS
- mark_all = bitmap->stats.mark_count + bitmap->stats.mark_ext_count;
- test_all = bitmap->stats.test_count + bitmap->stats.test_ext_count;
- if (mark_all)
- m_hit = ((double)bp->mark_hit / mark_all) * 100;
- if (test_all)
- t_hit = ((double)bp->test_hit / test_all) * 100;
-
- fprintf(stderr, "%16llu cache hits on test (%.2f%%)\n"
- "%16llu cache hits on mark (%.2f%%)\n",
- bp->test_hit, t_hit, bp->mark_hit, m_hit);
-#endif
- fprintf(stderr, "%16llu extents (%llu bytes)\n",
- count, ((count * sizeof(struct bmap_rb_extent)) +
- sizeof(struct ext2fs_rb_private)));
- fprintf(stderr, "%16llu bits minimum size\n",
- min_size);
- fprintf(stderr, "%16llu bits maximum size\n"
- "%16llu bits average size\n",
- max_size, avg_size);
- fprintf(stderr, "%16llu bits set in bitmap (out of %llu)\n", size,
- bitmap->real_end - bitmap->start);
- fprintf(stderr,
- "%16.4lf memory / bitmap bit memory ratio (bitarray = 1)\n",
- eff);
-}
-#else
-static void rb_print_stats(ext2fs_generic_bitmap bitmap){}
-#endif
-
-struct ext2_bitmap_ops ext2fs_blkmap64_rbtree = {
- .type = EXT2FS_BMAP64_RBTREE,
- .new_bmap = rb_new_bmap,
- .free_bmap = rb_free_bmap,
- .copy_bmap = rb_copy_bmap,
- .resize_bmap = rb_resize_bmap,
- .mark_bmap = rb_mark_bmap,
- .unmark_bmap = rb_unmark_bmap,
- .test_bmap = rb_test_bmap,
- .test_clear_bmap_extent = rb_test_clear_bmap_extent,
- .mark_bmap_extent = rb_mark_bmap_extent,
- .unmark_bmap_extent = rb_unmark_bmap_extent,
- .set_bmap_range = rb_set_bmap_range,
- .get_bmap_range = rb_get_bmap_range,
- .clear_bmap = rb_clear_bmap,
- .print_stats = rb_print_stats,
-};
diff --git a/lib/ext2fs/blknum.c b/lib/ext2fs/blknum.c
deleted file mode 100644
index e2f0f1bb..00000000
--- a/lib/ext2fs/blknum.c
+++ /dev/null
@@ -1,494 +0,0 @@
-/*
- * blknum.c --- Functions to handle blk64_t and high/low 64-bit block
- * number.
- *
- * Copyright IBM Corporation, 2007
- * Author Jose R. Santos <jrs@us.ibm.com>
- *
- * %Begin-Header%
- * This file may be redistributed under the terms of the GNU Public
- * License.
- * %End-Header%
- */
-
-#include "ext2fs.h"
-
-/*
- * Return the group # of a block
- */
-dgrp_t ext2fs_group_of_blk2(ext2_filsys fs, blk64_t blk)
-{
- return (blk - fs->super->s_first_data_block) /
- fs->super->s_blocks_per_group;
-}
-
-/*
- * Return the first block (inclusive) in a group
- */
-blk64_t ext2fs_group_first_block2(ext2_filsys fs, dgrp_t group)
-{
- return fs->super->s_first_data_block +
- ((blk64_t)group * fs->super->s_blocks_per_group);
-}
-
-/*
- * Return the last block (inclusive) in a group
- */
-blk64_t ext2fs_group_last_block2(ext2_filsys fs, dgrp_t group)
-{
- return (group == fs->group_desc_count - 1 ?
- ext2fs_blocks_count(fs->super) - 1 :
- ext2fs_group_first_block2(fs, group) +
- (fs->super->s_blocks_per_group - 1));
-}
-
-/*
- * Return the number of blocks in a group
- */
-int ext2fs_group_blocks_count(ext2_filsys fs, dgrp_t group)
-{
- int num_blocks;
-
- if (group == fs->group_desc_count - 1) {
- num_blocks = (ext2fs_blocks_count(fs->super) -
- fs->super->s_first_data_block) %
- fs->super->s_blocks_per_group;
- if (!num_blocks)
- num_blocks = fs->super->s_blocks_per_group;
- } else
- num_blocks = fs->super->s_blocks_per_group;
-
- return num_blocks;
-}
-
-/*
- * Return the inode data block count
- */
-blk64_t ext2fs_inode_data_blocks2(ext2_filsys fs,
- struct ext2_inode *inode)
-{
- return (inode->i_blocks |
- ((fs->super->s_feature_ro_compat &
- EXT4_FEATURE_RO_COMPAT_HUGE_FILE) ?
- (__u64) inode->osd2.linux2.l_i_blocks_hi << 32 : 0)) -
- (inode->i_file_acl ? fs->blocksize >> 9 : 0);
-}
-
-/*
- * Return the inode i_blocks count
- */
-blk64_t ext2fs_inode_i_blocks(ext2_filsys fs,
- struct ext2_inode *inode)
-{
- return (inode->i_blocks |
- ((fs->super->s_feature_ro_compat &
- EXT4_FEATURE_RO_COMPAT_HUGE_FILE) ?
- (__u64)inode->osd2.linux2.l_i_blocks_hi << 32 : 0));
-}
-
-/*
- * Return the fs block count
- */
-blk64_t ext2fs_blocks_count(struct ext2_super_block *super)
-{
- return super->s_blocks_count |
- (super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT ?
- (__u64) super->s_blocks_count_hi << 32 : 0);
-}
-
-/*
- * Set the fs block count
- */
-void ext2fs_blocks_count_set(struct ext2_super_block *super, blk64_t blk)
-{
- super->s_blocks_count = blk;
- if (super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT)
- super->s_blocks_count_hi = (__u64) blk >> 32;
-}
-
-/*
- * Add to the current fs block count
- */
-void ext2fs_blocks_count_add(struct ext2_super_block *super, blk64_t blk)
-{
- blk64_t tmp;
- tmp = ext2fs_blocks_count(super) + blk;
- ext2fs_blocks_count_set(super, tmp);
-}
-
-/*
- * Return the fs reserved block count
- */
-blk64_t ext2fs_r_blocks_count(struct ext2_super_block *super)
-{
- return super->s_r_blocks_count |
- (super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT ?
- (__u64) super->s_r_blocks_count_hi << 32 : 0);
-}
-
-/*
- * Set the fs reserved block count
- */
-void ext2fs_r_blocks_count_set(struct ext2_super_block *super, blk64_t blk)
-{
- super->s_r_blocks_count = blk;
- if (super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT)
- super->s_r_blocks_count_hi = (__u64) blk >> 32;
-}
-
-/*
- * Add to the current reserved fs block count
- */
-void ext2fs_r_blocks_count_add(struct ext2_super_block *super, blk64_t blk)
-{
- blk64_t tmp;
- tmp = ext2fs_r_blocks_count(super) + blk;
- ext2fs_r_blocks_count_set(super, tmp);
-}
-
-/*
- * Return the fs free block count
- */
-blk64_t ext2fs_free_blocks_count(struct ext2_super_block *super)
-{
- return super->s_free_blocks_count |
- (super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT ?
- (__u64) super->s_free_blocks_hi << 32 : 0);
-}
-
-/*
- * Set the fs free block count
- */
-void ext2fs_free_blocks_count_set(struct ext2_super_block *super, blk64_t blk)
-{
- super->s_free_blocks_count = blk;
- if (super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT)
- super->s_free_blocks_hi = (__u64) blk >> 32;
-}
-
-/*
- * Add to the current free fs block count
- */
-void ext2fs_free_blocks_count_add(struct ext2_super_block *super, blk64_t blk)
-{
- blk64_t tmp;
- tmp = ext2fs_free_blocks_count(super) + blk;
- ext2fs_free_blocks_count_set(super, tmp);
-}
-
-/*
- * Get a pointer to a block group descriptor. We need the explicit
- * pointer to the group desc for code that swaps block group
- * descriptors before writing them out, as it wants to make a copy and
- * do the swap there.
- */
-struct ext2_group_desc *ext2fs_group_desc(ext2_filsys fs,
- struct opaque_ext2_group_desc *gdp,
- dgrp_t group)
-{
- return (struct ext2_group_desc *)((char *)gdp +
- group * EXT2_DESC_SIZE(fs->super));
-}
-
-/* Do the same but as an ext4 group desc for internal use here */
-static struct ext4_group_desc *ext4fs_group_desc(ext2_filsys fs,
- struct opaque_ext2_group_desc *gdp,
- dgrp_t group)
-{
- return (struct ext4_group_desc *)ext2fs_group_desc(fs, gdp, group);
-}
-
-/*
- * Return the block bitmap block of a group
- */
-blk64_t ext2fs_block_bitmap_loc(ext2_filsys fs, dgrp_t group)
-{
- struct ext4_group_desc *gdp;
-
- gdp = ext4fs_group_desc(fs, fs->group_desc, group);
- return gdp->bg_block_bitmap |
- (fs->super->s_feature_incompat
- & EXT4_FEATURE_INCOMPAT_64BIT ?
- (__u64)gdp->bg_block_bitmap_hi << 32 : 0);
-}
-
-/*
- * Set the block bitmap block of a group
- */
-void ext2fs_block_bitmap_loc_set(ext2_filsys fs, dgrp_t group, blk64_t blk)
-{
- struct ext4_group_desc *gdp;
-
- gdp = ext4fs_group_desc(fs, fs->group_desc, group);
- gdp->bg_block_bitmap = blk;
- if (fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT)
- gdp->bg_block_bitmap_hi = (__u64) blk >> 32;
-}
-
-/*
- * Return the inode bitmap block of a group
- */
-blk64_t ext2fs_inode_bitmap_loc(ext2_filsys fs, dgrp_t group)
-{
- struct ext4_group_desc *gdp;
-
- gdp = ext4fs_group_desc(fs, fs->group_desc, group);
- return gdp->bg_inode_bitmap |
- (fs->super->s_feature_incompat
- & EXT4_FEATURE_INCOMPAT_64BIT ?
- (__u64) gdp->bg_inode_bitmap_hi << 32 : 0);
-}
-
-/*
- * Set the inode bitmap block of a group
- */
-void ext2fs_inode_bitmap_loc_set(ext2_filsys fs, dgrp_t group, blk64_t blk)
-{
- struct ext4_group_desc *gdp;
-
- gdp = ext4fs_group_desc(fs, fs->group_desc, group);
- gdp->bg_inode_bitmap = blk;
- if (fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT)
- gdp->bg_inode_bitmap_hi = (__u64) blk >> 32;
-}
-
-/*
- * Return the inode table block of a group
- */
-blk64_t ext2fs_inode_table_loc(ext2_filsys fs, dgrp_t group)
-{
- struct ext4_group_desc *gdp;
-
- gdp = ext4fs_group_desc(fs, fs->group_desc, group);
- return gdp->bg_inode_table |
- (fs->super->s_feature_incompat
- & EXT4_FEATURE_INCOMPAT_64BIT ?
- (__u64) gdp->bg_inode_table_hi << 32 : 0);
-}
-
-/*
- * Set the inode table block of a group
- */
-void ext2fs_inode_table_loc_set(ext2_filsys fs, dgrp_t group, blk64_t blk)
-{
- struct ext4_group_desc *gdp;
-
- gdp = ext4fs_group_desc(fs, fs->group_desc, group);
- gdp->bg_inode_table = blk;
- if (fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT)
- gdp->bg_inode_table_hi = (__u64) blk >> 32;
-}
-
-/*
- * Return the free blocks count of a group
- */
-__u32 ext2fs_bg_free_blocks_count(ext2_filsys fs, dgrp_t group)
-{
- struct ext4_group_desc *gdp;
-
- gdp = ext4fs_group_desc(fs, fs->group_desc, group);
- return gdp->bg_free_blocks_count |
- (fs->super->s_feature_incompat
- & EXT4_FEATURE_INCOMPAT_64BIT ?
- (__u32) gdp->bg_free_blocks_count_hi << 16 : 0);
-}
-
-/*
- * Set the free blocks count of a group
- */
-void ext2fs_bg_free_blocks_count_set(ext2_filsys fs, dgrp_t group, __u32 n)
-{
- struct ext4_group_desc *gdp;
-
- gdp = ext4fs_group_desc(fs, fs->group_desc, group);
- gdp->bg_free_blocks_count = n;
-
- if (fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT)
- gdp->bg_free_blocks_count_hi = (__u32) n >> 16;
-}
-
-/*
- * Return the free inodes count of a group
- */
-__u32 ext2fs_bg_free_inodes_count(ext2_filsys fs, dgrp_t group)
-{
- struct ext4_group_desc *gdp;
-
- gdp = ext4fs_group_desc(fs, fs->group_desc, group);
- return gdp->bg_free_inodes_count |
- (fs->super->s_feature_incompat
- & EXT4_FEATURE_INCOMPAT_64BIT ?
- (__u32) gdp->bg_free_inodes_count_hi << 16 : 0);
-}
-
-/*
- * Set the free inodes count of a group
- */
-void ext2fs_bg_free_inodes_count_set(ext2_filsys fs, dgrp_t group, __u32 n)
-{
- struct ext4_group_desc *gdp;
-
- gdp = ext4fs_group_desc(fs, fs->group_desc, group);
- gdp->bg_free_inodes_count = n;
- if (fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT)
- gdp->bg_free_inodes_count_hi = (__u32) n >> 16;
-}
-
-/*
- * Return the used dirs count of a group
- */
-__u32 ext2fs_bg_used_dirs_count(ext2_filsys fs, dgrp_t group)
-{
- struct ext4_group_desc *gdp;
-
- gdp = ext4fs_group_desc(fs, fs->group_desc, group);
- return gdp->bg_used_dirs_count |
- (fs->super->s_feature_incompat
- & EXT4_FEATURE_INCOMPAT_64BIT ?
- (__u32) gdp->bg_used_dirs_count_hi << 16 : 0);
-}
-
-/*
- * Set the used dirs count of a group
- */
-void ext2fs_bg_used_dirs_count_set(ext2_filsys fs, dgrp_t group, __u32 n)
-{
- struct ext4_group_desc *gdp;
-
- gdp = ext4fs_group_desc(fs, fs->group_desc, group);
- gdp->bg_used_dirs_count = n;
- if (fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT)
- gdp->bg_used_dirs_count_hi = (__u32) n >> 16;
-}
-
-/*
- * Return the unused inodes count of a group
- */
-__u32 ext2fs_bg_itable_unused(ext2_filsys fs, dgrp_t group)
-{
- struct ext4_group_desc *gdp;
-
- gdp = ext4fs_group_desc(fs, fs->group_desc, group);
- return gdp->bg_itable_unused |
- (fs->super->s_feature_incompat
- & EXT4_FEATURE_INCOMPAT_64BIT ?
- (__u32) gdp->bg_itable_unused_hi << 16 : 0);
-}
-
-/*
- * Set the unused inodes count of a group
- */
-void ext2fs_bg_itable_unused_set(ext2_filsys fs, dgrp_t group, __u32 n)
-{
- struct ext4_group_desc *gdp;
-
- gdp = ext4fs_group_desc(fs, fs->group_desc, group);
- gdp->bg_itable_unused = n;
- if (fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT)
- gdp->bg_itable_unused_hi = (__u32) n >> 16;
-}
-
-/*
- * Get the flags for this block group
- */
-__u16 ext2fs_bg_flags(ext2_filsys fs, dgrp_t group)
-{
- struct ext4_group_desc *gdp;
-
- gdp = ext4fs_group_desc(fs, fs->group_desc, group);
- return gdp->bg_flags;
-}
-
-/*
- * Zero out the flags for this block group
- */
-void ext2fs_bg_flags_zap(ext2_filsys fs, dgrp_t group)
-{
- struct ext4_group_desc *gdp;
-
- gdp = ext4fs_group_desc(fs, fs->group_desc, group);
- gdp->bg_flags = 0;
- return;
-}
-
-/*
- * Get the value of a particular flag for this block group
- */
-int ext2fs_bg_flags_test(ext2_filsys fs, dgrp_t group, __u16 bg_flag)
-{
- struct ext4_group_desc *gdp;
-
- gdp = ext4fs_group_desc(fs, fs->group_desc, group);
- return gdp->bg_flags & bg_flag;
-}
-
-/*
- * Set a flag or set of flags for this block group
- */
-void ext2fs_bg_flags_set(ext2_filsys fs, dgrp_t group, __u16 bg_flags)
-{
- struct ext4_group_desc *gdp;
-
- gdp = ext4fs_group_desc(fs, fs->group_desc, group);
- gdp->bg_flags |= bg_flags;
- return;
-}
-
-/*
- * Clear a flag or set of flags for this block group
- */
-void ext2fs_bg_flags_clear(ext2_filsys fs, dgrp_t group, __u16 bg_flags)
-{
- struct ext4_group_desc *gdp;
-
- gdp = ext4fs_group_desc(fs, fs->group_desc, group);
- gdp->bg_flags &= ~bg_flags;
- return;
-}
-
-/*
- * Get the checksum for this block group
- */
-__u16 ext2fs_bg_checksum(ext2_filsys fs, dgrp_t group)
-{
- struct ext4_group_desc *gdp;
-
- gdp = ext4fs_group_desc(fs, fs->group_desc, group);
- return gdp->bg_checksum;
-}
-
-/*
- * Set the checksum for this block group to a previously calculated value
- */
-void ext2fs_bg_checksum_set(ext2_filsys fs, dgrp_t group, __u16 checksum)
-{
- struct ext4_group_desc *gdp;
-
- gdp = ext4fs_group_desc(fs, fs->group_desc, group);
- gdp->bg_checksum = checksum;
- return;
-}
-
-/*
- * Get the acl block of a file
- */
-blk64_t ext2fs_file_acl_block(ext2_filsys fs, const struct ext2_inode *inode)
-{
- blk64_t blk = inode->i_file_acl;
-
- if (fs && fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT)
- blk |= ((__u64) inode->osd2.linux2.l_i_file_acl_high) << 32;
- return blk;
-}
-
-/*
- * Set the acl block of a file
- */
-void ext2fs_file_acl_block_set(ext2_filsys fs, struct ext2_inode *inode,
- blk64_t blk)
-{
- inode->i_file_acl = blk;
- if (fs && fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT)
- inode->osd2.linux2.l_i_file_acl_high = (__u64) blk >> 32;
-}
-
diff --git a/lib/ext2fs/block.c b/lib/ext2fs/block.c
index 3e4bbde2..4054a07b 100644
--- a/lib/ext2fs/block.c
+++ b/lib/ext2fs/block.c
@@ -21,9 +21,9 @@
struct block_context {
ext2_filsys fs;
int (*func)(ext2_filsys fs,
- blk64_t *blocknr,
+ blk_t *blocknr,
e2_blkcnt_t bcount,
- blk64_t ref_blk,
+ blk_t ref_blk,
int ref_offset,
void *priv_data);
e2_blkcnt_t bcount;
@@ -62,23 +62,19 @@ static int block_iterate_ind(blk_t *ind_block, blk_t ref_block,
int ret = 0, changed = 0;
int i, flags, limit, offset;
blk_t *block_nr;
- blk64_t blk64;
limit = ctx->fs->blocksize >> 2;
if (!(ctx->flags & BLOCK_FLAG_DEPTH_TRAVERSE) &&
- !(ctx->flags & BLOCK_FLAG_DATA_ONLY)) {
- blk64 = *ind_block;
- ret = (*ctx->func)(ctx->fs, &blk64,
+ !(ctx->flags & BLOCK_FLAG_DATA_ONLY))
+ ret = (*ctx->func)(ctx->fs, ind_block,
BLOCK_COUNT_IND, ref_block,
ref_offset, ctx->priv_data);
- *ind_block = blk64;
- }
check_for_ro_violation_return(ctx, ret);
if (!*ind_block || (ret & BLOCK_ABORT)) {
ctx->bcount += limit;
return ret;
}
- if (*ind_block >= ext2fs_blocks_count(ctx->fs->super) ||
+ if (*ind_block >= ctx->fs->super->s_blocks_count ||
*ind_block < ctx->fs->super->s_first_data_block) {
ctx->errcode = EXT2_ET_BAD_IND_BLOCK;
ret |= BLOCK_ERROR;
@@ -95,11 +91,9 @@ static int block_iterate_ind(blk_t *ind_block, blk_t ref_block,
offset = 0;
if (ctx->flags & BLOCK_FLAG_APPEND) {
for (i = 0; i < limit; i++, ctx->bcount++, block_nr++) {
- blk64 = *block_nr;
- flags = (*ctx->func)(ctx->fs, &blk64, ctx->bcount,
+ flags = (*ctx->func)(ctx->fs, block_nr, ctx->bcount,
*ind_block, offset,
ctx->priv_data);
- *block_nr = blk64;
changed |= flags;
if (flags & BLOCK_ABORT) {
ret |= BLOCK_ABORT;
@@ -111,11 +105,9 @@ static int block_iterate_ind(blk_t *ind_block, blk_t ref_block,
for (i = 0; i < limit; i++, ctx->bcount++, block_nr++) {
if (*block_nr == 0)
goto skip_sparse;
- blk64 = *block_nr;
- flags = (*ctx->func)(ctx->fs, &blk64, ctx->bcount,
+ flags = (*ctx->func)(ctx->fs, block_nr, ctx->bcount,
*ind_block, offset,
ctx->priv_data);
- *block_nr = blk64;
changed |= flags;
if (flags & BLOCK_ABORT) {
ret |= BLOCK_ABORT;
@@ -134,13 +126,10 @@ static int block_iterate_ind(blk_t *ind_block, blk_t ref_block,
}
if ((ctx->flags & BLOCK_FLAG_DEPTH_TRAVERSE) &&
!(ctx->flags & BLOCK_FLAG_DATA_ONLY) &&
- !(ret & BLOCK_ABORT)) {
- blk64 = *ind_block;
- ret |= (*ctx->func)(ctx->fs, &blk64,
+ !(ret & BLOCK_ABORT))
+ ret |= (*ctx->func)(ctx->fs, ind_block,
BLOCK_COUNT_IND, ref_block,
ref_offset, ctx->priv_data);
- *ind_block = blk64;
- }
check_for_ro_violation_return(ctx, ret);
return ret;
}
@@ -151,23 +140,19 @@ static int block_iterate_dind(blk_t *dind_block, blk_t ref_block,
int ret = 0, changed = 0;
int i, flags, limit, offset;
blk_t *block_nr;
- blk64_t blk64;
limit = ctx->fs->blocksize >> 2;
if (!(ctx->flags & (BLOCK_FLAG_DEPTH_TRAVERSE |
- BLOCK_FLAG_DATA_ONLY))) {
- blk64 = *dind_block;
- ret = (*ctx->func)(ctx->fs, &blk64,
+ BLOCK_FLAG_DATA_ONLY)))
+ ret = (*ctx->func)(ctx->fs, dind_block,
BLOCK_COUNT_DIND, ref_block,
ref_offset, ctx->priv_data);
- *dind_block = blk64;
- }
check_for_ro_violation_return(ctx, ret);
if (!*dind_block || (ret & BLOCK_ABORT)) {
ctx->bcount += limit*limit;
return ret;
}
- if (*dind_block >= ext2fs_blocks_count(ctx->fs->super) ||
+ if (*dind_block >= ctx->fs->super->s_blocks_count ||
*dind_block < ctx->fs->super->s_first_data_block) {
ctx->errcode = EXT2_ET_BAD_DIND_BLOCK;
ret |= BLOCK_ERROR;
@@ -220,13 +205,10 @@ static int block_iterate_dind(blk_t *dind_block, blk_t ref_block,
}
if ((ctx->flags & BLOCK_FLAG_DEPTH_TRAVERSE) &&
!(ctx->flags & BLOCK_FLAG_DATA_ONLY) &&
- !(ret & BLOCK_ABORT)) {
- blk64 = *dind_block;
- ret |= (*ctx->func)(ctx->fs, &blk64,
+ !(ret & BLOCK_ABORT))
+ ret |= (*ctx->func)(ctx->fs, dind_block,
BLOCK_COUNT_DIND, ref_block,
ref_offset, ctx->priv_data);
- *dind_block = blk64;
- }
check_for_ro_violation_return(ctx, ret);
return ret;
}
@@ -237,23 +219,19 @@ static int block_iterate_tind(blk_t *tind_block, blk_t ref_block,
int ret = 0, changed = 0;
int i, flags, limit, offset;
blk_t *block_nr;
- blk64_t blk64;
limit = ctx->fs->blocksize >> 2;
if (!(ctx->flags & (BLOCK_FLAG_DEPTH_TRAVERSE |
- BLOCK_FLAG_DATA_ONLY))) {
- blk64 = *tind_block;
- ret = (*ctx->func)(ctx->fs, &blk64,
+ BLOCK_FLAG_DATA_ONLY)))
+ ret = (*ctx->func)(ctx->fs, tind_block,
BLOCK_COUNT_TIND, ref_block,
ref_offset, ctx->priv_data);
- *tind_block = blk64;
- }
check_for_ro_violation_return(ctx, ret);
if (!*tind_block || (ret & BLOCK_ABORT)) {
ctx->bcount += limit*limit*limit;
return ret;
}
- if (*tind_block >= ext2fs_blocks_count(ctx->fs->super) ||
+ if (*tind_block >= ctx->fs->super->s_blocks_count ||
*tind_block < ctx->fs->super->s_first_data_block) {
ctx->errcode = EXT2_ET_BAD_TIND_BLOCK;
ret |= BLOCK_ERROR;
@@ -306,25 +284,22 @@ static int block_iterate_tind(blk_t *tind_block, blk_t ref_block,
}
if ((ctx->flags & BLOCK_FLAG_DEPTH_TRAVERSE) &&
!(ctx->flags & BLOCK_FLAG_DATA_ONLY) &&
- !(ret & BLOCK_ABORT)) {
- blk64 = *tind_block;
- ret |= (*ctx->func)(ctx->fs, &blk64,
+ !(ret & BLOCK_ABORT))
+ ret |= (*ctx->func)(ctx->fs, tind_block,
BLOCK_COUNT_TIND, ref_block,
ref_offset, ctx->priv_data);
- *tind_block = blk64;
- }
check_for_ro_violation_return(ctx, ret);
return ret;
}
-errcode_t ext2fs_block_iterate3(ext2_filsys fs,
+errcode_t ext2fs_block_iterate2(ext2_filsys fs,
ext2_ino_t ino,
int flags,
char *block_buf,
int (*func)(ext2_filsys fs,
- blk64_t *blocknr,
+ blk_t *blocknr,
e2_blkcnt_t blockcnt,
- blk64_t ref_blk,
+ blk_t ref_blk,
int ref_offset,
void *priv_data),
void *priv_data)
@@ -335,7 +310,6 @@ errcode_t ext2fs_block_iterate3(ext2_filsys fs,
errcode_t retval;
struct block_context ctx;
int limit;
- blk64_t blk64;
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
@@ -375,11 +349,10 @@ errcode_t ext2fs_block_iterate3(ext2_filsys fs,
if ((fs->super->s_creator_os == EXT2_OS_HURD) &&
!(flags & BLOCK_FLAG_DATA_ONLY)) {
if (inode.osd1.hurd1.h_i_translator) {
- blk64 = inode.osd1.hurd1.h_i_translator;
- ret |= (*ctx.func)(fs, &blk64,
+ ret |= (*ctx.func)(fs,
+ &inode.osd1.hurd1.h_i_translator,
BLOCK_COUNT_TRANSLATOR,
0, 0, priv_data);
- inode.osd1.hurd1.h_i_translator = (blk_t) blk64;
if (ret & BLOCK_ABORT)
goto abort_exit;
check_for_ro_violation_goto(&ctx, ret, abort_exit);
@@ -388,9 +361,9 @@ errcode_t ext2fs_block_iterate3(ext2_filsys fs,
if (inode.i_flags & EXT4_EXTENTS_FL) {
ext2_extent_handle_t handle;
- struct ext2fs_extent extent, next;
+ struct ext2fs_extent extent;
e2_blkcnt_t blockcnt = 0;
- blk64_t blk, new_blk;
+ blk_t blk, new_blk;
int op = EXT2_EXTENT_ROOT;
int uninit;
unsigned int j;
@@ -400,11 +373,7 @@ errcode_t ext2fs_block_iterate3(ext2_filsys fs,
goto abort_exit;
while (1) {
- if (op == EXT2_EXTENT_CURRENT)
- ctx.errcode = 0;
- else
- ctx.errcode = ext2fs_extent_get(handle, op,
- &extent);
+ ctx.errcode = ext2fs_extent_get(handle, op, &extent);
if (ctx.errcode) {
if (ctx.errcode != EXT2_ET_EXTENT_NO_NEXT)
break;
@@ -417,7 +386,7 @@ errcode_t ext2fs_block_iterate3(ext2_filsys fs,
0, 0, priv_data);
ret |= r;
check_for_ro_violation_goto(&ctx, ret,
- extent_done);
+ extent_errout);
if (r & BLOCK_CHANGED) {
ctx.errcode =
ext2fs_extent_set_bmap(handle,
@@ -451,32 +420,12 @@ errcode_t ext2fs_block_iterate3(ext2_filsys fs,
if (ctx.errcode)
break;
}
- if (ret & BLOCK_ABORT)
- break;
}
continue;
}
uninit = 0;
if (extent.e_flags & EXT2_EXTENT_FLAGS_UNINIT)
uninit = EXT2_EXTENT_SET_BMAP_UNINIT;
-
- /*
- * Get the next extent before we start messing
- * with the current extent
- */
- retval = ext2fs_extent_get(handle, op, &next);
-
-#if 0
- printf("lblk %llu pblk %llu len %d blockcnt %llu\n",
- extent.e_lblk, extent.e_pblk,
- extent.e_len, blockcnt);
-#endif
- if (extent.e_lblk + extent.e_len <= (blk64_t) blockcnt)
- continue;
- if (extent.e_lblk > (blk64_t) blockcnt)
- blockcnt = extent.e_lblk;
- j = blockcnt - extent.e_lblk;
- blk += j;
for (blockcnt = extent.e_lblk, j = 0;
j < extent.e_len;
blk++, blockcnt++, j++) {
@@ -485,27 +434,24 @@ errcode_t ext2fs_block_iterate3(ext2_filsys fs,
0, 0, priv_data);
ret |= r;
check_for_ro_violation_goto(&ctx, ret,
- extent_done);
+ extent_errout);
if (r & BLOCK_CHANGED) {
ctx.errcode =
ext2fs_extent_set_bmap(handle,
(blk64_t) blockcnt,
- new_blk, uninit);
+ (blk64_t) new_blk,
+ uninit);
if (ctx.errcode)
- goto extent_done;
+ goto extent_errout;
}
if (ret & BLOCK_ABORT)
- goto extent_done;
- }
- if (retval == 0) {
- extent = next;
- op = EXT2_EXTENT_CURRENT;
+ break;
}
}
- extent_done:
+ extent_errout:
ext2fs_extent_free(handle);
- ret |= BLOCK_ERROR; /* ctx.errcode is always valid here */
+ ret |= BLOCK_ERROR | BLOCK_ABORT;
goto errout;
}
@@ -514,17 +460,15 @@ errcode_t ext2fs_block_iterate3(ext2_filsys fs,
*/
for (i = 0; i < EXT2_NDIR_BLOCKS ; i++, ctx.bcount++) {
if (inode.i_block[i] || (flags & BLOCK_FLAG_APPEND)) {
- blk64 = inode.i_block[i];
- ret |= (*ctx.func)(fs, &blk64, ctx.bcount, 0, i,
- priv_data);
- inode.i_block[i] = (blk_t) blk64;
+ ret |= (*ctx.func)(fs, &inode.i_block[i],
+ ctx.bcount, 0, i, priv_data);
if (ret & BLOCK_ABORT)
goto abort_exit;
}
}
check_for_ro_violation_goto(&ctx, ret, abort_exit);
if (inode.i_block[EXT2_IND_BLOCK] || (flags & BLOCK_FLAG_APPEND)) {
- ret |= block_iterate_ind(&inode.i_block[EXT2_IND_BLOCK],
+ ret |= block_iterate_ind(&inode.i_block[EXT2_IND_BLOCK],
0, EXT2_IND_BLOCK, &ctx);
if (ret & BLOCK_ABORT)
goto abort_exit;
@@ -563,52 +507,6 @@ errout:
* Emulate the old ext2fs_block_iterate function!
*/
-struct xlate64 {
- int (*func)(ext2_filsys fs,
- blk_t *blocknr,
- e2_blkcnt_t blockcnt,
- blk_t ref_blk,
- int ref_offset,
- void *priv_data);
- void *real_private;
-};
-
-static int xlate64_func(ext2_filsys fs, blk64_t *blocknr,
- e2_blkcnt_t blockcnt, blk64_t ref_blk,
- int ref_offset, void *priv_data)
-{
- struct xlate64 *xl = (struct xlate64 *) priv_data;
- int ret;
- blk_t block32 = *blocknr;
-
- ret = (*xl->func)(fs, &block32, blockcnt, (blk_t) ref_blk, ref_offset,
- xl->real_private);
- *blocknr = block32;
- return ret;
-}
-
-errcode_t ext2fs_block_iterate2(ext2_filsys fs,
- ext2_ino_t ino,
- int flags,
- char *block_buf,
- int (*func)(ext2_filsys fs,
- blk_t *blocknr,
- e2_blkcnt_t blockcnt,
- blk_t ref_blk,
- int ref_offset,
- void *priv_data),
- void *priv_data)
-{
- struct xlate64 xl;
-
- xl.real_private = priv_data;
- xl.func = func;
-
- return ext2fs_block_iterate3(fs, ino, flags, block_buf,
- xlate64_func, &xl);
-}
-
-
struct xlate {
int (*func)(ext2_filsys fs,
blk_t *blocknr,
diff --git a/lib/ext2fs/bmap.c b/lib/ext2fs/bmap.c
index 28a33207..fbcb3753 100644
--- a/lib/ext2fs/bmap.c
+++ b/lib/ext2fs/bmap.c
@@ -17,7 +17,7 @@
#include <errno.h>
#include "ext2_fs.h"
-#include "ext2fsP.h"
+#include "ext2fs.h"
#if defined(__GNUC__) && !defined(NO_INLINE_FUNCS)
#define _BMAP_INLINE_ __inline__
@@ -94,7 +94,7 @@ static _BMAP_INLINE_ errcode_t block_dind_bmap(ext2_filsys fs, int flags,
int *blocks_alloc,
blk_t nr, blk_t *ret_blk)
{
- blk_t b = 0;
+ blk_t b;
errcode_t retval;
blk_t addr_per_block;
@@ -114,7 +114,7 @@ static _BMAP_INLINE_ errcode_t block_tind_bmap(ext2_filsys fs, int flags,
int *blocks_alloc,
blk_t nr, blk_t *ret_blk)
{
- blk_t b = 0;
+ blk_t b;
errcode_t retval;
blk_t addr_per_block;
@@ -129,165 +129,6 @@ static _BMAP_INLINE_ errcode_t block_tind_bmap(ext2_filsys fs, int flags,
return retval;
}
-static errcode_t extent_bmap(ext2_filsys fs, ext2_ino_t ino,
- struct ext2_inode *inode,
- ext2_extent_handle_t handle,
- char *block_buf, int bmap_flags, blk64_t block,
- int *ret_flags, int *blocks_alloc,
- blk64_t *phys_blk);
-
-static errcode_t implied_cluster_alloc(ext2_filsys fs, ext2_ino_t ino,
- struct ext2_inode *inode,
- ext2_extent_handle_t handle,
- blk64_t lblk, blk64_t *phys_blk)
-{
- blk64_t base_block, pblock = 0;
- int i;
-
- if (!EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
- EXT4_FEATURE_RO_COMPAT_BIGALLOC))
- return 0;
-
- base_block = lblk & ~EXT2FS_CLUSTER_MASK(fs);
- /*
- * Except for the logical block (lblk) that was passed in, search all
- * blocks in this logical cluster for a mapping to a physical cluster.
- * If any such map exists, calculate the physical block that maps to
- * the logical block and return that.
- *
- * The old code wouldn't even look if (block % cluster_ratio) == 0;
- * this is incorrect if we're allocating blocks in reverse order.
- */
- for (i = 0; i < EXT2FS_CLUSTER_RATIO(fs); i++) {
- if (base_block + i == lblk)
- continue;
- extent_bmap(fs, ino, inode, handle, 0, 0,
- base_block + i, 0, 0, &pblock);
- if (pblock)
- break;
- }
- if (pblock == 0)
- return 0;
- *phys_blk = pblock - i + (lblk - base_block);
- return 0;
-}
-
-/* Try to map a logical block to an already-allocated physical cluster. */
-errcode_t ext2fs_map_cluster_block(ext2_filsys fs, ext2_ino_t ino,
- struct ext2_inode *inode, blk64_t lblk,
- blk64_t *pblk)
-{
- ext2_extent_handle_t handle;
- errcode_t retval;
-
- /* Need bigalloc and extents to be enabled */
- *pblk = 0;
- if (!EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
- EXT4_FEATURE_RO_COMPAT_BIGALLOC) ||
- !(inode->i_flags & EXT4_EXTENTS_FL))
- return 0;
-
- retval = ext2fs_extent_open2(fs, ino, inode, &handle);
- if (retval)
- goto out;
-
- retval = implied_cluster_alloc(fs, ino, inode, handle, lblk, pblk);
- if (retval)
- goto out2;
-
-out2:
- ext2fs_extent_free(handle);
-out:
- return retval;
-}
-
-static errcode_t extent_bmap(ext2_filsys fs, ext2_ino_t ino,
- struct ext2_inode *inode,
- ext2_extent_handle_t handle,
- char *block_buf, int bmap_flags, blk64_t block,
- int *ret_flags, int *blocks_alloc,
- blk64_t *phys_blk)
-{
- struct ext2fs_extent extent;
- unsigned int offset;
- errcode_t retval = 0;
- blk64_t blk64 = 0;
- int alloc = 0;
-
- if (bmap_flags & BMAP_SET) {
- retval = ext2fs_extent_set_bmap(handle, block,
- *phys_blk, 0);
- return retval;
- }
- retval = ext2fs_extent_goto(handle, block);
- if (retval) {
- /* If the extent is not found, return phys_blk = 0 */
- if (retval == EXT2_ET_EXTENT_NOT_FOUND)
- goto got_block;
- return retval;
- }
- retval = ext2fs_extent_get(handle, EXT2_EXTENT_CURRENT, &extent);
- if (retval)
- return retval;
- offset = block - extent.e_lblk;
- if (block >= extent.e_lblk && (offset <= extent.e_len)) {
- *phys_blk = extent.e_pblk + offset;
- if (ret_flags && extent.e_flags & EXT2_EXTENT_FLAGS_UNINIT)
- *ret_flags |= BMAP_RET_UNINIT;
- }
-got_block:
- if ((*phys_blk == 0) && (bmap_flags & BMAP_ALLOC)) {
- implied_cluster_alloc(fs, ino, inode, handle, block, &blk64);
- if (blk64)
- goto set_extent;
- retval = extent_bmap(fs, ino, inode, handle, block_buf,
- 0, block-1, 0, blocks_alloc, &blk64);
- if (retval)
- blk64 = 0;
- retval = ext2fs_alloc_block2(fs, blk64, block_buf,
- &blk64);
- if (retval)
- return retval;
- blk64 &= ~EXT2FS_CLUSTER_MASK(fs);
- blk64 += EXT2FS_CLUSTER_MASK(fs) & block;
- alloc++;
- set_extent:
- retval = ext2fs_extent_set_bmap(handle, block,
- blk64, 0);
- if (retval)
- return retval;
- /* Update inode after setting extent */
- retval = ext2fs_read_inode(fs, ino, inode);
- if (retval)
- return retval;
- *blocks_alloc += alloc;
- *phys_blk = blk64;
- }
- return 0;
-}
-
-int ext2fs_file_block_offset_too_big(ext2_filsys fs,
- struct ext2_inode *inode,
- blk64_t offset)
-{
- blk64_t addr_per_block, max_map_block;
-
- /* Kernel seems to cut us off at 4294967294 blocks */
- if (offset >= (1ULL << 32) - 1)
- return 1;
-
- if (inode->i_flags & EXT4_EXTENTS_FL)
- return 0;
-
- addr_per_block = fs->blocksize >> 2;
- max_map_block = addr_per_block;
- max_map_block += addr_per_block * addr_per_block;
- max_map_block += addr_per_block * addr_per_block * addr_per_block;
- max_map_block += 12;
-
- return offset >= max_map_block;
-}
-
errcode_t ext2fs_bmap2(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode,
char *block_buf, int bmap_flags, blk64_t block,
int *ret_flags, blk64_t *phys_blk)
@@ -315,8 +156,53 @@ errcode_t ext2fs_bmap2(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode,
}
addr_per_block = (blk_t) fs->blocksize >> 2;
- if (ext2fs_file_block_offset_too_big(fs, inode, block))
- return EXT2_ET_FILE_TOO_BIG;
+ if (inode->i_flags & EXT4_EXTENTS_FL) {
+ struct ext2fs_extent extent;
+ unsigned int offset;
+
+ retval = ext2fs_extent_open2(fs, ino, inode, &handle);
+ if (retval)
+ goto done;
+ if (bmap_flags & BMAP_SET) {
+ retval = ext2fs_extent_set_bmap(handle, block,
+ *phys_blk, 0);
+ goto done;
+ }
+ retval = ext2fs_extent_goto(handle, block);
+ if (retval) {
+ /* If the extent is not found, return phys_blk = 0 */
+ if (retval == EXT2_ET_EXTENT_NOT_FOUND)
+ goto got_block;
+ goto done;
+ }
+ retval = ext2fs_extent_get(handle, EXT2_EXTENT_CURRENT, &extent);
+ if (retval)
+ goto done;
+ offset = block - extent.e_lblk;
+ if (block >= extent.e_lblk && (offset <= extent.e_len)) {
+ *phys_blk = extent.e_pblk + offset;
+ if (ret_flags && extent.e_flags & EXT2_EXTENT_FLAGS_UNINIT)
+ *ret_flags |= BMAP_RET_UNINIT;
+ }
+ got_block:
+ if ((*phys_blk == 0) && (bmap_flags & BMAP_ALLOC)) {
+ retval = ext2fs_alloc_block(fs, b, block_buf, &b);
+ if (retval)
+ goto done;
+ retval = ext2fs_extent_set_bmap(handle, block,
+ (blk64_t) b, 0);
+ if (retval)
+ goto done;
+ /* Update inode after setting extent */
+ retval = ext2fs_read_inode(fs, ino, inode);
+ if (retval)
+ return retval;
+ blocks_alloc++;
+ *phys_blk = b;
+ }
+ retval = 0;
+ goto done;
+ }
if (!block_buf) {
retval = ext2fs_get_array(2, fs->blocksize, &buf);
@@ -325,16 +211,6 @@ errcode_t ext2fs_bmap2(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode,
block_buf = buf;
}
- if (inode->i_flags & EXT4_EXTENTS_FL) {
- retval = ext2fs_extent_open2(fs, ino, inode, &handle);
- if (retval)
- goto done;
- retval = extent_bmap(fs, ino, inode, handle, block_buf,
- bmap_flags, block, ret_flags,
- &blocks_alloc, phys_blk);
- goto done;
- }
-
if (block < EXT2_NDIR_BLOCKS) {
if (bmap_flags & BMAP_SET) {
b = *phys_blk;
diff --git a/lib/ext2fs/bmap64.h b/lib/ext2fs/bmap64.h
deleted file mode 100644
index f44d379c..00000000
--- a/lib/ext2fs/bmap64.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * bmap64.h --- 64-bit bitmap structure
- *
- * Copyright (C) 2007, 2008 Theodore Ts'o.
- *
- * %Begin-Header%
- * This file may be redistributed under the terms of the GNU Public
- * License.
- * %End-Header%
- */
-
-struct ext2_bmap_statistics {
- int type;
- struct timeval created;
-
-#ifdef BMAP_STATS_OPS
- unsigned long copy_count;
- unsigned long resize_count;
- unsigned long mark_count;
- unsigned long unmark_count;
- unsigned long test_count;
- unsigned long mark_ext_count;
- unsigned long unmark_ext_count;
- unsigned long test_ext_count;
- unsigned long set_range_count;
- unsigned long get_range_count;
- unsigned long clear_count;
-
- blk64_t last_marked;
- blk64_t last_tested;
- blk64_t mark_back;
- blk64_t test_back;
-
- unsigned long mark_seq;
- unsigned long test_seq;
-#endif /* BMAP_STATS_OPS */
-};
-
-
-struct ext2fs_struct_generic_bitmap {
- errcode_t magic;
- ext2_filsys fs;
- struct ext2_bitmap_ops *bitmap_ops;
- int flags;
- __u64 start, end;
- __u64 real_end;
- int cluster_bits;
- char *description;
- void *private;
- errcode_t base_error_code;
-#ifdef BMAP_STATS
- struct ext2_bmap_statistics stats;
-#endif
-};
-
-#define EXT2FS_IS_32_BITMAP(bmap) \
- (((bmap)->magic == EXT2_ET_MAGIC_GENERIC_BITMAP) || \
- ((bmap)->magic == EXT2_ET_MAGIC_BLOCK_BITMAP) || \
- ((bmap)->magic == EXT2_ET_MAGIC_INODE_BITMAP))
-
-#define EXT2FS_IS_64_BITMAP(bmap) \
- (((bmap)->magic == EXT2_ET_MAGIC_GENERIC_BITMAP64) || \
- ((bmap)->magic == EXT2_ET_MAGIC_BLOCK_BITMAP64) || \
- ((bmap)->magic == EXT2_ET_MAGIC_INODE_BITMAP64))
-
-struct ext2_bitmap_ops {
- int type;
- /* Generic bmap operators */
- errcode_t (*new_bmap)(ext2_filsys fs, ext2fs_generic_bitmap bmap);
- void (*free_bmap)(ext2fs_generic_bitmap bitmap);
- errcode_t (*copy_bmap)(ext2fs_generic_bitmap src,
- ext2fs_generic_bitmap dest);
- errcode_t (*resize_bmap)(ext2fs_generic_bitmap bitmap,
- __u64 new_end,
- __u64 new_real_end);
- /* bit set/test operators */
- int (*mark_bmap)(ext2fs_generic_bitmap bitmap, __u64 arg);
- int (*unmark_bmap)(ext2fs_generic_bitmap bitmap, __u64 arg);
- int (*test_bmap)(ext2fs_generic_bitmap bitmap, __u64 arg);
- void (*mark_bmap_extent)(ext2fs_generic_bitmap bitmap, __u64 arg,
- unsigned int num);
- void (*unmark_bmap_extent)(ext2fs_generic_bitmap bitmap, __u64 arg,
- unsigned int num);
- int (*test_clear_bmap_extent)(ext2fs_generic_bitmap bitmap,
- __u64 arg, unsigned int num);
- errcode_t (*set_bmap_range)(ext2fs_generic_bitmap bitmap,
- __u64 start, size_t num, void *in);
- errcode_t (*get_bmap_range)(ext2fs_generic_bitmap bitmap,
- __u64 start, size_t num, void *out);
- void (*clear_bmap)(ext2fs_generic_bitmap bitmap);
- void (*print_stats)(ext2fs_generic_bitmap);
-
- /* Find the first zero bit between start and end, inclusive.
- * May be NULL, in which case a generic function is used. */
- errcode_t (*find_first_zero)(ext2fs_generic_bitmap bitmap,
- __u64 start, __u64 end, __u64 *out);
-};
-
-extern struct ext2_bitmap_ops ext2fs_blkmap64_bitarray;
-extern struct ext2_bitmap_ops ext2fs_blkmap64_rbtree;
diff --git a/lib/ext2fs/bmove.c b/lib/ext2fs/bmove.c
index f9480c88..1caf2fa9 100644
--- a/lib/ext2fs/bmove.c
+++ b/lib/ext2fs/bmove.c
@@ -36,14 +36,14 @@ struct process_block_struct {
int flags;
};
-static int process_block(ext2_filsys fs, blk64_t *block_nr,
- e2_blkcnt_t blockcnt, blk64_t ref_block,
+static int process_block(ext2_filsys fs, blk_t *block_nr,
+ e2_blkcnt_t blockcnt, blk_t ref_block,
int ref_offset, void *priv_data)
{
struct process_block_struct *pb;
errcode_t retval;
int ret;
- blk64_t block, orig;
+ blk_t block, orig;
pb = (struct process_block_struct *) priv_data;
block = orig = *block_nr;
@@ -52,39 +52,37 @@ static int process_block(ext2_filsys fs, blk64_t *block_nr,
/*
* Let's see if this is one which we need to relocate
*/
- if (ext2fs_test_block_bitmap2(pb->reserve, block)) {
+ if (ext2fs_test_block_bitmap(pb->reserve, block)) {
do {
- if (++block >= ext2fs_blocks_count(fs->super))
+ if (++block >= fs->super->s_blocks_count)
block = fs->super->s_first_data_block;
if (block == orig) {
pb->error = EXT2_ET_BLOCK_ALLOC_FAIL;
return BLOCK_ABORT;
}
- } while (ext2fs_test_block_bitmap2(pb->reserve, block) ||
- ext2fs_test_block_bitmap2(pb->alloc_map, block));
+ } while (ext2fs_test_block_bitmap(pb->reserve, block) ||
+ ext2fs_test_block_bitmap(pb->alloc_map, block));
- retval = io_channel_read_blk64(fs->io, orig, 1, pb->buf);
+ retval = io_channel_read_blk(fs->io, orig, 1, pb->buf);
if (retval) {
pb->error = retval;
return BLOCK_ABORT;
}
- retval = io_channel_write_blk64(fs->io, block, 1, pb->buf);
+ retval = io_channel_write_blk(fs->io, block, 1, pb->buf);
if (retval) {
pb->error = retval;
return BLOCK_ABORT;
}
*block_nr = block;
- ext2fs_mark_block_bitmap2(pb->alloc_map, block);
+ ext2fs_mark_block_bitmap(pb->alloc_map, block);
ret = BLOCK_CHANGED;
if (pb->flags & EXT2_BMOVE_DEBUG)
- printf("ino=%u, blockcnt=%lld, %llu->%llu\n",
- (unsigned) pb->ino, blockcnt,
- (unsigned long long) orig,
- (unsigned long long) block);
+ printf("ino=%ld, blockcnt=%lld, %u->%u\n", pb->ino,
+ blockcnt, orig, block);
}
if (pb->add_dir) {
- retval = ext2fs_add_dir_block2(fs->dblist, pb->ino,
- block, blockcnt);
+ retval = ext2fs_add_dir_block(fs->dblist, pb->ino,
+ block, (int) blockcnt);
if (retval) {
pb->error = retval;
ret |= BLOCK_ABORT;
@@ -140,7 +138,7 @@ errcode_t ext2fs_move_blocks(ext2_filsys fs,
while (ino) {
if ((inode.i_links_count == 0) ||
- !ext2fs_inode_has_valid_blocks2(fs, &inode))
+ !ext2fs_inode_has_valid_blocks(&inode))
goto next;
pb.ino = ino;
@@ -149,8 +147,8 @@ errcode_t ext2fs_move_blocks(ext2_filsys fs,
pb.add_dir = (LINUX_S_ISDIR(inode.i_mode) &&
flags & EXT2_BMOVE_GET_DBLIST);
- retval = ext2fs_block_iterate3(fs, ino, 0, block_buf,
- process_block, &pb);
+ retval = ext2fs_block_iterate2(fs, ino, 0, block_buf,
+ process_block, &pb);
if (retval)
return retval;
if (pb.error)
diff --git a/lib/ext2fs/brel.h b/lib/ext2fs/brel.h
index 9fdddd40..a0dd5b9c 100644
--- a/lib/ext2fs/brel.h
+++ b/lib/ext2fs/brel.h
@@ -10,11 +10,11 @@
*/
struct ext2_block_relocate_entry {
- blk64_t new;
+ blk_t new;
__s16 offset;
__u16 flags;
union {
- blk64_t block_ref;
+ blk_t block_ref;
ext2_ino_t inode_ref;
} owner;
};
@@ -28,19 +28,19 @@ typedef struct ext2_block_relocation_table *ext2_brel;
struct ext2_block_relocation_table {
__u32 magic;
char *name;
- blk64_t current;
+ blk_t current;
void *priv_data;
/*
* Add a block relocation entry.
*/
- errcode_t (*put)(ext2_brel brel, blk64_t old,
+ errcode_t (*put)(ext2_brel brel, blk_t old,
struct ext2_block_relocate_entry *ent);
/*
* Get a block relocation entry.
*/
- errcode_t (*get)(ext2_brel brel, blk64_t old,
+ errcode_t (*get)(ext2_brel brel, blk_t old,
struct ext2_block_relocate_entry *ent);
/*
@@ -52,19 +52,19 @@ struct ext2_block_relocation_table {
* The iterator function for the inode relocation entries.
* Returns an inode number of 0 when out of entries.
*/
- errcode_t (*next)(ext2_brel brel, blk64_t *old,
+ errcode_t (*next)(ext2_brel brel, blk_t *old,
struct ext2_block_relocate_entry *ent);
/*
* Move the inode relocation table from one block number to
* another.
*/
- errcode_t (*move)(ext2_brel brel, blk64_t old, blk_t new);
+ errcode_t (*move)(ext2_brel brel, blk_t old, blk_t new);
/*
* Remove a block relocation entry.
*/
- errcode_t (*delete)(ext2_brel brel, blk64_t old);
+ errcode_t (*delete)(ext2_brel brel, blk_t old);
/*
@@ -73,7 +73,7 @@ struct ext2_block_relocation_table {
errcode_t (*free)(ext2_brel brel);
};
-errcode_t ext2fs_brel_memarray_create(char *name, blk64_t max_block,
+errcode_t ext2fs_brel_memarray_create(char *name, blk_t max_block,
ext2_brel *brel);
#define ext2fs_brel_put(brel, old, ent) ((brel)->put((brel), old, ent))
diff --git a/lib/ext2fs/brel_ma.c b/lib/ext2fs/brel_ma.c
index e398c1e0..1a55702b 100644
--- a/lib/ext2fs/brel_ma.c
+++ b/lib/ext2fs/brel_ma.c
@@ -26,24 +26,24 @@
#include "ext2fs.h"
#include "brel.h"
-static errcode_t bma_put(ext2_brel brel, blk64_t old,
+static errcode_t bma_put(ext2_brel brel, blk_t old,
struct ext2_block_relocate_entry *ent);
-static errcode_t bma_get(ext2_brel brel, blk64_t old,
+static errcode_t bma_get(ext2_brel brel, blk_t old,
struct ext2_block_relocate_entry *ent);
static errcode_t bma_start_iter(ext2_brel brel);
-static errcode_t bma_next(ext2_brel brel, blk64_t *old,
+static errcode_t bma_next(ext2_brel brel, blk_t *old,
struct ext2_block_relocate_entry *ent);
-static errcode_t bma_move(ext2_brel brel, blk64_t old, blk64_t new);
-static errcode_t bma_delete(ext2_brel brel, blk64_t old);
+static errcode_t bma_move(ext2_brel brel, blk_t old, blk_t new);
+static errcode_t bma_delete(ext2_brel brel, blk_t old);
static errcode_t bma_free(ext2_brel brel);
struct brel_ma {
__u32 magic;
- blk64_t max_block;
+ blk_t max_block;
struct ext2_block_relocate_entry *entries;
};
-errcode_t ext2fs_brel_memarray_create(char *name, blk64_t max_block,
+errcode_t ext2fs_brel_memarray_create(char *name, blk_t max_block,
ext2_brel *new_brel)
{
ext2_brel brel = 0;
@@ -101,7 +101,7 @@ errout:
return retval;
}
-static errcode_t bma_put(ext2_brel brel, blk64_t old,
+static errcode_t bma_put(ext2_brel brel, blk_t old,
struct ext2_block_relocate_entry *ent)
{
struct brel_ma *ma;
@@ -113,7 +113,7 @@ static errcode_t bma_put(ext2_brel brel, blk64_t old,
return 0;
}
-static errcode_t bma_get(ext2_brel brel, blk64_t old,
+static errcode_t bma_get(ext2_brel brel, blk_t old,
struct ext2_block_relocate_entry *ent)
{
struct brel_ma *ma;
@@ -133,7 +133,7 @@ static errcode_t bma_start_iter(ext2_brel brel)
return 0;
}
-static errcode_t bma_next(ext2_brel brel, blk64_t *old,
+static errcode_t bma_next(ext2_brel brel, blk_t *old,
struct ext2_block_relocate_entry *ent)
{
struct brel_ma *ma;
@@ -150,7 +150,7 @@ static errcode_t bma_next(ext2_brel brel, blk64_t *old,
return 0;
}
-static errcode_t bma_move(ext2_brel brel, blk64_t old, blk64_t new)
+static errcode_t bma_move(ext2_brel brel, blk_t old, blk_t new)
{
struct brel_ma *ma;
@@ -164,7 +164,7 @@ static errcode_t bma_move(ext2_brel brel, blk64_t old, blk64_t new)
return 0;
}
-static errcode_t bma_delete(ext2_brel brel, blk64_t old)
+static errcode_t bma_delete(ext2_brel brel, blk_t old)
{
struct brel_ma *ma;
diff --git a/lib/ext2fs/check_desc.c b/lib/ext2fs/check_desc.c
index d2cc5659..5ab95147 100644
--- a/lib/ext2fs/check_desc.c
+++ b/lib/ext2fs/check_desc.c
@@ -34,17 +34,14 @@ errcode_t ext2fs_check_desc(ext2_filsys fs)
ext2fs_block_bitmap bmap;
errcode_t retval;
dgrp_t i;
- blk64_t first_block = fs->super->s_first_data_block;
- blk64_t last_block = ext2fs_blocks_count(fs->super)-1;
- blk64_t blk, b;
- unsigned int j;
+ blk_t first_block = fs->super->s_first_data_block;
+ blk_t last_block = fs->super->s_blocks_count-1;
+ blk_t blk, b;
+ int j;
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
- if (EXT2_DESC_SIZE(fs->super) & (EXT2_DESC_SIZE(fs->super) - 1))
- return EXT2_ET_BAD_DESC_SIZE;
-
- retval = ext2fs_allocate_subcluster_bitmap(fs, "check_desc map", &bmap);
+ retval = ext2fs_allocate_block_bitmap(fs, "check_desc map", &bmap);
if (retval)
return retval;
@@ -54,36 +51,38 @@ errcode_t ext2fs_check_desc(ext2_filsys fs)
for (i = 0; i < fs->group_desc_count; i++) {
if (!EXT2_HAS_INCOMPAT_FEATURE(fs->super,
EXT4_FEATURE_INCOMPAT_FLEX_BG)) {
- first_block = ext2fs_group_first_block2(fs, i);
- last_block = ext2fs_group_last_block2(fs, i);
+ first_block = ext2fs_group_first_block(fs, i);
+ last_block = ext2fs_group_last_block(fs, i);
+ if (i == (fs->group_desc_count - 1))
+ last_block = fs->super->s_blocks_count-1;
}
/*
* Check to make sure the block bitmap for group is sane
*/
- blk = ext2fs_block_bitmap_loc(fs, i);
+ blk = fs->group_desc[i].bg_block_bitmap;
if (blk < first_block || blk > last_block ||
- ext2fs_test_block_bitmap2(bmap, blk)) {
+ ext2fs_test_block_bitmap(bmap, blk)) {
retval = EXT2_ET_GDESC_BAD_BLOCK_MAP;
goto errout;
}
- ext2fs_mark_block_bitmap2(bmap, blk);
+ ext2fs_mark_block_bitmap(bmap, blk);
/*
* Check to make sure the inode bitmap for group is sane
*/
- blk = ext2fs_inode_bitmap_loc(fs, i);
+ blk = fs->group_desc[i].bg_inode_bitmap;
if (blk < first_block || blk > last_block ||
- ext2fs_test_block_bitmap2(bmap, blk)) {
+ ext2fs_test_block_bitmap(bmap, blk)) {
retval = EXT2_ET_GDESC_BAD_INODE_MAP;
goto errout;
}
- ext2fs_mark_block_bitmap2(bmap, blk);
+ ext2fs_mark_block_bitmap(bmap, blk);
/*
* Check to make sure the inode table for group is sane
*/
- blk = ext2fs_inode_table_loc(fs, i);
+ blk = fs->group_desc[i].bg_inode_table;
if (blk < first_block ||
((blk + fs->inode_blocks_per_group - 1) > last_block)) {
retval = EXT2_ET_GDESC_BAD_INODE_TABLE;
@@ -91,11 +90,11 @@ errcode_t ext2fs_check_desc(ext2_filsys fs)
}
for (j = 0, b = blk; j < fs->inode_blocks_per_group;
j++, b++) {
- if (ext2fs_test_block_bitmap2(bmap, b)) {
+ if (ext2fs_test_block_bitmap(bmap, b)) {
retval = EXT2_ET_GDESC_BAD_INODE_TABLE;
goto errout;
}
- ext2fs_mark_block_bitmap2(bmap, b);
+ ext2fs_mark_block_bitmap(bmap, b);
}
}
errout:
diff --git a/lib/ext2fs/closefs.c b/lib/ext2fs/closefs.c
index 87403839..99430d7b 100644
--- a/lib/ext2fs/closefs.c
+++ b/lib/ext2fs/closefs.c
@@ -19,12 +19,12 @@
#include "ext2_fs.h"
#include "ext2fsP.h"
-static int test_root(unsigned int a, unsigned int b)
+static int test_root(int a, int b)
{
+ if (a == 0)
+ return 1;
while (1) {
- if (a < b)
- return 0;
- if (a == b)
+ if (a == 1)
return 1;
if (a % b)
return 0;
@@ -32,50 +32,45 @@ static int test_root(unsigned int a, unsigned int b)
}
}
-int ext2fs_bg_has_super(ext2_filsys fs, dgrp_t group)
+int ext2fs_bg_has_super(ext2_filsys fs, int group_block)
{
if (!(fs->super->s_feature_ro_compat &
- EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER) || group <= 1)
+ EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER))
return 1;
- if (!(group & 1))
- return 0;
- if (test_root(group, 3) || (test_root(group, 5)) ||
- test_root(group, 7))
+
+ if (test_root(group_block, 3) || (test_root(group_block, 5)) ||
+ test_root(group_block, 7))
return 1;
return 0;
}
/*
- * ext2fs_super_and_bgd_loc2()
- * @fs: ext2 fs pointer
- * @group given block group
- * @ret_super_blk: if !NULL, returns super block location
- * @ret_old_desc_blk: if !NULL, returns location of the old block
- * group descriptor
- * @ret_new_desc_blk: if !NULL, returns location of meta_bg block
- * group descriptor
- * @ret_used_blks: if !NULL, returns number of blocks used by
- * super block and group_descriptors.
+ * This function returns the location of the superblock, block group
+ * descriptors for a given block group. It currently returns the
+ * number of free blocks assuming that inode table and allocation
+ * bitmaps will be in the group. This is not necessarily the case
+ * when the flex_bg feature is enabled, so callers should take care!
+ * It was only really intended for use by mke2fs, and even there it's
+ * not that useful. In the future, when we redo this function for
+ * 64-bit block numbers, we should probably return the number of
+ * blocks used by the super block and group descriptors instead.
*
- * Returns errcode_t of 0
+ * See also the comment for ext2fs_reserve_super_and_bgd()
*/
-errcode_t ext2fs_super_and_bgd_loc2(ext2_filsys fs,
- dgrp_t group,
- blk64_t *ret_super_blk,
- blk64_t *ret_old_desc_blk,
- blk64_t *ret_new_desc_blk,
- blk_t *ret_used_blks)
+int ext2fs_super_and_bgd_loc(ext2_filsys fs,
+ dgrp_t group,
+ blk_t *ret_super_blk,
+ blk_t *ret_old_desc_blk,
+ blk_t *ret_new_desc_blk,
+ int *ret_meta_bg)
{
- blk64_t group_block, super_blk = 0, old_desc_blk = 0, new_desc_blk = 0;
+ blk_t group_block, super_blk = 0, old_desc_blk = 0, new_desc_blk = 0;
unsigned int meta_bg, meta_bg_size;
- blk_t numblocks = 0;
- blk64_t old_desc_blocks;
+ blk_t numblocks, old_desc_blocks;
int has_super;
- group_block = ext2fs_group_first_block2(fs, group);
- if (group_block == 0 && fs->blocksize == 1024)
- group_block = 1; /* Deal with 1024 blocksize && bigalloc */
+ group_block = ext2fs_group_first_block(fs, group);
if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG)
old_desc_blocks = fs->super->s_first_meta_bg;
@@ -83,11 +78,20 @@ errcode_t ext2fs_super_and_bgd_loc2(ext2_filsys fs,
old_desc_blocks =
fs->desc_blocks + fs->super->s_reserved_gdt_blocks;
+ if (group == fs->group_desc_count-1) {
+ numblocks = (fs->super->s_blocks_count -
+ fs->super->s_first_data_block) %
+ fs->super->s_blocks_per_group;
+ if (!numblocks)
+ numblocks = fs->super->s_blocks_per_group;
+ } else
+ numblocks = fs->super->s_blocks_per_group;
+
has_super = ext2fs_bg_has_super(fs, group);
if (has_super) {
super_blk = group_block;
- numblocks++;
+ numblocks--;
}
meta_bg_size = EXT2_DESC_PER_BLOCK(fs->super);
meta_bg = group / meta_bg_size;
@@ -96,7 +100,7 @@ errcode_t ext2fs_super_and_bgd_loc2(ext2_filsys fs,
(meta_bg < fs->super->s_first_meta_bg)) {
if (has_super) {
old_desc_blk = group_block + 1;
- numblocks += old_desc_blocks;
+ numblocks -= old_desc_blocks;
}
} else {
if (((group % meta_bg_size) == 0) ||
@@ -105,71 +109,23 @@ errcode_t ext2fs_super_and_bgd_loc2(ext2_filsys fs,
if (has_super)
has_super = 1;
new_desc_blk = group_block + has_super;
- numblocks++;
+ numblocks--;
}
}
+ numblocks -= 2 + fs->inode_blocks_per_group;
+
if (ret_super_blk)
*ret_super_blk = super_blk;
if (ret_old_desc_blk)
*ret_old_desc_blk = old_desc_blk;
if (ret_new_desc_blk)
*ret_new_desc_blk = new_desc_blk;
- if (ret_used_blks)
- *ret_used_blks = numblocks;
-
- return 0;
+ if (ret_meta_bg)
+ *ret_meta_bg = meta_bg;
+ return (numblocks);
}
-/*
- * This function returns the location of the superblock, block group
- * descriptors for a given block group. It currently returns the
- * number of free blocks assuming that inode table and allocation
- * bitmaps will be in the group. This is not necessarily the case
- * when the flex_bg feature is enabled, so callers should take care!
- * It was only really intended for use by mke2fs, and even there it's
- * not that useful.
- *
- * The ext2fs_super_and_bgd_loc2() function is 64-bit block number
- * capable and returns the number of blocks used by super block and
- * group descriptors.
- */
-int ext2fs_super_and_bgd_loc(ext2_filsys fs,
- dgrp_t group,
- blk_t *ret_super_blk,
- blk_t *ret_old_desc_blk,
- blk_t *ret_new_desc_blk,
- int *ret_meta_bg)
-{
- blk64_t ret_super_blk2;
- blk64_t ret_old_desc_blk2;
- blk64_t ret_new_desc_blk2;
- blk_t ret_used_blks;
- blk_t numblocks;
- unsigned int meta_bg_size;
-
- ext2fs_super_and_bgd_loc2(fs, group, &ret_super_blk2,
- &ret_old_desc_blk2,
- &ret_new_desc_blk2,
- &ret_used_blks);
-
- numblocks = ext2fs_group_blocks_count(fs, group);
-
- if (ret_super_blk)
- *ret_super_blk = (blk_t)ret_super_blk2;
- if (ret_old_desc_blk)
- *ret_old_desc_blk = (blk_t)ret_old_desc_blk2;
- if (ret_new_desc_blk)
- *ret_new_desc_blk = (blk_t)ret_new_desc_blk2;
- if (ret_meta_bg) {
- meta_bg_size = EXT2_DESC_PER_BLOCK(fs->super);
- *ret_meta_bg = group / meta_bg_size;
- }
-
- numblocks -= 2 + fs->inode_blocks_per_group + ret_used_blks;
-
- return numblocks;
-}
/*
* This function forces out the primary superblock. We need to only
@@ -191,7 +147,7 @@ static errcode_t write_primary_superblock(ext2_filsys fs,
if (!fs->io->manager->write_byte || !fs->orig_super) {
fallback:
io_channel_set_blksize(fs->io, SUPERBLOCK_OFFSET);
- retval = io_channel_write_blk64(fs->io, 1, -SUPERBLOCK_SIZE,
+ retval = io_channel_write_blk(fs->io, 1, -SUPERBLOCK_SIZE,
super);
io_channel_set_blksize(fs->io, fs->blocksize);
return retval;
@@ -243,7 +199,7 @@ void ext2fs_update_dynamic_rev(ext2_filsys fs)
}
static errcode_t write_backup_super(ext2_filsys fs, dgrp_t group,
- blk64_t group_block,
+ blk_t group_block,
struct ext2_super_block *super_shadow)
{
dgrp_t sgrp = group;
@@ -256,16 +212,12 @@ static errcode_t write_backup_super(ext2_filsys fs, dgrp_t group,
fs->super->s_block_group_nr = sgrp;
#endif
- return io_channel_write_blk64(fs->io, group_block, -SUPERBLOCK_SIZE,
+ return io_channel_write_blk(fs->io, group_block, -SUPERBLOCK_SIZE,
super_shadow);
}
-errcode_t ext2fs_flush(ext2_filsys fs)
-{
- return ext2fs_flush2(fs, 0);
-}
-errcode_t ext2fs_flush2(ext2_filsys fs, int flags)
+errcode_t ext2fs_flush(ext2_filsys fs)
{
dgrp_t i;
errcode_t retval;
@@ -274,12 +226,11 @@ errcode_t ext2fs_flush2(ext2_filsys fs, int flags)
struct ext2_super_block *super_shadow = 0;
struct ext2_group_desc *group_shadow = 0;
#ifdef WORDS_BIGENDIAN
- struct ext2_group_desc *gdp;
+ struct ext2_group_desc *s, *t;
dgrp_t j;
#endif
char *group_ptr;
int old_desc_blocks;
- struct ext2fs_numeric_progress_struct progress;
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
@@ -297,17 +248,18 @@ errcode_t ext2fs_flush2(ext2_filsys fs, int flags)
&group_shadow);
if (retval)
goto errout;
- memcpy(group_shadow, fs->group_desc, (size_t) fs->blocksize *
+ memset(group_shadow, 0, (size_t) fs->blocksize *
fs->desc_blocks);
/* swap the group descriptors */
- for (j = 0; j < fs->group_desc_count; j++) {
- gdp = ext2fs_group_desc(fs, group_shadow, j);
- ext2fs_swap_group_desc2(fs, gdp);
+ 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 = ext2fs_group_desc(fs, fs->group_desc, 0);
+ group_shadow = fs->group_desc;
#endif
/*
@@ -340,16 +292,12 @@ errcode_t ext2fs_flush2(ext2_filsys fs, int flags)
else
old_desc_blocks = fs->desc_blocks;
- ext2fs_numeric_progress_init(fs, &progress, NULL,
- fs->group_desc_count);
-
-
for (i = 0; i < fs->group_desc_count; i++) {
- blk64_t super_blk, old_desc_blk, new_desc_blk;
+ blk_t super_blk, old_desc_blk, new_desc_blk;
+ int meta_bg;
- ext2fs_numeric_progress_update(fs, &progress, i);
- ext2fs_super_and_bgd_loc2(fs, i, &super_blk, &old_desc_blk,
- &new_desc_blk, 0);
+ ext2fs_super_and_bgd_loc(fs, i, &super_blk, &old_desc_blk,
+ &new_desc_blk, &meta_bg);
if (!(fs->flags & EXT2_FLAG_MASTER_SB_ONLY) &&i && super_blk) {
retval = write_backup_super(fs, i, super_blk,
@@ -361,23 +309,19 @@ errcode_t ext2fs_flush2(ext2_filsys fs, int flags)
continue;
if ((old_desc_blk) &&
(!(fs->flags & EXT2_FLAG_MASTER_SB_ONLY) || (i == 0))) {
- retval = io_channel_write_blk64(fs->io,
+ retval = io_channel_write_blk(fs->io,
old_desc_blk, old_desc_blocks, group_ptr);
if (retval)
goto errout;
}
if (new_desc_blk) {
- int meta_bg = i / EXT2_DESC_PER_BLOCK(fs->super);
-
- retval = io_channel_write_blk64(fs->io, new_desc_blk,
+ retval = io_channel_write_blk(fs->io, new_desc_blk,
1, group_ptr + (meta_bg*fs->blocksize));
if (retval)
goto errout;
}
}
- ext2fs_numeric_progress_close(fs, &progress, NULL);
-
/*
* If the write_bitmaps() function is present, call it to
* flush the bitmaps. This is done this way so that a simple
@@ -407,16 +351,14 @@ write_primary_superblock_only:
ext2fs_swap_super(super_shadow);
#endif
- if (!(flags & EXT2_FLAG_FLUSH_NO_SYNC))
- retval = io_channel_flush(fs->io);
+ retval = io_channel_flush(fs->io);
retval = write_primary_superblock(fs, super_shadow);
if (retval)
goto errout;
fs->flags &= ~EXT2_FLAG_DIRTY;
- if (!(flags & EXT2_FLAG_FLUSH_NO_SYNC))
- retval = io_channel_flush(fs->io);
+ retval = io_channel_flush(fs->io);
errout:
fs->super->s_state = fs_state;
#ifdef WORDS_BIGENDIAN
@@ -430,11 +372,6 @@ errout:
errcode_t ext2fs_close(ext2_filsys fs)
{
- return ext2fs_close2(fs, 0);
-}
-
-errcode_t ext2fs_close2(ext2_filsys fs, int flags)
-{
errcode_t retval;
int meta_blks;
io_stats stats = 0;
@@ -459,15 +396,10 @@ errcode_t ext2fs_close2(ext2_filsys fs, int flags)
fs->flags |= EXT2_FLAG_SUPER_ONLY | EXT2_FLAG_DIRTY;
}
if (fs->flags & EXT2_FLAG_DIRTY) {
- retval = ext2fs_flush2(fs, flags);
+ retval = ext2fs_flush(fs);
if (retval)
return retval;
}
-
- retval = ext2fs_mmp_stop(fs);
- if (retval)
- return retval;
-
ext2fs_free(fs);
return 0;
}
diff --git a/lib/ext2fs/crc32c.c b/lib/ext2fs/crc32c.c
deleted file mode 100644
index 5907500b..00000000
--- a/lib/ext2fs/crc32c.c
+++ /dev/null
@@ -1,1143 +0,0 @@
-/*
- * crc32c.c
- *
- * August 26, 2011 Darrick J. Wong <djwong at us.ibm.com>
- * Reuse Bob Pearson's slice-by-8 implementation for e2fsprogs.
- *
- * July 20, 2011 Bob Pearson <rpearson at systemfabricworks.com>
- * added slice by 8 algorithm to the existing conventional and
- * slice by 4 algorithms.
- *
- * Oct 15, 2000 Matt Domsch <Matt_Domsch@dell.com>
- * Nicer crc32 functions/docs submitted by linux@horizon.com. Thanks!
- * Code was from the public domain, copyright abandoned. Code was
- * subsequently included in the kernel, thus was re-licensed under the
- * GNU GPL v2.
- *
- * Oct 12, 2000 Matt Domsch <Matt_Domsch@dell.com>
- * Same crc32 function was used in 5 other places in the kernel.
- * I made one version, and deleted the others.
- * There are various incantations of crc32(). Some use a seed of 0 or ~0.
- * Some xor at the end with ~0. The generic crc32() function takes
- * seed as an argument, and doesn't xor at the end. Then individual
- * users can do whatever they need.
- * drivers/net/smc9194.c uses seed ~0, doesn't xor with ~0.
- * fs/jffs2 uses seed 0, doesn't xor with ~0.
- * fs/partitions/efi.c uses seed ~0, xor's with ~0.
- *
- * This source code is licensed under the GNU General Public License,
- * Version 2. See the file COPYING for more details.
- */
-#include <stdint.h>
-#include <stdlib.h>
-#include <stdio.h>
-#define __force
-#define min(x, y) ((x) > (y) ? (y) : (x))
-#define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
-#define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (__typeof__(x))(a) - 1)
-#define ALIGN(x, a) __ALIGN_KERNEL((x), (a))
-#define PTR_ALIGN(p, a) ((__typeof__(p))ALIGN((unsigned long)(p), (a)))
-#include "crc32c_defs.h"
-
-#include "ext2fs.h"
-#ifdef WORDS_BIGENDIAN
-#define __constant_cpu_to_le32(x) ___constant_swab32((x))
-#define __constant_cpu_to_be32(x) (x)
-#define __be32_to_cpu(x) (x)
-#define __cpu_to_be32(x) (x)
-#define __cpu_to_le32(x) (ext2fs_cpu_to_le32((x)))
-#define __le32_to_cpu(x) (ext2fs_le32_to_cpu((x)))
-#else
-#define __constant_cpu_to_le32(x) (x)
-#define __constant_cpu_to_be32(x) ___constant_swab32((x))
-#define __be32_to_cpu(x) (ext2fs_be32_to_cpu((x)))
-#define __cpu_to_be32(x) (ext2fs_cpu_to_be32((x)))
-#define __cpu_to_le32(x) (x)
-#define __le32_to_cpu(x) (x)
-#endif
-
-#if CRC_LE_BITS > 8
-# define tole(x) (__force uint32_t) __constant_cpu_to_le32(x)
-#else
-# define tole(x) (x)
-#endif
-
-#if CRC_BE_BITS > 8
-# define tobe(x) (__force uint32_t) __constant_cpu_to_be32(x)
-#else
-# define tobe(x) (x)
-#endif
-
-#include "crc32c_table.h"
-
-#if CRC_LE_BITS == 32
-/* slice by 4 algorithm */
-static uint32_t crc32c_le_body(uint32_t crc, uint8_t const *buf, size_t len)
-{
- const uint8_t *p8;
- const uint32_t *p32;
- size_t init_bytes;
- size_t words;
- size_t end_bytes;
- size_t i;
- uint32_t q;
- uint8_t i0, i1, i2, i3;
-
- crc = (__force uint32_t) __cpu_to_le32(crc);
-
- /* unroll loop into 'init_bytes' odd bytes followed by
- * 'words' aligned 4 byte words followed by
- * 'end_bytes' odd bytes at the end */
- p8 = buf;
- p32 = (uint32_t *)PTR_ALIGN(p8, 4);
- init_bytes = min((uintptr_t)p32 - (uintptr_t)p8, len);
- words = (len - init_bytes) >> 2;
- end_bytes = (len - init_bytes) & 3;
-
- for (i = 0; i < init_bytes; i++) {
-#ifndef WORDS_BIGENDIAN
- i0 = *p8++ ^ crc;
- crc = t0_le[i0] ^ (crc >> 8);
-#else
- i0 = *p8++ ^ (crc >> 24);
- crc = t0_le[i0] ^ (crc << 8);
-#endif
- }
-
- /* using pre-increment below slightly faster */
- p32--;
-
- for (i = 0; i < words; i++) {
-#ifndef WORDS_BIGENDIAN
- q = *++p32 ^ crc;
- i3 = q;
- i2 = q >> 8;
- i1 = q >> 16;
- i0 = q >> 24;
- crc = t3_le[i3] ^ t2_le[i2] ^ t1_le[i1] ^ t0_le[i0];
-#else
- q = *++p32 ^ crc;
- i3 = q >> 24;
- i2 = q >> 16;
- i1 = q >> 8;
- i0 = q;
- crc = t3_le[i3] ^ t2_le[i2] ^ t1_le[i1] ^ t0_le[i0];
-#endif
- }
-
- p8 = (uint8_t *)(++p32);
-
- for (i = 0; i < end_bytes; i++) {
-#ifndef WORDS_BIGENDIAN
- i0 = *p8++ ^ crc;
- crc = t0_le[i0] ^ (crc >> 8);
-#else
- i0 = *p8++ ^ (crc >> 24);
- crc = t0_le[i0] ^ (crc << 8);
-#endif
- }
-
- return __le32_to_cpu((__force __le32)crc);
-}
-#endif
-
-#if CRC_BE_BITS == 32
-static uint32_t crc32c_be_body(uint32_t crc, uint8_t const *buf, size_t len)
-{
- const uint8_t *p8;
- const uint32_t *p32;
- size_t init_bytes;
- size_t words;
- size_t end_bytes;
- size_t i;
- uint32_t q;
- uint8_t i0, i1, i2, i3;
-
- crc = (__force uint32_t) __cpu_to_be32(crc);
-
- p8 = buf;
- p32 = (uint32_t *)PTR_ALIGN(p8, 4);
- init_bytes = min((uintptr_t)p32 - (uintptr_t)p8, len);
- words = (len - init_bytes) >> 2;
- end_bytes = (len - init_bytes) & 3;
-
- for (i = 0; i < init_bytes; i++) {
-#ifndef WORDS_BIGENDIAN
- i0 = *p8++ ^ crc;
- crc = t0_be[i0] ^ (crc >> 8);
-#else
- i0 = *p8++ ^ (crc >> 24);
- crc = t0_be[i0] ^ (crc << 8);
-#endif
- }
-
- p32--;
-
- for (i = 0; i < words; i++) {
-#ifndef WORDS_BIGENDIAN
- q = *++p32 ^ crc;
- i3 = q;
- i2 = q >> 8;
- i1 = q >> 16;
- i0 = q >> 24;
- crc = t3_be[i3] ^ t2_be[i2] ^ t1_be[i1] ^ t0_be[i0];
-#else
- q = *++p32 ^ crc;
- i3 = q >> 24;
- i2 = q >> 16;
- i1 = q >> 8;
- i0 = q;
- crc = t3_be[i3] ^ t2_be[i2] ^ t1_be[i1] ^ t0_be[i0];
-#endif
- }
-
- p8 = (uint8_t *)(++p32);
-
- for (i = 0; i < end_bytes; i++) {
-#ifndef WORDS_BIGENDIAN
- i0 = *p8++ ^ crc;
- crc = t0_be[i0] ^ (crc >> 8);
-#else
- i0 = *p8++ ^ (crc >> 24);
- crc = t0_be[i0] ^ (crc << 8);
-#endif
- }
-
- return __be32_to_cpu((__force __be32)crc);
-}
-#endif
-
-#if CRC_LE_BITS == 64
-/* slice by 8 algorithm */
-static uint32_t crc32c_le_body(uint32_t crc, uint8_t const *buf, size_t len)
-{
- const uint8_t *p8;
- const uint32_t *p32;
- size_t init_bytes;
- size_t words;
- size_t end_bytes;
- size_t i;
- uint32_t q;
- uint8_t i0, i1, i2, i3;
-
- crc = (__force uint32_t) __cpu_to_le32(crc);
-
- p8 = buf;
- p32 = (const uint32_t *)PTR_ALIGN(p8, 8);
- init_bytes = min((uintptr_t)p32 - (uintptr_t)p8, len);
- words = (len - init_bytes) >> 3;
- end_bytes = (len - init_bytes) & 7;
-
- for (i = 0; i < init_bytes; i++) {
-#ifndef WORDS_BIGENDIAN
- i0 = *p8++ ^ crc;
- crc = t0_le[i0] ^ (crc >> 8);
-#else
- i0 = *p8++ ^ (crc >> 24);
- crc = t0_le[i0] ^ (crc << 8);
-#endif
- }
-
- p32--;
-
- for (i = 0; i < words; i++) {
-#ifndef WORDS_BIGENDIAN
- q = *++p32 ^ crc;
- i3 = q;
- i2 = q >> 8;
- i1 = q >> 16;
- i0 = q >> 24;
- crc = t7_le[i3] ^ t6_le[i2] ^ t5_le[i1] ^ t4_le[i0];
-
- q = *++p32;
- i3 = q;
- i2 = q >> 8;
- i1 = q >> 16;
- i0 = q >> 24;
- crc ^= t3_le[i3] ^ t2_le[i2] ^ t1_le[i1] ^ t0_le[i0];
-#else
- q = *++p32 ^ crc;
- i3 = q >> 24;
- i2 = q >> 16;
- i1 = q >> 8;
- i0 = q;
- crc = t7_le[i3] ^ t6_le[i2] ^ t5_le[i1] ^ t4_le[i0];
-
- q = *++p32;
- i3 = q >> 24;
- i2 = q >> 16;
- i1 = q >> 8;
- i0 = q;
- crc ^= t3_le[i3] ^ t2_le[i2] ^ t1_le[i1] ^ t0_le[i0];
-#endif
- }
-
- p8 = (const uint8_t *)(++p32);
-
- for (i = 0; i < end_bytes; i++) {
-#ifndef WORDS_BIGENDIAN
- i0 = *p8++ ^ crc;
- crc = t0_le[i0] ^ (crc >> 8);
-#else
- i0 = *p8++ ^ (crc >> 24);
- crc = t0_le[i0] ^ (crc << 8);
-#endif
- }
-
- return __le32_to_cpu(crc);
-}
-#endif
-
-#if CRC_BE_BITS == 64
-static uint32_t crc32c_be_body(uint32_t crc, uint8_t const *buf, size_t len)
-{
- const uint8_t *p8;
- const uint32_t *p32;
- size_t init_bytes;
- size_t words;
- size_t end_bytes;
- size_t i;
- uint32_t q;
- uint8_t i0, i1, i2, i3;
-
- crc = (__force uint32_t) __cpu_to_be32(crc);
-
- p8 = buf;
- p32 = (const uint32_t *)PTR_ALIGN(p8, 8);
- init_bytes = min((uintptr_t)p32 - (uintptr_t)p8, len);
- words = (len - init_bytes) >> 3;
- end_bytes = (len - init_bytes) & 7;
-
- for (i = 0; i < init_bytes; i++) {
-#ifndef WORDS_BIGENDIAN
- i0 = *p8++ ^ crc;
- crc = t0_be[i0] ^ (crc >> 8);
-#else
- i0 = *p8++ ^ (crc >> 24);
- crc = t0_be[i0] ^ (crc << 8);
-#endif
- }
-
- p32--;
-
- for (i = 0; i < words; i++) {
-#ifndef WORDS_BIGENDIAN
- q = *++p32 ^ crc;
- i3 = q;
- i2 = q >> 8;
- i1 = q >> 16;
- i0 = q >> 24;
- crc = t7_be[i3] ^ t6_be[i2] ^ t5_be[i1] ^ t4_be[i0];
-
- q = *++p32;
- i3 = q;
- i2 = q >> 8;
- i1 = q >> 16;
- i0 = q >> 24;
- crc ^= t3_be[i3] ^ t2_be[i2] ^ t1_be[i1] ^ t0_be[i0];
-#else
- q = *++p32 ^ crc;
- i3 = q >> 24;
- i2 = q >> 16;
- i1 = q >> 8;
- i0 = q;
- crc = t7_be[i3] ^ t6_be[i2] ^ t5_be[i1] ^ t4_be[i0];
-
- q = *++p32;
- i3 = q >> 24;
- i2 = q >> 16;
- i1 = q >> 8;
- i0 = q;
- crc ^= t3_be[i3] ^ t2_be[i2] ^ t1_be[i1] ^ t0_be[i0];
-#endif
- }
-
- p8 = (const uint8_t *)(++p32);
-
- for (i = 0; i < end_bytes; i++) {
-#ifndef WORDS_BIGENDIAN
- i0 = *p8++ ^ crc;
- crc = t0_be[i0] ^ (crc >> 8);
-#else
- i0 = *p8++ ^ (crc >> 24);
- crc = t0_be[i0] ^ (crc << 8);
-#endif
- }
-
- return __be32_to_cpu(crc);
-}
-#endif
-
-/**
- * crc32c_le() - Calculate bitwise little-endian CRC32c.
- * @crc: seed value for computation. ~0 for ext4, sometimes 0 for
- * other uses, or the previous crc32c value if computing incrementally.
- * @p: pointer to buffer over which CRC is run
- * @len: length of buffer @p
- */
-uint32_t ext2fs_crc32c_le(uint32_t crc, unsigned char const *p, size_t len)
-{
-#if CRC_LE_BITS == 1
- int i;
- while (len--) {
- crc ^= *p++;
- for (i = 0; i < 8; i++)
- crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0);
- }
-# elif CRC_LE_BITS == 2
- while (len--) {
- crc ^= *p++;
- crc = (crc >> 2) ^ t0_le[crc & 0x03];
- crc = (crc >> 2) ^ t0_le[crc & 0x03];
- crc = (crc >> 2) ^ t0_le[crc & 0x03];
- crc = (crc >> 2) ^ t0_le[crc & 0x03];
- }
-# elif CRC_LE_BITS == 4
- while (len--) {
- crc ^= *p++;
- crc = (crc >> 4) ^ t0_le[crc & 0x0f];
- crc = (crc >> 4) ^ t0_le[crc & 0x0f];
- }
-# elif CRC_LE_BITS == 8
- while (len--) {
- crc ^= *p++;
- crc = (crc >> 8) ^ t0_le[crc & 0xff];
- }
-# else
- crc = crc32c_le_body(crc, p, len);
-# endif
- return crc;
-}
-
-/**
- * crc32c_be() - Calculate bitwise big-endian CRC32c.
- * @crc: seed value for computation. ~0 for ext4, sometimes 0 for
- * other uses, or the previous crc32c value if computing incrementally.
- * @p: pointer to buffer over which CRC is run
- * @len: length of buffer @p
- */
-uint32_t ext2fs_crc32c_be(uint32_t crc, unsigned char const *p, size_t len)
-{
-#if CRC_BE_BITS == 1
- int i;
- while (len--) {
- crc ^= *p++ << 24;
- for (i = 0; i < 8; i++)
- crc = (crc << 1) ^
- ((crc & 0x80000000) ? CRCPOLY_BE : 0);
- }
-# elif CRC_BE_BITS == 2
- while (len--) {
- crc ^= *p++ << 24;
- crc = (crc << 2) ^ t0_be[crc >> 30];
- crc = (crc << 2) ^ t0_be[crc >> 30];
- crc = (crc << 2) ^ t0_be[crc >> 30];
- crc = (crc << 2) ^ t0_be[crc >> 30];
- }
-# elif CRC_BE_BITS == 4
- while (len--) {
- crc ^= *p++ << 24;
- crc = (crc << 4) ^ t0_be[crc >> 28];
- crc = (crc << 4) ^ t0_be[crc >> 28];
- }
-# elif CRC_BE_BITS == 8
- while (len--) {
- crc ^= *p++ << 24;
- crc = (crc << 8) ^ t0_be[crc >> 24];
- }
-# else
- crc = crc32c_be_body(crc, p, len);
-# endif
- return crc;
-}
-
-#ifdef UNITTEST
-static uint8_t test_buf[] = {
- 0xd9, 0xd7, 0x6a, 0x13, 0x3a, 0xb1, 0x05, 0x48,
- 0xda, 0xad, 0x14, 0xbd, 0x03, 0x3a, 0x58, 0x5e,
- 0x6e, 0xd1, 0x56, 0xc9, 0x2e, 0xc4, 0xcb, 0x6b,
- 0xe8, 0x77, 0x52, 0x37, 0x4e, 0x0f, 0x55, 0xd2,
- 0x12, 0x65, 0x90, 0xc2, 0x41, 0x49, 0x81, 0x01,
- 0xf5, 0x01, 0xeb, 0x2d, 0x78, 0x74, 0x23, 0x5d,
- 0x84, 0x5c, 0x81, 0x92, 0x21, 0xe9, 0x8d, 0x1d,
- 0x89, 0xf2, 0x4a, 0xac, 0xdd, 0xf9, 0xaf, 0xee,
- 0x44, 0xe7, 0x6e, 0xed, 0xfb, 0xd8, 0x89, 0x0e,
- 0x96, 0x62, 0xcd, 0xa4, 0x4b, 0xa9, 0xe5, 0x45,
- 0xb1, 0x29, 0x9b, 0x0f, 0xfc, 0xbd, 0x83, 0xab,
- 0xa8, 0x54, 0x96, 0x44, 0x2c, 0x7f, 0xbb, 0xe7,
- 0x52, 0x29, 0x08, 0xee, 0x14, 0xc5, 0xc2, 0xec,
- 0x5a, 0xeb, 0x40, 0x40, 0xea, 0xd1, 0x3d, 0x15,
- 0x73, 0xaa, 0x8c, 0x73, 0xfc, 0xf2, 0x2b, 0x49,
- 0x0b, 0x13, 0x96, 0xd9, 0x8e, 0x4b, 0xbc, 0xe0,
- 0xf4, 0xd2, 0xe0, 0x2e, 0x7a, 0xf0, 0x5d, 0x1f,
- 0xd2, 0x92, 0x97, 0xe0, 0xaa, 0x59, 0xab, 0xc9,
- 0x5c, 0xa6, 0x51, 0x1a, 0xe3, 0xd6, 0x06, 0xb9,
- 0xae, 0xb8, 0x76, 0x36, 0x79, 0x37, 0x52, 0xf6,
- 0x34, 0xaf, 0x27, 0x19, 0xe1, 0xc0, 0x2b, 0xdd,
- 0x01, 0x15, 0xcd, 0xce, 0x44, 0xf6, 0x4c, 0x18,
- 0x92, 0x69, 0xbe, 0x8a, 0x76, 0x23, 0x52, 0x13,
- 0x3f, 0xf9, 0xe0, 0xf5, 0x06, 0x28, 0x7c, 0xc7,
- 0xf3, 0x42, 0x0f, 0xdd, 0x40, 0x33, 0xf7, 0x99,
- 0xe2, 0xad, 0x26, 0xd9, 0x53, 0x10, 0x72, 0x0c,
- 0x4e, 0x43, 0x4c, 0x61, 0xfe, 0xd9, 0xc1, 0x16,
- 0xa1, 0x93, 0xca, 0x3c, 0x75, 0x7f, 0x07, 0x7a,
- 0x65, 0xb3, 0x53, 0x2a, 0x52, 0x00, 0xa0, 0x62,
- 0xe0, 0xa3, 0x1f, 0xad, 0xd7, 0xbb, 0xc0, 0x83,
- 0x5d, 0x54, 0x87, 0x5f, 0xc8, 0x2f, 0xc8, 0xbf,
- 0x69, 0x04, 0x91, 0xc8, 0xa6, 0x1d, 0x4d, 0x46,
- 0x91, 0xfc, 0x26, 0xf4, 0x16, 0xd1, 0xa4, 0xbf,
- 0x5c, 0xa2, 0x6c, 0xdd, 0xb4, 0x40, 0xf2, 0x2e,
- 0xa2, 0xad, 0xf7, 0xf4, 0xa5, 0x8a, 0x3e, 0x23,
- 0x64, 0x08, 0xc8, 0xa1, 0xa0, 0xf0, 0x5d, 0x70,
- 0xd2, 0x77, 0xfd, 0xc8, 0x50, 0x83, 0x0f, 0xd6,
- 0x2b, 0xe4, 0x1f, 0x52, 0x34, 0x33, 0x68, 0xfd,
- 0x92, 0xbe, 0x9f, 0x97, 0x6b, 0x8d, 0x81, 0x91,
- 0x0f, 0xef, 0x65, 0xc8, 0x0d, 0x15, 0x01, 0x77,
- 0x58, 0xb2, 0xf4, 0x1b, 0x06, 0x7e, 0xf5, 0xca,
- 0x15, 0x2e, 0x38, 0xd8, 0x81, 0x1c, 0x1c, 0xa0,
- 0xb6, 0x13, 0x6a, 0x2b, 0x71, 0x34, 0x52, 0xd7,
- 0x1d, 0xbd, 0x37, 0x59, 0xbc, 0x86, 0x25, 0x2b,
- 0xa8, 0x93, 0xce, 0x1a, 0x03, 0x16, 0xfe, 0x01,
- 0x57, 0x99, 0x24, 0x25, 0x2c, 0xb3, 0xab, 0x1e,
- 0x2d, 0x65, 0x20, 0x89, 0x17, 0x02, 0x0e, 0x0a,
- 0xf5, 0x1e, 0xc7, 0xff, 0x1f, 0x61, 0xa9, 0x54,
- 0x18, 0xd4, 0xba, 0x50, 0x57, 0x02, 0xa1, 0xab,
- 0x22, 0x2e, 0x07, 0xea, 0xa9, 0xa3, 0x83, 0x4f,
- 0x27, 0xf5, 0xc5, 0xee, 0x3c, 0x3b, 0x10, 0xad,
- 0x32, 0x2b, 0x1c, 0x03, 0xcb, 0xaf, 0x98, 0x83,
- 0x54, 0xc3, 0x68, 0x63, 0xd4, 0xe0, 0x0e, 0x3c,
- 0x1a, 0x4e, 0xc0, 0x81, 0xd0, 0xe8, 0x6a, 0x62,
- 0x6b, 0x3e, 0x6f, 0xc4, 0xc6, 0x33, 0x4e, 0x26,
- 0x21, 0xf5, 0x04, 0xdf, 0xfa, 0xce, 0x45, 0xaf,
- 0xdc, 0x5e, 0x1b, 0xad, 0x93, 0xca, 0xf5, 0xcf,
- 0xd7, 0xee, 0x0c, 0x5c, 0x5e, 0xb4, 0xf0, 0x92,
- 0xd2, 0xf2, 0xf0, 0xa9, 0x1e, 0xab, 0x80, 0x68,
- 0x46, 0xef, 0xcc, 0x26, 0x0c, 0x5c, 0xdd, 0x4e,
- 0x83, 0xb8, 0xb9, 0x53, 0x6e, 0xf8, 0x93, 0x38,
- 0x67, 0xa4, 0x41, 0x87, 0x72, 0xe7, 0x7e, 0x86,
- 0xc9, 0x49, 0x00, 0x33, 0xb1, 0x38, 0x6c, 0x71,
- 0xd7, 0x1d, 0x8e, 0x61, 0x01, 0xb6, 0x57, 0xa9,
- 0xf1, 0xac, 0x15, 0xc2, 0x83, 0x77, 0xca, 0x64,
- 0xca, 0x7b, 0x6c, 0xa1, 0x10, 0x1b, 0x13, 0xd0,
- 0xd3, 0x9e, 0x9e, 0x10, 0x70, 0xc8, 0x1a, 0xbb,
- 0x3f, 0x19, 0x86, 0xab, 0x01, 0x0e, 0xea, 0x34,
- 0x22, 0xea, 0xe2, 0x15, 0xb7, 0xed, 0x21, 0x21,
- 0x75, 0xa5, 0xe7, 0x08, 0xa1, 0x38, 0xe0, 0x91,
- 0x05, 0x60, 0xea, 0xa7, 0x50, 0x27, 0x18, 0x07,
- 0x9d, 0xe0, 0x18, 0x2b, 0xd4, 0x07, 0x59, 0x00,
- 0xe6, 0x45, 0x18, 0x2a, 0x30, 0x6e, 0xf3, 0xb4,
- 0xd0, 0xef, 0xa6, 0x5b, 0x71, 0xa2, 0x5a, 0x3b,
- 0x89, 0x4c, 0xaf, 0x3f, 0xcb, 0x9f, 0x03, 0xfb,
- 0x43, 0x7c, 0x6b, 0xd3, 0x6a, 0xea, 0xce, 0x4a,
- 0x5f, 0x64, 0xb5, 0x62, 0xda, 0x5d, 0x27, 0xb7,
- 0xb8, 0x11, 0xca, 0x33, 0x30, 0xec, 0x70, 0xf0,
- 0x1b, 0x03, 0x50, 0xff, 0x5e, 0xa6, 0x08, 0xde,
- 0x37, 0x70, 0xc0, 0x81, 0x55, 0x60, 0x17, 0xa1,
- 0x85, 0xae, 0x26, 0x44, 0xe4, 0x67, 0x3c, 0x91,
- 0xfd, 0xc4, 0x3d, 0x97, 0x72, 0x23, 0xf3, 0x3c,
- 0x8f, 0xe0, 0xe2, 0xf2, 0x09, 0x96, 0x10, 0x67,
- 0xb5, 0xfe, 0xff, 0x3d, 0x4a, 0xc8, 0x62, 0x11,
- 0xa5, 0x98, 0xc1, 0x2d, 0x40, 0x82, 0x88, 0x8b,
- 0xe5, 0xb0, 0x75, 0xbf, 0x2f, 0xa8, 0x6a, 0x55,
- 0x49, 0x2e, 0x9c, 0x29, 0xd2, 0x7c, 0xbf, 0xf3,
- 0xaa, 0x3a, 0x16, 0x4a, 0xa4, 0x15, 0xf3, 0x48,
- 0xde, 0x38, 0x13, 0x44, 0x26, 0x02, 0xe6, 0xe9,
- 0xa8, 0x24, 0x89, 0xb5, 0x43, 0x95, 0xe4, 0x4c,
- 0xc3, 0xa0, 0xdf, 0xcc, 0x42, 0xf8, 0x8d, 0xb0,
- 0x3b, 0xea, 0x10, 0xb7, 0xe1, 0x40, 0x54, 0xb9,
- 0xa3, 0x2d, 0xfb, 0xb4, 0x91, 0xc0, 0x3e, 0x94,
- 0xf1, 0xa1, 0x3c, 0xbe, 0xef, 0xb8, 0x70, 0x55,
- 0x0a, 0x26, 0x93, 0xbf, 0xe6, 0x21, 0x92, 0x32,
- 0x3c, 0x39, 0x27, 0x6a, 0x23, 0x48, 0x02, 0x35,
- 0x3c, 0xd4, 0xcc, 0x04, 0xc0, 0x4e, 0xa7, 0x02,
- 0x63, 0x37, 0xc2, 0xb8, 0x56, 0x1d, 0x57, 0x57,
- 0x42, 0x04, 0x8d, 0xee, 0xcf, 0x8b, 0xc9, 0xc3,
- 0xba, 0x3b, 0x15, 0xd7, 0xaf, 0xbf, 0x9e, 0xcd,
- 0x44, 0xcf, 0xf0, 0x00, 0xb7, 0x3a, 0xfc, 0xa8,
- 0x12, 0xab, 0x3a, 0x62, 0x01, 0x21, 0x46, 0xe9,
- 0x1e, 0x48, 0x37, 0xfc, 0x13, 0x4d, 0xf6, 0x2a,
- 0x72, 0x40, 0x75, 0x38, 0x71, 0xf2, 0x17, 0x20,
- 0x2c, 0xdd, 0xc0, 0x49, 0xbc, 0x63, 0x33, 0xea,
- 0x06, 0x75, 0x41, 0xe7, 0x5c, 0x1f, 0xfb, 0xf9,
- 0x68, 0x83, 0xc2, 0x5a, 0x4a, 0x1e, 0x61, 0x08,
- 0x57, 0xf3, 0x00, 0xba, 0x77, 0x92, 0x63, 0xa5,
- 0xb7, 0xfe, 0x97, 0x22, 0xda, 0x5e, 0xd3, 0xaf,
- 0xbc, 0x89, 0x0d, 0x4c, 0x37, 0xa9, 0x27, 0x4a,
- 0x7f, 0xdb, 0x81, 0x39, 0x11, 0x86, 0x12, 0xf9,
- 0x10, 0x50, 0xe4, 0xdb, 0x72, 0xf9, 0xae, 0x10,
- 0x7c, 0xed, 0x50, 0x5c, 0x61, 0xeb, 0x42, 0x1e,
- 0xa4, 0xf4, 0xf0, 0xfa, 0x45, 0x4d, 0x95, 0x2b,
- 0xd4, 0x67, 0x4a, 0xe3, 0x8a, 0x15, 0x55, 0x92,
- 0x77, 0x64, 0x8c, 0x51, 0x38, 0xf9, 0x26, 0x3e,
- 0x68, 0xe2, 0xac, 0xbb, 0x64, 0x77, 0xe2, 0x82,
- 0xa4, 0x42, 0x41, 0x38, 0xa0, 0xf0, 0xc9, 0xd8,
- 0x6c, 0xe0, 0xef, 0x4c, 0xda, 0xb4, 0x92, 0xef,
- 0x1b, 0xe3, 0x9b, 0xc1, 0x44, 0x3c, 0xb9, 0xb7,
- 0x39, 0xac, 0x5c, 0x32, 0x39, 0xb4, 0x21, 0x85,
- 0x93, 0xbc, 0xf2, 0x51, 0x43, 0xb7, 0xae, 0x1e,
- 0x61, 0x9c, 0x38, 0x9c, 0xaa, 0xff, 0xde, 0xfc,
- 0xbf, 0x85, 0xef, 0x17, 0x34, 0x36, 0x71, 0x5f,
- 0x04, 0x16, 0xa6, 0x9e, 0xfd, 0x3a, 0x03, 0xd8,
- 0xbf, 0x71, 0x70, 0x20, 0x8f, 0x7c, 0xfb, 0xff,
- 0x61, 0xe0, 0xe2, 0x60, 0xa7, 0xb1, 0xc0, 0xe0,
- 0xd9, 0x3f, 0xdc, 0x8d, 0x4a, 0xa4, 0x52, 0x61,
- 0xaf, 0x9d, 0xdf, 0x8a, 0x0d, 0x41, 0xc0, 0x25,
- 0x68, 0x12, 0x7b, 0xd5, 0xc7, 0xdb, 0x68, 0x70,
- 0x2d, 0x7d, 0x95, 0x12, 0x03, 0x23, 0x0c, 0xe8,
- 0x14, 0x41, 0x11, 0x28, 0xec, 0x9d, 0xd3, 0x28,
- 0x77, 0x7a, 0x3c, 0x93, 0x8e, 0x5c, 0x7e, 0xb3,
- 0x42, 0x9a, 0x18, 0x25, 0x93, 0xc8, 0xea, 0x43,
- 0x1b, 0xbe, 0xd5, 0x27, 0xf1, 0xd4, 0xe0, 0x1e,
- 0xce, 0xc7, 0xc7, 0x2c, 0x25, 0x35, 0x58, 0xb8,
- 0x6c, 0xf3, 0xa2, 0xad, 0xe7, 0x58, 0x49, 0x47,
- 0xf7, 0xca, 0xde, 0x8b, 0x81, 0xb7, 0x75, 0xf4,
- 0x95, 0xa7, 0x5c, 0xc3, 0x2c, 0x0e, 0x1c, 0x52,
- 0x9a, 0xc3, 0x2a, 0x00, 0x21, 0xa7, 0x51, 0x6b,
- 0xf0, 0x05, 0x87, 0x8c, 0x42, 0x1b, 0xc3, 0x2e,
- 0xa3, 0x76, 0x22, 0xd5, 0x7f, 0x56, 0x10, 0xef,
- 0x98, 0x85, 0x65, 0x86, 0x71, 0x87, 0xd2, 0x8c,
- 0xc0, 0x47, 0x20, 0xe8, 0xb5, 0x1c, 0xe3, 0xdd,
- 0x3c, 0x5c, 0x03, 0xbb, 0x0e, 0x97, 0x3b, 0xe1,
- 0x56, 0x9a, 0xd5, 0x0a, 0x63, 0xd5, 0x33, 0xaf,
- 0x36, 0xca, 0xcf, 0x8f, 0x00, 0x28, 0xa3, 0x45,
- 0xb8, 0xcd, 0xde, 0x73, 0xd4, 0xfa, 0x2d, 0x6f,
- 0xdb, 0x93, 0xaa, 0xdd, 0x7f, 0xd2, 0x22, 0x9c,
- 0x96, 0x48, 0x1e, 0xa8, 0x63, 0xbe, 0xbc, 0x0d,
- 0x14, 0x3c, 0x2e, 0x11, 0x1f, 0xd2, 0xf4, 0x57,
- 0xb3, 0x47, 0xf8, 0xa6, 0x1b, 0xc3, 0xa7, 0x95,
- 0x2d, 0xd4, 0xca, 0xb8, 0x0d, 0xfb, 0x06, 0x85,
- 0xda, 0x63, 0xf0, 0x3e, 0x9d, 0x5e, 0xee, 0xce,
- 0xed, 0x74, 0x1d, 0x2c, 0x97, 0x3f, 0x71, 0x95,
- 0x12, 0x03, 0xc5, 0x92, 0x46, 0x84, 0x1b, 0x07,
- 0xe6, 0xb4, 0x1d, 0x3a, 0xf1, 0x89, 0x90, 0x50,
- 0x10, 0x29, 0x34, 0xc0, 0x90, 0xbe, 0x4a, 0xa9,
- 0x0d, 0xb0, 0x7b, 0xfb, 0x35, 0xee, 0x4e, 0x34,
- 0xec, 0x5a, 0x58, 0xbc, 0xb8, 0xda, 0x38, 0x88,
- 0x8c, 0x74, 0x1e, 0xc9, 0xab, 0x78, 0x2e, 0x2a,
- 0x17, 0x8a, 0x43, 0x3d, 0xa1, 0x2a, 0x41, 0xb5,
- 0xd6, 0xe8, 0x5b, 0xc5, 0x4a, 0x1c, 0x3c, 0x9f,
- 0x8d, 0x3a, 0x69, 0x88, 0xf8, 0x80, 0xd2, 0x11,
- 0xfc, 0x7e, 0x80, 0x8e, 0x7f, 0x85, 0x64, 0x9c,
- 0x46, 0x58, 0xc8, 0x48, 0x98, 0x4b, 0xf5, 0x73,
- 0x3f, 0x49, 0xce, 0x53, 0x2c, 0xd5, 0xfc, 0x33,
- 0xf1, 0x6f, 0xd8, 0xe9, 0x2e, 0x70, 0x2e, 0xdc,
- 0xe5, 0x43, 0x80, 0x38, 0xf2, 0x87, 0xed, 0x85,
- 0xe4, 0x3e, 0x45, 0x14, 0x20, 0xcf, 0xa0, 0x61,
- 0x4f, 0xe8, 0xd7, 0x5b, 0xb3, 0x0d, 0x0e, 0x4e,
- 0x4d, 0xce, 0xbe, 0xba, 0xaa, 0x90, 0x09, 0xcb,
- 0x4b, 0x5d, 0x08, 0xff, 0x52, 0xd5, 0x23, 0xbc,
- 0xad, 0x8d, 0xd3, 0x06, 0x4a, 0xa0, 0x51, 0x56,
- 0xa7, 0xd8, 0x33, 0xab, 0xbc, 0xd0, 0xdf, 0x92,
- 0x87, 0x20, 0x2d, 0x7b, 0x5e, 0xfa, 0x30, 0xa7,
- 0x06, 0x06, 0xe5, 0x4f, 0x2c, 0xb5, 0x61, 0xd7,
- 0x54, 0xd3, 0xdf, 0xd0, 0x0a, 0xb0, 0x06, 0xce,
- 0xf6, 0x86, 0xb7, 0x8e, 0xaa, 0x7b, 0x78, 0xd5,
- 0xb9, 0xeb, 0x07, 0xac, 0x5f, 0xc5, 0xd2, 0x8c,
- 0x40, 0xe0, 0x7f, 0x98, 0xd4, 0xe5, 0x4b, 0xca,
- 0xfb, 0x47, 0xef, 0xef, 0xb9, 0x4d, 0x6d, 0x8f,
- 0x82, 0x68, 0x74, 0x84, 0xe0, 0x0a, 0x93, 0x0f,
- 0xb2, 0x01, 0xa9, 0x9f, 0x68, 0x6a, 0xe8, 0xf7,
- 0xfb, 0x0b, 0xde, 0x17, 0xe0, 0x30, 0x38, 0x51,
- 0xbc, 0x07, 0xb8, 0x2c, 0x91, 0x0f, 0xc1, 0x0e,
- 0xa6, 0xf9, 0xf0, 0xd5, 0x48, 0x76, 0x8a, 0xde,
- 0x74, 0xe3, 0x30, 0x65, 0x56, 0xb3, 0x5c, 0xe2,
- 0x89, 0x8d, 0xda, 0x80, 0xad, 0x0f, 0x22, 0xfb,
- 0x24, 0x1d, 0x16, 0xdd, 0x34, 0x4b, 0x90, 0x58,
- 0x4e, 0x0c, 0x13, 0x28, 0xcf, 0x1d, 0xa4, 0xaa,
- 0xb7, 0xf3, 0xb1, 0x66, 0xad, 0x3b, 0xcf, 0x79,
- 0x12, 0x04, 0xd7, 0x79, 0xd9, 0x5f, 0xdf, 0x89,
- 0xb2, 0x5b, 0xa7, 0x9a, 0x26, 0x1e, 0x67, 0x46,
- 0x7c, 0x66, 0x95, 0x67, 0xe6, 0x45, 0x8b, 0x1f,
- 0x65, 0x79, 0x9f, 0x6d, 0x11, 0x81, 0x17, 0x0d,
- 0x11, 0xb0, 0x5c, 0xb4, 0xc7, 0x27, 0x87, 0xab,
- 0x5d, 0x0a, 0x18, 0xae, 0x4e, 0x06, 0xa3, 0x3d,
- 0xc7, 0xb0, 0x22, 0xba, 0x03, 0xa4, 0x0f, 0xe5,
- 0x1c, 0x72, 0x2a, 0x04, 0xce, 0x83, 0xe9, 0xf3,
- 0xd7, 0xc9, 0x67, 0x6c, 0x1e, 0x6b, 0x3c, 0x9b,
- 0x0b, 0x5e, 0x6a, 0xa6, 0x79, 0x0a, 0xf1, 0xbe,
- 0xd7, 0xb4, 0x6f, 0x45, 0x1e, 0xfb, 0x78, 0x97,
- 0xaf, 0x34, 0x76, 0x95, 0x52, 0xf7, 0x3d, 0x5d,
- 0x07, 0x28, 0x57, 0x9c, 0x4a, 0x0f, 0xcf, 0x0b,
- 0x1b, 0xc4, 0xc2, 0x72, 0xd7, 0x72, 0x38, 0x9b,
- 0xea, 0xeb, 0xee, 0xae, 0x34, 0xc8, 0x01, 0xd7,
- 0xa5, 0xe3, 0xce, 0x41, 0xad, 0x02, 0x60, 0x23,
- 0x18, 0x36, 0xba, 0x17, 0xfa, 0xcf, 0xe4, 0xda,
- 0xdc, 0xfc, 0x82, 0xdc, 0x7c, 0x11, 0xf4, 0xb8,
- 0x52, 0x5d, 0xf7, 0x2f, 0xc8, 0xfe, 0x4a, 0xe6,
- 0xb9, 0xaf, 0x4b, 0x17, 0x18, 0x91, 0xc2, 0xfe,
- 0xd7, 0x3a, 0x77, 0x0c, 0xa0, 0x43, 0x9c, 0x6f,
- 0x13, 0x06, 0xbe, 0x6e, 0xe0, 0x1a, 0x3c, 0xf3,
- 0xf5, 0xcc, 0x78, 0xfb, 0x5d, 0xd5, 0xda, 0xb7,
- 0x58, 0xea, 0x86, 0x42, 0x6b, 0x32, 0xff, 0xb2,
- 0xe2, 0xee, 0x03, 0x1f, 0xf4, 0xef, 0xdb, 0x53,
- 0x79, 0xd5, 0x4e, 0xaf, 0x60, 0x8e, 0x02, 0xc2,
- 0xcc, 0x39, 0x97, 0x7b, 0xfd, 0xa1, 0xf8, 0x7a,
- 0x26, 0xe8, 0x55, 0xd6, 0xa4, 0x8b, 0xa0, 0x1b,
- 0x2d, 0x63, 0xaa, 0x73, 0x71, 0x6e, 0xbf, 0x8b,
- 0x3b, 0xe3, 0x1b, 0x0d, 0xbb, 0x2e, 0x44, 0x09,
- 0x64, 0xac, 0xc7, 0x9e, 0xb5, 0xc6, 0x77, 0xb0,
- 0x79, 0xb3, 0xaa, 0xfc, 0x67, 0x57, 0x9a, 0x50,
- 0x81, 0x37, 0x14, 0x7c, 0xd7, 0xa0, 0xd4, 0x6a,
- 0x79, 0x84, 0x51, 0x0e, 0x95, 0x0a, 0x30, 0xa3,
- 0x60, 0x55, 0x48, 0x05, 0x16, 0xae, 0x43, 0x90,
- 0xdc, 0x8e, 0x09, 0xbe, 0x79, 0xf6, 0x90, 0x74,
- 0xf8, 0x20, 0x96, 0x4d, 0xa7, 0xf5, 0x1a, 0x2b,
- 0xc7, 0x15, 0x9d, 0x18, 0xf7, 0x94, 0x87, 0xf7,
- 0xf4, 0xfb, 0x0d, 0x61, 0xb6, 0xd7, 0xbe, 0x10,
- 0x8e, 0x47, 0x3c, 0x10, 0x44, 0x90, 0x52, 0x21,
- 0x83, 0xc0, 0xf5, 0x99, 0xaa, 0xbc, 0xf6, 0x55,
- 0xae, 0xf5, 0xb2, 0xa4, 0xcd, 0x4d, 0xb9, 0x38,
- 0x6c, 0xbc, 0x80, 0xc3, 0xad, 0xf4, 0x46, 0x31,
- 0x01, 0x58, 0x2d, 0x88, 0x57, 0xc3, 0x23, 0xd1,
- 0x64, 0xc9, 0xa3, 0x21, 0x6b, 0x8b, 0x8a, 0x23,
- 0x2c, 0x4f, 0xa9, 0xcd, 0x67, 0xfa, 0x77, 0xad,
- 0xa3, 0x16, 0xa2, 0xe5, 0x19, 0x14, 0x70, 0x41,
- 0x5b, 0xda, 0x14, 0xde, 0xe3, 0xe5, 0xc1, 0x15,
- 0xb4, 0x77, 0xa4, 0x9b, 0xb8, 0xb1, 0x28, 0x51,
- 0x30, 0xb4, 0xf1, 0xf3, 0xf8, 0x6d, 0xd0, 0xc3,
- 0x8c, 0x4c, 0x76, 0xb0, 0x9a, 0xdf, 0xc8, 0xbe,
- 0xf8, 0x4a, 0x61, 0x6e, 0x3e, 0xd6, 0x3c, 0xe8,
- 0xde, 0x56, 0xa0, 0x9c, 0x25, 0xbe, 0xce, 0x93,
- 0x1f, 0x88, 0xfb, 0x9a, 0x1a, 0xe2, 0xff, 0x88,
- 0xad, 0x10, 0xcb, 0x6c, 0xd6, 0xe7, 0x39, 0x0b,
- 0xe5, 0x1a, 0x06, 0x05, 0x64, 0x5b, 0x0a, 0xdf,
- 0x22, 0x58, 0xd7, 0xfb, 0x88, 0x12, 0xdd, 0xb7,
- 0x52, 0x3a, 0xc9, 0xbf, 0x49, 0xdf, 0x8c, 0x87,
- 0x9f, 0x84, 0xb5, 0x0a, 0xf6, 0x00, 0x52, 0xae,
- 0x67, 0x12, 0x1a, 0x8c, 0x71, 0x15, 0xf5, 0xa1,
- 0x13, 0x39, 0xf0, 0x91, 0x7e, 0x88, 0x7c, 0xb3,
- 0x95, 0x50, 0x02, 0xa6, 0x63, 0xb5, 0x64, 0xfb,
- 0x90, 0x87, 0x61, 0xe2, 0x27, 0xaf, 0x11, 0x0c,
- 0x73, 0x83, 0xef, 0xa9, 0x28, 0xfe, 0xc8, 0x85,
- 0x1a, 0x3a, 0xde, 0xf2, 0xe5, 0x25, 0x64, 0x6d,
- 0xaa, 0x41, 0x4c, 0x80, 0x2e, 0x84, 0xff, 0xc1,
- 0xc0, 0x54, 0x0c, 0x29, 0x1b, 0xa3, 0x07, 0x7c,
- 0x33, 0x4c, 0x10, 0xf6, 0x6f, 0x79, 0xdf, 0xd3,
- 0xf0, 0x24, 0x57, 0xf1, 0x60, 0xe1, 0xf0, 0xbd,
- 0xc4, 0x1f, 0xf4, 0x67, 0xd2, 0xd3, 0xcc, 0x6a,
- 0x07, 0x72, 0x44, 0x16, 0x85, 0x46, 0xd0, 0x73,
- 0x87, 0xa9, 0xc7, 0x2f, 0xd1, 0xf5, 0xec, 0xe3,
- 0x28, 0xa3, 0x93, 0x4f, 0xd7, 0x76, 0xc1, 0x3c,
- 0x0d, 0x13, 0x33, 0xcf, 0x5b, 0xbd, 0x6a, 0x52,
- 0x4e, 0xee, 0xc8, 0x5e, 0xa1, 0x58, 0x4a, 0x08,
- 0x81, 0xd9, 0x23, 0xcc, 0xfb, 0x1c, 0xb2, 0xd8,
- 0xa3, 0xe4, 0x53, 0xfe, 0xf4, 0x4b, 0x48, 0xc1,
- 0x20, 0xa4, 0x97, 0xf8, 0x38, 0xa3, 0x69, 0xc1,
- 0x11, 0xf0, 0xa1, 0x3b, 0xa9, 0x9a, 0x12, 0x61,
- 0xe8, 0x8d, 0x99, 0x44, 0x3f, 0x94, 0x72, 0x82,
- 0x19, 0x96, 0x62, 0xb0, 0xa6, 0x64, 0x05, 0x19,
- 0x8f, 0xd6, 0x5d, 0x05, 0xbf, 0x79, 0x9e, 0x9d,
- 0xe4, 0x93, 0x4c, 0xad, 0x61, 0x8c, 0x18, 0xda,
- 0xb6, 0x2e, 0xb3, 0xca, 0x14, 0x4d, 0x53, 0xa4,
- 0x97, 0x27, 0x10, 0x56, 0xa2, 0x67, 0x5a, 0x5a,
- 0x5e, 0x13, 0xc0, 0xdb, 0xa7, 0x9f, 0x45, 0x5b,
- 0xeb, 0x1a, 0x14, 0x0c, 0x8c, 0x38, 0x5e, 0x77,
- 0x9a, 0xec, 0x75, 0x68, 0x93, 0x65, 0x02, 0x9c,
- 0xfb, 0x62, 0x60, 0x49, 0xdd, 0xb2, 0x2a, 0x67,
- 0x86, 0xe3, 0x8a, 0x7d, 0x8c, 0x46, 0x78, 0x81,
- 0x60, 0x69, 0xf2, 0x3f, 0x74, 0x11, 0x35, 0xff,
- 0x77, 0xa3, 0x66, 0x20, 0xfc, 0x98, 0x4a, 0x35,
- 0x7a, 0x52, 0xe4, 0x90, 0x13, 0x80, 0xb9, 0xa6,
- 0x73, 0x7a, 0x7d, 0x66, 0x6e, 0x6b, 0xb6, 0x43,
- 0x10, 0xd5, 0x91, 0x2b, 0x66, 0xdd, 0x89, 0x87,
- 0xe3, 0x8c, 0x58, 0x53, 0x2f, 0x40, 0x74, 0x45,
- 0x1b, 0x77, 0x7a, 0xa4, 0x44, 0x19, 0x78, 0xba,
- 0x87, 0x10, 0x41, 0x31, 0x32, 0x5f, 0x87, 0x68,
- 0xde, 0x43, 0x4a, 0xef, 0x33, 0xb3, 0x11, 0x83,
- 0xa9, 0xc2, 0x6f, 0x8d, 0x34, 0xe2, 0x95, 0x84,
- 0x3a, 0x4f, 0x6f, 0x8c, 0x31, 0x1d, 0xb6, 0xf5,
- 0x95, 0x0d, 0x01, 0x11, 0x20, 0xdf, 0x72, 0xf3,
- 0x3f, 0x9a, 0x33, 0xaa, 0xb1, 0x06, 0x6a, 0x63,
- 0x47, 0x91, 0x01, 0xdf, 0xb3, 0x54, 0x36, 0xfd,
- 0x06, 0x2d, 0xb8, 0x08, 0xe3, 0xd3, 0x65, 0xac,
- 0x66, 0x03, 0xee, 0xa4, 0x63, 0xbd, 0xd4, 0xce,
- 0xbd, 0x79, 0xa7, 0x48, 0x38, 0xc5, 0x7d, 0xb5,
- 0x71, 0x9a, 0x3c, 0x11, 0x7c, 0x6c, 0xe2, 0x54,
- 0x02, 0x5d, 0x42, 0xab, 0x25, 0x93, 0x66, 0x01,
- 0x37, 0x78, 0x35, 0x4a, 0x8c, 0x19, 0x4d, 0x00,
- 0x75, 0x4f, 0xcc, 0xc0, 0x26, 0x82, 0xc1, 0x35,
- 0x8c, 0xc7, 0xc2, 0x59, 0x01, 0x3e, 0x98, 0x22,
- 0x88, 0x9c, 0x90, 0x75, 0x05, 0x33, 0x07, 0xb9,
- 0x39, 0x81, 0x38, 0x58, 0x10, 0x29, 0xcf, 0xc8,
- 0x98, 0xb2, 0x03, 0xd7, 0x5b, 0xb3, 0x18, 0xba,
- 0x34, 0x0c, 0x9f, 0xab, 0xd7, 0xed, 0x29, 0x82,
- 0x41, 0xe0, 0x20, 0x97, 0x57, 0x92, 0xb2, 0xb8,
- 0x10, 0x2d, 0x0b, 0xa2, 0xc5, 0x8f, 0x90, 0x6f,
- 0xed, 0x12, 0x56, 0x25, 0xbe, 0xfd, 0x75, 0xf7,
- 0xb6, 0xf8, 0x40, 0x67, 0x39, 0x11, 0xfa, 0x15,
- 0xae, 0x6a, 0x54, 0x5f, 0x32, 0x2b, 0xf8, 0x48,
- 0x55, 0xbe, 0x86, 0x2f, 0x69, 0x48, 0x5b, 0x5d,
- 0x4d, 0xb7, 0x35, 0xaa, 0xb6, 0x91, 0x88, 0x19,
- 0x96, 0x1c, 0x68, 0xf6, 0x85, 0x9e, 0xb3, 0xb2,
- 0xa3, 0x32, 0xd4, 0x52, 0x70, 0xb7, 0x62, 0xe3,
- 0x14, 0xb6, 0x78, 0x5f, 0x1b, 0x1d, 0x04, 0x9c,
- 0x26, 0x0c, 0x33, 0x94, 0xb1, 0x97, 0x08, 0xdb,
- 0x0b, 0x39, 0x29, 0xd4, 0xbc, 0x6d, 0xdf, 0x02,
- 0xc6, 0x99, 0xab, 0x99, 0x32, 0xe5, 0xce, 0x51,
- 0x4f, 0xae, 0xb8, 0x8b, 0xe0, 0xaf, 0x07, 0xc4,
- 0xf9, 0x41, 0x7c, 0x59, 0xa0, 0xac, 0x74, 0x4d,
- 0x7e, 0x43, 0x77, 0x9c, 0x06, 0x49, 0x79, 0x8a,
- 0x14, 0x73, 0x93, 0xa8, 0x5b, 0x1b, 0x34, 0x29,
- 0x78, 0x04, 0x2f, 0xd7, 0x1f, 0x13, 0x90, 0xe0,
- 0xdd, 0x3b, 0x42, 0x6b, 0x79, 0x6e, 0x52, 0xc7,
- 0x0f, 0x38, 0xda, 0x01, 0x2c, 0x8d, 0xe6, 0x94,
- 0x5d, 0x59, 0x27, 0x1d, 0x10, 0x4e, 0x11, 0x36,
- 0xfb, 0x53, 0x16, 0x05, 0x25, 0xf2, 0x64, 0xd8,
- 0xf9, 0xcd, 0x5c, 0xfe, 0xb4, 0x18, 0x44, 0x80,
- 0x10, 0xbc, 0x3d, 0xf3, 0x1d, 0x5a, 0xf0, 0xc1,
- 0xc3, 0x55, 0xff, 0x41, 0x3e, 0xe3, 0xef, 0x44,
- 0xb2, 0xc0, 0x01, 0x18, 0xa2, 0x49, 0x88, 0x78,
- 0x0d, 0x4c, 0xc8, 0x73, 0xcf, 0x30, 0x85, 0x3a,
- 0x88, 0x90, 0x01, 0xcf, 0x69, 0x53, 0xa3, 0x18,
- 0x3f, 0xd6, 0xe7, 0x94, 0x14, 0xa7, 0xae, 0xcd,
- 0x6f, 0x11, 0x72, 0xfe, 0x2b, 0xb0, 0x81, 0x53,
- 0xea, 0x67, 0xd6, 0xe4, 0xca, 0x42, 0xa0, 0xf9,
- 0xb1, 0xd4, 0xb5, 0x3b, 0xc9, 0xf0, 0x36, 0xc1,
- 0x1c, 0xf4, 0xb1, 0xf6, 0x84, 0xd0, 0x86, 0x6c,
- 0x76, 0x9a, 0x03, 0xc2, 0xb6, 0x2e, 0x9a, 0x46,
- 0xf5, 0x5f, 0x2c, 0x38, 0xac, 0xad, 0x6f, 0x2e,
- 0x7a, 0x18, 0x2d, 0x22, 0x95, 0x5e, 0x5e, 0xc9,
- 0x7a, 0x0a, 0x56, 0xe1, 0xc7, 0x15, 0xfd, 0xbf,
- 0xff, 0xf7, 0x7e, 0x85, 0x20, 0xa9, 0x8a, 0x9c,
- 0xa9, 0x7d, 0xe8, 0xed, 0xfc, 0x7f, 0xbb, 0xf0,
- 0x05, 0x3f, 0xce, 0x4f, 0x4c, 0xee, 0xa4, 0xa0,
- 0xcc, 0x9c, 0x62, 0x1e, 0xd6, 0xd0, 0x30, 0x37,
- 0xb8, 0x98, 0x56, 0x1d, 0xaa, 0xd6, 0x5e, 0x73,
- 0x12, 0xe4, 0x88, 0x82, 0x48, 0x64, 0x06, 0xd7,
- 0x2a, 0x31, 0x50, 0x7b, 0x10, 0x17, 0xb8, 0x4c,
- 0x5a, 0x8d, 0xf1, 0xfc, 0xf1, 0x33, 0x3b, 0x98,
- 0x42, 0x18, 0x5b, 0x35, 0x78, 0xca, 0x8e, 0x41,
- 0x52, 0xae, 0x6d, 0xe1, 0xa2, 0x9d, 0x5b, 0xbd,
- 0xf3, 0x5f, 0x49, 0xc1, 0x27, 0x06, 0xc1, 0xaf,
- 0xc0, 0xa3, 0x9d, 0xf3, 0x1c, 0x8e, 0x90, 0x8a,
- 0xb0, 0x69, 0xb0, 0xc5, 0x11, 0x0c, 0x91, 0x14,
- 0x1f, 0x5e, 0x10, 0xe1, 0x1d, 0x14, 0x30, 0x54,
- 0x1e, 0x17, 0x3d, 0x31, 0x7b, 0xbf, 0x2f, 0x9d,
- 0x6d, 0x63, 0x32, 0xf0, 0x9d, 0x9f, 0x95, 0x3d,
- 0x0b, 0xd2, 0x4d, 0x10, 0xe2, 0x3f, 0x67, 0x69,
- 0x43, 0x9a, 0x4a, 0x2c, 0x54, 0x71, 0xa8, 0xa0,
- 0x9e, 0x9f, 0x10, 0xaf, 0x1b, 0xce, 0x99, 0xe3,
- 0x25, 0x32, 0x10, 0x54, 0x80, 0xfe, 0xda, 0x57,
- 0xd0, 0xb2, 0x92, 0x7f, 0xbb, 0x5f, 0xe7, 0x4d,
- 0x1b, 0x3d, 0x46, 0x4d, 0xe4, 0x4c, 0xd6, 0xaf,
- 0x1a, 0x32, 0x12, 0x40, 0xb8, 0x84, 0x8e, 0xe4,
- 0x80, 0xce, 0x7e, 0xc1, 0x13, 0x8b, 0xb0, 0xb7,
- 0x6f, 0x24, 0xba, 0x85, 0x50, 0x83, 0xc3, 0xcf,
- 0x19, 0xb3, 0xf0, 0xc7, 0xee, 0x68, 0xbe, 0x9e,
- 0x6d, 0xb9, 0xfb, 0xd5, 0x29, 0xce, 0x82, 0xcd,
- 0x69, 0x16, 0x68, 0x6b, 0x6a, 0xf4, 0x02, 0x32,
- 0xce, 0x60, 0x37, 0x0c, 0xb9, 0x38, 0x92, 0x9c,
- 0x42, 0xa9, 0x0b, 0x53, 0x96, 0xfe, 0x39, 0xc1,
- 0x24, 0x65, 0x9b, 0xcd, 0xe7, 0x8d, 0x36, 0x07,
- 0x9f, 0x1d, 0x35, 0x8e, 0xdc, 0x4c, 0xb5, 0x68,
- 0xc5, 0xfd, 0x44, 0x19, 0xf2, 0x6c, 0x59, 0x1c,
- 0xb1, 0x0b, 0x35, 0x48, 0x86, 0x1a, 0x05, 0x22,
- 0x03, 0x0c, 0x0c, 0xa2, 0x92, 0x90, 0x35, 0xfb,
- 0x37, 0x94, 0xc7, 0x15, 0x84, 0xae, 0xe8, 0x05,
- 0xa0, 0xf7, 0x30, 0x11, 0x5c, 0xe4, 0x5d, 0x3e,
- 0x12, 0x54, 0x80, 0x54, 0x6b, 0x09, 0x8c, 0xce,
- 0x80, 0x5e, 0xa7, 0xc8, 0x6a, 0x0c, 0x56, 0xe1,
- 0x18, 0x7d, 0xc9, 0x39, 0xc1, 0xef, 0xe3, 0x25,
- 0xa0, 0x8b, 0x2f, 0x60, 0x3a, 0x43, 0x39, 0xa6,
- 0x28, 0x28, 0x7b, 0x4c, 0x77, 0xd4, 0x49, 0x61,
- 0x46, 0xe9, 0x1b, 0x45, 0xd6, 0xb1, 0x56, 0xe1,
- 0x7d, 0x34, 0xcd, 0x06, 0xb6, 0x67, 0x8d, 0x7d,
- 0x7a, 0xe2, 0xbe, 0x68, 0x35, 0xa6, 0x78, 0xe5,
- 0x47, 0x48, 0xb7, 0xc7, 0xde, 0xcd, 0xc9, 0x05,
- 0xb4, 0xe7, 0x50, 0x48, 0xe1, 0x4b, 0xfe, 0x76,
- 0x77, 0xc6, 0xf7, 0x5f, 0xcb, 0xc2, 0xa8, 0xd7,
- 0xd6, 0x8a, 0xe5, 0x49, 0xd9, 0xca, 0x45, 0xf4,
- 0xda, 0xcd, 0x33, 0xd1, 0x59, 0x2d, 0x9e, 0xc1,
- 0x5c, 0xe6, 0x01, 0x18, 0xb8, 0xf0, 0x5e, 0xb1,
- 0x69, 0x95, 0x2f, 0x02, 0x2a, 0xe7, 0x4a, 0xd7,
- 0xd1, 0xc3, 0xd5, 0x6f, 0x15, 0xc8, 0xdc, 0x29,
- 0xde, 0xb9, 0x3f, 0x8b, 0xa6, 0xbc, 0xdd, 0x25,
- 0x84, 0x35, 0x3c, 0x90, 0x2d, 0xc2, 0x1e, 0x98,
- 0x8a, 0x50, 0x09, 0x77, 0x42, 0xe9, 0x35, 0x8a,
- 0x7c, 0x97, 0xbf, 0xe8, 0xbf, 0x56, 0xd0, 0x8b,
- 0x65, 0xd3, 0xaf, 0x1e, 0x05, 0x94, 0xfa, 0xac,
- 0xa8, 0x2b, 0x28, 0xcb, 0x37, 0x3e, 0xe8, 0xbb,
- 0x66, 0x3a, 0xed, 0xb2, 0x48, 0x10, 0x0f, 0x3a,
- 0x5a, 0xc5, 0xdb, 0x26, 0x0e, 0xaa, 0x5e, 0x69,
- 0x15, 0xd6, 0x81, 0xae, 0xbd, 0xe6, 0x03, 0xf1,
- 0xf6, 0x37, 0xc8, 0xde, 0x70, 0x1f, 0x64, 0xb9,
- 0x5e, 0xbf, 0x2e, 0x4f, 0xb1, 0xea, 0xa0, 0x17,
- 0xe6, 0x7c, 0xf9, 0x2f, 0x1e, 0xd8, 0x58, 0xde,
- 0xa7, 0xf0, 0x46, 0x52, 0x95, 0xdf, 0xa4, 0x96,
- 0xd0, 0xc4, 0x97, 0x2b, 0x95, 0xcd, 0x5e, 0x40,
- 0x23, 0x5c, 0x10, 0xee, 0xba, 0x72, 0x9b, 0xcf,
- 0x0b, 0xe8, 0x18, 0x3a, 0x70, 0xd2, 0x5e, 0x07,
- 0x68, 0x93, 0xef, 0x4a, 0x5b, 0x8d, 0x72, 0x41,
- 0x4e, 0xea, 0x33, 0x6a, 0x0a, 0x5e, 0xfb, 0x02,
- 0x3f, 0xd4, 0xed, 0x5b, 0xe0, 0x42, 0x84, 0xd4,
- 0xaa, 0x85, 0xdc, 0x5b, 0x67, 0xee, 0x71, 0x67,
- 0xba, 0x8e, 0xd2, 0xbe, 0x61, 0xdf, 0x5a, 0x26,
- 0xb9, 0xf0, 0x77, 0x81, 0x53, 0x24, 0x16, 0xcb,
- 0x8c, 0xb8, 0x06, 0x6e, 0x68, 0xda, 0xc8, 0x2d,
- 0x17, 0x54, 0xdb, 0x46, 0xcb, 0xfd, 0x1f, 0x3d,
- 0x94, 0x81, 0x09, 0x4b, 0xfa, 0xb1, 0x46, 0xd9,
- 0x11, 0xa3, 0xb7, 0x31, 0x9c, 0xd2, 0x38, 0xd6,
- 0xba, 0x3d, 0xa3, 0x74, 0xd8, 0xf1, 0x24, 0xe8,
- 0x9c, 0xcb, 0x1d, 0xf9, 0x4a, 0xf7, 0xc8, 0x4b,
- 0xfe, 0x97, 0x7c, 0xa1, 0x02, 0xeb, 0x40, 0xc3,
- 0x89, 0x71, 0x01, 0xcd, 0x33, 0x2a, 0xc2, 0x82,
- 0xce, 0x62, 0x8d, 0x53, 0x7c, 0xdf, 0xce, 0xd7,
- 0xf5, 0xa8, 0x4f, 0xf2, 0xf2, 0x2e, 0xc1, 0xeb,
- 0x97, 0x99, 0x37, 0x3c, 0x53, 0xa6, 0xb4, 0x46,
- 0x05, 0x64, 0x92, 0x87, 0x08, 0x3c, 0x23, 0x4b,
- 0x9d, 0x67, 0x18, 0xf9, 0xe2, 0x0b, 0x1c, 0x39,
- 0xd3, 0x87, 0x70, 0xc0, 0xb9, 0x1e, 0x52, 0x0a,
- 0x0f, 0x48, 0xe2, 0xe7, 0x51, 0x72, 0x94, 0xf7,
- 0xa3, 0xdc, 0xe5, 0x66, 0x33, 0x39, 0x54, 0x06,
- 0x55, 0x93, 0x30, 0xf9, 0x5e, 0x76, 0x8f, 0xe0,
- 0x59, 0x4d, 0x0d, 0xa7, 0xf5, 0xbe, 0xdb, 0x20,
- 0xad, 0x0d, 0x76, 0x88, 0x5f, 0x9c, 0x7c, 0x75,
- 0x2f, 0x2a, 0x0b, 0x79, 0x6e, 0xd3, 0xe2, 0x66,
- 0xf5, 0x4a, 0x2d, 0x87, 0x87, 0x49, 0x84, 0x17,
- 0xa2, 0x62, 0x4c, 0xbb, 0xe4, 0x6e, 0x98, 0x10,
- 0xc9, 0xfb, 0x8a, 0x04, 0x68, 0x8d, 0x22, 0x66,
- 0xad, 0xea, 0x2a, 0xc9, 0x97, 0x2d, 0x3c, 0xbc,
- 0xd0, 0x77, 0x5f, 0xe6, 0xb8, 0x7f, 0xe6, 0xf6,
- 0x39, 0xbf, 0x56, 0x0e, 0x26, 0x6d, 0xc5, 0x3e,
- 0x53, 0x19, 0xd6, 0xb4, 0x57, 0x36, 0xa3, 0xc6,
- 0xd3, 0x3d, 0x66, 0x79, 0x30, 0x5c, 0x14, 0x0c,
- 0x0f, 0x3e, 0x96, 0xae, 0x90, 0x97, 0xab, 0x0d,
- 0x9f, 0xc3, 0xe7, 0x66, 0x3e, 0xe0, 0x31, 0x43,
- 0x4b, 0x01, 0xb3, 0x0e, 0x9e, 0x8c, 0x82, 0x4a,
- 0x8c, 0xc7, 0x79, 0x85, 0xdf, 0x75, 0x0d, 0xb4,
- 0x2b, 0x03, 0x14, 0xef, 0x72, 0x58, 0xfd, 0x64,
- 0xc8, 0xe3, 0x0d, 0x9a, 0x14, 0x6f, 0x76, 0xf9,
- 0x46, 0xd1, 0xd2, 0x81, 0xb3, 0x16, 0x6e, 0xc7,
- 0x76, 0x82, 0xce, 0xf4, 0xee, 0x33, 0x00, 0xe6,
- 0x77, 0xc4, 0xad, 0x4f, 0x06, 0xa7, 0x48, 0x80,
- 0x9e, 0x21, 0x66, 0xca, 0x75, 0x69, 0x57, 0xcb,
- 0xf0, 0x67, 0x6a, 0xaa, 0x8f, 0x88, 0x14, 0xbd,
- 0x65, 0x62, 0xe2, 0xad, 0xcc, 0x22, 0x88, 0x7b,
- 0x94, 0xbd, 0x0e, 0xcd, 0xb6, 0x69, 0xa2, 0xcb,
- 0x7d, 0x57, 0x5c, 0xb4, 0x92, 0x80, 0x13, 0x99,
- 0x84, 0xf3, 0x79, 0x0a, 0x2d, 0x70, 0xa4, 0xe0,
- 0xde, 0xc6, 0x32, 0xb0, 0x8a, 0x62, 0xb5, 0xcf,
- 0xfa, 0x5e, 0x5a, 0x92, 0x32, 0x7d, 0x34, 0x07,
- 0xb5, 0x52, 0x3a, 0xb5, 0x7d, 0x0f, 0xa1, 0xba,
- 0x56, 0xd0, 0x07, 0x76, 0x11, 0xf2, 0xc3, 0x33,
- 0x9d, 0xbd, 0x12, 0x35, 0x5e, 0xf7, 0x05, 0x88,
- 0x76, 0x94, 0xa6, 0xbf, 0xed, 0xb8, 0xa4, 0xa2,
- 0x0c, 0xbe, 0x0f, 0x6a, 0xaf, 0xf3, 0x1b, 0x33,
- 0x4a, 0xb7, 0x68, 0x3f, 0xbe, 0x95, 0x13, 0x97,
- 0x0f, 0x15, 0x17, 0x1b, 0x23, 0xaa, 0x08, 0x78,
- 0xa6, 0x5b, 0x08, 0xa2, 0x9d, 0x03, 0xa8, 0xa7,
- 0x39, 0xdc, 0xbc, 0x9a, 0x85, 0xf5, 0xe5, 0x55,
- 0x59, 0x3c, 0xef, 0xf9, 0x3f, 0x22, 0x8e, 0xf8,
- 0xd8, 0x3e, 0x02, 0x0b, 0xd8, 0x78, 0x4b, 0x15,
- 0x7f, 0xaa, 0x2c, 0xff, 0xbe, 0x77, 0x33, 0xc7,
- 0x6a, 0x12, 0xaa, 0xa4, 0xbe, 0xc0, 0x3b, 0xcb,
- 0x13, 0x9d, 0x9c, 0x5a, 0x9f, 0x8a, 0x57, 0x36,
- 0x4f, 0x02, 0x5a, 0xf8, 0x1d, 0x97, 0x77, 0x43,
- 0xc8, 0xa5, 0xb7, 0x9b, 0x10, 0x98, 0xfd, 0x58,
- 0xbf, 0x42, 0xf6, 0xbf, 0xff, 0x6c, 0x40, 0x18,
- 0x18, 0xdf, 0xac, 0x57, 0x71, 0xea, 0xcc, 0x8e,
- 0xfd, 0xfe, 0x10, 0xfb, 0xb9, 0xfe, 0xbc, 0x9a,
- 0x9c, 0x27, 0xe4, 0x10, 0x15, 0x94, 0x41, 0xa1,
- 0xcc, 0xf6, 0x25, 0x49, 0x4f, 0x96, 0xc1, 0x8c,
- 0x9e, 0x3e, 0x18, 0x29, 0x49, 0x92, 0xe7, 0xfe,
- 0x22, 0xff, 0xed, 0x02, 0x16, 0x90, 0xef, 0xac,
- 0xec, 0x95, 0x1d, 0x5b, 0x94, 0x9c, 0xf6, 0x7c,
- 0x1b, 0x5a, 0x9d, 0xb0, 0x9b, 0x05, 0x36, 0xbf,
- 0xef, 0xec, 0x63, 0x35, 0x40, 0x24, 0x45, 0x40,
- 0x30, 0x1a, 0x9b, 0x90, 0xc3, 0xc2, 0xf7, 0x37,
- 0xfb, 0x08, 0x8e, 0x48, 0x19, 0x48, 0xed, 0xa8,
- 0xa8, 0x04, 0x6f, 0xd0, 0x33, 0xe9, 0xb8, 0x8d,
- 0xe7, 0x1e, 0x5c, 0x47, 0x74, 0xc0, 0x66, 0x30,
- 0x4e, 0xa7, 0x86, 0x73, 0xf1, 0xe5, 0x78, 0xa6,
- 0xe0, 0xc1, 0xda, 0x13, 0x72, 0x07, 0x85, 0x34,
- 0x63, 0x95, 0x49, 0x30, 0x4b, 0x9d, 0x03, 0xf1,
- 0x7a, 0x6b, 0x91, 0xa2, 0x85, 0x41, 0xf9, 0x4a,
- 0xd6, 0xff, 0xff, 0x86, 0xf7, 0xf0, 0xce, 0xb9,
- 0x07, 0xf1, 0x88, 0x04, 0x33, 0xaa, 0xeb, 0x54,
- 0xb2, 0x1c, 0x8e, 0x2e, 0x7b, 0x04, 0xa8, 0xcc,
- 0x2c, 0x7a, 0xb3, 0xad, 0x1a, 0x89, 0x38, 0x89,
- 0xd7, 0x11, 0x3a, 0x8c, 0xcf, 0xe3, 0xc5, 0xba,
- 0xb0, 0xcc, 0xc4, 0xe3, 0x33, 0xf3, 0x18, 0xba,
- 0xec, 0x56, 0xd9, 0x1c, 0x40, 0x70, 0x0d, 0x4e,
- 0x97, 0x01, 0x23, 0xf3, 0x5a, 0xdc, 0xbf, 0x68,
- 0x93, 0xc2, 0x1d, 0x8a, 0x96, 0xb7, 0xac, 0x18,
- 0x6f, 0xf7, 0x84, 0x71, 0x0d, 0x3d, 0xf8, 0xba,
- 0xdf, 0xb6, 0x89, 0x1d, 0x78, 0x19, 0xf2, 0x59,
- 0xe9, 0x15, 0x55, 0x29, 0x73, 0x50, 0x59, 0x14,
- 0x02, 0x21, 0x16, 0x8f, 0x0f, 0xdf, 0xa5, 0xf0,
-};
-
-static struct crc_test {
- uint32_t crc; /* random starting crc */
- uint32_t start; /* random offset in buf */
- uint32_t length; /* random length of test */
- uint32_t crc_le; /* expected crc32_le result */
- uint32_t crc_be; /* expected crc32_be result */
-} test[] = {
- {0xffffffff, 0x00000000, 0x00001000, 0x13934bef, 0x14f3b75f},
- {0xfe7328ea, 0x00000763, 0x00000717, 0xed2c0d70, 0x57531214},
- {0x4c40684e, 0x00000721, 0x0000011e, 0xd7f46ccc, 0xedf12ec3},
- {0x6b487f90, 0x00000264, 0x000007bc, 0x759e9939, 0x9af8e387},
- {0x9f5810db, 0x00000afa, 0x00000255, 0x2685197f, 0x716de6ed},
- {0xb15c4755, 0x00000d5b, 0x000002a4, 0xd8fadcb5, 0xfc34ae3f},
- {0x06518253, 0x00000ffb, 0x00000004, 0xabee2433, 0xfa30ac9e},
- {0xd9e71c55, 0x00000a2a, 0x00000259, 0x96682af2, 0xe5907ea3},
- {0x0c1ae843, 0x00000ce4, 0x0000031b, 0x7b637c43, 0xe7f71b04},
- {0xec3cd517, 0x000002ff, 0x00000566, 0x5d719a77, 0xed16e045},
- {0x77828e95, 0x0000067f, 0x0000038f, 0x43ee5b6c, 0x35999927},
- {0xec87b4e3, 0x00000d1c, 0x000002e3, 0x2ddd2eee, 0x9452d3f8},
- {0x412158bb, 0x00000eee, 0x00000111, 0x67b38ba2, 0x177976d0},
- {0x2e52de3e, 0x00000c4a, 0x000003b5, 0xbcc5d61d, 0xf60fee71},
- {0x6ddaae8b, 0x00000d99, 0x00000266, 0x8b535544, 0x1dab8596},
- {0x049b6cb1, 0x000009c5, 0x000000b0, 0xfc22cabc, 0x47ebc954},
- {0x77d4b954, 0x0000028a, 0x000007fa, 0x71d00923, 0x905585ef},
- {0x5e192355, 0x00000ac1, 0x000001fa, 0xb966b81a, 0x33c12903},
- {0x7d80b71d, 0x00000213, 0x000001e0, 0x2bba371a, 0x5f4bd8d9},
- {0x01f6f1e4, 0x000001d6, 0x00000395, 0xb7e8a647, 0x2a7943a1},
- {0x1dfabb13, 0x00000e14, 0x000001eb, 0x53917fba, 0x8dee1e5d},
- {0xb00a4449, 0x00000bf6, 0x00000409, 0xedecb577, 0x628e087d},
- {0x7ecd3981, 0x0000083f, 0x0000016b, 0xefef62b9, 0xda4f94e6},
- {0xf8f330d2, 0x000004be, 0x00000757, 0x9357c9f3, 0x8e2d5c2f},
- {0x03c38af2, 0x00000d23, 0x000002dc, 0x360fa8c0, 0x6294c0d6},
- {0x687bb79b, 0x00000f3d, 0x000000c2, 0x448d3be2, 0x08f48f3a},
- {0x6710f550, 0x000009e9, 0x00000603, 0xdbfd1998, 0xc950ac29},
- {0x873171d1, 0x00000787, 0x000004d5, 0xab7f1b62, 0xe66896ab},
- {0x373b1314, 0x00000f0f, 0x000000f0, 0x184098ab, 0x4038e674},
- {0x90fad9cd, 0x00000ead, 0x00000152, 0x23ce52ff, 0x9eff3974},
- {0x19676fe7, 0x0000007d, 0x0000070d, 0xf8a76f1e, 0xfbc5c8a9},
- {0x89facd45, 0x000005f3, 0x00000473, 0x4331a006, 0xb8f0f0cc},
- {0x6f173747, 0x00000fc3, 0x0000003c, 0xb012f08e, 0x5126e378},
- {0x4b44a106, 0x0000075a, 0x0000008b, 0xf6f7ac38, 0xf9b1781b},
- {0xb620ad06, 0x00000774, 0x0000017e, 0xd34558e6, 0xb175edd3},
- {0x976f21e9, 0x000008d7, 0x0000034a, 0xe533aa3a, 0x1e4367b9},
- {0x687628c0, 0x000006c5, 0x0000061b, 0x3a840b15, 0xfb5989a0},
- {0xe24ac108, 0x00000cd0, 0x0000032f, 0x51010ae8, 0xcdd8f182},
- {0x361c44a3, 0x00000304, 0x00000719, 0xfd7bd481, 0x12de540f},
- {0xd93ff95e, 0x00000db7, 0x0000008e, 0xcfbbc304, 0x42eecd5a},
- {0xed752d12, 0x00000883, 0x00000091, 0x65a6c868, 0x9ebfa578},
- {0xb4ff4b54, 0x000003d3, 0x000001c1, 0xf82597e7, 0xa8ad2b19},
- {0x111b520f, 0x00000708, 0x000000eb, 0xc3e109f3, 0x323ace17},
- {0x62c806f2, 0x00000ba3, 0x0000045c, 0x874d3a72, 0xaf1a1360},
- {0x40d97470, 0x000005e1, 0x0000058d, 0x87a9684f, 0x524244a8},
- {0x4312179c, 0x00000056, 0x0000070e, 0x809a00f5, 0xf9e940b0},
- {0x13d5f84c, 0x00000a2d, 0x00000104, 0xf3d27578, 0x5d33341c},
- {0x1f302cb2, 0x00000151, 0x00000014, 0x1e162693, 0x53c3cfc3},
- {0xe491db24, 0x00000600, 0x000006f6, 0x7ff09615, 0xa300ecf7},
- {0xf9a98069, 0x000002ba, 0x000002ad, 0x01af7387, 0x31c0911e},
- {0xe9c477ad, 0x0000015f, 0x00000778, 0x6facf9a0, 0x1993b688},
- {0x353f32b2, 0x0000087c, 0x00000783, 0x6cc964ea, 0x418db561},
- {0x78e1b24f, 0x00000650, 0x000006a8, 0xb3bb7c27, 0xf2aad006},
- {0x61aa400e, 0x00000049, 0x00000254, 0xb8cd1681, 0x79150b15},
- {0xb84b10b0, 0x00000f73, 0x0000008c, 0x406a6450, 0x0c705222},
- {0x9fa99c9c, 0x00000a7c, 0x000004d7, 0xfb3d21b4, 0xe4e789df},
- {0x3fc9ebe3, 0x00000cd9, 0x000000d6, 0x43803f9c, 0x5a152be5},
- {0x529879cd, 0x000002f2, 0x00000595, 0x78b4c6a6, 0xf7236ec4},
- {0x3a933019, 0x00000516, 0x00000266, 0xdcb45436, 0x2c7935f5},
- {0x887b4977, 0x00000227, 0x0000038d, 0xc5f7c3d9, 0x0d6d7df6},
- {0x770745de, 0x000008c6, 0x00000739, 0xf69145e8, 0x47d5efc9},
- {0x28be3b47, 0x00000c46, 0x0000032b, 0x764c028f, 0x1eb70d64},
- {0x5013a050, 0x00000cf6, 0x00000309, 0xea8fe164, 0x186affa4},
- {0x2ec4c9ba, 0x000006e8, 0x0000078d, 0xa35557a9, 0xb41f49ec},
- {0xa9f950c9, 0x00000d33, 0x000002cc, 0x41ea8618, 0xab8dfae3},
- {0x5b520229, 0x000007b2, 0x00000484, 0x44569f1f, 0x607a8052},
- {0xd8dcbbfc, 0x0000002f, 0x0000048c, 0xdb88ab8b, 0xf1c411f1},
- {0x25529792, 0x00000d1d, 0x000002e2, 0x20cda404, 0x32683a2d},
- {0x9f3f6d71, 0x00000238, 0x0000079a, 0x0720443e, 0x4b8ba2ff},
- {0x64121215, 0x000007ff, 0x0000038f, 0x6aacff2c, 0x3b84233b},
- {0xfb6cdde0, 0x00000ef8, 0x00000107, 0xbd43a0f1, 0x926624d0},
- {0x221c9d6f, 0x000007b6, 0x0000014f, 0xb67f834b, 0x2bdedda4},
- {0x030e1de4, 0x00000836, 0x000004b4, 0x0d67d26a, 0x75a73b73},
- {0xb56fa6cf, 0x00000c07, 0x000003f8, 0x60601ac1, 0x10a43f35},
- {0xb55c89f5, 0x0000098e, 0x000001d4, 0x2400efbe, 0x006e28eb},
- {0x5e90b6d5, 0x0000070b, 0x000003ea, 0x3bb5d6ea, 0xb175fa6b},
- {0x2a7045ae, 0x00000961, 0x00000633, 0xfca89e4b, 0x962cd6d2},
- {0x8b374ea9, 0x000006ba, 0x00000780, 0xbce036ed, 0x4dc8279b},
- {0x8bd90bc9, 0x00000562, 0x00000369, 0xcb26a24b, 0x50dee743},
- {0x5b1b1762, 0x000000fd, 0x0000051a, 0x33cdda07, 0xee75ff7b},
- {0xa4153555, 0x0000058f, 0x000005c7, 0xbe50eeca, 0xe73fffcc},
- {0x0be1f931, 0x00000651, 0x00000672, 0x95a25753, 0x4ad6270f},
- {0xb7e78618, 0x00000a7f, 0x000002bb, 0xe06bcc1c, 0x1a35ee59},
- {0x4a9bc41b, 0x00000e51, 0x000001ae, 0x709e8d2c, 0x75080ca8},
- {0xfc359d13, 0x00000440, 0x000002f8, 0x0a58451f, 0x6fa3cfbf},
- {0x5aa48619, 0x000006d1, 0x00000284, 0x928ead83, 0xbd600efc},
- {0xa609afa8, 0x0000053e, 0x00000272, 0xb048c141, 0x184f80bb},
- {0x3f108afb, 0x00000949, 0x00000150, 0x9a6bb5bc, 0x0ea02be1},
- {0x79bec2d3, 0x000008ed, 0x00000712, 0x32692d57, 0x2eb13289},
- {0x9429e067, 0x00000bc3, 0x0000043c, 0x5295ceff, 0x8a9014a7},
- {0xae58b96a, 0x0000082d, 0x000007d2, 0xc2a681ba, 0x6af94089},
- {0x95df24be, 0x00000985, 0x000004c1, 0x3a287765, 0x379fcb42},
- {0x5e94976f, 0x00000596, 0x000004ed, 0xff00c489, 0x991fc1f5},
- {0xf5e5f1de, 0x00000d31, 0x000002ce, 0x35f28e91, 0x543def1a},
- {0xa2c219cf, 0x00000a3c, 0x00000374, 0x707d21eb, 0xa6d28bc1},
- {0xf21b6ceb, 0x00000919, 0x00000135, 0x0847fb8b, 0x224468c2},
- {0xaa988728, 0x00000787, 0x00000771, 0x885aeaa4, 0x814db00b},
- {0xaa5dfaac, 0x000003e5, 0x0000051b, 0x52c48ab7, 0x725bef8a},
- {0x0a053968, 0x00000d2a, 0x000002d5, 0x7a90256d, 0xc53b9402},
- {0x1421dc20, 0x00000eef, 0x00000110, 0x97d6da24, 0x10846935},
- {0xb47c2166, 0x00000a6a, 0x00000209, 0xcfd6cc52, 0x46e2797e},
- {0x77dd1955, 0x000000de, 0x00000266, 0xba74bcaa, 0x4fa3fe9c},
- {0x68a03cc2, 0x0000082f, 0x000007b0, 0x752bd5d8, 0x4f760c63},
- {0x0226b0a3, 0x00000a5f, 0x000005a0, 0x82de4970, 0x8ee1310e},
- {0x637bf3b1, 0x00000d93, 0x0000026c, 0x5c7115cb, 0x9f6a0ced},
- {0x3b120edf, 0x00000c13, 0x000003ec, 0x80d7d20f, 0x241657d5},
- {0xe2456780, 0x000002eb, 0x00000641, 0xc0a5d289, 0x74df96b4},
- {0x9b2e7125, 0x00000c0c, 0x000003f3, 0xcc15f57e, 0x03e290bf},
- {0x153033ef, 0x00000787, 0x000006b6, 0x3cde443b, 0x7bf1d121},
- {0x18458b3f, 0x0000066c, 0x00000561, 0x9a2bd8c6, 0x9d564bef},
- {0x4ff9d4b9, 0x00000c8f, 0x0000033a, 0xd0ee6d6d, 0xee00aa0b},
- {0xdf84b5d9, 0x00000802, 0x0000029a, 0xdab0d74a, 0xd0cb63dc},
- {0x81ee15df, 0x000003ce, 0x00000725, 0x9942e2de, 0xe48fb26b},
- {0x5c768e04, 0x00000afd, 0x00000160, 0x36110831, 0x8dc74483},
- {0xe5e18094, 0x00000b4b, 0x000000a0, 0xffa3e4a7, 0xc0145e1b},
- {0xed7263b6, 0x00000d0d, 0x000002f2, 0xb0006a35, 0x5468ae3a},
- {0x5bfde7d7, 0x000006fb, 0x00000554, 0xa4193b76, 0xb73d34b2},
- {0x67f4a743, 0x00000b85, 0x0000047a, 0xf05c8d8f, 0x4f843e49},
- {0xf13bdf22, 0x00000ff7, 0x00000008, 0x816351eb, 0x41f537f6},
- {0x08ecc608, 0x00000d5d, 0x00000098, 0x90492772, 0xf5172204},
- {0x296f52ba, 0x000004f9, 0x00000788, 0x5e5a4896, 0xe01d5b46},
- {0xbe4624c2, 0x00000427, 0x000004ef, 0xcd267b94, 0x7b9069f4},
- {0x906f7c7c, 0x00000a05, 0x0000003f, 0x03fcfc33, 0x7b6ff563},
- {0x8f7b323e, 0x00000458, 0x000004c7, 0xcd4969c8, 0xd4c22ada},
- {0x88d6593d, 0x00000597, 0x000005b5, 0xf199cd3b, 0x5c3e8ca2},
- {0x978a7768, 0x00000268, 0x000001d3, 0xb28c95bd, 0x49a2cc67},
- {0x857a621e, 0x000007a7, 0x000003a8, 0xf4bf84ab, 0xde26f369},
- {0xb0e121ef, 0x000005be, 0x00000644, 0x28747c14, 0x61d4dc6b},
- {0, 0, 0, 0, 0},
-};
-
-static int test_crc32c(void)
-{
- struct crc_test *t = test;
- int failures = 0;
-
- while (t->length) {
- uint32_t be, le;
- le = ext2fs_crc32c_le(t->crc, test_buf + t->start, t->length);
- be = ext2fs_crc32c_be(t->crc, test_buf + t->start, t->length);
- if (le != t->crc_le) {
- printf("Test %d LE fails, %x != %x\n",
- (int) (t - test), le, t->crc_le);
- failures++;
- }
- if (be != t->crc_be) {
- printf("Test %d BE fails, %x != %x\n",
- (int) (t - test), be, t->crc_be);
- failures++;
- }
- t++;
- }
-
- return failures;
-}
-
-int main(int argc, char *argv[])
-{
- int ret;
-
- ret = test_crc32c();
- if (!ret)
- printf("No failures.\n");
-
- return ret;
-}
-#endif /* UNITTEST */
diff --git a/lib/ext2fs/crc32c_defs.h b/lib/ext2fs/crc32c_defs.h
deleted file mode 100644
index 023f2c01..00000000
--- a/lib/ext2fs/crc32c_defs.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * This is the CRC32c polynomial, as outlined by Castagnoli.
- * x^32+x^28+x^27+x^26+x^25+x^23+x^22+x^20+x^19+x^18+x^14+x^13+x^11+x^10+x^9+
- * x^8+x^6+x^0
- */
-#define CRCPOLY_LE 0x82F63B78
-#define CRCPOLY_BE 0x1EDC6F41
-
-/* How many bits at a time to use. Valid values are 1, 2, 4, 8, 32 and 64. */
-/* For less performance-sensitive, use 4 */
-#ifndef CRC_LE_BITS
-# define CRC_LE_BITS 64
-#endif
-#ifndef CRC_BE_BITS
-# define CRC_BE_BITS 64
-#endif
-
-/*
- * Little-endian CRC computation. Used with serial bit streams sent
- * lsbit-first. Be sure to use cpu_to_le32() to append the computed CRC.
- */
-#if CRC_LE_BITS > 64 || CRC_LE_BITS < 1 || CRC_LE_BITS == 16 || \
- CRC_LE_BITS & CRC_LE_BITS-1
-# error "CRC_LE_BITS must be one of {1, 2, 4, 8, 32, 64}"
-#endif
-
-/*
- * Big-endian CRC computation. Used with serial bit streams sent
- * msbit-first. Be sure to use cpu_to_be32() to append the computed CRC.
- */
-#if CRC_BE_BITS > 64 || CRC_BE_BITS < 1 || CRC_BE_BITS == 16 || \
- CRC_BE_BITS & CRC_BE_BITS-1
-# error "CRC_BE_BITS must be one of {1, 2, 4, 8, 32, 64}"
-#endif
-
-
-#define ___constant_swab32(x) \
- ((uint32_t)( \
- (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \
- (((uint32_t)(x) & (uint32_t)0x0000ff00UL) << 8) | \
- (((uint32_t)(x) & (uint32_t)0x00ff0000UL) >> 8) | \
- (((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24)))
-
-
-#if (__GNUC__ >= 3)
-#define likely(x) __builtin_expect(!!(x), 1)
-#define unlikely(x) __builtin_expect(!!(x), 0)
-#else
-#define likely(x) (x)
-#define unlikely(x) (x)
-#endif
diff --git a/lib/ext2fs/csum.c b/lib/ext2fs/csum.c
index b588ead3..10f3423d 100644
--- a/lib/ext2fs/csum.c
+++ b/lib/ext2fs/csum.c
@@ -29,30 +29,22 @@
#define STATIC static
#endif
-__u16 ext2fs_group_desc_csum(ext2_filsys fs, dgrp_t group)
+STATIC __u16 ext2fs_group_desc_csum(ext2_filsys fs, dgrp_t group)
{
- struct ext2_group_desc *desc = ext2fs_group_desc(fs, fs->group_desc,
- group);
- size_t size = EXT2_DESC_SIZE(fs->super);
- size_t offset;
- __u16 crc;
+ __u16 crc = 0;
+ struct ext2_group_desc *desc;
+
+ desc = &fs->group_desc[group];
if (fs->super->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_GDT_CSUM) {
- size_t offset = offsetof(struct ext2_group_desc, bg_checksum);
+ int offset = offsetof(struct ext2_group_desc, bg_checksum);
#ifdef WORDS_BIGENDIAN
- struct ext4_group_desc swabdesc;
- size_t save_size = size;
- const size_t ext4_bg_size = sizeof(struct ext4_group_desc);
- struct ext2_group_desc *save_desc = desc;
+ struct ext2_group_desc swabdesc = *desc;
/* Have to swab back to little-endian to do the checksum */
- if (size > ext4_bg_size)
- size = ext4_bg_size;
- memcpy(&swabdesc, desc, size);
- ext2fs_swap_group_desc2(fs,
- (struct ext2_group_desc *) &swabdesc);
- desc = (struct ext2_group_desc *) &swabdesc;
+ ext2fs_swap_group_desc(&swabdesc);
+ desc = &swabdesc;
group = ext2fs_swab32(group);
#endif
@@ -61,22 +53,12 @@ __u16 ext2fs_group_desc_csum(ext2_filsys fs, dgrp_t group)
crc = ext2fs_crc16(crc, &group, sizeof(group));
crc = ext2fs_crc16(crc, desc, offset);
offset += sizeof(desc->bg_checksum); /* skip checksum */
+ assert(offset == sizeof(*desc));
/* for checksum of struct ext4_group_desc do the rest...*/
- if (offset < size) {
+ if (offset < fs->super->s_desc_size) {
crc = ext2fs_crc16(crc, (char *)desc + offset,
- size - offset);
+ fs->super->s_desc_size - offset);
}
-#ifdef WORDS_BIGENDIAN
- /*
- * If the size of the bg descriptor is greater than 64
- * bytes, which is the size of the traditional ext4 bg
- * descriptor, checksum the rest of the descriptor here
- */
- if (save_size > ext4_bg_size)
- crc = ext2fs_crc16(crc,
- (char *)save_desc + ext4_bg_size,
- save_size - ext4_bg_size);
-#endif
}
return crc;
@@ -86,7 +68,7 @@ int ext2fs_group_desc_csum_verify(ext2_filsys fs, dgrp_t group)
{
if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
EXT4_FEATURE_RO_COMPAT_GDT_CSUM) &&
- (ext2fs_bg_checksum(fs, group) !=
+ (fs->group_desc[group].bg_checksum !=
ext2fs_group_desc_csum(fs, group)))
return 0;
@@ -95,13 +77,10 @@ int ext2fs_group_desc_csum_verify(ext2_filsys fs, dgrp_t group)
void ext2fs_group_desc_csum_set(ext2_filsys fs, dgrp_t group)
{
- if (!EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
- EXT4_FEATURE_RO_COMPAT_GDT_CSUM))
- return;
-
- /* ext2fs_bg_checksum_set() sets the actual checksum field but
- * does not calculate the checksum itself. */
- ext2fs_bg_checksum_set(fs, group, ext2fs_group_desc_csum(fs, group));
+ if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
+ EXT4_FEATURE_RO_COMPAT_GDT_CSUM))
+ fs->group_desc[group].bg_checksum =
+ ext2fs_group_desc_csum(fs, group);
}
static __u32 find_last_inode_ingrp(ext2fs_inode_bitmap bitmap,
@@ -113,7 +92,7 @@ static __u32 find_last_inode_ingrp(ext2fs_inode_bitmap bitmap,
end_ino = start_ino + inodes_per_grp - 1;
for (i = end_ino; i >= start_ino; i--) {
- if (ext2fs_fast_test_inode_bitmap2(bitmap, i))
+ if (ext2fs_fast_test_inode_bitmap(bitmap, i))
return i - start_ino + 1;
}
return inodes_per_grp;
@@ -124,6 +103,7 @@ static __u32 find_last_inode_ingrp(ext2fs_inode_bitmap bitmap,
errcode_t ext2fs_set_gdt_csum(ext2_filsys fs)
{
struct ext2_super_block *sb = fs->super;
+ struct ext2_group_desc *bg = fs->group_desc;
int dirty = 0;
dgrp_t i;
@@ -134,31 +114,27 @@ errcode_t ext2fs_set_gdt_csum(ext2_filsys fs)
EXT4_FEATURE_RO_COMPAT_GDT_CSUM))
return 0;
- for (i = 0; i < fs->group_desc_count; i++) {
- __u32 old_csum = ext2fs_bg_checksum(fs, i);
- __u32 old_unused = ext2fs_bg_itable_unused(fs, i);
- __u32 old_flags = ext2fs_bg_flags(fs, i);
- __u32 old_free_inodes_count = ext2fs_bg_free_inodes_count(fs, i);
+ for (i = 0; i < fs->group_desc_count; i++, bg++) {
+ int old_csum = bg->bg_checksum;
+ int old_unused = bg->bg_itable_unused;
+ int old_flags = bg->bg_flags;
- if (old_free_inodes_count == sb->s_inodes_per_group) {
- ext2fs_bg_flags_set(fs, i, EXT2_BG_INODE_UNINIT);
- ext2fs_bg_itable_unused_set(fs, i, sb->s_inodes_per_group);
+ if (bg->bg_free_inodes_count == sb->s_inodes_per_group) {
+ bg->bg_flags |= EXT2_BG_INODE_UNINIT;
+ bg->bg_itable_unused = sb->s_inodes_per_group;
} else {
- int unused =
- sb->s_inodes_per_group -
+ bg->bg_flags &= ~EXT2_BG_INODE_UNINIT;
+ bg->bg_itable_unused = sb->s_inodes_per_group -
find_last_inode_ingrp(fs->inode_map,
- sb->s_inodes_per_group, i);
-
- ext2fs_bg_flags_clear(fs, i, EXT2_BG_INODE_UNINIT);
- ext2fs_bg_itable_unused_set(fs, i, unused);
+ sb->s_inodes_per_group,i);
}
ext2fs_group_desc_csum_set(fs, i);
- if (old_flags != ext2fs_bg_flags(fs, i))
+ if (old_flags != bg->bg_flags)
dirty = 1;
- if (old_unused != ext2fs_bg_itable_unused(fs, i))
+ if (old_unused != bg->bg_itable_unused)
dirty = 1;
- if (old_csum != ext2fs_bg_checksum(fs, i))
+ if (old_csum != bg->bg_checksum)
dirty = 1;
}
if (dirty)
@@ -173,25 +149,15 @@ void print_csum(const char *msg, ext2_filsys fs, dgrp_t group)
{
__u16 crc1, crc2, crc3;
dgrp_t swabgroup;
- struct ext2_group_desc *desc = ext2fs_group_desc(fs, fs->group_desc,
- group);
- size_t size = EXT2_DESC_SIZE(fs->super);
+ struct ext2_group_desc *desc = &fs->group_desc[group];
struct ext2_super_block *sb = fs->super;
- int offset = offsetof(struct ext2_group_desc, bg_checksum);
-#ifdef WORDS_BIGENDIAN
- struct ext4_group_desc swabdesc;
- struct ext2_group_desc *save_desc = desc;
- const size_t ext4_bg_size = sizeof(struct ext4_group_desc);
- size_t save_size = size;
-#endif
#ifdef WORDS_BIGENDIAN
+ struct ext2_group_desc swabdesc = fs->group_desc[group];
+
/* Have to swab back to little-endian to do the checksum */
- if (size > ext4_bg_size)
- size = ext4_bg_size;
- memcpy(&swabdesc, desc, size);
- ext2fs_swap_group_desc2(fs, (struct ext2_group_desc *) &swabdesc);
- desc = (struct ext2_group_desc *) &swabdesc;
+ ext2fs_swap_group_desc(&swabdesc);
+ desc = &swabdesc;
swabgroup = ext2fs_swab32(group);
#else
@@ -200,19 +166,10 @@ void print_csum(const char *msg, ext2_filsys fs, dgrp_t group)
crc1 = ext2fs_crc16(~0, sb->s_uuid, sizeof(fs->super->s_uuid));
crc2 = ext2fs_crc16(crc1, &swabgroup, sizeof(swabgroup));
- crc3 = ext2fs_crc16(crc2, desc, offset);
- offset += sizeof(desc->bg_checksum); /* skip checksum */
- /* for checksum of struct ext4_group_desc do the rest...*/
- if (offset < size)
- crc3 = ext2fs_crc16(crc3, (char *)desc + offset, size - offset);
-#ifdef WORDS_BIGENDIAN
- if (save_size > ext4_bg_size)
- crc3 = ext2fs_crc16(crc3, (char *)save_desc + ext4_bg_size,
- save_size - ext4_bg_size);
-#endif
-
- printf("%s UUID %s=%04x, grp %u=%04x: %04x=%04x\n",
- msg, e2p_uuid2str(sb->s_uuid), crc1, group, crc2, crc3,
+ crc3 = ext2fs_crc16(crc2, desc,
+ offsetof(struct ext2_group_desc, bg_checksum));
+ printf("%s: UUID %s(%04x), grp %u(%04x): %04x=%04x\n",
+ msg, e2p_uuid2str(sb->s_uuid), crc1, group, crc2,crc3,
ext2fs_group_desc_csum(fs, group));
}
@@ -228,14 +185,9 @@ int main(int argc, char **argv)
__u16 csum1, csum2, csum_known = 0xd3a4;
memset(&param, 0, sizeof(param));
- ext2fs_blocks_count_set(&param, 32768);
-#if 0
- param.s_feature_incompat |= EXT4_FEATURE_INCOMPAT_64BIT;
- param.s_desc_size = 128;
- csum_known = 0x5b6e;
-#endif
+ param.s_blocks_count = 32768;
- retval = ext2fs_initialize("test fs", EXT2_FLAG_64BITS, &param,
+ retval = ext2fs_initialize("test fs", 0, &param,
test_io_manager, &fs);
if (retval) {
com_err("setup", retval,
@@ -246,13 +198,13 @@ int main(int argc, char **argv)
fs->super->s_feature_ro_compat = EXT4_FEATURE_RO_COMPAT_GDT_CSUM;
for (i=0; i < fs->group_desc_count; i++) {
- ext2fs_block_bitmap_loc_set(fs, i, 124);
- ext2fs_inode_bitmap_loc_set(fs, i, 125);
- ext2fs_inode_table_loc_set(fs, i, 126);
- ext2fs_bg_free_blocks_count_set(fs, i, 31119);
- ext2fs_bg_free_inodes_count_set(fs, i, 15701);
- ext2fs_bg_used_dirs_count_set(fs, i, 2);
- ext2fs_bg_flags_zap(fs, i);
+ fs->group_desc[i].bg_block_bitmap = 124;
+ fs->group_desc[i].bg_inode_bitmap = 125;
+ fs->group_desc[i].bg_inode_table = 126;
+ fs->group_desc[i].bg_free_blocks_count = 31119;
+ fs->group_desc[i].bg_free_inodes_count = 15701;
+ fs->group_desc[i].bg_used_dirs_count = 2;
+ fs->group_desc[i].bg_flags = 0;
};
csum1 = ext2fs_group_desc_csum(fs, 0);
@@ -274,7 +226,7 @@ int main(int argc, char **argv)
printf("checksums for different groups shouldn't match\n");
exit(1);
}
- ext2fs_bg_checksum_set(fs, 0, csum1);
+ fs->group_desc[0].bg_checksum = csum1;
csum2 = ext2fs_group_desc_csum(fs, 0);
print_csum("csum_set", fs, 0);
if (csum1 != csum2) {
@@ -291,10 +243,9 @@ int main(int argc, char **argv)
printf("checksums for different filesystems shouldn't match\n");
exit(1);
}
- csum1 = ext2fs_group_desc_csum(fs, 0);
- ext2fs_bg_checksum_set(fs, 0, csum1);
+ csum1 = fs->group_desc[0].bg_checksum = ext2fs_group_desc_csum(fs, 0);
print_csum("csum_new", fs, 0);
- ext2fs_bg_free_blocks_count_set(fs, 0, 1);
+ fs->group_desc[0].bg_free_blocks_count = 1;
csum2 = ext2fs_group_desc_csum(fs, 0);
print_csum("csum_blk", fs, 0);
if (csum1 == csum2) {
diff --git a/lib/ext2fs/dblist.c b/lib/ext2fs/dblist.c
index e5b685a1..84adcb2b 100644
--- a/lib/ext2fs/dblist.c
+++ b/lib/ext2fs/dblist.c
@@ -20,8 +20,6 @@
#include "ext2fsP.h"
static EXT2_QSORT_TYPE dir_block_cmp(const void *a, const void *b);
-static EXT2_QSORT_TYPE dir_block_cmp2(const void *a, const void *b);
-static EXT2_QSORT_TYPE (*sortfunc32)(const void *a, const void *b);
/*
* Returns the number of directories in the filesystem as reported by
@@ -38,10 +36,10 @@ errcode_t ext2fs_get_num_dirs(ext2_filsys fs, ext2_ino_t *ret_num_dirs)
num_dirs = 0;
max_dirs = fs->super->s_inodes_per_group;
for (i = 0; i < fs->group_desc_count; i++) {
- if (ext2fs_bg_used_dirs_count(fs, i) > max_dirs)
+ if (fs->group_desc[i].bg_used_dirs_count > max_dirs)
num_dirs += max_dirs / 8;
else
- num_dirs += ext2fs_bg_used_dirs_count(fs, i);
+ num_dirs += fs->group_desc[i].bg_used_dirs_count;
}
if (num_dirs > fs->super->s_inodes_count)
num_dirs = fs->super->s_inodes_count;
@@ -55,14 +53,12 @@ errcode_t ext2fs_get_num_dirs(ext2_filsys fs, ext2_ino_t *ret_num_dirs)
* helper function for making a new directory block list (for
* initialize and copy).
*/
-static errcode_t make_dblist(ext2_filsys fs, ext2_ino_t size,
- ext2_ino_t count,
- struct ext2_db_entry2 *list,
+static errcode_t make_dblist(ext2_filsys fs, ext2_ino_t size, ext2_ino_t count,
+ struct ext2_db_entry *list,
ext2_dblist *ret_dblist)
{
- ext2_dblist dblist = NULL;
+ ext2_dblist dblist;
errcode_t retval;
- ext2_ino_t num_dirs;
size_t len;
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
@@ -73,7 +69,7 @@ static errcode_t make_dblist(ext2_filsys fs, ext2_ino_t size,
retval = ext2fs_get_mem(sizeof(struct ext2_struct_dblist), &dblist);
if (retval)
- goto cleanup;
+ return retval;
memset(dblist, 0, sizeof(struct ext2_struct_dblist));
dblist->magic = EXT2_ET_MAGIC_DBLIST;
@@ -81,14 +77,14 @@ static errcode_t make_dblist(ext2_filsys fs, ext2_ino_t size,
if (size)
dblist->size = size;
else {
- retval = ext2fs_get_num_dirs(fs, &num_dirs);
+ retval = ext2fs_get_num_dirs(fs, &dblist->size);
if (retval)
goto cleanup;
- dblist->size = (num_dirs * 2) + 12;
+ dblist->size = (dblist->size * 2) + 12;
}
- len = (size_t) sizeof(struct ext2_db_entry2) * dblist->size;
+ len = (size_t) sizeof(struct ext2_db_entry) * dblist->size;
dblist->count = count;
- retval = ext2fs_get_array(dblist->size, sizeof(struct ext2_db_entry2),
+ retval = ext2fs_get_array(dblist->size, sizeof(struct ext2_db_entry),
&dblist->list);
if (retval)
goto cleanup;
@@ -156,27 +152,27 @@ errcode_t ext2fs_copy_dblist(ext2_dblist src, ext2_dblist *dest)
/*
* Add a directory block to the directory block list
*/
-errcode_t ext2fs_add_dir_block2(ext2_dblist dblist, ext2_ino_t ino,
- blk64_t blk, e2_blkcnt_t blockcnt)
+errcode_t ext2fs_add_dir_block(ext2_dblist dblist, ext2_ino_t ino, blk_t blk,
+ int blockcnt)
{
- struct ext2_db_entry2 *new_entry;
+ struct ext2_db_entry *new_entry;
errcode_t retval;
unsigned long old_size;
EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST);
if (dblist->count >= dblist->size) {
- old_size = dblist->size * sizeof(struct ext2_db_entry2);
+ old_size = dblist->size * sizeof(struct ext2_db_entry);
dblist->size += dblist->size > 200 ? dblist->size / 2 : 100;
retval = ext2fs_resize_mem(old_size, (size_t) dblist->size *
- sizeof(struct ext2_db_entry2),
+ sizeof(struct ext2_db_entry),
&dblist->list);
if (retval) {
- dblist->size = old_size / sizeof(struct ext2_db_entry2);
+ dblist->size -= 100;
return retval;
}
}
- new_entry = dblist->list + ( dblist->count++);
+ new_entry = dblist->list + ( (int) dblist->count++);
new_entry->blk = blk;
new_entry->ino = ino;
new_entry->blockcnt = blockcnt;
@@ -189,8 +185,8 @@ errcode_t ext2fs_add_dir_block2(ext2_dblist dblist, ext2_ino_t ino,
/*
* Change the directory block to the directory block list
*/
-errcode_t ext2fs_set_dir_block2(ext2_dblist dblist, ext2_ino_t ino,
- blk64_t blk, e2_blkcnt_t blockcnt)
+errcode_t ext2fs_set_dir_block(ext2_dblist dblist, ext2_ino_t ino, blk_t blk,
+ int blockcnt)
{
dgrp_t i;
@@ -207,47 +203,47 @@ errcode_t ext2fs_set_dir_block2(ext2_dblist dblist, ext2_ino_t ino,
return EXT2_ET_DB_NOT_FOUND;
}
-void ext2fs_dblist_sort2(ext2_dblist dblist,
- EXT2_QSORT_TYPE (*sortfunc)(const void *,
- const void *))
+void ext2fs_dblist_sort(ext2_dblist dblist,
+ EXT2_QSORT_TYPE (*sortfunc)(const void *,
+ const void *))
{
if (!sortfunc)
- sortfunc = dir_block_cmp2;
+ sortfunc = dir_block_cmp;
qsort(dblist->list, (size_t) dblist->count,
- sizeof(struct ext2_db_entry2), sortfunc);
+ sizeof(struct ext2_db_entry), sortfunc);
dblist->sorted = 1;
}
/*
* This function iterates over the directory block list
*/
-errcode_t ext2fs_dblist_iterate2(ext2_dblist dblist,
- int (*func)(ext2_filsys fs,
- struct ext2_db_entry2 *db_info,
- void *priv_data),
- void *priv_data)
+errcode_t ext2fs_dblist_iterate(ext2_dblist dblist,
+ int (*func)(ext2_filsys fs,
+ struct ext2_db_entry *db_info,
+ void *priv_data),
+ void *priv_data)
{
- unsigned long long i;
+ ext2_ino_t i;
int ret;
EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST);
if (!dblist->sorted)
- ext2fs_dblist_sort2(dblist, 0);
+ ext2fs_dblist_sort(dblist, 0);
for (i=0; i < dblist->count; i++) {
- ret = (*func)(dblist->fs, &dblist->list[i], priv_data);
+ ret = (*func)(dblist->fs, &dblist->list[(int)i], priv_data);
if (ret & DBLIST_ABORT)
return 0;
}
return 0;
}
-static EXT2_QSORT_TYPE dir_block_cmp2(const void *a, const void *b)
+static EXT2_QSORT_TYPE dir_block_cmp(const void *a, const void *b)
{
- const struct ext2_db_entry2 *db_a =
- (const struct ext2_db_entry2 *) a;
- const struct ext2_db_entry2 *db_b =
- (const struct ext2_db_entry2 *) b;
+ const struct ext2_db_entry *db_a =
+ (const struct ext2_db_entry *) a;
+ const struct ext2_db_entry *db_b =
+ (const struct ext2_db_entry *) b;
if (db_a->blk != db_b->blk)
return (int) (db_a->blk - db_b->blk);
@@ -255,16 +251,16 @@ static EXT2_QSORT_TYPE dir_block_cmp2(const void *a, const void *b)
if (db_a->ino != db_b->ino)
return (int) (db_a->ino - db_b->ino);
- return (db_a->blockcnt - db_b->blockcnt);
+ return (int) (db_a->blockcnt - db_b->blockcnt);
}
-blk64_t ext2fs_dblist_count2(ext2_dblist dblist)
+int ext2fs_dblist_count(ext2_dblist dblist)
{
- return dblist->count;
+ return (int) dblist->count;
}
-errcode_t ext2fs_dblist_get_last2(ext2_dblist dblist,
- struct ext2_db_entry2 **entry)
+errcode_t ext2fs_dblist_get_last(ext2_dblist dblist,
+ struct ext2_db_entry **entry)
{
EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST);
@@ -272,7 +268,7 @@ errcode_t ext2fs_dblist_get_last2(ext2_dblist dblist,
return EXT2_ET_DBLIST_EMPTY;
if (entry)
- *entry = dblist->list + ( dblist->count-1);
+ *entry = dblist->list + ( (int) dblist->count-1);
return 0;
}
@@ -286,130 +282,3 @@ errcode_t ext2fs_dblist_drop_last(ext2_dblist dblist)
dblist->count--;
return 0;
}
-
-/*
- * Legacy 32-bit versions
- */
-
-/*
- * Add a directory block to the directory block list
- */
-errcode_t ext2fs_add_dir_block(ext2_dblist dblist, ext2_ino_t ino, blk_t blk,
- int blockcnt)
-{
- return ext2fs_add_dir_block2(dblist, ino, blk, blockcnt);
-}
-
-/*
- * Change the directory block to the directory block list
- */
-errcode_t ext2fs_set_dir_block(ext2_dblist dblist, ext2_ino_t ino, blk_t blk,
- int blockcnt)
-{
- return ext2fs_set_dir_block2(dblist, ino, blk, blockcnt);
-}
-
-void ext2fs_dblist_sort(ext2_dblist dblist,
- EXT2_QSORT_TYPE (*sortfunc)(const void *,
- const void *))
-{
- if (sortfunc) {
- sortfunc32 = sortfunc;
- sortfunc = dir_block_cmp;
- } else
- sortfunc = dir_block_cmp2;
- qsort(dblist->list, (size_t) dblist->count,
- sizeof(struct ext2_db_entry2), sortfunc);
- dblist->sorted = 1;
-}
-
-/*
- * This function iterates over the directory block list
- */
-struct iterate_passthrough {
- int (*func)(ext2_filsys fs,
- struct ext2_db_entry *db_info,
- void *priv_data);
- void *priv_data;
-};
-
-static int passthrough_func(ext2_filsys fs,
- struct ext2_db_entry2 *db_info,
- void *priv_data)
-{
- struct iterate_passthrough *p = priv_data;
- struct ext2_db_entry db;
- int ret;
-
- db.ino = db_info->ino;
- db.blk = (blk_t) db_info->blk;
- db.blockcnt = (int) db_info->blockcnt;
- ret = (p->func)(fs, &db, p->priv_data);
- db_info->ino = db.ino;
- db_info->blk = db.blk;
- db_info->blockcnt = db.blockcnt;
- return ret;
-}
-
-errcode_t ext2fs_dblist_iterate(ext2_dblist dblist,
- int (*func)(ext2_filsys fs,
- struct ext2_db_entry *db_info,
- void *priv_data),
- void *priv_data)
-{
- struct iterate_passthrough pass;
-
- EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST);
- pass.func = func;
- pass.priv_data = priv_data;
-
- return ext2fs_dblist_iterate2(dblist, passthrough_func, &pass);
-}
-
-static EXT2_QSORT_TYPE dir_block_cmp(const void *a, const void *b)
-{
- const struct ext2_db_entry2 *db_a =
- (const struct ext2_db_entry2 *) a;
- const struct ext2_db_entry2 *db_b =
- (const struct ext2_db_entry2 *) b;
-
- struct ext2_db_entry a32, b32;
-
- a32.ino = db_a->ino; a32.blk = db_a->blk;
- a32.blockcnt = db_a->blockcnt;
-
- b32.ino = db_b->ino; b32.blk = db_b->blk;
- b32.blockcnt = db_b->blockcnt;
-
- return sortfunc32(&a32, &b32);
-}
-
-int ext2fs_dblist_count(ext2_dblist dblist)
-{
- return dblist->count;
-}
-
-errcode_t ext2fs_dblist_get_last(ext2_dblist dblist,
- struct ext2_db_entry **entry)
-{
- static struct ext2_db_entry ret_entry;
- struct ext2_db_entry2 *last;
-
- EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST);
-
- if (dblist->count == 0)
- return EXT2_ET_DBLIST_EMPTY;
-
- if (!entry)
- return 0;
-
- last = dblist->list + dblist->count -1;
-
- ret_entry.ino = last->ino;
- ret_entry.blk = last->blk;
- ret_entry.blockcnt = last->blockcnt;
- *entry = &ret_entry;
-
- return 0;
-}
-
diff --git a/lib/ext2fs/dblist_dir.c b/lib/ext2fs/dblist_dir.c
index 07ed8afa..8c38d315 100644
--- a/lib/ext2fs/dblist_dir.c
+++ b/lib/ext2fs/dblist_dir.c
@@ -19,7 +19,7 @@
#include "ext2_fs.h"
#include "ext2fsP.h"
-static int db_dir_proc(ext2_filsys fs, struct ext2_db_entry2 *db_info,
+static int db_dir_proc(ext2_filsys fs, struct ext2_db_entry *db_info,
void *priv_data);
errcode_t ext2fs_dblist_dir_iterate(ext2_dblist dblist,
@@ -52,7 +52,7 @@ errcode_t ext2fs_dblist_dir_iterate(ext2_dblist dblist,
ctx.priv_data = priv_data;
ctx.errcode = 0;
- retval = ext2fs_dblist_iterate2(dblist, db_dir_proc, &ctx);
+ retval = ext2fs_dblist_iterate(dblist, db_dir_proc, &ctx);
if (!block_buf)
ext2fs_free_mem(&ctx.buf);
@@ -61,7 +61,7 @@ errcode_t ext2fs_dblist_dir_iterate(ext2_dblist dblist,
return ctx.errcode;
}
-static int db_dir_proc(ext2_filsys fs, struct ext2_db_entry2 *db_info,
+static int db_dir_proc(ext2_filsys fs, struct ext2_db_entry *db_info,
void *priv_data)
{
struct dir_context *ctx;
diff --git a/lib/ext2fs/dir_iterate.c b/lib/ext2fs/dir_iterate.c
index 8412218c..124862ea 100644
--- a/lib/ext2fs/dir_iterate.c
+++ b/lib/ext2fs/dir_iterate.c
@@ -122,7 +122,7 @@ errcode_t ext2fs_dir_iterate2(ext2_filsys fs,
ctx.func = func;
ctx.priv_data = priv_data;
ctx.errcode = 0;
- retval = ext2fs_block_iterate3(fs, dir, BLOCK_FLAG_READ_ONLY, 0,
+ retval = ext2fs_block_iterate2(fs, dir, BLOCK_FLAG_READ_ONLY, 0,
ext2fs_process_dir_block, &ctx);
if (!block_buf)
ext2fs_free_mem(&ctx.buf);
@@ -150,16 +150,16 @@ static int xlate_func(ext2_ino_t dir EXT2FS_ATTR((unused)),
return (*xl->func)(dirent, offset, blocksize, buf, xl->real_private);
}
-errcode_t ext2fs_dir_iterate(ext2_filsys fs,
- ext2_ino_t dir,
- int flags,
- char *block_buf,
- int (*func)(struct ext2_dir_entry *dirent,
- int offset,
- int blocksize,
- char *buf,
- void *priv_data),
- void *priv_data)
+extern errcode_t ext2fs_dir_iterate(ext2_filsys fs,
+ ext2_ino_t dir,
+ int flags,
+ char *block_buf,
+ int (*func)(struct ext2_dir_entry *dirent,
+ int offset,
+ int blocksize,
+ char *buf,
+ void *priv_data),
+ void *priv_data)
{
struct xlate xl;
@@ -176,9 +176,9 @@ errcode_t ext2fs_dir_iterate(ext2_filsys fs,
* ext2fs_dir_iterate() and ext2fs_dblist_dir_iterate()
*/
int ext2fs_process_dir_block(ext2_filsys fs,
- blk64_t *blocknr,
+ blk_t *blocknr,
e2_blkcnt_t blockcnt,
- blk64_t ref_block EXT2FS_ATTR((unused)),
+ blk_t ref_block EXT2FS_ATTR((unused)),
int ref_offset EXT2FS_ATTR((unused)),
void *priv_data)
{
@@ -197,7 +197,7 @@ int ext2fs_process_dir_block(ext2_filsys fs,
entry = blockcnt ? DIRENT_OTHER_FILE : DIRENT_DOT_FILE;
- ctx->errcode = ext2fs_read_dir_block3(fs, *blocknr, ctx->buf, 0);
+ ctx->errcode = ext2fs_read_dir_block(fs, *blocknr, ctx->buf);
if (ctx->errcode)
return BLOCK_ABORT;
@@ -258,8 +258,7 @@ next:
}
if (changed) {
- ctx->errcode = ext2fs_write_dir_block3(fs, *blocknr, ctx->buf,
- 0);
+ ctx->errcode = ext2fs_write_dir_block(fs, *blocknr, ctx->buf);
if (ctx->errcode)
return BLOCK_ABORT;
}
diff --git a/lib/ext2fs/dirblock.c b/lib/ext2fs/dirblock.c
index 73e1f0ab..29b4fcd2 100644
--- a/lib/ext2fs/dirblock.c
+++ b/lib/ext2fs/dirblock.c
@@ -19,7 +19,7 @@
#include "ext2_fs.h"
#include "ext2fs.h"
-errcode_t ext2fs_read_dir_block3(ext2_filsys fs, blk64_t block,
+errcode_t ext2fs_read_dir_block2(ext2_filsys fs, blk_t block,
void *buf, int flags EXT2FS_ATTR((unused)))
{
errcode_t retval;
@@ -28,7 +28,7 @@ errcode_t ext2fs_read_dir_block3(ext2_filsys fs, blk64_t block,
unsigned int name_len, rec_len;
- retval = io_channel_read_blk64(fs->io, block, 1, buf);
+ retval = io_channel_read_blk(fs->io, block, 1, buf);
if (retval)
return retval;
@@ -58,20 +58,14 @@ errcode_t ext2fs_read_dir_block3(ext2_filsys fs, blk64_t block,
return retval;
}
-errcode_t ext2fs_read_dir_block2(ext2_filsys fs, blk_t block,
- void *buf, int flags EXT2FS_ATTR((unused)))
-{
- return ext2fs_read_dir_block3(fs, block, buf, flags);
-}
-
errcode_t ext2fs_read_dir_block(ext2_filsys fs, blk_t block,
void *buf)
{
- return ext2fs_read_dir_block3(fs, block, buf, 0);
+ return ext2fs_read_dir_block2(fs, block, buf, 0);
}
-errcode_t ext2fs_write_dir_block3(ext2_filsys fs, blk64_t block,
+errcode_t ext2fs_write_dir_block2(ext2_filsys fs, blk_t block,
void *inbuf, int flags EXT2FS_ATTR((unused)))
{
#ifdef WORDS_BIGENDIAN
@@ -104,23 +98,18 @@ errcode_t ext2fs_write_dir_block3(ext2_filsys fs, blk64_t block,
if (flags & EXT2_DIRBLOCK_V2_STRUCT)
dirent->name_len = ext2fs_swab16(dirent->name_len);
}
- retval = io_channel_write_blk64(fs->io, block, 1, buf);
+ retval = io_channel_write_blk(fs->io, block, 1, buf);
ext2fs_free_mem(&buf);
return retval;
#else
- return io_channel_write_blk64(fs->io, block, 1, (char *) inbuf);
+ return io_channel_write_blk(fs->io, block, 1, (char *) inbuf);
#endif
}
-errcode_t ext2fs_write_dir_block2(ext2_filsys fs, blk_t block,
- void *inbuf, int flags EXT2FS_ATTR((unused)))
-{
- return ext2fs_write_dir_block3(fs, block, inbuf, flags);
-}
errcode_t ext2fs_write_dir_block(ext2_filsys fs, blk_t block,
void *inbuf)
{
- return ext2fs_write_dir_block3(fs, block, inbuf, 0);
+ return ext2fs_write_dir_block2(fs, block, inbuf, 0);
}
diff --git a/lib/ext2fs/dirhash.c b/lib/ext2fs/dirhash.c
index 5477bfbc..a0697069 100644
--- a/lib/ext2fs/dirhash.c
+++ b/lib/ext2fs/dirhash.c
@@ -217,13 +217,11 @@ errcode_t ext2fs_dirhash(int version, const char *name, int len,
switch (version) {
case EXT2_HASH_LEGACY_UNSIGNED:
unsigned_flag++;
- /* fallthrough */
case EXT2_HASH_LEGACY:
hash = dx_hack_hash(name, len, unsigned_flag);
break;
case EXT2_HASH_HALF_MD4_UNSIGNED:
unsigned_flag++;
- /* fallthrough */
case EXT2_HASH_HALF_MD4:
p = name;
while (len > 0) {
@@ -237,7 +235,6 @@ errcode_t ext2fs_dirhash(int version, const char *name, int len,
break;
case EXT2_HASH_TEA_UNSIGNED:
unsigned_flag++;
- /* fallthrough */
case EXT2_HASH_TEA:
p = name;
while (len > 0) {
diff --git a/lib/ext2fs/dupfs.c b/lib/ext2fs/dupfs.c
index 13a48121..a9e2a976 100644
--- a/lib/ext2fs/dupfs.c
+++ b/lib/ext2fs/dupfs.c
@@ -39,9 +39,6 @@ errcode_t ext2fs_dup_handle(ext2_filsys src, ext2_filsys *dest)
fs->block_map = 0;
fs->badblocks = 0;
fs->dblist = 0;
- fs->mmp_buf = 0;
- fs->mmp_cmp = 0;
- fs->mmp_fd = -1;
io_channel_bumpcount(fs->io);
if (fs->icache)
@@ -89,28 +86,6 @@ errcode_t ext2fs_dup_handle(ext2_filsys src, ext2_filsys *dest)
if (retval)
goto errout;
}
- if (src->mmp_buf) {
- retval = ext2fs_get_mem(src->blocksize, &fs->mmp_buf);
- if (retval)
- goto errout;
- memcpy(fs->mmp_buf, src->mmp_buf, src->blocksize);
- }
- if (src->mmp_fd >= 0) {
- fs->mmp_fd = dup(src->mmp_fd);
- if (fs->mmp_fd < 0) {
- retval = EXT2_ET_MMP_OPEN_DIRECT;
- goto errout;
- }
- }
- if (src->mmp_cmp) {
- int align = ext2fs_get_dio_alignment(src->mmp_fd);
-
- retval = ext2fs_get_memalign(src->blocksize, align,
- &fs->mmp_cmp);
- if (retval)
- goto errout;
- memcpy(fs->mmp_cmp, src->mmp_cmp, src->blocksize);
- }
*dest = fs;
return 0;
errout:
diff --git a/lib/ext2fs/e2image.h b/lib/ext2fs/e2image.h
index 53b20cc7..4de2c8d9 100644
--- a/lib/ext2fs/e2image.h
+++ b/lib/ext2fs/e2image.h
@@ -12,6 +12,7 @@
* %End-Header%
*/
+
struct ext2_image_hdr {
__u32 magic_number; /* This must be EXT2_ET_MAGIC_E2IMAGE */
char magic_descriptor[16]; /* "Ext2 Image 1.0", w/ null padding */
@@ -35,3 +36,16 @@ struct ext2_image_hdr {
__u32 offset_blockmap; /* Byte offset of the inode bitmaps */
__u32 offset_reserved[8];
};
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/ext2fs/expanddir.c b/lib/ext2fs/expanddir.c
index c89385be..a71c6c9d 100644
--- a/lib/ext2fs/expanddir.c
+++ b/lib/ext2fs/expanddir.c
@@ -21,39 +21,30 @@
struct expand_dir_struct {
int done;
int newblocks;
- blk64_t goal;
errcode_t err;
};
static int expand_dir_proc(ext2_filsys fs,
- blk64_t *blocknr,
+ blk_t *blocknr,
e2_blkcnt_t blockcnt,
- blk64_t ref_block EXT2FS_ATTR((unused)),
+ blk_t ref_block EXT2FS_ATTR((unused)),
int ref_offset EXT2FS_ATTR((unused)),
void *priv_data)
{
struct expand_dir_struct *es = (struct expand_dir_struct *) priv_data;
- blk64_t new_blk;
+ blk_t new_blk;
+ static blk_t last_blk = 0;
char *block;
errcode_t retval;
if (*blocknr) {
- if (blockcnt >= 0)
- es->goal = *blocknr;
+ last_blk = *blocknr;
return 0;
}
- if (blockcnt &&
- (EXT2FS_B2C(fs, es->goal) == EXT2FS_B2C(fs, es->goal+1)))
- new_blk = es->goal+1;
- else {
- es->goal &= ~EXT2FS_CLUSTER_MASK(fs);
- retval = ext2fs_new_block2(fs, es->goal, 0, &new_blk);
- if (retval) {
- es->err = retval;
- return BLOCK_ABORT;
- }
- es->newblocks++;
- ext2fs_block_alloc_stats2(fs, new_blk, +1);
+ retval = ext2fs_new_block(fs, last_blk, 0, &new_blk);
+ if (retval) {
+ es->err = retval;
+ return BLOCK_ABORT;
}
if (blockcnt > 0) {
retval = ext2fs_new_dir_block(fs, 0, 0, &block);
@@ -70,16 +61,16 @@ static int expand_dir_proc(ext2_filsys fs,
return BLOCK_ABORT;
}
memset(block, 0, fs->blocksize);
- retval = io_channel_write_blk64(fs->io, new_blk, 1, block);
+ retval = io_channel_write_blk(fs->io, new_blk, 1, block);
}
- if (blockcnt >= 0)
- es->goal = new_blk;
if (retval) {
es->err = retval;
return BLOCK_ABORT;
}
ext2fs_free_mem(&block);
*blocknr = new_blk;
+ ext2fs_block_alloc_stats(fs, new_blk, +1);
+ es->newblocks++;
if (es->done)
return (BLOCK_CHANGED | BLOCK_ABORT);
@@ -107,10 +98,9 @@ errcode_t ext2fs_expand_dir(ext2_filsys fs, ext2_ino_t dir)
es.done = 0;
es.err = 0;
- es.goal = 0;
es.newblocks = 0;
- retval = ext2fs_block_iterate3(fs, dir, BLOCK_FLAG_APPEND,
+ retval = ext2fs_block_iterate2(fs, dir, BLOCK_FLAG_APPEND,
0, expand_dir_proc, &es);
if (es.err)
diff --git a/lib/ext2fs/ext2_err.c b/lib/ext2fs/ext2_err.c
index 3d6f0b4a..9008ac86 100644
--- a/lib/ext2fs/ext2_err.c
+++ b/lib/ext2fs/ext2_err.c
@@ -5,165 +5,144 @@
#include <stdlib.h>
-#define N_(a) a
-
static const char * const text[] = {
- N_( "EXT2FS Library version 1.42.9"),
- N_( "Wrong magic number for ext2_filsys structure"),
- N_( "Wrong magic number for badblocks_list structure"),
- N_( "Wrong magic number for badblocks_iterate structure"),
- N_( "Wrong magic number for inode_scan structure"),
- N_( "Wrong magic number for io_channel structure"),
- N_( "Wrong magic number for unix io_channel structure"),
- N_( "Wrong magic number for io_manager structure"),
- N_( "Wrong magic number for block_bitmap structure"),
- N_( "Wrong magic number for inode_bitmap structure"),
- N_( "Wrong magic number for generic_bitmap structure"),
- N_( "Wrong magic number for test io_channel structure"),
- N_( "Wrong magic number for directory block list structure"),
- N_( "Wrong magic number for icount structure"),
- N_( "Wrong magic number for Powerquest io_channel structure"),
- N_( "Wrong magic number for ext2 file structure"),
- N_( "Wrong magic number for Ext2 Image Header"),
- N_( "Wrong magic number for inode io_channel structure"),
- N_( "Wrong magic number for ext4 extent handle"),
- N_( "Bad magic number in super-block"),
- N_( "Filesystem revision too high"),
- N_( "Attempt to write to filesystem opened read-only"),
- N_( "Can't read group descriptors"),
- N_( "Can't write group descriptors"),
- N_( "Corrupt group descriptor: bad block for block bitmap"),
- N_( "Corrupt group descriptor: bad block for inode bitmap"),
- N_( "Corrupt group descriptor: bad block for inode table"),
- N_( "Can't write an inode bitmap"),
- N_( "Can't read an inode bitmap"),
- N_( "Can't write a block bitmap"),
- N_( "Can't read a block bitmap"),
- N_( "Can't write an inode table"),
- N_( "Can't read an inode table"),
- N_( "Can't read next inode"),
- N_( "Filesystem has unexpected block size"),
- N_( "EXT2 directory corrupted"),
- N_( "Attempt to read block from filesystem resulted in short read"),
- N_( "Attempt to write block to filesystem resulted in short write"),
- N_( "No free space in the directory"),
- N_( "Inode bitmap not loaded"),
- N_( "Block bitmap not loaded"),
- N_( "Illegal inode number"),
- N_( "Illegal block number"),
- N_( "Internal error in ext2fs_expand_dir"),
- N_( "Not enough space to build proposed filesystem"),
- N_( "Illegal block number passed to ext2fs_mark_block_bitmap"),
- N_( "Illegal block number passed to ext2fs_unmark_block_bitmap"),
- N_( "Illegal block number passed to ext2fs_test_block_bitmap"),
- N_( "Illegal inode number passed to ext2fs_mark_inode_bitmap"),
- N_( "Illegal inode number passed to ext2fs_unmark_inode_bitmap"),
- N_( "Illegal inode number passed to ext2fs_test_inode_bitmap"),
- N_( "Attempt to fudge end of block bitmap past the real end"),
- N_( "Attempt to fudge end of inode bitmap past the real end"),
- N_( "Illegal indirect block found" ),
- N_( "Illegal doubly indirect block found" ),
- N_( "Illegal triply indirect block found" ),
- N_( "Block bitmaps are not the same"),
- N_( "Inode bitmaps are not the same"),
- N_( "Illegal or malformed device name"),
- N_( "A block group is missing an inode table"),
- N_( "The ext2 superblock is corrupt"),
- N_( "Illegal generic bit number passed to ext2fs_mark_generic_bitmap"),
- N_( "Illegal generic bit number passed to ext2fs_unmark_generic_bitmap"),
- N_( "Illegal generic bit number passed to ext2fs_test_generic_bitmap"),
- N_( "Too many symbolic links encountered."),
- N_( "The callback function will not handle this case"),
- N_( "The inode is from a bad block in the inode table"),
- N_( "Filesystem has unsupported feature(s)"),
- N_( "Filesystem has unsupported read-only feature(s)"),
- N_( "IO Channel failed to seek on read or write"),
- N_( "Memory allocation failed"),
- N_( "Invalid argument passed to ext2 library"),
- N_( "Could not allocate block in ext2 filesystem"),
- N_( "Could not allocate inode in ext2 filesystem"),
- N_( "Ext2 inode is not a directory"),
- N_( "Too many references in table"),
- N_( "File not found by ext2_lookup"),
- N_( "File open read-only"),
- N_( "Ext2 directory block not found"),
- N_( "Ext2 directory already exists"),
- N_( "Unimplemented ext2 library function"),
- N_( "User cancel requested"),
- N_( "Ext2 file too big"),
- N_( "Supplied journal device not a block device"),
- N_( "Journal superblock not found"),
- N_( "Journal must be at least 1024 blocks"),
- N_( "Unsupported journal version"),
- N_( "Error loading external journal"),
- N_( "Journal not found"),
- N_( "Directory hash unsupported"),
- N_( "Illegal extended attribute block number"),
- N_( "Cannot create filesystem with requested number of inodes"),
- N_( "E2image snapshot not in use"),
- N_( "Too many reserved group descriptor blocks"),
- N_( "Resize inode is corrupt"),
- N_( "Tried to set block bmap with missing indirect block"),
- N_( "TDB: Success"),
- N_( "TDB: Corrupt database"),
- N_( "TDB: IO Error"),
- N_( "TDB: Locking error"),
- N_( "TDB: Out of memory"),
- N_( "TDB: Record exists"),
- N_( "TDB: Lock exists on other keys"),
- N_( "TDB: Invalid parameter"),
- N_( "TDB: Record does not exist"),
- N_( "TDB: Write not permitted"),
- N_( "Ext2fs directory block list is empty"),
- N_( "Attempt to modify a block mapping via a read-only block iterator"),
- N_( "Wrong magic number for ext4 extent saved path"),
- N_( "Wrong magic number for 64-bit generic bitmap"),
- N_( "Wrong magic number for 64-bit block bitmap"),
- N_( "Wrong magic number for 64-bit inode bitmap"),
- N_( "Wrong magic number --- RESERVED_13"),
- N_( "Wrong magic number --- RESERVED_14"),
- N_( "Wrong magic number --- RESERVED_15"),
- N_( "Wrong magic number --- RESERVED_16"),
- N_( "Wrong magic number --- RESERVED_17"),
- N_( "Wrong magic number --- RESERVED_18"),
- N_( "Wrong magic number --- RESERVED_19"),
- N_( "Corrupt extent header"),
- N_( "Corrupt extent index"),
- N_( "Corrupt extent"),
- N_( "No free space in extent map"),
- N_( "Inode does not use extents"),
- N_( "No 'next' extent"),
- N_( "No 'previous' extent"),
- N_( "No 'up' extent"),
- N_( "No 'down' extent"),
- N_( "No current node"),
- N_( "Ext2fs operation not supported"),
- N_( "No room to insert extent in node"),
- N_( "Splitting would result in empty node"),
- N_( "Extent not found"),
- N_( "Operation not supported for inodes containing extents"),
- N_( "Extent length is invalid"),
- N_( "I/O Channel does not support 64-bit block numbers"),
- N_( "Can't check if filesystem is mounted due to missing mtab file"),
- N_( "Filesystem too large to use legacy bitmaps"),
- N_( "MMP: invalid magic number"),
- N_( "MMP: device currently active"),
- N_( "MMP: fsck being run"),
- N_( "MMP: block number beyond filesystem range"),
- N_( "MMP: undergoing an unknown operation"),
- N_( "MMP: filesystem still in use"),
- N_( "MMP: open with O_DIRECT failed"),
- N_( "Block group descriptor size incorrect"),
- N_( "Inode checksum does not match inode"),
- N_( "Inode bitmap checksum does not match bitmap"),
- N_( "Extent block checksum does not match extent block"),
- N_( "Directory block does not have space for checksum"),
- N_( "Directory block checksum does not match directory block"),
- N_( "Extended attribute block checksum does not match block"),
- N_( "Superblock checksum does not match superblock"),
- N_( "Unknown checksum algorithm"),
- N_( "MMP block checksum does not match MMP block"),
- N_( "Ext2 file already exists"),
+ "EXT2FS Library version 1.41.14",
+ "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 for generic_bitmap structure",
+ "Wrong magic number for test io_channel structure",
+ "Wrong magic number for directory block list structure",
+ "Wrong magic number for icount structure",
+ "Wrong magic number for Powerquest io_channel structure",
+ "Wrong magic number for ext2 file structure",
+ "Wrong magic number for Ext2 Image Header",
+ "Wrong magic number for inode io_channel structure",
+ "Wrong magic number for ext4 extent handle",
+ "Bad magic number in super-block",
+ "Filesystem revision too high",
+ "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" ,
+ "Block bitmaps are not the same",
+ "Inode bitmaps are not the same",
+ "Illegal or malformed device name",
+ "A block group is missing an inode table",
+ "The ext2 superblock is corrupt",
+ "Illegal generic bit number passed to ext2fs_mark_generic_bitmap",
+ "Illegal generic bit number passed to ext2fs_unmark_generic_bitmap",
+ "Illegal generic bit number passed to ext2fs_test_generic_bitmap",
+ "Too many symbolic links encountered.",
+ "The callback function will not handle this case",
+ "The inode is from a bad block in the inode table",
+ "Filesystem has unsupported feature(s)",
+ "Filesystem has unsupported read-only feature(s)",
+ "IO Channel failed to seek on read or write",
+ "Memory allocation failed",
+ "Invalid argument passed to ext2 library",
+ "Could not allocate block in ext2 filesystem",
+ "Could not allocate inode in ext2 filesystem",
+ "Ext2 inode is not a directory",
+ "Too many references in table",
+ "File not found by ext2_lookup",
+ "File open read-only",
+ "Ext2 directory block not found",
+ "Ext2 directory already exists",
+ "Unimplemented ext2 library function",
+ "User cancel requested",
+ "Ext2 file too big",
+ "Supplied journal device not a block device",
+ "Journal superblock not found",
+ "Journal must be at least 1024 blocks",
+ "Unsupported journal version",
+ "Error loading external journal",
+ "Journal not found",
+ "Directory hash unsupported",
+ "Illegal extended attribute block number",
+ "Cannot create filesystem with requested number of inodes",
+ "E2image snapshot not in use",
+ "Too many reserved group descriptor blocks",
+ "Resize inode is corrupt",
+ "Missing indirect block not present",
+ "TDB: Success",
+ "TDB: Corrupt database",
+ "TDB: IO Error",
+ "TDB: Locking error",
+ "TDB: Out of memory",
+ "TDB: Record exists",
+ "TDB: Lock exists on other keys",
+ "TDB: Invalid parameter",
+ "TDB: Record does not exist",
+ "TDB: Write not permitted",
+ "Ext2fs directory block list is empty",
+ "Attempt to modify a block mapping via a read-only block iterator",
+ "Wrong magic number for ext4 extent saved path",
+ "Wrong magic number --- RESERVED_10",
+ "Wrong magic number --- RESERVED_11",
+ "Wrong magic number --- RESERVED_12",
+ "Wrong magic number --- RESERVED_13",
+ "Wrong magic number --- RESERVED_14",
+ "Wrong magic number --- RESERVED_15",
+ "Wrong magic number --- RESERVED_16",
+ "Wrong magic number --- RESERVED_17",
+ "Wrong magic number --- RESERVED_18",
+ "Wrong magic number --- RESERVED_19",
+ "Corrupt extent header",
+ "Corrupt extent index",
+ "Corrupt extent",
+ "No free space in extent map",
+ "Inode does not use extents",
+ "No 'next' extent",
+ "No 'previous' extent",
+ "No 'up' extent",
+ "No 'down' extent",
+ "No current node",
+ "Ext2fs operation not supported",
+ "No room to insert extent in node",
+ "Splitting would result in empty node",
+ "Extent not found",
+ "Operation not supported for inodes containing extents",
+ "Extent length is invalid",
+ "I/O Channel does not support 64-bit block numbers",
+ "Can't check if filesystem is mounted due to missing mtab file",
0
};
@@ -178,7 +157,7 @@ struct et_list {
};
extern struct et_list *_et_list;
-const struct error_table et_ext2_error_table = { text, 2133571328L, 156 };
+const struct error_table et_ext2_error_table = { text, 2133571328L, 137 };
static struct et_list link = { 0, 0 };
diff --git a/lib/ext2fs/ext2_err.et.in b/lib/ext2fs/ext2_err.et.in
index 87812ab4..406f3ae8 100644
--- a/lib/ext2fs/ext2_err.et.in
+++ b/lib/ext2fs/ext2_err.et.in
@@ -96,10 +96,10 @@ ec EXT2_ET_INODE_BITMAP_READ,
"Can't read an inode bitmap"
ec EXT2_ET_BLOCK_BITMAP_WRITE,
- "Can't write a block bitmap"
+ "Can't write an block bitmap"
ec EXT2_ET_BLOCK_BITMAP_READ,
- "Can't read a block bitmap"
+ "Can't read an block bitmap"
ec EXT2_ET_INODE_TABLE_WRITE,
"Can't write an inode table"
@@ -120,7 +120,7 @@ ec EXT2_ET_SHORT_READ,
"Attempt to read block from filesystem resulted in short read"
ec EXT2_ET_SHORT_WRITE,
- "Attempt to write block to filesystem resulted in short write"
+ "Attempt to write block from filesystem resulted in short write"
ec EXT2_ET_DIR_NO_SPACE,
"No free space in the directory"
@@ -294,7 +294,7 @@ ec EXT2_ET_RESIZE_INODE_CORRUPT,
"Resize inode is corrupt"
ec EXT2_ET_SET_BMAP_NO_IND,
- "Tried to set block bmap with missing indirect block"
+ "Missing indirect block not present"
ec EXT2_ET_TDB_SUCCESS,
"TDB: Success"
@@ -335,14 +335,14 @@ ec EXT2_ET_RO_BLOCK_ITERATE,
ec EXT2_ET_MAGIC_EXTENT_PATH,
"Wrong magic number for ext4 extent saved path"
-ec EXT2_ET_MAGIC_GENERIC_BITMAP64,
- "Wrong magic number for 64-bit generic bitmap"
+ec EXT2_ET_MAGIC_RESERVED_10,
+ "Wrong magic number --- RESERVED_10"
-ec EXT2_ET_MAGIC_BLOCK_BITMAP64,
- "Wrong magic number for 64-bit block bitmap"
+ec EXT2_ET_MAGIC_RESERVED_11,
+ "Wrong magic number --- RESERVED_11"
-ec EXT2_ET_MAGIC_INODE_BITMAP64,
- "Wrong magic number for 64-bit inode bitmap"
+ec EXT2_ET_MAGIC_RESERVED_12,
+ "Wrong magic number --- RESERVED_12"
ec EXT2_ET_MAGIC_RESERVED_13,
"Wrong magic number --- RESERVED_13"
@@ -416,64 +416,7 @@ ec EXT2_ET_EXTENT_INVALID_LENGTH,
ec EXT2_ET_IO_CHANNEL_NO_SUPPORT_64,
"I/O Channel does not support 64-bit block numbers"
-ec EXT2_ET_NO_MTAB_FILE,
+ec EXT2_NO_MTAB_FILE,
"Can't check if filesystem is mounted due to missing mtab file"
-ec EXT2_ET_CANT_USE_LEGACY_BITMAPS,
- "Filesystem too large to use legacy bitmaps"
-
-ec EXT2_ET_MMP_MAGIC_INVALID,
- "MMP: invalid magic number"
-
-ec EXT2_ET_MMP_FAILED,
- "MMP: device currently active"
-
-ec EXT2_ET_MMP_FSCK_ON,
- "MMP: fsck being run"
-
-ec EXT2_ET_MMP_BAD_BLOCK,
- "MMP: block number beyond filesystem range"
-
-ec EXT2_ET_MMP_UNKNOWN_SEQ,
- "MMP: undergoing an unknown operation"
-
-ec EXT2_ET_MMP_CHANGE_ABORT,
- "MMP: filesystem still in use"
-
-ec EXT2_ET_MMP_OPEN_DIRECT,
- "MMP: open with O_DIRECT failed"
-
-ec EXT2_ET_BAD_DESC_SIZE,
- "Block group descriptor size incorrect"
-
-ec EXT2_ET_INODE_CSUM_INVALID,
- "Inode checksum does not match inode"
-
-ec EXT2_ET_INODE_BITMAP_CSUM_INVALID,
- "Inode bitmap checksum does not match bitmap"
-
-ec EXT2_ET_EXTENT_CSUM_INVALID,
- "Extent block checksum does not match extent block"
-
-ec EXT2_ET_DIR_NO_SPACE_FOR_CSUM,
- "Directory block does not have space for checksum"
-
-ec EXT2_ET_DIR_CSUM_INVALID,
- "Directory block checksum does not match directory block"
-
-ec EXT2_ET_EXT_ATTR_CSUM_INVALID,
- "Extended attribute block checksum does not match block"
-
-ec EXT2_ET_SB_CSUM_INVALID,
- "Superblock checksum does not match superblock"
-
-ec EXT2_ET_UNKNOWN_CSUM,
- "Unknown checksum algorithm"
-
-ec EXT2_ET_MMP_CSUM_INVALID,
- "MMP block checksum does not match MMP block"
-
-ec EXT2_ET_FILE_EXISTS,
- "Ext2 file already exists"
-
end
diff --git a/lib/ext2fs/ext2_err.h b/lib/ext2fs/ext2_err.h
index 70224181..7b2df090 100644
--- a/lib/ext2fs/ext2_err.h
+++ b/lib/ext2fs/ext2_err.h
@@ -114,9 +114,9 @@
#define EXT2_ET_DBLIST_EMPTY (2133571434L)
#define EXT2_ET_RO_BLOCK_ITERATE (2133571435L)
#define EXT2_ET_MAGIC_EXTENT_PATH (2133571436L)
-#define EXT2_ET_MAGIC_GENERIC_BITMAP64 (2133571437L)
-#define EXT2_ET_MAGIC_BLOCK_BITMAP64 (2133571438L)
-#define EXT2_ET_MAGIC_INODE_BITMAP64 (2133571439L)
+#define EXT2_ET_MAGIC_RESERVED_10 (2133571437L)
+#define EXT2_ET_MAGIC_RESERVED_11 (2133571438L)
+#define EXT2_ET_MAGIC_RESERVED_12 (2133571439L)
#define EXT2_ET_MAGIC_RESERVED_13 (2133571440L)
#define EXT2_ET_MAGIC_RESERVED_14 (2133571441L)
#define EXT2_ET_MAGIC_RESERVED_15 (2133571442L)
@@ -141,26 +141,7 @@
#define EXT2_ET_EXTENT_NOT_SUPPORTED (2133571461L)
#define EXT2_ET_EXTENT_INVALID_LENGTH (2133571462L)
#define EXT2_ET_IO_CHANNEL_NO_SUPPORT_64 (2133571463L)
-#define EXT2_ET_NO_MTAB_FILE (2133571464L)
-#define EXT2_ET_CANT_USE_LEGACY_BITMAPS (2133571465L)
-#define EXT2_ET_MMP_MAGIC_INVALID (2133571466L)
-#define EXT2_ET_MMP_FAILED (2133571467L)
-#define EXT2_ET_MMP_FSCK_ON (2133571468L)
-#define EXT2_ET_MMP_BAD_BLOCK (2133571469L)
-#define EXT2_ET_MMP_UNKNOWN_SEQ (2133571470L)
-#define EXT2_ET_MMP_CHANGE_ABORT (2133571471L)
-#define EXT2_ET_MMP_OPEN_DIRECT (2133571472L)
-#define EXT2_ET_BAD_DESC_SIZE (2133571473L)
-#define EXT2_ET_INODE_CSUM_INVALID (2133571474L)
-#define EXT2_ET_INODE_BITMAP_CSUM_INVALID (2133571475L)
-#define EXT2_ET_EXTENT_CSUM_INVALID (2133571476L)
-#define EXT2_ET_DIR_NO_SPACE_FOR_CSUM (2133571477L)
-#define EXT2_ET_DIR_CSUM_INVALID (2133571478L)
-#define EXT2_ET_EXT_ATTR_CSUM_INVALID (2133571479L)
-#define EXT2_ET_SB_CSUM_INVALID (2133571480L)
-#define EXT2_ET_UNKNOWN_CSUM (2133571481L)
-#define EXT2_ET_MMP_CSUM_INVALID (2133571482L)
-#define EXT2_ET_FILE_EXISTS (2133571483L)
+#define EXT2_NO_MTAB_FILE (2133571464L)
extern const struct error_table et_ext2_error_table;
extern void initialize_ext2_error_table(void);
diff --git a/lib/ext2fs/ext2_fs.h b/lib/ext2fs/ext2_fs.h
index 930c2a3f..afd33a93 100644
--- a/lib/ext2fs/ext2_fs.h
+++ b/lib/ext2fs/ext2_fs.h
@@ -44,14 +44,13 @@
*/
#define EXT2_BAD_INO 1 /* Bad blocks inode */
#define EXT2_ROOT_INO 2 /* Root inode */
-#define EXT4_USR_QUOTA_INO 3 /* User quota inode */
-#define EXT4_GRP_QUOTA_INO 4 /* Group quota inode */
+#define EXT2_ACL_IDX_INO 3 /* ACL inode */
+#define EXT2_ACL_DATA_INO 4 /* ACL inode */
#define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */
#define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */
#define EXT2_RESIZE_INO 7 /* Reserved group descriptors inode */
#define EXT2_JOURNAL_INO 8 /* Journal inode */
#define EXT2_EXCLUDE_INO 9 /* The "exclude" inode, for snapshots */
-#define EXT4_REPLICA_INO 10 /* Used by non-upstream feature */
/* First non-reserved inode for old ext2 filesystems */
#define EXT2_GOOD_OLD_FIRST_INO 11
@@ -99,27 +98,18 @@
#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof(__u32))
/*
- * Macro-instructions used to manage allocation clusters
- */
-#define EXT2_MIN_CLUSTER_LOG_SIZE EXT2_MIN_BLOCK_LOG_SIZE
-#define EXT2_MAX_CLUSTER_LOG_SIZE 29 /* 512MB */
-#define EXT2_MIN_CLUSTER_SIZE EXT2_MIN_BLOCK_SIZE
-#define EXT2_MAX_CLUSTER_SIZE (1 << EXT2_MAX_CLUSTER_LOG_SIZE)
-#define EXT2_CLUSTER_SIZE(s) (EXT2_MIN_BLOCK_SIZE << \
- (s)->s_log_cluster_size)
-#define EXT2_CLUSTER_SIZE_BITS(s) ((s)->s_log_cluster_size + 10)
-
-/*
* Macro-instructions used to manage fragments
- *
- * Note: for backwards compatibility only, for the dump program.
- * Ext2/3/4 will never support fragments....
*/
-#define EXT2_MIN_FRAG_SIZE EXT2_MIN_BLOCK_SIZE
-#define EXT2_MAX_FRAG_SIZE EXT2_MAX_BLOCK_SIZE
-#define EXT2_MIN_FRAG_LOG_SIZE EXT2_MIN_BLOCK_LOG_SIZE
-#define EXT2_FRAG_SIZE(s) EXT2_BLOCK_SIZE(s)
-#define EXT2_FRAGS_PER_BLOCK(s) 1
+#define EXT2_MIN_FRAG_SIZE EXT2_MIN_BLOCK_SIZE
+#define EXT2_MAX_FRAG_SIZE EXT2_MAX_BLOCK_SIZE
+#define EXT2_MIN_FRAG_LOG_SIZE EXT2_MIN_BLOCK_LOG_SIZE
+#ifdef __KERNEL__
+# define EXT2_FRAG_SIZE(s) (EXT2_SB(s)->s_frag_size)
+# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_SB(s)->s_frags_per_block)
+#else
+# define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size)
+# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
+#endif
/*
* ACL structures
@@ -155,16 +145,11 @@ struct ext2_group_desc
__u16 bg_free_inodes_count; /* Free inodes count */
__u16 bg_used_dirs_count; /* Directories count */
__u16 bg_flags;
- __u32 bg_exclude_bitmap_lo; /* Exclude bitmap for snapshots */
- __u16 bg_block_bitmap_csum_lo;/* crc32c(s_uuid+grp_num+bitmap) LSB */
- __u16 bg_inode_bitmap_csum_lo;/* crc32c(s_uuid+grp_num+bitmap) LSB */
+ __u32 bg_reserved[2];
__u16 bg_itable_unused; /* Unused inodes count */
- __u16 bg_checksum; /* crc16(s_uuid+group_num+group_desc)*/
+ __u16 bg_checksum; /* crc16(s_uuid+grouo_num+group_desc)*/
};
-/*
- * Structure of a blocks group descriptor
- */
struct ext4_group_desc
{
__u32 bg_block_bitmap; /* Blocks bitmap block */
@@ -173,23 +158,18 @@ struct ext4_group_desc
__u16 bg_free_blocks_count; /* Free blocks count */
__u16 bg_free_inodes_count; /* Free inodes count */
__u16 bg_used_dirs_count; /* Directories count */
- __u16 bg_flags; /* EXT4_BG_flags (INODE_UNINIT, etc) */
- __u32 bg_exclude_bitmap_lo; /* Exclude bitmap for snapshots */
- __u16 bg_block_bitmap_csum_lo;/* crc32c(s_uuid+grp_num+bitmap) LSB */
- __u16 bg_inode_bitmap_csum_lo;/* crc32c(s_uuid+grp_num+bitmap) LSB */
+ __u16 bg_flags;
+ __u32 bg_reserved[2];
__u16 bg_itable_unused; /* Unused inodes count */
- __u16 bg_checksum; /* crc16(sb_uuid+group+desc) */
+ __u16 bg_checksum; /* crc16(s_uuid+grouo_num+group_desc)*/
__u32 bg_block_bitmap_hi; /* Blocks bitmap block MSB */
__u32 bg_inode_bitmap_hi; /* Inodes bitmap block MSB */
__u32 bg_inode_table_hi; /* Inodes table block MSB */
__u16 bg_free_blocks_count_hi;/* Free blocks count MSB */
__u16 bg_free_inodes_count_hi;/* Free inodes count MSB */
__u16 bg_used_dirs_count_hi; /* Directories count MSB */
- __u16 bg_itable_unused_hi; /* Unused inodes count MSB */
- __u32 bg_exclude_bitmap_hi; /* Exclude bitmap block MSB */
- __u16 bg_block_bitmap_csum_hi;/* crc32c(s_uuid+grp_num+bitmap) MSB */
- __u16 bg_inode_bitmap_csum_hi;/* crc32c(s_uuid+grp_num+bitmap) MSB */
- __u32 bg_reserved;
+ __u16 bg_pad;
+ __u32 bg_reserved2[3];
};
#define EXT2_BG_INODE_UNINIT 0x0001 /* Inode table/bitmap not initialized */
@@ -248,15 +228,10 @@ struct ext2_dx_countlimit {
#define EXT2_BLOCKS_PER_GROUP(s) (EXT2_SB(s)->s_blocks_per_group)
#define EXT2_INODES_PER_GROUP(s) (EXT2_SB(s)->s_inodes_per_group)
-#define EXT2_CLUSTERS_PER_GROUP(s) (EXT2_SB(s)->s_clusters_per_group)
#define EXT2_INODES_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s)/EXT2_INODE_SIZE(s))
/* limits imposed by 16-bit value gd_free_{blocks,inode}_count */
-#define EXT2_MAX_BLOCKS_PER_GROUP(s) ((((unsigned) 1 << 16) - 8) * \
- (EXT2_CLUSTER_SIZE(s) / \
- EXT2_BLOCK_SIZE(s)))
-#define EXT2_MAX_CLUSTERS_PER_GROUP(s) (((unsigned) 1 << 16) - 8)
-#define EXT2_MAX_INODES_PER_GROUP(s) (((unsigned) 1 << 16) - \
- EXT2_INODES_PER_BLOCK(s))
+#define EXT2_MAX_BLOCKS_PER_GROUP(s) ((1 << 16) - 8)
+#define EXT2_MAX_INODES_PER_GROUP(s) ((1 << 16) - EXT2_INODES_PER_BLOCK(s))
#ifdef __KERNEL__
#define EXT2_DESC_PER_BLOCK(s) (EXT2_SB(s)->s_desc_per_block)
#define EXT2_DESC_PER_BLOCK_BITS(s) (EXT2_SB(s)->s_desc_per_block_bits)
@@ -300,8 +275,7 @@ struct ext2_dx_countlimit {
#define EXT4_HUGE_FILE_FL 0x00040000 /* Set to each huge file */
#define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
#define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
-/* EXT4_EOFBLOCKS_FL 0x00400000 was here */
-#define FS_NOCOW_FL 0x00800000 /* Do not cow file */
+#define EXT4_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */
#define EXT4_SNAPFILE_FL 0x01000000 /* Inode is a snapshot */
#define EXT4_SNAPFILE_DELETED_FL 0x04000000 /* Snapshot is being deleted */
#define EXT4_SNAPFILE_SHRUNK_FL 0x08000000 /* Snapshot shrink has completed */
@@ -348,7 +322,6 @@ struct ext4_new_group_input {
#define EXT2_IOC_GROUP_EXTEND _IOW('f', 7, unsigned long)
#define EXT2_IOC_GROUP_ADD _IOW('f', 8,struct ext2_new_group_input)
#define EXT4_IOC_GROUP_ADD _IOW('f', 8,struct ext4_new_group_input)
-#define EXT4_IOC_RESIZE_FS _IOW('f', 16, __u64)
/*
* Structure of an inode on the disk
@@ -376,7 +349,7 @@ struct ext2_inode {
__u32 i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
__u32 i_generation; /* File version (for NFS) */
__u32 i_file_acl; /* File ACL */
- __u32 i_size_high; /* Formerly i_dir_acl, directory ACL */
+ __u32 i_dir_acl; /* Directory ACL */
__u32 i_faddr; /* Fragment address */
union {
struct {
@@ -384,8 +357,7 @@ struct ext2_inode {
__u16 l_i_file_acl_high;
__u16 l_i_uid_high; /* these 2 fields */
__u16 l_i_gid_high; /* were reserved2[0] */
- __u16 l_i_checksum_lo; /* crc32c(uuid+inum+inode) */
- __u16 l_i_reserved;
+ __u32 l_i_reserved2;
} linux2;
struct {
__u8 h_i_frag; /* Fragment number */
@@ -424,7 +396,7 @@ struct ext2_inode_large {
__u32 i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
__u32 i_generation; /* File version (for NFS) */
__u32 i_file_acl; /* File ACL */
- __u32 i_size_high; /* Formerly i_dir_acl, directory ACL */
+ __u32 i_dir_acl; /* Directory ACL */
__u32 i_faddr; /* Fragment address */
union {
struct {
@@ -432,8 +404,7 @@ struct ext2_inode_large {
__u16 l_i_file_acl_high;
__u16 l_i_uid_high; /* these 2 fields */
__u16 l_i_gid_high; /* were reserved2[0] */
- __u16 l_i_checksum_lo; /* crc32c(uuid+inum+inode) */
- __u16 l_i_reserved;
+ __u32 l_i_reserved2;
} linux2;
struct {
__u8 h_i_frag; /* Fragment number */
@@ -445,7 +416,7 @@ struct ext2_inode_large {
} hurd2;
} osd2; /* OS dependent 2 */
__u16 i_extra_isize;
- __u16 i_checksum_hi; /* crc32c(uuid+inum+inode) */
+ __u16 i_pad1;
__u32 i_ctime_extra; /* extra Change time (nsec << 2 | epoch) */
__u32 i_mtime_extra; /* extra Modification time (nsec << 2 | epoch) */
__u32 i_atime_extra; /* extra Access time (nsec << 2 | epoch) */
@@ -454,7 +425,7 @@ struct ext2_inode_large {
__u32 i_version_hi; /* high 32 bits for 64-bit version */
};
-#define i_dir_acl i_size_high
+#define i_size_high i_dir_acl
#if defined(__KERNEL__) || defined(__linux__)
#define i_reserved1 osd1.linux1.l_i_reserved1
@@ -464,6 +435,7 @@ struct ext2_inode_large {
#define i_gid_low i_gid
#define i_uid_high osd2.linux2.l_i_uid_high
#define i_gid_high osd2.linux2.l_i_gid_high
+#define i_reserved2 osd2.linux2.l_i_reserved2
#else
#if defined(__GNU__)
@@ -546,9 +518,9 @@ struct ext2_super_block {
__u32 s_free_inodes_count; /* Free inodes count */
__u32 s_first_data_block; /* First Data Block */
__u32 s_log_block_size; /* Block size */
- __u32 s_log_cluster_size; /* Allocation cluster size */
+ __s32 s_log_frag_size; /* Fragment size */
__u32 s_blocks_per_group; /* # Blocks per group */
- __u32 s_clusters_per_group; /* # Fragments per group */
+ __u32 s_frags_per_group; /* # Fragments per group */
__u32 s_inodes_per_group; /* # Inodes per group */
__u32 s_mtime; /* Mount time */
__u32 s_wtime; /* Write time */
@@ -616,7 +588,7 @@ struct ext2_super_block {
__u16 s_want_extra_isize; /* New inodes should reserve # bytes */
__u32 s_flags; /* Miscellaneous flags */
__u16 s_raid_stride; /* RAID stride */
- __u16 s_mmp_update_interval; /* # seconds to wait in MMP checking */
+ __u16 s_mmp_interval; /* # seconds to wait in MMP checking */
__u64 s_mmp_block; /* Block for multi-mount protection */
__u32 s_raid_stripe_width; /* blocks on all data disks (N*stride)*/
__u8 s_log_groups_per_flex; /* FLEX_BG group size */
@@ -642,11 +614,7 @@ struct ext2_super_block {
__u8 s_last_error_func[32]; /* function where the error happened */
#define EXT4_S_ERR_END ext4_offsetof(struct ext2_super_block, s_mount_opts)
__u8 s_mount_opts[64];
- __u32 s_usr_quota_inum; /* inode number of user quota file */
- __u32 s_grp_quota_inum; /* inode number of group quota file */
- __u32 s_overhead_blocks; /* overhead blocks/clusters in fs */
- __u32 s_reserved[108]; /* Padding to the end of the block */
- __u32 s_checksum; /* crc32c(superblock) */
+ __u32 s_reserved[112]; /* Padding to the end of the block */
};
#define EXT4_S_ERR_LEN (EXT4_S_ERR_END - EXT4_S_ERR_START)
@@ -694,9 +662,7 @@ struct ext2_super_block {
#define EXT2_FEATURE_COMPAT_RESIZE_INODE 0x0010
#define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020
#define EXT2_FEATURE_COMPAT_LAZY_BG 0x0040
-/* #define EXT2_FEATURE_COMPAT_EXCLUDE_INODE 0x0080 not used, legacy */
-#define EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP 0x0100
-
+#define EXT2_FEATURE_COMPAT_EXCLUDE_INODE 0x0080
#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
@@ -706,10 +672,6 @@ struct ext2_super_block {
#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020
#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
#define EXT4_FEATURE_RO_COMPAT_HAS_SNAPSHOT 0x0080
-#define EXT4_FEATURE_RO_COMPAT_QUOTA 0x0100
-#define EXT4_FEATURE_RO_COMPAT_BIGALLOC 0x0200
-#define EXT4_FEATURE_RO_COMPAT_METADATA_CSUM 0x0400
-#define EXT4_FEATURE_RO_COMPAT_REPLICA 0x0800
#define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001
#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
@@ -722,13 +684,10 @@ struct ext2_super_block {
#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
#define EXT4_FEATURE_INCOMPAT_EA_INODE 0x0400
#define EXT4_FEATURE_INCOMPAT_DIRDATA 0x1000
-/* 0x2000 was EXT4_FEATURE_INCOMPAT_BG_USE_META_CSUM but this was never used */
-#define EXT4_FEATURE_INCOMPAT_LARGEDIR 0x4000 /* >2GB or 3-lvl htree */
-#define EXT4_FEATURE_INCOMPAT_INLINEDATA 0x8000 /* data in inode */
+
#define EXT2_FEATURE_COMPAT_SUPP 0
-#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \
- EXT4_FEATURE_INCOMPAT_MMP)
+#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE)
#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
EXT4_FEATURE_RO_COMPAT_DIR_NLINK| \
@@ -809,52 +768,28 @@ struct ext2_dir_entry_2 {
~EXT2_DIR_ROUND)
/*
- * This structure is used for multiple mount protection. It is written
- * into the block number saved in the s_mmp_block field in the superblock.
- * Programs that check MMP should assume that if SEQ_FSCK (or any unknown
- * code above SEQ_MAX) is present then it is NOT safe to use the filesystem,
- * regardless of how old the timestamp is.
- *
- * The timestamp in the MMP structure will be updated by e2fsck at some
- * arbitary intervals (start of passes, after every few groups of inodes
- * in pass1 and pass1b). There is no guarantee that e2fsck is updating
- * the MMP block in a timely manner, and the updates it does are purely
- * for the convenience of the sysadmin and not for automatic validation.
- *
- * Note: Only the mmp_seq value is used to determine whether the MMP block
- * is being updated. The mmp_time, mmp_nodename, and mmp_bdevname
- * fields are only for informational purposes for the administrator,
- * due to clock skew between nodes and hostname HA service takeover.
+ * This structure will be used for multiple mount protection. It will be
+ * written into the block number saved in the s_mmp_block field in the
+ * superblock.
*/
-#define EXT4_MMP_MAGIC 0x004D4D50U /* ASCII for MMP */
-#define EXT4_MMP_SEQ_CLEAN 0xFF4D4D50U /* mmp_seq value for clean unmount */
-#define EXT4_MMP_SEQ_FSCK 0xE24D4D50U /* mmp_seq value when being fscked */
-#define EXT4_MMP_SEQ_MAX 0xE24D4D4FU /* maximum valid mmp_seq value */
+#define EXT2_MMP_MAGIC 0x004D4D50 /* ASCII for MMP */
+#define EXT2_MMP_CLEAN 0xFF4D4D50 /* Value of mmp_seq for clean unmount */
+#define EXT2_MMP_FSCK_ON 0xE24D4D50 /* Value of mmp_seq when being fscked */
struct mmp_struct {
- __u32 mmp_magic; /* Magic number for MMP */
- __u32 mmp_seq; /* Sequence no. updated periodically */
- __u64 mmp_time; /* Time last updated */
- char mmp_nodename[64]; /* Node which last updated MMP block */
- char mmp_bdevname[32]; /* Bdev which last updated MMP block */
- __u16 mmp_check_interval; /* Changed mmp_check_interval */
+ __u32 mmp_magic;
+ __u32 mmp_seq;
+ __u64 mmp_time;
+ char mmp_nodename[64];
+ char mmp_bdevname[32];
+ __u16 mmp_interval;
__u16 mmp_pad1;
- __u32 mmp_pad2[227];
+ __u32 mmp_pad2;
};
/*
- * Default interval for MMP update in seconds.
- */
-#define EXT4_MMP_UPDATE_INTERVAL 5
-
-/*
- * Maximum interval for MMP update in seconds.
- */
-#define EXT4_MMP_MAX_UPDATE_INTERVAL 300
-
-/*
- * Minimum interval for MMP checking in seconds.
+ * Interval in number of seconds to update the MMP sequence number.
*/
-#define EXT4_MMP_MIN_CHECK_INTERVAL 5
+#define EXT2_MMP_DEF_INTERVAL 5
#endif /* _LINUX_EXT2_FS_H */
diff --git a/lib/ext2fs/ext2_io.h b/lib/ext2fs/ext2_io.h
index 1894fb8c..b917559c 100644
--- a/lib/ext2fs/ext2_io.h
+++ b/lib/ext2fs/ext2_io.h
@@ -29,10 +29,6 @@ typedef struct struct_io_channel *io_channel;
typedef struct struct_io_stats *io_stats;
#define CHANNEL_FLAGS_WRITETHROUGH 0x01
-#define CHANNEL_FLAGS_DISCARD_ZEROES 0x02
-#define CHANNEL_FLAGS_BLOCK_DEVICE 0x04
-
-#define io_channel_discard_zeroes_data(i) (i->flags & CHANNEL_FLAGS_DISCARD_ZEROES)
struct struct_io_channel {
errcode_t magic;
@@ -58,7 +54,6 @@ struct struct_io_channel {
long reserved[14];
void *private_data;
void *app_data;
- int align;
};
struct struct_io_stats {
@@ -88,8 +83,6 @@ struct struct_io_manager {
int count, void *data);
errcode_t (*write_blk64)(io_channel channel, unsigned long long block,
int count, const void *data);
- errcode_t (*discard)(io_channel channel, unsigned long long block,
- unsigned long long count);
long reserved[16];
};
@@ -119,11 +112,6 @@ extern errcode_t io_channel_read_blk64(io_channel channel,
extern errcode_t io_channel_write_blk64(io_channel channel,
unsigned long long block,
int count, const void *data);
-extern errcode_t io_channel_discard(io_channel channel,
- unsigned long long block,
- unsigned long long count);
-extern errcode_t io_channel_alloc_buf(io_channel channel,
- int count, void *ptr);
/* unix_io.c */
extern io_manager unix_io_manager;
@@ -139,10 +127,6 @@ extern void (*test_io_cb_read_blk)
(unsigned long block, int count, errcode_t err);
extern void (*test_io_cb_write_blk)
(unsigned long block, int count, errcode_t err);
-extern void (*test_io_cb_read_blk64)
- (unsigned long long block, int count, errcode_t err);
-extern void (*test_io_cb_write_blk64)
- (unsigned long long block, int count, errcode_t err);
extern void (*test_io_cb_set_blksize)
(int blksize, errcode_t err);
diff --git a/lib/ext2fs/ext2_types.h b/lib/ext2fs/ext2_types.h
index 18d4f9bd..27277fa3 100644
--- a/lib/ext2fs/ext2_types.h
+++ b/lib/ext2fs/ext2_types.h
@@ -7,6 +7,14 @@
!defined(_EXT2_TYPES_H))
#define _EXT2_TYPES_H
+#define __S8_TYPEDEF __signed__ char
+#define __U8_TYPEDEF unsigned char
+#define __S16_TYPEDEF __signed__ short
+#define __U16_TYPEDEF unsigned short
+#define __S32_TYPEDEF __signed__ int
+#define __U32_TYPEDEF unsigned int
+#define __S64_TYPEDEF __signed__ long long
+#define __U64_TYPEDEF unsigned long long
#ifdef __U8_TYPEDEF
typedef __U8_TYPEDEF __u8;
@@ -91,11 +99,11 @@ typedef __U64_TYPEDEF __u64;
#if (4 == 8)
typedef unsigned int __u64;
#else
-#if (8 == 8)
-typedef unsigned long long __u64;
-#else
#if (4 == 8)
typedef unsigned long __u64;
+#else
+#if (8 == 8)
+typedef unsigned long long __u64;
#endif /* SIZEOF_LONG_LONG == 8 */
#endif /* SIZEOF_LONG == 8 */
#endif /* SIZEOF_INT == 8 */
@@ -107,15 +115,15 @@ typedef __S64_TYPEDEF __s64;
#if (4 == 8)
typedef int __s64;
#else
+#if (4 == 8)
+typedef long __s64;
+#else
#if (8 == 8)
#if defined(__GNUC__)
-typedef __signed__ long long __s64;
+typedef __signed__ long long __s64;
#else
-typedef signed long long __s64;
+typedef signed long long __s64;
#endif /* __GNUC__ */
-#else
-#if (4 == 8)
-typedef long __s64;
#endif /* SIZEOF_LONG_LONG == 8 */
#endif /* SIZEOF_LONG == 8 */
#endif /* SIZEOF_INT == 8 */
diff --git a/lib/ext2fs/ext2_types.h.in b/lib/ext2fs/ext2_types.h.in
index 5b98f715..aa7ca3a9 100644
--- a/lib/ext2fs/ext2_types.h.in
+++ b/lib/ext2fs/ext2_types.h.in
@@ -92,11 +92,11 @@ typedef __U64_TYPEDEF __u64;
#if (@SIZEOF_INT@ == 8)
typedef unsigned int __u64;
#else
-#if (@SIZEOF_LONG_LONG@ == 8)
-typedef unsigned long long __u64;
-#else
#if (@SIZEOF_LONG@ == 8)
typedef unsigned long __u64;
+#else
+#if (@SIZEOF_LONG_LONG@ == 8)
+typedef unsigned long long __u64;
#endif /* SIZEOF_LONG_LONG == 8 */
#endif /* SIZEOF_LONG == 8 */
#endif /* SIZEOF_INT == 8 */
@@ -108,15 +108,15 @@ typedef __S64_TYPEDEF __s64;
#if (@SIZEOF_INT@ == 8)
typedef int __s64;
#else
+#if (@SIZEOF_LONG@ == 8)
+typedef long __s64;
+#else
#if (@SIZEOF_LONG_LONG@ == 8)
#if defined(__GNUC__)
-typedef __signed__ long long __s64;
+typedef __signed__ long long __s64;
#else
-typedef signed long long __s64;
+typedef signed long long __s64;
#endif /* __GNUC__ */
-#else
-#if (@SIZEOF_LONG@ == 8)
-typedef long __s64;
#endif /* SIZEOF_LONG_LONG == 8 */
#endif /* SIZEOF_LONG == 8 */
#endif /* SIZEOF_INT == 8 */
diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
index fb6b0b43..3573e854 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h
@@ -30,6 +30,14 @@ extern "C" {
#endif
/*
+ * The Apple compiler in Xcode 4.3 fails when inlines are enabled in
+ * so disable them for that compiler.
+ */
+#if __APPLE_CC__ >= 5621
+#define NO_INLINE_FUNCS
+#endif
+
+/*
* Where the master copy of the superblock is located, and how big
* superblocks are supposed to be. We define SUPERBLOCK_SIZE because
* the size of the superblock structure is not necessarily trustworthy
@@ -37,7 +45,7 @@ extern "C" {
* 1032 bytes long).
*/
#define SUPERBLOCK_OFFSET 1024
-#define SUPERBLOCK_SIZE 1024
+#define SUPERBLOCK_SIZE 1024
/*
* The last ext2fs revision level that this version of the library is
@@ -64,20 +72,13 @@ extern "C" {
#include <ext2fs/ext3_extents.h>
#endif /* EXT2_FLAT_INCLUDES */
-#ifdef __CHECK_ENDIAN__
-#define __bitwise __attribute__((bitwise))
-#else
-#define __bitwise
-#endif
-
-typedef __u32 __bitwise ext2_ino_t;
-typedef __u32 __bitwise blk_t;
-typedef __u64 __bitwise blk64_t;
-typedef __u32 __bitwise dgrp_t;
-typedef __u32 __bitwise ext2_off_t;
-typedef __u64 __bitwise ext2_off64_t;
-typedef __s64 __bitwise e2_blkcnt_t;
-typedef __u32 __bitwise ext2_dirhash_t;
+typedef __u32 ext2_ino_t;
+typedef __u32 blk_t;
+typedef __u64 blk64_t;
+typedef __u32 dgrp_t;
+typedef __u32 ext2_off_t;
+typedef __s64 e2_blkcnt_t;
+typedef __u32 ext2_dirhash_t;
#if EXT2_FLAT_INCLUDES
#include "com_err.h"
@@ -132,13 +133,6 @@ typedef struct ext2_struct_u32_iterate *badblocks_iterate;
/*
* ext2_dblist structure and abstractions (see dblist.c)
*/
-struct ext2_db_entry2 {
- ext2_ino_t ino;
- blk64_t blk;
- e2_blkcnt_t blockcnt;
-};
-
-/* Ye Olde 32-bit version */
struct ext2_db_entry {
ext2_ino_t ino;
blk_t blk;
@@ -187,10 +181,7 @@ typedef struct ext2_file *ext2_file_t;
#define EXT2_FLAG_EXCLUSIVE 0x4000
#define EXT2_FLAG_SOFTSUPP_FEATURES 0x8000
#define EXT2_FLAG_NOFREE_ON_ERROR 0x10000
-#define EXT2_FLAG_64BITS 0x20000
-#define EXT2_FLAG_PRINT_PROGRESS 0x40000
#define EXT2_FLAG_DIRECT_IO 0x80000
-#define EXT2_FLAG_SKIP_MMP 0x100000
/*
* Special flag in the ext2 inode i_flag field that means that this is
@@ -200,12 +191,10 @@ typedef struct ext2_file *ext2_file_t;
/*
* Flags for mkjournal
+ *
+ * EXT2_MKJOURNAL_V1_SUPER Make a (deprecated) V1 journal superblock
*/
-#define EXT2_MKJOURNAL_V1_SUPER 0x0000001 /* create V1 superblock (deprecated) */
-#define EXT2_MKJOURNAL_LAZYINIT 0x0000002 /* don't zero journal inode before use*/
-#define EXT2_MKJOURNAL_NO_MNT_CHECK 0x0000004 /* don't check mount status */
-
-struct opaque_ext2_group_desc;
+#define EXT2_MKJOURNAL_V1_SUPER 0x0000001
struct struct_ext2_filsys {
errcode_t magic;
@@ -217,11 +206,10 @@ struct struct_ext2_filsys {
int fragsize;
dgrp_t group_desc_count;
unsigned long desc_blocks;
- struct opaque_ext2_group_desc * group_desc;
- unsigned int inode_blocks_per_group;
+ struct ext2_group_desc * group_desc;
+ int inode_blocks_per_group;
ext2fs_inode_bitmap inode_map;
ext2fs_block_bitmap block_map;
- /* XXX FIXME-64: not 64-bit safe, but not used? */
errcode_t (*get_blocks)(ext2_filsys fs, ext2_ino_t ino, blk_t *blocks);
errcode_t (*check_directory)(ext2_filsys fs, ext2_ino_t ino);
errcode_t (*write_bitmaps)(ext2_filsys fs);
@@ -236,13 +224,10 @@ struct struct_ext2_filsys {
struct ext2_image_hdr * image_header;
__u32 umask;
time_t now;
- int cluster_ratio_bits;
- __u16 default_bitmap_type;
- __u16 pad;
/*
* Reserved for future expansion
*/
- __u32 reserved[5];
+ __u32 reserved[7];
/*
* Reserved for the use of the calling application.
@@ -261,18 +246,6 @@ struct struct_ext2_filsys {
errcode_t (*get_alloc_block)(ext2_filsys fs, blk64_t goal,
blk64_t *ret);
void (*block_alloc_stats)(ext2_filsys fs, blk64_t blk, int inuse);
-
- /*
- * Buffers for Multiple mount protection(MMP) block.
- */
- void *mmp_buf;
- void *mmp_cmp;
- int mmp_fd;
-
- /*
- * Time at which e2fsck last updated the MMP block.
- */
- long mmp_last_written;
};
#if EXT2_FLAT_INCLUDES
@@ -282,13 +255,6 @@ struct struct_ext2_filsys {
#endif
/*
- * 64-bit bitmap backend types
- */
-#define EXT2FS_BMAP64_BITARRAY 1
-#define EXT2FS_BMAP64_RBTREE 2
-#define EXT2FS_BMAP64_AUTODIR 3
-
-/*
* Return flags for the block iterator functions
*/
#define BLOCK_CHANGED 1
@@ -566,97 +532,44 @@ typedef struct ext2_icount *ext2_icount_t;
EXT2_FEATURE_INCOMPAT_META_BG|\
EXT3_FEATURE_INCOMPAT_RECOVER|\
EXT3_FEATURE_INCOMPAT_EXTENTS|\
- EXT4_FEATURE_INCOMPAT_FLEX_BG|\
- EXT4_FEATURE_INCOMPAT_MMP|\
- EXT4_FEATURE_INCOMPAT_64BIT)
+ EXT4_FEATURE_INCOMPAT_FLEX_BG)
#else
#define EXT2_LIB_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE|\
EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|\
EXT2_FEATURE_INCOMPAT_META_BG|\
EXT3_FEATURE_INCOMPAT_RECOVER|\
EXT3_FEATURE_INCOMPAT_EXTENTS|\
- EXT4_FEATURE_INCOMPAT_FLEX_BG|\
- EXT4_FEATURE_INCOMPAT_MMP|\
- EXT4_FEATURE_INCOMPAT_64BIT)
+ EXT4_FEATURE_INCOMPAT_FLEX_BG)
#endif
-#ifdef CONFIG_QUOTA
#define EXT2_LIB_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|\
EXT4_FEATURE_RO_COMPAT_HUGE_FILE|\
EXT2_FEATURE_RO_COMPAT_LARGE_FILE|\
EXT4_FEATURE_RO_COMPAT_DIR_NLINK|\
EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE|\
- EXT4_FEATURE_RO_COMPAT_GDT_CSUM|\
- EXT4_FEATURE_RO_COMPAT_BIGALLOC|\
- EXT4_FEATURE_RO_COMPAT_QUOTA)
-#else
-#define EXT2_LIB_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|\
- EXT4_FEATURE_RO_COMPAT_HUGE_FILE|\
- EXT2_FEATURE_RO_COMPAT_LARGE_FILE|\
- EXT4_FEATURE_RO_COMPAT_DIR_NLINK|\
- EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE|\
- EXT4_FEATURE_RO_COMPAT_GDT_CSUM|\
- EXT4_FEATURE_RO_COMPAT_BIGALLOC)
-#endif
+ EXT4_FEATURE_RO_COMPAT_GDT_CSUM)
/*
* These features are only allowed if EXT2_FLAG_SOFTSUPP_FEATURES is passed
* to ext2fs_openfs()
*/
#define EXT2_LIB_SOFTSUPP_INCOMPAT (0)
-#define EXT2_LIB_SOFTSUPP_RO_COMPAT (EXT4_FEATURE_RO_COMPAT_REPLICA)
-
-
-/* Translate a block number to a cluster number */
-#define EXT2FS_CLUSTER_RATIO(fs) (1 << (fs)->cluster_ratio_bits)
-#define EXT2FS_CLUSTER_MASK(fs) (EXT2FS_CLUSTER_RATIO(fs) - 1)
-#define EXT2FS_B2C(fs, blk) ((blk) >> (fs)->cluster_ratio_bits)
-/* Translate a cluster number to a block number */
-#define EXT2FS_C2B(fs, cluster) ((cluster) << (fs)->cluster_ratio_bits)
-/* Translate # of blks to # of clusters */
-#define EXT2FS_NUM_B2C(fs, blks) (((blks) + EXT2FS_CLUSTER_MASK(fs)) >> \
- (fs)->cluster_ratio_bits)
-
-#if defined(HAVE_FSTAT64) && !defined(__OSX_AVAILABLE_BUT_DEPRECATED)
-typedef struct stat64 ext2fs_struct_stat;
-#else
-typedef struct stat ext2fs_struct_stat;
-#endif
-
-/*
- * For ext2fs_close2() and ext2fs_flush2(), this flag allows you to
- * avoid the fsync call.
- */
-#define EXT2_FLAG_FLUSH_NO_SYNC 1
+#define EXT2_LIB_SOFTSUPP_RO_COMPAT (0)
/*
* function prototypes
*/
-/* The LARGE_FILE feature should be set if we have stored files 2GB+ in size */
-static inline int ext2fs_needs_large_file_feature(unsigned long long file_size)
-{
- return file_size >= 0x80000000ULL;
-}
-
/* alloc.c */
extern errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir, int mode,
ext2fs_inode_bitmap map, ext2_ino_t *ret);
extern errcode_t ext2fs_new_block(ext2_filsys fs, blk_t goal,
ext2fs_block_bitmap map, blk_t *ret);
-extern errcode_t ext2fs_new_block2(ext2_filsys fs, blk64_t goal,
- ext2fs_block_bitmap map, blk64_t *ret);
extern errcode_t ext2fs_get_free_blocks(ext2_filsys fs, blk_t start,
blk_t finish, int num,
ext2fs_block_bitmap map,
blk_t *ret);
-extern errcode_t ext2fs_get_free_blocks2(ext2_filsys fs, blk64_t start,
- blk64_t finish, int num,
- ext2fs_block_bitmap map,
- blk64_t *ret);
extern errcode_t ext2fs_alloc_block(ext2_filsys fs, blk_t goal,
char *block_buf, blk_t *ret);
-extern errcode_t ext2fs_alloc_block2(ext2_filsys fs, blk64_t goal,
- char *block_buf, blk64_t *ret);
extern void ext2fs_set_alloc_block_callback(ext2_filsys fs,
errcode_t (*func)(ext2_filsys fs,
blk64_t goal,
@@ -682,7 +595,6 @@ void ext2fs_inode_alloc_stats(ext2_filsys fs, ext2_ino_t ino, int inuse);
void ext2fs_inode_alloc_stats2(ext2_filsys fs, ext2_ino_t ino,
int inuse, int isdir);
void ext2fs_block_alloc_stats(ext2_filsys fs, blk_t blk, int inuse);
-void ext2fs_block_alloc_stats2(ext2_filsys fs, blk64_t blk, int inuse);
/* alloc_tables.c */
extern errcode_t ext2fs_allocate_tables(ext2_filsys fs);
@@ -747,10 +659,6 @@ extern errcode_t ext2fs_read_block_bitmap(ext2_filsys fs);
extern errcode_t ext2fs_allocate_block_bitmap(ext2_filsys fs,
const char *descr,
ext2fs_block_bitmap *ret);
-extern errcode_t ext2fs_allocate_subcluster_bitmap(ext2_filsys fs,
- const char *descr,
- ext2fs_block_bitmap *ret);
-extern int ext2fs_get_bitmap_granularity(ext2fs_block_bitmap bitmap);
extern errcode_t ext2fs_allocate_inode_bitmap(ext2_filsys fs,
const char *descr,
ext2fs_inode_bitmap *ret);
@@ -758,22 +666,14 @@ extern errcode_t ext2fs_fudge_inode_bitmap_end(ext2fs_inode_bitmap bitmap,
ext2_ino_t end, ext2_ino_t *oend);
extern errcode_t ext2fs_fudge_block_bitmap_end(ext2fs_block_bitmap bitmap,
blk_t end, blk_t *oend);
-extern errcode_t ext2fs_fudge_block_bitmap_end2(ext2fs_block_bitmap bitmap,
- blk64_t end, blk64_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);
extern errcode_t ext2fs_resize_inode_bitmap(__u32 new_end, __u32 new_real_end,
ext2fs_inode_bitmap bmap);
-extern errcode_t ext2fs_resize_inode_bitmap2(__u64 new_end,
- __u64 new_real_end,
- ext2fs_inode_bitmap bmap);
extern errcode_t ext2fs_resize_block_bitmap(__u32 new_end, __u32 new_real_end,
ext2fs_block_bitmap bmap);
-extern errcode_t ext2fs_resize_block_bitmap2(__u64 new_end,
- __u64 new_real_end,
- ext2fs_block_bitmap bmap);
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,
@@ -781,88 +681,16 @@ extern errcode_t ext2fs_compare_inode_bitmap(ext2fs_inode_bitmap bm1,
extern errcode_t ext2fs_set_inode_bitmap_range(ext2fs_inode_bitmap bmap,
ext2_ino_t start, unsigned int num,
void *in);
-extern errcode_t ext2fs_set_inode_bitmap_range2(ext2fs_inode_bitmap bmap,
- __u64 start, size_t num,
- void *in);
extern errcode_t ext2fs_get_inode_bitmap_range(ext2fs_inode_bitmap bmap,
ext2_ino_t start, unsigned int num,
void *out);
-extern errcode_t ext2fs_get_inode_bitmap_range2(ext2fs_inode_bitmap bmap,
- __u64 start, size_t num,
- void *out);
extern errcode_t ext2fs_set_block_bitmap_range(ext2fs_block_bitmap bmap,
blk_t start, unsigned int num,
void *in);
-extern errcode_t ext2fs_set_block_bitmap_range2(ext2fs_block_bitmap bmap,
- blk64_t start, size_t num,
- void *in);
extern errcode_t ext2fs_get_block_bitmap_range(ext2fs_block_bitmap bmap,
blk_t start, unsigned int num,
void *out);
-extern errcode_t ext2fs_get_block_bitmap_range2(ext2fs_block_bitmap bmap,
- blk64_t start, size_t num,
- void *out);
-
-/* blknum.c */
-extern dgrp_t ext2fs_group_of_blk2(ext2_filsys fs, blk64_t);
-extern blk64_t ext2fs_group_first_block2(ext2_filsys fs, dgrp_t group);
-extern blk64_t ext2fs_group_last_block2(ext2_filsys fs, dgrp_t group);
-extern int ext2fs_group_blocks_count(ext2_filsys fs, dgrp_t group);
-extern blk64_t ext2fs_inode_data_blocks2(ext2_filsys fs,
- struct ext2_inode *inode);
-extern blk64_t ext2fs_inode_i_blocks(ext2_filsys fs,
- struct ext2_inode *inode);
-extern blk64_t ext2fs_blocks_count(struct ext2_super_block *super);
-extern void ext2fs_blocks_count_set(struct ext2_super_block *super,
- blk64_t blk);
-extern void ext2fs_blocks_count_add(struct ext2_super_block *super,
- blk64_t blk);
-extern blk64_t ext2fs_r_blocks_count(struct ext2_super_block *super);
-extern void ext2fs_r_blocks_count_set(struct ext2_super_block *super,
- blk64_t blk);
-extern void ext2fs_r_blocks_count_add(struct ext2_super_block *super,
- blk64_t blk);
-extern blk64_t ext2fs_free_blocks_count(struct ext2_super_block *super);
-extern void ext2fs_free_blocks_count_set(struct ext2_super_block *super,
- blk64_t blk);
-extern void ext2fs_free_blocks_count_add(struct ext2_super_block *super,
- blk64_t blk);
-/* Block group descriptor accessor functions */
-extern struct ext2_group_desc *ext2fs_group_desc(ext2_filsys fs,
- struct opaque_ext2_group_desc *gdp,
- dgrp_t group);
-extern blk64_t ext2fs_block_bitmap_loc(ext2_filsys fs, dgrp_t group);
-extern void ext2fs_block_bitmap_loc_set(ext2_filsys fs, dgrp_t group,
- blk64_t blk);
-extern blk64_t ext2fs_inode_bitmap_loc(ext2_filsys fs, dgrp_t group);
-extern void ext2fs_inode_bitmap_loc_set(ext2_filsys fs, dgrp_t group,
- blk64_t blk);
-extern blk64_t ext2fs_inode_table_loc(ext2_filsys fs, dgrp_t group);
-extern void ext2fs_inode_table_loc_set(ext2_filsys fs, dgrp_t group,
- blk64_t blk);
-extern __u32 ext2fs_bg_free_blocks_count(ext2_filsys fs, dgrp_t group);
-extern void ext2fs_bg_free_blocks_count_set(ext2_filsys fs, dgrp_t group,
- __u32 n);
-extern __u32 ext2fs_bg_free_inodes_count(ext2_filsys fs, dgrp_t group);
-extern void ext2fs_bg_free_inodes_count_set(ext2_filsys fs, dgrp_t group,
- __u32 n);
-extern __u32 ext2fs_bg_used_dirs_count(ext2_filsys fs, dgrp_t group);
-extern void ext2fs_bg_used_dirs_count_set(ext2_filsys fs, dgrp_t group,
- __u32 n);
-extern __u32 ext2fs_bg_itable_unused(ext2_filsys fs, dgrp_t group);
-extern void ext2fs_bg_itable_unused_set(ext2_filsys fs, dgrp_t group,
- __u32 n);
-extern __u16 ext2fs_bg_flags(ext2_filsys fs, dgrp_t group);
-extern void ext2fs_bg_flags_zap(ext2_filsys fs, dgrp_t group);
-extern int ext2fs_bg_flags_test(ext2_filsys fs, dgrp_t group, __u16 bg_flag);
-extern void ext2fs_bg_flags_set(ext2_filsys fs, dgrp_t group, __u16 bg_flags);
-extern void ext2fs_bg_flags_clear(ext2_filsys fs, dgrp_t group, __u16 bg_flags);
-extern __u16 ext2fs_bg_checksum(ext2_filsys fs, dgrp_t group);
-extern void ext2fs_bg_checksum_set(ext2_filsys fs, dgrp_t group, __u16 checksum);
-extern blk64_t ext2fs_file_acl_block(ext2_filsys fs,
- const struct ext2_inode *inode);
-extern void ext2fs_file_acl_block_set(ext2_filsys fs,
- struct ext2_inode *inode, blk64_t blk);
+
/* block.c */
extern errcode_t ext2fs_block_iterate(ext2_filsys fs,
@@ -885,17 +713,6 @@ errcode_t ext2fs_block_iterate2(ext2_filsys fs,
int ref_offset,
void *priv_data),
void *priv_data);
-errcode_t ext2fs_block_iterate3(ext2_filsys fs,
- ext2_ino_t ino,
- int flags,
- char *block_buf,
- int (*func)(ext2_filsys fs,
- blk64_t *blocknr,
- e2_blkcnt_t blockcnt,
- blk64_t ref_blk,
- int ref_offset,
- void *priv_data),
- void *priv_data);
/* bmap.c */
extern errcode_t ext2fs_bmap(ext2_filsys fs, ext2_ino_t ino,
@@ -906,9 +723,6 @@ extern errcode_t ext2fs_bmap2(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode *inode,
char *block_buf, int bmap_flags, blk64_t block,
int *ret_flags, blk64_t *phys_blk);
-errcode_t ext2fs_map_cluster_block(ext2_filsys fs, ext2_ino_t ino,
- struct ext2_inode *inode, blk64_t lblk,
- blk64_t *pblk);
#if 0
/* bmove.c */
@@ -923,16 +737,8 @@ extern errcode_t ext2fs_check_desc(ext2_filsys fs);
/* closefs.c */
extern errcode_t ext2fs_close(ext2_filsys fs);
-extern errcode_t ext2fs_close2(ext2_filsys fs, int flags);
extern errcode_t ext2fs_flush(ext2_filsys fs);
-extern errcode_t ext2fs_flush2(ext2_filsys fs, int flags);
-extern int ext2fs_bg_has_super(ext2_filsys fs, dgrp_t group_block);
-extern errcode_t ext2fs_super_and_bgd_loc2(ext2_filsys fs,
- dgrp_t group,
- blk64_t *ret_super_blk,
- blk64_t *ret_old_desc_blk,
- blk64_t *ret_new_desc_blk,
- blk_t *ret_used_blks);
+extern int ext2fs_bg_has_super(ext2_filsys fs, int group_block);
extern int ext2fs_super_and_bgd_loc(ext2_filsys fs,
dgrp_t group,
blk_t *ret_super_blk,
@@ -941,15 +747,10 @@ extern int ext2fs_super_and_bgd_loc(ext2_filsys fs,
int *ret_meta_bg);
extern void ext2fs_update_dynamic_rev(ext2_filsys fs);
-/* crc32c.c */
-extern __u32 ext2fs_crc32c_be(__u32 crc, unsigned char const *p, size_t len);
-extern __u32 ext2fs_crc32c_le(__u32 crc, unsigned char const *p, size_t len);
-
/* csum.c */
extern void ext2fs_group_desc_csum_set(ext2_filsys fs, dgrp_t group);
extern int ext2fs_group_desc_csum_verify(ext2_filsys fs, dgrp_t group);
extern errcode_t ext2fs_set_gdt_csum(ext2_filsys fs);
-extern __u16 ext2fs_group_desc_csum(ext2_filsys fs, dgrp_t group);
/* dblist.c */
@@ -957,34 +758,20 @@ extern errcode_t ext2fs_get_num_dirs(ext2_filsys fs, ext2_ino_t *ret_num_dirs);
extern errcode_t ext2fs_init_dblist(ext2_filsys fs, ext2_dblist *ret_dblist);
extern errcode_t ext2fs_add_dir_block(ext2_dblist dblist, ext2_ino_t ino,
blk_t blk, int blockcnt);
-extern errcode_t ext2fs_add_dir_block2(ext2_dblist dblist, ext2_ino_t ino,
- blk64_t blk, e2_blkcnt_t blockcnt);
extern void ext2fs_dblist_sort(ext2_dblist dblist,
EXT2_QSORT_TYPE (*sortfunc)(const void *,
const void *));
-extern void ext2fs_dblist_sort2(ext2_dblist dblist,
- EXT2_QSORT_TYPE (*sortfunc)(const void *,
- const void *));
extern errcode_t ext2fs_dblist_iterate(ext2_dblist dblist,
int (*func)(ext2_filsys fs, struct ext2_db_entry *db_info,
void *priv_data),
void *priv_data);
-extern errcode_t ext2fs_dblist_iterate2(ext2_dblist dblist,
- int (*func)(ext2_filsys fs, struct ext2_db_entry2 *db_info,
- void *priv_data),
- void *priv_data);
extern errcode_t ext2fs_set_dir_block(ext2_dblist dblist, ext2_ino_t ino,
blk_t blk, int blockcnt);
-extern errcode_t ext2fs_set_dir_block2(ext2_dblist dblist, ext2_ino_t ino,
- blk64_t blk, e2_blkcnt_t blockcnt);
extern errcode_t ext2fs_copy_dblist(ext2_dblist src,
ext2_dblist *dest);
extern int ext2fs_dblist_count(ext2_dblist dblist);
-extern blk64_t ext2fs_dblist_count2(ext2_dblist dblist);
extern errcode_t ext2fs_dblist_get_last(ext2_dblist dblist,
struct ext2_db_entry **entry);
-extern errcode_t ext2fs_dblist_get_last2(ext2_dblist dblist,
- struct ext2_db_entry2 **entry);
extern errcode_t ext2fs_dblist_drop_last(ext2_dblist dblist);
/* dblist_dir.c */
@@ -1006,14 +793,10 @@ extern errcode_t ext2fs_read_dir_block(ext2_filsys fs, blk_t block,
void *buf);
extern errcode_t ext2fs_read_dir_block2(ext2_filsys fs, blk_t block,
void *buf, int flags);
-extern errcode_t ext2fs_read_dir_block3(ext2_filsys fs, blk64_t block,
- void *buf, int flags);
extern errcode_t ext2fs_write_dir_block(ext2_filsys fs, blk_t block,
void *buf);
extern errcode_t ext2fs_write_dir_block2(ext2_filsys fs, blk_t block,
void *buf, int flags);
-extern errcode_t ext2fs_write_dir_block3(ext2_filsys fs, blk64_t block,
- void *buf, int flags);
/* dirhash.c */
extern errcode_t ext2fs_dirhash(int version, const char *name, int len,
@@ -1062,18 +845,11 @@ extern errcode_t ext2fs_expand_dir(ext2_filsys fs, ext2_ino_t dir);
extern __u32 ext2fs_ext_attr_hash_entry(struct ext2_ext_attr_entry *entry,
void *data);
extern errcode_t ext2fs_read_ext_attr(ext2_filsys fs, blk_t block, void *buf);
-extern errcode_t ext2fs_read_ext_attr2(ext2_filsys fs, blk64_t block,
- void *buf);
extern errcode_t ext2fs_write_ext_attr(ext2_filsys fs, blk_t block,
void *buf);
-extern errcode_t ext2fs_write_ext_attr2(ext2_filsys fs, blk64_t block,
- void *buf);
extern errcode_t ext2fs_adjust_ea_refcount(ext2_filsys fs, blk_t blk,
char *block_buf,
int adjust, __u32 *newcount);
-extern errcode_t ext2fs_adjust_ea_refcount2(ext2_filsys fs, blk64_t blk,
- char *block_buf,
- int adjust, __u32 *newcount);
/* extent.c */
extern errcode_t ext2fs_extent_header_verify(void *ptr, int size);
@@ -1085,7 +861,6 @@ extern errcode_t ext2fs_extent_open2(ext2_filsys fs, ext2_ino_t ino,
extern void ext2fs_extent_free(ext2_extent_handle_t handle);
extern errcode_t ext2fs_extent_get(ext2_extent_handle_t handle,
int flags, struct ext2fs_extent *extent);
-extern errcode_t ext2fs_extent_node_split(ext2_extent_handle_t handle);
extern errcode_t ext2fs_extent_replace(ext2_extent_handle_t handle, int flags,
struct ext2fs_extent *extent);
extern errcode_t ext2fs_extent_insert(ext2_extent_handle_t handle, int flags,
@@ -1098,9 +873,6 @@ extern errcode_t ext2fs_extent_get_info(ext2_extent_handle_t handle,
struct ext2_extent_info *info);
extern errcode_t ext2fs_extent_goto(ext2_extent_handle_t handle,
blk64_t blk);
-extern errcode_t ext2fs_extent_goto2(ext2_extent_handle_t handle,
- int leaf_level, blk64_t blk);
-extern errcode_t ext2fs_extent_fix_parents(ext2_extent_handle_t handle);
/* fileio.c */
extern errcode_t ext2fs_file_open2(ext2_filsys fs, ext2_ino_t ino,
@@ -1109,8 +881,6 @@ extern errcode_t ext2fs_file_open2(ext2_filsys fs, ext2_ino_t ino,
extern errcode_t ext2fs_file_open(ext2_filsys fs, ext2_ino_t ino,
int flags, ext2_file_t *ret);
extern ext2_filsys ext2fs_file_get_fs(ext2_file_t file);
-struct ext2_inode *ext2fs_file_get_inode(ext2_file_t file);
-extern ext2_ino_t ext2fs_file_get_inode_num(ext2_file_t file);
extern errcode_t ext2fs_file_close(ext2_file_t file);
extern errcode_t ext2fs_file_flush(ext2_file_t file);
extern errcode_t ext2fs_file_read(ext2_file_t file, void *buf,
@@ -1124,7 +894,6 @@ extern errcode_t ext2fs_file_lseek(ext2_file_t file, ext2_off_t offset,
errcode_t ext2fs_file_get_lsize(ext2_file_t file, __u64 *ret_size);
extern ext2_off_t ext2fs_file_get_size(ext2_file_t file);
extern errcode_t ext2fs_file_set_size(ext2_file_t file, ext2_off_t size);
-extern errcode_t ext2fs_file_set_size2(ext2_file_t file, ext2_off64_t size);
/* finddev.c */
extern char *ext2fs_find_block_device(dev_t device);
@@ -1174,42 +943,6 @@ extern errcode_t ext2fs_set_generic_bitmap_range(ext2fs_generic_bitmap bmap,
errcode_t magic,
__u32 start, __u32 num,
void *in);
-extern errcode_t ext2fs_find_first_zero_generic_bitmap(ext2fs_generic_bitmap bitmap,
- __u32 start, __u32 end,
- __u32 *out);
-
-/* gen_bitmap64.c */
-
-/* Generate and print bitmap usage statistics */
-#define BMAP_STATS
-
-void ext2fs_free_generic_bmap(ext2fs_generic_bitmap bmap);
-errcode_t ext2fs_alloc_generic_bmap(ext2_filsys fs, errcode_t magic,
- int type, __u64 start, __u64 end,
- __u64 real_end,
- const char *descr,
- ext2fs_generic_bitmap *ret);
-errcode_t ext2fs_copy_generic_bmap(ext2fs_generic_bitmap src,
- ext2fs_generic_bitmap *dest);
-void ext2fs_clear_generic_bmap(ext2fs_generic_bitmap bitmap);
-errcode_t ext2fs_fudge_generic_bmap_end(ext2fs_generic_bitmap bitmap,
- errcode_t neq,
- __u64 end, __u64 *oend);
-void ext2fs_set_generic_bmap_padding(ext2fs_generic_bitmap bmap);
-errcode_t ext2fs_resize_generic_bmap(ext2fs_generic_bitmap bmap,
- __u64 new_end,
- __u64 new_real_end);
-errcode_t ext2fs_compare_generic_bmap(errcode_t neq,
- ext2fs_generic_bitmap bm1,
- ext2fs_generic_bitmap bm2);
-errcode_t ext2fs_get_generic_bmap_range(ext2fs_generic_bitmap bmap,
- __u64 start, unsigned int num,
- void *out);
-errcode_t ext2fs_set_generic_bmap_range(ext2fs_generic_bitmap bmap,
- __u64 start, unsigned int num,
- void *in);
-errcode_t ext2fs_convert_subcluster_bitmap(ext2_filsys fs,
- ext2fs_block_bitmap *bitmap);
/* getsize.c */
extern errcode_t ext2fs_get_device_size(const char *file, int blocksize,
@@ -1218,7 +951,6 @@ extern errcode_t ext2fs_get_device_size2(const char *file, int blocksize,
blk64_t *retblocks);
/* getsectsize.c */
-extern int ext2fs_get_dio_alignment(int fd);
errcode_t ext2fs_get_device_sectsize(const char *file, int *sectsize);
errcode_t ext2fs_get_device_phys_sectsize(const char *file, int *sectsize);
@@ -1267,11 +999,6 @@ extern errcode_t ext2fs_icount_store(ext2_icount_t icount, ext2_ino_t ino,
extern ext2_ino_t ext2fs_get_icount_size(ext2_icount_t icount);
errcode_t ext2fs_icount_validate(ext2_icount_t icount, FILE *);
-/* inline.c */
-
-extern errcode_t ext2fs_get_memalign(unsigned long size,
- unsigned long align, void *ptr);
-
/* inode.c */
extern errcode_t ext2fs_flush_icache(ext2_filsys fs);
extern errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan,
@@ -1322,16 +1049,6 @@ extern errcode_t ext2fs_check_if_mounted(const char *file, int *mount_flags);
extern errcode_t ext2fs_check_mount_point(const char *device, int *mount_flags,
char *mtpt, int mtlen);
-/* punch.c */
-/*
- * NOTE: This function removes from an inode the blocks "start", "end", and
- * every block in between.
- */
-extern errcode_t ext2fs_punch(ext2_filsys fs, ext2_ino_t ino,
- struct ext2_inode *inode,
- char *block_buf, blk64_t start,
- blk64_t end);
-
/* namei.c */
extern errcode_t ext2fs_lookup(ext2_filsys fs, ext2_ino_t dir, const char *name,
int namelen, char *buf, ext2_ino_t *inode);
@@ -1356,16 +1073,14 @@ extern errcode_t ext2fs_mkdir(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t inum
/* mkjournal.c */
extern errcode_t ext2fs_zero_blocks(ext2_filsys fs, blk_t blk, int num,
blk_t *ret_blk, int *ret_count);
-extern errcode_t ext2fs_zero_blocks2(ext2_filsys fs, blk64_t blk, int num,
- blk64_t *ret_blk, int *ret_count);
extern errcode_t ext2fs_create_journal_superblock(ext2_filsys fs,
- __u32 num_blocks, int flags,
+ __u32 size, int flags,
char **ret_jsb);
extern errcode_t ext2fs_add_journal_device(ext2_filsys fs,
ext2_filsys journal_dev);
-extern errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t num_blocks,
+extern errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t size,
int flags);
-extern int ext2fs_default_journal_size(__u64 num_blocks);
+extern int ext2fs_default_journal_size(__u64 blocks);
/* openfs.c */
extern errcode_t ext2fs_open(const char *name, int flags, int superblock,
@@ -1375,8 +1090,6 @@ extern errcode_t ext2fs_open2(const char *name, const char *io_options,
int flags, int superblock,
unsigned int block_size, io_manager manager,
ext2_filsys *ret_fs);
-extern blk64_t ext2fs_descriptor_block_loc2(ext2_filsys fs,
- blk64_t group_block, dgrp_t i);
extern blk_t ext2fs_descriptor_block_loc(ext2_filsys fs, blk_t group_block,
dgrp_t i);
errcode_t ext2fs_get_data_io(ext2_filsys fs, io_channel *old_io);
@@ -1393,20 +1106,6 @@ errcode_t ext2fs_link(ext2_filsys fs, ext2_ino_t dir, const char *name,
errcode_t ext2fs_unlink(ext2_filsys fs, ext2_ino_t dir, const char *name,
ext2_ino_t ino, int flags);
-/* symlink.c */
-errcode_t ext2fs_symlink(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t ino,
- const char *name, char *target);
-
-/* mmp.c */
-errcode_t ext2fs_mmp_read(ext2_filsys fs, blk64_t mmp_blk, void *buf);
-errcode_t ext2fs_mmp_write(ext2_filsys fs, blk64_t mmp_blk, void *buf);
-errcode_t ext2fs_mmp_clear(ext2_filsys fs);
-errcode_t ext2fs_mmp_init(ext2_filsys fs);
-errcode_t ext2fs_mmp_start(ext2_filsys fs);
-errcode_t ext2fs_mmp_update(ext2_filsys fs);
-errcode_t ext2fs_mmp_stop(ext2_filsys fs);
-unsigned ext2fs_mmp_new_seq(void);
-
/* read_bb.c */
extern errcode_t ext2fs_read_bb_inode(ext2_filsys fs,
ext2_badblocks_list *bb_list);
@@ -1436,23 +1135,14 @@ extern void ext2fs_swap_ext_attr_entry(struct ext2_ext_attr_entry *to_entry,
struct ext2_ext_attr_entry *from_entry);
extern void ext2fs_swap_super(struct ext2_super_block * super);
extern void ext2fs_swap_group_desc(struct ext2_group_desc *gdp);
-extern void ext2fs_swap_group_desc2(ext2_filsys, struct ext2_group_desc *gdp);
extern void ext2fs_swap_inode_full(ext2_filsys fs, struct ext2_inode_large *t,
struct ext2_inode_large *f, int hostorder,
int bufsize);
extern void ext2fs_swap_inode(ext2_filsys fs,struct ext2_inode *t,
struct ext2_inode *f, int hostorder);
-extern void ext2fs_swap_mmp(struct mmp_struct *mmp);
-
-/* unix_io.c */
-extern int ext2fs_open_file(const char *pathname, int flags, mode_t mode);
-extern int ext2fs_stat(const char *path, ext2fs_struct_stat *buf);
-extern int ext2fs_fstat(int fd, ext2fs_struct_stat *buf);
/* valid_blk.c */
extern int ext2fs_inode_has_valid_blocks(struct ext2_inode *inode);
-extern int ext2fs_inode_has_valid_blocks2(ext2_filsys fs,
- struct ext2_inode *inode);
/* version.c */
extern int ext2fs_parse_version_string(const char *ver_string);
@@ -1466,13 +1156,9 @@ extern errcode_t ext2fs_write_bb_FILE(ext2_badblocks_list bb_list,
/* inline functions */
-#ifdef NO_INLINE_FUNCS
extern errcode_t ext2fs_get_mem(unsigned long size, void *ptr);
-extern errcode_t ext2fs_get_memzero(unsigned long size, void *ptr);
-extern errcode_t ext2fs_get_array(unsigned long count,
- unsigned long size, void *ptr);
-extern errcode_t ext2fs_get_arrayzero(unsigned long count,
- unsigned long size, void *ptr);
+extern errcode_t ext2fs_get_memalign(unsigned long size,
+ unsigned long align, void *ptr);
extern errcode_t ext2fs_free_mem(void *ptr);
extern errcode_t ext2fs_resize_mem(unsigned long old_size,
unsigned long size, void *ptr);
@@ -1486,15 +1172,13 @@ extern void ext2fs_mark_ib_dirty(ext2_filsys fs);
extern void ext2fs_mark_bb_dirty(ext2_filsys fs);
extern int ext2fs_test_ib_dirty(ext2_filsys fs);
extern int ext2fs_test_bb_dirty(ext2_filsys fs);
-extern dgrp_t ext2fs_group_of_blk(ext2_filsys fs, blk_t blk);
-extern dgrp_t ext2fs_group_of_ino(ext2_filsys fs, ext2_ino_t ino);
+extern int ext2fs_group_of_blk(ext2_filsys fs, blk_t blk);
+extern int ext2fs_group_of_ino(ext2_filsys fs, ext2_ino_t ino);
extern blk_t ext2fs_group_first_block(ext2_filsys fs, dgrp_t group);
extern blk_t ext2fs_group_last_block(ext2_filsys fs, dgrp_t group);
extern blk_t ext2fs_inode_data_blocks(ext2_filsys fs,
struct ext2_inode *inode);
extern unsigned int ext2fs_div_ceil(unsigned int a, unsigned int b);
-extern __u64 ext2fs_div64_ceil(__u64 a, __u64 b);
-#endif
/*
* The actual inlined functions definitions themselves...
@@ -1506,21 +1190,17 @@ extern __u64 ext2fs_div64_ceil(__u64 a, __u64 b);
#ifdef INCLUDE_INLINE_FUNCS
#define _INLINE_ extern
#else
-#if (__STDC_VERSION__ >= 199901L)
-#define _INLINE_ inline
-#else
#ifdef __GNUC__
#define _INLINE_ extern __inline__
#else /* For Watcom C */
#define _INLINE_ extern inline
-#endif /* __GNUC__ */
-#endif /* __STDC_VERSION__ >= 199901L */
+#endif
#endif
#ifndef EXT2_CUSTOM_MEMORY_ROUTINES
#include <string.h>
/*
- * Allocate memory. The 'ptr' arg must point to a pointer.
+ * Allocate memory
*/
_INLINE_ errcode_t ext2fs_get_mem(unsigned long size, void *ptr)
{
@@ -1533,41 +1213,42 @@ _INLINE_ errcode_t ext2fs_get_mem(unsigned long size, void *ptr)
return 0;
}
-_INLINE_ errcode_t ext2fs_get_memzero(unsigned long size, void *ptr)
+_INLINE_ errcode_t ext2fs_get_memalign(unsigned long size,
+ unsigned long align, void *ptr)
{
- void *pp;
+ errcode_t retval;
- pp = malloc(size);
- if (!pp)
+ if (align == 0)
+ align = 8;
+
+#if defined(__APPLE__) && defined(__MACH__)
+ /* MacOS 10.5, which we build for, doesn't have posix_memalign.
+ * The only option is valloc, but only use it if the requested
+ * alignment is larger than the alignment provided by malloc.
+ * The idea for this fix came from a patch on the macports website.
+ */
+ *(void **) ptr = (align > 16) ? valloc(size) : malloc(size);
+ if (*(void **)ptr == NULL)
return EXT2_ET_NO_MEMORY;
- memset(pp, 0, size);
- memcpy(ptr, &pp, sizeof(pp));
+#else
+ if ((retval = posix_memalign((void **) ptr, align, size))) {
+ if (retval == ENOMEM)
+ return EXT2_ET_NO_MEMORY;
+ return retval;
+ }
+#endif
return 0;
}
_INLINE_ errcode_t ext2fs_get_array(unsigned long count, unsigned long size, void *ptr)
{
if (count && (-1UL)/count<size)
- return EXT2_ET_NO_MEMORY;
+ return EXT2_ET_NO_MEMORY; //maybe define EXT2_ET_OVERFLOW ?
return ext2fs_get_mem(count*size, ptr);
}
-_INLINE_ errcode_t ext2fs_get_arrayzero(unsigned long count,
- unsigned long size, void *ptr)
-{
- void *pp;
-
- if (count && (-1UL)/count<size)
- return EXT2_ET_NO_MEMORY;
- pp = calloc(count, size);
- if (!pp)
- return EXT2_ET_NO_MEMORY;
- memcpy(ptr, &pp, sizeof(pp));
- return 0;
-}
-
/*
- * Free memory. The 'ptr' arg must point to a pointer.
+ * Free memory
*/
_INLINE_ errcode_t ext2fs_free_mem(void *ptr)
{
@@ -1581,7 +1262,7 @@ _INLINE_ errcode_t ext2fs_free_mem(void *ptr)
}
/*
- * Resize memory. The 'ptr' arg must point to a pointer.
+ * Resize memory
*/
_INLINE_ errcode_t ext2fs_resize_mem(unsigned long EXT2FS_ATTR((unused)) old_size,
unsigned long size, void *ptr)
@@ -1682,14 +1363,16 @@ _INLINE_ int ext2fs_test_bb_dirty(ext2_filsys fs)
/*
* Return the group # of a block
*/
-_INLINE_ dgrp_t ext2fs_group_of_blk(ext2_filsys fs, blk_t blk)
+_INLINE_ int ext2fs_group_of_blk(ext2_filsys fs, blk_t blk)
{
- return ext2fs_group_of_blk2(fs, blk);
+ return (blk - fs->super->s_first_data_block) /
+ fs->super->s_blocks_per_group;
}
+
/*
* Return the group # of an inode number
*/
-_INLINE_ dgrp_t ext2fs_group_of_ino(ext2_filsys fs, ext2_ino_t ino)
+_INLINE_ int ext2fs_group_of_ino(ext2_filsys fs, ext2_ino_t ino)
{
return (ino - 1) / fs->super->s_inodes_per_group;
}
@@ -1699,7 +1382,8 @@ _INLINE_ dgrp_t ext2fs_group_of_ino(ext2_filsys fs, ext2_ino_t ino)
*/
_INLINE_ blk_t ext2fs_group_first_block(ext2_filsys fs, dgrp_t group)
{
- return (blk_t) ext2fs_group_first_block2(fs, group);
+ return fs->super->s_first_data_block +
+ (group * fs->super->s_blocks_per_group);
}
/*
@@ -1707,13 +1391,17 @@ _INLINE_ blk_t ext2fs_group_first_block(ext2_filsys fs, dgrp_t group)
*/
_INLINE_ blk_t ext2fs_group_last_block(ext2_filsys fs, dgrp_t group)
{
- return (blk_t) ext2fs_group_last_block2(fs, group);
+ return (group == fs->group_desc_count - 1 ?
+ fs->super->s_blocks_count - 1 :
+ ext2fs_group_first_block(fs, group) +
+ (fs->super->s_blocks_per_group - 1));
}
_INLINE_ blk_t ext2fs_inode_data_blocks(ext2_filsys fs,
struct ext2_inode *inode)
{
- return (blk_t) ext2fs_inode_data_blocks2(fs, inode);
+ return inode->i_blocks -
+ (inode->i_file_acl ? fs->blocksize >> 9 : 0);
}
/*
@@ -1725,14 +1413,6 @@ _INLINE_ unsigned int ext2fs_div_ceil(unsigned int a, unsigned int b)
return 0;
return ((a - 1) / b) + 1;
}
-
-_INLINE_ __u64 ext2fs_div64_ceil(__u64 a, __u64 b)
-{
- if (!a)
- return 0;
- return ((a - 1) / b) + 1;
-}
-
#undef _INLINE_
#endif
diff --git a/lib/ext2fs/ext2fs.pc.in b/lib/ext2fs/ext2fs.pc.in
index efac85e3..8db86635 100644
--- a/lib/ext2fs/ext2fs.pc.in
+++ b/lib/ext2fs/ext2fs.pc.in
@@ -7,5 +7,5 @@ Name: ext2fs
Description: Ext2fs library
Version: @E2FSPROGS_VERSION@
Requires.private: com_err
-Cflags: -I${includedir}/ext2fs -I${includedir}
+Cflags: -I${includedir}/ext2fs
Libs: -L${libdir} -lext2fs
diff --git a/lib/ext2fs/ext2fsP.h b/lib/ext2fs/ext2fsP.h
index a88db93e..8772a4fc 100644
--- a/lib/ext2fs/ext2fsP.h
+++ b/lib/ext2fs/ext2fsP.h
@@ -11,8 +11,6 @@
#include "ext2fs.h"
-#define EXT2FS_MAX_NESTED_LINKS 8
-
/*
* Badblocks list
*/
@@ -37,10 +35,10 @@ struct ext2_struct_u32_iterate {
struct ext2_struct_dblist {
int magic;
ext2_filsys fs;
- unsigned long long size;
- unsigned long long count;
+ ext2_ino_t size;
+ ext2_ino_t count;
int sorted;
- struct ext2_db_entry2 * list;
+ struct ext2_db_entry * list;
};
/*
@@ -66,7 +64,7 @@ struct dir_context {
*/
struct ext2_inode_cache {
void * buffer;
- blk64_t buffer_blk;
+ blk_t buffer_blk;
int cache_last;
int cache_size;
int refcount;
@@ -81,67 +79,10 @@ struct ext2_inode_cache_ent {
/* Function prototypes */
extern int ext2fs_process_dir_block(ext2_filsys fs,
- blk64_t *blocknr,
+ blk_t *blocknr,
e2_blkcnt_t blockcnt,
- blk64_t ref_block,
+ blk_t ref_block,
int ref_offset,
void *priv_data);
-/* Generic numeric progress meter */
-
-struct ext2fs_numeric_progress_struct {
- __u64 max;
- int log_max;
- int skip_progress;
-};
-
-extern void ext2fs_numeric_progress_init(ext2_filsys fs,
- struct ext2fs_numeric_progress_struct * progress,
- const char *label, __u64 max);
-extern void ext2fs_numeric_progress_update(ext2_filsys fs,
- struct ext2fs_numeric_progress_struct * progress,
- __u64 val);
-extern void ext2fs_numeric_progress_close(ext2_filsys fs,
- struct ext2fs_numeric_progress_struct * progress,
- const char *message);
-
-/*
- * 64-bit bitmap support
- */
-
-extern errcode_t ext2fs_alloc_generic_bmap(ext2_filsys fs, errcode_t magic,
- int type, __u64 start, __u64 end,
- __u64 real_end,
- const char * description,
- ext2fs_generic_bitmap *bmap);
-
-extern void ext2fs_free_generic_bmap(ext2fs_generic_bitmap bmap);
-
-extern errcode_t ext2fs_copy_generic_bmap(ext2fs_generic_bitmap src,
- ext2fs_generic_bitmap *dest);
-
-extern errcode_t ext2fs_resize_generic_bmap(ext2fs_generic_bitmap bmap,
- __u64 new_end,
- __u64 new_real_end);
-extern errcode_t ext2fs_fudge_generic_bmap_end(ext2fs_generic_bitmap bitmap,
- errcode_t neq,
- __u64 end, __u64 *oend);
-extern int ext2fs_mark_generic_bmap(ext2fs_generic_bitmap bitmap,
- __u64 arg);
-extern int ext2fs_unmark_generic_bmap(ext2fs_generic_bitmap bitmap,
- __u64 arg);
-extern int ext2fs_test_generic_bmap(ext2fs_generic_bitmap bitmap,
- __u64 arg);
-extern errcode_t ext2fs_set_generic_bmap_range(ext2fs_generic_bitmap bitmap,
- __u64 start, unsigned int num,
- void *in);
-extern errcode_t ext2fs_get_generic_bmap_range(ext2fs_generic_bitmap bitmap,
- __u64 start, unsigned int num,
- void *out);
-extern void ext2fs_warn_bitmap32(ext2fs_generic_bitmap bitmap,const char *func);
-
-extern int ext2fs_mem_is_zero(const char *mem, size_t len);
-extern int ext2fs_file_block_offset_too_big(ext2_filsys fs,
- struct ext2_inode *inode,
- blk64_t offset);
diff --git a/lib/ext2fs/ext_attr.c b/lib/ext2fs/ext_attr.c
index ddcc89f7..358003ee 100644
--- a/lib/ext2fs/ext_attr.c
+++ b/lib/ext2fs/ext_attr.c
@@ -60,11 +60,11 @@ __u32 ext2fs_ext_attr_hash_entry(struct ext2_ext_attr_entry *entry, void *data)
#undef NAME_HASH_SHIFT
#undef VALUE_HASH_SHIFT
-errcode_t ext2fs_read_ext_attr2(ext2_filsys fs, blk64_t block, void *buf)
+errcode_t ext2fs_read_ext_attr(ext2_filsys fs, blk_t block, void *buf)
{
errcode_t retval;
- retval = io_channel_read_blk64(fs->io, block, 1, buf);
+ retval = io_channel_read_blk(fs->io, block, 1, buf);
if (retval)
return retval;
#ifdef WORDS_BIGENDIAN
@@ -73,18 +73,13 @@ errcode_t ext2fs_read_ext_attr2(ext2_filsys fs, blk64_t block, void *buf)
return 0;
}
-errcode_t ext2fs_read_ext_attr(ext2_filsys fs, blk_t block, void *buf)
-{
- return ext2fs_read_ext_attr2(fs, block, buf);
-}
-
-errcode_t ext2fs_write_ext_attr2(ext2_filsys fs, blk64_t block, void *inbuf)
+errcode_t ext2fs_write_ext_attr(ext2_filsys fs, blk_t block, void *inbuf)
{
errcode_t retval;
char *write_buf;
-#ifdef WORDS_BIGENDIAN
char *buf = NULL;
+#ifdef WORDS_BIGENDIAN
retval = ext2fs_get_mem(fs->blocksize, &buf);
if (retval)
return retval;
@@ -93,24 +88,18 @@ errcode_t ext2fs_write_ext_attr2(ext2_filsys fs, blk64_t block, void *inbuf)
#else
write_buf = (char *) inbuf;
#endif
- retval = io_channel_write_blk64(fs->io, block, 1, write_buf);
-#ifdef WORDS_BIGENDIAN
- ext2fs_free_mem(&buf);
-#endif
+ retval = io_channel_write_blk(fs->io, block, 1, write_buf);
+ if (buf)
+ ext2fs_free_mem(&buf);
if (!retval)
ext2fs_mark_changed(fs);
return retval;
}
-errcode_t ext2fs_write_ext_attr(ext2_filsys fs, blk_t block, void *inbuf)
-{
- return ext2fs_write_ext_attr2(fs, block, inbuf);
-}
-
/*
* This function adjusts the reference count of the EA block.
*/
-errcode_t ext2fs_adjust_ea_refcount2(ext2_filsys fs, blk64_t blk,
+errcode_t ext2fs_adjust_ea_refcount(ext2_filsys fs, blk_t blk,
char *block_buf, int adjust,
__u32 *newcount)
{
@@ -118,7 +107,7 @@ errcode_t ext2fs_adjust_ea_refcount2(ext2_filsys fs, blk64_t blk,
struct ext2_ext_attr_header *header;
char *buf = 0;
- if ((blk >= ext2fs_blocks_count(fs->super)) ||
+ if ((blk >= fs->super->s_blocks_count) ||
(blk < fs->super->s_first_data_block))
return EXT2_ET_BAD_EA_BLOCK_NUM;
@@ -129,7 +118,7 @@ errcode_t ext2fs_adjust_ea_refcount2(ext2_filsys fs, blk64_t blk,
block_buf = buf;
}
- retval = ext2fs_read_ext_attr2(fs, blk, block_buf);
+ retval = ext2fs_read_ext_attr(fs, blk, block_buf);
if (retval)
goto errout;
@@ -138,7 +127,7 @@ errcode_t ext2fs_adjust_ea_refcount2(ext2_filsys fs, blk64_t blk,
if (newcount)
*newcount = header->h_refcount;
- retval = ext2fs_write_ext_attr2(fs, blk, block_buf);
+ retval = ext2fs_write_ext_attr(fs, blk, block_buf);
if (retval)
goto errout;
@@ -147,10 +136,3 @@ errout:
ext2fs_free_mem(&buf);
return retval;
}
-
-errcode_t ext2fs_adjust_ea_refcount(ext2_filsys fs, blk_t blk,
- char *block_buf, int adjust,
- __u32 *newcount)
-{
- return ext2fs_adjust_ea_refcount(fs, blk, block_buf, adjust, newcount);
-}
diff --git a/lib/ext2fs/extent.c b/lib/ext2fs/extent.c
index fc6c95b8..053ff158 100644
--- a/lib/ext2fs/extent.c
+++ b/lib/ext2fs/extent.c
@@ -53,7 +53,6 @@ struct ext2_extent_handle {
ext2_filsys fs;
ext2_ino_t ino;
struct ext2_inode *inode;
- struct ext2_inode inodebuf;
int type;
int level;
int max_depth;
@@ -159,13 +158,15 @@ errcode_t ext2fs_extent_header_verify(void *ptr, int size)
/*
* Begin functions to handle an inode's extent information
*/
-void ext2fs_extent_free(ext2_extent_handle_t handle)
+extern void ext2fs_extent_free(ext2_extent_handle_t handle)
{
int i;
if (!handle)
return;
+ if (handle->inode)
+ ext2fs_free_mem(&handle->inode);
if (handle->path) {
for (i=1; i <= handle->max_depth; i++) {
if (handle->path[i].buf)
@@ -176,13 +177,13 @@ void ext2fs_extent_free(ext2_extent_handle_t handle)
ext2fs_free_mem(&handle);
}
-errcode_t ext2fs_extent_open(ext2_filsys fs, ext2_ino_t ino,
+extern errcode_t ext2fs_extent_open(ext2_filsys fs, ext2_ino_t ino,
ext2_extent_handle_t *ret_handle)
{
return ext2fs_extent_open2(fs, ino, NULL, ret_handle);
}
-errcode_t ext2fs_extent_open2(ext2_filsys fs, ext2_ino_t ino,
+extern errcode_t ext2fs_extent_open2(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode *inode,
ext2_extent_handle_t *ret_handle)
{
@@ -202,13 +203,17 @@ errcode_t ext2fs_extent_open2(ext2_filsys fs, ext2_ino_t ino,
return retval;
memset(handle, 0, sizeof(struct ext2_extent_handle));
+ retval = ext2fs_get_mem(sizeof(struct ext2_inode), &handle->inode);
+ if (retval)
+ goto errout;
+
handle->ino = ino;
handle->fs = fs;
if (inode) {
- handle->inode = inode;
- } else {
- handle->inode = &handle->inodebuf;
+ memcpy(handle->inode, inode, sizeof(struct ext2_inode));
+ }
+ else {
retval = ext2fs_read_inode(fs, ino, handle->inode);
if (retval)
goto errout;
@@ -253,8 +258,9 @@ errcode_t ext2fs_extent_open2(ext2_filsys fs, ext2_ino_t ino,
handle->path[0].max_entries = ext2fs_le16_to_cpu(eh->eh_max);
handle->path[0].curr = 0;
handle->path[0].end_blk =
- (EXT2_I_SIZE(handle->inode) + fs->blocksize - 1) >>
- EXT2_BLOCK_SIZE_BITS(fs->super);
+ ((((__u64) handle->inode->i_size_high << 32) +
+ handle->inode->i_size + (fs->blocksize - 1))
+ >> EXT2_BLOCK_SIZE_BITS(fs->super));
handle->path[0].visit_num = 1;
handle->level = 0;
handle->magic = EXT2_ET_MAGIC_EXTENT_HANDLE;
@@ -279,7 +285,7 @@ errcode_t ext2fs_extent_get(ext2_extent_handle_t handle,
struct ext3_extent_idx *ix = 0;
struct ext3_extent *ex;
errcode_t retval;
- blk64_t blk;
+ blk_t blk;
blk64_t end_blk;
int orig_op, op;
@@ -373,11 +379,9 @@ retry:
case EXT2_EXTENT_ROOT:
handle->level = 0;
path = handle->path + handle->level;
- /* fallthrough */
case EXT2_EXTENT_FIRST_SIB:
path->left = path->entries;
path->curr = 0;
- /* fallthrough */
case EXT2_EXTENT_NEXT_SIB:
if (path->left <= 0)
return EXT2_ET_EXTENT_NO_NEXT;
@@ -439,7 +443,7 @@ retry:
(handle->fs->io != handle->fs->image_io))
memset(newpath->buf, 0, handle->fs->blocksize);
else {
- retval = io_channel_read_blk64(handle->fs->io,
+ retval = io_channel_read_blk(handle->fs->io,
blk, 1, newpath->buf);
if (retval)
return retval;
@@ -549,7 +553,7 @@ static errcode_t update_path(ext2_extent_handle_t handle)
blk = ext2fs_le32_to_cpu(ix->ei_leaf) +
((__u64) ext2fs_le16_to_cpu(ix->ei_leaf_hi) << 32);
- retval = io_channel_write_blk64(handle->fs->io,
+ retval = io_channel_write_blk(handle->fs->io,
blk, 1, handle->path[handle->level].buf);
}
return retval;
@@ -603,8 +607,8 @@ errcode_t ext2fs_extent_free_path(ext2_extent_path_t path)
* If "blk" has no mapping (hole) then handle is left at last
* extent before blk.
*/
-errcode_t ext2fs_extent_goto2(ext2_extent_handle_t handle,
- int leaf_level, blk64_t blk)
+static errcode_t extent_goto(ext2_extent_handle_t handle,
+ int leaf_level, blk64_t blk)
{
struct ext2fs_extent extent;
errcode_t retval;
@@ -693,7 +697,7 @@ errcode_t ext2fs_extent_goto2(ext2_extent_handle_t handle,
errcode_t ext2fs_extent_goto(ext2_extent_handle_t handle,
blk64_t blk)
{
- return ext2fs_extent_goto2(handle, 0, blk);
+ return extent_goto(handle, 0, blk);
}
/*
@@ -705,14 +709,12 @@ errcode_t ext2fs_extent_goto(ext2_extent_handle_t handle,
* Safe to call for any position in node; if not at the first entry,
* will simply return.
*/
-errcode_t ext2fs_extent_fix_parents(ext2_extent_handle_t handle)
+static errcode_t ext2fs_extent_fix_parents(ext2_extent_handle_t handle)
{
int retval = 0;
- int orig_height;
blk64_t start;
struct extent_path *path;
struct ext2fs_extent extent;
- struct ext2_extent_info info;
EXT2_CHECK_MAGIC(handle, EXT2_ET_MAGIC_EXTENT_HANDLE);
@@ -733,10 +735,6 @@ errcode_t ext2fs_extent_fix_parents(ext2_extent_handle_t handle)
/* modified node's start block */
start = extent.e_lblk;
- if ((retval = ext2fs_extent_get_info(handle, &info)))
- return retval;
- orig_height = info.max_depth - info.curr_level;
-
/* traverse up until index not first, or startblk matches, or top */
while (handle->level > 0 &&
(path->left == path->entries - 1)) {
@@ -755,7 +753,7 @@ errcode_t ext2fs_extent_fix_parents(ext2_extent_handle_t handle)
}
/* put handle back to where we started */
- retval = ext2fs_extent_goto2(handle, orig_height, start);
+ retval = ext2fs_extent_goto(handle, start);
done:
return retval;
}
@@ -818,10 +816,10 @@ errcode_t ext2fs_extent_replace(ext2_extent_handle_t handle,
*
* handle will be left pointing at original record.
*/
-errcode_t ext2fs_extent_node_split(ext2_extent_handle_t handle)
+static errcode_t extent_node_split(ext2_extent_handle_t handle)
{
errcode_t retval = 0;
- blk64_t new_node_pblk;
+ blk_t new_node_pblk;
blk64_t new_node_start;
blk64_t orig_lblk;
blk64_t goal_blk = 0;
@@ -873,12 +871,12 @@ errcode_t ext2fs_extent_node_split(ext2_extent_handle_t handle)
goto done;
goal_blk = extent.e_pblk;
- retval = ext2fs_extent_node_split(handle);
+ retval = extent_node_split(handle);
if (retval)
goto done;
/* get handle back to our original split position */
- retval = ext2fs_extent_goto2(handle, orig_height, orig_lblk);
+ retval = extent_goto(handle, orig_height, orig_lblk);
if (retval)
goto done;
}
@@ -933,9 +931,10 @@ errcode_t ext2fs_extent_node_split(ext2_extent_handle_t handle)
if (log_flex)
group = group & ~((1 << (log_flex)) - 1);
- goal_blk = ext2fs_group_first_block2(handle->fs, group);
+ goal_blk = (group * handle->fs->super->s_blocks_per_group) +
+ handle->fs->super->s_first_data_block;
}
- retval = ext2fs_alloc_block2(handle->fs, goal_blk, block_buf,
+ retval = ext2fs_alloc_block(handle->fs, (blk_t) goal_blk, block_buf,
&new_node_pblk);
if (retval)
goto done;
@@ -963,8 +962,7 @@ errcode_t ext2fs_extent_node_split(ext2_extent_handle_t handle)
new_node_start = ext2fs_le32_to_cpu(EXT_FIRST_INDEX(neweh)->ei_block);
/* ...and write the new node block out to disk. */
- retval = io_channel_write_blk64(handle->fs->io, new_node_pblk, 1,
- block_buf);
+ retval = io_channel_write_blk(handle->fs->io, new_node_pblk, 1, block_buf);
if (retval)
goto done;
@@ -1026,13 +1024,12 @@ errcode_t ext2fs_extent_node_split(ext2_extent_handle_t handle)
}
/* get handle back to our original position */
- retval = ext2fs_extent_goto2(handle, orig_height, orig_lblk);
+ retval = extent_goto(handle, orig_height, orig_lblk);
if (retval)
goto done;
/* new node hooked in, so update inode block count (do this here?) */
- handle->inode->i_blocks += (handle->fs->blocksize *
- EXT2FS_CLUSTER_RATIO(handle->fs)) / 512;
+ handle->inode->i_blocks += handle->fs->blocksize / 512;
retval = ext2fs_write_inode(handle->fs, handle->ino,
handle->inode);
if (retval)
@@ -1077,7 +1074,7 @@ errcode_t ext2fs_extent_insert(ext2_extent_handle_t handle, int flags,
printf("node full (level %d) - splitting\n",
handle->level);
#endif
- retval = ext2fs_extent_node_split(handle);
+ retval = extent_node_split(handle);
if (retval)
return retval;
path = handle->path + handle->level;
@@ -1356,9 +1353,6 @@ errcode_t ext2fs_extent_set_bmap(ext2_extent_handle_t handle,
&next_extent);
if (retval)
goto done;
- retval = ext2fs_extent_fix_parents(handle);
- if (retval)
- goto done;
} else
retval = ext2fs_extent_insert(handle,
EXT2_EXTENT_INSERT_AFTER, &newextent);
@@ -1411,9 +1405,6 @@ errcode_t ext2fs_extent_set_bmap(ext2_extent_handle_t handle,
retval = ext2fs_extent_replace(handle, 0, &extent);
if (retval)
goto done;
- retval = ext2fs_extent_fix_parents(handle);
- if (retval)
- goto done;
} else {
__u32 orig_length;
@@ -1451,7 +1442,7 @@ done:
/* get handle back to its position */
if (orig_height > handle->max_depth)
orig_height = handle->max_depth; /* In case we shortened the tree */
- ext2fs_extent_goto2(handle, orig_height, orig_lblk);
+ extent_goto(handle, orig_height, orig_lblk);
return retval;
}
@@ -1512,13 +1503,10 @@ errcode_t ext2fs_extent_delete(ext2_extent_handle_t handle, int flags)
return retval;
retval = ext2fs_extent_delete(handle, flags);
- handle->inode->i_blocks -=
- (handle->fs->blocksize *
- EXT2FS_CLUSTER_RATIO(handle->fs)) / 512;
+ handle->inode->i_blocks -= handle->fs->blocksize / 512;
retval = ext2fs_write_inode(handle->fs, handle->ino,
handle->inode);
- ext2fs_block_alloc_stats2(handle->fs,
- extent.e_pblk, -1);
+ ext2fs_block_alloc_stats(handle->fs, extent.e_pblk, -1);
}
} else {
eh = (struct ext3_extent_header *) path->buf;
@@ -1563,10 +1551,458 @@ errcode_t ext2fs_extent_get_info(ext2_extent_handle_t handle,
}
#ifdef DEBUG
+
+#include "ss/ss.h"
+
+#include "debugfs.h"
+
/*
- * Override debugfs's prompt
+ * Hook in new commands into debugfs
*/
const char *debug_prog_name = "tst_extents";
+extern ss_request_table extent_cmds;
+ss_request_table *extra_cmds = &extent_cmds;
+
+ext2_ino_t current_ino = 0;
+ext2_extent_handle_t current_handle;
+
+int common_extent_args_process(int argc, char *argv[], int min_argc,
+ int max_argc, const char *cmd,
+ const char *usage, int flags)
+{
+ if (common_args_process(argc, argv, min_argc, max_argc, cmd,
+ usage, flags))
+ return 1;
+
+ if (!current_handle) {
+ com_err(cmd, 0, "Extent handle not open");
+ return 1;
+ }
+ return 0;
+}
+
+void do_inode(int argc, char *argv[])
+{
+ ext2_ino_t inode;
+ int i;
+ struct ext3_extent_header *eh;
+ errcode_t retval;
+
+ if (check_fs_open(argv[0]))
+ return;
+
+ if (argc == 1) {
+ if (current_ino)
+ printf("Current inode is %d\n", current_ino);
+ else
+ printf("No current inode\n");
+ return;
+ }
+
+ if (common_inode_args_process(argc, argv, &inode, 0)) {
+ return;
+ }
+
+ current_ino = 0;
+
+ retval = ext2fs_extent_open(current_fs, inode, &current_handle);
+ if (retval) {
+ com_err(argv[1], retval, "while opening extent handle");
+ return;
+ }
+
+ current_ino = inode;
+
+ printf("Loaded inode %d\n", current_ino);
+
+ return;
+}
+
+void generic_goto_node(char *cmd_name, int op)
+{
+ struct ext2fs_extent extent;
+ errcode_t retval;
+
+ if (check_fs_open(cmd_name))
+ return;
+
+ if (!current_handle) {
+ com_err(cmd_name, 0, "Extent handle not open");
+ return;
+ }
+
+ retval = ext2fs_extent_get(current_handle, op, &extent);
+ if (retval) {
+ com_err(cmd_name, retval, 0);
+ return;
+ }
+ dbg_print_extent(0, &extent);
+}
+
+void do_current_node(int argc, char *argv[])
+{
+ generic_goto_node(argv[0], EXT2_EXTENT_CURRENT);
+}
+
+void do_root_node(int argc, char *argv[])
+{
+ generic_goto_node(argv[0], EXT2_EXTENT_ROOT);
+}
+
+void do_last_leaf(int argc, char *argv[])
+{
+ generic_goto_node(argv[0], EXT2_EXTENT_LAST_LEAF);
+}
+
+void do_first_sib(int argc, char *argv[])
+{
+ generic_goto_node(argv[0], EXT2_EXTENT_FIRST_SIB);
+}
+
+void do_last_sib(int argc, char *argv[])
+{
+ generic_goto_node(argv[0], EXT2_EXTENT_LAST_SIB);
+}
+
+void do_next_sib(int argc, char *argv[])
+{
+ generic_goto_node(argv[0], EXT2_EXTENT_NEXT_SIB);
+}
+
+void do_prev_sib(int argc, char *argv[])
+{
+ generic_goto_node(argv[0], EXT2_EXTENT_PREV_SIB);
+}
+
+void do_next_leaf(int argc, char *argv[])
+{
+ generic_goto_node(argv[0], EXT2_EXTENT_NEXT_LEAF);
+}
+
+void do_prev_leaf(int argc, char *argv[])
+{
+ generic_goto_node(argv[0], EXT2_EXTENT_PREV_LEAF);
+}
+
+void do_next(int argc, char *argv[])
+{
+ generic_goto_node(argv[0], EXT2_EXTENT_NEXT);
+}
+
+void do_prev(int argc, char *argv[])
+{
+ generic_goto_node(argv[0], EXT2_EXTENT_PREV);
+}
+
+void do_up(int argc, char *argv[])
+{
+ generic_goto_node(argv[0], EXT2_EXTENT_UP);
+}
+
+void do_down(int argc, char *argv[])
+{
+ generic_goto_node(argv[0], EXT2_EXTENT_DOWN);
+}
+
+void do_delete_node(int argc, char *argv[])
+{
+ errcode_t retval;
+ int err;
+
+ if (common_extent_args_process(argc, argv, 1, 1, "delete_node",
+ "", CHECK_FS_RW | CHECK_FS_BITMAPS))
+ return;
+
+ retval = ext2fs_extent_delete(current_handle, 0);
+ if (retval) {
+ com_err(argv[0], retval, 0);
+ return;
+ }
+ if (current_handle->path && current_handle->path[0].curr)
+ do_current_node(argc, argv);
+}
+
+void do_replace_node(int argc, char *argv[])
+{
+ const char *usage = "[--uninit] <lblk> <len> <pblk>";
+ errcode_t retval;
+ struct ext2fs_extent extent;
+ int err;
+
+ if (common_extent_args_process(argc, argv, 3, 5, "replace_node",
+ usage, CHECK_FS_RW | CHECK_FS_BITMAPS))
+ return;
+
+ extent.e_flags = 0;
+
+ if (!strcmp(argv[1], "--uninit")) {
+ argc--;
+ argv++;
+ extent.e_flags |= EXT2_EXTENT_FLAGS_UNINIT;
+ }
+
+ if (argc != 4) {
+ fprintf(stderr, "Usage: %s %s\n", argv[0], usage);
+ return;
+ }
+ extent.e_lblk = parse_ulong(argv[1], argv[0], "logical block", &err);
+ if (err)
+ return;
+
+ extent.e_len = parse_ulong(argv[2], argv[0], "logical block", &err);
+ if (err)
+ return;
+
+ extent.e_pblk = parse_ulong(argv[3], argv[0], "logical block", &err);
+ if (err)
+ return;
+
+ retval = ext2fs_extent_replace(current_handle, 0, &extent);
+ if (retval) {
+ com_err(argv[0], retval, 0);
+ return;
+ }
+ do_current_node(argc, argv);
+}
+
+void do_split_node(int argc, char *argv[])
+{
+ errcode_t retval;
+ struct ext2fs_extent extent;
+ int err;
+
+ if (common_extent_args_process(argc, argv, 1, 1, "split_node",
+ "", CHECK_FS_RW | CHECK_FS_BITMAPS))
+ return;
+
+ retval = extent_node_split(current_handle);
+ if (retval) {
+ com_err(argv[0], retval, 0);
+ return;
+ }
+ do_current_node(argc, argv);
+}
+
+void do_insert_node(int argc, char *argv[])
+{
+ const char *usage = "[--after] [--uninit] <lblk> <len> <pblk>";
+ errcode_t retval;
+ struct ext2fs_extent extent;
+ char *cmd;
+ int err;
+ int flags = 0;
+
+ if (common_extent_args_process(argc, argv, 3, 6, "insert_node",
+ usage, CHECK_FS_RW | CHECK_FS_BITMAPS))
+ return;
+
+ cmd = argv[0];
+
+ extent.e_flags = 0;
+
+ while (argc > 2) {
+ if (!strcmp(argv[1], "--after")) {
+ argc--;
+ argv++;
+ flags |= EXT2_EXTENT_INSERT_AFTER;
+ continue;
+ }
+ if (!strcmp(argv[1], "--uninit")) {
+ argc--;
+ argv++;
+ extent.e_flags |= EXT2_EXTENT_FLAGS_UNINIT;
+ continue;
+ }
+ break;
+ }
+
+ if (argc != 4) {
+ fprintf(stderr, "usage: %s %s\n", cmd, usage);
+ return;
+ }
+
+ extent.e_lblk = parse_ulong(argv[1], cmd,
+ "logical block", &err);
+ if (err)
+ return;
+
+ extent.e_len = parse_ulong(argv[2], cmd,
+ "length", &err);
+ if (err)
+ return;
+
+ extent.e_pblk = parse_ulong(argv[3], cmd,
+ "pysical block", &err);
+ if (err)
+ return;
+
+ retval = ext2fs_extent_insert(current_handle, flags, &extent);
+ if (retval) {
+ com_err(cmd, retval, 0);
+ return;
+ }
+ do_current_node(argc, argv);
+}
+
+void do_set_bmap(int argc, char **argv)
+{
+ const char *usage = "[--uninit] <lblk> <pblk>";
+ errcode_t retval;
+ blk_t logical;
+ blk_t physical;
+ char *cmd = argv[0];
+ int flags = 0;
+ int err;
+
+ if (common_extent_args_process(argc, argv, 3, 5, "set_bmap",
+ usage, CHECK_FS_RW | CHECK_FS_BITMAPS))
+ return;
+
+ if (argc > 2 && !strcmp(argv[1], "--uninit")) {
+ argc--;
+ argv++;
+ flags |= EXT2_EXTENT_SET_BMAP_UNINIT;
+ }
+
+ if (argc != 3) {
+ fprintf(stderr, "Usage: %s %s\n", cmd, usage);
+ return;
+ }
+
+ logical = parse_ulong(argv[1], cmd,
+ "logical block", &err);
+ if (err)
+ return;
+
+ physical = parse_ulong(argv[2], cmd,
+ "physical block", &err);
+ if (err)
+ return;
+
+ retval = ext2fs_extent_set_bmap(current_handle, logical,
+ (blk64_t) physical, flags);
+ if (retval) {
+ com_err(cmd, retval, 0);
+ return;
+ }
+ if (current_handle->path && current_handle->path[0].curr)
+ do_current_node(argc, argv);
+}
+
+void do_print_all(int argc, char **argv)
+{
+ const char *usage = "[--leaf-only|--reverse|--reverse-leaf]";
+ struct ext2fs_extent extent;
+ errcode_t retval;
+ errcode_t end_err = EXT2_ET_EXTENT_NO_NEXT;
+ int op = EXT2_EXTENT_NEXT;
+ int first_op = EXT2_EXTENT_ROOT;
+
+
+ if (common_extent_args_process(argc, argv, 1, 2, "print_all",
+ usage, 0))
+ return;
+
+ if (argc == 2) {
+ if (!strcmp(argv[1], "--leaf-only"))
+ op = EXT2_EXTENT_NEXT_LEAF;
+ else if (!strcmp(argv[1], "--reverse")) {
+ op = EXT2_EXTENT_PREV;
+ first_op = EXT2_EXTENT_LAST_LEAF;
+ end_err = EXT2_ET_EXTENT_NO_PREV;
+ } else if (!strcmp(argv[1], "--reverse-leaf")) {
+ op = EXT2_EXTENT_PREV_LEAF;
+ first_op = EXT2_EXTENT_LAST_LEAF;
+ end_err = EXT2_ET_EXTENT_NO_PREV;
+ } else {
+ fprintf(stderr, "Usage: %s %s\n", argv[0], usage);
+ return;
+ }
+ }
+
+ retval = ext2fs_extent_get(current_handle, first_op, &extent);
+ if (retval) {
+ com_err(argv[0], retval, 0);
+ return;
+ }
+ dbg_print_extent(0, &extent);
+
+ while (1) {
+ retval = ext2fs_extent_get(current_handle, op, &extent);
+ if (retval == end_err)
+ break;
+
+ if (retval) {
+ com_err(argv[0], retval, 0);
+ return;
+ }
+ dbg_print_extent(0, &extent);
+ }
+}
+
+void do_info(int argc, char **argv)
+{
+ struct ext2fs_extent extent;
+ struct ext2_extent_info info;
+ errcode_t retval;
+
+ if (common_extent_args_process(argc, argv, 1, 1, "info", "", 0))
+ return;
+
+ retval = ext2fs_extent_get_info(current_handle, &info);
+ if (retval) {
+ com_err(argv[0], retval, 0);
+ return;
+ }
+
+ retval = ext2fs_extent_get(current_handle,
+ EXT2_EXTENT_CURRENT, &extent);
+ if (retval) {
+ com_err(argv[0], retval, 0);
+ return;
+ }
+
+ dbg_print_extent(0, &extent);
+
+ printf("Current handle location: %d/%d (max: %d, bytes %d), level %d/%d\n",
+ info.curr_entry, info.num_entries, info.max_entries,
+ info.bytes_avail, info.curr_level, info.max_depth);
+ printf("\tmax lblk: %llu, max pblk: %llu\n", info.max_lblk,
+ info.max_pblk);
+ printf("\tmax_len: %u, max_uninit_len: %u\n", info.max_len,
+ info.max_uninit_len);
+}
+
+void do_goto_block(int argc, char **argv)
+{
+ struct ext2fs_extent extent;
+ errcode_t retval;
+ int op = EXT2_EXTENT_NEXT_LEAF;
+ blk_t blk;
+ int level = 0;
+
+ if (common_extent_args_process(argc, argv, 2, 3, "goto_block",
+ "block [level]", 0))
+ return;
+
+ if (strtoblk(argv[0], argv[1], &blk))
+ return;
+
+ if (argc == 3)
+ if (strtoblk(argv[0], argv[2], &level))
+ return;
+
+ retval = extent_goto(current_handle, level, (blk64_t) blk);
+
+ if (retval) {
+ com_err(argv[0], retval,
+ "while trying to go to block %u, level %d",
+ blk, level);
+ return;
+ }
+
+ generic_goto_node(argv[0], EXT2_EXTENT_CURRENT);
+}
#endif
diff --git a/lib/ext2fs/extent_dbg.ct b/lib/ext2fs/extent_dbg.ct
new file mode 100644
index 00000000..d0571f47
--- /dev/null
+++ b/lib/ext2fs/extent_dbg.ct
@@ -0,0 +1,74 @@
+#
+# Copyright (C) 1993 Theodore Ts'o. This file may be redistributed
+# under the terms of the GNU Public License.
+#
+command_table extent_cmds;
+
+request do_inode, "Open an inode",
+ inode;
+
+request do_current_node, "Current extent node",
+ current_node, current;
+
+request do_root_node, "Goto root extent",
+ root_node, root;
+
+request do_last_leaf, "Goto last leaf",
+ last_leaf;
+
+request do_first_sib, "Goto first sibling",
+ first_sibling, first_sib;
+
+request do_last_sib, "Goto last sibling",
+ last_sibling, last_sib;
+
+request do_next_sib, "Goto next sibling",
+ next_sibling, next_sib, ns;
+
+request do_prev_sib, "Goto previous sibling",
+ prev_sibling, prev_sib, ps;
+
+request do_next_leaf, "Goto next leaf",
+ next_leaf, nl;
+
+request do_prev_leaf, "Goto previous leaf",
+ prev_leaf, pl;
+
+request do_next, "Goto next node",
+ next, n;
+
+request do_prev, "Goto previous node",
+ previous, prev, p;
+
+request do_up, "Up node",
+ up_node, up, u;
+
+request do_down, "Down node",
+ down_node, down, d;
+
+request do_delete_node, "Delete node",
+ delete_node, delete;
+
+request do_insert_node, "Insert node",
+ insert_node, insert;
+
+request do_split_node, "Split node",
+ split_node, split;
+
+request do_set_bmap, "Set block mapping",
+ set_bmap;
+
+request do_replace_node, "Insert node",
+ replace_node, replace;
+
+request do_print_all, "Iterate over all nodes and print them",
+ print_all, all;
+
+request do_goto_block, "Goto extent containing specified block",
+ goto_block, goto;
+
+request do_info, "Print extent info",
+ info;
+
+end;
+
diff --git a/lib/ext2fs/fiemap.h b/lib/ext2fs/fiemap.h
index 30bf5555..671decbd 100644
--- a/lib/ext2fs/fiemap.h
+++ b/lib/ext2fs/fiemap.h
@@ -34,10 +34,6 @@ struct fiemap {
struct fiemap_extent fm_extents[0]; /* array of mapped extents (out) */
};
-#ifndef FS_IOC_FIEMAP
-#define FS_IOC_FIEMAP _IOWR('f', 11, struct fiemap)
-#endif
-
#define FIEMAP_MAX_OFFSET (~0ULL)
#define FIEMAP_FLAG_SYNC 0x00000001 /* sync file data before map */
diff --git a/lib/ext2fs/fileio.c b/lib/ext2fs/fileio.c
index 2e1b6824..834867e1 100644
--- a/lib/ext2fs/fileio.c
+++ b/lib/ext2fs/fileio.c
@@ -17,7 +17,6 @@
#include "ext2_fs.h"
#include "ext2fs.h"
-#include "ext2fsP.h"
struct ext2_file {
errcode_t magic;
@@ -26,8 +25,8 @@ struct ext2_file {
struct ext2_inode inode;
int flags;
__u64 pos;
- blk64_t blockno;
- blk64_t physblock;
+ blk_t blockno;
+ blk_t physblock;
char *buf;
};
@@ -97,24 +96,6 @@ ext2_filsys ext2fs_file_get_fs(ext2_file_t file)
}
/*
- * This function returns the pointer to the inode of a file from the structure
- */
-struct ext2_inode *ext2fs_file_get_inode(ext2_file_t file)
-{
- if (file->magic != EXT2_ET_MAGIC_EXT2_FILE)
- return NULL;
- return &file->inode;
-}
-
-/* This function returns the inode number from the structure */
-ext2_ino_t ext2fs_file_get_inode_num(ext2_file_t file)
-{
- if (file->magic != EXT2_ET_MAGIC_EXT2_FILE)
- return 0;
- return file->ino;
-}
-
-/*
* This function flushes the dirty block buffer out to disk if
* necessary.
*/
@@ -135,14 +116,15 @@ errcode_t ext2fs_file_flush(ext2_file_t file)
* Allocate it.
*/
if (!file->physblock) {
- retval = ext2fs_bmap2(fs, file->ino, &file->inode,
+ retval = ext2fs_bmap(fs, file->ino, &file->inode,
BMAP_BUFFER, file->ino ? BMAP_ALLOC : 0,
- file->blockno, 0, &file->physblock);
+ file->blockno, &file->physblock);
if (retval)
return retval;
}
- retval = io_channel_write_blk64(fs->io, file->physblock, 1, file->buf);
+ retval = io_channel_write_blk(fs->io, file->physblock,
+ 1, file->buf);
if (retval)
return retval;
@@ -157,7 +139,7 @@ errcode_t ext2fs_file_flush(ext2_file_t file)
*/
static errcode_t sync_buffer_position(ext2_file_t file)
{
- blk64_t b;
+ blk_t b;
errcode_t retval;
b = file->pos / file->fs->blocksize;
@@ -186,16 +168,16 @@ static errcode_t load_buffer(ext2_file_t file, int dontfill)
errcode_t retval;
if (!(file->flags & EXT2_FILE_BUF_VALID)) {
- retval = ext2fs_bmap2(fs, file->ino, &file->inode,
- BMAP_BUFFER, 0, file->blockno, 0,
+ retval = ext2fs_bmap(fs, file->ino, &file->inode,
+ BMAP_BUFFER, 0, file->blockno,
&file->physblock);
if (retval)
return retval;
if (!dontfill) {
if (file->physblock) {
- retval = io_channel_read_blk64(fs->io,
- file->physblock,
- 1, file->buf);
+ retval = io_channel_read_blk(fs->io,
+ file->physblock,
+ 1, file->buf);
if (retval)
return retval;
} else
@@ -297,20 +279,6 @@ errcode_t ext2fs_file_write(ext2_file_t file, const void *buf,
if (retval)
goto fail;
- /*
- * OK, the physical block hasn't been allocated yet.
- * Allocate it.
- */
- if (!file->physblock) {
- retval = ext2fs_bmap2(fs, file->ino, &file->inode,
- BMAP_BUFFER,
- file->ino ? BMAP_ALLOC : 0,
- file->blockno, 0,
- &file->physblock);
- if (retval)
- goto fail;
- }
-
file->flags |= EXT2_FILE_BUF_DIRTY;
memcpy(file->buf+start, ptr, c);
file->pos += c;
@@ -320,15 +288,6 @@ errcode_t ext2fs_file_write(ext2_file_t file, const void *buf,
}
fail:
- /* Update inode size */
- if (count != 0 && EXT2_I_SIZE(&file->inode) < file->pos) {
- errcode_t rc;
-
- rc = ext2fs_file_set_size2(file, file->pos);
- if (retval == 0)
- retval = rc;
- }
-
if (written)
*written = count;
return retval;
@@ -393,106 +352,27 @@ ext2_off_t ext2fs_file_get_size(ext2_file_t file)
return size;
}
-/* Zero the parts of the last block that are past EOF. */
-static errcode_t ext2fs_file_zero_past_offset(ext2_file_t file,
- ext2_off64_t offset)
-{
- ext2_filsys fs = file->fs;
- char *b = NULL;
- ext2_off64_t off = offset % fs->blocksize;
- blk64_t blk;
- int ret_flags;
- errcode_t retval;
-
- if (off == 0)
- return 0;
-
- retval = sync_buffer_position(file);
- if (retval)
- return retval;
-
- /* Is there an initialized block at the end? */
- retval = ext2fs_bmap2(fs, file->ino, NULL, NULL, 0,
- offset / fs->blocksize, &ret_flags, &blk);
- if (retval)
- return retval;
- if ((blk == 0) || (ret_flags & BMAP_RET_UNINIT))
- return 0;
-
- /* Zero to the end of the block */
- retval = ext2fs_get_mem(fs->blocksize, &b);
- if (retval)
- return retval;
-
- /* Read/zero/write block */
- retval = io_channel_read_blk64(fs->io, blk, 1, b);
- if (retval)
- goto out;
-
- memset(b + off, 0, fs->blocksize - off);
-
- retval = io_channel_write_blk64(fs->io, blk, 1, b);
- if (retval)
- goto out;
-
-out:
- ext2fs_free_mem(&b);
- return retval;
-}
-
/*
* This function sets the size of the file, truncating it if necessary
*
+ * XXX still need to call truncate
*/
-errcode_t ext2fs_file_set_size2(ext2_file_t file, ext2_off64_t size)
+errcode_t ext2fs_file_set_size(ext2_file_t file, ext2_off_t size)
{
- ext2_off64_t old_size;
errcode_t retval;
- blk64_t old_truncate, truncate_block;
-
EXT2_CHECK_MAGIC(file, EXT2_ET_MAGIC_EXT2_FILE);
- if (size && ext2fs_file_block_offset_too_big(file->fs, &file->inode,
- (size - 1) / file->fs->blocksize))
- return EXT2_ET_FILE_TOO_BIG;
- truncate_block = ((size + file->fs->blocksize - 1) >>
- EXT2_BLOCK_SIZE_BITS(file->fs->super));
- old_size = EXT2_I_SIZE(&file->inode);
- old_truncate = ((old_size + file->fs->blocksize - 1) >>
- EXT2_BLOCK_SIZE_BITS(file->fs->super));
-
- /* If we're writing a large file, set the large_file flag */
- if (LINUX_S_ISREG(file->inode.i_mode) &&
- ext2fs_needs_large_file_feature(EXT2_I_SIZE(&file->inode)) &&
- (!EXT2_HAS_RO_COMPAT_FEATURE(file->fs->super,
- EXT2_FEATURE_RO_COMPAT_LARGE_FILE) ||
- file->fs->super->s_rev_level == EXT2_GOOD_OLD_REV)) {
- file->fs->super->s_feature_ro_compat |=
- EXT2_FEATURE_RO_COMPAT_LARGE_FILE;
- ext2fs_update_dynamic_rev(file->fs);
- ext2fs_mark_super_dirty(file->fs);
- }
-
- file->inode.i_size = size & 0xffffffff;
- file->inode.i_size_high = (size >> 32);
+ file->inode.i_size = size;
+ file->inode.i_size_high = 0;
if (file->ino) {
retval = ext2fs_write_inode(file->fs, file->ino, &file->inode);
if (retval)
return retval;
}
- retval = ext2fs_file_zero_past_offset(file, size);
- if (retval)
- return retval;
-
- if (truncate_block >= old_truncate)
- return 0;
-
- return ext2fs_punch(file->fs, file->ino, &file->inode, 0,
- truncate_block, ~0ULL);
-}
+ /*
+ * XXX truncate inode if necessary
+ */
-errcode_t ext2fs_file_set_size(ext2_file_t file, ext2_off_t size)
-{
- return ext2fs_file_set_size2(file, size);
+ return 0;
}
diff --git a/lib/ext2fs/finddev.c b/lib/ext2fs/finddev.c
index 88eb5cee..cc2029f2 100644
--- a/lib/ext2fs/finddev.c
+++ b/lib/ext2fs/finddev.c
@@ -33,7 +33,6 @@
#include "ext2_fs.h"
#include "ext2fs.h"
-#include "ext2fsP.h"
struct dir_list {
char *name;
@@ -128,7 +127,6 @@ char *ext2fs_find_block_device(dev_t device)
struct dir_list *list = 0, *new_list = 0;
struct dir_list *current;
char *ret_path = 0;
- int level = 0;
/*
* Add the starting directories to search...
@@ -155,9 +153,6 @@ char *ext2fs_find_block_device(dev_t device)
if (list == 0) {
list = new_list;
new_list = 0;
- /* Avoid infinite loop */
- if (++level >= EXT2FS_MAX_NESTED_LINKS)
- break;
}
}
free_dirlist(&list);
diff --git a/lib/ext2fs/flushb.c b/lib/ext2fs/flushb.c
index c4406fd1..394bb074 100644
--- a/lib/ext2fs/flushb.c
+++ b/lib/ext2fs/flushb.c
@@ -65,13 +65,17 @@ errcode_t ext2fs_sync_device(int fd, int flushb)
#ifdef BLKFLSBUF
if (ioctl (fd, BLKFLSBUF, 0) == 0)
return 0;
-#elif defined(__linux__)
-#warning BLKFLSBUF not defined
+#else
+#ifdef __GNUC__
+ #warning BLKFLSBUF not defined
+#endif /* __GNUC__ */
#endif
#ifdef FDFLUSH
- return ioctl(fd, FDFLUSH, 0); /* In case this is a floppy */
-#elif defined(__linux__)
-#warning FDFLUSH not defined
+ ioctl (fd, FDFLUSH, 0); /* In case this is a floppy */
+#else
+#ifdef __GNUC__
+ #warning FDFLUSH not defined
+#endif /* __GNUC__ */
#endif
}
return 0;
diff --git a/lib/ext2fs/freefs.c b/lib/ext2fs/freefs.c
index 1e01ef5f..5c35bb68 100644
--- a/lib/ext2fs/freefs.c
+++ b/lib/ext2fs/freefs.c
@@ -42,8 +42,6 @@ void ext2fs_free(ext2_filsys fs)
ext2fs_free_block_bitmap(fs->block_map);
if (fs->inode_map)
ext2fs_free_inode_bitmap(fs->inode_map);
- if (fs->image_header)
- ext2fs_free_mem(&fs->image_header);
if (fs->badblocks)
ext2fs_badblocks_list_free(fs->badblocks);
@@ -55,11 +53,6 @@ void ext2fs_free(ext2_filsys fs)
if (fs->icache)
ext2fs_free_inode_cache(fs->icache);
- if (fs->mmp_buf)
- ext2fs_free_mem(&fs->mmp_buf);
- if (fs->mmp_cmp)
- ext2fs_free_mem(&fs->mmp_cmp);
-
fs->magic = 0;
ext2fs_free_mem(&fs);
diff --git a/lib/ext2fs/gen_bitmap.c b/lib/ext2fs/gen_bitmap.c
index e4362345..42c9c7e4 100644
--- a/lib/ext2fs/gen_bitmap.c
+++ b/lib/ext2fs/gen_bitmap.c
@@ -25,7 +25,7 @@
#endif
#include "ext2_fs.h"
-#include "ext2fsP.h"
+#include "ext2fs.h"
struct ext2fs_struct_generic_bitmap {
errcode_t magic;
@@ -38,16 +38,6 @@ struct ext2fs_struct_generic_bitmap {
__u32 reserved[7];
};
-#define EXT2FS_IS_32_BITMAP(bmap) \
- (((bmap)->magic == EXT2_ET_MAGIC_GENERIC_BITMAP) || \
- ((bmap)->magic == EXT2_ET_MAGIC_BLOCK_BITMAP) || \
- ((bmap)->magic == EXT2_ET_MAGIC_INODE_BITMAP))
-
-#define EXT2FS_IS_64_BITMAP(bmap) \
- (((bmap)->magic == EXT2_ET_MAGIC_GENERIC_BITMAP64) || \
- ((bmap)->magic == EXT2_ET_MAGIC_BLOCK_BITMAP64) || \
- ((bmap)->magic == EXT2_ET_MAGIC_INODE_BITMAP64))
-
/*
* Used by previously inlined function, so we have to export this and
* not change the function signature
@@ -170,18 +160,6 @@ void ext2fs_free_generic_bitmap(ext2fs_inode_bitmap bitmap)
int ext2fs_test_generic_bitmap(ext2fs_generic_bitmap bitmap,
blk_t bitno)
{
- if (!EXT2FS_IS_32_BITMAP(bitmap)) {
- if (EXT2FS_IS_64_BITMAP(bitmap)) {
- ext2fs_warn_bitmap32(bitmap, __func__);
- return ext2fs_test_generic_bmap(bitmap, bitno);
- }
-#ifndef OMIT_COM_ERR
- com_err(0, EXT2_ET_MAGIC_GENERIC_BITMAP,
- "test_bitmap(%lu)", (unsigned long) bitno);
-#endif
- return 0;
- }
-
if ((bitno < bitmap->start) || (bitno > bitmap->end)) {
ext2fs_warn_bitmap2(bitmap, EXT2FS_TEST_ERROR, bitno);
return 0;
@@ -192,18 +170,6 @@ int ext2fs_test_generic_bitmap(ext2fs_generic_bitmap bitmap,
int ext2fs_mark_generic_bitmap(ext2fs_generic_bitmap bitmap,
__u32 bitno)
{
- if (!EXT2FS_IS_32_BITMAP(bitmap)) {
- if (EXT2FS_IS_64_BITMAP(bitmap)) {
- ext2fs_warn_bitmap32(bitmap, __func__);
- return ext2fs_mark_generic_bmap(bitmap, bitno);
- }
-#ifndef OMIT_COM_ERR
- com_err(0, EXT2_ET_MAGIC_GENERIC_BITMAP,
- "mark_bitmap(%lu)", (unsigned long) bitno);
-#endif
- return 0;
- }
-
if ((bitno < bitmap->start) || (bitno > bitmap->end)) {
ext2fs_warn_bitmap2(bitmap, EXT2FS_MARK_ERROR, bitno);
return 0;
@@ -214,18 +180,6 @@ int ext2fs_mark_generic_bitmap(ext2fs_generic_bitmap bitmap,
int ext2fs_unmark_generic_bitmap(ext2fs_generic_bitmap bitmap,
blk_t bitno)
{
- if (!EXT2FS_IS_32_BITMAP(bitmap)) {
- if (EXT2FS_IS_64_BITMAP(bitmap)) {
- ext2fs_warn_bitmap32(bitmap, __func__);
- return ext2fs_unmark_generic_bmap(bitmap, bitno);
- }
-#ifndef OMIT_COM_ERR
- com_err(0, EXT2_ET_MAGIC_GENERIC_BITMAP,
- "mark_bitmap(%lu)", (unsigned long) bitno);
-#endif
- return 0;
- }
-
if ((bitno < bitmap->start) || (bitno > bitmap->end)) {
ext2fs_warn_bitmap2(bitmap, EXT2FS_UNMARK_ERROR, bitno);
return 0;
@@ -235,51 +189,18 @@ int ext2fs_unmark_generic_bitmap(ext2fs_generic_bitmap bitmap,
__u32 ext2fs_get_generic_bitmap_start(ext2fs_generic_bitmap bitmap)
{
- if (!EXT2FS_IS_32_BITMAP(bitmap)) {
- if (EXT2FS_IS_64_BITMAP(bitmap)) {
- ext2fs_warn_bitmap32(bitmap, __func__);
- return ext2fs_get_generic_bmap_start(bitmap);
- }
-#ifndef OMIT_COM_ERR
- com_err(0, EXT2_ET_MAGIC_GENERIC_BITMAP,
- "get_bitmap_start");
-#endif
- return 0;
- }
-
return bitmap->start;
}
__u32 ext2fs_get_generic_bitmap_end(ext2fs_generic_bitmap bitmap)
{
- if (!EXT2FS_IS_32_BITMAP(bitmap)) {
- if (EXT2FS_IS_64_BITMAP(bitmap)) {
- ext2fs_warn_bitmap32(bitmap, __func__);
- return ext2fs_get_generic_bmap_end(bitmap);
- }
-#ifndef OMIT_COM_ERR
- com_err(0, EXT2_ET_MAGIC_GENERIC_BITMAP,
- "get_bitmap_end");
-#endif
- return 0;
- }
return bitmap->end;
}
void ext2fs_clear_generic_bitmap(ext2fs_generic_bitmap bitmap)
{
- if (!EXT2FS_IS_32_BITMAP(bitmap)) {
- if (EXT2FS_IS_64_BITMAP(bitmap)) {
- ext2fs_warn_bitmap32(bitmap, __func__);
- ext2fs_clear_generic_bmap(bitmap);
- return;
- }
-#ifndef OMIT_COM_ERR
- com_err(0, EXT2_ET_MAGIC_GENERIC_BITMAP,
- "clear_generic_bitmap");
-#endif
+ if (check_magic(bitmap))
return;
- }
memset(bitmap->bitmap, 0,
(size_t) (((bitmap->real_end - bitmap->start) / 8) + 1));
@@ -412,7 +333,7 @@ errcode_t ext2fs_set_generic_bitmap_range(ext2fs_generic_bitmap bmap,
* Compare @mem to zero buffer by 256 bytes.
* Return 1 if @mem is zeroed memory, otherwise return 0.
*/
-int ext2fs_mem_is_zero(const char *mem, size_t len)
+static int mem_is_zero(const char *mem, size_t len)
{
static const char zero_buf[256];
@@ -500,33 +421,9 @@ static int ext2fs_test_clear_generic_bitmap_range(ext2fs_generic_bitmap bitmap,
}
/* Check whether all bytes are 0 */
- return ext2fs_mem_is_zero(ADDR + start_byte, len_byte);
+ return mem_is_zero(ADDR + start_byte, len_byte);
}
-errcode_t ext2fs_find_first_zero_generic_bitmap(ext2fs_generic_bitmap bitmap,
- __u32 start, __u32 end,
- __u32 *out)
-{
- blk_t b;
-
- if (start < bitmap->start || end > bitmap->end || start > end) {
- ext2fs_warn_bitmap2(bitmap, EXT2FS_TEST_ERROR, start);
- return EINVAL;
- }
-
- while (start <= end) {
- b = ext2fs_test_bit(start - bitmap->start, bitmap->bitmap);
- if (!b) {
- *out = start;
- return 0;
- }
- start++;
- }
-
- return ENOENT;
-}
-
-
int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
blk_t block, int num)
{
@@ -581,4 +478,3 @@ void ext2fs_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
ext2fs_fast_clear_bit(block + i - bitmap->start,
bitmap->bitmap);
}
-
diff --git a/lib/ext2fs/gen_bitmap64.c b/lib/ext2fs/gen_bitmap64.c
deleted file mode 100644
index 7f49fd9d..00000000
--- a/lib/ext2fs/gen_bitmap64.c
+++ /dev/null
@@ -1,849 +0,0 @@
-/*
- * gen_bitmap64.c --- routines to read, write, and manipulate the new qinode and
- * block bitmaps.
- *
- * Copyright (C) 2007, 2008 Theodore Ts'o.
- *
- * %Begin-Header%
- * This file may be redistributed under the terms of the GNU Public
- * License.
- * %End-Header%
- */
-
-#include <stdio.h>
-#include <string.h>
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <fcntl.h>
-#include <time.h>
-#include <errno.h>
-#if HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-
-#include "ext2_fs.h"
-#include "ext2fsP.h"
-#include "bmap64.h"
-
-/*
- * Design of 64-bit bitmaps
- *
- * In order maintain ABI compatibility with programs that don't
- * understand about 64-bit blocks/inodes,
- * ext2fs_allocate_inode_bitmap() and ext2fs_allocate_block_bitmap()
- * will create old-style bitmaps unless the application passes the
- * flag EXT2_FLAG_64BITS to ext2fs_open(). If this flag is
- * passed, then we know the application has been recompiled, so we can
- * use the new-style bitmaps. If it is not passed, we have to return
- * an error if trying to open a filesystem which needs 64-bit bitmaps.
- *
- * The new bitmaps use a new set of structure magic numbers, so that
- * both the old-style and new-style interfaces can identify which
- * version of the data structure was used. Both the old-style and
- * new-style interfaces will support either type of bitmap, although
- * of course 64-bit operation will only be possible when both the
- * new-style interface and the new-style bitmap are used.
- *
- * For example, the new bitmap interfaces will check the structure
- * magic numbers and so will be able to detect old-stype bitmap. If
- * they see an old-style bitmap, they will pass it to the gen_bitmap.c
- * functions for handling. The same will be true for the old
- * interfaces as well.
- *
- * The new-style interfaces will have several different back-end
- * implementations, so we can support different encodings that are
- * appropriate for different applications. In general the default
- * should be whatever makes sense, and what the application/library
- * will use. However, e2fsck may need specialized implementations for
- * its own uses. For example, when doing parent directory pointer
- * loop detections in pass 3, the bitmap will *always* be sparse, so
- * e2fsck can request an encoding which is optimized for that.
- */
-
-static void warn_bitmap(ext2fs_generic_bitmap bitmap,
- int code, __u64 arg)
-{
-#ifndef OMIT_COM_ERR
- if (bitmap->description)
- com_err(0, bitmap->base_error_code+code,
- "#%llu for %s", arg, bitmap->description);
- else
- com_err(0, bitmap->base_error_code + code, "#%llu", arg);
-#endif
-}
-
-#ifdef BMAP_STATS_OPS
-#define INC_STAT(map, name) map->stats.name
-#else
-#define INC_STAT(map, name) ;;
-#endif
-
-
-errcode_t ext2fs_alloc_generic_bmap(ext2_filsys fs, errcode_t magic,
- int type, __u64 start, __u64 end,
- __u64 real_end,
- const char *descr,
- ext2fs_generic_bitmap *ret)
-{
- ext2fs_generic_bitmap bitmap;
- struct ext2_bitmap_ops *ops;
- ext2_ino_t num_dirs;
- errcode_t retval;
-
- if (!type)
- type = EXT2FS_BMAP64_BITARRAY;
-
- switch (type) {
- case EXT2FS_BMAP64_BITARRAY:
- ops = &ext2fs_blkmap64_bitarray;
- break;
- case EXT2FS_BMAP64_RBTREE:
- ops = &ext2fs_blkmap64_rbtree;
- break;
- case EXT2FS_BMAP64_AUTODIR:
- retval = ext2fs_get_num_dirs(fs, &num_dirs);
- if (retval || num_dirs > (fs->super->s_inodes_count / 320))
- ops = &ext2fs_blkmap64_bitarray;
- else
- ops = &ext2fs_blkmap64_rbtree;
- break;
- default:
- return EINVAL;
- }
-
- retval = ext2fs_get_memzero(sizeof(struct ext2fs_struct_generic_bitmap),
- &bitmap);
- if (retval)
- return retval;
-
-#ifdef BMAP_STATS
- if (gettimeofday(&bitmap->stats.created,
- (struct timezone *) NULL) == -1) {
- perror("gettimeofday");
- ext2fs_free_mem(&bitmap);
- return 1;
- }
- bitmap->stats.type = type;
-#endif
-
- /* XXX factor out, repeated in copy_bmap */
- bitmap->magic = magic;
- bitmap->fs = fs;
- bitmap->start = start;
- bitmap->end = end;
- bitmap->real_end = real_end;
- bitmap->bitmap_ops = ops;
- bitmap->cluster_bits = 0;
- switch (magic) {
- case EXT2_ET_MAGIC_INODE_BITMAP64:
- bitmap->base_error_code = EXT2_ET_BAD_INODE_MARK;
- break;
- case EXT2_ET_MAGIC_BLOCK_BITMAP64:
- bitmap->base_error_code = EXT2_ET_BAD_BLOCK_MARK;
- bitmap->cluster_bits = fs->cluster_ratio_bits;
- break;
- default:
- bitmap->base_error_code = EXT2_ET_BAD_GENERIC_MARK;
- }
- if (descr) {
- retval = ext2fs_get_mem(strlen(descr)+1, &bitmap->description);
- if (retval) {
- ext2fs_free_mem(&bitmap);
- return retval;
- }
- strcpy(bitmap->description, descr);
- } else
- bitmap->description = 0;
-
- retval = bitmap->bitmap_ops->new_bmap(fs, bitmap);
- if (retval) {
- ext2fs_free_mem(&bitmap->description);
- ext2fs_free_mem(&bitmap);
- return retval;
- }
-
- *ret = bitmap;
- return 0;
-}
-
-#ifdef BMAP_STATS
-static void ext2fs_print_bmap_statistics(ext2fs_generic_bitmap bitmap)
-{
- struct ext2_bmap_statistics *stats = &bitmap->stats;
-#ifdef BMAP_STATS_OPS
- float mark_seq_perc = 0.0, test_seq_perc = 0.0;
- float mark_back_perc = 0.0, test_back_perc = 0.0;
-#endif
- double inuse;
- struct timeval now;
-
-#ifdef BMAP_STATS_OPS
- if (stats->test_count) {
- test_seq_perc = ((float)stats->test_seq /
- stats->test_count) * 100;
- test_back_perc = ((float)stats->test_back /
- stats->test_count) * 100;
- }
-
- if (stats->mark_count) {
- mark_seq_perc = ((float)stats->mark_seq /
- stats->mark_count) * 100;
- mark_back_perc = ((float)stats->mark_back /
- stats->mark_count) * 100;
- }
-#endif
-
- if (gettimeofday(&now, (struct timezone *) NULL) == -1) {
- perror("gettimeofday");
- return;
- }
-
- inuse = (double) now.tv_sec + \
- (((double) now.tv_usec) * 0.000001);
- inuse -= (double) stats->created.tv_sec + \
- (((double) stats->created.tv_usec) * 0.000001);
-
- fprintf(stderr, "\n[+] %s bitmap (type %d)\n", bitmap->description,
- stats->type);
- fprintf(stderr, "=================================================\n");
-#ifdef BMAP_STATS_OPS
- fprintf(stderr, "%16llu bits long\n",
- bitmap->real_end - bitmap->start);
- fprintf(stderr, "%16lu copy_bmap\n%16lu resize_bmap\n",
- stats->copy_count, stats->resize_count);
- fprintf(stderr, "%16lu mark bmap\n%16lu unmark_bmap\n",
- stats->mark_count, stats->unmark_count);
- fprintf(stderr, "%16lu test_bmap\n%16lu mark_bmap_extent\n",
- stats->test_count, stats->mark_ext_count);
- fprintf(stderr, "%16lu unmark_bmap_extent\n"
- "%16lu test_clear_bmap_extent\n",
- stats->unmark_ext_count, stats->test_ext_count);
- fprintf(stderr, "%16lu set_bmap_range\n%16lu set_bmap_range\n",
- stats->set_range_count, stats->get_range_count);
- fprintf(stderr, "%16lu clear_bmap\n%16lu contiguous bit test (%.2f%%)\n",
- stats->clear_count, stats->test_seq, test_seq_perc);
- fprintf(stderr, "%16lu contiguous bit mark (%.2f%%)\n"
- "%16llu bits tested backwards (%.2f%%)\n",
- stats->mark_seq, mark_seq_perc,
- stats->test_back, test_back_perc);
- fprintf(stderr, "%16llu bits marked backwards (%.2f%%)\n"
- "%16.2f seconds in use\n",
- stats->mark_back, mark_back_perc, inuse);
-#endif /* BMAP_STATS_OPS */
-}
-#endif
-
-void ext2fs_free_generic_bmap(ext2fs_generic_bitmap bmap)
-{
- if (!bmap)
- return;
-
- if (EXT2FS_IS_32_BITMAP(bmap)) {
- ext2fs_free_generic_bitmap(bmap);
- return;
- }
-
- if (!EXT2FS_IS_64_BITMAP(bmap))
- return;
-
-#ifdef BMAP_STATS
- if (getenv("E2FSPROGS_BITMAP_STATS")) {
- ext2fs_print_bmap_statistics(bmap);
- bmap->bitmap_ops->print_stats(bmap);
- }
-#endif
-
- bmap->bitmap_ops->free_bmap(bmap);
-
- if (bmap->description) {
- ext2fs_free_mem(&bmap->description);
- bmap->description = 0;
- }
- bmap->magic = 0;
- ext2fs_free_mem(&bmap);
-}
-
-errcode_t ext2fs_copy_generic_bmap(ext2fs_generic_bitmap src,
- ext2fs_generic_bitmap *dest)
-{
- char *descr, *new_descr;
- ext2fs_generic_bitmap new_bmap;
- errcode_t retval;
-
- if (!src)
- return EINVAL;
-
- if (EXT2FS_IS_32_BITMAP(src))
- return ext2fs_copy_generic_bitmap(src, dest);
-
- if (!EXT2FS_IS_64_BITMAP(src))
- return EINVAL;
-
- /* Allocate a new bitmap struct */
- retval = ext2fs_get_memzero(sizeof(struct ext2fs_struct_generic_bitmap),
- &new_bmap);
- if (retval)
- return retval;
-
-
-#ifdef BMAP_STATS_OPS
- src->stats.copy_count++;
-#endif
-#ifdef BMAP_STATS
- if (gettimeofday(&new_bmap->stats.created,
- (struct timezone *) NULL) == -1) {
- perror("gettimeofday");
- ext2fs_free_mem(&new_bmap);
- return 1;
- }
- new_bmap->stats.type = src->stats.type;
-#endif
-
- /* Copy all the high-level parts over */
- new_bmap->magic = src->magic;
- new_bmap->fs = src->fs;
- new_bmap->start = src->start;
- new_bmap->end = src->end;
- new_bmap->real_end = src->real_end;
- new_bmap->bitmap_ops = src->bitmap_ops;
- new_bmap->base_error_code = src->base_error_code;
- new_bmap->cluster_bits = src->cluster_bits;
-
- descr = src->description;
- if (descr) {
- retval = ext2fs_get_mem(strlen(descr)+10, &new_descr);
- if (retval) {
- ext2fs_free_mem(&new_bmap);
- return retval;
- }
- sprintf(new_descr, "copy of %s", descr);
- new_bmap->description = new_descr;
- }
-
- retval = src->bitmap_ops->copy_bmap(src, new_bmap);
- if (retval) {
- ext2fs_free_mem(&new_bmap->description);
- ext2fs_free_mem(&new_bmap);
- return retval;
- }
-
- *dest = new_bmap;
-
- return 0;
-}
-
-errcode_t ext2fs_resize_generic_bmap(ext2fs_generic_bitmap bmap,
- __u64 new_end,
- __u64 new_real_end)
-{
- if (!bmap)
- return EINVAL;
-
- if (EXT2FS_IS_32_BITMAP(bmap))
- return ext2fs_resize_generic_bitmap(bmap->magic, new_end,
- new_real_end, bmap);
-
- if (!EXT2FS_IS_64_BITMAP(bmap))
- return EINVAL;
-
- INC_STAT(bmap, resize_count);
-
- return bmap->bitmap_ops->resize_bmap(bmap, new_end, new_real_end);
-}
-
-errcode_t ext2fs_fudge_generic_bmap_end(ext2fs_generic_bitmap bitmap,
- errcode_t neq,
- __u64 end, __u64 *oend)
-{
- if (!bitmap)
- return EINVAL;
-
- if (EXT2FS_IS_32_BITMAP(bitmap)) {
- ext2_ino_t tmp_oend;
- int retval;
-
- retval = ext2fs_fudge_generic_bitmap_end(bitmap, bitmap->magic,
- neq, end, &tmp_oend);
- if (oend)
- *oend = tmp_oend;
- return retval;
- }
-
- if (!EXT2FS_IS_64_BITMAP(bitmap))
- return EINVAL;
-
- if (end > bitmap->real_end)
- return neq;
- if (oend)
- *oend = bitmap->end;
- bitmap->end = end;
- return 0;
-}
-
-__u64 ext2fs_get_generic_bmap_start(ext2fs_generic_bitmap bitmap)
-{
- if (!bitmap)
- return EINVAL;
-
- if (EXT2FS_IS_32_BITMAP(bitmap))
- return ext2fs_get_generic_bitmap_start(bitmap);
-
- if (!EXT2FS_IS_64_BITMAP(bitmap))
- return EINVAL;
-
- return bitmap->start;
-}
-
-__u64 ext2fs_get_generic_bmap_end(ext2fs_generic_bitmap bitmap)
-{
- if (!bitmap)
- return EINVAL;
-
- if (EXT2FS_IS_32_BITMAP(bitmap))
- return ext2fs_get_generic_bitmap_end(bitmap);
-
- if (!EXT2FS_IS_64_BITMAP(bitmap))
- return EINVAL;
-
- return bitmap->end;
-}
-
-void ext2fs_clear_generic_bmap(ext2fs_generic_bitmap bitmap)
-{
- if (EXT2FS_IS_32_BITMAP(bitmap))
- ext2fs_clear_generic_bitmap(bitmap);
- else
- bitmap->bitmap_ops->clear_bmap (bitmap);
-}
-
-int ext2fs_mark_generic_bmap(ext2fs_generic_bitmap bitmap,
- __u64 arg)
-{
- if (!bitmap)
- return 0;
-
- if (EXT2FS_IS_32_BITMAP(bitmap)) {
- if (arg & ~0xffffffffULL) {
- ext2fs_warn_bitmap2(bitmap,
- EXT2FS_MARK_ERROR, 0xffffffff);
- return 0;
- }
- return ext2fs_mark_generic_bitmap(bitmap, arg);
- }
-
- if (!EXT2FS_IS_64_BITMAP(bitmap))
- return 0;
-
- arg >>= bitmap->cluster_bits;
-
-#ifdef BMAP_STATS_OPS
- if (arg == bitmap->stats.last_marked + 1)
- bitmap->stats.mark_seq++;
- if (arg < bitmap->stats.last_marked)
- bitmap->stats.mark_back++;
- bitmap->stats.last_marked = arg;
- bitmap->stats.mark_count++;
-#endif
-
- if ((arg < bitmap->start) || (arg > bitmap->end)) {
- warn_bitmap(bitmap, EXT2FS_MARK_ERROR, arg);
- return 0;
- }
-
- return bitmap->bitmap_ops->mark_bmap(bitmap, arg);
-}
-
-int ext2fs_unmark_generic_bmap(ext2fs_generic_bitmap bitmap,
- __u64 arg)
-{
- if (!bitmap)
- return 0;
-
- if (EXT2FS_IS_32_BITMAP(bitmap)) {
- if (arg & ~0xffffffffULL) {
- ext2fs_warn_bitmap2(bitmap, EXT2FS_UNMARK_ERROR,
- 0xffffffff);
- return 0;
- }
- return ext2fs_unmark_generic_bitmap(bitmap, arg);
- }
-
- if (!EXT2FS_IS_64_BITMAP(bitmap))
- return 0;
-
- arg >>= bitmap->cluster_bits;
-
- INC_STAT(bitmap, unmark_count);
-
- if ((arg < bitmap->start) || (arg > bitmap->end)) {
- warn_bitmap(bitmap, EXT2FS_UNMARK_ERROR, arg);
- return 0;
- }
-
- return bitmap->bitmap_ops->unmark_bmap(bitmap, arg);
-}
-
-int ext2fs_test_generic_bmap(ext2fs_generic_bitmap bitmap,
- __u64 arg)
-{
- if (!bitmap)
- return 0;
-
- if (EXT2FS_IS_32_BITMAP(bitmap)) {
- if (arg & ~0xffffffffULL) {
- ext2fs_warn_bitmap2(bitmap, EXT2FS_TEST_ERROR,
- 0xffffffff);
- return 0;
- }
- return ext2fs_test_generic_bitmap(bitmap, arg);
- }
-
- if (!EXT2FS_IS_64_BITMAP(bitmap))
- return 0;
-
- arg >>= bitmap->cluster_bits;
-
-#ifdef BMAP_STATS_OPS
- bitmap->stats.test_count++;
- if (arg == bitmap->stats.last_tested + 1)
- bitmap->stats.test_seq++;
- if (arg < bitmap->stats.last_tested)
- bitmap->stats.test_back++;
- bitmap->stats.last_tested = arg;
-#endif
-
- if ((arg < bitmap->start) || (arg > bitmap->end)) {
- warn_bitmap(bitmap, EXT2FS_TEST_ERROR, arg);
- return 0;
- }
-
- return bitmap->bitmap_ops->test_bmap(bitmap, arg);
-}
-
-errcode_t ext2fs_set_generic_bmap_range(ext2fs_generic_bitmap bmap,
- __u64 start, unsigned int num,
- void *in)
-{
- if (!bmap)
- return EINVAL;
-
- if (EXT2FS_IS_32_BITMAP(bmap)) {
- if ((start+num-1) & ~0xffffffffULL) {
- ext2fs_warn_bitmap2(bmap, EXT2FS_UNMARK_ERROR,
- 0xffffffff);
- return EINVAL;
- }
- return ext2fs_set_generic_bitmap_range(bmap, bmap->magic,
- start, num, in);
- }
-
- if (!EXT2FS_IS_64_BITMAP(bmap))
- return EINVAL;
-
- INC_STAT(bmap, set_range_count);
-
- return bmap->bitmap_ops->set_bmap_range(bmap, start, num, in);
-}
-
-errcode_t ext2fs_get_generic_bmap_range(ext2fs_generic_bitmap bmap,
- __u64 start, unsigned int num,
- void *out)
-{
- if (!bmap)
- return EINVAL;
-
- if (EXT2FS_IS_32_BITMAP(bmap)) {
- if ((start+num-1) & ~0xffffffffULL) {
- ext2fs_warn_bitmap2(bmap,
- EXT2FS_UNMARK_ERROR, 0xffffffff);
- return EINVAL;
- }
- return ext2fs_get_generic_bitmap_range(bmap, bmap->magic,
- start, num, out);
- }
-
- if (!EXT2FS_IS_64_BITMAP(bmap))
- return EINVAL;
-
- INC_STAT(bmap, get_range_count);
-
- return bmap->bitmap_ops->get_bmap_range(bmap, start, num, out);
-}
-
-errcode_t ext2fs_compare_generic_bmap(errcode_t neq,
- ext2fs_generic_bitmap bm1,
- ext2fs_generic_bitmap bm2)
-{
- blk64_t i;
-
- if (!bm1 || !bm2)
- return EINVAL;
- if (bm1->magic != bm2->magic)
- return EINVAL;
-
- /* Now we know both bitmaps have the same magic */
- if (EXT2FS_IS_32_BITMAP(bm1))
- return ext2fs_compare_generic_bitmap(bm1->magic, neq, bm1, bm2);
-
- if (!EXT2FS_IS_64_BITMAP(bm1))
- return EINVAL;
-
- if ((bm1->start != bm2->start) ||
- (bm1->end != bm2->end))
- return neq;
-
- for (i = bm1->end - ((bm1->end - bm1->start) % 8); i <= bm1->end; i++)
- if (ext2fs_test_generic_bmap(bm1, i) !=
- ext2fs_test_generic_bmap(bm2, i))
- return neq;
-
- return 0;
-}
-
-void ext2fs_set_generic_bmap_padding(ext2fs_generic_bitmap bmap)
-{
- __u64 start, num;
-
- if (EXT2FS_IS_32_BITMAP(bmap)) {
- ext2fs_set_generic_bitmap_padding(bmap);
- return;
- }
-
- start = bmap->end + 1;
- num = bmap->real_end - bmap->end;
- bmap->bitmap_ops->mark_bmap_extent(bmap, start, num);
- /* XXX ought to warn on error */
-}
-
-int ext2fs_test_block_bitmap_range2(ext2fs_block_bitmap bmap,
- blk64_t block, unsigned int num)
-{
- __u64 end = block + num;
-
- if (!bmap)
- return EINVAL;
-
- if (num == 1)
- return !ext2fs_test_generic_bmap((ext2fs_generic_bitmap)
- bmap, block);
-
- if (EXT2FS_IS_32_BITMAP(bmap)) {
- if ((block+num-1) & ~0xffffffffULL) {
- ext2fs_warn_bitmap2((ext2fs_generic_bitmap) bmap,
- EXT2FS_UNMARK_ERROR, 0xffffffff);
- return EINVAL;
- }
- return ext2fs_test_block_bitmap_range(
- (ext2fs_generic_bitmap) bmap, block, num);
- }
-
- if (!EXT2FS_IS_64_BITMAP(bmap))
- return EINVAL;
-
- INC_STAT(bmap, test_ext_count);
-
- /* convert to clusters if necessary */
- block >>= bmap->cluster_bits;
- end += (1 << bmap->cluster_bits) - 1;
- end >>= bmap->cluster_bits;
- num = end - block;
-
- if ((block < bmap->start) || (block+num-1 > bmap->end)) {
- ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_TEST, block,
- bmap->description);
- return EINVAL;
- }
-
- return bmap->bitmap_ops->test_clear_bmap_extent(bmap, block, num);
-}
-
-void ext2fs_mark_block_bitmap_range2(ext2fs_block_bitmap bmap,
- blk64_t block, unsigned int num)
-{
- __u64 end = block + num;
-
- if (!bmap)
- return;
-
- if (EXT2FS_IS_32_BITMAP(bmap)) {
- if ((block+num-1) & ~0xffffffffULL) {
- ext2fs_warn_bitmap2((ext2fs_generic_bitmap) bmap,
- EXT2FS_UNMARK_ERROR, 0xffffffff);
- return;
- }
- ext2fs_mark_block_bitmap_range((ext2fs_generic_bitmap) bmap,
- block, num);
- }
-
- if (!EXT2FS_IS_64_BITMAP(bmap))
- return;
-
- INC_STAT(bmap, mark_ext_count);
-
- /* convert to clusters if necessary */
- block >>= bmap->cluster_bits;
- end += (1 << bmap->cluster_bits) - 1;
- end >>= bmap->cluster_bits;
- num = end - block;
-
- if ((block < bmap->start) || (block+num-1 > bmap->end)) {
- ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_MARK, block,
- bmap->description);
- return;
- }
-
- bmap->bitmap_ops->mark_bmap_extent(bmap, block, num);
-}
-
-void ext2fs_unmark_block_bitmap_range2(ext2fs_block_bitmap bmap,
- blk64_t block, unsigned int num)
-{
- __u64 end = block + num;
-
- if (!bmap)
- return;
-
- if (EXT2FS_IS_32_BITMAP(bmap)) {
- if ((block+num-1) & ~0xffffffffULL) {
- ext2fs_warn_bitmap2((ext2fs_generic_bitmap) bmap,
- EXT2FS_UNMARK_ERROR, 0xffffffff);
- return;
- }
- ext2fs_unmark_block_bitmap_range((ext2fs_generic_bitmap) bmap,
- block, num);
- }
-
- if (!EXT2FS_IS_64_BITMAP(bmap))
- return;
-
- INC_STAT(bmap, unmark_ext_count);
-
- /* convert to clusters if necessary */
- block >>= bmap->cluster_bits;
- end += (1 << bmap->cluster_bits) - 1;
- end >>= bmap->cluster_bits;
- num = end - block;
-
- if ((block < bmap->start) || (block+num-1 > bmap->end)) {
- ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_UNMARK, block,
- bmap->description);
- return;
- }
-
- bmap->bitmap_ops->unmark_bmap_extent(bmap, block, num);
-}
-
-void ext2fs_warn_bitmap32(ext2fs_generic_bitmap bitmap, const char *func)
-{
-#ifndef OMIT_COM_ERR
- if (bitmap && bitmap->description)
- com_err(0, EXT2_ET_MAGIC_GENERIC_BITMAP,
- "called %s with 64-bit bitmap for %s", func,
- bitmap->description);
- else
- com_err(0, EXT2_ET_MAGIC_GENERIC_BITMAP,
- "called %s with 64-bit bitmap", func);
-#endif
-}
-
-errcode_t ext2fs_convert_subcluster_bitmap(ext2_filsys fs,
- ext2fs_block_bitmap *bitmap)
-{
- ext2fs_block_bitmap cmap, bmap;
- errcode_t retval;
- blk64_t i, b_end, c_end;
- int n, ratio;
-
- bmap = *bitmap;
-
- if (fs->cluster_ratio_bits == ext2fs_get_bitmap_granularity(bmap))
- return 0; /* Nothing to do */
-
- retval = ext2fs_allocate_block_bitmap(fs, "converted cluster bitmap",
- &cmap);
- if (retval)
- return retval;
-
- i = bmap->start;
- b_end = bmap->end;
- bmap->end = bmap->real_end;
- c_end = cmap->end;
- cmap->end = cmap->real_end;
- n = 0;
- ratio = 1 << fs->cluster_ratio_bits;
- while (i < bmap->real_end) {
- if (ext2fs_test_block_bitmap2(bmap, i)) {
- ext2fs_mark_block_bitmap2(cmap, i);
- i += ratio - n;
- n = 0;
- continue;
- }
- i++; n++;
- if (n >= ratio)
- n = 0;
- }
- bmap->end = b_end;
- cmap->end = c_end;
- ext2fs_free_block_bitmap(bmap);
- *bitmap = cmap;
- return 0;
-}
-
-errcode_t ext2fs_find_first_zero_generic_bmap(ext2fs_generic_bitmap bitmap,
- __u64 start, __u64 end, __u64 *out)
-{
- int b;
-
- if (!bitmap)
- return EINVAL;
-
- if (EXT2FS_IS_64_BITMAP(bitmap) && bitmap->bitmap_ops->find_first_zero)
- return bitmap->bitmap_ops->find_first_zero(bitmap, start,
- end, out);
-
- if (EXT2FS_IS_32_BITMAP(bitmap)) {
- blk_t blk = 0;
- errcode_t retval;
-
- if (((start) & ~0xffffffffULL) ||
- ((end) & ~0xffffffffULL)) {
- ext2fs_warn_bitmap2(bitmap, EXT2FS_TEST_ERROR, start);
- return EINVAL;
- }
-
- retval = ext2fs_find_first_zero_generic_bitmap(bitmap, start,
- end, &blk);
- if (retval == 0)
- *out = blk;
- return retval;
- }
-
- if (!EXT2FS_IS_64_BITMAP(bitmap))
- return EINVAL;
-
- start >>= bitmap->cluster_bits;
- end >>= bitmap->cluster_bits;
-
- if (start < bitmap->start || end > bitmap->end || start > end) {
- warn_bitmap(bitmap, EXT2FS_TEST_ERROR, start);
- return EINVAL;
- }
-
- while (start <= end) {
- b = bitmap->bitmap_ops->test_bmap(bitmap, start);
- if (!b) {
- *out = start << bitmap->cluster_bits;
- return 0;
- }
- start++;
- }
-
- return ENOENT;
-}
diff --git a/lib/ext2fs/gen_crc32ctable.c b/lib/ext2fs/gen_crc32ctable.c
deleted file mode 100644
index 9996e9d8..00000000
--- a/lib/ext2fs/gen_crc32ctable.c
+++ /dev/null
@@ -1,123 +0,0 @@
-#include <stdio.h>
-#include "crc32c_defs.h"
-#include <inttypes.h>
-
-#define ENTRIES_PER_LINE 4
-
-#if CRC_LE_BITS <= 8
-#define LE_TABLE_SIZE (1 << CRC_LE_BITS)
-#else
-#define LE_TABLE_SIZE 256
-#endif
-
-#if CRC_BE_BITS <= 8
-#define BE_TABLE_SIZE (1 << CRC_BE_BITS)
-#else
-#define BE_TABLE_SIZE 256
-#endif
-
-static uint32_t crc32ctable_le[8][256];
-static uint32_t crc32ctable_be[8][256];
-
-/**
- * crc32cinit_le() - allocate and initialize LE table data
- *
- * crc is the crc of the byte i; other entries are filled in based on the
- * fact that crctable[i^j] = crctable[i] ^ crctable[j].
- *
- */
-static void crc32cinit_le(void)
-{
- unsigned i, j;
- uint32_t crc = 1;
-
- crc32ctable_le[0][0] = 0;
-
- for (i = LE_TABLE_SIZE >> 1; i; i >>= 1) {
- crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0);
- for (j = 0; j < LE_TABLE_SIZE; j += 2 * i)
- crc32ctable_le[0][i + j] = crc ^ crc32ctable_le[0][j];
- }
- for (i = 0; i < LE_TABLE_SIZE; i++) {
- crc = crc32ctable_le[0][i];
- for (j = 1; j < 8; j++) {
- crc = crc32ctable_le[0][crc & 0xff] ^ (crc >> 8);
- crc32ctable_le[j][i] = crc;
- }
- }
-}
-
-/**
- * crc32cinit_be() - allocate and initialize BE table data
- */
-static void crc32cinit_be(void)
-{
- unsigned i, j;
- uint32_t crc = 0x80000000;
-
- crc32ctable_be[0][0] = 0;
-
- for (i = 1; i < BE_TABLE_SIZE; i <<= 1) {
- crc = (crc << 1) ^ ((crc & 0x80000000) ? CRCPOLY_BE : 0);
- for (j = 0; j < i; j++)
- crc32ctable_be[0][i + j] = crc ^ crc32ctable_be[0][j];
- }
- for (i = 0; i < BE_TABLE_SIZE; i++) {
- crc = crc32ctable_be[0][i];
- for (j = 1; j < 8; j++) {
- crc = crc32ctable_be[0][(crc >> 24) & 0xff] ^
- (crc << 8);
- crc32ctable_be[j][i] = crc;
- }
- }
-}
-
-static void output_table(uint32_t table[8][256], int len, char trans)
-{
- int i, j;
-
- for (j = 0 ; j < 8; j++) {
- printf("static const uint32_t t%d_%ce[] = {", j, trans);
- for (i = 0; i < len - 1; i++) {
- if ((i % ENTRIES_PER_LINE) == 0)
- printf("\n");
- printf("to%ce(0x%8.8xL),", trans, table[j][i]);
- if ((i % ENTRIES_PER_LINE) != (ENTRIES_PER_LINE - 1))
- printf(" ");
- }
- printf("to%ce(0x%8.8xL)};\n\n", trans, table[j][len - 1]);
-
- if (trans == 'l') {
- if ((j+1)*8 >= CRC_LE_BITS)
- break;
- } else {
- if ((j+1)*8 >= CRC_BE_BITS)
- break;
- }
- }
-}
-
-int main(int argc, char **argv)
-{
- printf("/*\n");
- printf(" * crc32ctable.h - CRC32c tables\n");
- printf(" * this file is generated - do not edit\n");
- printf(" * # gen_crc32ctable > crc32c_table.h\n");
- printf(" * with\n");
- printf(" * CRC_LE_BITS = %d\n", CRC_LE_BITS);
- printf(" * CRC_BE_BITS = %d\n", CRC_BE_BITS);
- printf(" */\n");
- printf("#include <stdint.h>\n");
-
- if (CRC_LE_BITS > 1) {
- crc32cinit_le();
- output_table(crc32ctable_le, LE_TABLE_SIZE, 'l');
- }
-
- if (CRC_BE_BITS > 1) {
- crc32cinit_be();
- output_table(crc32ctable_be, BE_TABLE_SIZE, 'b');
- }
-
- return 0;
-}
diff --git a/lib/ext2fs/get_pathname.c b/lib/ext2fs/get_pathname.c
index 93a9ec81..7ac14db2 100644
--- a/lib/ext2fs/get_pathname.c
+++ b/lib/ext2fs/get_pathname.c
@@ -73,7 +73,7 @@ static errcode_t ext2fs_get_pathname_int(ext2_filsys fs, ext2_ino_t dir,
char *buf, char **name)
{
struct get_pathname_struct gp;
- char *parent_name = 0, *ret;
+ char *parent_name, *ret;
errcode_t retval;
if (dir == ino) {
@@ -98,19 +98,7 @@ static errcode_t ext2fs_get_pathname_int(ext2_filsys fs, ext2_ino_t dir,
gp.errcode = 0;
retval = ext2fs_dir_iterate(fs, dir, 0, buf, get_pathname_proc, &gp);
- if (retval == EXT2_ET_NO_DIRECTORY) {
- char tmp[32];
-
- if (ino)
- snprintf(tmp, sizeof(tmp), "<%u>/<%u>", dir, ino);
- else
- snprintf(tmp, sizeof(tmp), "<%u>", dir);
- retval = ext2fs_get_mem(strlen(tmp)+1, name);
- if (retval)
- goto cleanup;
- strcpy(*name, tmp);
- return 0;
- } else if (retval)
+ if (retval)
goto cleanup;
if (gp.errcode) {
retval = gp.errcode;
@@ -143,11 +131,12 @@ static errcode_t ext2fs_get_pathname_int(ext2_filsys fs, ext2_ino_t dir,
else
strcat(ret, "???");
*name = ret;
+ ext2fs_free_mem(&parent_name);
retval = 0;
cleanup:
- ext2fs_free_mem(&parent_name);
- ext2fs_free_mem(&gp.name);
+ if (gp.name)
+ ext2fs_free_mem(&gp.name);
return retval;
}
diff --git a/lib/ext2fs/getsectsize.c b/lib/ext2fs/getsectsize.c
index c7ae6594..64f42a62 100644
--- a/lib/ext2fs/getsectsize.c
+++ b/lib/ext2fs/getsectsize.c
@@ -45,7 +45,11 @@ errcode_t ext2fs_get_device_sectsize(const char *file, int *sectsize)
{
int fd;
- fd = ext2fs_open_file(file, O_RDONLY, 0);
+#ifdef HAVE_OPEN64
+ fd = open64(file, O_RDONLY);
+#else
+ fd = open(file, O_RDONLY);
+#endif
if (fd < 0)
return errno;
@@ -61,39 +65,17 @@ errcode_t ext2fs_get_device_sectsize(const char *file, int *sectsize)
}
/*
- * Return desired alignment for direct I/O
- */
-int ext2fs_get_dio_alignment(int fd)
-{
- int align = 0;
-
-#ifdef BLKSSZGET
- if (ioctl(fd, BLKSSZGET, &align) < 0)
- align = 0;
-#endif
-
-#ifdef _SC_PAGESIZE
- if (align <= 0)
- align = sysconf(_SC_PAGESIZE);
-#endif
-#ifdef HAVE_GETPAGESIZE
- if (align <= 0)
- align = getpagesize();
-#endif
- if (align <= 0)
- align = 4096;
-
- return align;
-}
-
-/*
* Returns the physical sector size of a device
*/
errcode_t ext2fs_get_device_phys_sectsize(const char *file, int *sectsize)
{
int fd;
- fd = ext2fs_open_file(file, O_RDONLY, 0);
+#ifdef HAVE_OPEN64
+ fd = open64(file, O_RDONLY);
+#else
+ fd = open(file, O_RDONLY);
+#endif
if (fd < 0)
return errno;
diff --git a/lib/ext2fs/getsize.c b/lib/ext2fs/getsize.c
index 2f4495ed..5ef0081b 100644
--- a/lib/ext2fs/getsize.c
+++ b/lib/ext2fs/getsize.c
@@ -139,13 +139,31 @@ static int valid_offset (int fd, ext2_loff_t offset)
* Returns the number of blocks in a partition
*/
errcode_t ext2fs_get_device_size2(const char *file, int blocksize,
- blk64_t *retblocks)
+ blk64_t *retblocks)
{
int fd, rc = 0;
+ int valid_blkgetsize64 = 1;
+#ifdef __linux__
+ struct utsname ut;
+#endif
unsigned long long size64;
+ unsigned long size;
ext2_loff_t high, low;
+#ifdef FDGETPRM
+ struct floppy_struct this_floppy;
+#endif
+#ifdef HAVE_SYS_DISKLABEL_H
+ int part;
+ struct disklabel lab;
+ struct partition *pp;
+ char ch;
+#endif /* HAVE_SYS_DISKLABEL_H */
- fd = ext2fs_open_file(file, O_RDONLY, 0);
+#ifdef HAVE_OPEN64
+ fd = open64(file, O_RDONLY);
+#else
+ fd = open(file, O_RDONLY);
+#endif
if (fd < 0)
return errno;
@@ -157,89 +175,73 @@ errcode_t ext2fs_get_device_size2(const char *file, int blocksize,
#endif
#ifdef BLKGETSIZE64
- {
- int valid_blkgetsize64 = 1;
#ifdef __linux__
- struct utsname ut;
-
- if ((uname(&ut) == 0) &&
- ((ut.release[0] == '2') && (ut.release[1] == '.') &&
- (ut.release[2] < '6') && (ut.release[3] == '.')))
- valid_blkgetsize64 = 0;
+ if ((uname(&ut) == 0) &&
+ ((ut.release[0] == '2') && (ut.release[1] == '.') &&
+ (ut.release[2] < '6') && (ut.release[3] == '.')))
+ valid_blkgetsize64 = 0;
#endif
- if (valid_blkgetsize64 &&
- ioctl(fd, BLKGETSIZE64, &size64) >= 0) {
- *retblocks = size64 / blocksize;
- goto out;
- }
+ if (valid_blkgetsize64 &&
+ ioctl(fd, BLKGETSIZE64, &size64) >= 0) {
+ *retblocks = size64 / blocksize;
+ goto out;
}
-#endif /* BLKGETSIZE64 */
+#endif
#ifdef BLKGETSIZE
- {
- unsigned long size;
-
- if (ioctl(fd, BLKGETSIZE, &size) >= 0) {
- *retblocks = size / (blocksize / 512);
- goto out;
- }
+ if (ioctl(fd, BLKGETSIZE, &size) >= 0) {
+ *retblocks = size / (blocksize / 512);
+ goto out;
}
#endif
#ifdef FDGETPRM
- {
- struct floppy_struct this_floppy;
-
- if (ioctl(fd, FDGETPRM, &this_floppy) >= 0) {
- *retblocks = this_floppy.size / (blocksize / 512);
- goto out;
- }
+ if (ioctl(fd, FDGETPRM, &this_floppy) >= 0) {
+ *retblocks = this_floppy.size / (blocksize / 512);
+ goto out;
}
#endif
#ifdef HAVE_SYS_DISKLABEL_H
- {
- int part;
- struct disklabel lab;
- struct partition *pp;
- char ch;
-
#if defined(DIOCGMEDIASIZE)
- {
- off_t ms;
- u_int bs;
- if (ioctl(fd, DIOCGMEDIASIZE, &ms) >= 0) {
- *retblocks = ms / blocksize;
- goto out;
- }
- }
+ {
+ off_t ms;
+ u_int bs;
+ if (ioctl(fd, DIOCGMEDIASIZE, &ms) >= 0) {
+ *retblocks = ms / blocksize;
+ goto out;
+ }
+ }
#elif defined(DIOCGDINFO)
- /* old disklabel interface */
- part = strlen(file) - 1;
- if (part >= 0) {
- ch = file[part];
- if (isdigit(ch))
- part = 0;
- else if (ch >= 'a' && ch <= 'h')
- part = ch - 'a';
- else
- part = -1;
- }
- if (part >= 0 && (ioctl(fd, DIOCGDINFO, (char *)&lab) >= 0)) {
- pp = &lab.d_partitions[part];
- if (pp->p_size) {
- *retblocks = pp->p_size / (blocksize / 512);
- goto out;
- }
+ /* old disklabel interface */
+ part = strlen(file) - 1;
+ if (part >= 0) {
+ ch = file[part];
+ if (isdigit(ch))
+ part = 0;
+ else if (ch >= 'a' && ch <= 'h')
+ part = ch - 'a';
+ else
+ part = -1;
+ }
+ if (part >= 0 && (ioctl(fd, DIOCGDINFO, (char *)&lab) >= 0)) {
+ pp = &lab.d_partitions[part];
+ if (pp->p_size) {
+ *retblocks = pp->p_size / (blocksize / 512);
+ goto out;
}
-#endif /* defined(DIOCG*) */
}
+#endif /* defined(DIOCG*) */
#endif /* HAVE_SYS_DISKLABEL_H */
{
- ext2fs_struct_stat st;
-
- if (ext2fs_fstat(fd, &st) == 0)
+#ifdef HAVE_FSTAT64
+ struct stat64 st;
+ if (fstat64(fd, &st) == 0)
+#else
+ struct stat st;
+ if (fstat(fd, &st) == 0)
+#endif
if (S_ISREG(st.st_mode)) {
*retblocks = st.st_size / blocksize;
goto out;
@@ -252,9 +254,10 @@ errcode_t ext2fs_get_device_size2(const char *file, int blocksize,
* find the size of the partition.
*/
low = 0;
- for (high = 1024; valid_offset(fd, high); high *= 2)
+ for (high = 1024; valid_offset (fd, high); high *= 2)
low = high;
- while (low < high - 1) {
+ while (low < high - 1)
+ {
const ext2_loff_t mid = (low + high) / 2;
if (valid_offset (fd, mid))
@@ -262,7 +265,7 @@ errcode_t ext2fs_get_device_size2(const char *file, int blocksize,
else
high = mid;
}
- valid_offset(fd, 0);
+ valid_offset (fd, 0);
size64 = low + 1;
*retblocks = size64 / blocksize;
out:
diff --git a/lib/ext2fs/i_block.c b/lib/ext2fs/i_block.c
index f36c3c47..822776df 100644
--- a/lib/ext2fs/i_block.c
+++ b/lib/ext2fs/i_block.c
@@ -31,20 +31,18 @@ errcode_t ext2fs_iblk_add_blocks(ext2_filsys fs, struct ext2_inode *inode,
{
unsigned long long b = inode->i_blocks;
- if (fs->super->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_HUGE_FILE)
- b += ((long long) inode->osd2.linux2.l_i_blocks_hi) << 32;
-
if (!(fs->super->s_feature_ro_compat &
EXT4_FEATURE_RO_COMPAT_HUGE_FILE) ||
!(inode->i_flags & EXT4_HUGE_FILE_FL))
num_blocks *= fs->blocksize / 512;
- num_blocks *= EXT2FS_CLUSTER_RATIO(fs);
b += num_blocks;
- if (fs->super->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_HUGE_FILE)
+ if (fs->super->s_feature_ro_compat &
+ EXT4_FEATURE_RO_COMPAT_HUGE_FILE) {
+ b += ((long long) inode->osd2.linux2.l_i_blocks_hi) << 32;
inode->osd2.linux2.l_i_blocks_hi = b >> 32;
- else if (b > 0xFFFFFFFF)
+ } else if (b > 0xFFFFFFFF)
return EOVERFLOW;
inode->i_blocks = b & 0xFFFFFFFF;
return 0;
@@ -55,22 +53,21 @@ errcode_t ext2fs_iblk_sub_blocks(ext2_filsys fs, struct ext2_inode *inode,
{
unsigned long long b = inode->i_blocks;
- if (fs->super->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_HUGE_FILE)
- b += ((long long) inode->osd2.linux2.l_i_blocks_hi) << 32;
-
if (!(fs->super->s_feature_ro_compat &
EXT4_FEATURE_RO_COMPAT_HUGE_FILE) ||
!(inode->i_flags & EXT4_HUGE_FILE_FL))
num_blocks *= fs->blocksize / 512;
- num_blocks *= EXT2FS_CLUSTER_RATIO(fs);
if (num_blocks > b)
return EOVERFLOW;
b -= num_blocks;
- if (fs->super->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_HUGE_FILE)
+ if (fs->super->s_feature_ro_compat &
+ EXT4_FEATURE_RO_COMPAT_HUGE_FILE) {
+ b += ((long long) inode->osd2.linux2.l_i_blocks_hi) << 32;
inode->osd2.linux2.l_i_blocks_hi = b >> 32;
+ }
inode->i_blocks = b & 0xFFFFFFFF;
return 0;
}
@@ -81,7 +78,6 @@ errcode_t ext2fs_iblk_set(ext2_filsys fs, struct ext2_inode *inode, blk64_t b)
EXT4_FEATURE_RO_COMPAT_HUGE_FILE) ||
!(inode->i_flags & EXT4_HUGE_FILE_FL))
b *= fs->blocksize / 512;
- b *= EXT2FS_CLUSTER_RATIO(fs);
inode->i_blocks = b & 0xFFFFFFFF;
if (fs->super->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_HUGE_FILE)
diff --git a/lib/ext2fs/icount.c b/lib/ext2fs/icount.c
index f99824f8..a49f05fb 100644
--- a/lib/ext2fs/icount.c
+++ b/lib/ext2fs/icount.c
@@ -103,12 +103,12 @@ static errcode_t alloc_icount(ext2_filsys fs, int flags, ext2_icount_t *ret)
return retval;
memset(icount, 0, sizeof(struct ext2_icount));
- retval = ext2fs_allocate_inode_bitmap(fs, "icount", &icount->single);
+ retval = ext2fs_allocate_inode_bitmap(fs, 0, &icount->single);
if (retval)
goto errout;
if (flags & EXT2_ICOUNT_OPT_INCREMENT) {
- retval = ext2fs_allocate_inode_bitmap(fs, "icount_inc",
+ retval = ext2fs_allocate_inode_bitmap(fs, 0,
&icount->multiple);
if (retval)
goto errout;
@@ -179,7 +179,6 @@ errcode_t ext2fs_create_icount_tdb(ext2_filsys fs, char *tdb_dir,
ext2_icount_t icount;
errcode_t retval;
char *fn, uuid[40];
- ext2_ino_t num_inodes;
int fd;
retval = alloc_icount(fs, flags, &icount);
@@ -192,21 +191,9 @@ errcode_t ext2fs_create_icount_tdb(ext2_filsys fs, char *tdb_dir,
uuid_unparse(fs->super->s_uuid, uuid);
sprintf(fn, "%s/%s-icount-XXXXXX", tdb_dir, uuid);
fd = mkstemp(fn);
- if (fd < 0)
- return fd;
-
- /*
- * This is an overestimate of the size that we will need; the
- * ideal value is the number of used inodes with a count
- * greater than 1. OTOH the times when we really need this is
- * with the backup programs that use lots of hard links, in
- * which case the number of inodes in use approaches the ideal
- * value.
- */
- num_inodes = fs->super->s_inodes_count - fs->super->s_free_inodes_count;
icount->tdb_fn = fn;
- icount->tdb = tdb_open(fn, num_inodes, TDB_NOLOCK | TDB_NOSYNC,
+ icount->tdb = tdb_open(fn, 0, TDB_CLEAR_IF_FIRST,
O_RDWR | O_CREAT | O_TRUNC, 0600);
if (icount->tdb) {
close(fd);
@@ -352,7 +339,9 @@ static struct ext2_icount_el *insert_icount_el(ext2_icount_t icount,
static struct ext2_icount_el *get_icount_el(ext2_icount_t icount,
ext2_ino_t ino, int create)
{
+ float range;
int low, high, mid;
+ ext2_ino_t lowval, highval;
if (!icount || !icount->list)
return 0;
@@ -374,7 +363,31 @@ static struct ext2_icount_el *get_icount_el(ext2_icount_t icount,
low = 0;
high = (int) icount->count-1;
while (low <= high) {
- mid = ((unsigned)low + (unsigned)high) >> 1;
+#if 0
+ mid = (low+high)/2;
+#else
+ if (low == high)
+ mid = low;
+ else {
+ /* Interpolate for efficiency */
+ lowval = icount->list[low].ino;
+ highval = icount->list[high].ino;
+
+ if (ino < lowval)
+ range = 0;
+ else if (ino > highval)
+ range = 1;
+ else {
+ range = ((float) (ino - lowval)) /
+ (highval - lowval);
+ if (range > 0.9)
+ range = 0.9;
+ if (range < 0.1)
+ range = 0.1;
+ }
+ mid = low + ((int) (range * (high-low)));
+ }
+#endif
if (ino == icount->list[mid].ino) {
icount->cursor = mid+1;
return &icount->list[mid];
@@ -485,12 +498,12 @@ errcode_t ext2fs_icount_fetch(ext2_icount_t icount, ext2_ino_t ino, __u16 *ret)
if (!ino || (ino > icount->num_inodes))
return EXT2_ET_INVALID_ARGUMENT;
- if (ext2fs_test_inode_bitmap2(icount->single, ino)) {
+ if (ext2fs_test_inode_bitmap(icount->single, ino)) {
*ret = 1;
return 0;
}
if (icount->multiple &&
- !ext2fs_test_inode_bitmap2(icount->multiple, ino)) {
+ !ext2fs_test_inode_bitmap(icount->multiple, ino)) {
*ret = 0;
return 0;
}
@@ -509,7 +522,7 @@ errcode_t ext2fs_icount_increment(ext2_icount_t icount, ext2_ino_t ino,
if (!ino || (ino > icount->num_inodes))
return EXT2_ET_INVALID_ARGUMENT;
- if (ext2fs_test_inode_bitmap2(icount->single, ino)) {
+ if (ext2fs_test_inode_bitmap(icount->single, ino)) {
/*
* If the existing count is 1, then we know there is
* no entry in the list.
@@ -517,14 +530,14 @@ errcode_t ext2fs_icount_increment(ext2_icount_t icount, ext2_ino_t ino,
if (set_inode_count(icount, ino, 2))
return EXT2_ET_NO_MEMORY;
curr_value = 2;
- ext2fs_unmark_inode_bitmap2(icount->single, ino);
+ ext2fs_unmark_inode_bitmap(icount->single, ino);
} else if (icount->multiple) {
/*
* The count is either zero or greater than 1; if the
* inode is set in icount->multiple, then there should
* be an entry in the list, so we need to fix it.
*/
- if (ext2fs_test_inode_bitmap2(icount->multiple, ino)) {
+ if (ext2fs_test_inode_bitmap(icount->multiple, ino)) {
get_inode_count(icount, ino, &curr_value);
curr_value++;
if (set_inode_count(icount, ino, curr_value))
@@ -534,7 +547,7 @@ errcode_t ext2fs_icount_increment(ext2_icount_t icount, ext2_ino_t ino,
* The count was zero; mark the single bitmap
* and return.
*/
- ext2fs_mark_inode_bitmap2(icount->single, ino);
+ ext2fs_mark_inode_bitmap(icount->single, ino);
if (ret)
*ret = 1;
return 0;
@@ -550,7 +563,7 @@ errcode_t ext2fs_icount_increment(ext2_icount_t icount, ext2_ino_t ino,
return EXT2_ET_NO_MEMORY;
}
if (icount->multiple)
- ext2fs_mark_inode_bitmap2(icount->multiple, ino);
+ ext2fs_mark_inode_bitmap(icount->multiple, ino);
if (ret)
*ret = icount_16_xlate(curr_value);
return 0;
@@ -566,10 +579,10 @@ errcode_t ext2fs_icount_decrement(ext2_icount_t icount, ext2_ino_t ino,
EXT2_CHECK_MAGIC(icount, EXT2_ET_MAGIC_ICOUNT);
- if (ext2fs_test_inode_bitmap2(icount->single, ino)) {
- ext2fs_unmark_inode_bitmap2(icount->single, ino);
+ if (ext2fs_test_inode_bitmap(icount->single, ino)) {
+ ext2fs_unmark_inode_bitmap(icount->single, ino);
if (icount->multiple)
- ext2fs_unmark_inode_bitmap2(icount->multiple, ino);
+ ext2fs_unmark_inode_bitmap(icount->multiple, ino);
else {
set_inode_count(icount, ino, 0);
}
@@ -579,7 +592,7 @@ errcode_t ext2fs_icount_decrement(ext2_icount_t icount, ext2_ino_t ino,
}
if (icount->multiple &&
- !ext2fs_test_inode_bitmap2(icount->multiple, ino))
+ !ext2fs_test_inode_bitmap(icount->multiple, ino))
return EXT2_ET_INVALID_ARGUMENT;
get_inode_count(icount, ino, &curr_value);
@@ -590,9 +603,9 @@ errcode_t ext2fs_icount_decrement(ext2_icount_t icount, ext2_ino_t ino,
return EXT2_ET_NO_MEMORY;
if (curr_value == 1)
- ext2fs_mark_inode_bitmap2(icount->single, ino);
+ ext2fs_mark_inode_bitmap(icount->single, ino);
if ((curr_value == 0) && icount->multiple)
- ext2fs_unmark_inode_bitmap2(icount->multiple, ino);
+ ext2fs_unmark_inode_bitmap(icount->multiple, ino);
if (ret)
*ret = icount_16_xlate(curr_value);
@@ -608,19 +621,19 @@ errcode_t ext2fs_icount_store(ext2_icount_t icount, ext2_ino_t ino,
EXT2_CHECK_MAGIC(icount, EXT2_ET_MAGIC_ICOUNT);
if (count == 1) {
- ext2fs_mark_inode_bitmap2(icount->single, ino);
+ ext2fs_mark_inode_bitmap(icount->single, ino);
if (icount->multiple)
- ext2fs_unmark_inode_bitmap2(icount->multiple, ino);
+ ext2fs_unmark_inode_bitmap(icount->multiple, ino);
return 0;
}
if (count == 0) {
- ext2fs_unmark_inode_bitmap2(icount->single, ino);
+ ext2fs_unmark_inode_bitmap(icount->single, ino);
if (icount->multiple) {
/*
* If the icount->multiple bitmap is enabled,
* we can just clear both bitmaps and we're done
*/
- ext2fs_unmark_inode_bitmap2(icount->multiple, ino);
+ ext2fs_unmark_inode_bitmap(icount->multiple, ino);
} else
set_inode_count(icount, ino, 0);
return 0;
@@ -628,9 +641,9 @@ errcode_t ext2fs_icount_store(ext2_icount_t icount, ext2_ino_t ino,
if (set_inode_count(icount, ino, count))
return EXT2_ET_NO_MEMORY;
- ext2fs_unmark_inode_bitmap2(icount->single, ino);
+ ext2fs_unmark_inode_bitmap(icount->single, ino);
if (icount->multiple)
- ext2fs_mark_inode_bitmap2(icount->multiple, ino);
+ ext2fs_mark_inode_bitmap(icount->multiple, ino);
return 0;
}
@@ -731,9 +744,9 @@ static void setup(void)
initialize_ext2_error_table();
memset(&param, 0, sizeof(param));
- ext2fs_blocks_count_set(&param, 12000);
+ param.s_blocks_count = 12000;
- retval = ext2fs_initialize("test fs", EXT2_FLAG_64BITS, &param,
+ retval = ext2fs_initialize("test fs", 0, &param,
test_io_manager, &test_fs);
if (retval) {
com_err("setup", retval,
diff --git a/lib/ext2fs/imager.c b/lib/ext2fs/imager.c
index 5c7003a6..afa9a216 100644
--- a/lib/ext2fs/imager.c
+++ b/lib/ext2fs/imager.c
@@ -62,17 +62,16 @@ errcode_t ext2fs_image_inode_write(ext2_filsys fs, int fd, int flags)
{
unsigned int group, left, c, d;
char *buf, *cp;
- blk64_t blk;
+ blk_t blk;
ssize_t actual;
errcode_t retval;
- off_t r;
buf = malloc(fs->blocksize * BUF_BLOCKS);
if (!buf)
return ENOMEM;
for (group = 0; group < fs->group_desc_count; group++) {
- blk = ext2fs_inode_table_loc(fs, (unsigned)group);
+ blk = fs->group_desc[(unsigned)group].bg_inode_table;
if (!blk) {
retval = EXT2_ET_MISSING_INODE_TABLE;
goto errout;
@@ -82,7 +81,7 @@ errcode_t ext2fs_image_inode_write(ext2_filsys fs, int fd, int flags)
c = BUF_BLOCKS;
if (c > left)
c = left;
- retval = io_channel_read_blk64(fs->io, blk, c, buf);
+ retval = io_channel_read_blk(fs->io, blk, c, buf);
if (retval)
goto errout;
cp = buf;
@@ -97,11 +96,7 @@ errcode_t ext2fs_image_inode_write(ext2_filsys fs, int fd, int flags)
blk++;
left--;
cp += fs->blocksize;
- r = lseek(fd, fs->blocksize, SEEK_CUR);
- if (r < 0) {
- retval = errno;
- goto errout;
- }
+ lseek(fd, fs->blocksize, SEEK_CUR);
continue;
}
/* Find non-zero blocks */
@@ -141,7 +136,7 @@ errcode_t ext2fs_image_inode_read(ext2_filsys fs, int fd,
{
unsigned int group, c, left;
char *buf;
- blk64_t blk;
+ blk_t blk;
ssize_t actual;
errcode_t retval;
@@ -150,7 +145,7 @@ errcode_t ext2fs_image_inode_read(ext2_filsys fs, int fd,
return ENOMEM;
for (group = 0; group < fs->group_desc_count; group++) {
- blk = ext2fs_inode_table_loc(fs, (unsigned)group);
+ blk = fs->group_desc[(unsigned)group].bg_inode_table;
if (!blk) {
retval = EXT2_ET_MISSING_INODE_TABLE;
goto errout;
@@ -169,7 +164,7 @@ errcode_t ext2fs_image_inode_read(ext2_filsys fs, int fd,
retval = EXT2_ET_SHORT_READ;
goto errout;
}
- retval = io_channel_write_blk64(fs->io, blk, c, buf);
+ retval = io_channel_write_blk(fs->io, blk, c, buf);
if (retval)
goto errout;
@@ -283,7 +278,7 @@ errout:
errcode_t ext2fs_image_bitmap_write(ext2_filsys fs, int fd, int flags)
{
ext2fs_generic_bitmap bmap;
- errcode_t retval;
+ errcode_t err, retval;
ssize_t actual;
__u32 itr, cnt, size;
int c, total_size;
@@ -296,6 +291,7 @@ errcode_t ext2fs_image_bitmap_write(ext2_filsys fs, int fd, int flags)
return retval;
}
bmap = fs->inode_map;
+ err = EXT2_ET_MAGIC_INODE_BITMAP;
itr = 1;
cnt = EXT2_INODES_PER_GROUP(fs->super) * fs->group_desc_count;
size = (EXT2_INODES_PER_GROUP(fs->super) / 8);
@@ -306,6 +302,7 @@ errcode_t ext2fs_image_bitmap_write(ext2_filsys fs, int fd, int flags)
return retval;
}
bmap = fs->block_map;
+ err = EXT2_ET_MAGIC_BLOCK_BITMAP;
itr = fs->super->s_first_data_block;
cnt = EXT2_BLOCKS_PER_GROUP(fs->super) * fs->group_desc_count;
size = EXT2_BLOCKS_PER_GROUP(fs->super) / 8;
@@ -317,8 +314,8 @@ errcode_t ext2fs_image_bitmap_write(ext2_filsys fs, int fd, int flags)
if (size > (cnt >> 3))
size = (cnt >> 3);
- retval = ext2fs_get_generic_bmap_range(bmap, itr,
- size << 3, buf);
+ retval = ext2fs_get_generic_bitmap_range(bmap,
+ err, itr, size << 3, buf);
if (retval)
return retval;
@@ -358,7 +355,7 @@ errcode_t ext2fs_image_bitmap_write(ext2_filsys fs, int fd, int flags)
errcode_t ext2fs_image_bitmap_read(ext2_filsys fs, int fd, int flags)
{
ext2fs_generic_bitmap bmap;
- errcode_t retval;
+ errcode_t err, retval;
__u32 itr, cnt;
char buf[1024];
unsigned int size;
@@ -371,6 +368,7 @@ errcode_t ext2fs_image_bitmap_read(ext2_filsys fs, int fd, int flags)
return retval;
}
bmap = fs->inode_map;
+ err = EXT2_ET_MAGIC_INODE_BITMAP;
itr = 1;
cnt = EXT2_INODES_PER_GROUP(fs->super) * fs->group_desc_count;
size = (EXT2_INODES_PER_GROUP(fs->super) / 8);
@@ -381,6 +379,7 @@ errcode_t ext2fs_image_bitmap_read(ext2_filsys fs, int fd, int flags)
return retval;
}
bmap = fs->block_map;
+ err = EXT2_ET_MAGIC_BLOCK_BITMAP;
itr = fs->super->s_first_data_block;
cnt = EXT2_BLOCKS_PER_GROUP(fs->super) * fs->group_desc_count;
size = EXT2_BLOCKS_PER_GROUP(fs->super) / 8;
@@ -397,8 +396,8 @@ errcode_t ext2fs_image_bitmap_read(ext2_filsys fs, int fd, int flags)
if (actual != (int) size)
return EXT2_ET_SHORT_READ;
- retval = ext2fs_set_generic_bmap_range(bmap, itr,
- size << 3, buf);
+ retval = ext2fs_set_generic_bitmap_range(bmap,
+ err, itr, size << 3, buf);
if (retval)
return retval;
diff --git a/lib/ext2fs/initialize.c b/lib/ext2fs/initialize.c
index a57ffcb5..32f075e7 100644
--- a/lib/ext2fs/initialize.c
+++ b/lib/ext2fs/initialize.c
@@ -46,6 +46,19 @@
#endif /* defined(__linux__) && defined(EXT2_OS_LINUX) */
/*
+ * Note we override the kernel include file's idea of what the default
+ * check interval (never) should be. It's a good idea to check at
+ * least *occasionally*, specially since servers will never rarely get
+ * to reboot, since Linux is so robust these days. :-)
+ *
+ * 180 days (six months) seems like a good value.
+ */
+#ifdef EXT2_DFL_CHECKINTERVAL
+#undef EXT2_DFL_CHECKINTERVAL
+#endif
+#define EXT2_DFL_CHECKINTERVAL (86400L * 180L)
+
+/*
* Calculate the number of GDT blocks to reserve for online filesystem growth.
* The absolute maximum number of GDT blocks we can reserve is determined by
* the number of block pointers that can fit into a single block.
@@ -62,12 +75,8 @@ static unsigned int calc_reserved_gdt_blocks(ext2_filsys fs)
/* We set it at 1024x the current filesystem size, or
* the upper block count limit (2^32), whichever is lower.
*/
- if (ext2fs_blocks_count(sb) < max_blocks / 1024)
- max_blocks = ext2fs_blocks_count(sb) * 1024;
- /*
- * ext2fs_div64_ceil() is unnecessary because max_blocks is
- * max _GDT_ blocks, which is limited to 32 bits.
- */
+ if (sb->s_blocks_count < max_blocks / 1024)
+ max_blocks = sb->s_blocks_count * 1024;
rsv_groups = ext2fs_div_ceil(max_blocks - sb->s_first_data_block, bpg);
rsv_gdb = ext2fs_div_ceil(rsv_groups, gdpb) - fs->desc_blocks;
if (rsv_gdb > EXT2_ADDR_PER_BLOCK(sb))
@@ -87,22 +96,19 @@ errcode_t ext2fs_initialize(const char *name, int flags,
ext2_filsys fs;
errcode_t retval;
struct ext2_super_block *super;
+ int frags_per_block;
unsigned int rem;
unsigned int overhead = 0;
unsigned int ipg;
dgrp_t i;
- blk64_t free_blocks;
blk_t numblocks;
int rsv_gdt;
int csum_flag;
- int bigalloc_flag;
int io_flags;
- unsigned reserved_inos;
char *buf = 0;
char c;
- double reserved_ratio;
- if (!param || !ext2fs_blocks_count(param))
+ if (!param || !param->s_blocks_count)
return EXT2_ET_INVALID_ARGUMENT;
retval = ext2fs_get_mem(sizeof(struct struct_ext2_filsys), &fs);
@@ -113,15 +119,12 @@ errcode_t ext2fs_initialize(const char *name, int flags,
fs->magic = EXT2_ET_MAGIC_EXT2FS_FILSYS;
fs->flags = flags | EXT2_FLAG_RW;
fs->umask = 022;
- fs->default_bitmap_type = EXT2FS_BMAP64_RBTREE;
#ifdef WORDS_BIGENDIAN
fs->flags |= EXT2_FLAG_SWAP_BYTES;
#endif
io_flags = IO_FLAG_RW;
if (flags & EXT2_FLAG_EXCLUSIVE)
io_flags |= IO_FLAG_EXCLUSIVE;
- if (flags & EXT2_FLAG_DIRECT_IO)
- io_flags |= IO_FLAG_DIRECT_IO;
retval = manager->open(name, io_flags, &fs->io);
if (retval)
goto cleanup;
@@ -141,32 +144,18 @@ errcode_t ext2fs_initialize(const char *name, int flags,
#define set_field(field, default) (super->field = param->field ? \
param->field : (default))
-#define assign_field(field) (super->field = param->field)
super->s_magic = EXT2_SUPER_MAGIC;
super->s_state = EXT2_VALID_FS;
- bigalloc_flag = EXT2_HAS_RO_COMPAT_FEATURE(param,
- EXT4_FEATURE_RO_COMPAT_BIGALLOC);
-
- assign_field(s_log_block_size);
-
- if (bigalloc_flag) {
- set_field(s_log_cluster_size, super->s_log_block_size+4);
- if (super->s_log_block_size > super->s_log_cluster_size) {
- retval = EXT2_ET_INVALID_ARGUMENT;
- goto cleanup;
- }
- } else
- super->s_log_cluster_size = super->s_log_block_size;
-
- set_field(s_first_data_block, super->s_log_cluster_size ? 0 : 1);
- set_field(s_max_mnt_count, 0);
+ set_field(s_log_block_size, 0); /* default blocksize: 1024 bytes */
+ set_field(s_log_frag_size, 0); /* default fragsize: 1024 bytes */
+ set_field(s_first_data_block, super->s_log_block_size ? 0 : 1);
+ set_field(s_max_mnt_count, EXT2_DFL_MAX_MNT_COUNT);
set_field(s_errors, EXT2_ERRORS_DEFAULT);
set_field(s_feature_compat, 0);
set_field(s_feature_incompat, 0);
set_field(s_feature_ro_compat, 0);
- set_field(s_default_mount_opts, 0);
set_field(s_first_meta_bg, 0);
set_field(s_raid_stride, 0); /* default stride size: 0 */
set_field(s_raid_stripe_width, 0); /* default stripe width: 0 */
@@ -196,61 +185,28 @@ errcode_t ext2fs_initialize(const char *name, int flags,
super->s_inode_size = EXT2_GOOD_OLD_INODE_SIZE;
}
- set_field(s_checkinterval, 0);
+ set_field(s_checkinterval, EXT2_DFL_CHECKINTERVAL);
super->s_mkfs_time = super->s_lastcheck = fs->now ? fs->now : time(NULL);
super->s_creator_os = CREATOR_OS;
- fs->fragsize = fs->blocksize = EXT2_BLOCK_SIZE(super);
- fs->cluster_ratio_bits = super->s_log_cluster_size -
- super->s_log_block_size;
+ fs->blocksize = EXT2_BLOCK_SIZE(super);
+ fs->fragsize = EXT2_FRAG_SIZE(super);
+ frags_per_block = fs->blocksize / fs->fragsize;
- if (bigalloc_flag) {
- unsigned long long bpg;
+ /* default: (fs->blocksize*8) blocks/group, up to 2^16 (GDT limit) */
+ set_field(s_blocks_per_group, fs->blocksize * 8);
+ if (super->s_blocks_per_group > EXT2_MAX_BLOCKS_PER_GROUP(super))
+ super->s_blocks_per_group = EXT2_MAX_BLOCKS_PER_GROUP(super);
+ super->s_frags_per_group = super->s_blocks_per_group * frags_per_block;
- if (param->s_blocks_per_group &&
- param->s_clusters_per_group &&
- ((param->s_clusters_per_group * EXT2FS_CLUSTER_RATIO(fs)) !=
- param->s_blocks_per_group)) {
- retval = EXT2_ET_INVALID_ARGUMENT;
- goto cleanup;
- }
- if (param->s_clusters_per_group)
- assign_field(s_clusters_per_group);
- else if (param->s_blocks_per_group)
- super->s_clusters_per_group =
- param->s_blocks_per_group /
- EXT2FS_CLUSTER_RATIO(fs);
- else if (super->s_log_cluster_size + 15 < 32)
- super->s_clusters_per_group = fs->blocksize * 8;
- else
- super->s_clusters_per_group = (fs->blocksize - 1) * 8;
- if (super->s_clusters_per_group > EXT2_MAX_CLUSTERS_PER_GROUP(super))
- super->s_clusters_per_group = EXT2_MAX_CLUSTERS_PER_GROUP(super);
- bpg = EXT2FS_C2B(fs,
- (unsigned long long) super->s_clusters_per_group);
- if (bpg >= (((unsigned long long) 1) << 32)) {
- retval = EXT2_ET_INVALID_ARGUMENT;
- goto cleanup;
- }
- super->s_blocks_per_group = bpg;
- } else {
- set_field(s_blocks_per_group, fs->blocksize * 8);
- if (super->s_blocks_per_group > EXT2_MAX_BLOCKS_PER_GROUP(super))
- super->s_blocks_per_group = EXT2_MAX_BLOCKS_PER_GROUP(super);
- super->s_clusters_per_group = super->s_blocks_per_group;
- }
-
- ext2fs_blocks_count_set(super, ext2fs_blocks_count(param) &
- ~((blk64_t) EXT2FS_CLUSTER_MASK(fs)));
- ext2fs_r_blocks_count_set(super, ext2fs_r_blocks_count(param));
- if (ext2fs_r_blocks_count(super) >= ext2fs_blocks_count(param)) {
+ super->s_blocks_count = param->s_blocks_count;
+ super->s_r_blocks_count = param->s_r_blocks_count;
+ if (super->s_r_blocks_count >= param->s_blocks_count) {
retval = EXT2_ET_INVALID_ARGUMENT;
goto cleanup;
}
- set_field(s_mmp_update_interval, 0);
-
/*
* If we're creating an external journal device, we don't need
* to bother with the rest.
@@ -263,28 +219,18 @@ errcode_t ext2fs_initialize(const char *name, int flags,
}
retry:
- fs->group_desc_count = (dgrp_t) ext2fs_div64_ceil(
- ext2fs_blocks_count(super) - super->s_first_data_block,
- EXT2_BLOCKS_PER_GROUP(super));
+ fs->group_desc_count = ext2fs_div_ceil(super->s_blocks_count -
+ super->s_first_data_block,
+ EXT2_BLOCKS_PER_GROUP(super));
if (fs->group_desc_count == 0) {
retval = EXT2_ET_TOOSMALL;
goto cleanup;
}
-
- set_field(s_desc_size,
- super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT ?
- EXT2_MIN_DESC_SIZE_64BIT : 0);
-
fs->desc_blocks = ext2fs_div_ceil(fs->group_desc_count,
EXT2_DESC_PER_BLOCK(super));
i = fs->blocksize >= 4096 ? 1 : 4096 / fs->blocksize;
-
- if (super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT &&
- (ext2fs_blocks_count(super) / i) > (1ULL << 32))
- set_field(s_inodes_count, ~0U);
- else
- set_field(s_inodes_count, ext2fs_blocks_count(super) / i);
+ set_field(s_inodes_count, super->s_blocks_count / i);
/*
* Make sure we have at least EXT2_FIRST_INO + 1 inodes, so
@@ -301,12 +247,12 @@ retry:
*/
ipg = ext2fs_div_ceil(super->s_inodes_count, fs->group_desc_count);
if (ipg > fs->blocksize * 8) {
- if (!bigalloc_flag && super->s_blocks_per_group >= 256) {
+ if (super->s_blocks_per_group >= 256) {
/* Try again with slightly different parameters */
super->s_blocks_per_group -= 8;
- ext2fs_blocks_count_set(super,
- ext2fs_blocks_count(param));
- super->s_clusters_per_group = super->s_blocks_per_group;
+ super->s_blocks_count = param->s_blocks_count;
+ super->s_frags_per_group = super->s_blocks_per_group *
+ frags_per_block;
goto retry;
} else {
retval = EXT2_ET_TOO_MANY_INODES;
@@ -337,8 +283,6 @@ ipg_retry:
* multiple of 8. This is needed to simplify the bitmap
* splicing code.
*/
- if (super->s_inodes_per_group < 8)
- super->s_inodes_per_group = 8;
super->s_inodes_per_group &= ~7;
fs->inode_blocks_per_group = (((super->s_inodes_per_group *
EXT2_INODE_SIZE(super)) +
@@ -394,24 +338,14 @@ ipg_retry:
overhead = (int) (2 + fs->inode_blocks_per_group);
if (ext2fs_bg_has_super(fs, fs->group_desc_count - 1))
overhead += 1 + fs->desc_blocks + super->s_reserved_gdt_blocks;
- rem = ((ext2fs_blocks_count(super) - super->s_first_data_block) %
+ rem = ((super->s_blocks_count - super->s_first_data_block) %
super->s_blocks_per_group);
if ((fs->group_desc_count == 1) && rem && (rem < overhead)) {
retval = EXT2_ET_TOOSMALL;
goto cleanup;
}
if (rem && (rem < overhead+50)) {
- ext2fs_blocks_count_set(super, ext2fs_blocks_count(super) -
- rem);
- /*
- * If blocks count is changed, we need to recalculate
- * reserved blocks count not to exceed 50%.
- */
- reserved_ratio = 100.0 * ext2fs_r_blocks_count(param) /
- ext2fs_blocks_count(param);
- ext2fs_r_blocks_count_set(super, reserved_ratio *
- ext2fs_blocks_count(super) / 100.0);
-
+ super->s_blocks_count -= rem;
goto retry;
}
@@ -427,7 +361,7 @@ ipg_retry:
strcpy(buf, "block bitmap for ");
strcat(buf, fs->device_name);
- retval = ext2fs_allocate_subcluster_bitmap(fs, buf, &fs->block_map);
+ retval = ext2fs_allocate_block_bitmap(fs, buf, &fs->block_map);
if (retval)
goto cleanup;
@@ -457,10 +391,9 @@ ipg_retry:
* superblock and group descriptors (the inode tables and
* bitmaps will be accounted for when allocated).
*/
- free_blocks = 0;
+ super->s_free_blocks_count = 0;
csum_flag = EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
EXT4_FEATURE_RO_COMPAT_GDT_CSUM);
- reserved_inos = super->s_first_ino;
for (i = 0; i < fs->group_desc_count; i++) {
/*
* Don't set the BLOCK_UNINIT group for the last group
@@ -468,33 +401,25 @@ ipg_retry:
*/
if (csum_flag) {
if (i != fs->group_desc_count - 1)
- ext2fs_bg_flags_set(fs, i,
- EXT2_BG_BLOCK_UNINIT);
- ext2fs_bg_flags_set(fs, i, EXT2_BG_INODE_UNINIT);
+ fs->group_desc[i].bg_flags |=
+ EXT2_BG_BLOCK_UNINIT;
+ fs->group_desc[i].bg_flags |= EXT2_BG_INODE_UNINIT;
numblocks = super->s_inodes_per_group;
- if (reserved_inos) {
- if (numblocks > reserved_inos) {
- numblocks -= reserved_inos;
- reserved_inos = 0;
- } else {
- reserved_inos -= numblocks;
- numblocks = 0;
- }
- }
- ext2fs_bg_itable_unused_set(fs, i, numblocks);
+ if (i == 0)
+ numblocks -= super->s_first_ino;
+ fs->group_desc[i].bg_itable_unused = numblocks;
}
numblocks = ext2fs_reserve_super_and_bgd(fs, i, fs->block_map);
if (fs->super->s_log_groups_per_flex)
numblocks += 2 + fs->inode_blocks_per_group;
- free_blocks += numblocks;
- ext2fs_bg_free_blocks_count_set(fs, i, numblocks);
- ext2fs_bg_free_inodes_count_set(fs, i, fs->super->s_inodes_per_group);
- ext2fs_bg_used_dirs_count_set(fs, i, 0);
+ super->s_free_blocks_count += numblocks;
+ fs->group_desc[i].bg_free_blocks_count = numblocks;
+ fs->group_desc[i].bg_free_inodes_count =
+ fs->super->s_inodes_per_group;
+ fs->group_desc[i].bg_used_dirs_count = 0;
ext2fs_group_desc_csum_set(fs, i);
}
- free_blocks &= ~EXT2FS_CLUSTER_MASK(fs);
- ext2fs_free_blocks_count_set(super, free_blocks);
c = (char) 255;
if (((int) c) == -1) {
diff --git a/lib/ext2fs/inline.c b/lib/ext2fs/inline.c
index 4d0f4ad1..f9be368b 100644
--- a/lib/ext2fs/inline.c
+++ b/lib/ext2fs/inline.c
@@ -11,9 +11,6 @@
* %End-Header%
*/
-#ifndef _XOPEN_SOURCE
-#define _XOPEN_SOURCE 600 /* for posix_memalign() */
-#endif
#include <stdio.h>
#include <string.h>
@@ -28,93 +25,8 @@
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
-#ifdef HAVE_MALLOC_H
-#include <malloc.h>
-#endif
#include "ext2_fs.h"
#define INCLUDE_INLINE_FUNCS
#include "ext2fs.h"
-/*
- * We used to define this as an inline, but since we are now using
- * autoconf-defined #ifdef's, we need to export this as a
- * library-provided function exclusively.
- */
-errcode_t ext2fs_get_memalign(unsigned long size,
- unsigned long align, void *ptr)
-{
- errcode_t retval;
- void **p = ptr;
-
- if (align < 8)
- align = 8;
-#ifdef HAVE_POSIX_MEMALIGN
- retval = posix_memalign(p, align, size);
- if (retval) {
- if (retval == ENOMEM)
- return EXT2_ET_NO_MEMORY;
- return retval;
- }
-#else
-#ifdef HAVE_MEMALIGN
- *p = memalign(align, size);
- if (*p == NULL) {
- if (errno)
- return errno;
- else
- return EXT2_ET_NO_MEMORY;
- }
-#else
-#ifdef HAVE_VALLOC
- if (align > sizeof(long long))
- *p = valloc(size);
- else
-#endif
- *p = malloc(size);
- if ((unsigned long) *p & (align - 1)) {
- free(*p);
- *p = 0;
- }
- if (*p == 0)
- return EXT2_ET_NO_MEMORY;
-#endif
-#endif
- return 0;
-}
-
-#ifdef DEBUG
-static int isaligned(void *ptr, unsigned long align)
-{
- return (((unsigned long) ptr & (align - 1)) == 0);
-}
-
-static errcode_t test_memalign(unsigned long align)
-{
- void *ptr = 0;
- errcode_t retval;
-
- retval = ext2fs_get_memalign(32, align, &ptr);
- if (!retval && !isaligned(ptr, align))
- retval = EINVAL;
- free(ptr);
- printf("tst_memalign(%lu) is %s\n", align,
- retval ? error_message(retval) : "OK");
- return retval;
-}
-
-int main(int argc, char **argv)
-{
- int err = 0;
-
- if (test_memalign(4))
- err++;
- if (test_memalign(32))
- err++;
- if (test_memalign(1024))
- err++;
- if (test_memalign(4096))
- err++;
- return err;
-}
-#endif
diff --git a/lib/ext2fs/inode.c b/lib/ext2fs/inode.c
index d0b528cf..5088f9bb 100644
--- a/lib/ext2fs/inode.c
+++ b/lib/ext2fs/inode.c
@@ -33,7 +33,7 @@ struct ext2_struct_inode_scan {
errcode_t magic;
ext2_filsys fs;
ext2_ino_t current_inode;
- blk64_t current_block;
+ blk_t current_block;
dgrp_t current_group;
ext2_ino_t inodes_left;
blk_t blocks_left;
@@ -143,21 +143,21 @@ errcode_t ext2fs_open_inode_scan(ext2_filsys fs, int buffer_blocks,
scan->current_group = 0;
scan->groups_left = fs->group_desc_count - 1;
scan->inode_buffer_blocks = buffer_blocks ? buffer_blocks : 8;
- scan->current_block = ext2fs_inode_table_loc(scan->fs,
- scan->current_group);
+ scan->current_block = scan->fs->
+ group_desc[scan->current_group].bg_inode_table;
scan->inodes_left = EXT2_INODES_PER_GROUP(scan->fs->super);
scan->blocks_left = scan->fs->inode_blocks_per_group;
if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) {
scan->inodes_left -=
- ext2fs_bg_itable_unused(fs, scan->current_group);
+ fs->group_desc[scan->current_group].bg_itable_unused;
scan->blocks_left =
(scan->inodes_left +
(fs->blocksize / scan->inode_size - 1)) *
scan->inode_size / fs->blocksize;
}
- retval = io_channel_alloc_buf(fs->io, scan->inode_buffer_blocks,
- &scan->inode_buffer);
+ retval = ext2fs_get_memalign(scan->inode_buffer_blocks * fs->blocksize,
+ fs->blocksize, &scan->inode_buffer);
scan->done_group = 0;
scan->done_group_data = 0;
scan->bad_block_ptr = 0;
@@ -232,8 +232,8 @@ static errcode_t get_next_blockgroup(ext2_inode_scan scan)
scan->current_group++;
scan->groups_left--;
- scan->current_block = ext2fs_inode_table_loc(scan->fs,
- scan->current_group);
+ scan->current_block =fs->group_desc[scan->current_group].bg_inode_table;
+
scan->current_inode = scan->current_group *
EXT2_INODES_PER_GROUP(fs->super);
@@ -243,7 +243,7 @@ static errcode_t get_next_blockgroup(ext2_inode_scan scan)
if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) {
scan->inodes_left -=
- ext2fs_bg_itable_unused(fs, scan->current_group);
+ fs->group_desc[scan->current_group].bg_itable_unused;
scan->blocks_left =
(scan->inodes_left +
(fs->blocksize / scan->inode_size - 1)) *
@@ -269,9 +269,9 @@ errcode_t ext2fs_inode_scan_goto_blockgroup(ext2_inode_scan scan,
* increasing order.
*/
static errcode_t check_for_inode_bad_blocks(ext2_inode_scan scan,
- blk64_t *num_blocks)
+ blk_t *num_blocks)
{
- blk64_t blk = scan->current_block;
+ blk_t blk = scan->current_block;
badblocks_list bb = scan->fs->badblocks;
/*
@@ -328,7 +328,7 @@ static errcode_t check_for_inode_bad_blocks(ext2_inode_scan scan,
*/
static errcode_t get_next_blocks(ext2_inode_scan scan)
{
- blk64_t num_blocks;
+ blk_t num_blocks;
errcode_t retval;
/*
@@ -364,7 +364,7 @@ static errcode_t get_next_blocks(ext2_inode_scan scan)
memset(scan->inode_buffer, 0,
(size_t) num_blocks * scan->fs->blocksize);
} else {
- retval = io_channel_read_blk64(scan->fs->io,
+ retval = io_channel_read_blk(scan->fs->io,
scan->current_block,
(int) num_blocks,
scan->inode_buffer);
@@ -434,8 +434,8 @@ errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, ext2_ino_t *ino,
* they can be done for block group #0.
*/
if ((scan->scan_flags & EXT2_SF_DO_LAZY) &&
- (ext2fs_bg_flags_test(scan->fs, scan->current_group, EXT2_BG_INODE_UNINIT)
- ))
+ (scan->fs->group_desc[scan->current_group].bg_flags &
+ EXT2_BG_INODE_UNINIT))
goto force_new_group;
if (scan->inodes_left == 0)
goto force_new_group;
@@ -522,8 +522,7 @@ errcode_t ext2fs_get_next_inode(ext2_inode_scan scan, ext2_ino_t *ino,
errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode * inode, int bufsize)
{
- blk64_t block_nr;
- unsigned long group, block, offset;
+ unsigned long group, block, block_nr, offset;
char *ptr;
errcode_t retval;
int clen, i, inodes_per_block, length;
@@ -532,9 +531,7 @@ errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino,
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
/* Check to see if user has an override function */
- if (fs->read_inode &&
- ((bufsize == sizeof(struct ext2_inode)) ||
- (EXT2_INODE_SIZE(fs->super) == sizeof(struct ext2_inode)))) {
+ if (fs->read_inode) {
retval = (fs->read_inode)(fs, ino, inode);
if (retval != EXT2_ET_CALLBACK_NOTHANDLED)
return retval;
@@ -571,9 +568,9 @@ errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino,
offset = ((ino - 1) % EXT2_INODES_PER_GROUP(fs->super)) *
EXT2_INODE_SIZE(fs->super);
block = offset >> EXT2_BLOCK_SIZE_BITS(fs->super);
- if (!ext2fs_inode_table_loc(fs, (unsigned) group))
+ if (!fs->group_desc[(unsigned)group].bg_inode_table)
return EXT2_ET_MISSING_INODE_TABLE;
- block_nr = ext2fs_inode_table_loc(fs, group) +
+ block_nr = fs->group_desc[(unsigned)group].bg_inode_table +
block;
io = fs->io;
}
@@ -590,7 +587,7 @@ errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino,
clen = fs->blocksize - offset;
if (block_nr != fs->icache->buffer_blk) {
- retval = io_channel_read_blk64(io, block_nr, 1,
+ retval = io_channel_read_blk(io, block_nr, 1,
fs->icache->buffer);
if (retval)
return retval;
@@ -631,8 +628,7 @@ errcode_t ext2fs_read_inode(ext2_filsys fs, ext2_ino_t ino,
errcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode * inode, int bufsize)
{
- blk64_t block_nr;
- unsigned long group, block, offset;
+ unsigned long group, block, block_nr, offset;
errcode_t retval = 0;
struct ext2_inode_large temp_inode, *w_inode;
char *ptr;
@@ -673,10 +669,8 @@ errcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino,
if (length > (int) sizeof(struct ext2_inode_large)) {
w_inode = malloc(length);
- if (!w_inode) {
- retval = ENOMEM;
- goto errout;
- }
+ if (!w_inode)
+ return ENOMEM;
} else
w_inode = &temp_inode;
memset(w_inode, 0, length);
@@ -693,11 +687,11 @@ errcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino,
offset = ((ino - 1) % EXT2_INODES_PER_GROUP(fs->super)) *
EXT2_INODE_SIZE(fs->super);
block = offset >> EXT2_BLOCK_SIZE_BITS(fs->super);
- if (!ext2fs_inode_table_loc(fs, (unsigned) group)) {
+ if (!fs->group_desc[(unsigned) group].bg_inode_table) {
retval = EXT2_ET_MISSING_INODE_TABLE;
goto errout;
}
- block_nr = ext2fs_inode_table_loc(fs, (unsigned) group) + block;
+ block_nr = fs->group_desc[(unsigned) group].bg_inode_table + block;
offset &= (EXT2_BLOCK_SIZE(fs->super) - 1);
@@ -713,7 +707,7 @@ errcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino,
clen = fs->blocksize - offset;
if (fs->icache->buffer_blk != block_nr) {
- retval = io_channel_read_blk64(fs->io, block_nr, 1,
+ retval = io_channel_read_blk(fs->io, block_nr, 1,
fs->icache->buffer);
if (retval)
goto errout;
@@ -724,7 +718,7 @@ errcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino,
memcpy((char *) fs->icache->buffer + (unsigned) offset,
ptr, clen);
- retval = io_channel_write_blk64(fs->io, block_nr, 1,
+ retval = io_channel_write_blk(fs->io, block_nr, 1,
fs->icache->buffer);
if (retval)
goto errout;
diff --git a/lib/ext2fs/inode_io.c b/lib/ext2fs/inode_io.c
index ced32448..4faaa487 100644
--- a/lib/ext2fs/inode_io.c
+++ b/lib/ext2fs/inode_io.c
@@ -163,10 +163,9 @@ static errcode_t inode_open(const char *name, int flags, io_channel *channel)
return 0;
cleanup:
- if (io && io->name)
- ext2fs_free_mem(&io->name);
- if (data)
+ if (data) {
ext2fs_free_mem(&data);
+ }
if (io)
ext2fs_free_mem(&io);
return retval;
diff --git a/lib/ext2fs/io_manager.c b/lib/ext2fs/io_manager.c
index 116f2aea..6d0e2343 100644
--- a/lib/ext2fs/io_manager.c
+++ b/lib/ext2fs/io_manager.c
@@ -99,31 +99,3 @@ errcode_t io_channel_write_blk64(io_channel channel, unsigned long long block,
return (channel->manager->write_blk)(channel, (unsigned long) block,
count, data);
}
-
-errcode_t io_channel_discard(io_channel channel, unsigned long long block,
- unsigned long long count)
-{
- EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
-
- if (channel->manager->discard)
- return (channel->manager->discard)(channel, block, count);
-
- return EXT2_ET_UNIMPLEMENTED;
-}
-
-errcode_t io_channel_alloc_buf(io_channel io, int count, void *ptr)
-{
- size_t size;
-
- if (count == 0)
- size = io->block_size;
- else if (count > 0)
- size = io->block_size * count;
- else
- size = -count;
-
- if (io->align)
- return ext2fs_get_memalign(size, io->align, ptr);
- else
- return ext2fs_get_mem(size, ptr);
-}
diff --git a/lib/ext2fs/irel.h b/lib/ext2fs/irel.h
index 8aaa2d2b..9a4958be 100644
--- a/lib/ext2fs/irel.h
+++ b/lib/ext2fs/irel.h
@@ -10,7 +10,7 @@
*/
struct ext2_inode_reference {
- blk64_t block;
+ blk_t block;
__u16 offset;
};
diff --git a/lib/ext2fs/ismounted.c b/lib/ext2fs/ismounted.c
index db80c460..2e9df4e0 100644
--- a/lib/ext2fs/ismounted.c
+++ b/lib/ext2fs/ismounted.c
@@ -20,13 +20,6 @@
#ifdef HAVE_LINUX_FD_H
#include <linux/fd.h>
#endif
-#ifdef HAVE_LINUX_LOOP_H
-#include <linux/loop.h>
-#include <sys/ioctl.h>
-#ifdef HAVE_LINUX_MAJOR_H
-#include <linux/major.h>
-#endif /* HAVE_LINUX_MAJOR_H */
-#endif /* HAVE_LINUX_LOOP_H */
#ifdef HAVE_MNTENT_H
#include <mntent.h>
#endif
@@ -41,37 +34,7 @@
#include "ext2_fs.h"
#include "ext2fs.h"
-/*
- * Check to see if a regular file is mounted.
- * If /etc/mtab/ is a symlink of /proc/mounts, you will need the following check
- * because the name in /proc/mounts is a loopback device not a regular file.
- */
-static int check_loop_mounted(const char *mnt_fsname, dev_t mnt_rdev,
- dev_t file_dev, ino_t file_ino)
-{
-#if defined(HAVE_LINUX_LOOP_H) && defined(HAVE_LINUX_MAJOR_H)
- struct loop_info64 loopinfo;
- int loop_fd, ret;
-
- if (major(mnt_rdev) == LOOP_MAJOR) {
- loop_fd = open(mnt_fsname, O_RDONLY);
- if (loop_fd < 0)
- return -1;
-
- ret = ioctl(loop_fd, LOOP_GET_STATUS64, &loopinfo);
- close(loop_fd);
- if (ret < 0)
- return -1;
-
- if (file_dev == loopinfo.lo_device &&
- file_ino == loopinfo.lo_inode)
- return 1;
- }
-#endif /* defined(HAVE_LINUX_LOOP_H) && defined(HAVE_LINUX_MAJOR_H) */
- return 0;
-}
-
-#ifdef HAVE_SETMNTENT
+#ifdef HAVE_MNTENT_H
/*
* Helper function which checks a file in /etc/mtab format to see if a
* filesystem is mounted. Returns an error if the file doesn't exist
@@ -89,15 +52,8 @@ static errcode_t check_mntent_file(const char *mtab_file, const char *file,
int fd;
*mount_flags = 0;
- if ((f = setmntent (mtab_file, "r")) == NULL) {
- if (errno == ENOENT) {
- if (getenv("EXT2FS_NO_MTAB_OK"))
- return 0;
- else
- return EXT2_ET_NO_MTAB_FILE;
- }
- return errno;
- }
+ if ((f = setmntent (mtab_file, "r")) == NULL)
+ return (errno == ENOENT ? EXT2_NO_MTAB_FILE : errno);
if (stat(file, &st_buf) == 0) {
if (S_ISBLK(st_buf.st_mode)) {
#ifndef __GNU__ /* The GNU hurd is broken with respect to stat devices */
@@ -118,10 +74,6 @@ static errcode_t check_mntent_file(const char *mtab_file, const char *file,
#ifndef __GNU__
if (file_rdev && (file_rdev == st_buf.st_rdev))
break;
- if (check_loop_mounted(mnt->mnt_fsname,
- st_buf.st_rdev, file_dev,
- file_ino) == 1)
- break;
#endif /* __GNU__ */
} else {
if (file_dev && ((file_dev == st_buf.st_dev) &&
@@ -278,7 +230,7 @@ static errcode_t check_getmntinfo(const char *file, int *mount_flags,
return 0;
}
#endif /* HAVE_GETMNTINFO */
-#endif /* HAVE_SETMNTENT */
+#endif /* HAVE_MNTENT_H */
/*
* Check to see if we're dealing with the swap device.
@@ -349,13 +301,15 @@ leave:
errcode_t ext2fs_check_mount_point(const char *device, int *mount_flags,
char *mtpt, int mtlen)
{
+ struct stat st_buf;
errcode_t retval = 0;
+ int fd;
if (is_swap_device(device)) {
*mount_flags = EXT2_MF_MOUNTED | EXT2_MF_SWAP;
strncpy(mtpt, "<swap>", mtlen);
} else {
-#ifdef HAVE_SETMNTENT
+#ifdef HAVE_MNTENT_H
retval = check_mntent(device, mount_flags, mtpt, mtlen);
#else
#ifdef HAVE_GETMNTINFO
@@ -366,24 +320,21 @@ errcode_t ext2fs_check_mount_point(const char *device, int *mount_flags,
#endif
*mount_flags = 0;
#endif /* HAVE_GETMNTINFO */
-#endif /* HAVE_SETMNTENT */
+#endif /* HAVE_MNTENT_H */
}
if (retval)
return retval;
#ifdef __linux__ /* This only works on Linux 2.6+ systems */
- {
- struct stat st_buf;
-
- if (stat(device, &st_buf) == 0 && S_ISBLK(st_buf.st_mode)) {
- int fd = open(device, O_RDONLY | O_EXCL);
-
- if (fd >= 0)
- close(fd);
- else if (errno == EBUSY)
- *mount_flags |= EXT2_MF_BUSY;
- }
- }
+ if ((stat(device, &st_buf) != 0) ||
+ !S_ISBLK(st_buf.st_mode))
+ return 0;
+ fd = open(device, O_RDONLY | O_EXCL);
+ if (fd < 0) {
+ if (errno == EBUSY)
+ *mount_flags |= EXT2_MF_BUSY;
+ } else
+ close(fd);
#endif
return 0;
diff --git a/lib/ext2fs/kernel-jbd.h b/lib/ext2fs/kernel-jbd.h
index 059bf8fa..331b0e47 100644
--- a/lib/ext2fs/kernel-jbd.h
+++ b/lib/ext2fs/kernel-jbd.h
@@ -214,13 +214,13 @@ typedef struct journal_superblock_s
#define JFS_HAS_COMPAT_FEATURE(j,mask) \
((j)->j_format_version >= 2 && \
- ((j)->j_superblock->s_feature_compat & ext2fs_cpu_to_be32((mask))))
+ ((j)->j_superblock->s_feature_compat & cpu_to_be32((mask))))
#define JFS_HAS_RO_COMPAT_FEATURE(j,mask) \
((j)->j_format_version >= 2 && \
- ((j)->j_superblock->s_feature_ro_compat & ext2fs_cpu_to_be32((mask))))
+ ((j)->j_superblock->s_feature_ro_compat & cpu_to_be32((mask))))
#define JFS_HAS_INCOMPAT_FEATURE(j,mask) \
((j)->j_format_version >= 2 && \
- ((j)->j_superblock->s_feature_incompat & ext2fs_cpu_to_be32((mask))))
+ ((j)->j_superblock->s_feature_incompat & cpu_to_be32((mask))))
#define JFS_FEATURE_COMPAT_CHECKSUM 0x00000001
@@ -234,8 +234,7 @@ typedef struct journal_superblock_s
#define JFS_KNOWN_COMPAT_FEATURES 0
#define JFS_KNOWN_ROCOMPAT_FEATURES 0
#define JFS_KNOWN_INCOMPAT_FEATURES (JFS_FEATURE_INCOMPAT_REVOKE|\
- JFS_FEATURE_INCOMPAT_ASYNC_COMMIT|\
- JFS_FEATURE_INCOMPAT_64BIT)
+ JFS_FEATURE_INCOMPAT_ASYNC_COMMIT)
#ifdef __KERNEL__
diff --git a/lib/ext2fs/kernel-list.h b/lib/ext2fs/kernel-list.h
index 01f4f6b9..e07d06b6 100644
--- a/lib/ext2fs/kernel-list.h
+++ b/lib/ext2fs/kernel-list.h
@@ -17,6 +17,9 @@ struct list_head {
#define LIST_HEAD_INIT(name) { &(name), &(name) }
+#define LIST_HEAD(name) \
+ struct list_head name = { &name, &name }
+
#define INIT_LIST_HEAD(ptr) do { \
(ptr)->next = (ptr); (ptr)->prev = (ptr); \
} while (0)
diff --git a/lib/ext2fs/link.c b/lib/ext2fs/link.c
index 8c5553c9..4cc8426a 100644
--- a/lib/ext2fs/link.c
+++ b/lib/ext2fs/link.c
@@ -41,9 +41,6 @@ static int link_proc(struct ext2_dir_entry *dirent,
unsigned int rec_len, min_rec_len, curr_rec_len;
int ret = 0;
- if (ls->done)
- return DIRENT_ABORT;
-
rec_len = EXT2_DIR_REC_LEN(ls->namelen);
ls->err = ext2fs_get_rec_len(ls->fs, dirent, &curr_rec_len);
@@ -55,9 +52,9 @@ static int link_proc(struct ext2_dir_entry *dirent,
* if so, absorb it into this one.
*/
next = (struct ext2_dir_entry *) (buf + offset + curr_rec_len);
- if ((offset + (int) curr_rec_len < blocksize - 8) &&
+ if ((offset + curr_rec_len < blocksize - 8) &&
(next->inode == 0) &&
- (offset + (int) curr_rec_len + (int) next->rec_len <= blocksize)) {
+ (offset + curr_rec_len + next->rec_len <= blocksize)) {
curr_rec_len += next->rec_len;
ls->err = ext2fs_set_rec_len(ls->fs, curr_rec_len, dirent);
if (ls->err)
diff --git a/lib/ext2fs/llseek.c b/lib/ext2fs/llseek.c
index 774d1d4d..7855590b 100644
--- a/lib/ext2fs/llseek.c
+++ b/lib/ext2fs/llseek.c
@@ -89,14 +89,17 @@ static ext2_loff_t my_llseek (int fd, ext2_loff_t offset, int origin)
ext2_loff_t ext2fs_llseek (int fd, ext2_loff_t offset, int origin)
{
-#if SIZEOF_OFF_T >= SIZEOF_LONG_LONG
- return lseek (fd, offset, origin);
-#else
ext2_loff_t result;
static int do_compat = 0;
- if (do_compat)
- goto fallback;
+ 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) {
+ errno = EINVAL;
+ return -1;
+ }
result = my_llseek (fd, offset, origin);
if (result == -1 && errno == ENOSYS) {
@@ -105,14 +108,9 @@ ext2_loff_t ext2fs_llseek (int fd, ext2_loff_t offset, int origin)
* which does not support the llseek system call
*/
do_compat++;
- fallback:
- if (offset < ((ext2_loff_t) 1 << ((sizeof(off_t)*8) -1)))
- return lseek(fd, (off_t) offset, origin);
errno = EINVAL;
- return -1;
}
return result;
-#endif
}
#else /* !linux */
diff --git a/lib/ext2fs/mkdir.c b/lib/ext2fs/mkdir.c
index 9b6b7996..549ff6a3 100644
--- a/lib/ext2fs/mkdir.c
+++ b/lib/ext2fs/mkdir.c
@@ -33,12 +33,11 @@
errcode_t ext2fs_mkdir(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t inum,
const char *name)
{
- ext2_extent_handle_t handle;
errcode_t retval;
struct ext2_inode parent_inode, inode;
ext2_ino_t ino = inum;
ext2_ino_t scratch_ino;
- blk64_t blk;
+ blk_t blk;
char *block = 0;
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
@@ -56,7 +55,7 @@ errcode_t ext2fs_mkdir(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t inum,
/*
* Allocate a data block for the directory
*/
- retval = ext2fs_new_block2(fs, 0, 0, &blk);
+ retval = ext2fs_new_block(fs, 0, 0, &blk);
if (retval)
goto cleanup;
@@ -84,10 +83,7 @@ errcode_t ext2fs_mkdir(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t inum,
inode.i_mode = LINUX_S_IFDIR | (0777 & ~fs->umask);
inode.i_uid = inode.i_gid = 0;
ext2fs_iblk_set(fs, &inode, 1);
- if (fs->super->s_feature_incompat & EXT3_FEATURE_INCOMPAT_EXTENTS)
- inode.i_flags |= EXT4_EXTENTS_FL;
- else
- inode.i_block[0] = blk;
+ inode.i_block[0] = blk;
inode.i_links_count = 2;
inode.i_size = fs->blocksize;
@@ -101,16 +97,6 @@ errcode_t ext2fs_mkdir(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t inum,
if (retval)
goto cleanup;
- if (fs->super->s_feature_incompat & EXT3_FEATURE_INCOMPAT_EXTENTS) {
- retval = ext2fs_extent_open2(fs, ino, &inode, &handle);
- if (retval)
- goto cleanup;
- retval = ext2fs_extent_set_bmap(handle, 0, blk, 0);
- ext2fs_extent_free(handle);
- if (retval)
- goto cleanup;
- }
-
/*
* Link the directory into the filesystem hierarchy
*/
@@ -142,7 +128,7 @@ errcode_t ext2fs_mkdir(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t inum,
/*
* Update accounting....
*/
- ext2fs_block_alloc_stats2(fs, blk, +1);
+ ext2fs_block_alloc_stats(fs, blk, +1);
ext2fs_inode_alloc_stats2(fs, ino, +1, 1);
cleanup:
diff --git a/lib/ext2fs/mkjournal.c b/lib/ext2fs/mkjournal.c
index 02ffb97c..4a81f4b2 100644
--- a/lib/ext2fs/mkjournal.c
+++ b/lib/ext2fs/mkjournal.c
@@ -42,13 +42,13 @@
* returns it as an allocated block.
*/
errcode_t ext2fs_create_journal_superblock(ext2_filsys fs,
- __u32 num_blocks, int flags,
+ __u32 size, int flags,
char **ret_jsb)
{
errcode_t retval;
journal_superblock_t *jsb;
- if (num_blocks < 1024)
+ if (size < 1024)
return EXT2_ET_JOURNAL_TOO_SMALL;
if ((retval = ext2fs_get_mem(fs->blocksize, &jsb)))
@@ -62,7 +62,7 @@ errcode_t ext2fs_create_journal_superblock(ext2_filsys fs,
else
jsb->s_header.h_blocktype = htonl(JFS_SUPERBLOCK_V2);
jsb->s_blocksize = htonl(fs->blocksize);
- jsb->s_maxlen = htonl(num_blocks);
+ jsb->s_maxlen = htonl(size);
jsb->s_nr_users = htonl(1);
jsb->s_first = htonl(1);
jsb->s_sequence = htonl(1);
@@ -90,21 +90,20 @@ errcode_t ext2fs_create_journal_superblock(ext2_filsys fs,
* filesystems.
*/
static errcode_t write_journal_file(ext2_filsys fs, char *filename,
- blk_t num_blocks, int flags)
+ blk_t size, int flags)
{
errcode_t retval;
char *buf = 0;
int fd, ret_size;
blk_t i;
- if ((retval = ext2fs_create_journal_superblock(fs, num_blocks, flags,
- &buf)))
+ if ((retval = ext2fs_create_journal_superblock(fs, size, flags, &buf)))
return retval;
/* Open the device or journal file */
if ((fd = open(filename, O_WRONLY)) < 0) {
retval = errno;
- goto errfree;
+ goto errout;
}
/* Write the superblock out */
@@ -118,10 +117,7 @@ static errcode_t write_journal_file(ext2_filsys fs, char *filename,
goto errout;
memset(buf, 0, fs->blocksize);
- if (flags & EXT2_MKJOURNAL_LAZYINIT)
- goto success;
-
- for (i = 1; i < num_blocks; i++) {
+ for (i = 1; i < size; i++) {
ret_size = write(fd, buf, fs->blocksize);
if (ret_size < 0) {
retval = errno;
@@ -130,12 +126,10 @@ static errcode_t write_journal_file(ext2_filsys fs, char *filename,
if (ret_size != (int) fs->blocksize)
goto errout;
}
+ close(fd);
-success:
retval = 0;
errout:
- close(fd);
-errfree:
ext2fs_free_mem(&buf);
return retval;
}
@@ -151,8 +145,8 @@ errfree:
* programs that check for memory leaks happy.)
*/
#define STRIDE_LENGTH 8
-errcode_t ext2fs_zero_blocks2(ext2_filsys fs, blk64_t blk, int num,
- blk64_t *ret_blk, int *ret_count)
+errcode_t ext2fs_zero_blocks(ext2_filsys fs, blk_t blk, int num,
+ blk_t *ret_blk, int *ret_count)
{
int j, count;
static char *buf;
@@ -185,7 +179,7 @@ errcode_t ext2fs_zero_blocks2(ext2_filsys fs, blk64_t blk, int num,
if (count > STRIDE_LENGTH)
count = STRIDE_LENGTH;
}
- retval = io_channel_write_blk64(fs->io, blk, count, buf);
+ retval = io_channel_write_blk(fs->io, blk, count, buf);
if (retval) {
if (ret_count)
*ret_count = count;
@@ -198,76 +192,56 @@ errcode_t ext2fs_zero_blocks2(ext2_filsys fs, blk64_t blk, int num,
return 0;
}
-errcode_t ext2fs_zero_blocks(ext2_filsys fs, blk_t blk, int num,
- blk_t *ret_blk, int *ret_count)
-{
- blk64_t ret_blk2;
- errcode_t retval;
-
- retval = ext2fs_zero_blocks2(fs, blk, num, &ret_blk2, ret_count);
- if (retval)
- *ret_blk = (blk_t) ret_blk2;
- return retval;
-}
-
/*
* Helper function for creating the journal using direct I/O routines
*/
struct mkjournal_struct {
int num_blocks;
int newblocks;
- blk64_t goal;
- blk64_t blk_to_zero;
+ blk_t goal;
+ blk_t blk_to_zero;
int zero_count;
- int flags;
char *buf;
errcode_t err;
};
static int mkjournal_proc(ext2_filsys fs,
- blk64_t *blocknr,
- e2_blkcnt_t blockcnt,
- blk64_t ref_block EXT2FS_ATTR((unused)),
- int ref_offset EXT2FS_ATTR((unused)),
- void *priv_data)
+ blk_t *blocknr,
+ e2_blkcnt_t blockcnt,
+ blk_t ref_block EXT2FS_ATTR((unused)),
+ int ref_offset EXT2FS_ATTR((unused)),
+ void *priv_data)
{
struct mkjournal_struct *es = (struct mkjournal_struct *) priv_data;
- blk64_t new_blk;
+ blk_t new_blk;
errcode_t retval;
if (*blocknr) {
es->goal = *blocknr;
return 0;
}
- if (blockcnt &&
- (EXT2FS_B2C(fs, es->goal) == EXT2FS_B2C(fs, es->goal+1)))
- new_blk = es->goal+1;
- else {
- es->goal &= ~EXT2FS_CLUSTER_MASK(fs);
- retval = ext2fs_new_block2(fs, es->goal, 0, &new_blk);
- if (retval) {
- es->err = retval;
- return BLOCK_ABORT;
- }
- ext2fs_block_alloc_stats2(fs, new_blk, +1);
- es->newblocks++;
+ retval = ext2fs_new_block(fs, es->goal, 0, &new_blk);
+ if (retval) {
+ es->err = retval;
+ return BLOCK_ABORT;
}
if (blockcnt >= 0)
es->num_blocks--;
+ es->newblocks++;
retval = 0;
if (blockcnt <= 0)
- retval = io_channel_write_blk64(fs->io, new_blk, 1, es->buf);
- else if (!(es->flags & EXT2_MKJOURNAL_LAZYINIT)) {
+ retval = io_channel_write_blk(fs->io, new_blk, 1, es->buf);
+ else {
if (es->zero_count) {
if ((es->blk_to_zero + es->zero_count == new_blk) &&
(es->zero_count < 1024))
es->zero_count++;
else {
- retval = ext2fs_zero_blocks2(fs,
- es->blk_to_zero,
- es->zero_count,
- 0, 0);
+ retval = ext2fs_zero_blocks(fs,
+ es->blk_to_zero,
+ es->zero_count,
+ 0, 0);
es->zero_count = 0;
}
}
@@ -285,6 +259,7 @@ static int mkjournal_proc(ext2_filsys fs,
return BLOCK_ABORT;
}
*blocknr = es->goal = new_blk;
+ ext2fs_block_alloc_stats(fs, new_blk, +1);
if (es->num_blocks == 0)
return (BLOCK_CHANGED | BLOCK_ABORT);
@@ -297,41 +272,36 @@ static int mkjournal_proc(ext2_filsys fs,
* This function creates a journal using direct I/O routines.
*/
static errcode_t write_journal_inode(ext2_filsys fs, ext2_ino_t journal_ino,
- blk_t num_blocks, int flags)
+ blk_t size, int flags)
{
char *buf;
dgrp_t group, start, end, i, log_flex;
errcode_t retval;
struct ext2_inode inode;
- unsigned long long inode_size;
struct mkjournal_struct es;
- if ((retval = ext2fs_create_journal_superblock(fs, num_blocks, flags,
- &buf)))
+ if ((retval = ext2fs_create_journal_superblock(fs, size, flags, &buf)))
return retval;
if ((retval = ext2fs_read_bitmaps(fs)))
- goto out2;
+ return retval;
if ((retval = ext2fs_read_inode(fs, journal_ino, &inode)))
- goto out2;
+ return retval;
- if (inode.i_blocks > 0) {
- retval = EEXIST;
- goto out2;
- }
+ if (inode.i_blocks > 0)
+ return EEXIST;
- es.num_blocks = num_blocks;
+ es.num_blocks = size;
es.newblocks = 0;
es.buf = buf;
es.err = 0;
- es.flags = flags;
es.zero_count = 0;
if (fs->super->s_feature_incompat & EXT3_FEATURE_INCOMPAT_EXTENTS) {
inode.i_flags |= EXT4_EXTENTS_FL;
if ((retval = ext2fs_write_inode(fs, journal_ino, &inode)))
- goto out2;
+ return retval;
}
/*
@@ -339,13 +309,13 @@ static errcode_t write_journal_inode(ext2_filsys fs, ext2_ino_t journal_ino,
* the filesystem. Pick a group that has the largest number
* of free blocks.
*/
- group = ext2fs_group_of_blk2(fs, (ext2fs_blocks_count(fs->super) -
+ group = ext2fs_group_of_blk(fs, (fs->super->s_blocks_count -
fs->super->s_first_data_block) / 2);
log_flex = 1 << fs->super->s_log_groups_per_flex;
if (fs->super->s_log_groups_per_flex && (group > log_flex)) {
group = group & ~(log_flex - 1);
while ((group < fs->group_desc_count) &&
- ext2fs_bg_free_blocks_count(fs, group) == 0)
+ fs->group_desc[group].bg_free_blocks_count == 0)
group++;
if (group == fs->group_desc_count)
group = 0;
@@ -355,19 +325,21 @@ static errcode_t write_journal_inode(ext2_filsys fs, ext2_ino_t journal_ino,
end = ((group+1) < fs->group_desc_count) ? group+1 : group;
group = start;
for (i=start+1; i <= end; i++)
- if (ext2fs_bg_free_blocks_count(fs, i) >
- ext2fs_bg_free_blocks_count(fs, group))
+ if (fs->group_desc[i].bg_free_blocks_count >
+ fs->group_desc[group].bg_free_blocks_count)
group = i;
- es.goal = ext2fs_group_first_block2(fs, group);
- retval = ext2fs_block_iterate3(fs, journal_ino, BLOCK_FLAG_APPEND,
+ es.goal = (fs->super->s_blocks_per_group * group) +
+ fs->super->s_first_data_block;
+
+ retval = ext2fs_block_iterate2(fs, journal_ino, BLOCK_FLAG_APPEND,
0, mkjournal_proc, &es);
if (es.err) {
retval = es.err;
goto errout;
}
if (es.zero_count) {
- retval = ext2fs_zero_blocks2(fs, es.blk_to_zero,
+ retval = ext2fs_zero_blocks(fs, es.blk_to_zero,
es.zero_count, 0, 0);
if (retval)
goto errout;
@@ -376,12 +348,7 @@ static errcode_t write_journal_inode(ext2_filsys fs, ext2_ino_t journal_ino,
if ((retval = ext2fs_read_inode(fs, journal_ino, &inode)))
goto errout;
- inode_size = (unsigned long long)fs->blocksize * num_blocks;
- inode.i_size = inode_size & 0xFFFFFFFF;
- inode.i_size_high = (inode_size >> 32) & 0xFFFFFFFF;
- if (ext2fs_needs_large_file_feature(inode_size))
- fs->super->s_feature_ro_compat |=
- EXT2_FEATURE_RO_COMPAT_LARGE_FILE;
+ inode.i_size += fs->blocksize * size;
ext2fs_iblk_add_blocks(fs, &inode, es.newblocks);
inode.i_mtime = inode.i_ctime = fs->now ? fs->now : time(0);
inode.i_links_count = 1;
@@ -392,14 +359,11 @@ static errcode_t write_journal_inode(ext2_filsys fs, ext2_ino_t journal_ino,
retval = 0;
memcpy(fs->super->s_jnl_blocks, inode.i_block, EXT2_N_BLOCKS*4);
- fs->super->s_jnl_blocks[15] = inode.i_size_high;
fs->super->s_jnl_blocks[16] = inode.i_size;
fs->super->s_jnl_backup_type = EXT3_JNL_BACKUP_BLOCKS;
ext2fs_mark_super_dirty(fs);
errout:
- ext2fs_zero_blocks2(0, 0, 0, 0, 0);
-out2:
ext2fs_free_mem(&buf);
return retval;
}
@@ -409,17 +373,17 @@ out2:
* in the filesystem. For very small filesystems, it is not reasonable to
* have a journal that fills more than half of the filesystem.
*/
-int ext2fs_default_journal_size(__u64 num_blocks)
+int ext2fs_default_journal_size(__u64 blocks)
{
- if (num_blocks < 2048)
+ if (blocks < 2048)
return -1;
- if (num_blocks < 32768)
+ if (blocks < 32768)
return (1024);
- if (num_blocks < 256*1024)
+ if (blocks < 256*1024)
return (4096);
- if (num_blocks < 512*1024)
+ if (blocks < 512*1024)
return (8192);
- if (num_blocks < 1024*1024)
+ if (blocks < 1024*1024)
return (16384);
return 32768;
}
@@ -447,8 +411,7 @@ errcode_t ext2fs_add_journal_device(ext2_filsys fs, ext2_filsys journal_dev)
start = 1;
if (journal_dev->blocksize == 1024)
start++;
- if ((retval = io_channel_read_blk64(journal_dev->io, start, -1024,
- buf)))
+ if ((retval = io_channel_read_blk(journal_dev->io, start, -1024, buf)))
return retval;
jsb = (journal_superblock_t *) buf;
@@ -473,7 +436,7 @@ errcode_t ext2fs_add_journal_device(ext2_filsys fs, ext2_filsys journal_dev)
}
/* Writeback the journal superblock */
- if ((retval = io_channel_write_blk64(journal_dev->io, start, -1024, buf)))
+ if ((retval = io_channel_write_blk(journal_dev->io, start, -1024, buf)))
return retval;
fs->super->s_journal_inum = 0;
@@ -490,26 +453,20 @@ errcode_t ext2fs_add_journal_device(ext2_filsys fs, ext2_filsys journal_dev)
* POSIX routines if the filesystem is mounted, or using direct I/O
* functions if it is not.
*/
-errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t num_blocks, int flags)
+errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t size, int flags)
{
errcode_t retval;
ext2_ino_t journal_ino;
struct stat st;
char jfile[1024];
- int mount_flags;
+ int mount_flags, f;
int fd = -1;
- if (flags & EXT2_MKJOURNAL_NO_MNT_CHECK)
- mount_flags = 0;
- else if ((retval = ext2fs_check_mount_point(fs->device_name,
- &mount_flags,
- jfile, sizeof(jfile)-10)))
+ if ((retval = ext2fs_check_mount_point(fs->device_name, &mount_flags,
+ jfile, sizeof(jfile)-10)))
return retval;
if (mount_flags & EXT2_MF_MOUNTED) {
-#if HAVE_EXT2_IOCTLS
- int f = 0;
-#endif
strcat(jfile, "/.journal");
/*
@@ -522,10 +479,9 @@ errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t num_blocks, int flags)
#if HAVE_EXT2_IOCTLS
fd = open(jfile, O_RDONLY);
if (fd >= 0) {
- retval = ioctl(fd, EXT2_IOC_SETFLAGS, &f);
+ f = 0;
+ ioctl(fd, EXT2_IOC_SETFLAGS, &f);
close(fd);
- if (retval)
- return retval;
}
#endif
#endif
@@ -534,14 +490,7 @@ errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t num_blocks, int flags)
if ((fd = open(jfile, O_CREAT|O_WRONLY, 0600)) < 0)
return errno;
- /* Note that we can't do lazy journal initialization for mounted
- * filesystems, since the zero writing is also allocating the
- * journal blocks. We could use fallocate, but not all kernels
- * support that, and creating a journal on a mounted ext2
- * filesystems is extremely rare these days... Ignore it. */
- flags &= ~EXT2_MKJOURNAL_LAZYINIT;
-
- if ((retval = write_journal_file(fs, jfile, num_blocks, flags)))
+ if ((retval = write_journal_file(fs, jfile, size, flags)))
goto errout;
/* Get inode number of the journal file */
@@ -581,7 +530,7 @@ errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t num_blocks, int flags)
}
journal_ino = EXT2_JOURNAL_INO;
if ((retval = write_journal_inode(fs, journal_ino,
- num_blocks, flags)))
+ size, flags)))
return retval;
}
@@ -594,7 +543,7 @@ errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t num_blocks, int flags)
ext2fs_mark_super_dirty(fs);
return 0;
errout:
- if (fd >= 0)
+ if (fd > 0)
close(fd);
return retval;
}
@@ -604,7 +553,7 @@ main(int argc, char **argv)
{
errcode_t retval;
char *device_name;
- ext2_filsys fs;
+ ext2_filsys fs;
if (argc < 2) {
fprintf(stderr, "Usage: %s filesystem\n", argv[0]);
@@ -619,7 +568,7 @@ main(int argc, char **argv)
exit(1);
}
- retval = ext2fs_add_journal_inode(fs, 1024, 0);
+ retval = ext2fs_add_journal_inode(fs, 1024);
if (retval) {
com_err(argv[0], retval, "while adding journal to %s",
device_name);
diff --git a/lib/ext2fs/mmp.c b/lib/ext2fs/mmp.c
deleted file mode 100644
index a9eae504..00000000
--- a/lib/ext2fs/mmp.c
+++ /dev/null
@@ -1,397 +0,0 @@
-/*
- * Helper functions for multiple mount protection (MMP).
- *
- * Copyright (C) 2011 Whamcloud, Inc.
- *
- * %Begin-Header%
- * This file may be redistributed under the terms of the GNU Library
- * General Public License, version 2.
- * %End-Header%
- */
-
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
-
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <sys/time.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-#include "ext2fs/ext2_fs.h"
-#include "ext2fs/ext2fs.h"
-
-#ifndef O_DIRECT
-#define O_DIRECT 0
-#endif
-
-errcode_t ext2fs_mmp_read(ext2_filsys fs, blk64_t mmp_blk, void *buf)
-{
- struct mmp_struct *mmp_cmp;
- errcode_t retval = 0;
-
- if ((mmp_blk <= fs->super->s_first_data_block) ||
- (mmp_blk >= ext2fs_blocks_count(fs->super)))
- return EXT2_ET_MMP_BAD_BLOCK;
-
- /* ext2fs_open() reserves fd0,1,2 to avoid stdio collision, so checking
- * mmp_fd <= 0 is OK to validate that the fd is valid. This opens its
- * own fd to read the MMP block to ensure that it is using O_DIRECT,
- * regardless of how the io_manager is doing reads, to avoid caching of
- * the MMP block by the io_manager or the VM. It needs to be fresh. */
- if (fs->mmp_fd <= 0) {
- fs->mmp_fd = open(fs->device_name, O_RDWR | O_DIRECT);
- if (fs->mmp_fd < 0) {
- retval = EXT2_ET_MMP_OPEN_DIRECT;
- goto out;
- }
- }
-
- if (fs->mmp_cmp == NULL) {
- int align = ext2fs_get_dio_alignment(fs->mmp_fd);
-
- retval = ext2fs_get_memalign(fs->blocksize, align,
- &fs->mmp_cmp);
- if (retval)
- return retval;
- }
-
- if ((blk64_t) ext2fs_llseek(fs->mmp_fd, mmp_blk * fs->blocksize,
- SEEK_SET) !=
- mmp_blk * fs->blocksize) {
- retval = EXT2_ET_LLSEEK_FAILED;
- goto out;
- }
-
- if (read(fs->mmp_fd, fs->mmp_cmp, fs->blocksize) != fs->blocksize) {
- retval = EXT2_ET_SHORT_READ;
- goto out;
- }
-
- mmp_cmp = fs->mmp_cmp;
-#ifdef WORDS_BIGENDIAN
- ext2fs_swap_mmp(mmp_cmp);
-#endif
-
- if (buf != NULL && buf != fs->mmp_cmp)
- memcpy(buf, fs->mmp_cmp, fs->blocksize);
-
- if (mmp_cmp->mmp_magic != EXT4_MMP_MAGIC) {
- retval = EXT2_ET_MMP_MAGIC_INVALID;
- goto out;
- }
-
-out:
- return retval;
-}
-
-errcode_t ext2fs_mmp_write(ext2_filsys fs, blk64_t mmp_blk, void *buf)
-{
- struct mmp_struct *mmp_s = buf;
- struct timeval tv;
- errcode_t retval = 0;
-
- gettimeofday(&tv, 0);
- mmp_s->mmp_time = tv.tv_sec;
- fs->mmp_last_written = tv.tv_sec;
-
- if (fs->super->s_mmp_block < fs->super->s_first_data_block ||
- fs->super->s_mmp_block > ext2fs_blocks_count(fs->super))
- return EXT2_ET_MMP_BAD_BLOCK;
-
-#ifdef WORDS_BIGENDIAN
- ext2fs_swap_mmp(mmp_s);
-#endif
-
- /* I was tempted to make this use O_DIRECT and the mmp_fd, but
- * this caused no end of grief, while leaving it as-is works. */
- retval = io_channel_write_blk64(fs->io, mmp_blk, -(int)sizeof(struct mmp_struct), buf);
-
-#ifdef WORDS_BIGENDIAN
- ext2fs_swap_mmp(mmp_s);
-#endif
-
- /* Make sure the block gets to disk quickly */
- io_channel_flush(fs->io);
- return retval;
-}
-
-#ifdef HAVE_SRANDOM
-#define srand(x) srandom(x)
-#define rand() random()
-#endif
-
-unsigned ext2fs_mmp_new_seq(void)
-{
- unsigned new_seq;
- struct timeval tv;
-
- gettimeofday(&tv, 0);
- srand((getpid() << 16) ^ getuid() ^ tv.tv_sec ^ tv.tv_usec);
-
- gettimeofday(&tv, 0);
- /* Crank the random number generator a few times */
- for (new_seq = (tv.tv_sec ^ tv.tv_usec) & 0x1F; new_seq > 0; new_seq--)
- rand();
-
- do {
- new_seq = rand();
- } while (new_seq > EXT4_MMP_SEQ_MAX);
-
- return new_seq;
-}
-
-static errcode_t ext2fs_mmp_reset(ext2_filsys fs)
-{
- struct mmp_struct *mmp_s = NULL;
- errcode_t retval = 0;
-
- if (fs->mmp_buf == NULL) {
- retval = ext2fs_get_mem(fs->blocksize, &fs->mmp_buf);
- if (retval)
- goto out;
- }
-
- memset(fs->mmp_buf, 0, fs->blocksize);
- mmp_s = fs->mmp_buf;
-
- mmp_s->mmp_magic = EXT4_MMP_MAGIC;
- mmp_s->mmp_seq = EXT4_MMP_SEQ_CLEAN;
- mmp_s->mmp_time = 0;
-#if _BSD_SOURCE || _XOPEN_SOURCE >= 500
- gethostname(mmp_s->mmp_nodename, sizeof(mmp_s->mmp_nodename));
-#else
- mmp_s->mmp_nodename[0] = '\0';
-#endif
- strncpy(mmp_s->mmp_bdevname, fs->device_name,
- sizeof(mmp_s->mmp_bdevname));
-
- mmp_s->mmp_check_interval = fs->super->s_mmp_update_interval;
- if (mmp_s->mmp_check_interval < EXT4_MMP_MIN_CHECK_INTERVAL)
- mmp_s->mmp_check_interval = EXT4_MMP_MIN_CHECK_INTERVAL;
-
- retval = ext2fs_mmp_write(fs, fs->super->s_mmp_block, fs->mmp_buf);
-out:
- return retval;
-}
-
-errcode_t ext2fs_mmp_clear(ext2_filsys fs)
-{
- errcode_t retval = 0;
-
- if (!(fs->flags & EXT2_FLAG_RW))
- return EXT2_ET_RO_FILSYS;
-
- retval = ext2fs_mmp_reset(fs);
-
- return retval;
-}
-
-errcode_t ext2fs_mmp_init(ext2_filsys fs)
-{
- struct ext2_super_block *sb = fs->super;
- blk64_t mmp_block;
- errcode_t retval;
-
- if (sb->s_mmp_update_interval == 0)
- sb->s_mmp_update_interval = EXT4_MMP_UPDATE_INTERVAL;
- /* This is probably excessively large, but who knows? */
- else if (sb->s_mmp_update_interval > EXT4_MMP_MAX_UPDATE_INTERVAL)
- return EXT2_ET_INVALID_ARGUMENT;
-
- if (fs->mmp_buf == NULL) {
- retval = ext2fs_get_mem(fs->blocksize, &fs->mmp_buf);
- if (retval)
- goto out;
- }
-
- retval = ext2fs_alloc_block2(fs, 0, fs->mmp_buf, &mmp_block);
- if (retval)
- goto out;
-
- sb->s_mmp_block = mmp_block;
-
- retval = ext2fs_mmp_reset(fs);
- if (retval)
- goto out;
-
-out:
- return retval;
-}
-
-/*
- * Make sure that the fs is not mounted or being fsck'ed while opening the fs.
- */
-errcode_t ext2fs_mmp_start(ext2_filsys fs)
-{
- struct mmp_struct *mmp_s;
- unsigned seq;
- unsigned int mmp_check_interval;
- errcode_t retval = 0;
-
- if (fs->mmp_buf == NULL) {
- retval = ext2fs_get_mem(fs->blocksize, &fs->mmp_buf);
- if (retval)
- goto mmp_error;
- }
-
- retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, fs->mmp_buf);
- if (retval)
- goto mmp_error;
-
- mmp_s = fs->mmp_buf;
-
- mmp_check_interval = fs->super->s_mmp_update_interval;
- if (mmp_check_interval < EXT4_MMP_MIN_CHECK_INTERVAL)
- mmp_check_interval = EXT4_MMP_MIN_CHECK_INTERVAL;
-
- seq = mmp_s->mmp_seq;
- if (seq == EXT4_MMP_SEQ_CLEAN)
- goto clean_seq;
- if (seq == EXT4_MMP_SEQ_FSCK) {
- retval = EXT2_ET_MMP_FSCK_ON;
- goto mmp_error;
- }
-
- if (seq > EXT4_MMP_SEQ_FSCK) {
- retval = EXT2_ET_MMP_UNKNOWN_SEQ;
- goto mmp_error;
- }
-
- /*
- * If check_interval in MMP block is larger, use that instead of
- * check_interval from the superblock.
- */
- if (mmp_s->mmp_check_interval > mmp_check_interval)
- mmp_check_interval = mmp_s->mmp_check_interval;
-
- sleep(2 * mmp_check_interval + 1);
-
- retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, fs->mmp_buf);
- if (retval)
- goto mmp_error;
-
- if (seq != mmp_s->mmp_seq) {
- retval = EXT2_ET_MMP_FAILED;
- goto mmp_error;
- }
-
-clean_seq:
- if (!(fs->flags & EXT2_FLAG_RW))
- goto mmp_error;
-
- mmp_s->mmp_seq = seq = ext2fs_mmp_new_seq();
-#if _BSD_SOURCE || _XOPEN_SOURCE >= 500
- gethostname(mmp_s->mmp_nodename, sizeof(mmp_s->mmp_nodename));
-#else
- strcpy(mmp_s->mmp_nodename, "unknown host");
-#endif
- strncpy(mmp_s->mmp_bdevname, fs->device_name,
- sizeof(mmp_s->mmp_bdevname));
-
- retval = ext2fs_mmp_write(fs, fs->super->s_mmp_block, fs->mmp_buf);
- if (retval)
- goto mmp_error;
-
- sleep(2 * mmp_check_interval + 1);
-
- retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, fs->mmp_buf);
- if (retval)
- goto mmp_error;
-
- if (seq != mmp_s->mmp_seq) {
- retval = EXT2_ET_MMP_FAILED;
- goto mmp_error;
- }
-
- mmp_s->mmp_seq = EXT4_MMP_SEQ_FSCK;
- retval = ext2fs_mmp_write(fs, fs->super->s_mmp_block, fs->mmp_buf);
- if (retval)
- goto mmp_error;
-
- return 0;
-
-mmp_error:
- return retval;
-}
-
-/*
- * Clear the MMP usage in the filesystem. If this function returns an
- * error EXT2_ET_MMP_CHANGE_ABORT it means the filesystem was modified
- * by some other process while in use, and changes should be dropped, or
- * risk filesystem corruption.
- */
-errcode_t ext2fs_mmp_stop(ext2_filsys fs)
-{
- struct mmp_struct *mmp, *mmp_cmp;
- errcode_t retval = 0;
-
- if (!(fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_MMP) ||
- !(fs->flags & EXT2_FLAG_RW) || (fs->flags & EXT2_FLAG_SKIP_MMP))
- goto mmp_error;
-
- retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, fs->mmp_buf);
- if (retval)
- goto mmp_error;
-
- /* Check if the MMP block is not changed. */
- mmp = fs->mmp_buf;
- mmp_cmp = fs->mmp_cmp;
- if (memcmp(mmp, mmp_cmp, sizeof(*mmp_cmp))) {
- retval = EXT2_ET_MMP_CHANGE_ABORT;
- goto mmp_error;
- }
-
- mmp_cmp->mmp_seq = EXT4_MMP_SEQ_CLEAN;
- retval = ext2fs_mmp_write(fs, fs->super->s_mmp_block, fs->mmp_cmp);
-
-mmp_error:
- if (fs->mmp_fd > 0) {
- close(fs->mmp_fd);
- fs->mmp_fd = -1;
- }
-
- return retval;
-}
-
-#define EXT2_MIN_MMP_UPDATE_INTERVAL 60
-
-/*
- * Update the on-disk mmp buffer, after checking that it hasn't been changed.
- */
-errcode_t ext2fs_mmp_update(ext2_filsys fs)
-{
- struct mmp_struct *mmp, *mmp_cmp;
- struct timeval tv;
- errcode_t retval = 0;
-
- if (!(fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_MMP) ||
- !(fs->flags & EXT2_FLAG_RW) || (fs->flags & EXT2_FLAG_SKIP_MMP))
- return 0;
-
- gettimeofday(&tv, 0);
- if (tv.tv_sec - fs->mmp_last_written < EXT2_MIN_MMP_UPDATE_INTERVAL)
- return 0;
-
- retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, NULL);
- if (retval)
- goto mmp_error;
-
- mmp = fs->mmp_buf;
- mmp_cmp = fs->mmp_cmp;
-
- if (memcmp(mmp, mmp_cmp, sizeof(*mmp_cmp)))
- return EXT2_ET_MMP_CHANGE_ABORT;
-
- mmp->mmp_time = tv.tv_sec;
- mmp->mmp_seq = EXT4_MMP_SEQ_FSCK;
- retval = ext2fs_mmp_write(fs, fs->super->s_mmp_block, fs->mmp_buf);
-
-mmp_error:
- return retval;
-}
diff --git a/lib/ext2fs/namei.c b/lib/ext2fs/namei.c
index dd710b89..22d2d2d2 100644
--- a/lib/ext2fs/namei.c
+++ b/lib/ext2fs/namei.c
@@ -19,7 +19,6 @@
#include "ext2_fs.h"
#include "ext2fs.h"
-#include "ext2fsP.h"
static errcode_t open_namei(ext2_filsys fs, ext2_ino_t root, ext2_ino_t base,
const char *pathname, size_t pathlen, int follow,
@@ -33,7 +32,6 @@ static errcode_t follow_link(ext2_filsys fs, ext2_ino_t root, ext2_ino_t dir,
char *buffer = 0;
errcode_t retval;
struct ext2_inode ei;
- blk64_t blk;
#ifdef NAMEI_DEBUG
printf("follow_link: root=%lu, dir=%lu, inode=%lu, lc=%d\n",
@@ -46,19 +44,14 @@ static errcode_t follow_link(ext2_filsys fs, ext2_ino_t root, ext2_ino_t dir,
*res_inode = inode;
return 0;
}
- if (link_count++ >= EXT2FS_MAX_NESTED_LINKS)
+ if (link_count++ > 5) {
return EXT2_ET_SYMLINK_LOOP;
-
+ }
if (ext2fs_inode_data_blocks(fs,&ei)) {
- retval = ext2fs_bmap2(fs, inode, &ei, NULL, 0, 0, NULL, &blk);
- if (retval)
- return retval;
-
retval = ext2fs_get_mem(fs->blocksize, &buffer);
if (retval)
return retval;
-
- retval = io_channel_read_blk64(fs->io, blk, 1, buffer);
+ retval = io_channel_read_blk(fs->io, ei.i_block[0], 1, buffer);
if (retval) {
ext2fs_free_mem(&buffer);
return retval;
diff --git a/lib/ext2fs/newdir.c b/lib/ext2fs/newdir.c
index bccaecdb..6bc57194 100644
--- a/lib/ext2fs/newdir.c
+++ b/lib/ext2fs/newdir.c
@@ -43,10 +43,8 @@ errcode_t ext2fs_new_dir_block(ext2_filsys fs, ext2_ino_t dir_ino,
dir = (struct ext2_dir_entry *) buf;
retval = ext2fs_set_rec_len(fs, fs->blocksize, dir);
- if (retval) {
- ext2fs_free_mem(&buf);
+ if (retval)
return retval;
- }
if (dir_ino) {
if (fs->super->s_feature_incompat &
@@ -66,10 +64,8 @@ errcode_t ext2fs_new_dir_block(ext2_filsys fs, ext2_ino_t dir_ino,
*/
dir = (struct ext2_dir_entry *) (buf + dir->rec_len);
retval = ext2fs_set_rec_len(fs, rec_len, dir);
- if (retval) {
- ext2fs_free_mem(&buf);
+ if (retval)
return retval;
- }
dir->inode = parent_ino;
dir->name_len = 2 | filetype;
dir->name[0] = '.';
diff --git a/lib/ext2fs/nt_io.c b/lib/ext2fs/nt_io.c
index a29e1d49..0f10543a 100644
--- a/lib/ext2fs/nt_io.c
+++ b/lib/ext2fs/nt_io.c
@@ -13,6 +13,7 @@
*/
#ifdef HAVE_CONFIG_H
+#include "config.h"
#endif
diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c
index 45b3627e..d638da03 100644
--- a/lib/ext2fs/openfs.c
+++ b/lib/ext2fs/openfs.c
@@ -22,9 +22,6 @@
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
-#ifdef HAVE_ERRNO_H
-#include <errno.h>
-#endif
#include "ext2_fs.h"
@@ -32,12 +29,11 @@
#include "ext2fs.h"
#include "e2image.h"
-blk64_t ext2fs_descriptor_block_loc2(ext2_filsys fs, blk64_t group_block,
- dgrp_t i)
+blk_t ext2fs_descriptor_block_loc(ext2_filsys fs, blk_t group_block, dgrp_t i)
{
int bg;
int has_super = 0;
- blk64_t ret_blk;
+ int ret_blk;
if (!(fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) ||
(i < fs->super->s_first_meta_bg))
@@ -46,7 +42,7 @@ blk64_t ext2fs_descriptor_block_loc2(ext2_filsys fs, blk64_t group_block,
bg = EXT2_DESC_PER_BLOCK(fs->super) * i;
if (ext2fs_bg_has_super(fs, bg))
has_super = 1;
- ret_blk = ext2fs_group_first_block2(fs, bg) + has_super;
+ ret_blk = ext2fs_group_first_block(fs, bg) + has_super;
/*
* If group_block is not the normal value, we're trying to use
* the backup group descriptors and superblock --- so use the
@@ -57,16 +53,11 @@ blk64_t ext2fs_descriptor_block_loc2(ext2_filsys fs, blk64_t group_block,
*/
if (group_block != fs->super->s_first_data_block &&
((ret_blk + fs->super->s_blocks_per_group) <
- ext2fs_blocks_count(fs->super)))
+ fs->super->s_blocks_count))
ret_blk += fs->super->s_blocks_per_group;
return ret_blk;
}
-blk_t ext2fs_descriptor_block_loc(ext2_filsys fs, blk_t group_block, dgrp_t i)
-{
- return ext2fs_descriptor_block_loc2(fs, group_block, i);
-}
-
errcode_t ext2fs_open(const char *name, int flags, int superblock,
unsigned int block_size, io_manager manager,
ext2_filsys *ret_fs)
@@ -85,9 +76,6 @@ errcode_t ext2fs_open(const char *name, int flags, int superblock,
* EXT2_FLAG_FORCE - Open the filesystem even if some of the
* features aren't supported.
* EXT2_FLAG_JOURNAL_DEV_OK - Open an ext3 journal device
- * EXT2_FLAG_SKIP_MMP - Open without multi-mount protection check.
- * EXT2_FLAG_64BITS - Allow 64-bit bitfields (needed for large
- * filesystems)
*/
errcode_t ext2fs_open2(const char *name, const char *io_options,
int flags, int superblock,
@@ -98,11 +86,10 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
errcode_t retval;
unsigned long i, first_meta_bg;
__u32 features;
- unsigned int blocks_per_group, io_flags;
- blk64_t group_block, blk;
+ int groups_per_block, blocks_per_group, io_flags;
+ blk_t group_block, blk;
char *dest, *cp;
#ifdef WORDS_BIGENDIAN
- unsigned int groups_per_block;
struct ext2_group_desc *gdp;
int j;
#endif
@@ -144,7 +131,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
goto cleanup;
fs->image_io = fs->io;
fs->io->app_data = fs;
- retval = io_channel_alloc_buf(fs->io, -SUPERBLOCK_SIZE, &fs->super);
+ retval = ext2fs_get_memalign(SUPERBLOCK_SIZE, 512, &fs->super);
if (retval)
goto cleanup;
if (flags & EXT2_FLAG_IMAGE_FILE) {
@@ -221,7 +208,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
features = fs->super->s_feature_incompat;
#ifdef EXT2_LIB_SOFTSUPP_INCOMPAT
if (flags & EXT2_FLAG_SOFTSUPP_FEATURES)
- features &= ~EXT2_LIB_SOFTSUPP_INCOMPAT;
+ features &= !EXT2_LIB_SOFTSUPP_INCOMPAT;
#endif
if (features & ~EXT2_LIB_FEATURE_INCOMPAT_SUPP) {
retval = EXT2_ET_UNSUPP_FEATURE;
@@ -231,7 +218,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
features = fs->super->s_feature_ro_compat;
#ifdef EXT2_LIB_SOFTSUPP_RO_COMPAT
if (flags & EXT2_FLAG_SOFTSUPP_FEATURES)
- features &= ~EXT2_LIB_SOFTSUPP_RO_COMPAT;
+ features &= !EXT2_LIB_SOFTSUPP_RO_COMPAT;
#endif
if ((flags & EXT2_FLAG_RW) &&
(features & ~EXT2_LIB_FEATURE_RO_COMPAT_SUPP)) {
@@ -252,36 +239,12 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
retval = EXT2_ET_CORRUPT_SUPERBLOCK;
goto cleanup;
}
-
- /*
- * bigalloc requires cluster-aware bitfield operations, which at the
- * moment means we need EXT2_FLAG_64BITS.
- */
- if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
- EXT4_FEATURE_RO_COMPAT_BIGALLOC) &&
- !(flags & EXT2_FLAG_64BITS)) {
- retval = EXT2_ET_CANT_USE_LEGACY_BITMAPS;
- goto cleanup;
- }
-
- if (!EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
- EXT4_FEATURE_RO_COMPAT_BIGALLOC) &&
- (fs->super->s_log_block_size != fs->super->s_log_cluster_size)) {
- retval = EXT2_ET_CORRUPT_SUPERBLOCK;
- goto cleanup;
- }
- fs->fragsize = fs->blocksize = EXT2_BLOCK_SIZE(fs->super);
+ fs->blocksize = EXT2_BLOCK_SIZE(fs->super);
if (EXT2_INODE_SIZE(fs->super) < EXT2_GOOD_OLD_INODE_SIZE) {
retval = EXT2_ET_CORRUPT_SUPERBLOCK;
goto cleanup;
}
- fs->cluster_ratio_bits = fs->super->s_log_cluster_size -
- fs->super->s_log_block_size;
- if (EXT2_BLOCKS_PER_GROUP(fs->super) !=
- EXT2_CLUSTERS_PER_GROUP(fs->super) << fs->cluster_ratio_bits) {
- retval = EXT2_ET_CORRUPT_SUPERBLOCK;
- goto cleanup;
- }
+ fs->fragsize = EXT2_FRAG_SIZE(fs->super);
fs->inode_blocks_per_group = ((EXT2_INODES_PER_GROUP(fs->super) *
EXT2_INODE_SIZE(fs->super) +
EXT2_BLOCK_SIZE(fs->super) - 1) /
@@ -321,18 +284,18 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
blocks_per_group > EXT2_MAX_BLOCKS_PER_GROUP(fs->super) ||
fs->inode_blocks_per_group > EXT2_MAX_INODES_PER_GROUP(fs->super) ||
EXT2_DESC_PER_BLOCK(fs->super) == 0 ||
- fs->super->s_first_data_block >= ext2fs_blocks_count(fs->super)) {
+ fs->super->s_first_data_block >= fs->super->s_blocks_count) {
retval = EXT2_ET_CORRUPT_SUPERBLOCK;
goto cleanup;
}
- fs->group_desc_count = ext2fs_div64_ceil(ext2fs_blocks_count(fs->super) -
- fs->super->s_first_data_block,
- blocks_per_group);
- if (fs->group_desc_count * EXT2_INODES_PER_GROUP(fs->super) !=
- fs->super->s_inodes_count) {
- retval = EXT2_ET_CORRUPT_SUPERBLOCK;
+ fs->group_desc_count = ext2fs_div_ceil(fs->super->s_blocks_count -
+ fs->super->s_first_data_block,
+ blocks_per_group);
+ if (fs->group_desc_count * EXT2_INODES_PER_GROUP(fs->super) !=
+ fs->super->s_inodes_count) {
+ retval = EXT2_ET_CORRUPT_SUPERBLOCK;
goto cleanup;
- }
+ }
fs->desc_blocks = ext2fs_div_ceil(fs->group_desc_count,
EXT2_DESC_PER_BLOCK(fs->super));
retval = ext2fs_get_array(fs->desc_blocks, fs->blocksize,
@@ -341,12 +304,8 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
goto cleanup;
if (!group_block)
group_block = fs->super->s_first_data_block;
- if (group_block == 0 && fs->blocksize == 1024)
- group_block = 1; /* Deal with 1024 blocksize && bigalloc */
dest = (char *) fs->group_desc;
-#ifdef WORDS_BIGENDIAN
groups_per_block = EXT2_DESC_PER_BLOCK(fs->super);
-#endif
if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG)
first_meta_bg = fs->super->s_first_meta_bg;
else
@@ -358,24 +317,20 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
goto cleanup;
#ifdef WORDS_BIGENDIAN
gdp = (struct ext2_group_desc *) dest;
- for (j=0; j < groups_per_block*first_meta_bg; j++) {
- gdp = ext2fs_group_desc(fs, fs->group_desc, j);
- ext2fs_swap_group_desc2(fs, gdp);
- }
+ for (j=0; j < groups_per_block*first_meta_bg; j++)
+ ext2fs_swap_group_desc(gdp++);
#endif
dest += fs->blocksize*first_meta_bg;
}
for (i=first_meta_bg ; i < fs->desc_blocks; i++) {
- blk = ext2fs_descriptor_block_loc2(fs, group_block, i);
- retval = io_channel_read_blk64(fs->io, blk, 1, dest);
+ blk = ext2fs_descriptor_block_loc(fs, group_block, i);
+ retval = io_channel_read_blk(fs->io, blk, 1, dest);
if (retval)
goto cleanup;
#ifdef WORDS_BIGENDIAN
- for (j=0; j < groups_per_block; j++) {
- gdp = ext2fs_group_desc(fs, fs->group_desc,
- i * groups_per_block + j);
- ext2fs_swap_group_desc2(fs, gdp);
- }
+ gdp = (struct ext2_group_desc *) dest;
+ for (j=0; j < groups_per_block; j++)
+ ext2fs_swap_group_desc(gdp++);
#endif
dest += fs->blocksize;
}
@@ -388,34 +343,18 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
*/
if (superblock > 1 && EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) {
- dgrp_t group;
-
- for (group = 0; group < fs->group_desc_count; group++) {
- ext2fs_bg_flags_clear(fs, group, EXT2_BG_BLOCK_UNINIT);
- ext2fs_bg_flags_clear(fs, group, EXT2_BG_INODE_UNINIT);
- ext2fs_bg_itable_unused_set(fs, group, 0);
- /* The checksum will be reset later, but fix it here
- * anyway to avoid printing a lot of spurious errors. */
- ext2fs_group_desc_csum_set(fs, group);
- }
- if (fs->flags & EXT2_FLAG_RW)
- ext2fs_mark_super_dirty(fs);
- }
-
- if ((fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_MMP) &&
- !(flags & EXT2_FLAG_SKIP_MMP) &&
- (flags & (EXT2_FLAG_RW | EXT2_FLAG_EXCLUSIVE))) {
- retval = ext2fs_mmp_start(fs);
- if (retval) {
- fs->flags |= EXT2_FLAG_SKIP_MMP; /* just do cleanup */
- ext2fs_mmp_stop(fs);
- goto cleanup;
+ struct ext2_group_desc *gd;
+ for (i = 0, gd = fs->group_desc; i < fs->group_desc_count;
+ i++, gd++) {
+ gd->bg_flags &= ~EXT2_BG_BLOCK_UNINIT;
+ gd->bg_flags &= ~EXT2_BG_INODE_UNINIT;
+ gd->bg_itable_unused = 0;
}
+ ext2fs_mark_super_dirty(fs);
}
fs->flags &= ~EXT2_FLAG_NOFREE_ON_ERROR;
*ret_fs = fs;
-
return 0;
cleanup:
if (flags & EXT2_FLAG_NOFREE_ON_ERROR)
@@ -450,20 +389,8 @@ errcode_t ext2fs_set_data_io(ext2_filsys fs, io_channel new_io)
errcode_t ext2fs_rewrite_to_io(ext2_filsys fs, io_channel new_io)
{
- errcode_t err;
-
if ((fs->flags & EXT2_FLAG_IMAGE_FILE) == 0)
return EXT2_ET_NOT_IMAGE_FILE;
- err = io_channel_set_blksize(new_io, fs->blocksize);
- if (err)
- return err;
- if ((new_io == fs->image_io) || (new_io == fs->io))
- return 0;
- if ((fs->image_io != fs->io) &&
- fs->image_io)
- io_channel_close(fs->image_io);
- if (fs->io)
- io_channel_close(fs->io);
fs->io = fs->image_io = new_io;
fs->flags |= EXT2_FLAG_DIRTY | EXT2_FLAG_RW |
EXT2_FLAG_BB_DIRTY | EXT2_FLAG_IB_DIRTY;
diff --git a/lib/ext2fs/progress.c b/lib/ext2fs/progress.c
deleted file mode 100644
index ad6a3d4d..00000000
--- a/lib/ext2fs/progress.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * progress.c - Numeric progress meter
- *
- * Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
- * 2003, 2004, 2005 by Theodore Ts'o.
- *
- * %Begin-Header%
- * This file may be redistributed under the terms of the GNU Public
- * License.
- * %End-Header%
- */
-
-#include "ext2fs.h"
-#include "ext2fsP.h"
-
-#include <time.h>
-
-static char spaces[80], backspaces[80];
-static time_t last_update;
-
-static int int_log10(unsigned int arg)
-{
- int l;
-
- for (l=0; arg ; l++)
- arg = arg / 10;
- return l;
-}
-
-void ext2fs_numeric_progress_init(ext2_filsys fs,
- struct ext2fs_numeric_progress_struct * progress,
- const char *label, __u64 max)
-{
- /*
- * The PRINT_PROGRESS flag turns on or off ALL
- * progress-related messages, whereas the SKIP_PROGRESS
- * environment variable prints the start and end messages but
- * not the numeric countdown in the middle.
- */
- if (!(fs->flags & EXT2_FLAG_PRINT_PROGRESS))
- return;
-
- memset(spaces, ' ', sizeof(spaces)-1);
- spaces[sizeof(spaces)-1] = 0;
- memset(backspaces, '\b', sizeof(backspaces)-1);
- backspaces[sizeof(backspaces)-1] = 0;
-
- memset(progress, 0, sizeof(*progress));
- if (getenv("E2FSPROGS_SKIP_PROGRESS"))
- progress->skip_progress++;
-
-
- /*
- * Figure out how many digits we need
- */
- progress->max = max;
- progress->log_max = int_log10(max);
-
- if (label) {
- fputs(label, stdout);
- fflush(stdout);
- }
- last_update = 0;
-}
-
-void ext2fs_numeric_progress_update(ext2_filsys fs,
- struct ext2fs_numeric_progress_struct * progress,
- __u64 val)
-{
- time_t now;
-
- if (!(fs->flags & EXT2_FLAG_PRINT_PROGRESS))
- return;
- if (progress->skip_progress)
- return;
- now = time(0);
- if (now == last_update)
- return;
- last_update = now;
-
- printf("%*llu/%*llu", progress->log_max, val,
- progress->log_max, progress->max);
- fprintf(stdout, "%.*s", (2*progress->log_max)+1, backspaces);
-}
-
-void ext2fs_numeric_progress_close(ext2_filsys fs,
- struct ext2fs_numeric_progress_struct * progress,
- const char *message)
-{
- if (!(fs->flags & EXT2_FLAG_PRINT_PROGRESS))
- return;
- fprintf(stdout, "%.*s", (2*progress->log_max)+1, spaces);
- fprintf(stdout, "%.*s", (2*progress->log_max)+1, backspaces);
- if (message)
- fputs(message, stdout);
-}
diff --git a/lib/ext2fs/punch.c b/lib/ext2fs/punch.c
deleted file mode 100644
index adfcdecb..00000000
--- a/lib/ext2fs/punch.c
+++ /dev/null
@@ -1,447 +0,0 @@
-/*
- * punch.c --- deallocate blocks allocated to an inode
- *
- * Copyright (C) 2010 Theodore Ts'o.
- *
- * %Begin-Header%
- * This file may be redistributed under the terms of the GNU Library
- * General Public License, version 2.
- * %End-Header%
- */
-
-#include <stdio.h>
-#include <string.h>
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <errno.h>
-
-#include "ext2_fs.h"
-#include "ext2fs.h"
-
-#undef PUNCH_DEBUG
-
-/*
- * This function returns 1 if the specified block is all zeros
- */
-static int check_zero_block(char *buf, int blocksize)
-{
- char *cp = buf;
- int left = blocksize;
-
- while (left > 0) {
- if (*cp++)
- return 0;
- left--;
- }
- return 1;
-}
-
-/*
- * This clever recursive function handles i_blocks[] as well as
- * indirect, double indirect, and triple indirect blocks. It iterates
- * over the entries in the i_blocks array or indirect blocks, and for
- * each one, will recursively handle any indirect blocks and then
- * frees and deallocates the blocks.
- */
-static errcode_t ind_punch(ext2_filsys fs, struct ext2_inode *inode,
- char *block_buf, blk_t *p, int level,
- blk_t start, blk_t count, int max)
-{
- errcode_t retval;
- blk_t b;
- int i;
- blk64_t offset, incr;
- int freed = 0;
-
-#ifdef PUNCH_DEBUG
- printf("Entering ind_punch, level %d, start %u, count %u, "
- "max %d\n", level, start, count, max);
-#endif
- incr = 1ULL << ((EXT2_BLOCK_SIZE_BITS(fs->super)-2)*level);
- for (i=0, offset=0; i < max; i++, p++, offset += incr) {
- if (offset >= start + count)
- break;
- if (*p == 0 || (offset+incr) <= start)
- continue;
- b = *p;
- if (level > 0) {
- blk_t start2;
-#ifdef PUNCH_DEBUG
- printf("Reading indirect block %u\n", b);
-#endif
- retval = ext2fs_read_ind_block(fs, b, block_buf);
- if (retval)
- return retval;
- start2 = (start > offset) ? start - offset : 0;
- retval = ind_punch(fs, inode, block_buf + fs->blocksize,
- (blk_t *) block_buf, level - 1,
- start2, count - offset,
- fs->blocksize >> 2);
- if (retval)
- return retval;
- retval = ext2fs_write_ind_block(fs, b, block_buf);
- if (retval)
- return retval;
- if (!check_zero_block(block_buf, fs->blocksize))
- continue;
- }
-#ifdef PUNCH_DEBUG
- printf("Freeing block %u (offset %llu)\n", b, offset);
-#endif
- ext2fs_block_alloc_stats(fs, b, -1);
- *p = 0;
- freed++;
- }
-#ifdef PUNCH_DEBUG
- printf("Freed %d blocks\n", freed);
-#endif
- return ext2fs_iblk_sub_blocks(fs, inode, freed);
-}
-
-static errcode_t ext2fs_punch_ind(ext2_filsys fs, struct ext2_inode *inode,
- char *block_buf, blk_t start, blk_t count)
-{
- errcode_t retval;
- char *buf = 0;
- int level;
- int num = EXT2_NDIR_BLOCKS;
- blk_t *bp = inode->i_block;
- blk_t addr_per_block;
- blk64_t max = EXT2_NDIR_BLOCKS;
-
- if (!block_buf) {
- retval = ext2fs_get_array(3, fs->blocksize, &buf);
- if (retval)
- return retval;
- block_buf = buf;
- }
-
- addr_per_block = (blk_t) fs->blocksize >> 2;
-
- for (level = 0; level < 4; level++, max *= (blk64_t)addr_per_block) {
-#ifdef PUNCH_DEBUG
- printf("Main loop level %d, start %u count %u "
- "max %llu num %d\n", level, start, count, max, num);
-#endif
- if (start < max) {
- retval = ind_punch(fs, inode, block_buf, bp, level,
- start, count, num);
- if (retval)
- goto errout;
- if (count > max)
- count -= max - start;
- else
- break;
- start = 0;
- } else
- start -= max;
- bp += num;
- if (level == 0) {
- num = 1;
- max = 1;
- }
- }
- retval = 0;
-errout:
- if (buf)
- ext2fs_free_mem(&buf);
- return retval;
-}
-
-#ifdef PUNCH_DEBUG
-
-#define dbg_printf(f, a...) printf(f, ## a)
-
-static void dbg_print_extent(char *desc, struct ext2fs_extent *extent)
-{
- if (desc)
- printf("%s: ", desc);
- printf("extent: lblk %llu--%llu, len %u, pblk %llu, flags: ",
- extent->e_lblk, extent->e_lblk + extent->e_len - 1,
- extent->e_len, extent->e_pblk);
- if (extent->e_flags & EXT2_EXTENT_FLAGS_LEAF)
- fputs("LEAF ", stdout);
- if (extent->e_flags & EXT2_EXTENT_FLAGS_UNINIT)
- fputs("UNINIT ", stdout);
- if (extent->e_flags & EXT2_EXTENT_FLAGS_SECOND_VISIT)
- fputs("2ND_VISIT ", stdout);
- if (!extent->e_flags)
- fputs("(none)", stdout);
- fputc('\n', stdout);
-
-}
-#else
-#define dbg_print_extent(desc, ex) do { } while (0)
-#define dbg_printf(f, a...) do { } while (0)
-#endif
-
-/* Free a range of blocks, respecting cluster boundaries */
-static errcode_t punch_extent_blocks(ext2_filsys fs, ext2_ino_t ino,
- struct ext2_inode *inode,
- blk64_t lfree_start, blk64_t free_start,
- __u32 free_count, int *freed)
-{
- blk64_t pblk;
- int freed_now = 0;
- __u32 cluster_freed;
- errcode_t retval = 0;
-
- /* No bigalloc? Just free each block. */
- if (EXT2FS_CLUSTER_RATIO(fs) == 1) {
- *freed += free_count;
- while (free_count-- > 0)
- ext2fs_block_alloc_stats2(fs, free_start++, -1);
- return retval;
- }
-
- /*
- * Try to free up to the next cluster boundary. We assume that all
- * blocks in a logical cluster map to blocks from the same physical
- * cluster, and that the offsets within the [pl]clusters match.
- */
- if (free_start & EXT2FS_CLUSTER_MASK(fs)) {
- retval = ext2fs_map_cluster_block(fs, ino, inode,
- lfree_start, &pblk);
- if (retval)
- goto errout;
- if (!pblk) {
- ext2fs_block_alloc_stats2(fs, free_start, -1);
- freed_now++;
- }
- cluster_freed = EXT2FS_CLUSTER_RATIO(fs) -
- (free_start & EXT2FS_CLUSTER_MASK(fs));
- if (cluster_freed > free_count)
- cluster_freed = free_count;
- free_count -= cluster_freed;
- free_start += cluster_freed;
- lfree_start += cluster_freed;
- }
-
- /* Free whole clusters from the middle of the range. */
- while (free_count > 0 && free_count >= EXT2FS_CLUSTER_RATIO(fs)) {
- ext2fs_block_alloc_stats2(fs, free_start, -1);
- freed_now++;
- cluster_freed = EXT2FS_CLUSTER_RATIO(fs);
- free_count -= cluster_freed;
- free_start += cluster_freed;
- lfree_start += cluster_freed;
- }
-
- /* Try to free the last cluster. */
- if (free_count > 0) {
- retval = ext2fs_map_cluster_block(fs, ino, inode,
- lfree_start, &pblk);
- if (retval)
- goto errout;
- if (!pblk) {
- ext2fs_block_alloc_stats2(fs, free_start, -1);
- freed_now++;
- }
- }
-
-errout:
- *freed += freed_now;
- return retval;
-}
-
-static errcode_t ext2fs_punch_extent(ext2_filsys fs, ext2_ino_t ino,
- struct ext2_inode *inode,
- blk64_t start, blk64_t end)
-{
- ext2_extent_handle_t handle = 0;
- struct ext2fs_extent extent;
- errcode_t retval;
- blk64_t free_start, next, lfree_start;
- __u32 free_count, newlen;
- int freed = 0;
- int op;
-
- retval = ext2fs_extent_open2(fs, ino, inode, &handle);
- if (retval)
- return retval;
- /*
- * Find the extent closest to the start of the punch range. We don't
- * check the return value because _goto() sets the current node to the
- * next-lowest extent if 'start' is in a hole, and doesn't set a
- * current node if there was a real error reading the extent tree.
- * In that case, _get() will error out.
- *
- * Note: If _get() returns 'no current node', that simply means that
- * there aren't any blocks mapped past this point in the file, so we're
- * done.
- */
- ext2fs_extent_goto(handle, start);
- retval = ext2fs_extent_get(handle, EXT2_EXTENT_CURRENT, &extent);
- if (retval == EXT2_ET_NO_CURRENT_NODE) {
- retval = 0;
- goto errout;
- } else if (retval)
- goto errout;
- while (1) {
- op = EXT2_EXTENT_NEXT_LEAF;
- dbg_print_extent("main loop", &extent);
- next = extent.e_lblk + extent.e_len;
- dbg_printf("start %llu, end %llu, next %llu\n",
- (unsigned long long) start,
- (unsigned long long) end,
- (unsigned long long) next);
- if (start <= extent.e_lblk) {
- if (end < extent.e_lblk)
- goto next_extent;
- dbg_printf("Case #%d\n", 1);
- /* Start of deleted region before extent;
- adjust beginning of extent */
- free_start = extent.e_pblk;
- lfree_start = extent.e_lblk;
- if (next > end)
- free_count = end - extent.e_lblk + 1;
- else
- free_count = extent.e_len;
- extent.e_len -= free_count;
- extent.e_lblk += free_count;
- extent.e_pblk += free_count;
- } else if (end >= next-1) {
- if (start >= next)
- break;
- /* End of deleted region after extent;
- adjust end of extent */
- dbg_printf("Case #%d\n", 2);
- newlen = start - extent.e_lblk;
- free_start = extent.e_pblk + newlen;
- lfree_start = extent.e_lblk + newlen;
- free_count = extent.e_len - newlen;
- extent.e_len = newlen;
- } else {
- struct ext2fs_extent newex;
-
- dbg_printf("Case #%d\n", 3);
- /* The hard case; we need to split the extent */
- newex.e_pblk = extent.e_pblk +
- (end + 1 - extent.e_lblk);
- newex.e_lblk = end + 1;
- newex.e_len = next - end - 1;
- newex.e_flags = extent.e_flags;
-
- extent.e_len = start - extent.e_lblk;
- free_start = extent.e_pblk + extent.e_len;
- lfree_start = extent.e_lblk + extent.e_len;
- free_count = end - start + 1;
-
- dbg_print_extent("inserting", &newex);
- retval = ext2fs_extent_insert(handle,
- EXT2_EXTENT_INSERT_AFTER, &newex);
- if (retval)
- goto errout;
- /* Now pointing at inserted extent; so go back */
- retval = ext2fs_extent_get(handle,
- EXT2_EXTENT_PREV_LEAF,
- &newex);
- if (retval)
- goto errout;
- }
- if (extent.e_len) {
- dbg_print_extent("replacing", &extent);
- retval = ext2fs_extent_replace(handle, 0, &extent);
- } else {
- struct ext2fs_extent newex;
- blk64_t old_lblk, next_lblk;
- dbg_printf("deleting current extent%s\n", "");
-
- /*
- * Save the location of the next leaf, then slip
- * back to the current extent.
- */
- retval = ext2fs_extent_get(handle, EXT2_EXTENT_CURRENT,
- &newex);
- if (retval)
- goto errout;
- old_lblk = newex.e_lblk;
-
- retval = ext2fs_extent_get(handle,
- EXT2_EXTENT_NEXT_LEAF,
- &newex);
- if (retval == EXT2_ET_EXTENT_NO_NEXT)
- next_lblk = old_lblk;
- else if (retval)
- goto errout;
- else
- next_lblk = newex.e_lblk;
-
- retval = ext2fs_extent_goto(handle, old_lblk);
- if (retval)
- goto errout;
-
- /* Now delete the extent. */
- retval = ext2fs_extent_delete(handle, 0);
- if (retval)
- goto errout;
-
- /* Jump forward to the next extent. */
- ext2fs_extent_goto(handle, next_lblk);
- op = EXT2_EXTENT_CURRENT;
- }
- if (retval)
- goto errout;
- dbg_printf("Free start %llu, free count = %u\n",
- free_start, free_count);
- retval = punch_extent_blocks(fs, ino, inode, lfree_start,
- free_start, free_count, &freed);
- if (retval)
- goto errout;
- next_extent:
- retval = ext2fs_extent_get(handle, op,
- &extent);
- if (retval == EXT2_ET_EXTENT_NO_NEXT ||
- retval == EXT2_ET_NO_CURRENT_NODE)
- break;
- if (retval)
- goto errout;
- }
- dbg_printf("Freed %d blocks\n", freed);
- retval = ext2fs_iblk_sub_blocks(fs, inode, freed);
-errout:
- ext2fs_extent_free(handle);
- return retval;
-}
-
-/*
- * Deallocate all logical blocks starting at start to end, inclusive.
- * If end is ~0, then this is effectively truncate.
- */
-errcode_t ext2fs_punch(ext2_filsys fs, ext2_ino_t ino,
- struct ext2_inode *inode,
- char *block_buf, blk64_t start,
- blk64_t end)
-{
- errcode_t retval;
- struct ext2_inode inode_buf;
-
- if (start > end)
- return EINVAL;
-
- /* Read inode structure if necessary */
- if (!inode) {
- retval = ext2fs_read_inode(fs, ino, &inode_buf);
- if (retval)
- return retval;
- inode = &inode_buf;
- }
- if (inode->i_flags & EXT4_EXTENTS_FL)
- retval = ext2fs_punch_extent(fs, ino, inode, start, end);
- else {
- blk_t count;
-
- if (start > ~0U)
- return 0;
- if (end > ~0U)
- end = ~0U;
- count = ((end - start + 1) < ~0U) ? (end - start + 1) : ~0U;
- retval = ext2fs_punch_ind(fs, inode, block_buf,
- (blk_t) start, count);
- }
- if (retval)
- return retval;
-
- return ext2fs_write_inode(fs, ino, inode);
-}
diff --git a/lib/ext2fs/qcow2.c b/lib/ext2fs/qcow2.c
deleted file mode 100644
index 9d56ae58..00000000
--- a/lib/ext2fs/qcow2.c
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
- * qcow2.c --- Functions to generate qcow2 formatted disk images. This
- * format is used originally by QEMU for virtual machines, and stores the
- * filesystem data on disk in a packed format to avoid creating sparse
- * image files that need lots of seeking to read and write.
- *
- * The qcow2 format supports zlib compression, but that is not yet
- * implemented.
- *
- * It is possible to directly mount a qcow2 image using qemu-nbd:
- *
- * [root]# modprobe nbd max_part=63
- * [root]# qemu-nbd -c /dev/nbd0 image.img
- * [root]# mount /dev/nbd0p1 /mnt/qemu
- *
- * Format details at http://people.gnome.org/~markmc/qcow-image-format.html
- *
- * Copyright (C) 2010 Red Hat, Inc., Lukas Czerner <lczerner@redhat.com>
- *
- * %Begin-Header%
- * This file may be redistributed under the terms of the GNU Public
- * License.
- * %End-Header%
- */
-
-#define _LARGEFILE_SOURCE
-#define _LARGEFILE64_SOURCE
-
-#include <fcntl.h>
-#include <grp.h>
-#include <pwd.h>
-#include <stdio.h>
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <assert.h>
-
-#include "ext2fs/ext2fs.h"
-#include "qcow2.h"
-
-/* Functions for converting qcow2 image into raw image */
-
-struct ext2_qcow2_hdr *qcow2_read_header(int fd)
-{
- void *buffer = NULL;
- struct ext2_qcow2_hdr *hdr = NULL;
- size_t size;
- errcode_t ret;
-
- ret = ext2fs_get_mem(sizeof(struct ext2_qcow2_hdr), &buffer);
- if (ret)
- return NULL;
- memset(buffer, 0, sizeof(struct ext2_qcow2_hdr));
-
- if (ext2fs_llseek(fd, 0, SEEK_SET < 0)) {
- ext2fs_free_mem(&buffer);
- return NULL;
- }
-
- size = read(fd, buffer, sizeof(struct ext2_qcow2_hdr));
- if (size != sizeof(struct ext2_qcow2_hdr)) {
- ext2fs_free_mem(&buffer);
- return NULL;
- }
-
- hdr = (struct ext2_qcow2_hdr *)(buffer);
-
- if ((ext2fs_be32_to_cpu(hdr->magic) != QCOW_MAGIC) ||
- (ext2fs_be32_to_cpu(hdr->version) != 2)) {
- ext2fs_free_mem(&hdr);
- return NULL;
- }
-
- return hdr;
-}
-
-static int qcow2_read_l1_table(struct ext2_qcow2_image *img)
-{
- int fd = img->fd;
- size_t size, l1_size = img->l1_size * sizeof(blk64_t);
- blk64_t *table;
- errcode_t ret;
-
- ret = ext2fs_get_memzero(l1_size, &table);
- if (ret)
- return ret;
-
- if (ext2fs_llseek(fd, img->l1_offset, SEEK_SET) < 0) {
- ext2fs_free_mem(&table);
- return errno;
- }
-
- size = read(fd, table, l1_size);
- if (size != l1_size) {
- ext2fs_free_mem(&table);
- return errno;
- }
-
- img->l1_table = table;
-
- return 0;
-}
-
-static int qcow2_read_l2_table(struct ext2_qcow2_image *img,
- ext2_off64_t offset, blk64_t **l2_table)
-{
- int fd = img->fd;
- size_t size;
-
- assert(*l2_table);
-
- if (ext2fs_llseek(fd, offset, SEEK_SET) < 0)
- return errno;
-
- size = read(fd, *l2_table, img->cluster_size);
- if (size != img->cluster_size)
- return errno;
-
- return 0;
-}
-
-static int qcow2_copy_data(int fdin, int fdout, ext2_off64_t off_in,
- ext2_off64_t off_out, void *buf, size_t count)
-{
- size_t size;
-
- assert(buf);
-
- if (ext2fs_llseek(fdout, off_out, SEEK_SET) < 0)
- return errno;
-
- if (ext2fs_llseek(fdin, off_in, SEEK_SET) < 0)
- return errno;
-
- size = read(fdin, buf, count);
- if (size != count)
- return errno;
-
- size = write(fdout, buf, count);
- if (size != count)
- return errno;
-
- return 0;
-}
-
-
-int qcow2_write_raw_image(int qcow2_fd, int raw_fd,
- struct ext2_qcow2_hdr *hdr)
-{
- struct ext2_qcow2_image img;
- errcode_t ret = 0;
- unsigned int l1_index, l2_index;
- ext2_off64_t offset;
- blk64_t *l1_table, *l2_table = NULL;
- void *copy_buf = NULL;
- size_t size;
-
- if (hdr->crypt_method)
- return -QCOW_ENCRYPTED;
-
- img.fd = qcow2_fd;
- img.hdr = hdr;
- img.l2_cache = NULL;
- img.l1_table = NULL;
- img.cluster_bits = ext2fs_be32_to_cpu(hdr->cluster_bits);
- img.cluster_size = 1 << img.cluster_bits;
- img.l1_size = ext2fs_be32_to_cpu(hdr->l1_size);
- img.l1_offset = ext2fs_be64_to_cpu(hdr->l1_table_offset);
- img.l2_size = 1 << (img.cluster_bits - 3);
- img.image_size = ext2fs_be64_to_cpu(hdr->size);
-
-
- ret = ext2fs_get_memzero(img.cluster_size, &l2_table);
- if (ret)
- goto out;
-
- ret = ext2fs_get_memzero(1 << img.cluster_bits, &copy_buf);
- if (ret)
- goto out;
-
- if (ext2fs_llseek(raw_fd, 0, SEEK_SET) < 0) {
- ret = errno;
- goto out;
- }
-
- ret = qcow2_read_l1_table(&img);
- if (ret)
- goto out;
-
- l1_table = img.l1_table;
- /* Walk through l1 table */
- for (l1_index = 0; l1_index < img.l1_size; l1_index++) {
- ext2_off64_t off_out;
-
- offset = ext2fs_be64_to_cpu(l1_table[l1_index]) &
- ~QCOW_OFLAG_COPIED;
-
- if ((offset > img.image_size) ||
- (offset <= 0))
- continue;
-
- if (offset & QCOW_OFLAG_COMPRESSED) {
- ret = -QCOW_COMPRESSED;
- goto out;
- }
-
- ret = qcow2_read_l2_table(&img, offset, &l2_table);
- if (ret)
- break;
-
- /* Walk through l2 table and copy data blocks into raw image */
- for (l2_index = 0; l2_index < img.l2_size; l2_index++) {
- offset = ext2fs_be64_to_cpu(l2_table[l2_index]) &
- ~QCOW_OFLAG_COPIED;
-
- if (offset == 0)
- continue;
-
- off_out = (l1_index * img.l2_size) +
- l2_index;
- off_out <<= img.cluster_bits;
- ret = qcow2_copy_data(qcow2_fd, raw_fd, offset,
- off_out, copy_buf, img.cluster_size);
- if (ret)
- goto out;
- }
- }
-
- /* Resize the output image to the filesystem size */
- if (ext2fs_llseek(raw_fd, img.image_size - 1, SEEK_SET) < 0)
- return errno;
-
- ((char *)copy_buf)[0] = 0;
- size = write(raw_fd, copy_buf, 1);
- if (size != 1) {
- ret = errno;
- goto out;
- }
-
-out:
- if (copy_buf)
- ext2fs_free_mem(&copy_buf);
- if (img.l1_table)
- ext2fs_free_mem(&img.l1_table);
- if (l2_table)
- ext2fs_free_mem(&l2_table);
- return ret;
-}
diff --git a/lib/ext2fs/qcow2.h b/lib/ext2fs/qcow2.h
deleted file mode 100644
index 81e0ec93..00000000
--- a/lib/ext2fs/qcow2.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * qcow2.h --- structures and function prototypes for qcow2.c to generate
- * qcow2 formatted disk images. This format is used originally by QEMU
- * for virtual machines, and stores the filesystem data on disk in a
- * packed format to avoid creating sparse image files that need lots of
- * seeking to read and write.
- *
- * The qcow2 format supports zlib compression, but that is not yet
- * implemented.
- *
- * It is possible to directly mount a qcow2 image using qemu-nbd:
- *
- * [root]# modprobe nbd max_part=63
- * [root]# qemu-nbd -c /dev/nbd0 image.img
- * [root]# mount /dev/nbd0p1 /mnt/qemu
- *
- * Format details at http://people.gnome.org/~markmc/qcow-image-format.html
- *
- * Copyright (C) 2010 Red Hat, Inc., Lukas Czerner <lczerner@redhat.com>
- *
- * %Begin-Header%
- * This file may be redistributed under the terms of the GNU Public
- * License.
- * %End-Header%
- */
-
-/* Number of l2 tables in memory before writeback */
-#define L2_CACHE_PREALLOC 512
-
-
-#define QCOW_MAGIC (('Q' << 24) | ('F' << 16) | ('I' << 8) | 0xfb)
-#define QCOW_VERSION 2
-#define QCOW_OFLAG_COPIED (1LL << 63)
-#define QCOW_OFLAG_COMPRESSED (1LL << 62)
-
-#define QCOW_COMPRESSED 1
-#define QCOW_ENCRYPTED 2
-
-struct ext2_qcow2_hdr {
- __u32 magic;
- __u32 version;
-
- __u64 backing_file_offset;
- __u32 backing_file_size;
-
- __u32 cluster_bits;
- __u64 size;
- __u32 crypt_method;
-
- __u32 l1_size;
- __u64 l1_table_offset;
-
- __u64 refcount_table_offset;
- __u32 refcount_table_clusters;
-
- __u32 nb_snapshots;
- __u64 snapshots_offset;
-};
-
-typedef struct ext2_qcow2_l2_table L2_CACHE_HEAD;
-
-struct ext2_qcow2_l2_table {
- __u32 l1_index;
- __u64 offset;
- __u64 *data;
- L2_CACHE_HEAD *next;
-};
-
-struct ext2_qcow2_l2_cache {
- L2_CACHE_HEAD *used_head;
- L2_CACHE_HEAD *used_tail;
- L2_CACHE_HEAD *free_head;
- __u32 free;
- __u32 count;
- __u64 next_offset;
-};
-
-struct ext2_qcow2_refcount {
- __u64 *refcount_table;
- __u64 refcount_table_offset;
- __u64 refcount_block_offset;
-
- __u32 refcount_table_clusters;
- __u32 refcount_table_index;
- __u32 refcount_block_index;
-
- __u16 *refcount_block;
-};
-
-struct ext2_qcow2_image {
- int fd;
- struct ext2_qcow2_hdr *hdr;
- struct ext2_qcow2_l2_cache *l2_cache;
- struct ext2_qcow2_refcount refcount;
- __u32 cluster_size;
- __u32 cluster_bits;
- __u32 l1_size;
- __u32 l2_size;
-
- __u64 *l1_table;
- __u64 l2_offset;
- __u64 l1_offset;
- __u64 image_size;
-};
-
-/* Function prototypes */
-
-/* qcow2.c */
-
-/* Functions for converting qcow2 image into raw image */
-struct ext2_qcow2_hdr *qcow2_read_header(int);
-int qcow2_write_raw_image(int, int, struct ext2_qcow2_hdr *);
-
diff --git a/lib/ext2fs/rbtree.c b/lib/ext2fs/rbtree.c
deleted file mode 100644
index 94393030..00000000
--- a/lib/ext2fs/rbtree.c
+++ /dev/null
@@ -1,451 +0,0 @@
-/*
- Red Black Trees
- (C) 1999 Andrea Arcangeli <andrea@suse.de>
- (C) 2002 David Woodhouse <dwmw2@infradead.org>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- linux/lib/rbtree.c
-*/
-
-#include "rbtree.h"
-
-static void __rb_rotate_left(struct rb_node *node, struct rb_root *root)
-{
- struct rb_node *right = node->rb_right;
- struct rb_node *parent = ext2fs_rb_parent(node);
-
- if ((node->rb_right = right->rb_left))
- ext2fs_rb_set_parent(right->rb_left, node);
- right->rb_left = node;
-
- ext2fs_rb_set_parent(right, parent);
-
- if (parent)
- {
- if (node == parent->rb_left)
- parent->rb_left = right;
- else
- parent->rb_right = right;
- }
- else
- root->rb_node = right;
- ext2fs_rb_set_parent(node, right);
-}
-
-static void __rb_rotate_right(struct rb_node *node, struct rb_root *root)
-{
- struct rb_node *left = node->rb_left;
- struct rb_node *parent = ext2fs_rb_parent(node);
-
- if ((node->rb_left = left->rb_right))
- ext2fs_rb_set_parent(left->rb_right, node);
- left->rb_right = node;
-
- ext2fs_rb_set_parent(left, parent);
-
- if (parent)
- {
- if (node == parent->rb_right)
- parent->rb_right = left;
- else
- parent->rb_left = left;
- }
- else
- root->rb_node = left;
- ext2fs_rb_set_parent(node, left);
-}
-
-void ext2fs_rb_insert_color(struct rb_node *node, struct rb_root *root)
-{
- struct rb_node *parent, *gparent;
-
- while ((parent = ext2fs_rb_parent(node)) && ext2fs_rb_is_red(parent))
- {
- gparent = ext2fs_rb_parent(parent);
-
- if (parent == gparent->rb_left)
- {
- {
- register struct rb_node *uncle = gparent->rb_right;
- if (uncle && ext2fs_rb_is_red(uncle))
- {
- ext2fs_rb_set_black(uncle);
- ext2fs_rb_set_black(parent);
- ext2fs_rb_set_red(gparent);
- node = gparent;
- continue;
- }
- }
-
- if (parent->rb_right == node)
- {
- register struct rb_node *tmp;
- __rb_rotate_left(parent, root);
- tmp = parent;
- parent = node;
- node = tmp;
- }
-
- ext2fs_rb_set_black(parent);
- ext2fs_rb_set_red(gparent);
- __rb_rotate_right(gparent, root);
- } else {
- {
- register struct rb_node *uncle = gparent->rb_left;
- if (uncle && ext2fs_rb_is_red(uncle))
- {
- ext2fs_rb_set_black(uncle);
- ext2fs_rb_set_black(parent);
- ext2fs_rb_set_red(gparent);
- node = gparent;
- continue;
- }
- }
-
- if (parent->rb_left == node)
- {
- register struct rb_node *tmp;
- __rb_rotate_right(parent, root);
- tmp = parent;
- parent = node;
- node = tmp;
- }
-
- ext2fs_rb_set_black(parent);
- ext2fs_rb_set_red(gparent);
- __rb_rotate_left(gparent, root);
- }
- }
-
- ext2fs_rb_set_black(root->rb_node);
-}
-
-static void __rb_erase_color(struct rb_node *node, struct rb_node *parent,
- struct rb_root *root)
-{
- struct rb_node *other;
-
- while ((!node || ext2fs_rb_is_black(node)) && node != root->rb_node)
- {
- if (parent->rb_left == node)
- {
- other = parent->rb_right;
- if (ext2fs_rb_is_red(other))
- {
- ext2fs_rb_set_black(other);
- ext2fs_rb_set_red(parent);
- __rb_rotate_left(parent, root);
- other = parent->rb_right;
- }
- if ((!other->rb_left || ext2fs_rb_is_black(other->rb_left)) &&
- (!other->rb_right || ext2fs_rb_is_black(other->rb_right)))
- {
- ext2fs_rb_set_red(other);
- node = parent;
- parent = ext2fs_rb_parent(node);
- }
- else
- {
- if (!other->rb_right || ext2fs_rb_is_black(other->rb_right))
- {
- ext2fs_rb_set_black(other->rb_left);
- ext2fs_rb_set_red(other);
- __rb_rotate_right(other, root);
- other = parent->rb_right;
- }
- ext2fs_rb_set_color(other, ext2fs_rb_color(parent));
- ext2fs_rb_set_black(parent);
- ext2fs_rb_set_black(other->rb_right);
- __rb_rotate_left(parent, root);
- node = root->rb_node;
- break;
- }
- }
- else
- {
- other = parent->rb_left;
- if (ext2fs_rb_is_red(other))
- {
- ext2fs_rb_set_black(other);
- ext2fs_rb_set_red(parent);
- __rb_rotate_right(parent, root);
- other = parent->rb_left;
- }
- if ((!other->rb_left || ext2fs_rb_is_black(other->rb_left)) &&
- (!other->rb_right || ext2fs_rb_is_black(other->rb_right)))
- {
- ext2fs_rb_set_red(other);
- node = parent;
- parent = ext2fs_rb_parent(node);
- }
- else
- {
- if (!other->rb_left || ext2fs_rb_is_black(other->rb_left))
- {
- ext2fs_rb_set_black(other->rb_right);
- ext2fs_rb_set_red(other);
- __rb_rotate_left(other, root);
- other = parent->rb_left;
- }
- ext2fs_rb_set_color(other, ext2fs_rb_color(parent));
- ext2fs_rb_set_black(parent);
- ext2fs_rb_set_black(other->rb_left);
- __rb_rotate_right(parent, root);
- node = root->rb_node;
- break;
- }
- }
- }
- if (node)
- ext2fs_rb_set_black(node);
-}
-
-void ext2fs_rb_erase(struct rb_node *node, struct rb_root *root)
-{
- struct rb_node *child, *parent;
- int color;
-
- if (!node->rb_left)
- child = node->rb_right;
- else if (!node->rb_right)
- child = node->rb_left;
- else
- {
- struct rb_node *old = node, *left;
-
- node = node->rb_right;
- while ((left = node->rb_left) != NULL)
- node = left;
-
- if (ext2fs_rb_parent(old)) {
- if (ext2fs_rb_parent(old)->rb_left == old)
- ext2fs_rb_parent(old)->rb_left = node;
- else
- ext2fs_rb_parent(old)->rb_right = node;
- } else
- root->rb_node = node;
-
- child = node->rb_right;
- parent = ext2fs_rb_parent(node);
- color = ext2fs_rb_color(node);
-
- if (parent == old) {
- parent = node;
- } else {
- if (child)
- ext2fs_rb_set_parent(child, parent);
- parent->rb_left = child;
-
- node->rb_right = old->rb_right;
- ext2fs_rb_set_parent(old->rb_right, node);
- }
-
- node->rb_parent_color = old->rb_parent_color;
- node->rb_left = old->rb_left;
- ext2fs_rb_set_parent(old->rb_left, node);
-
- goto color;
- }
-
- parent = ext2fs_rb_parent(node);
- color = ext2fs_rb_color(node);
-
- if (child)
- ext2fs_rb_set_parent(child, parent);
- if (parent)
- {
- if (parent->rb_left == node)
- parent->rb_left = child;
- else
- parent->rb_right = child;
- }
- else
- root->rb_node = child;
-
- color:
- if (color == RB_BLACK)
- __rb_erase_color(child, parent, root);
-}
-
-static void ext2fs_rb_augment_path(struct rb_node *node, rb_augment_f func, void *data)
-{
- struct rb_node *parent;
-
-up:
- func(node, data);
- parent = ext2fs_rb_parent(node);
- if (!parent)
- return;
-
- if (node == parent->rb_left && parent->rb_right)
- func(parent->rb_right, data);
- else if (parent->rb_left)
- func(parent->rb_left, data);
-
- node = parent;
- goto up;
-}
-
-/*
- * after inserting @node into the tree, update the tree to account for
- * both the new entry and any damage done by rebalance
- */
-void ext2fs_rb_augment_insert(struct rb_node *node, rb_augment_f func, void *data)
-{
- if (node->rb_left)
- node = node->rb_left;
- else if (node->rb_right)
- node = node->rb_right;
-
- ext2fs_rb_augment_path(node, func, data);
-}
-
-/*
- * before removing the node, find the deepest node on the rebalance path
- * that will still be there after @node gets removed
- */
-struct rb_node *ext2fs_rb_augment_erase_begin(struct rb_node *node)
-{
- struct rb_node *deepest;
-
- if (!node->rb_right && !node->rb_left)
- deepest = ext2fs_rb_parent(node);
- else if (!node->rb_right)
- deepest = node->rb_left;
- else if (!node->rb_left)
- deepest = node->rb_right;
- else {
- deepest = ext2fs_rb_next(node);
- if (deepest->rb_right)
- deepest = deepest->rb_right;
- else if (ext2fs_rb_parent(deepest) != node)
- deepest = ext2fs_rb_parent(deepest);
- }
-
- return deepest;
-}
-
-/*
- * after removal, update the tree to account for the removed entry
- * and any rebalance damage.
- */
-void ext2fs_rb_augment_erase_end(struct rb_node *node, rb_augment_f func, void *data)
-{
- if (node)
- ext2fs_rb_augment_path(node, func, data);
-}
-
-/*
- * This function returns the first node (in sort order) of the tree.
- */
-struct rb_node *ext2fs_rb_first(const struct rb_root *root)
-{
- struct rb_node *n;
-
- n = root->rb_node;
- if (!n)
- return NULL;
- while (n->rb_left)
- n = n->rb_left;
- return n;
-}
-
-struct rb_node *ext2fs_rb_last(const struct rb_root *root)
-{
- struct rb_node *n;
-
- n = root->rb_node;
- if (!n)
- return NULL;
- while (n->rb_right)
- n = n->rb_right;
- return n;
-}
-
-struct rb_node *ext2fs_rb_next(struct rb_node *node)
-{
- struct rb_node *parent;
-
- if (ext2fs_rb_parent(node) == node)
- return NULL;
-
- /* If we have a right-hand child, go down and then left as far
- as we can. */
- if (node->rb_right) {
- node = node->rb_right;
- while (node->rb_left)
- node=node->rb_left;
- return (struct rb_node *)node;
- }
-
- /* No right-hand children. Everything down and left is
- smaller than us, so any 'next' node must be in the general
- direction of our parent. Go up the tree; any time the
- ancestor is a right-hand child of its parent, keep going
- up. First time it's a left-hand child of its parent, said
- parent is our 'next' node. */
- while ((parent = ext2fs_rb_parent(node)) && node == parent->rb_right)
- node = parent;
-
- return parent;
-}
-
-struct rb_node *ext2fs_rb_prev(struct rb_node *node)
-{
- struct rb_node *parent;
-
- if (ext2fs_rb_parent(node) == node)
- return NULL;
-
- /* If we have a left-hand child, go down and then right as far
- as we can. */
- if (node->rb_left) {
- node = node->rb_left;
- while (node->rb_right)
- node=node->rb_right;
- return (struct rb_node *)node;
- }
-
- /* No left-hand children. Go up till we find an ancestor which
- is a right-hand child of its parent */
- while ((parent = ext2fs_rb_parent(node)) && node == parent->rb_left)
- node = parent;
-
- return parent;
-}
-
-void ext2fs_rb_replace_node(struct rb_node *victim, struct rb_node *new,
- struct rb_root *root)
-{
- struct rb_node *parent = ext2fs_rb_parent(victim);
-
- /* Set the surrounding nodes to point to the replacement */
- if (parent) {
- if (victim == parent->rb_left)
- parent->rb_left = new;
- else
- parent->rb_right = new;
- } else {
- root->rb_node = new;
- }
- if (victim->rb_left)
- ext2fs_rb_set_parent(victim->rb_left, new);
- if (victim->rb_right)
- ext2fs_rb_set_parent(victim->rb_right, new);
-
- /* Copy the pointers/colour from the victim to the replacement */
- *new = *victim;
-}
diff --git a/lib/ext2fs/rbtree.h b/lib/ext2fs/rbtree.h
deleted file mode 100644
index 3b0b0784..00000000
--- a/lib/ext2fs/rbtree.h
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- Red Black Trees
- (C) 1999 Andrea Arcangeli <andrea@suse.de>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- linux/include/linux/rbtree.h
-
- To use rbtrees you'll have to implement your own insert and search cores.
- This will avoid us to use callbacks and to drop drammatically performances.
- I know it's not the cleaner way, but in C (not in C++) to get
- performances and genericity...
-
- Some example of insert and search follows here. The search is a plain
- normal search over an ordered tree. The insert instead must be implemented
- in two steps: First, the code must insert the element in order as a red leaf
- in the tree, and then the support library function rb_insert_color() must
- be called. Such function will do the not trivial work to rebalance the
- rbtree, if necessary.
-
------------------------------------------------------------------------
-static inline struct page * rb_search_page_cache(struct inode * inode,
- unsigned long offset)
-{
- struct rb_node * n = inode->i_rb_page_cache.rb_node;
- struct page * page;
-
- while (n)
- {
- page = rb_entry(n, struct page, rb_page_cache);
-
- if (offset < page->offset)
- n = n->rb_left;
- else if (offset > page->offset)
- n = n->rb_right;
- else
- return page;
- }
- return NULL;
-}
-
-static inline struct page * __rb_insert_page_cache(struct inode * inode,
- unsigned long offset,
- struct rb_node * node)
-{
- struct rb_node ** p = &inode->i_rb_page_cache.rb_node;
- struct rb_node * parent = NULL;
- struct page * page;
-
- while (*p)
- {
- parent = *p;
- page = rb_entry(parent, struct page, rb_page_cache);
-
- if (offset < page->offset)
- p = &(*p)->rb_left;
- else if (offset > page->offset)
- p = &(*p)->rb_right;
- else
- return page;
- }
-
- rb_link_node(node, parent, p);
-
- return NULL;
-}
-
-static inline struct page * rb_insert_page_cache(struct inode * inode,
- unsigned long offset,
- struct rb_node * node)
-{
- struct page * ret;
- if ((ret = __rb_insert_page_cache(inode, offset, node)))
- goto out;
- rb_insert_color(node, &inode->i_rb_page_cache);
- out:
- return ret;
-}
------------------------------------------------------------------------
-*/
-
-#ifndef _LINUX_RBTREE_H
-#define _LINUX_RBTREE_H
-
-#include <stdlib.h>
-
-#undef offsetof
-#ifdef __compiler_offsetof
-#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
-#else
-#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
-#endif
-
-#define container_of(ptr, type, member) ({ \
- const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
- (type *)( (char *)__mptr - offsetof(type,member) );})
-
-struct rb_node
-{
- unsigned long rb_parent_color;
-#define RB_RED 0
-#define RB_BLACK 1
- struct rb_node *rb_right;
- struct rb_node *rb_left;
-} __attribute__((aligned(sizeof(long))));
- /* The alignment might seem pointless, but allegedly CRIS needs it */
-
-struct rb_root
-{
- struct rb_node *rb_node;
-};
-
-
-#define ext2fs_rb_parent(r) ((struct rb_node *)((r)->rb_parent_color & ~3))
-#define ext2fs_rb_color(r) ((r)->rb_parent_color & 1)
-#define ext2fs_rb_is_red(r) (!ext2fs_rb_color(r))
-#define ext2fs_rb_is_black(r) ext2fs_rb_color(r)
-#define ext2fs_rb_set_red(r) do { (r)->rb_parent_color &= ~1; } while (0)
-#define ext2fs_rb_set_black(r) do { (r)->rb_parent_color |= 1; } while (0)
-
-static inline void ext2fs_rb_set_parent(struct rb_node *rb, struct rb_node *p)
-{
- rb->rb_parent_color = (rb->rb_parent_color & 3) | (unsigned long)p;
-}
-static inline void ext2fs_rb_set_color(struct rb_node *rb, int color)
-{
- rb->rb_parent_color = (rb->rb_parent_color & ~1) | color;
-}
-
-#define RB_ROOT (struct rb_root) { NULL, }
-#define ext2fs_rb_entry(ptr, type, member) container_of(ptr, type, member)
-
-#define EXT2FS_RB_EMPTY_ROOT(root) ((root)->rb_node == NULL)
-#define EXT2FS_RB_EMPTY_NODE(node) (ext2fs_rb_parent(node) == node)
-#define EXT2FS_RB_CLEAR_NODE(node) (ext2fs_rb_set_parent(node, node))
-
-extern void ext2fs_rb_insert_color(struct rb_node *, struct rb_root *);
-extern void ext2fs_rb_erase(struct rb_node *, struct rb_root *);
-
-typedef void (*rb_augment_f)(struct rb_node *node, void *data);
-
-extern void ext2fs_rb_augment_insert(struct rb_node *node,
- rb_augment_f func, void *data);
-extern struct rb_node *ext2fs_rb_augment_erase_begin(struct rb_node *node);
-extern void ext2fs_rb_augment_erase_end(struct rb_node *node,
- rb_augment_f func, void *data);
-
-/* Find logical next and previous nodes in a tree */
-extern struct rb_node *ext2fs_rb_next(struct rb_node *);
-extern struct rb_node *ext2fs_rb_prev(struct rb_node *);
-extern struct rb_node *ext2fs_rb_first(const struct rb_root *);
-extern struct rb_node *ext2fs_rb_last(const struct rb_root *);
-
-/* Fast replacement of a single node without remove/rebalance/add/rebalance */
-extern void ext2fs_rb_replace_node(struct rb_node *victim, struct rb_node *new,
- struct rb_root *root);
-
-static inline void ext2fs_rb_link_node(struct rb_node * node,
- struct rb_node * parent,
- struct rb_node ** rb_link)
-{
- node->rb_parent_color = (unsigned long )parent;
- node->rb_left = node->rb_right = NULL;
-
- *rb_link = node;
-}
-
-#endif /* _LINUX_RBTREE_H */
diff --git a/lib/ext2fs/read_bb.c b/lib/ext2fs/read_bb.c
index e5d63227..33167840 100644
--- a/lib/ext2fs/read_bb.c
+++ b/lib/ext2fs/read_bb.c
@@ -49,7 +49,7 @@ static int mark_bad_block(ext2_filsys fs, blk_t *block_nr,
return 0;
if ((*block_nr < fs->super->s_first_data_block) ||
- (*block_nr >= ext2fs_blocks_count(fs->super)))
+ (*block_nr >= fs->super->s_blocks_count))
return 0; /* Ignore illegal blocks */
rb->err = ext2fs_badblocks_list_add(rb->bb_list, *block_nr);
diff --git a/lib/ext2fs/read_bb_file.c b/lib/ext2fs/read_bb_file.c
index 89c567bb..0ca76045 100644
--- a/lib/ext2fs/read_bb_file.c
+++ b/lib/ext2fs/read_bb_file.c
@@ -38,7 +38,7 @@ errcode_t ext2fs_read_bb_FILE2(ext2_filsys fs, FILE *f,
void *priv_data))
{
errcode_t retval;
- blk64_t blockno;
+ blk_t blockno;
int count;
char buf[128];
@@ -54,15 +54,12 @@ errcode_t ext2fs_read_bb_FILE2(ext2_filsys fs, FILE *f,
while (!feof (f)) {
if (fgets(buf, sizeof(buf), f) == NULL)
break;
- count = sscanf(buf, "%llu", &blockno);
+ count = sscanf(buf, "%u", &blockno);
if (count <= 0)
continue;
- /* Badblocks isn't going to be updated for 64bit */
- if (blockno >> 32)
- return EOVERFLOW;
if (fs &&
((blockno < fs->super->s_first_data_block) ||
- (blockno >= ext2fs_blocks_count(fs->super)))) {
+ (blockno >= fs->super->s_blocks_count))) {
if (invalid)
(invalid)(fs, blockno, buf, priv_data);
continue;
diff --git a/lib/ext2fs/res_gdt.c b/lib/ext2fs/res_gdt.c
index acce650d..424d8671 100644
--- a/lib/ext2fs/res_gdt.c
+++ b/lib/ext2fs/res_gdt.c
@@ -65,9 +65,8 @@ errcode_t ext2fs_create_resize_inode(ext2_filsys fs)
struct ext2_inode inode;
__u32 *dindir_buf, *gdt_buf;
unsigned long long apb, inode_size;
- /* FIXME-64 - can't deal with extents */
blk_t dindir_blk, rsv_off, gdt_off, gdt_blk;
- int dindir_dirty = 0, inode_dirty = 0, sb_blk = 0;
+ int dindir_dirty = 0, inode_dirty = 0;
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
@@ -75,22 +74,13 @@ errcode_t ext2fs_create_resize_inode(ext2_filsys fs)
retval = ext2fs_get_array(2, fs->blocksize, &dindir_buf);
if (retval)
- return retval;
+ goto out_free;
gdt_buf = (__u32 *)((char *)dindir_buf + fs->blocksize);
retval = ext2fs_read_inode(fs, EXT2_RESIZE_INO, &inode);
if (retval)
goto out_free;
- /*
- * File systems with a blocksize of 1024 and bigalloc have
- * sb->s_first_data_block of 0; yet the superblock is still at
- * block #1. We compensate for it here.
- */
- sb_blk = sb->s_first_data_block;
- if (fs->blocksize == 1024 && sb_blk == 0)
- sb_blk = 1;
-
/* Maximum possible file size (we donly use the dindirect blocks) */
apb = EXT2_ADDR_PER_BLOCK(sb);
if ((dindir_blk = inode.i_block[EXT2_DIND_BLOCK])) {
@@ -101,7 +91,7 @@ errcode_t ext2fs_create_resize_inode(ext2_filsys fs)
if (retval)
goto out_inode;
} else {
- blk_t goal = sb_blk + fs->desc_blocks +
+ blk_t goal = sb->s_first_data_block + fs->desc_blocks +
sb->s_reserved_gdt_blocks + 2 +
fs->inode_blocks_per_group;
@@ -129,7 +119,7 @@ errcode_t ext2fs_create_resize_inode(ext2_filsys fs)
}
for (rsv_off = 0, gdt_off = fs->desc_blocks,
- gdt_blk = sb_blk + 1 + fs->desc_blocks;
+ gdt_blk = sb->s_first_data_block + 1 + fs->desc_blocks;
rsv_off < sb->s_reserved_gdt_blocks;
rsv_off++, gdt_off++, gdt_blk++) {
unsigned int three = 1, five = 5, seven = 7;
diff --git a/lib/ext2fs/rw_bitmaps.c b/lib/ext2fs/rw_bitmaps.c
index eacf86a5..4e77a8f1 100644
--- a/lib/ext2fs/rw_bitmaps.c
+++ b/lib/ext2fs/rw_bitmaps.c
@@ -34,10 +34,10 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block)
int block_nbytes, inode_nbytes;
unsigned int nbits;
errcode_t retval;
- char *block_buf = NULL, *inode_buf = NULL;
+ char *block_buf, *inode_buf;
int csum_flag = 0;
- blk64_t blk;
- blk64_t blk_itr = EXT2FS_B2C(fs, fs->super->s_first_data_block);
+ blk_t blk;
+ blk_t blk_itr = fs->super->s_first_data_block;
ext2_ino_t ino_itr = 1;
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
@@ -51,18 +51,20 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block)
inode_nbytes = block_nbytes = 0;
if (do_block) {
- block_nbytes = EXT2_CLUSTERS_PER_GROUP(fs->super) / 8;
- retval = io_channel_alloc_buf(fs->io, 0, &block_buf);
+ block_nbytes = EXT2_BLOCKS_PER_GROUP(fs->super) / 8;
+ retval = ext2fs_get_memalign(fs->blocksize, fs->blocksize,
+ &block_buf);
if (retval)
- goto errout;
+ return retval;
memset(block_buf, 0xff, fs->blocksize);
}
if (do_inode) {
inode_nbytes = (size_t)
((EXT2_INODES_PER_GROUP(fs->super)+7) / 8);
- retval = io_channel_alloc_buf(fs->io, 0, &inode_buf);
+ retval = ext2fs_get_memalign(fs->blocksize, fs->blocksize,
+ &inode_buf);
if (retval)
- goto errout;
+ return retval;
memset(inode_buf, 0xff, fs->blocksize);
}
@@ -70,33 +72,30 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block)
if (!do_block)
goto skip_block_bitmap;
- if (csum_flag && ext2fs_bg_flags_test(fs, i, EXT2_BG_BLOCK_UNINIT)
- )
+ if (csum_flag && fs->group_desc[i].bg_flags &
+ EXT2_BG_BLOCK_UNINIT)
goto skip_this_block_bitmap;
- retval = ext2fs_get_block_bitmap_range2(fs->block_map,
+ retval = ext2fs_get_block_bitmap_range(fs->block_map,
blk_itr, block_nbytes << 3, block_buf);
if (retval)
- goto errout;
+ return retval;
if (i == fs->group_desc_count - 1) {
/* Force bitmap padding for the last group */
- nbits = EXT2FS_NUM_B2C(fs,
- ((ext2fs_blocks_count(fs->super)
- - (__u64) fs->super->s_first_data_block)
- % (__u64) EXT2_BLOCKS_PER_GROUP(fs->super)));
+ nbits = ((fs->super->s_blocks_count
+ - fs->super->s_first_data_block)
+ % EXT2_BLOCKS_PER_GROUP(fs->super));
if (nbits)
for (j = nbits; j < fs->blocksize * 8; j++)
ext2fs_set_bit(j, block_buf);
}
- blk = ext2fs_block_bitmap_loc(fs, i);
+ blk = fs->group_desc[i].bg_block_bitmap;
if (blk) {
- retval = io_channel_write_blk64(fs->io, blk, 1,
- block_buf);
- if (retval) {
- retval = EXT2_ET_BLOCK_BITMAP_WRITE;
- goto errout;
- }
+ retval = io_channel_write_blk(fs->io, blk, 1,
+ block_buf);
+ if (retval)
+ return EXT2_ET_BLOCK_BITMAP_WRITE;
}
skip_this_block_bitmap:
blk_itr += block_nbytes << 3;
@@ -105,23 +104,21 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block)
if (!do_inode)
continue;
- if (csum_flag && ext2fs_bg_flags_test(fs, i, EXT2_BG_INODE_UNINIT)
- )
+ if (csum_flag && fs->group_desc[i].bg_flags &
+ EXT2_BG_INODE_UNINIT)
goto skip_this_inode_bitmap;
- retval = ext2fs_get_inode_bitmap_range2(fs->inode_map,
+ retval = ext2fs_get_inode_bitmap_range(fs->inode_map,
ino_itr, inode_nbytes << 3, inode_buf);
if (retval)
- goto errout;
+ return retval;
- blk = ext2fs_inode_bitmap_loc(fs, i);
+ blk = fs->group_desc[i].bg_inode_bitmap;
if (blk) {
- retval = io_channel_write_blk64(fs->io, blk, 1,
+ retval = io_channel_write_blk(fs->io, blk, 1,
inode_buf);
- if (retval) {
- retval = EXT2_ET_INODE_BITMAP_WRITE;
- goto errout;
- }
+ if (retval)
+ return EXT2_ET_INODE_BITMAP_WRITE;
}
skip_this_inode_bitmap:
ino_itr += inode_nbytes << 3;
@@ -136,12 +133,6 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block)
ext2fs_free_mem(&inode_buf);
}
return 0;
-errout:
- if (inode_buf)
- ext2fs_free_mem(&inode_buf);
- if (block_buf)
- ext2fs_free_mem(&block_buf);
- return retval;
}
static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
@@ -150,22 +141,19 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
char *block_bitmap = 0, *inode_bitmap = 0;
char *buf;
errcode_t retval;
- int block_nbytes = EXT2_CLUSTERS_PER_GROUP(fs->super) / 8;
+ int block_nbytes = EXT2_BLOCKS_PER_GROUP(fs->super) / 8;
int inode_nbytes = EXT2_INODES_PER_GROUP(fs->super) / 8;
int csum_flag = 0;
+ int do_image = fs->flags & EXT2_FLAG_IMAGE_FILE;
unsigned int cnt;
- blk64_t blk;
- blk64_t blk_itr = EXT2FS_B2C(fs, fs->super->s_first_data_block);
- blk64_t blk_cnt;
+ blk_t blk;
+ blk_t blk_itr = fs->super->s_first_data_block;
+ blk_t blk_cnt;
ext2_ino_t ino_itr = 1;
ext2_ino_t ino_cnt;
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
- if ((block_nbytes > (int) fs->blocksize) ||
- (inode_nbytes > (int) fs->blocksize))
- return EXT2_ET_CORRUPT_SUPERBLOCK;
-
fs->write_bitmaps = ext2fs_write_bitmaps;
if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
@@ -183,7 +171,13 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
retval = ext2fs_allocate_block_bitmap(fs, buf, &fs->block_map);
if (retval)
goto cleanup;
- retval = io_channel_alloc_buf(fs->io, 0, &block_bitmap);
+ if (do_image)
+ retval = ext2fs_get_mem(fs->blocksize, &block_bitmap);
+ else
+ retval = ext2fs_get_memalign((unsigned) block_nbytes,
+ fs->blocksize,
+ &block_bitmap);
+
if (retval)
goto cleanup;
} else
@@ -196,7 +190,8 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
retval = ext2fs_allocate_inode_bitmap(fs, buf, &fs->inode_map);
if (retval)
goto cleanup;
- retval = io_channel_alloc_buf(fs->io, 0, &inode_bitmap);
+ retval = ext2fs_get_mem(do_image ? fs->blocksize :
+ (unsigned) inode_nbytes, &inode_bitmap);
if (retval)
goto cleanup;
} else
@@ -207,14 +202,14 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
blk = (fs->image_header->offset_inodemap / fs->blocksize);
ino_cnt = fs->super->s_inodes_count;
while (inode_nbytes > 0) {
- retval = io_channel_read_blk64(fs->image_io, blk++,
+ retval = io_channel_read_blk(fs->image_io, blk++,
1, inode_bitmap);
if (retval)
goto cleanup;
cnt = fs->blocksize << 3;
if (cnt > ino_cnt)
cnt = ino_cnt;
- retval = ext2fs_set_inode_bitmap_range2(fs->inode_map,
+ retval = ext2fs_set_inode_bitmap_range(fs->inode_map,
ino_itr, cnt, inode_bitmap);
if (retval)
goto cleanup;
@@ -224,17 +219,17 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
}
blk = (fs->image_header->offset_blockmap /
fs->blocksize);
- blk_cnt = (blk64_t)EXT2_CLUSTERS_PER_GROUP(fs->super) *
+ blk_cnt = EXT2_BLOCKS_PER_GROUP(fs->super) *
fs->group_desc_count;
while (block_nbytes > 0) {
- retval = io_channel_read_blk64(fs->image_io, blk++,
+ retval = io_channel_read_blk(fs->image_io, blk++,
1, block_bitmap);
if (retval)
goto cleanup;
cnt = fs->blocksize << 3;
if (cnt > blk_cnt)
cnt = blk_cnt;
- retval = ext2fs_set_block_bitmap_range2(fs->block_map,
+ retval = ext2fs_set_block_bitmap_range(fs->block_map,
blk_itr, cnt, block_bitmap);
if (retval)
goto cleanup;
@@ -247,14 +242,14 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
for (i = 0; i < fs->group_desc_count; i++) {
if (block_bitmap) {
- blk = ext2fs_block_bitmap_loc(fs, i);
- if (csum_flag &&
- ext2fs_bg_flags_test(fs, i, EXT2_BG_BLOCK_UNINIT) &&
+ blk = fs->group_desc[i].bg_block_bitmap;
+ if (csum_flag && fs->group_desc[i].bg_flags &
+ EXT2_BG_BLOCK_UNINIT &&
ext2fs_group_desc_csum_verify(fs, i))
blk = 0;
if (blk) {
- retval = io_channel_read_blk64(fs->io, blk,
- 1, block_bitmap);
+ retval = io_channel_read_blk(fs->io, blk,
+ -block_nbytes, block_bitmap);
if (retval) {
retval = EXT2_ET_BLOCK_BITMAP_READ;
goto cleanup;
@@ -262,21 +257,21 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
} else
memset(block_bitmap, 0, block_nbytes);
cnt = block_nbytes << 3;
- retval = ext2fs_set_block_bitmap_range2(fs->block_map,
+ retval = ext2fs_set_block_bitmap_range(fs->block_map,
blk_itr, cnt, block_bitmap);
if (retval)
goto cleanup;
blk_itr += block_nbytes << 3;
}
if (inode_bitmap) {
- blk = ext2fs_inode_bitmap_loc(fs, i);
- if (csum_flag &&
- ext2fs_bg_flags_test(fs, i, EXT2_BG_INODE_UNINIT) &&
+ blk = fs->group_desc[i].bg_inode_bitmap;
+ if (csum_flag && fs->group_desc[i].bg_flags &
+ EXT2_BG_INODE_UNINIT &&
ext2fs_group_desc_csum_verify(fs, i))
blk = 0;
if (blk) {
- retval = io_channel_read_blk64(fs->io, blk,
- 1, inode_bitmap);
+ retval = io_channel_read_blk(fs->io, blk,
+ -inode_nbytes, inode_bitmap);
if (retval) {
retval = EXT2_ET_INODE_BITMAP_READ;
goto cleanup;
@@ -284,7 +279,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
} else
memset(inode_bitmap, 0, inode_nbytes);
cnt = inode_nbytes << 3;
- retval = ext2fs_set_inode_bitmap_range2(fs->inode_map,
+ retval = ext2fs_set_inode_bitmap_range(fs->inode_map,
ino_itr, cnt, inode_bitmap);
if (retval)
goto cleanup;
diff --git a/lib/ext2fs/sparse.c b/lib/ext2fs/sparse.c
new file mode 100644
index 00000000..63c11f61
--- /dev/null
+++ b/lib/ext2fs/sparse.c
@@ -0,0 +1,78 @@
+/*
+ * sparse.c --- find the groups in an ext2 filesystem with metadata backups
+ *
+ * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
+ * Copyright (C) 2002 Andreas Dilger.
+ *
+ * %Begin-Header%
+ * This file may be redistributed under the terms of the GNU Library
+ * General Public License, version 2.
+ * %End-Header%
+ */
+
+#include <stdio.h>
+
+#include "ext2_fs.h"
+#include "ext2fsP.h"
+
+static int test_root(int a, int b)
+{
+ if (a == 0)
+ return 1;
+ while (1) {
+ if (a == 1)
+ return 1;
+ if (a % b)
+ return 0;
+ a = a / b;
+ }
+}
+
+int ext2fs_bg_has_super(ext2_filsys fs, int group_block)
+{
+ if (!(fs->super->s_feature_ro_compat &
+ EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER))
+ return 1;
+
+ if (test_root(group_block, 3) || (test_root(group_block, 5)) ||
+ test_root(group_block, 7))
+ return 1;
+
+ return 0;
+}
+
+/*
+ * Iterate through the groups which hold BACKUP superblock/GDT copies in an
+ * ext3 filesystem. The counters should be initialized to 1, 5, and 7 before
+ * calling this for the first time. In a sparse filesystem it will be the
+ * sequence of powers of 3, 5, and 7: 1, 3, 5, 7, 9, 25, 27, 49, 81, ...
+ * For a non-sparse filesystem it will be every group: 1, 2, 3, 4, ...
+ */
+unsigned int ext2fs_list_backups(ext2_filsys fs, unsigned int *three,
+ unsigned int *five, unsigned int *seven)
+{
+ unsigned int *min = three;
+ int mult = 3;
+ unsigned int ret;
+
+ if (!(fs->super->s_feature_ro_compat &
+ EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER)) {
+ ret = *min;
+ *min += 1;
+ return ret;
+ }
+
+ if (*five < *min) {
+ min = five;
+ mult = 5;
+ }
+ if (*seven < *min) {
+ min = seven;
+ mult = 7;
+ }
+
+ ret = *min;
+ *min *= mult;
+
+ return ret;
+}
diff --git a/lib/ext2fs/swapfs.c b/lib/ext2fs/swapfs.c
index 46d60ef4..12427e0a 100644
--- a/lib/ext2fs/swapfs.c
+++ b/lib/ext2fs/swapfs.c
@@ -31,9 +31,9 @@ void ext2fs_swap_super(struct ext2_super_block * sb)
sb->s_free_inodes_count = ext2fs_swab32(sb->s_free_inodes_count);
sb->s_first_data_block = ext2fs_swab32(sb->s_first_data_block);
sb->s_log_block_size = ext2fs_swab32(sb->s_log_block_size);
- sb->s_log_cluster_size = ext2fs_swab32(sb->s_log_cluster_size);
+ sb->s_log_frag_size = ext2fs_swab32(sb->s_log_frag_size);
sb->s_blocks_per_group = ext2fs_swab32(sb->s_blocks_per_group);
- sb->s_clusters_per_group = ext2fs_swab32(sb->s_clusters_per_group);
+ sb->s_frags_per_group = ext2fs_swab32(sb->s_frags_per_group);
sb->s_inodes_per_group = ext2fs_swab32(sb->s_inodes_per_group);
sb->s_mtime = ext2fs_swab32(sb->s_mtime);
sb->s_wtime = ext2fs_swab32(sb->s_wtime);
@@ -70,41 +70,32 @@ void ext2fs_swap_super(struct ext2_super_block * sb)
sb->s_min_extra_isize = ext2fs_swab16(sb->s_min_extra_isize);
sb->s_want_extra_isize = ext2fs_swab16(sb->s_want_extra_isize);
sb->s_flags = ext2fs_swab32(sb->s_flags);
- sb->s_mmp_update_interval = ext2fs_swab16(sb->s_mmp_update_interval);
- sb->s_mmp_block = ext2fs_swab64(sb->s_mmp_block);
sb->s_kbytes_written = ext2fs_swab64(sb->s_kbytes_written);
sb->s_snapshot_inum = ext2fs_swab32(sb->s_snapshot_inum);
sb->s_snapshot_id = ext2fs_swab32(sb->s_snapshot_id);
sb->s_snapshot_r_blocks_count =
ext2fs_swab64(sb->s_snapshot_r_blocks_count);
sb->s_snapshot_list = ext2fs_swab32(sb->s_snapshot_list);
- sb->s_usr_quota_inum = ext2fs_swab32(sb->s_usr_quota_inum);
- sb->s_grp_quota_inum = ext2fs_swab32(sb->s_grp_quota_inum);
- sb->s_overhead_blocks = ext2fs_swab32(sb->s_overhead_blocks);
- sb->s_checksum = ext2fs_swab32(sb->s_checksum);
for (i=0; i < 4; i++)
sb->s_hash_seed[i] = ext2fs_swab32(sb->s_hash_seed[i]);
/* if journal backup is for a valid extent-based journal... */
- if (ext2fs_extent_header_verify(sb->s_jnl_blocks,
- sizeof(sb->s_jnl_blocks)) == 0) {
- /* ... swap only the journal i_size and i_size_high,
- * and the extent data is not swapped on read */
- i = 15;
- } else {
- /* direct/indirect journal: swap it all */
- i = 0;
+ if (!ext2fs_extent_header_verify(sb->s_jnl_blocks,
+ sizeof(sb->s_jnl_blocks))) {
+ /* ... swap only the journal i_size */
+ sb->s_jnl_blocks[16] = ext2fs_swab32(sb->s_jnl_blocks[16]);
+ /* and the extent data is not swapped on read */
+ return;
}
- for (; i < 17; i++)
+
+ /* direct/indirect journal: swap it all */
+ for (i=0; i < 17; i++)
sb->s_jnl_blocks[i] = ext2fs_swab32(sb->s_jnl_blocks[i]);
}
-void ext2fs_swap_group_desc2(ext2_filsys fs, struct ext2_group_desc *gdp)
+void ext2fs_swap_group_desc(struct ext2_group_desc *gdp)
{
- struct ext4_group_desc *gdp4 = (struct ext4_group_desc *)gdp;
-
- /* Do the 32-bit parts first */
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);
@@ -112,41 +103,10 @@ void ext2fs_swap_group_desc2(ext2_filsys fs, struct ext2_group_desc *gdp)
gdp->bg_free_inodes_count = ext2fs_swab16(gdp->bg_free_inodes_count);
gdp->bg_used_dirs_count = ext2fs_swab16(gdp->bg_used_dirs_count);
gdp->bg_flags = ext2fs_swab16(gdp->bg_flags);
- gdp->bg_exclude_bitmap_lo = ext2fs_swab32(gdp->bg_exclude_bitmap_lo);
- gdp->bg_block_bitmap_csum_lo =
- ext2fs_swab16(gdp->bg_block_bitmap_csum_lo);
- gdp->bg_inode_bitmap_csum_lo =
- ext2fs_swab16(gdp->bg_inode_bitmap_csum_lo);
gdp->bg_itable_unused = ext2fs_swab16(gdp->bg_itable_unused);
gdp->bg_checksum = ext2fs_swab16(gdp->bg_checksum);
- /* If we're 32-bit, we're done */
- if (fs == NULL || EXT2_DESC_SIZE(fs->super) < EXT2_MIN_DESC_SIZE_64BIT)
- return;
-
- /* Swap the 64-bit parts */
- gdp4->bg_block_bitmap_hi = ext2fs_swab32(gdp4->bg_block_bitmap_hi);
- gdp4->bg_inode_bitmap_hi = ext2fs_swab32(gdp4->bg_inode_bitmap_hi);
- gdp4->bg_inode_table_hi = ext2fs_swab32(gdp4->bg_inode_table_hi);
- gdp4->bg_free_blocks_count_hi =
- ext2fs_swab16(gdp4->bg_free_blocks_count_hi);
- gdp4->bg_free_inodes_count_hi =
- ext2fs_swab16(gdp4->bg_free_inodes_count_hi);
- gdp4->bg_used_dirs_count_hi =
- ext2fs_swab16(gdp4->bg_used_dirs_count_hi);
- gdp4->bg_itable_unused_hi = ext2fs_swab16(gdp4->bg_itable_unused_hi);
- gdp4->bg_exclude_bitmap_hi = ext2fs_swab16(gdp4->bg_exclude_bitmap_hi);
- gdp4->bg_block_bitmap_csum_hi =
- ext2fs_swab16(gdp4->bg_block_bitmap_csum_hi);
- gdp4->bg_inode_bitmap_csum_hi =
- ext2fs_swab16(gdp4->bg_inode_bitmap_csum_hi);
-}
-
-void ext2fs_swap_group_desc(struct ext2_group_desc *gdp)
-{
- ext2fs_swap_group_desc2(0, gdp);
}
-
void ext2fs_swap_ext_attr_header(struct ext2_ext_attr_header *to_header,
struct ext2_ext_attr_header *from_header)
{
@@ -258,8 +218,8 @@ void ext2fs_swap_inode_full(ext2_filsys fs, struct ext2_inode_large *t,
ext2fs_swab16 (f->osd2.linux2.l_i_uid_high);
t->osd2.linux2.l_i_gid_high =
ext2fs_swab16 (f->osd2.linux2.l_i_gid_high);
- t->osd2.linux2.l_i_checksum_lo =
- ext2fs_swab16(f->osd2.linux2.l_i_checksum_lo);
+ t->osd2.linux2.l_i_reserved2 =
+ ext2fs_swab32(f->osd2.linux2.l_i_reserved2);
break;
case EXT2_OS_HURD:
t->osd1.hurd1.h_i_translator =
@@ -293,21 +253,6 @@ void ext2fs_swap_inode_full(ext2_filsys fs, struct ext2_inode_large *t,
return;
}
- if (extra_isize >= 4)
- t->i_checksum_hi = ext2fs_swab16(f->i_checksum_hi);
- if (extra_isize >= 8)
- t->i_ctime_extra = ext2fs_swab32(f->i_ctime_extra);
- if (extra_isize >= 12)
- t->i_mtime_extra = ext2fs_swab32(f->i_mtime_extra);
- if (extra_isize >= 16)
- t->i_atime_extra = ext2fs_swab32(f->i_atime_extra);
- if (extra_isize >= 20)
- t->i_crtime = ext2fs_swab32(f->i_crtime);
- if (extra_isize >= 24)
- t->i_crtime_extra = ext2fs_swab32(f->i_crtime_extra);
- if (extra_isize >= 28)
- t->i_version_hi = ext2fs_swab32(f->i_version_hi);
-
i = sizeof(struct ext2_inode) + extra_isize + sizeof(__u32);
if (bufsize < (int) i)
return; /* no space for EA magic */
@@ -341,12 +286,4 @@ void ext2fs_swap_inode(ext2_filsys fs, struct ext2_inode *t,
sizeof(struct ext2_inode));
}
-void ext2fs_swap_mmp(struct mmp_struct *mmp)
-{
- mmp->mmp_magic = ext2fs_swab32(mmp->mmp_magic);
- mmp->mmp_seq = ext2fs_swab32(mmp->mmp_seq);
- mmp->mmp_time = ext2fs_swab64(mmp->mmp_time);
- mmp->mmp_check_interval = ext2fs_swab16(mmp->mmp_check_interval);
-}
-
#endif
diff --git a/lib/ext2fs/symlink.c b/lib/ext2fs/symlink.c
deleted file mode 100644
index 4478dffe..00000000
--- a/lib/ext2fs/symlink.c
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * symlink.c --- make a symlink in the filesystem, based on mkdir.c
- *
- * Copyright (c) 2012, Intel Corporation.
- * All Rights Reserved.
- *
- * %Begin-Header%
- * This file may be redistributed under the terms of the GNU Library
- * General Public License, version 2.
- * %End-Header%
- */
-
-#include <stdio.h>
-#include <string.h>
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <fcntl.h>
-#include <time.h>
-#if HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#include "ext2_fs.h"
-#include "ext2fs.h"
-
-errcode_t ext2fs_symlink(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t ino,
- const char *name, char *target)
-{
- ext2_extent_handle_t handle;
- errcode_t retval;
- struct ext2_inode inode;
- ext2_ino_t scratch_ino;
- blk64_t blk;
- int fastlink;
- unsigned int target_len;
- char *block_buf = 0;
-
- EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
-
- /* The Linux kernel doesn't allow for links longer than a block */
- target_len = strlen(target);
- if (target_len > fs->blocksize) {
- retval = EXT2_ET_INVALID_ARGUMENT;
- goto cleanup;
- }
-
- /*
- * Allocate a data block for slow links
- */
- fastlink = (target_len < sizeof(inode.i_block));
- if (!fastlink) {
- retval = ext2fs_new_block2(fs, 0, 0, &blk);
- if (retval)
- goto cleanup;
- retval = ext2fs_get_mem(fs->blocksize, &block_buf);
- if (retval)
- goto cleanup;
- }
-
- /*
- * Allocate an inode, if necessary
- */
- if (!ino) {
- retval = ext2fs_new_inode(fs, parent, LINUX_S_IFLNK | 0755,
- 0, &ino);
- if (retval)
- goto cleanup;
- }
-
- /*
- * Create the inode structure....
- */
- memset(&inode, 0, sizeof(struct ext2_inode));
- inode.i_mode = LINUX_S_IFLNK | 0777;
- inode.i_uid = inode.i_gid = 0;
- ext2fs_iblk_set(fs, &inode, fastlink ? 0 : 1);
- inode.i_links_count = 1;
- inode.i_size = target_len;
- /* The time fields are set by ext2fs_write_new_inode() */
-
- if (fastlink) {
- /* Fast symlinks, target stored in inode */
- strcpy((char *)&inode.i_block, target);
- } else {
- /* Slow symlinks, target stored in the first block */
- memset(block_buf, 0, fs->blocksize);
- strcpy(block_buf, target);
- if (fs->super->s_feature_incompat &
- EXT3_FEATURE_INCOMPAT_EXTENTS) {
- /*
- * The extent bmap is setup after the inode and block
- * have been written out below.
- */
- inode.i_flags |= EXT4_EXTENTS_FL;
- }
- }
-
- /*
- * Write out the inode and inode data block. The inode generation
- * number is assigned by write_new_inode, which means that the
- * operations using ino must come after it.
- */
- retval = ext2fs_write_new_inode(fs, ino, &inode);
- if (retval)
- goto cleanup;
-
- if (!fastlink) {
- retval = ext2fs_bmap2(fs, ino, &inode, NULL, BMAP_SET, 0, NULL,
- &blk);
- if (retval)
- goto cleanup;
-
- retval = io_channel_write_blk64(fs->io, blk, 1, block_buf);
- if (retval)
- goto cleanup;
- }
-
- /*
- * Link the symlink into the filesystem hierarchy
- */
- if (name) {
- retval = ext2fs_lookup(fs, parent, name, strlen(name), 0,
- &scratch_ino);
- if (!retval) {
- retval = EXT2_ET_FILE_EXISTS;
- goto cleanup;
- }
- if (retval != EXT2_ET_FILE_NOT_FOUND)
- goto cleanup;
- retval = ext2fs_link(fs, parent, name, ino, EXT2_FT_SYMLINK);
- if (retval)
- goto cleanup;
- }
-
- /*
- * Update accounting....
- */
- if (!fastlink)
- ext2fs_block_alloc_stats2(fs, blk, +1);
- ext2fs_inode_alloc_stats2(fs, ino, +1, 0);
-
-cleanup:
- if (block_buf)
- ext2fs_free_mem(&block_buf);
- return retval;
-}
diff --git a/lib/ext2fs/tdb.c b/lib/ext2fs/tdb.c
index 869c4057..0c82a248 100644
--- a/lib/ext2fs/tdb.c
+++ b/lib/ext2fs/tdb.c
@@ -107,12 +107,14 @@ typedef int bool;
#include "tdb.h"
-static TDB_DATA tdb_null;
-
#ifndef u32
#define u32 unsigned
#endif
+#ifndef HAVE_GETPAGESIZE
+#define getpagesize() 0x2000
+#endif
+
typedef u32 tdb_len_t;
typedef u32 tdb_off_t;
@@ -1747,7 +1749,7 @@ static int transaction_sync(struct tdb_context *tdb, tdb_off_t offset, tdb_len_t
TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction: fsync failed\n"));
return -1;
}
-#if defined(HAVE_MSYNC) && defined(MS_SYNC)
+#ifdef MS_SYNC
if (tdb->map_ptr) {
tdb_off_t moffset = offset & ~(tdb->page_size-1);
if (msync(moffset + (char *)tdb->map_ptr,
@@ -3055,6 +3057,8 @@ int tdb_printfreelist(struct tdb_context *tdb)
/* file: tdb.c */
+TDB_DATA tdb_null;
+
/*
non-blocking increment of the tdb sequence number if the tdb has been opened using
the TDB_SEQNUM flag
@@ -3706,17 +3710,17 @@ void tdb_enable_seqnum(struct tdb_context *tdb)
static struct tdb_context *tdbs = NULL;
-/* This is from a hash algorithm suggested by Rogier Wolff */
+/* This is based on the hash algorithm from gdbm */
static unsigned int default_tdb_hash(TDB_DATA *key)
{
u32 value; /* Used to compute the hash value. */
u32 i; /* Used to cycle through random values. */
/* Set the initial value from the key size. */
- for (value = 0, i=0; i < key->dsize; i++)
- value = value * 256 + key->dptr[i] + (value >> 24) * 241;
+ for (value = 0x238F13AF * key->dsize, i=0; i < key->dsize; i++)
+ value = (value + (key->dptr[i] << (i*5 % 24)));
- return value;
+ return (1103515243 * value + 12345);
}
@@ -3834,7 +3838,7 @@ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
tdb->hash_fn = hash_fn ? hash_fn : default_tdb_hash;
/* cache the page size */
- tdb->page_size = sysconf(_SC_PAGESIZE);
+ tdb->page_size = getpagesize();
if (tdb->page_size <= 0) {
tdb->page_size = 0x2000;
}
diff --git a/lib/ext2fs/tdb.h b/lib/ext2fs/tdb.h
index 732ef0ec..bfcd9436 100644
--- a/lib/ext2fs/tdb.h
+++ b/lib/ext2fs/tdb.h
@@ -206,6 +206,8 @@ void tdb_dump_all(struct tdb_context *tdb);
int tdb_printfreelist(struct tdb_context *tdb);
int tdb_validate_freelist(struct tdb_context *tdb, int *pnum_entries);
+extern TDB_DATA tdb_null;
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/ext2fs/test_io.c b/lib/ext2fs/test_io.c
index d79c6d58..8d887a86 100644
--- a/lib/ext2fs/test_io.c
+++ b/lib/ext2fs/test_io.c
@@ -9,12 +9,6 @@
* %End-Header%
*/
-#if HAVE_SECURE_GETENV
-#define _GNU_SOURCE
-#endif
-#if HAVE_SECURE_GETENV
-#define _GNU_SOURCE
-#endif
#include <stdio.h>
#include <string.h>
#if HAVE_UNISTD_H
@@ -79,8 +73,7 @@ static errcode_t test_write_byte(io_channel channel, unsigned long offset,
static errcode_t test_set_option(io_channel channel, const char *option,
const char *arg);
static errcode_t test_get_stats(io_channel channel, io_stats *stats);
-static errcode_t test_discard(io_channel channel, unsigned long long block,
- unsigned long long count);
+
static struct struct_io_manager struct_test_manager = {
EXT2_ET_MAGIC_IO_MANAGER,
@@ -96,7 +89,6 @@ static struct struct_io_manager struct_test_manager = {
test_get_stats,
test_read_blk64,
test_write_blk64,
- test_discard,
};
io_manager test_io_manager = &struct_test_manager;
@@ -128,7 +120,6 @@ void (*test_io_cb_write_byte)
#define TEST_FLAG_FLUSH 0x08
#define TEST_FLAG_DUMP 0x10
#define TEST_FLAG_SET_OPTION 0x20
-#define TEST_FLAG_DISCARD 0x40
static void test_dump_block(io_channel channel,
struct test_private_data *data,
@@ -178,9 +169,7 @@ static char *safe_getenv(const char *arg)
#endif
#endif
-#if defined(HAVE_SECURE_GETENV)
- return secure_getenv(arg);
-#elif defined(HAVE___SECURE_GETENV)
+#ifdef HAVE___SECURE_GETENV
return __secure_getenv(arg);
#else
return getenv(arg);
@@ -198,12 +187,14 @@ static errcode_t test_open(const char *name, int flags, io_channel *channel)
return EXT2_ET_BAD_DEVICE_NAME;
retval = ext2fs_get_mem(sizeof(struct struct_io_channel), &io);
if (retval)
- goto cleanup;
+ return retval;
memset(io, 0, sizeof(struct struct_io_channel));
io->magic = EXT2_ET_MAGIC_IO_CHANNEL;
retval = ext2fs_get_mem(sizeof(struct test_private_data), &data);
- if (retval)
+ if (retval) {
+ retval = EXT2_ET_NO_MEMORY;
goto cleanup;
+ }
io->manager = test_io_manager;
retval = ext2fs_get_mem(strlen(name)+1, &io->name);
if (retval)
@@ -254,9 +245,6 @@ static errcode_t test_open(const char *name, int flags, io_channel *channel)
if ((value = safe_getenv("TEST_IO_WRITE_ABORT")) != NULL)
data->write_abort_count = strtoul(value, NULL, 0);
- if (data->real)
- io->align = data->real->align;
-
*channel = io;
return 0;
@@ -302,10 +290,8 @@ static errcode_t test_set_blksize(io_channel channel, int blksize)
data = (struct test_private_data *) channel->private_data;
EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL);
- if (data->real) {
+ if (data->real)
retval = io_channel_set_blksize(data->real, blksize);
- channel->align = data->real->align;
- }
if (data->set_blksize)
data->set_blksize(blksize, retval);
if (data->flags & TEST_FLAG_SET_BLKSIZE)
@@ -509,22 +495,3 @@ static errcode_t test_get_stats(io_channel channel, io_stats *stats)
}
return retval;
}
-
-static errcode_t test_discard(io_channel channel, unsigned long long block,
- unsigned long long count)
-{
- struct test_private_data *data;
- errcode_t retval = 0;
-
- EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
- data = (struct test_private_data *) channel->private_data;
- EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL);
-
- if (data->real)
- retval = io_channel_discard(data->real, block, count);
- if (data->flags & TEST_FLAG_DISCARD)
- fprintf(data->outfile,
- "Test_io: discard(%llu, %llu) returned %s\n",
- block, count, retval ? error_message(retval) : "OK");
- return retval;
-}
diff --git a/lib/ext2fs/tst_badblocks.c b/lib/ext2fs/tst_badblocks.c
index 717b95b9..82090b1c 100644
--- a/lib/ext2fs/tst_badblocks.c
+++ b/lib/ext2fs/tst_badblocks.c
@@ -227,7 +227,7 @@ int file_test_invalid(badblocks_list bb)
fs->super = malloc(SUPERBLOCK_SIZE);
memset(fs->super, 0, SUPERBLOCK_SIZE);
fs->super->s_first_data_block = 1;
- ext2fs_blocks_count_set(fs->super, 100);
+ fs->super->s_blocks_count = 100;
f = tmpfile();
if (!f) {
diff --git a/lib/ext2fs/tst_bitmaps.c b/lib/ext2fs/tst_bitmaps.c
deleted file mode 100644
index d433e77d..00000000
--- a/lib/ext2fs/tst_bitmaps.c
+++ /dev/null
@@ -1,652 +0,0 @@
-/*
- * tst_bitmaps.c
- *
- * Copyright (C) 2011 Theodore Ts'o.
- *
- * %Begin-Header%
- * This file may be redistributed under the terms of the GNU Library
- * General Public License, version 2.
- * %End-Header%
- */
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#ifdef HAVE_GETOPT_H
-#include <getopt.h>
-#endif
-#include <string.h>
-#include <fcntl.h>
-#include <time.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include "ss/ss.h"
-
-#include "ext2_fs.h"
-#include "ext2fs.h"
-#include "ext2fsP.h"
-
-extern ss_request_table tst_bitmaps_cmds;
-
-static char subsystem_name[] = "tst_bitmaps";
-static char version[] = "1.0";
-
-ext2_filsys test_fs;
-int exit_status = 0;
-
-static int source_file(const char *cmd_file, int sci_idx)
-{
- FILE *f;
- char buf[256];
- char *cp;
- int retval;
- int noecho;
-
- if (strcmp(cmd_file, "-") == 0)
- f = stdin;
- else {
- f = fopen(cmd_file, "r");
- if (!f) {
- perror(cmd_file);
- exit(1);
- }
- }
- fflush(stdout);
- fflush(stderr);
- setbuf(stdout, NULL);
- setbuf(stderr, NULL);
- while (!feof(f)) {
- if (fgets(buf, sizeof(buf), f) == NULL)
- break;
- if (buf[0] == '#')
- continue;
- noecho = 0;
- if (buf[0] == '-') {
- noecho = 1;
- buf[0] = ' ';
- }
- cp = strchr(buf, '\n');
- if (cp)
- *cp = 0;
- cp = strchr(buf, '\r');
- if (cp)
- *cp = 0;
- if (!noecho)
- printf("%s: %s\n", subsystem_name, buf);
- retval = ss_execute_line(sci_idx, buf);
- if (retval) {
- ss_perror(sci_idx, retval, buf);
- exit_status++;
- }
- }
- return exit_status;
-}
-
-
-/*
- * This function resets the libc getopt() function, which keeps
- * internal state. Bad design! Stupid libc API designers! No
- * biscuit!
- *
- * BSD-derived getopt() functions require that optind be reset to 1 in
- * order to reset getopt() state. This used to be generally accepted
- * way of resetting getopt(). However, glibc's getopt()
- * has additional getopt() state beyond optind, and requires that
- * optind be set zero to reset its state. So the unfortunate state of
- * affairs is that BSD-derived versions of getopt() misbehave if
- * optind is set to 0 in order to reset getopt(), and glibc's getopt()
- * will core dump if optind is set 1 in order to reset getopt().
- *
- * More modern versions of BSD require that optreset be set to 1 in
- * order to reset getopt(). Sigh. Standards, anyone?
- *
- * We hide the hair here.
- */
-void reset_getopt(void)
-{
-#if defined(__GLIBC__) || defined(__linux__)
- optind = 0;
-#else
- optind = 1;
-#endif
-#ifdef HAVE_OPTRESET
- optreset = 1; /* Makes BSD getopt happy */
-#endif
-}
-
-/*
- * This function will convert a string to an unsigned long, printing
- * an error message if it fails, and returning success or failure in err.
- */
-unsigned long parse_ulong(const char *str, const char *cmd,
- const char *descr, int *err)
-{
- char *tmp;
- unsigned long ret;
-
- ret = strtoul(str, &tmp, 0);
- if (*tmp == 0) {
- if (err)
- *err = 0;
- return ret;
- }
- com_err(cmd, 0, "Bad %s - %s", descr, str);
- if (err)
- *err = 1;
- else
- exit(1);
- return 0;
-}
-
-
-int check_fs_open(char *name)
-{
- if (!test_fs) {
- com_err(name, 0, "Filesystem not open");
- return 1;
- }
- return 0;
-}
-
-static void setup_filesystem(const char *name,
- unsigned int blocks, unsigned int inodes,
- unsigned int type, int flags)
-{
- struct ext2_super_block param;
- errcode_t retval;
-
- memset(&param, 0, sizeof(param));
- ext2fs_blocks_count_set(&param, blocks);
- param.s_inodes_count = inodes;
-
- retval = ext2fs_initialize("test fs", flags, &param,
- test_io_manager, &test_fs);
-
- if (retval) {
- com_err(name, retval, "while initializing filesystem");
- return;
- }
- test_fs->default_bitmap_type = type;
- ext2fs_free_block_bitmap(test_fs->block_map);
- test_fs->block_map = 0;
- ext2fs_free_inode_bitmap(test_fs->inode_map);
- test_fs->inode_map = 0;
- retval = ext2fs_allocate_block_bitmap(test_fs, "block bitmap",
- &test_fs->block_map);
- if (retval) {
- com_err(name, retval, "while allocating block bitmap");
- goto errout;
- }
- retval = ext2fs_allocate_inode_bitmap(test_fs, "inode bitmap",
- &test_fs->inode_map);
- if (retval) {
- com_err(name, retval, "while allocating inode bitmap");
- goto errout;
- }
- return;
-
-errout:
- ext2fs_close(test_fs);
- test_fs = 0;
-}
-
-void setup_cmd(int argc, char **argv)
-{
- int c, err;
- unsigned int blocks = 128;
- unsigned int inodes = 0;
- unsigned int type = EXT2FS_BMAP64_BITARRAY;
- int flags = EXT2_FLAG_64BITS;
-
- if (test_fs) {
- ext2fs_close(test_fs);
- test_fs = 0;
- }
-
- reset_getopt();
- while ((c = getopt(argc, argv, "b:i:lt:")) != EOF) {
- switch (c) {
- case 'b':
- blocks = parse_ulong(optarg, argv[0],
- "number of blocks", &err);
- if (err)
- return;
- break;
- case 'i':
- inodes = parse_ulong(optarg, argv[0],
- "number of blocks", &err);
- if (err)
- return;
- break;
- case 'l': /* Legacy bitmaps */
- flags = 0;
- break;
- case 't':
- type = parse_ulong(optarg, argv[0],
- "bitmap backend type", &err);
- if (err)
- return;
- break;
- default:
- fprintf(stderr, "%s: usage: setup [-b blocks] "
- "[-i inodes] [-t type]\n", argv[0]);
- return;
- }
- }
- setup_filesystem(argv[0], blocks, inodes, type, flags);
-}
-
-void close_cmd(int argc, char **argv)
-{
- if (check_fs_open(argv[0]))
- return;
-
- ext2fs_close(test_fs);
- test_fs = 0;
-}
-
-
-void dump_bitmap(ext2fs_generic_bitmap bmap, unsigned int start, unsigned num)
-{
- unsigned char *buf;
- errcode_t retval;
- int i, len = (num - start + 7) / 8;
-
- buf = malloc(len);
- if (!buf) {
- com_err("dump_bitmap", 0, "couldn't allocate buffer");
- return;
- }
- memset(buf, 0, len);
- retval = ext2fs_get_generic_bmap_range(bmap, (__u64) start, num, buf);
- if (retval) {
- com_err("dump_bitmap", retval,
- "while calling ext2fs_generic_bmap_range");
- free(buf);
- return;
- }
- for (i=0; i < len; i++)
- printf("%02x", buf[i]);
- printf("\n");
- printf("bits set: %u\n", ext2fs_bitcount(buf, len));
- free(buf);
-}
-
-void dump_inode_bitmap_cmd(int argc, char **argv)
-{
- if (check_fs_open(argv[0]))
- return;
-
- printf("inode bitmap: ");
- dump_bitmap(test_fs->inode_map, 1, test_fs->super->s_inodes_count);
-}
-
-void dump_block_bitmap_cmd(int argc, char **argv)
-{
- if (check_fs_open(argv[0]))
- return;
-
- printf("block bitmap: ");
- dump_bitmap(test_fs->block_map, test_fs->super->s_first_data_block,
- test_fs->super->s_blocks_count);
-}
-
-void do_setb(int argc, char *argv[])
-{
- unsigned int block, num;
- int err;
- int test_result, op_result;
-
- if (check_fs_open(argv[0]))
- return;
-
- if (argc != 2 && argc != 3) {
- com_err(argv[0], 0, "Usage: setb <block> [num]");
- return;
- }
-
- block = parse_ulong(argv[1], argv[0], "block", &err);
- if (err)
- return;
-
- if (argc == 3) {
- num = parse_ulong(argv[2], argv[0], "num", &err);
- if (err)
- return;
-
- ext2fs_mark_block_bitmap_range2(test_fs->block_map,
- block, num);
- printf("Marking blocks %u to %u\n", block, block + num - 1);
- return;
- }
-
- test_result = ext2fs_test_block_bitmap2(test_fs->block_map, block);
- op_result = ext2fs_mark_block_bitmap2(test_fs->block_map, block);
- printf("Setting block %u, was %s before\n", block, op_result ?
- "set" : "clear");
- if (!test_result != !op_result)
- com_err(argv[0], 0, "*ERROR* test_result different! (%d, %d)",
- test_result, op_result);
-}
-
-void do_clearb(int argc, char *argv[])
-{
- unsigned int block, num;
- int err;
- int test_result, op_result;
-
- if (check_fs_open(argv[0]))
- return;
-
- if (argc != 2 && argc != 3) {
- com_err(argv[0], 0, "Usage: clearb <block> [num]");
- return;
- }
-
- block = parse_ulong(argv[1], argv[0], "block", &err);
- if (err)
- return;
-
- if (argc == 3) {
- num = parse_ulong(argv[2], argv[0], "num", &err);
- if (err)
- return;
-
- ext2fs_unmark_block_bitmap_range2(test_fs->block_map,
- block, num);
- printf("Clearing blocks %u to %u\n", block, block + num - 1);
- return;
- }
-
- test_result = ext2fs_test_block_bitmap2(test_fs->block_map, block);
- op_result = ext2fs_unmark_block_bitmap2(test_fs->block_map, block);
- printf("Clearing block %u, was %s before\n", block, op_result ?
- "set" : "clear");
- if (!test_result != !op_result)
- com_err(argv[0], 0, "*ERROR* test_result different! (%d, %d)",
- test_result, op_result);
-}
-
-void do_testb(int argc, char *argv[])
-{
- unsigned int block, num;
- int err;
- int test_result;
-
- if (check_fs_open(argv[0]))
- return;
-
- if (argc != 2 && argc != 3) {
- com_err(argv[0], 0, "Usage: testb <block> [num]");
- return;
- }
-
- block = parse_ulong(argv[1], argv[0], "block", &err);
- if (err)
- return;
-
- if (argc == 3) {
- num = parse_ulong(argv[2], argv[0], "num", &err);
- if (err)
- return;
-
- test_result =
- ext2fs_test_block_bitmap_range2(test_fs->block_map,
- block, num);
- printf("Blocks %u to %u are %sall clear.\n",
- block, block + num - 1, test_result ? "" : "NOT ");
- return;
- }
-
- test_result = ext2fs_test_block_bitmap2(test_fs->block_map, block);
- printf("Block %u is %s\n", block, test_result ? "set" : "clear");
-}
-
-void do_ffzb(int argc, char *argv[])
-{
- unsigned int start, end;
- int err;
- errcode_t retval;
- blk64_t out;
-
- if (check_fs_open(argv[0]))
- return;
-
- if (argc != 3 && argc != 3) {
- com_err(argv[0], 0, "Usage: ffzb <start> <end>");
- return;
- }
-
- start = parse_ulong(argv[1], argv[0], "start", &err);
- if (err)
- return;
-
- end = parse_ulong(argv[2], argv[0], "end", &err);
- if (err)
- return;
-
- retval = ext2fs_find_first_zero_block_bitmap2(test_fs->block_map,
- start, end, &out);
- if (retval) {
- printf("ext2fs_find_first_zero_block_bitmap2() returned %s\n",
- error_message(retval));
- return;
- }
- printf("First unmarked block is %llu\n", out);
-}
-
-
-void do_zerob(int argc, char *argv[])
-{
- if (check_fs_open(argv[0]))
- return;
-
- printf("Clearing block bitmap.\n");
- ext2fs_clear_block_bitmap(test_fs->block_map);
-}
-
-void do_seti(int argc, char *argv[])
-{
- unsigned int inode;
- int err;
- int test_result, op_result;
-
- if (check_fs_open(argv[0]))
- return;
-
- if (argc != 2) {
- com_err(argv[0], 0, "Usage: seti <inode>");
- return;
- }
-
- inode = parse_ulong(argv[1], argv[0], "inode", &err);
- if (err)
- return;
-
- test_result = ext2fs_test_inode_bitmap2(test_fs->inode_map, inode);
- op_result = ext2fs_mark_inode_bitmap2(test_fs->inode_map, inode);
- printf("Setting inode %u, was %s before\n", inode, op_result ?
- "set" : "clear");
- if (!test_result != !op_result) {
- com_err(argv[0], 0, "*ERROR* test_result different! (%d, %d)",
- test_result, op_result);
- exit_status++;
- }
-}
-
-void do_cleari(int argc, char *argv[])
-{
- unsigned int inode;
- int err;
- int test_result, op_result;
-
- if (check_fs_open(argv[0]))
- return;
-
- if (argc != 2) {
- com_err(argv[0], 0, "Usage: clearb <inode>");
- return;
- }
-
- inode = parse_ulong(argv[1], argv[0], "inode", &err);
- if (err)
- return;
-
- test_result = ext2fs_test_inode_bitmap2(test_fs->inode_map, inode);
- op_result = ext2fs_unmark_inode_bitmap2(test_fs->inode_map, inode);
- printf("Clearing inode %u, was %s before\n", inode, op_result ?
- "set" : "clear");
- if (!test_result != !op_result) {
- com_err(argv[0], 0, "*ERROR* test_result different! (%d, %d)",
- test_result, op_result);
- exit_status++;
- }
-}
-
-void do_testi(int argc, char *argv[])
-{
- unsigned int inode;
- int err;
- int test_result;
-
- if (check_fs_open(argv[0]))
- return;
-
- if (argc != 2) {
- com_err(argv[0], 0, "Usage: testb <inode>");
- return;
- }
-
- inode = parse_ulong(argv[1], argv[0], "inode", &err);
- if (err)
- return;
-
- test_result = ext2fs_test_inode_bitmap2(test_fs->inode_map, inode);
- printf("Inode %u is %s\n", inode, test_result ? "set" : "clear");
-}
-
-void do_ffzi(int argc, char *argv[])
-{
- unsigned int start, end;
- int err;
- errcode_t retval;
- ext2_ino_t out;
-
- if (check_fs_open(argv[0]))
- return;
-
- if (argc != 3 && argc != 3) {
- com_err(argv[0], 0, "Usage: ffzi <start> <end>");
- return;
- }
-
- start = parse_ulong(argv[1], argv[0], "start", &err);
- if (err)
- return;
-
- end = parse_ulong(argv[2], argv[0], "end", &err);
- if (err)
- return;
-
- retval = ext2fs_find_first_zero_inode_bitmap2(test_fs->inode_map,
- start, end, &out);
- if (retval) {
- printf("ext2fs_find_first_zero_inode_bitmap2() returned %s\n",
- error_message(retval));
- return;
- }
- printf("First unmarked inode is %u\n", out);
-}
-
-
-void do_zeroi(int argc, char *argv[])
-{
- if (check_fs_open(argv[0]))
- return;
-
- printf("Clearing inode bitmap.\n");
- ext2fs_clear_inode_bitmap(test_fs->inode_map);
-}
-
-int main(int argc, char **argv)
-{
- unsigned int blocks = 128;
- unsigned int inodes = 0;
- unsigned int type = EXT2FS_BMAP64_BITARRAY;
- int c, err, code;
- char *request = (char *)NULL;
- char *cmd_file = 0;
- int sci_idx;
- int flags = EXT2_FLAG_64BITS;
-
- add_error_table(&et_ss_error_table);
- add_error_table(&et_ext2_error_table);
- while ((c = getopt (argc, argv, "b:i:lt:R:f:")) != EOF) {
- switch (c) {
- case 'b':
- blocks = parse_ulong(optarg, argv[0],
- "number of blocks", &err);
- if (err)
- exit(1);
- break;
- case 'i':
- inodes = parse_ulong(optarg, argv[0],
- "number of blocks", &err);
- if (err)
- exit(1);
- break;
- case 'l': /* Legacy bitmaps */
- flags = 0;
- break;
- case 't':
- type = parse_ulong(optarg, argv[0],
- "bitmap backend type", &err);
- if (err)
- exit(1);
- break;
- case 'R':
- request = optarg;
- break;
- case 'f':
- cmd_file = optarg;
- break;
- default:
- com_err(argv[0], 0, "Usage: %s [-R request] "
- "[-f cmd_file]", subsystem_name);
- exit(1);
- }
- }
-
- sci_idx = ss_create_invocation(subsystem_name, version,
- (char *)NULL, &tst_bitmaps_cmds, &code);
- if (code) {
- ss_perror(sci_idx, code, "creating invocation");
- exit(1);
- }
-
- (void) ss_add_request_table (sci_idx, &ss_std_requests, 1, &code);
- if (code) {
- ss_perror(sci_idx, code, "adding standard requests");
- exit (1);
- }
-
- printf("%s %s. Type '?' for a list of commands.\n\n",
- subsystem_name, version);
-
- setup_filesystem(argv[0], blocks, inodes, type, flags);
-
- if (request) {
- code = ss_execute_line(sci_idx, request);
- if (code) {
- ss_perror(sci_idx, code, request);
- exit_status++;
- }
- } else if (cmd_file) {
- exit_status = source_file(cmd_file, sci_idx);
- } else {
- ss_listen(sci_idx);
- }
-
- exit(exit_status);
-}
-
diff --git a/lib/ext2fs/tst_bitmaps_cmd.ct b/lib/ext2fs/tst_bitmaps_cmd.ct
deleted file mode 100644
index 1e1e5d34..00000000
--- a/lib/ext2fs/tst_bitmaps_cmd.ct
+++ /dev/null
@@ -1,45 +0,0 @@
-command_table tst_bitmaps_cmds;
-
-request setup_cmd, "Setup file system",
- setup;
-
-request close_cmd, "Close file system",
- close;
-
-request dump_inode_bitmap_cmd, "Dump the inode bitmap",
- dump_inode_bitmap, dump_ib;
-
-request dump_block_bitmap_cmd, "Dump the block bitmap",
- dump_block_bitmap, dump_bb;
-
-request do_setb, "Set block",
- set_block, setb;
-
-request do_clearb, "Clear block",
- clear_block, clearb;
-
-request do_testb, "Test block",
- test_block, testb;
-
-request do_ffzb, "Find first zero block",
- find_first_zero_block, ffzb;
-
-request do_zerob, "Clear block bitmap",
- clear_block_bitmap, zerob;
-
-request do_seti, "Set inode",
- set_inode, seti;
-
-request do_cleari, "Clear inode",
- clear_inode, cleari;
-
-request do_testi, "Test inode",
- test_inode, testi;
-
-request do_ffzi, "Find first zero inode",
- find_first_zero_inode, ffzi;
-
-request do_zeroi, "Clear inode bitmap",
- clear_inode_bitmap, zeroi;
-
-end;
diff --git a/lib/ext2fs/tst_bitmaps_cmds b/lib/ext2fs/tst_bitmaps_cmds
deleted file mode 100644
index 31e2a600..00000000
--- a/lib/ext2fs/tst_bitmaps_cmds
+++ /dev/null
@@ -1,99 +0,0 @@
-setb 12
-setb 12
-clearb 12
-clearb 12
-setb 12
-setb 14
-setb 16
-testb 13
-testb 15
-testb 12
-testb 14
-setb 13
-setb 15
-testb 12
-testb 11
-testb 15
-testb 16
-dump_bb
-ffzb 11 16
-ffzb 12 16
-ffzb 12 20
-clearb 13
-ffzb 12 20
-setb 13
-clearb 12 7
-testb 12 7
-setb 15
-testb 12 7
-clearb 15
-testb 12 7
-setb 12 7
-dump_bb
-seti 2
-seti 5
-seti 4
-seti 3
-seti 4
-seti 5
-testi 6
-testi 1
-dump_ib
-ffzi 1 6
-ffzi 2 5
-ffzi 2 6
-cleari 4
-ffzi 2 6
-zeroi
-testi 5
-seti 5
-seti 5
-cleari 5
-cleari 5
-testi 17
-testi 6
-testi 4
-clearb 7 12
-dump_bb
-setb 1
-dump_bb
-setb 2
-dump_bb
-setb 3
-dump_bb
-setb 4
-dump_bb
-setb 5
-dump_bb
-setb 6
-dump_bb
-setb 7
-dump_bb
-setb 8
-dump_bb
-setb 10
-setb 12
-setb 14
-setb 17
-setb 19
-setb 24
-setb 26
-setb 27
-setb 30
-setb 31
-setb 32
-setb 35
-setb 39
-setb 40
-setb 44
-setb 46
-setb 47
-setb 49
-setb 51
-setb 52
-clearb 2
-clearb 3
-clearb 7
-dump_bb
-quit
-
diff --git a/lib/ext2fs/tst_bitmaps_exp b/lib/ext2fs/tst_bitmaps_exp
deleted file mode 100644
index 2d62b66d..00000000
--- a/lib/ext2fs/tst_bitmaps_exp
+++ /dev/null
@@ -1,211 +0,0 @@
-tst_bitmaps 1.0. Type '?' for a list of commands.
-
-tst_bitmaps: setb 12
-Setting block 12, was clear before
-tst_bitmaps: setb 12
-Setting block 12, was set before
-tst_bitmaps: clearb 12
-Clearing block 12, was set before
-tst_bitmaps: clearb 12
-Clearing block 12, was clear before
-tst_bitmaps: setb 12
-Setting block 12, was clear before
-tst_bitmaps: setb 14
-Setting block 14, was clear before
-tst_bitmaps: setb 16
-Setting block 16, was clear before
-tst_bitmaps: testb 13
-Block 13 is clear
-tst_bitmaps: testb 15
-Block 15 is clear
-tst_bitmaps: testb 12
-Block 12 is set
-tst_bitmaps: testb 14
-Block 14 is set
-tst_bitmaps: setb 13
-Setting block 13, was clear before
-tst_bitmaps: setb 15
-Setting block 15, was clear before
-tst_bitmaps: testb 12
-Block 12 is set
-tst_bitmaps: testb 11
-Block 11 is clear
-tst_bitmaps: testb 15
-Block 15 is set
-tst_bitmaps: testb 16
-Block 16 is set
-tst_bitmaps: dump_bb
-block bitmap: 00f80000000000000000000000000000
-bits set: 5
-tst_bitmaps: ffzb 11 16
-First unmarked block is 11
-tst_bitmaps: ffzb 12 16
-ext2fs_find_first_zero_block_bitmap2() returned No such file or directory
-tst_bitmaps: ffzb 12 20
-First unmarked block is 17
-tst_bitmaps: clearb 13
-Clearing block 13, was set before
-tst_bitmaps: ffzb 12 20
-First unmarked block is 13
-tst_bitmaps: setb 13
-Setting block 13, was clear before
-tst_bitmaps: clearb 12 7
-Clearing blocks 12 to 18
-tst_bitmaps: testb 12 7
-Blocks 12 to 18 are all clear.
-tst_bitmaps: setb 15
-Setting block 15, was clear before
-tst_bitmaps: testb 12 7
-Blocks 12 to 18 are NOT all clear.
-tst_bitmaps: clearb 15
-Clearing block 15, was set before
-tst_bitmaps: testb 12 7
-Blocks 12 to 18 are all clear.
-tst_bitmaps: setb 12 7
-Marking blocks 12 to 18
-tst_bitmaps: dump_bb
-block bitmap: 00f80300000000000000000000000000
-bits set: 7
-tst_bitmaps: seti 2
-Setting inode 2, was clear before
-tst_bitmaps: seti 5
-Setting inode 5, was clear before
-tst_bitmaps: seti 4
-Setting inode 4, was clear before
-tst_bitmaps: seti 3
-Setting inode 3, was clear before
-tst_bitmaps: seti 4
-Setting inode 4, was set before
-tst_bitmaps: seti 5
-Setting inode 5, was set before
-tst_bitmaps: testi 6
-Inode 6 is clear
-tst_bitmaps: testi 1
-Inode 1 is clear
-tst_bitmaps: dump_ib
-inode bitmap: 1e000000
-bits set: 4
-tst_bitmaps: ffzi 1 6
-First unmarked inode is 1
-tst_bitmaps: ffzi 2 5
-ext2fs_find_first_zero_inode_bitmap2() returned No such file or directory
-tst_bitmaps: ffzi 2 6
-First unmarked inode is 6
-tst_bitmaps: cleari 4
-Clearing inode 4, was set before
-tst_bitmaps: ffzi 2 6
-First unmarked inode is 4
-tst_bitmaps: zeroi
-Clearing inode bitmap.
-tst_bitmaps: testi 5
-Inode 5 is clear
-tst_bitmaps: seti 5
-Setting inode 5, was clear before
-tst_bitmaps: seti 5
-Setting inode 5, was set before
-tst_bitmaps: cleari 5
-Clearing inode 5, was set before
-tst_bitmaps: cleari 5
-Clearing inode 5, was clear before
-tst_bitmaps: testi 17
-Inode 17 is clear
-tst_bitmaps: testi 6
-Inode 6 is clear
-tst_bitmaps: testi 4
-Inode 4 is clear
-tst_bitmaps: clearb 7 12
-Clearing blocks 7 to 18
-tst_bitmaps: dump_bb
-block bitmap: 00000000000000000000000000000000
-bits set: 0
-tst_bitmaps: setb 1
-Setting block 1, was clear before
-tst_bitmaps: dump_bb
-block bitmap: 01000000000000000000000000000000
-bits set: 1
-tst_bitmaps: setb 2
-Setting block 2, was clear before
-tst_bitmaps: dump_bb
-block bitmap: 03000000000000000000000000000000
-bits set: 2
-tst_bitmaps: setb 3
-Setting block 3, was clear before
-tst_bitmaps: dump_bb
-block bitmap: 07000000000000000000000000000000
-bits set: 3
-tst_bitmaps: setb 4
-Setting block 4, was clear before
-tst_bitmaps: dump_bb
-block bitmap: 0f000000000000000000000000000000
-bits set: 4
-tst_bitmaps: setb 5
-Setting block 5, was clear before
-tst_bitmaps: dump_bb
-block bitmap: 1f000000000000000000000000000000
-bits set: 5
-tst_bitmaps: setb 6
-Setting block 6, was clear before
-tst_bitmaps: dump_bb
-block bitmap: 3f000000000000000000000000000000
-bits set: 6
-tst_bitmaps: setb 7
-Setting block 7, was clear before
-tst_bitmaps: dump_bb
-block bitmap: 7f000000000000000000000000000000
-bits set: 7
-tst_bitmaps: setb 8
-Setting block 8, was clear before
-tst_bitmaps: dump_bb
-block bitmap: ff000000000000000000000000000000
-bits set: 8
-tst_bitmaps: setb 10
-Setting block 10, was clear before
-tst_bitmaps: setb 12
-Setting block 12, was clear before
-tst_bitmaps: setb 14
-Setting block 14, was clear before
-tst_bitmaps: setb 17
-Setting block 17, was clear before
-tst_bitmaps: setb 19
-Setting block 19, was clear before
-tst_bitmaps: setb 24
-Setting block 24, was clear before
-tst_bitmaps: setb 26
-Setting block 26, was clear before
-tst_bitmaps: setb 27
-Setting block 27, was clear before
-tst_bitmaps: setb 30
-Setting block 30, was clear before
-tst_bitmaps: setb 31
-Setting block 31, was clear before
-tst_bitmaps: setb 32
-Setting block 32, was clear before
-tst_bitmaps: setb 35
-Setting block 35, was clear before
-tst_bitmaps: setb 39
-Setting block 39, was clear before
-tst_bitmaps: setb 40
-Setting block 40, was clear before
-tst_bitmaps: setb 44
-Setting block 44, was clear before
-tst_bitmaps: setb 46
-Setting block 46, was clear before
-tst_bitmaps: setb 47
-Setting block 47, was clear before
-tst_bitmaps: setb 49
-Setting block 49, was clear before
-tst_bitmaps: setb 51
-Setting block 51, was clear before
-tst_bitmaps: setb 52
-Setting block 52, was clear before
-tst_bitmaps: clearb 2
-Clearing block 2, was set before
-tst_bitmaps: clearb 3
-Clearing block 3, was set before
-tst_bitmaps: clearb 7
-Clearing block 7, was set before
-tst_bitmaps: dump_bb
-block bitmap: b92a85e6c4680d000000000000000000
-bits set: 25
-tst_bitmaps: quit
-tst_bitmaps:
diff --git a/lib/ext2fs/tst_bitops.c b/lib/ext2fs/tst_bitops.c
index b64735cd..f57a2e46 100644
--- a/lib/ext2fs/tst_bitops.c
+++ b/lib/ext2fs/tst_bitops.c
@@ -169,125 +169,5 @@ int main(int argc, char **argv)
printf("ext2fs_fast_set_bit big_test successful\n");
- /* Repeat foregoing tests for 64-bit bitops */
-
- /* Test test_bit */
- for (i=0,j=0; i < size; i++) {
- if (ext2fs_test_bit64(i, bitarray)) {
- if (bits_list[j] == i) {
- j++;
- } else {
- printf("64-bit: Bit %d set, not expected\n",
- i);
- exit(1);
- }
- } else {
- if (bits_list[j] == i) {
- printf("64-bit: "
- "Expected bit %d to be clear.\n", i);
- exit(1);
- }
- }
- }
- printf("64-bit: ext2fs_test_bit appears to be correct\n");
-
- /* Test ext2fs_set_bit */
- memset(testarray, 0, sizeof(testarray));
- for (i=0; bits_list[i] > 0; i++) {
- ext2fs_set_bit64(bits_list[i], testarray);
- }
- if (memcmp(testarray, bitarray, sizeof(testarray)) == 0) {
- printf("64-bit: ext2fs_set_bit test succeeded.\n");
- } else {
- printf("64-bit: ext2fs_set_bit test failed.\n");
- for (i=0; i < sizeof(testarray); i++) {
- printf("%02x ", testarray[i]);
- }
- printf("\n");
- exit(1);
- }
- for (i=0; bits_list[i] > 0; i++) {
- ext2fs_clear_bit64(bits_list[i], testarray);
- }
- for (i=0; i < sizeof(testarray); i++) {
- if (testarray[i]) {
- printf("64-bit: ext2fs_clear_bit failed, "
- "testarray[%d] is %d\n", i, testarray[i]);
- exit(1);
- }
- }
- printf("64-bit: ext2fs_clear_bit test succeed.\n");
-
- /* Do bigarray test */
- bigarray = malloc(1 << 29);
- if (!bigarray) {
- fprintf(stderr, "Failed to allocate scratch memory!\n");
- exit(1);
- }
-
- bigarray[BIG_TEST_BIT >> 3] = 0;
-
- ext2fs_set_bit64(BIG_TEST_BIT, bigarray);
- printf("64-bit: big bit number (%u) test: %d, expected %d\n",
- BIG_TEST_BIT, bigarray[BIG_TEST_BIT >> 3],
- (1 << (BIG_TEST_BIT & 7)));
- if (bigarray[BIG_TEST_BIT >> 3] != (1 << (BIG_TEST_BIT & 7)))
- exit(1);
-
- ext2fs_clear_bit64(BIG_TEST_BIT, bigarray);
-
- printf("64-bit: big bit number (%u) test: %d, expected 0\n",
- BIG_TEST_BIT,
- bigarray[BIG_TEST_BIT >> 3]);
- if (bigarray[BIG_TEST_BIT >> 3] != 0)
- exit(1);
-
- printf("64-bit: ext2fs_set_bit big_test successful\n");
-
- /* Now test ext2fs_fast_set_bit */
- memset(testarray, 0, sizeof(testarray));
- for (i=0; bits_list[i] > 0; i++) {
- ext2fs_fast_set_bit64(bits_list[i], testarray);
- }
- if (memcmp(testarray, bitarray, sizeof(testarray)) == 0) {
- printf("64-bit: ext2fs_fast_set_bit test succeeded.\n");
- } else {
- printf("64-bit: ext2fs_fast_set_bit test failed.\n");
- for (i=0; i < sizeof(testarray); i++) {
- printf("%02x ", testarray[i]);
- }
- printf("\n");
- exit(1);
- }
- for (i=0; bits_list[i] > 0; i++) {
- ext2fs_clear_bit64(bits_list[i], testarray);
- }
- for (i=0; i < sizeof(testarray); i++) {
- if (testarray[i]) {
- printf("64-bit: ext2fs_clear_bit failed, "
- "testarray[%d] is %d\n", i, testarray[i]);
- exit(1);
- }
- }
- printf("64-bit: ext2fs_clear_bit test succeed.\n");
-
- bigarray[BIG_TEST_BIT >> 3] = 0;
-
- ext2fs_fast_set_bit64(BIG_TEST_BIT, bigarray);
- printf("64-bit: big bit number (%u) test: %d, expected %d\n",
- BIG_TEST_BIT, bigarray[BIG_TEST_BIT >> 3],
- (1 << (BIG_TEST_BIT & 7)));
- if (bigarray[BIG_TEST_BIT >> 3] != (1 << (BIG_TEST_BIT & 7)))
- exit(1);
-
- ext2fs_fast_clear_bit64(BIG_TEST_BIT, bigarray);
-
- printf("64-bit: big bit number (%u) test: %d, expected 0\n",
- BIG_TEST_BIT, bigarray[BIG_TEST_BIT >> 3]);
- if (bigarray[BIG_TEST_BIT >> 3] != 0)
- exit(1);
-
- printf("64-bit: ext2fs_fast_set_bit big_test successful\n");
-
exit(0);
}
diff --git a/lib/ext2fs/tst_fs_struct.c b/lib/ext2fs/tst_fs_struct.c
deleted file mode 100644
index 6f44df18..00000000
--- a/lib/ext2fs/tst_fs_struct.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * This testing program checks the offset of the ext2_filsys structure
- *
- * Copyright (C) 2007 by Theodore Ts'o.
- *
- * %Begin-Header%
- * This file may be redistributed under the terms of the GNU Library
- * General Public License, version 2.
- * %End-Header%
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-#include "ext2fs.h"
-
-struct struct_ext2_filsys fs;
-
-#ifndef offsetof
-#define offsetof(type, member) __builtin_offsetof (type, member)
-#endif
-#define check_field(x) cur_offset = do_field(#x, sizeof(fs.x), \
- offsetof(struct struct_ext2_filsys, x), \
- cur_offset)
-
-static int do_field(const char *field, size_t size, int offset, int cur_offset)
-{
- if (offset != cur_offset) {
- printf("\t(padding %d bytes?)\n", offset - cur_offset);
- }
- printf("%8d %-30s %3u\n", offset, field, (unsigned) size);
- return offset + size;
-}
-
-int main(int argc, char **argv)
-{
-#if (__GNUC__ >= 4)
- int cur_offset = 0;
-
- printf("%8s %-30s %3s\n", "offset", "field", "size");
- check_field(magic);
- check_field(io);
- check_field(flags);
- check_field(device_name);
- check_field(super);
- check_field(blocksize);
- check_field(fragsize);
- check_field(group_desc_count);
- check_field(desc_blocks);
- check_field(group_desc);
- check_field(inode_blocks_per_group);
- check_field(inode_map);
- check_field(block_map);
- check_field(get_blocks);
- check_field(check_directory);
- check_field(write_bitmaps);
- check_field(read_inode);
- check_field(write_inode);
- check_field(badblocks);
- check_field(dblist);
- check_field(stride);
- check_field(orig_super);
- check_field(image_header);
- check_field(umask);
- check_field(now);
- check_field(cluster_ratio_bits);
- check_field(reserved);
- check_field(priv_data);
- check_field(icache);
- check_field(image_io);
- check_field(get_alloc_block);
- check_field(block_alloc_stats);
- check_field(mmp_buf);
- check_field(mmp_cmp);
- check_field(mmp_fd);
- check_field(mmp_last_written);
- printf("Ending offset is %d\n\n", cur_offset);
-#endif
- exit(0);
-}
diff --git a/lib/ext2fs/tst_inode_size.c b/lib/ext2fs/tst_inode_size.c
deleted file mode 100644
index 3f0ab82c..00000000
--- a/lib/ext2fs/tst_inode_size.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * This testing program makes sure the ext2_inode structure is 1024 bytes long
- *
- * Copyright (C) 2007 by Theodore Ts'o.
- *
- * %Begin-Header%
- * This file may be redistributed under the terms of the GNU Library
- * General Public License, version 2.
- * %End-Header%
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-#include "ext2_fs.h"
-
-struct ext2_inode_large inode;
-
-#ifndef offsetof
-#define offsetof(type, member) __builtin_offsetof(type, member)
-#endif
-
-#define check_field(x, s) cur_offset = do_field(#x, s, sizeof(inode.x), \
- offsetof(struct ext2_inode_large, x), \
- cur_offset)
-
-static int do_field(const char *field, unsigned size, unsigned cur_size,
- unsigned offset, unsigned cur_offset)
-{
- if (size != cur_size) {
- printf("error: %s size %u should be %u\n",
- field, cur_size, size);
- exit(1);
- }
- if (offset != cur_offset) {
- printf("error: %s offset %u should be %u\n",
- field, cur_offset, offset);
- exit(1);
- }
- printf("%8d %-30s %3u\n", offset, field, (unsigned) size);
- return offset + size;
-}
-
-int main(int argc, char **argv)
-{
-#if (__GNUC__ >= 4)
- int cur_offset = 0;
-
- printf("%8s %-30s %3s\n", "offset", "field", "size");
- check_field(i_mode, 2);
- check_field(i_uid, 2);
- check_field(i_size, 4);
- check_field(i_atime, 4);
- check_field(i_ctime, 4);
- check_field(i_mtime, 4);
- check_field(i_dtime, 4);
- check_field(i_gid, 2);
- check_field(i_links_count, 2);
- check_field(i_blocks, 4);
- check_field(i_flags, 4);
- check_field(osd1.linux1.l_i_version, 4);
- check_field(i_block, 15 * 4);
- check_field(i_generation, 4);
- check_field(i_file_acl, 4);
- check_field(i_size_high, 4);
- check_field(i_faddr, 4);
- check_field(osd2.linux2.l_i_blocks_hi, 2);
- check_field(osd2.linux2.l_i_file_acl_high, 2);
- check_field(osd2.linux2.l_i_uid_high, 2);
- check_field(osd2.linux2.l_i_gid_high, 2);
- check_field(osd2.linux2.l_i_checksum_lo, 2);
- check_field(osd2.linux2.l_i_reserved, 2);
- do_field("Small inode end", 0, 0, cur_offset, 128);
- check_field(i_extra_isize, 2);
- check_field(i_checksum_hi, 2);
- check_field(i_ctime_extra, 4);
- check_field(i_mtime_extra, 4);
- check_field(i_atime_extra, 4);
- check_field(i_crtime, 4);
- check_field(i_crtime_extra, 4);
- check_field(i_version_hi, 4);
- /* This size will change as new fields are added */
- do_field("Large inode end", 0, 0, cur_offset, sizeof(inode));
-#endif
- return 0;
-}
diff --git a/lib/ext2fs/tst_iscan.c b/lib/ext2fs/tst_iscan.c
index efeeb772..443b1b45 100644
--- a/lib/ext2fs/tst_iscan.c
+++ b/lib/ext2fs/tst_iscan.c
@@ -25,7 +25,7 @@
#include "ext2_fs.h"
#include "ext2fs.h"
-blk64_t test_vec[] = { 8, 12, 24, 34, 43, 44, 100, 0 };
+blk_t test_vec[] = { 8, 12, 24, 34, 43, 44, 100, 0 };
ext2_filsys test_fs;
ext2fs_block_bitmap bad_block_map, touched_map;
@@ -35,7 +35,7 @@ badblocks_list test_badblocks;
int first_no_comma = 1;
int failed = 0;
-static void iscan_test_read_blk64(unsigned long long block, int count, errcode_t err)
+static void test_read_blk(unsigned long block, int count, errcode_t err)
{
int i;
@@ -45,25 +45,20 @@ static void iscan_test_read_blk64(unsigned long long block, int count, errcode_t
printf(", ");
if (count > 1)
- printf("%llu-%llu", block, block+count-1);
+ printf("%lu-%lu", block, block+count-1);
else
- printf("%llu", block);
+ printf("%lu", block);
for (i=0; i < count; i++, block++) {
- if (ext2fs_test_block_bitmap2(touched_map, block)) {
- printf("\nDuplicate block?!? --- %llu\n", block);
+ if (ext2fs_test_block_bitmap(touched_map, block)) {
+ printf("\nDuplicate block?!? --- %lu\n", block);
failed++;
first_no_comma = 1;
}
- ext2fs_mark_block_bitmap2(touched_map, block);
+ ext2fs_mark_block_bitmap(touched_map, block);
}
}
-static void iscan_test_read_blk(unsigned long block, int count, errcode_t err)
-{
- iscan_test_read_blk64(block, count, err);
-}
-
/*
* Setup the variables for doing the inode scan test.
*/
@@ -76,13 +71,12 @@ static void setup(void)
initialize_ext2_error_table();
memset(&param, 0, sizeof(param));
- ext2fs_blocks_count_set(&param, 12000);
+ param.s_blocks_count = 12000;
- test_io_cb_read_blk = iscan_test_read_blk;
- test_io_cb_read_blk64 = iscan_test_read_blk64;
+ test_io_cb_read_blk = test_read_blk;
- retval = ext2fs_initialize("test fs", EXT2_FLAG_64BITS, &param,
+ retval = ext2fs_initialize("test fs", 0, &param,
test_io_manager, &test_fs);
if (retval) {
com_err("setup", retval,
@@ -129,7 +123,7 @@ static void setup(void)
"while adding test vector %d", i);
exit(1);
}
- ext2fs_mark_block_bitmap2(bad_block_map, test_vec[i]);
+ ext2fs_mark_block_bitmap(bad_block_map, test_vec[i]);
}
test_fs->badblocks = test_badblocks;
}
@@ -158,7 +152,7 @@ static void iterate(void)
while (ino) {
retval = ext2fs_get_next_inode(scan, &ino, &inode);
if (retval == EXT2_ET_BAD_BLOCK_IN_INODE_TABLE) {
- ext2fs_mark_inode_bitmap2(bad_inode_map, ino);
+ ext2fs_mark_inode_bitmap(bad_inode_map, ino);
continue;
}
if (retval) {
@@ -177,30 +171,30 @@ static void iterate(void)
static void check_map(void)
{
int i, j, first=1;
- blk64_t blk;
+ unsigned long blk;
for (i=0; test_vec[i]; i++) {
- if (ext2fs_test_block_bitmap2(touched_map, test_vec[i])) {
- printf("Bad block was touched --- %llu\n", test_vec[i]);
+ if (ext2fs_test_block_bitmap(touched_map, test_vec[i])) {
+ printf("Bad block was touched --- %u\n", test_vec[i]);
failed++;
first_no_comma = 1;
}
- ext2fs_mark_block_bitmap2(touched_map, test_vec[i]);
+ ext2fs_mark_block_bitmap(touched_map, test_vec[i]);
}
for (i = 0; i < test_fs->group_desc_count; i++) {
- for (j=0, blk = ext2fs_inode_table_loc(test_fs, i);
+ for (j=0, blk = test_fs->group_desc[i].bg_inode_table;
j < test_fs->inode_blocks_per_group;
j++, blk++) {
- if (!ext2fs_test_block_bitmap2(touched_map, blk) &&
- !ext2fs_test_block_bitmap2(bad_block_map, blk)) {
- printf("Missing block --- %llu\n", blk);
+ if (!ext2fs_test_block_bitmap(touched_map, blk) &&
+ !ext2fs_test_block_bitmap(bad_block_map, blk)) {
+ printf("Missing block --- %lu\n", blk);
failed++;
}
}
}
printf("Bad inodes: ");
for (i=1; i <= test_fs->super->s_inodes_count; i++) {
- if (ext2fs_test_inode_bitmap2(bad_inode_map, i)) {
+ if (ext2fs_test_inode_bitmap(bad_inode_map, i)) {
if (first)
first = 0;
else
diff --git a/lib/ext2fs/tst_super_size.c b/lib/ext2fs/tst_super_size.c
index eef5a630..eb9114f1 100644
--- a/lib/ext2fs/tst_super_size.c
+++ b/lib/ext2fs/tst_super_size.c
@@ -20,123 +20,123 @@
struct sb_struct sb;
-#ifndef offsetof
-#define offsetof(type, member) __builtin_offsetof (type, member)
-#endif
+int verbose = 0;
-#define check_field(x, s) cur_offset = do_field(#x, s, sizeof(sb.x), \
- offsetof(struct sb_struct, x), \
- cur_offset)
+#define offsetof(type, member) __builtin_offsetof (type, member)
+#define check_field(x) cur_offset = do_field(#x, sizeof(sb.x), \
+ offsetof(struct sb_struct, x), \
+ cur_offset)
-static int do_field(const char *field, unsigned size, unsigned cur_size,
- unsigned offset, unsigned cur_offset)
+static int do_field(const char *field, size_t size, int offset, int cur_offset)
{
- if (size != cur_size) {
- printf("error: %s size %u should be %u\n",
- field, cur_size, size);
- exit(1);
- }
if (offset != cur_offset) {
- printf("error: %s offset %u should be %u\n",
- field, cur_offset, offset);
+ printf("Warning! Unexpected offset at %s\n", field);
exit(1);
}
- printf("%8d %-30s %3u\n", offset, field, size);
+ printf("%8d %-30s %3u\n", offset, field, (unsigned) size);
return offset + size;
}
-int main(int argc, char **argv)
+void check_superblock_fields()
{
#if (__GNUC__ >= 4)
int cur_offset = 0;
printf("%8s %-30s %3s\n", "offset", "field", "size");
- check_field(s_inodes_count, 4);
- check_field(s_blocks_count, 4);
- check_field(s_r_blocks_count, 4);
- check_field(s_free_blocks_count, 4);
- check_field(s_free_inodes_count, 4);
- check_field(s_first_data_block, 4);
- check_field(s_log_block_size, 4);
- check_field(s_log_cluster_size, 4);
- check_field(s_blocks_per_group, 4);
- check_field(s_clusters_per_group, 4);
- check_field(s_inodes_per_group, 4);
- check_field(s_mtime, 4);
- check_field(s_wtime, 4);
- check_field(s_mnt_count, 2);
- check_field(s_max_mnt_count, 2);
- check_field(s_magic, 2);
- check_field(s_state, 2);
- check_field(s_errors, 2);
- check_field(s_minor_rev_level, 2);
- check_field(s_lastcheck, 4);
- check_field(s_checkinterval, 4);
- check_field(s_creator_os, 4);
- check_field(s_rev_level, 4);
- check_field(s_def_resuid, 2);
- check_field(s_def_resgid, 2);
- check_field(s_first_ino, 4);
- check_field(s_inode_size, 2);
- check_field(s_block_group_nr, 2);
- check_field(s_feature_compat, 4);
- check_field(s_feature_incompat, 4);
- check_field(s_feature_ro_compat, 4);
- check_field(s_uuid, 16);
- check_field(s_volume_name, 16);
- check_field(s_last_mounted, 64);
- check_field(s_algorithm_usage_bitmap, 4);
- check_field(s_prealloc_blocks, 1);
- check_field(s_prealloc_dir_blocks, 1);
- check_field(s_reserved_gdt_blocks, 2);
- check_field(s_journal_uuid, 16);
- check_field(s_journal_inum, 4);
- check_field(s_journal_dev, 4);
- check_field(s_last_orphan, 4);
- check_field(s_hash_seed, 4 * 4);
- check_field(s_def_hash_version, 1);
- check_field(s_jnl_backup_type, 1);
- check_field(s_desc_size, 2);
- check_field(s_default_mount_opts, 4);
- check_field(s_first_meta_bg, 4);
- check_field(s_mkfs_time, 4);
- check_field(s_jnl_blocks, 17 * 4);
- check_field(s_blocks_count_hi, 4);
- check_field(s_r_blocks_count_hi, 4);
- check_field(s_free_blocks_hi, 4);
- check_field(s_min_extra_isize, 2);
- check_field(s_want_extra_isize, 2);
- check_field(s_flags, 4);
- check_field(s_raid_stride, 2);
- check_field(s_mmp_update_interval, 2);
- check_field(s_mmp_block, 8);
- check_field(s_raid_stripe_width, 4);
- check_field(s_log_groups_per_flex, 1);
- check_field(s_reserved_char_pad, 1);
- check_field(s_reserved_pad, 2);
- check_field(s_kbytes_written, 8);
- check_field(s_snapshot_inum, 4);
- check_field(s_snapshot_id, 4);
- check_field(s_snapshot_r_blocks_count, 8);
- check_field(s_snapshot_list, 4);
- check_field(s_error_count, 4);
- check_field(s_first_error_time, 4);
- check_field(s_first_error_ino, 4);
- check_field(s_first_error_block, 8);
- check_field(s_first_error_func, 32);
- check_field(s_first_error_line, 4);
- check_field(s_last_error_time, 4);
- check_field(s_last_error_ino, 4);
- check_field(s_last_error_line, 4);
- check_field(s_last_error_block, 8);
- check_field(s_last_error_func, 32);
- check_field(s_mount_opts, 64);
- check_field(s_usr_quota_inum, 4);
- check_field(s_grp_quota_inum, 4);
- check_field(s_overhead_blocks, 4);
- check_field(s_reserved, 108 * 4);
- check_field(s_checksum, 4);
- do_field("Superblock end", 0, 0, cur_offset, 1024);
+ check_field(s_inodes_count);
+ check_field(s_blocks_count);
+ check_field(s_r_blocks_count);
+ check_field(s_free_blocks_count);
+ check_field(s_free_inodes_count);
+ check_field(s_first_data_block);
+ check_field(s_log_block_size);
+ check_field(s_log_frag_size);
+ check_field(s_blocks_per_group);
+ check_field(s_frags_per_group);
+ check_field(s_inodes_per_group);
+ check_field(s_mtime);
+ check_field(s_wtime);
+ check_field(s_mnt_count);
+ check_field(s_max_mnt_count);
+ check_field(s_magic);
+ check_field(s_state);
+ check_field(s_errors);
+ check_field(s_minor_rev_level);
+ check_field(s_lastcheck);
+ check_field(s_checkinterval);
+ check_field(s_creator_os);
+ check_field(s_rev_level);
+ check_field(s_def_resuid);
+ check_field(s_def_resgid);
+ check_field(s_first_ino);
+ check_field(s_inode_size);
+ check_field(s_block_group_nr);
+ check_field(s_feature_compat);
+ check_field(s_feature_incompat);
+ check_field(s_feature_ro_compat);
+ check_field(s_uuid);
+ check_field(s_volume_name);
+ check_field(s_last_mounted);
+ check_field(s_algorithm_usage_bitmap);
+ check_field(s_prealloc_blocks);
+ check_field(s_prealloc_dir_blocks);
+ check_field(s_reserved_gdt_blocks);
+ check_field(s_journal_uuid);
+ check_field(s_journal_inum);
+ check_field(s_journal_dev);
+ check_field(s_last_orphan);
+ check_field(s_hash_seed);
+ check_field(s_def_hash_version);
+ check_field(s_jnl_backup_type);
+ check_field(s_desc_size);
+ check_field(s_default_mount_opts);
+ check_field(s_first_meta_bg);
+ check_field(s_mkfs_time);
+ check_field(s_jnl_blocks);
+ check_field(s_blocks_count_hi);
+ check_field(s_r_blocks_count_hi);
+ check_field(s_free_blocks_hi);
+ check_field(s_min_extra_isize);
+ check_field(s_want_extra_isize);
+ check_field(s_flags);
+ check_field(s_raid_stride);
+ check_field(s_mmp_interval);
+ check_field(s_mmp_block);
+ check_field(s_raid_stripe_width);
+ check_field(s_log_groups_per_flex);
+ check_field(s_reserved_char_pad);
+ check_field(s_reserved_pad);
+ check_field(s_kbytes_written);
+ check_field(s_snapshot_inum);
+ check_field(s_snapshot_id);
+ check_field(s_snapshot_r_blocks_count);
+ check_field(s_snapshot_list);
+ check_field(s_error_count);
+ check_field(s_first_error_time);
+ check_field(s_first_error_ino);
+ check_field(s_first_error_block);
+ check_field(s_first_error_func);
+ check_field(s_first_error_line);
+ check_field(s_last_error_time);
+ check_field(s_last_error_ino);
+ check_field(s_last_error_line);
+ check_field(s_last_error_block);
+ check_field(s_last_error_func);
+ check_field(s_mount_opts);
+ check_field(s_reserved);
+ printf("Ending offset is %d\n\n", cur_offset);
#endif
- return 0;
+}
+
+
+int main(int argc, char **argv)
+{
+ int s = sizeof(struct sb_struct);
+
+ check_superblock_fields();
+ printf("Size of struct %s is %d\n", sb_struct_name, s);
+ if (s != 1024) {
+ exit(1);
+ }
+ exit(0);
}
diff --git a/lib/ext2fs/undo_io.c b/lib/ext2fs/undo_io.c
index df55abf3..7cf88684 100644
--- a/lib/ext2fs/undo_io.c
+++ b/lib/ext2fs/undo_io.c
@@ -73,10 +73,6 @@ struct undo_private_data {
static errcode_t undo_open(const char *name, int flags, io_channel *channel);
static errcode_t undo_close(io_channel channel);
static errcode_t undo_set_blksize(io_channel channel, int blksize);
-static errcode_t undo_read_blk64(io_channel channel, unsigned long long block,
- int count, void *data);
-static errcode_t undo_write_blk64(io_channel channel, unsigned long long block,
- int count, const void *data);
static errcode_t undo_read_blk(io_channel channel, unsigned long block,
int count, void *data);
static errcode_t undo_write_blk(io_channel channel, unsigned long block,
@@ -86,7 +82,6 @@ static errcode_t undo_write_byte(io_channel channel, unsigned long offset,
int size, const void *data);
static errcode_t undo_set_option(io_channel channel, const char *option,
const char *arg);
-static errcode_t undo_get_stats(io_channel channel, io_stats *stats);
static struct struct_io_manager struct_undo_manager = {
EXT2_ET_MAGIC_IO_MANAGER,
@@ -98,10 +93,7 @@ static struct struct_io_manager struct_undo_manager = {
undo_write_blk,
undo_flush,
undo_write_byte,
- undo_set_option,
- undo_get_stats,
- undo_read_blk64,
- undo_write_blk64,
+ undo_set_option
};
io_manager undo_io_manager = &struct_undo_manager;
@@ -148,7 +140,7 @@ static errcode_t write_file_system_identity(io_channel undo_channel,
block_size = channel->block_size;
io_channel_set_blksize(channel, SUPERBLOCK_OFFSET);
- retval = io_channel_read_blk64(channel, 1, -SUPERBLOCK_SIZE, &super);
+ retval = io_channel_read_blk(channel, 1, -SUPERBLOCK_SIZE, &super);
if (retval)
goto err_out;
@@ -198,17 +190,17 @@ static errcode_t write_block_size(TDB_CONTEXT *tdb, int block_size)
}
static errcode_t undo_write_tdb(io_channel channel,
- unsigned long long block, int count)
+ unsigned long block, int count)
{
int size, sz;
- unsigned long long block_num, backing_blk_num;
+ unsigned long block_num, backing_blk_num;
errcode_t retval = 0;
ext2_loff_t offset;
struct undo_private_data *data;
TDB_DATA tdb_key, tdb_data;
unsigned char *read_ptr;
- unsigned long long end_block;
+ unsigned long end_block;
data = (struct undo_private_data *) channel->private_data;
@@ -274,7 +266,7 @@ static errcode_t undo_write_tdb(io_channel channel,
sz = count / channel->block_size;
else
sz = -count;
- retval = io_channel_read_blk64(data->real, backing_blk_num,
+ retval = io_channel_read_blk(data->real, backing_blk_num,
sz, read_ptr);
if (retval) {
if (retval != EXT2_ET_SHORT_READ) {
@@ -293,7 +285,7 @@ static errcode_t undo_write_tdb(io_channel channel,
tdb_data.dptr = read_ptr +
((offset - data->offset) % channel->block_size);
#ifdef DEBUG
- printf("Printing with key %lld data %x and size %d\n",
+ printf("Printing with key %ld data %x and size %d\n",
block_num,
tdb_data.dptr,
tdb_data.dsize);
@@ -357,7 +349,7 @@ static errcode_t undo_open(const char *name, int flags, io_channel *channel)
return EXT2_ET_BAD_DEVICE_NAME;
retval = ext2fs_get_mem(sizeof(struct struct_io_channel), &io);
if (retval)
- goto cleanup;
+ return retval;
memset(io, 0, sizeof(struct struct_io_channel));
io->magic = EXT2_ET_MAGIC_IO_CHANNEL;
retval = ext2fs_get_mem(sizeof(struct undo_private_data), &data);
@@ -400,14 +392,13 @@ static errcode_t undo_open(const char *name, int flags, io_channel *channel)
* setup err handler for read so that we know
* when the backing manager fails do short read
*/
- if (data->real)
- undo_err_handler_init(data->real);
+ undo_err_handler_init(data->real);
*channel = io;
return 0;
cleanup:
- if (data && data->real)
+ if (data->real)
io_channel_close(data->real);
if (data)
ext2fs_free_mem(&data);
@@ -464,7 +455,7 @@ static errcode_t undo_set_blksize(io_channel channel, int blksize)
return retval;
}
-static errcode_t undo_read_blk64(io_channel channel, unsigned long long block,
+static errcode_t undo_read_blk(io_channel channel, unsigned long block,
int count, void *buf)
{
errcode_t retval = 0;
@@ -475,18 +466,12 @@ static errcode_t undo_read_blk64(io_channel channel, unsigned long long block,
EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL);
if (data->real)
- retval = io_channel_read_blk64(data->real, block, count, buf);
+ retval = io_channel_read_blk(data->real, block, count, buf);
return retval;
}
-static errcode_t undo_read_blk(io_channel channel, unsigned long block,
- int count, void *buf)
-{
- return undo_read_blk64(channel, block, count, buf);
-}
-
-static errcode_t undo_write_blk64(io_channel channel, unsigned long long block,
+static errcode_t undo_write_blk(io_channel channel, unsigned long block,
int count, const void *buf)
{
struct undo_private_data *data;
@@ -502,17 +487,11 @@ static errcode_t undo_write_blk64(io_channel channel, unsigned long long block,
if (retval)
return retval;
if (data->real)
- retval = io_channel_write_blk64(data->real, block, count, buf);
+ retval = io_channel_write_blk(data->real, block, count, buf);
return retval;
}
-static errcode_t undo_write_blk(io_channel channel, unsigned long block,
- int count, const void *buf)
-{
- return undo_write_blk64(channel, block, count, buf);
-}
-
static errcode_t undo_write_byte(io_channel channel, unsigned long offset,
int size, const void *buf)
{
@@ -605,18 +584,3 @@ static errcode_t undo_set_option(io_channel channel, const char *option,
}
return retval;
}
-
-static errcode_t undo_get_stats(io_channel channel, io_stats *stats)
-{
- errcode_t retval = 0;
- struct undo_private_data *data;
-
- EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
- data = (struct undo_private_data *) channel->private_data;
- EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL);
-
- if (data->real)
- retval = (data->real->manager->get_stats)(data->real, stats);
-
- return retval;
-}
diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c
index 419564fe..5bf2c925 100644
--- a/lib/ext2fs/unix_io.c
+++ b/lib/ext2fs/unix_io.c
@@ -17,9 +17,7 @@
#define _LARGEFILE_SOURCE
#define _LARGEFILE64_SOURCE
-#ifndef _GNU_SOURCE
#define _GNU_SOURCE
-#endif
#include <stdio.h>
#include <string.h>
@@ -49,14 +47,15 @@
#if HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
-#if HAVE_LINUX_FALLOC_H
-#include <linux/falloc.h>
-#endif
#if defined(__linux__) && defined(_IO) && !defined(BLKROGET)
#define BLKROGET _IO(0x12, 94) /* Get read-only status (0 = read_write). */
#endif
+#if defined(__linux__) && defined(_IO) && !defined(BLKSSZGET)
+#define BLKSSZGET _IO(0x12,104)/* get block device sector size */
+#endif
+
#undef ALIGN_DEBUG
#include "ext2_fs.h"
@@ -70,11 +69,11 @@
if ((struct)->magic != (code)) return (code)
struct unix_cache {
- char *buf;
- unsigned long long block;
- int access_time;
- unsigned dirty:1;
- unsigned in_use:1;
+ char *buf;
+ unsigned long block;
+ int access_time;
+ unsigned dirty:1;
+ unsigned in_use:1;
};
#define CACHE_SIZE 8
@@ -116,8 +115,6 @@ static errcode_t unix_read_blk64(io_channel channel, unsigned long long block,
int count, void *data);
static errcode_t unix_write_blk64(io_channel channel, unsigned long long block,
int count, const void *data);
-static errcode_t unix_discard(io_channel channel, unsigned long long block,
- unsigned long long count);
static struct struct_io_manager struct_unix_manager = {
EXT2_ET_MAGIC_IO_MANAGER,
@@ -133,7 +130,6 @@ static struct struct_io_manager struct_unix_manager = {
unix_get_stats,
unix_read_blk64,
unix_write_blk64,
- unix_discard,
};
io_manager unix_io_manager = &struct_unix_manager;
@@ -160,13 +156,12 @@ static errcode_t unix_get_stats(io_channel channel, io_stats *stats)
static errcode_t raw_read_blk(io_channel channel,
struct unix_private_data *data,
unsigned long long block,
- int count, void *bufv)
+ int count, void *buf)
{
errcode_t retval;
ssize_t size;
ext2_loff_t location;
int actual = 0;
- unsigned char *buf = bufv;
size = (count < 0) ? -count : count * channel->block_size;
data->io_stats.bytes_read += size;
@@ -175,9 +170,8 @@ static errcode_t raw_read_blk(io_channel channel,
retval = errno ? errno : EXT2_ET_LLSEEK_FAILED;
goto error_out;
}
- if ((channel->align == 0) ||
- (IS_ALIGNED(buf, channel->align) &&
- IS_ALIGNED(size, channel->align))) {
+ if ((data->align == 0) ||
+ ((IS_ALIGNED(buf, data->align)) && IS_ALIGNED(size, data->align))) {
actual = read(data->dev, buf, size);
if (actual != size) {
short_read:
@@ -222,13 +216,12 @@ error_out:
static errcode_t raw_write_blk(io_channel channel,
struct unix_private_data *data,
unsigned long long block,
- int count, const void *bufv)
+ int count, const void *buf)
{
ssize_t size;
ext2_loff_t location;
int actual = 0;
errcode_t retval;
- const unsigned char *buf = bufv;
if (count == 1)
size = channel->block_size;
@@ -246,9 +239,8 @@ static errcode_t raw_write_blk(io_channel channel,
goto error_out;
}
- if ((channel->align == 0) ||
- (IS_ALIGNED(buf, channel->align) &&
- IS_ALIGNED(size, channel->align))) {
+ if ((data->align == 0) ||
+ ((IS_ALIGNED(buf, data->align)) && IS_ALIGNED(size, data->align))) {
actual = write(data->dev, buf, size);
if (actual != size) {
short_write:
@@ -315,14 +307,16 @@ static errcode_t alloc_cache(io_channel channel,
cache->in_use = 0;
if (cache->buf)
ext2fs_free_mem(&cache->buf);
- retval = io_channel_alloc_buf(channel, 0, &cache->buf);
+ retval = ext2fs_get_memalign(channel->block_size,
+ data->align, &cache->buf);
if (retval)
return retval;
}
- if (channel->align) {
+ if (data->align) {
if (data->bounce)
ext2fs_free_mem(&data->bounce);
- retval = io_channel_alloc_buf(channel, 0, &data->bounce);
+ retval = ext2fs_get_memalign(channel->block_size, data->align,
+ &data->bounce);
}
return retval;
}
@@ -428,44 +422,6 @@ static errcode_t flush_cached_blocks(io_channel channel,
}
#endif /* NO_IO_CACHE */
-#ifdef __linux__
-#ifndef BLKDISCARDZEROES
-#define BLKDISCARDZEROES _IO(0x12,124)
-#endif
-#endif
-
-int ext2fs_open_file(const char *pathname, int flags, mode_t mode)
-{
- if (mode)
-#if defined(HAVE_OPEN64) && !defined(__OSX_AVAILABLE_BUT_DEPRECATED)
- return open64(pathname, flags, mode);
- else
- return open64(pathname, flags);
-#else
- return open(pathname, flags, mode);
- else
- return open(pathname, flags);
-#endif
-}
-
-int ext2fs_stat(const char *path, ext2fs_struct_stat *buf)
-{
-#if defined(HAVE_FSTAT64) && !defined(__OSX_AVAILABLE_BUT_DEPRECATED)
- return stat64(path, buf);
-#else
- return stat(path, buf);
-#endif
-}
-
-int ext2fs_fstat(int fd, ext2fs_struct_stat *buf)
-{
-#if defined(HAVE_FSTAT64) && !defined(__OSX_AVAILABLE_BUT_DEPRECATED)
- return fstat64(fd, buf);
-#else
- return fstat(fd, buf);
-#endif
-}
-
static errcode_t unix_open(const char *name, int flags, io_channel *channel)
{
io_channel io = NULL;
@@ -473,7 +429,7 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel)
errcode_t retval;
int open_flags;
int f_nocache = 0;
- ext2fs_struct_stat st;
+ struct stat st;
#ifdef __linux__
struct utsname ut;
#endif
@@ -482,7 +438,7 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel)
return EXT2_ET_BAD_DEVICE_NAME;
retval = ext2fs_get_mem(sizeof(struct struct_io_channel), &io);
if (retval)
- goto cleanup;
+ return retval;
memset(io, 0, sizeof(struct struct_io_channel));
io->magic = EXT2_ET_MAGIC_IO_CHANNEL;
retval = ext2fs_get_mem(sizeof(struct unix_private_data), &data);
@@ -504,29 +460,28 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel)
memset(data, 0, sizeof(struct unix_private_data));
data->magic = EXT2_ET_MAGIC_UNIX_IO_CHANNEL;
data->io_stats.num_fields = 2;
- data->dev = -1;
open_flags = (flags & IO_FLAG_RW) ? O_RDWR : O_RDONLY;
if (flags & IO_FLAG_EXCLUSIVE)
open_flags |= O_EXCL;
-#if defined(O_DIRECT)
- if (flags & IO_FLAG_DIRECT_IO) {
- open_flags |= O_DIRECT;
- io->align = ext2fs_get_dio_alignment(data->dev);
- }
-#elif defined(F_NOCACHE)
- if (flags & IO_FLAG_DIRECT_IO) {
+ if (flags & IO_FLAG_DIRECT_IO)
+#if !defined(O_DIRECT) && defined(F_NOCACHE)
f_nocache = F_NOCACHE;
- io->align = 4096;
- }
+#else
+ open_flags |= O_DIRECT;
#endif
data->flags = flags;
- data->dev = ext2fs_open_file(io->name, open_flags, 0);
+#ifdef HAVE_OPEN64
+ data->dev = open64(io->name, open_flags);
+#else
+ data->dev = open(io->name, open_flags);
+#endif
if (data->dev < 0) {
retval = errno;
goto cleanup;
}
+
if (f_nocache) {
if (fcntl(data->dev, f_nocache, 1) < 0) {
retval = errno;
@@ -534,26 +489,10 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel)
}
}
- /*
- * If the device is really a block device, then set the
- * appropriate flag, otherwise we can set DISCARD_ZEROES flag
- * because we are going to use punch hole instead of discard
- * and if it succeed, subsequent read from sparse area returns
- * zero.
- */
- if (ext2fs_stat(io->name, &st) == 0) {
- if (S_ISBLK(st.st_mode))
- io->flags |= CHANNEL_FLAGS_BLOCK_DEVICE;
- else
- io->flags |= CHANNEL_FLAGS_DISCARD_ZEROES;
- }
-
-#ifdef BLKDISCARDZEROES
- {
- int zeroes = 0;
- if (ioctl(data->dev, BLKDISCARDZEROES, &zeroes) == 0 &&
- zeroes)
- io->flags |= CHANNEL_FLAGS_DISCARD_ZEROES;
+#ifdef BLKSSZGET
+ if (flags & IO_FLAG_DIRECT_IO) {
+ if (ioctl(data->dev, BLKSSZGET, &data->align) != 0)
+ data->align = io->block_size;
}
#endif
@@ -562,8 +501,7 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel)
* Some operating systems require that the buffers be aligned,
* regardless of O_DIRECT
*/
- if (!io->align)
- io->align = 512;
+ data->align = 512;
#endif
@@ -578,6 +516,7 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel)
/* Is the block device actually writable? */
error = ioctl(data->dev, BLKROGET, &readonly);
if (!error && readonly) {
+ close(data->dev);
retval = EPERM;
goto cleanup;
}
@@ -604,7 +543,7 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel)
(ut.release[2] == '4') && (ut.release[3] == '.') &&
(ut.release[4] == '1') && (ut.release[5] >= '0') &&
(ut.release[5] < '8')) &&
- (ext2fs_stat(io->name, &st) == 0) &&
+ (fstat(data->dev, &st) == 0) &&
(S_ISBLK(st.st_mode))) {
struct rlimit rlim;
@@ -623,17 +562,11 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel)
cleanup:
if (data) {
- if (data->dev >= 0)
- close(data->dev);
free_cache(data);
ext2fs_free_mem(&data);
}
- if (io) {
- if (io->name) {
- ext2fs_free_mem(&io->name);
- }
+ if (io)
ext2fs_free_mem(&io);
- }
return retval;
}
@@ -844,7 +777,7 @@ static errcode_t unix_write_byte(io_channel channel, unsigned long offset,
data = (struct unix_private_data *) channel->private_data;
EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL);
- if (channel->align != 0) {
+ if (data->align != 0) {
#ifdef ALIGN_DEBUG
printf("unix_write_byte: O_DIRECT fallback\n");
#endif
@@ -913,52 +846,3 @@ static errcode_t unix_set_option(io_channel channel, const char *option,
}
return EXT2_ET_INVALID_ARGUMENT;
}
-
-#if defined(__linux__) && !defined(BLKDISCARD)
-#define BLKDISCARD _IO(0x12,119)
-#endif
-
-static errcode_t unix_discard(io_channel channel, unsigned long long block,
- unsigned long long count)
-{
- struct unix_private_data *data;
- int ret;
-
- EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
- data = (struct unix_private_data *) channel->private_data;
- EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL);
-
- if (channel->flags & CHANNEL_FLAGS_BLOCK_DEVICE) {
-#ifdef BLKDISCARD
- __uint64_t range[2];
-
- range[0] = (__uint64_t)(block) * channel->block_size;
- range[1] = (__uint64_t)(count) * channel->block_size;
-
- ret = ioctl(data->dev, BLKDISCARD, &range);
-#else
- goto unimplemented;
-#endif
- } else {
-#if defined(HAVE_FALLOCATE) && defined(FALLOC_FL_PUNCH_HOLE)
- /*
- * If we are not on block device, try to use punch hole
- * to reclaim free space.
- */
- ret = fallocate(data->dev,
- FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
- (off_t)(block) * channel->block_size,
- (off_t)(count) * channel->block_size);
-#else
- goto unimplemented;
-#endif
- }
- if (ret < 0) {
- if (errno == EOPNOTSUPP)
- goto unimplemented;
- return errno;
- }
- return 0;
-unimplemented:
- return EXT2_ET_UNIMPLEMENTED;
-}
diff --git a/lib/ext2fs/valid_blk.c b/lib/ext2fs/valid_blk.c
index 7c3defc7..32ac9e60 100644
--- a/lib/ext2fs/valid_blk.c
+++ b/lib/ext2fs/valid_blk.c
@@ -23,7 +23,7 @@
* This function returns 1 if the inode's block entries actually
* contain block entries.
*/
-int ext2fs_inode_has_valid_blocks2(ext2_filsys fs, struct ext2_inode *inode)
+int ext2fs_inode_has_valid_blocks(struct ext2_inode *inode)
{
/*
* Only directories, regular files, and some symbolic links
@@ -38,7 +38,7 @@ int ext2fs_inode_has_valid_blocks2(ext2_filsys fs, struct ext2_inode *inode)
* target is stored in the block entries.
*/
if (LINUX_S_ISLNK (inode->i_mode)) {
- if (ext2fs_file_acl_block(fs, inode) == 0) {
+ if (inode->i_file_acl == 0) {
/* With no EA block, we can rely on i_blocks */
if (inode->i_blocks == 0)
return 0;
@@ -53,8 +53,3 @@ int ext2fs_inode_has_valid_blocks2(ext2_filsys fs, struct ext2_inode *inode)
}
return 1;
}
-
-int ext2fs_inode_has_valid_blocks(struct ext2_inode *inode)
-{
- return ext2fs_inode_has_valid_blocks2(NULL, inode);
-}
diff --git a/lib/quota/Android.mk b/lib/quota/Android.mk
deleted file mode 100644
index 8d0bfc32..00000000
--- a/lib/quota/Android.mk
+++ /dev/null
@@ -1,61 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-libext2_quota_src_files := \
- mkquota.c \
- quotaio.c \
- quotaio_tree.c \
- quotaio_v2.c \
- ../../e2fsck/dict.c
-
-libext2_quota_c_includes := external/e2fsprogs/lib
-
-libext2_quota_cflags := -O2 -g -W -Wall \
- -DHAVE_UNISTD_H \
- -DHAVE_ERRNO_H \
- -DHAVE_NETINET_IN_H \
- -DHAVE_SYS_IOCTL_H \
- -DHAVE_SYS_MMAN_H \
- -DHAVE_SYS_MOUNT_H \
- -DHAVE_SYS_PRCTL_H \
- -DHAVE_SYS_RESOURCE_H \
- -DHAVE_SYS_SELECT_H \
- -DHAVE_SYS_STAT_H \
- -DHAVE_SYS_TYPES_H \
- -DHAVE_STDLIB_H \
- -DHAVE_STRDUP \
- -DHAVE_MMAP \
- -DHAVE_UTIME_H \
- -DHAVE_GETPAGESIZE \
- -DHAVE_LSEEK64 \
- -DHAVE_LSEEK64_PROTOTYPE \
- -DHAVE_EXT2_IOCTLS \
- -DHAVE_LINUX_FD_H \
- -DHAVE_TYPE_SSIZE_T \
- -DHAVE_SYS_TIME_H \
- -DHAVE_SYS_PARAM_H \
- -DHAVE_SYSCONF
-
-libext2_quota_shared_libraries := libext2fs libext2_com_err
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(libext2_quota_src_files)
-LOCAL_C_INCLUDES := $(libext2_quota_c_includes)
-LOCAL_CFLAGS := $(libext2_quota_cflags)
-LOCAL_SYSTEM_SHARED_LIBRARIES := libc $(libext2_quota_shared_libraries)
-LOCAL_PRELINK_MODULE := false
-LOCAL_MODULE := libext2_quota
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(libext2_quota_src_files)
-LOCAL_C_INCLUDES := $(libext2_quota_c_includes)
-LOCAL_CFLAGS := $(libext2_quota_cflags)
-LOCAL_MODULE := libext2_quota_host
-LOCAL_MODULE_TAGS := optional
-LOCAL_SHARED_LIBRARIES := $(addsuffix _host, $(libext2_quota_shared_libraries))
-
-include $(BUILD_HOST_SHARED_LIBRARY)
diff --git a/lib/quota/Makefile.in b/lib/quota/Makefile.in
deleted file mode 100644
index ec4f6c45..00000000
--- a/lib/quota/Makefile.in
+++ /dev/null
@@ -1,162 +0,0 @@
-# Makefile for the QUOTA library
-#
-
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-VPATH = @srcdir@
-top_builddir = ../..
-my_dir = lib/quota
-INSTALL = @INSTALL@
-
-@MCONFIG@
-
-all::
-
-SMANPAGES=
-
-
-OBJS= mkquota.o quotaio.o quotaio_v2.o quotaio_tree.o dict.o
-
-SRCS= $(srcdir)/mkquota.c \
- $(srcdir)/quotaio.c \
- $(srcdir)/quotaio_tree.c \
- $(srcdir)/quotaio_v2.c \
- $(srcdir)/../../e2fsck/dict.c
-
-LIBRARY= libquota
-LIBDIR= quota
-
-#ELF_VERSION = 1.0
-#ELF_SO_VERSION = 1
-#ELF_IMAGE = libquota
-#ELF_MYDIR = quota
-#ELF_INSTALL_DIR = $(root_libdir)
-#ELF_OTHER_LIBS = -lext2fs
-
-#BSDLIB_VERSION = 1.0
-#BSDLIB_IMAGE = libquota
-#BSDLIB_MYDIR = quota
-#BSDLIB_INSTALL_DIR = $(root_libdir)
-
-@MAKEFILE_LIBRARY@
-#MAKEFILE_ELF#
-#MAKEFILE_BSDLIB#
-@MAKEFILE_PROFILE@
-@MAKEFILE_CHECKER@
-
-.c.o:
- $(E) " CC $<"
- $(Q) $(CC) $(ALL_CFLAGS) -c $< -o $@
- $(Q) $(CHECK_CMD) $(ALL_CFLAGS) $<
-@PROFILE_CMT@ $(Q) $(CC) $(ALL_CFLAGS) -g -pg -o profiled/$*.o -c $<
-@CHECKER_CMT@ $(Q) $(CC) $(ALL_CFLAGS) -checker -g -o checker/$*.o -c $<
-#ELF_CMT# $(Q) $(CC) $(ALL_CFLAGS) -fPIC -o elfshared/$*.o -c $<
-#BSDLIB_CMT# $(Q) $(CC) $(ALL_CFLAGS) $(BSDLIB_PIC_FLAG) -o pic/$*.o -c $<
-
-all:: $(SMANPAGES) quota.pc
-
-quota.pc: $(srcdir)/quota.pc.in $(top_builddir)/config.status
- $(E) " CONFIG.STATUS $@"
- $(Q) cd $(top_builddir); CONFIG_FILES=lib/quota/quota.pc ./config.status
-
-dict.o:
- $(E) " CC $<"
- $(Q) $(CC) -c $(ALL_CFLAGS) $(top_srcdir)/e2fsck/dict.c -o $@
-@PROFILE_CMT@ $(Q) $(CC) $(ALL_CFLAGS) -g -pg -o profiled/dict.o -c \
-@PROFILE_CMT@ $(top_srcdir)/e2fsck/dict.c
-@CHECKER_CMT@ $(Q) $(CC) $(ALL_CFLAGS) -checker -g -o checker/$*.o -c \
-@CHECKER_CMT@ $(top_srcdir)/e2fsck/dict.c
-#ELF_CMT# $(Q) $(CC) $(ALL_CFLAGS) -fPIC -o elfshared/$*.o -c \
-#ELF_CMT# $(top_srcdir)/e2fsck/dict.c
-#BSDLIB_CMT# $(Q) $(CC) $(ALL_CFLAGS) $(BSDLIB_PIC_FLAG) -o pic/$*.o -c \
-#BSDLIB_CMT# $(top_srcdir)/e2fsck/dict.c
-
-installdirs::
- $(E) " MKINSTALLDIRS $(libdir) $(includedir)/quota $(man3dir)"
- $(Q) $(MKINSTALLDIRS) $(DESTDIR)$(libdir) \
- $(DESTDIR)$(includedir)/quota $(DESTDIR)$(man3dir) \
- $(DESTDIR)$(libdir)/pkgconfig
-
-install:: all installdirs
- $(E) " INSTALL_DATA $(libdir)/libquota.a"
- $(Q) $(INSTALL_DATA) libquota.a $(DESTDIR)$(libdir)/libquota.a
- -$(Q) $(RANLIB) $(DESTDIR)$(libdir)/libquota.a
- $(Q) $(CHMOD) $(LIBMODE) $(DESTDIR)$(libdir)/libquota.a
- $(E) " INSTALL_DATA $(includedir)/quota/mkquota.h"
- $(Q) $(INSTALL_DATA) $(srcdir)/mkquota.h $(DESTDIR)$(includedir)/quota/mkquota.h
- $(Q) for i in $(SMANPAGES); do \
- $(RM) -f $(DESTDIR)$(man3dir)/$$i.gz; \
- echo " INSTALL_DATA $(man3dir)/$$i"; \
- $(INSTALL_DATA) $$i $(DESTDIR)$(man3dir)/$$i; \
- done
- $(E) " INSTALL_DATA $(libdir)/pkgconfig/quota.pc"
- $(Q) $(INSTALL_DATA) quota.pc $(DESTDIR)$(libdir)/pkgconfig/quota.pc
-
-uninstall::
- $(RM) -f $(DESTDIR)$(libdir)/libquota.a \
- $(DESTDIR)$(libdir)/pkgconfig/quota.pc
- for i in $(SMANPAGES); do \
- $(RM) -f $(DESTDIR)$(man3dir)/$$i; \
- done
-
-clean::
- $(RM) -f \#* *.s *.o *.a *~ *.bak core profiled/* checker/*
- $(RM) -f ../libquota.a ../libquota_p.a $(SMANPAGES)
-
-#check:: tst_uuid
-# LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./tst_uuid
-
-mostlyclean:: clean
-distclean:: clean
- $(RM) -f .depend Makefile quota.pc \
- $(srcdir)/TAGS $(srcdir)/Makefile.in.old
-
-#
-# Hack to parallel makes recognize dependencies correctly.
-#
-../../lib/libquota.a: libquota.a
-../../lib/libquota.so: image
-../../lib/libquota.dylib: image
-
-$(OBJS):
-
-# +++ Dependency line eater +++
-#
-# Makefile dependencies follow. This must be the last section in
-# the Makefile.in file
-#
-mkquota.o: $(srcdir)/mkquota.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \
- $(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/lib/ext2fs/ext2fs.h \
- $(top_srcdir)/lib/ext2fs/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
- $(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
- $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h \
- $(top_srcdir)/lib/e2p/e2p.h $(srcdir)/quotaio.h $(srcdir)/dqblk_v2.h \
- $(srcdir)/quotaio_tree.h $(srcdir)/quotaio_v2.h $(srcdir)/mkquota.h \
- $(top_srcdir)/lib/../e2fsck/dict.h $(srcdir)/common.h
-quotaio.o: $(srcdir)/quotaio.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/common.h $(srcdir)/quotaio.h \
- $(top_srcdir)/lib/ext2fs/ext2fs.h $(top_builddir)/lib/ext2fs/ext2_types.h \
- $(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_srcdir)/lib/ext2fs/ext3_extents.h \
- $(top_srcdir)/lib/et/com_err.h $(top_srcdir)/lib/ext2fs/ext2_io.h \
- $(top_builddir)/lib/ext2fs/ext2_err.h \
- $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h \
- $(srcdir)/dqblk_v2.h $(srcdir)/quotaio_tree.h
-quotaio_tree.o: $(srcdir)/quotaio_tree.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/common.h $(srcdir)/quotaio_tree.h \
- $(srcdir)/quotaio.h $(top_srcdir)/lib/ext2fs/ext2fs.h \
- $(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \
- $(top_srcdir)/lib/ext2fs/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
- $(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
- $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h \
- $(srcdir)/dqblk_v2.h
-quotaio_v2.o: $(srcdir)/quotaio_v2.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/common.h $(srcdir)/quotaio_v2.h \
- $(srcdir)/quotaio.h $(top_srcdir)/lib/ext2fs/ext2fs.h \
- $(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \
- $(top_srcdir)/lib/ext2fs/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
- $(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
- $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h \
- $(srcdir)/dqblk_v2.h $(srcdir)/quotaio_tree.h
-dict.o: $(srcdir)/../../e2fsck/dict.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/../../e2fsck/dict.h
diff --git a/lib/quota/common.h b/lib/quota/common.h
deleted file mode 100644
index 7f3f4b98..00000000
--- a/lib/quota/common.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- *
- * Various things common for all utilities
- *
- */
-
-#ifndef __QUOTA_COMMON_H__
-#define __QUOTA_COMMON_H__
-
-#ifndef __attribute__
-# if !defined __GNUC__ || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
-# define __attribute__(x)
-# endif
-#endif
-
-#define log_err(format, arg ...) \
- fprintf(stderr, "[ERROR] %s:%d:%s:: " format "\n", \
- __FILE__, __LINE__, __func__, ## arg)
-
-#ifdef DEBUG_QUOTA
-# define log_debug(format, arg ...) \
- fprintf(stderr, "[DEBUG] %s:%d:%s:: " format "\n", \
- __FILE__, __LINE__, __func__, ## arg)
-#else
-# define log_debug(format, ...)
-#endif
-
-#endif /* __QUOTA_COMMON_H__ */
diff --git a/lib/quota/dqblk_v2.h b/lib/quota/dqblk_v2.h
deleted file mode 100644
index d12512a6..00000000
--- a/lib/quota/dqblk_v2.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Header file for disk format of new quotafile format
- *
- * Jan Kara <jack@suse.cz> - sponsored by SuSE CR
- */
-
-#ifndef __QUOTA_DQBLK_V2_H__
-#define __QUOTA_DQBLK_V2_H__
-
-#include "quotaio_tree.h"
-
-/* Structure for format specific information */
-struct v2_mem_dqinfo {
- struct qtree_mem_dqinfo dqi_qtree;
- unsigned int dqi_flags; /* Flags set in quotafile */
- unsigned int dqi_used_entries; /* Number of entries in file -
- updated by scan_dquots */
- unsigned int dqi_data_blocks; /* Number of data blocks in file -
- updated by scan_dquots */
-};
-
-struct v2_mem_dqblk {
- long long dqb_off; /* Offset of dquot in file */
-};
-
-struct quotafile_ops; /* Will be defined later in quotaio.h */
-
-/* Operations above this format */
-extern struct quotafile_ops quotafile_ops_2;
-
-#endif /* __QUOTA_DQBLK_V2_H__ */
diff --git a/lib/quota/mkquota.c b/lib/quota/mkquota.c
deleted file mode 100644
index 46e17b6c..00000000
--- a/lib/quota/mkquota.c
+++ /dev/null
@@ -1,560 +0,0 @@
-/*
- * mkquota.c --- create quota files for a filesystem
- *
- * Aditya Kali <adityakali@google.com>
- */
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include <fcntl.h>
-
-#include "ext2fs/ext2_fs.h"
-#include "ext2fs/ext2fs.h"
-#include "e2p/e2p.h"
-
-#include "quotaio.h"
-#include "quotaio_v2.h"
-#include "quotaio_tree.h"
-#include "mkquota.h"
-#include "common.h"
-
-/* Needed for architectures where sizeof(int) != sizeof(void *) */
-#define UINT_TO_VOIDPTR(val) ((void *)(intptr_t)(val))
-#define VOIDPTR_TO_UINT(ptr) ((unsigned int)(intptr_t)(ptr))
-
-#if DEBUG_QUOTA
-static void print_inode(struct ext2_inode *inode)
-{
- if (!inode)
- return;
-
- fprintf(stderr, " i_mode = %d\n", inode->i_mode);
- fprintf(stderr, " i_uid = %d\n", inode->i_uid);
- fprintf(stderr, " i_size = %d\n", inode->i_size);
- fprintf(stderr, " i_atime = %d\n", inode->i_atime);
- fprintf(stderr, " i_ctime = %d\n", inode->i_ctime);
- fprintf(stderr, " i_mtime = %d\n", inode->i_mtime);
- fprintf(stderr, " i_dtime = %d\n", inode->i_dtime);
- fprintf(stderr, " i_gid = %d\n", inode->i_gid);
- fprintf(stderr, " i_links_count = %d\n", inode->i_links_count);
- fprintf(stderr, " i_blocks = %d\n", inode->i_blocks);
- fprintf(stderr, " i_flags = %d\n", inode->i_flags);
-
- return;
-}
-#endif
-
-/*
- * Returns 0 if not able to find the quota file, otherwise returns its
- * inode number.
- */
-int quota_file_exists(ext2_filsys fs, int qtype, int fmt)
-{
- char qf_name[256];
- errcode_t ret;
- ext2_ino_t ino;
-
- if (qtype >= MAXQUOTAS)
- return -EINVAL;
-
- quota_get_qf_name(qtype, QFMT_VFS_V1, qf_name);
-
- ret = ext2fs_lookup(fs, EXT2_ROOT_INO, qf_name, strlen(qf_name), 0,
- &ino);
- if (ret)
- return 0;
-
- return ino;
-}
-
-/*
- * Set the value for reserved quota inode number field in superblock.
- */
-void quota_set_sb_inum(ext2_filsys fs, ext2_ino_t ino, int qtype)
-{
- ext2_ino_t *inump;
-
- inump = (qtype == USRQUOTA) ? &fs->super->s_usr_quota_inum :
- &fs->super->s_grp_quota_inum;
-
- log_debug("setting quota ino in superblock: ino=%u, type=%d", ino,
- qtype);
- *inump = ino;
- ext2fs_mark_super_dirty(fs);
-}
-
-errcode_t quota_remove_inode(ext2_filsys fs, int qtype)
-{
- ext2_ino_t qf_ino;
-
- ext2fs_read_bitmaps(fs);
- qf_ino = (qtype == USRQUOTA) ? fs->super->s_usr_quota_inum :
- fs->super->s_grp_quota_inum;
- quota_set_sb_inum(fs, 0, qtype);
- /* Truncate the inode only if its a reserved one. */
- if (qf_ino < EXT2_FIRST_INODE(fs->super))
- quota_inode_truncate(fs, qf_ino);
-
- ext2fs_mark_super_dirty(fs);
- fs->flags &= ~EXT2_FLAG_SUPER_ONLY;
- ext2fs_write_bitmaps(fs);
- return 0;
-}
-
-static void write_dquots(dict_t *dict, struct quota_handle *qh)
-{
- dnode_t *n;
- struct dquot *dq;
-
- for (n = dict_first(dict); n; n = dict_next(dict, n)) {
- dq = dnode_get(n);
- if (dq) {
- dq->dq_h = qh;
- update_grace_times(dq);
- qh->qh_ops->commit_dquot(dq);
- }
- }
-}
-
-errcode_t quota_write_inode(quota_ctx_t qctx, int qtype)
-{
- int retval = 0, i;
- dict_t *dict;
- ext2_filsys fs;
- struct quota_handle *h = NULL;
- int fmt = QFMT_VFS_V1;
-
- if (!qctx)
- return 0;
-
- fs = qctx->fs;
- retval = ext2fs_get_mem(sizeof(struct quota_handle), &h);
- if (retval) {
- log_err("Unable to allocate quota handle");
- goto out;
- }
-
- ext2fs_read_bitmaps(fs);
-
- for (i = 0; i < MAXQUOTAS; i++) {
- if ((qtype != -1) && (i != qtype))
- continue;
-
- dict = qctx->quota_dict[i];
- if (!dict)
- continue;
-
- retval = quota_file_create(h, fs, i, fmt);
- if (retval < 0) {
- log_err("Cannot initialize io on quotafile");
- continue;
- }
-
- write_dquots(dict, h);
- retval = quota_file_close(h);
- if (retval < 0) {
- log_err("Cannot finish IO on new quotafile: %s",
- strerror(errno));
- if (h->qh_qf.e2_file)
- ext2fs_file_close(h->qh_qf.e2_file);
- quota_inode_truncate(fs, h->qh_qf.ino);
- continue;
- }
-
- /* Set quota inode numbers in superblock. */
- quota_set_sb_inum(fs, h->qh_qf.ino, i);
- ext2fs_mark_super_dirty(fs);
- ext2fs_mark_bb_dirty(fs);
- fs->flags &= ~EXT2_FLAG_SUPER_ONLY;
- }
-
- ext2fs_write_bitmaps(fs);
-out:
- if (h)
- ext2fs_free_mem(&h);
- return retval;
-}
-
-/******************************************************************/
-/* Helper functions for computing quota in memory. */
-/******************************************************************/
-
-static int dict_uint_cmp(const void *a, const void *b)
-{
- unsigned int c, d;
-
- c = VOIDPTR_TO_UINT(a);
- d = VOIDPTR_TO_UINT(b);
-
- return c - d;
-}
-
-static inline qid_t get_qid(struct ext2_inode *inode, int qtype)
-{
- if (qtype == USRQUOTA)
- return inode_uid(*inode);
- return inode_gid(*inode);
-}
-
-static void quota_dnode_free(dnode_t *node,
- void *context EXT2FS_ATTR((unused)))
-{
- void *ptr = node ? dnode_get(node) : 0;
-
- ext2fs_free_mem(&ptr);
- free(node);
-}
-
-/*
- * Set up the quota tracking data structures.
- */
-errcode_t quota_init_context(quota_ctx_t *qctx, ext2_filsys fs, int qtype)
-{
- int i, err = 0;
- dict_t *dict;
- quota_ctx_t ctx;
-
- err = ext2fs_get_mem(sizeof(struct quota_ctx), &ctx);
- if (err) {
- log_err("Failed to allocate quota context");
- return err;
- }
-
- memset(ctx, 0, sizeof(struct quota_ctx));
- for (i = 0; i < MAXQUOTAS; i++) {
- if ((qtype != -1) && (i != qtype))
- continue;
- err = ext2fs_get_mem(sizeof(dict_t), &dict);
- if (err) {
- log_err("Failed to allocate dictionary");
- quota_release_context(&ctx);
- return err;
- }
- ctx->quota_dict[i] = dict;
- dict_init(dict, DICTCOUNT_T_MAX, dict_uint_cmp);
- dict_set_allocator(dict, NULL, quota_dnode_free, NULL);
- }
-
- ctx->fs = fs;
- *qctx = ctx;
- return 0;
-}
-
-void quota_release_context(quota_ctx_t *qctx)
-{
- dict_t *dict;
- int i;
- quota_ctx_t ctx;
-
- if (!qctx)
- return;
-
- ctx = *qctx;
- for (i = 0; i < MAXQUOTAS; i++) {
- dict = ctx->quota_dict[i];
- ctx->quota_dict[i] = 0;
- if (dict) {
- dict_free_nodes(dict);
- free(dict);
- }
- }
- *qctx = NULL;
- free(ctx);
-}
-
-static struct dquot *get_dq(dict_t *dict, __u32 key)
-{
- struct dquot *dq;
- dnode_t *n;
-
- n = dict_lookup(dict, UINT_TO_VOIDPTR(key));
- if (n)
- dq = dnode_get(n);
- else {
- if (ext2fs_get_mem(sizeof(struct dquot), &dq)) {
- log_err("Unable to allocate dquot");
- return NULL;
- }
- memset(dq, 0, sizeof(struct dquot));
- dict_alloc_insert(dict, UINT_TO_VOIDPTR(key), dq);
- dq->dq_id = key;
- }
- return dq;
-}
-
-
-/*
- * Called to update the blocks used by a particular inode
- */
-void quota_data_add(quota_ctx_t qctx, struct ext2_inode *inode, ext2_ino_t ino,
- qsize_t space)
-{
- struct dquot *dq;
- dict_t *dict;
- int i;
-
- if (!qctx)
- return;
-
- log_debug("ADD_DATA: Inode: %u, UID/GID: %u/%u, space: %ld", ino,
- inode_uid(*inode),
- inode_gid(*inode), space);
- for (i = 0; i < MAXQUOTAS; i++) {
- dict = qctx->quota_dict[i];
- if (dict) {
- dq = get_dq(dict, get_qid(inode, i));
- if (dq)
- dq->dq_dqb.dqb_curspace += space;
- }
- }
-}
-
-/*
- * Called to remove some blocks used by a particular inode
- */
-void quota_data_sub(quota_ctx_t qctx, struct ext2_inode *inode, ext2_ino_t ino,
- qsize_t space)
-{
- struct dquot *dq;
- dict_t *dict;
- int i;
-
- if (!qctx)
- return;
-
- log_debug("SUB_DATA: Inode: %u, UID/GID: %u/%u, space: %ld", ino,
- inode_uid(*inode),
- inode_gid(*inode), space);
- for (i = 0; i < MAXQUOTAS; i++) {
- dict = qctx->quota_dict[i];
- if (dict) {
- dq = get_dq(dict, get_qid(inode, i));
- dq->dq_dqb.dqb_curspace -= space;
- }
- }
-}
-
-/*
- * Called to count the files used by an inode's user/group
- */
-void quota_data_inodes(quota_ctx_t qctx, struct ext2_inode *inode,
- ext2_ino_t ino, int adjust)
-{
- struct dquot *dq;
- dict_t *dict;
- int i;
-
- if (!qctx)
- return;
-
- log_debug("ADJ_INODE: Inode: %u, UID/GID: %u/%u, adjust: %d", ino,
- inode_uid(*inode),
- inode_gid(*inode), adjust);
- for (i = 0; i < MAXQUOTAS; i++) {
- dict = qctx->quota_dict[i];
- if (dict) {
- dq = get_dq(dict, get_qid(inode, i));
- dq->dq_dqb.dqb_curinodes += adjust;
- }
- }
-}
-
-errcode_t quota_compute_usage(quota_ctx_t qctx)
-{
- ext2_filsys fs;
- ext2_ino_t ino;
- errcode_t ret;
- struct ext2_inode inode;
- qsize_t space;
- ext2_inode_scan scan;
-
- if (!qctx)
- return 0;
-
- fs = qctx->fs;
- ret = ext2fs_open_inode_scan(fs, 0, &scan);
- if (ret) {
- log_err("while opening inode scan. ret=%ld", ret);
- return ret;
- }
-
- while (1) {
- ret = ext2fs_get_next_inode(scan, &ino, &inode);
- if (ret) {
- log_err("while getting next inode. ret=%ld", ret);
- ext2fs_close_inode_scan(scan);
- return ret;
- }
- if (ino == 0)
- break;
- if (inode.i_links_count &&
- (ino == EXT2_ROOT_INO ||
- ino >= EXT2_FIRST_INODE(fs->super))) {
- space = ext2fs_inode_i_blocks(fs, &inode) << 9;
- quota_data_add(qctx, &inode, ino, space);
- quota_data_inodes(qctx, &inode, ino, +1);
- }
- }
-
- ext2fs_close_inode_scan(scan);
-
- return 0;
-}
-
-struct scan_dquots_data {
- dict_t *quota_dict;
- int update_limits; /* update limits from disk */
- int update_usage;
- int usage_is_inconsistent;
-};
-
-static int scan_dquots_callback(struct dquot *dquot, void *cb_data)
-{
- struct scan_dquots_data *scan_data = cb_data;
- dict_t *quota_dict = scan_data->quota_dict;
- struct dquot *dq;
-
- dq = get_dq(quota_dict, dquot->dq_id);
- dq->dq_id = dquot->dq_id;
- dq->dq_dqb.u.v2_mdqb.dqb_off = dquot->dq_dqb.u.v2_mdqb.dqb_off;
-
- /* Check if there is inconsistancy. */
- if (dq->dq_dqb.dqb_curspace != dquot->dq_dqb.dqb_curspace ||
- dq->dq_dqb.dqb_curinodes != dquot->dq_dqb.dqb_curinodes) {
- scan_data->usage_is_inconsistent = 1;
- fprintf(stderr, "[QUOTA WARNING] Usage inconsistent for ID %d:"
- "actual (%llu, %llu) != expected (%llu, %llu)\n",
- dq->dq_id, (long long)dq->dq_dqb.dqb_curspace,
- (long long)dq->dq_dqb.dqb_curinodes,
- (long long)dquot->dq_dqb.dqb_curspace,
- (long long)dquot->dq_dqb.dqb_curinodes);
- }
-
- if (scan_data->update_limits) {
- dq->dq_dqb.dqb_ihardlimit = dquot->dq_dqb.dqb_ihardlimit;
- dq->dq_dqb.dqb_isoftlimit = dquot->dq_dqb.dqb_isoftlimit;
- dq->dq_dqb.dqb_bhardlimit = dquot->dq_dqb.dqb_bhardlimit;
- dq->dq_dqb.dqb_bsoftlimit = dquot->dq_dqb.dqb_bsoftlimit;
- }
-
- if (scan_data->update_usage) {
- dq->dq_dqb.dqb_curspace = dquot->dq_dqb.dqb_curspace;
- dq->dq_dqb.dqb_curinodes = dquot->dq_dqb.dqb_curinodes;
- }
-
- return 0;
-}
-
-/*
- * Read all dquots from quota file into memory
- */
-static errcode_t quota_read_all_dquots(struct quota_handle *qh,
- quota_ctx_t qctx, int update_limits)
-{
- struct scan_dquots_data scan_data;
-
- scan_data.quota_dict = qctx->quota_dict[qh->qh_type];
- scan_data.update_limits = update_limits;
- scan_data.update_usage = 0;
-
- return qh->qh_ops->scan_dquots(qh, scan_dquots_callback, &scan_data);
-}
-
-/*
- * Write all memory dquots into quota file
- */
-#if 0 /* currently unused, but may be useful in the future? */
-static errcode_t quota_write_all_dquots(struct quota_handle *qh,
- quota_ctx_t qctx)
-{
- errcode_t err;
-
- err = ext2fs_read_bitmaps(qctx->fs);
- if (err)
- return err;
- write_dquots(qctx->quota_dict[qh->qh_type], qh);
- ext2fs_mark_bb_dirty(qctx->fs);
- qctx->fs->flags &= ~EXT2_FLAG_SUPER_ONLY;
- ext2fs_write_bitmaps(qctx->fs);
- return 0;
-}
-#endif
-
-/*
- * Updates the in-memory quota limits from the given quota inode.
- */
-errcode_t quota_update_limits(quota_ctx_t qctx, ext2_ino_t qf_ino, int type)
-{
- struct quota_handle *qh;
- errcode_t err;
-
- if (!qctx)
- return 0;
-
- err = ext2fs_get_mem(sizeof(struct quota_handle), &qh);
- if (err) {
- log_err("Unable to allocate quota handle");
- return err;
- }
-
- err = quota_file_open(qh, qctx->fs, qf_ino, type, -1, 0);
- if (err) {
- log_err("Open quota file failed");
- goto out;
- }
-
- quota_read_all_dquots(qh, qctx, 1);
-
- err = quota_file_close(qh);
- if (err) {
- log_err("Cannot finish IO on new quotafile: %s",
- strerror(errno));
- if (qh->qh_qf.e2_file)
- ext2fs_file_close(qh->qh_qf.e2_file);
- }
-out:
- ext2fs_free_mem(&qh);
- return err;
-}
-
-/*
- * Compares the measured quota in qctx->quota_dict with that in the quota inode
- * on disk and updates the limits in qctx->quota_dict. 'usage_inconsistent' is
- * set to 1 if the supplied and on-disk quota usage values are not identical.
- */
-errcode_t quota_compare_and_update(quota_ctx_t qctx, int qtype,
- int *usage_inconsistent)
-{
- ext2_filsys fs = qctx->fs;
- struct quota_handle qh;
- struct scan_dquots_data scan_data;
- ext2_ino_t qf_ino;
- errcode_t err = 0;
-
- if (!qctx->quota_dict[qtype])
- goto out;
-
- qf_ino = qtype == USRQUOTA ? fs->super->s_usr_quota_inum :
- fs->super->s_grp_quota_inum;
- err = quota_file_open(&qh, fs, qf_ino, qtype, -1, 0);
- if (err) {
- log_err("Open quota file failed");
- goto out;
- }
-
- scan_data.quota_dict = qctx->quota_dict[qtype];
- scan_data.update_limits = 1;
- scan_data.update_usage = 0;
- scan_data.usage_is_inconsistent = 0;
- err = qh.qh_ops->scan_dquots(&qh, scan_dquots_callback, &scan_data);
- if (err) {
- log_err("Error scanning dquots");
- goto out;
- }
- *usage_inconsistent = scan_data.usage_is_inconsistent;
-
-out:
- return err;
-}
diff --git a/lib/quota/mkquota.h b/lib/quota/mkquota.h
deleted file mode 100644
index ee150719..00000000
--- a/lib/quota/mkquota.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/** mkquota.h
- *
- * Interface to the quota library.
- *
- * The quota library provides interface for creating and updating the quota
- * files and the ext4 superblock fields. It supports the new VFS_V1 quota
- * format. The quota library also provides support for keeping track of quotas
- * in memory.
- * The typical way to use the quota library is as follows:
- * {
- * quota_ctx_t qctx;
- *
- * quota_init_context(&qctx, fs, -1);
- * {
- * quota_compute_usage(qctx, -1);
- * AND/OR
- * quota_data_add/quota_data_sub/quota_data_inodes();
- * }
- * quota_write_inode(qctx, USRQUOTA);
- * quota_write_inode(qctx, GRPQUOTA);
- * quota_release_context(&qctx);
- * }
- *
- * This initial version does not support reading the quota files. This support
- * will be added in near future.
- *
- * Aditya Kali <adityakali@google.com>
- */
-
-#ifndef __QUOTA_QUOTAIO_H__
-#define __QUOTA_QUOTAIO_H__
-
-#include "ext2fs/ext2_fs.h"
-#include "ext2fs/ext2fs.h"
-#include "quotaio.h"
-#include "../e2fsck/dict.h"
-
-typedef struct quota_ctx *quota_ctx_t;
-
-struct quota_ctx {
- ext2_filsys fs;
- dict_t *quota_dict[MAXQUOTAS];
-};
-
-/* In mkquota.c */
-errcode_t quota_init_context(quota_ctx_t *qctx, ext2_filsys fs, int qtype);
-void quota_data_inodes(quota_ctx_t qctx, struct ext2_inode *inode, ext2_ino_t ino,
- int adjust);
-void quota_data_add(quota_ctx_t qctx, struct ext2_inode *inode, ext2_ino_t ino,
- qsize_t space);
-void quota_data_sub(quota_ctx_t qctx, struct ext2_inode *inode, ext2_ino_t ino,
- qsize_t space);
-errcode_t quota_write_inode(quota_ctx_t qctx, int qtype);
-errcode_t quota_update_limits(quota_ctx_t qctx, ext2_ino_t qf_ino, int type);
-errcode_t quota_compute_usage(quota_ctx_t qctx);
-void quota_release_context(quota_ctx_t *qctx);
-
-errcode_t quota_remove_inode(ext2_filsys fs, int qtype);
-int quota_file_exists(ext2_filsys fs, int qtype, int fmt);
-void quota_set_sb_inum(ext2_filsys fs, ext2_ino_t ino, int qtype);
-errcode_t quota_compare_and_update(quota_ctx_t qctx, int qtype,
- int *usage_inconsistent);
-
-#endif /* __QUOTA_QUOTAIO_H__ */
diff --git a/lib/quota/quota.pc.in b/lib/quota/quota.pc.in
deleted file mode 100644
index 1e4b8874..00000000
--- a/lib/quota/quota.pc.in
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: quota
-Description: Quota management library
-Version: @E2FSPROGS_VERSION@
-Requires:
-Cflags: -I${includedir}/quota -I${includedir}
-Libs: -L${libdir} -lquota
diff --git a/lib/quota/quotaio.c b/lib/quota/quotaio.c
deleted file mode 100644
index b518bc86..00000000
--- a/lib/quota/quotaio.c
+++ /dev/null
@@ -1,381 +0,0 @@
-/** quotaio.c
- *
- * Generic IO operations on quotafiles
- * Jan Kara <jack@suse.cz> - sponsored by SuSE CR
- * Aditya Kali <adityakali@google.com> - Ported to e2fsprogs
- */
-
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-
-#include "common.h"
-#include "quotaio.h"
-
-static const char * const extensions[MAXQUOTAS] = {"user", "group"};
-static const char * const basenames[] = {
- "", /* undefined */
- "quota", /* QFMT_VFS_OLD */
- "aquota", /* QFMT_VFS_V0 */
- "", /* QFMT_OCFS2 */
- "aquota" /* QFMT_VFS_V1 */
-};
-
-/* Header in all newer quotafiles */
-struct disk_dqheader {
- u_int32_t dqh_magic;
- u_int32_t dqh_version;
-} __attribute__ ((packed));
-
-/**
- * Convert type of quota to written representation
- */
-const char *type2name(int type)
-{
- return extensions[type];
-}
-
-/**
- * Creates a quota file name for given type and format.
- */
-const char *quota_get_qf_name(int type, int fmt, char *buf)
-{
- if (!buf)
- return NULL;
- snprintf(buf, QUOTA_NAME_LEN, "%s.%s",
- basenames[fmt], extensions[type]);
-
- return buf;
-}
-
-const char *quota_get_qf_path(const char *mntpt, int qtype, int fmt,
- char *path_buf, size_t path_buf_size)
-{
- char qf_name[QUOTA_NAME_LEN];
-
- if (!mntpt || !path_buf || !path_buf_size)
- return NULL;
-
- strncpy(path_buf, mntpt, path_buf_size);
- strncat(path_buf, "/", 1);
- strncat(path_buf, quota_get_qf_name(qtype, fmt, qf_name),
- path_buf_size - strlen(path_buf));
-
- return path_buf;
-}
-
-/*
- * Set grace time if needed
- */
-void update_grace_times(struct dquot *q)
-{
- time_t now;
-
- time(&now);
- if (q->dq_dqb.dqb_bsoftlimit && toqb(q->dq_dqb.dqb_curspace) >
- q->dq_dqb.dqb_bsoftlimit) {
- if (!q->dq_dqb.dqb_btime)
- q->dq_dqb.dqb_btime =
- now + q->dq_h->qh_info.dqi_bgrace;
- } else {
- q->dq_dqb.dqb_btime = 0;
- }
-
- if (q->dq_dqb.dqb_isoftlimit && q->dq_dqb.dqb_curinodes >
- q->dq_dqb.dqb_isoftlimit) {
- if (!q->dq_dqb.dqb_itime)
- q->dq_dqb.dqb_itime =
- now + q->dq_h->qh_info.dqi_igrace;
- } else {
- q->dq_dqb.dqb_itime = 0;
- }
-}
-
-static int compute_num_blocks_proc(ext2_filsys fs, blk64_t *blocknr,
- e2_blkcnt_t blockcnt EXT2FS_ATTR((unused)),
- blk64_t ref_block EXT2FS_ATTR((unused)),
- int ref_offset EXT2FS_ATTR((unused)),
- void *private)
-{
- blk64_t *num_blocks = private;
-
- *num_blocks += 1;
- return 0;
-}
-
-errcode_t quota_inode_truncate(ext2_filsys fs, ext2_ino_t ino)
-{
- struct ext2_inode inode;
- errcode_t err;
-
- if ((err = ext2fs_read_inode(fs, ino, &inode)))
- return err;
-
- if ((ino == EXT4_USR_QUOTA_INO) || (ino == EXT4_GRP_QUOTA_INO)) {
- inode.i_dtime = fs->now ? fs->now : time(0);
- if (!ext2fs_inode_has_valid_blocks2(fs, &inode))
- return 0;
- err = ext2fs_punch(fs, ino, &inode, NULL, 0, ~0ULL);
- if (err)
- return err;
- fs->flags &= ~EXT2_FLAG_SUPER_ONLY;
- memset(&inode, 0, sizeof(struct ext2_inode));
- } else {
- inode.i_flags &= ~EXT2_IMMUTABLE_FL;
- }
- err = ext2fs_write_inode(fs, ino, &inode);
- return err;
-}
-
-static ext2_off64_t compute_inode_size(ext2_filsys fs, ext2_ino_t ino)
-{
- blk64_t num_blocks = 0;
-
- ext2fs_block_iterate3(fs, ino,
- BLOCK_FLAG_READ_ONLY,
- NULL,
- compute_num_blocks_proc,
- &num_blocks);
- return num_blocks * fs->blocksize;
-}
-
-/* Functions to read/write quota file. */
-static unsigned int quota_write_nomount(struct quota_file *qf,
- ext2_loff_t offset,
- void *buf, unsigned int size)
-{
- ext2_file_t e2_file = qf->e2_file;
- unsigned int bytes_written = 0;
- errcode_t err;
-
- err = ext2fs_file_llseek(e2_file, offset, EXT2_SEEK_SET, NULL);
- if (err) {
- log_err("ext2fs_file_llseek failed: %ld", err);
- return 0;
- }
-
- err = ext2fs_file_write(e2_file, buf, size, &bytes_written);
- if (err) {
- log_err("ext2fs_file_write failed: %ld", err);
- return 0;
- }
-
- /* Correct inode.i_size is set in end_io. */
- return bytes_written;
-}
-
-static unsigned int quota_read_nomount(struct quota_file *qf,
- ext2_loff_t offset,
- void *buf, unsigned int size)
-{
- ext2_file_t e2_file = qf->e2_file;
- unsigned int bytes_read = 0;
- errcode_t err;
-
- err = ext2fs_file_llseek(e2_file, offset, EXT2_SEEK_SET, NULL);
- if (err) {
- log_err("ext2fs_file_llseek failed: %ld", err);
- return 0;
- }
-
- err = ext2fs_file_read(e2_file, buf, size, &bytes_read);
- if (err) {
- log_err("ext2fs_file_read failed: %ld", err);
- return 0;
- }
-
- return bytes_read;
-}
-
-/*
- * Detect quota format and initialize quota IO
- */
-errcode_t quota_file_open(struct quota_handle *h, ext2_filsys fs,
- ext2_ino_t qf_ino, int type, int fmt, int flags)
-{
- ext2_file_t e2_file;
- errcode_t err;
-
- if (fmt == -1)
- fmt = QFMT_VFS_V1;
-
- err = ext2fs_read_bitmaps(fs);
- if (err)
- return err;
-
- log_debug("Opening quota ino=%lu, type=%d", qf_ino, type);
- err = ext2fs_file_open(fs, qf_ino, flags, &e2_file);
- if (err) {
- log_err("ext2fs_file_open failed: %s", error_message(err));
- return err;
- }
- h->qh_qf.e2_file = e2_file;
-
- h->qh_qf.fs = fs;
- h->qh_qf.ino = qf_ino;
- h->e2fs_write = quota_write_nomount;
- h->e2fs_read = quota_read_nomount;
- h->qh_io_flags = 0;
- h->qh_type = type;
- h->qh_fmt = fmt;
- memset(&h->qh_info, 0, sizeof(h->qh_info));
- h->qh_ops = &quotafile_ops_2;
-
- if (h->qh_ops->check_file &&
- (h->qh_ops->check_file(h, type, fmt) == 0)) {
- log_err("qh_ops->check_file failed");
- ext2fs_file_close(e2_file);
- return -1;
- }
-
- if (h->qh_ops->init_io && (h->qh_ops->init_io(h) < 0)) {
- log_err("qh_ops->init_io failed");
- ext2fs_file_close(e2_file);
- return -1;
- }
-
- return 0;
-}
-
-static errcode_t quota_inode_init_new(ext2_filsys fs, ext2_ino_t ino)
-{
- struct ext2_inode inode;
- errcode_t err = 0;
-
- err = ext2fs_read_inode(fs, ino, &inode);
- if (err) {
- log_err("ex2fs_read_inode failed");
- return err;
- }
-
- if (EXT2_I_SIZE(&inode))
- quota_inode_truncate(fs, ino);
-
- memset(&inode, 0, sizeof(struct ext2_inode));
- ext2fs_iblk_set(fs, &inode, 0);
- inode.i_atime = inode.i_mtime =
- inode.i_ctime = fs->now ? fs->now : time(0);
- inode.i_links_count = 1;
- inode.i_mode = LINUX_S_IFREG | 0600;
- inode.i_flags |= EXT2_IMMUTABLE_FL;
- if (fs->super->s_feature_incompat &
- EXT3_FEATURE_INCOMPAT_EXTENTS)
- inode.i_flags |= EXT4_EXTENTS_FL;
-
- err = ext2fs_write_new_inode(fs, ino, &inode);
- if (err) {
- log_err("ext2fs_write_new_inode failed: %ld", err);
- return err;
- }
- return err;
-}
-
-/*
- * Create new quotafile of specified format on given filesystem
- */
-errcode_t quota_file_create(struct quota_handle *h, ext2_filsys fs, int type, int fmt)
-{
- ext2_file_t e2_file;
- int err;
- unsigned long qf_inum;
-
- if (fmt == -1)
- fmt = QFMT_VFS_V1;
-
- h->qh_qf.fs = fs;
- if (type == USRQUOTA)
- qf_inum = EXT4_USR_QUOTA_INO;
- else if (type == GRPQUOTA)
- qf_inum = EXT4_GRP_QUOTA_INO;
- else
- return -1;
-
- err = ext2fs_read_bitmaps(fs);
- if (err)
- goto out_err;
-
- err = quota_inode_init_new(fs, qf_inum);
- if (err) {
- log_err("init_new_quota_inode failed");
- goto out_err;
- }
- h->qh_qf.ino = qf_inum;
- h->e2fs_write = quota_write_nomount;
- h->e2fs_read = quota_read_nomount;
-
- log_debug("Creating quota ino=%lu, type=%d", qf_inum, type);
- err = ext2fs_file_open(fs, qf_inum,
- EXT2_FILE_WRITE | EXT2_FILE_CREATE, &e2_file);
- if (err) {
- log_err("ext2fs_file_open failed: %d", err);
- goto out_err;
- }
- h->qh_qf.e2_file = e2_file;
-
- h->qh_io_flags = 0;
- h->qh_type = type;
- h->qh_fmt = fmt;
- memset(&h->qh_info, 0, sizeof(h->qh_info));
- h->qh_ops = &quotafile_ops_2;
-
- if (h->qh_ops->new_io && (h->qh_ops->new_io(h) < 0)) {
- log_err("qh_ops->new_io failed");
- goto out_err1;
- }
-
- return 0;
-
-out_err1:
- ext2fs_file_close(e2_file);
-out_err:
-
- if (qf_inum)
- quota_inode_truncate(fs, qf_inum);
-
- return -1;
-}
-
-/*
- * Close quotafile and release handle
- */
-errcode_t quota_file_close(struct quota_handle *h)
-{
- if (h->qh_io_flags & IOFL_INFODIRTY) {
- if (h->qh_ops->write_info && h->qh_ops->write_info(h) < 0)
- return -1;
- h->qh_io_flags &= ~IOFL_INFODIRTY;
- }
-
- if (h->qh_ops->end_io && h->qh_ops->end_io(h) < 0)
- return -1;
- if (h->qh_qf.e2_file) {
- ext2fs_file_flush(h->qh_qf.e2_file);
- ext2fs_file_set_size2(h->qh_qf.e2_file,
- compute_inode_size(h->qh_qf.fs, h->qh_qf.ino));
- ext2fs_file_close(h->qh_qf.e2_file);
- }
-
- return 0;
-}
-
-/*
- * Create empty quota structure
- */
-struct dquot *get_empty_dquot(void)
-{
- struct dquot *dquot;
-
- if (ext2fs_get_memzero(sizeof(struct dquot), &dquot)) {
- log_err("Failed to allocate dquot");
- return NULL;
- }
-
- dquot->dq_id = -1;
- return dquot;
-}
diff --git a/lib/quota/quotaio.h b/lib/quota/quotaio.h
deleted file mode 100644
index 1c062f10..00000000
--- a/lib/quota/quotaio.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/** quotaio.h
- *
- * Header of IO operations for quota utilities
- * Jan Kara <jack@suse.cz>
- */
-
-#ifndef GUARD_QUOTAIO_H
-#define GUARD_QUOTAIO_H
-
-#include <limits.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include "ext2fs/ext2fs.h"
-#include "dqblk_v2.h"
-
-typedef int64_t qsize_t; /* Type in which we store size limitations */
-
-#define MAXQUOTAS 2
-#define USRQUOTA 0
-#define GRPQUOTA 1
-
-/*
- * Definitions of magics and versions of current quota files
- */
-#define INITQMAGICS {\
- 0xd9c01f11, /* USRQUOTA */\
- 0xd9c01927 /* GRPQUOTA */\
-}
-
-/* Size of blocks in which are counted size limits in generic utility parts */
-#define QUOTABLOCK_BITS 10
-#define QUOTABLOCK_SIZE (1 << QUOTABLOCK_BITS)
-#define toqb(x) (((x) + QUOTABLOCK_SIZE - 1) >> QUOTABLOCK_BITS)
-
-/* Quota format type IDs */
-#define QFMT_VFS_OLD 1
-#define QFMT_VFS_V0 2
-#define QFMT_VFS_V1 4
-
-/*
- * The following constants define the default amount of time given a user
- * before the soft limits are treated as hard limits (usually resulting
- * in an allocation failure). The timer is started when the user crosses
- * their soft limit, it is reset when they go below their soft limit.
- */
-#define MAX_IQ_TIME 604800 /* (7*24*60*60) 1 week */
-#define MAX_DQ_TIME 604800 /* (7*24*60*60) 1 week */
-
-#define IOFL_INFODIRTY 0x01 /* Did info change? */
-
-struct quotafile_ops;
-
-/* Generic information about quotafile */
-struct util_dqinfo {
- time_t dqi_bgrace; /* Block grace time for given quotafile */
- time_t dqi_igrace; /* Inode grace time for given quotafile */
- union {
- struct v2_mem_dqinfo v2_mdqi;
- } u; /* Format specific info about quotafile */
-};
-
-struct quota_file {
- ext2_filsys fs;
- ext2_ino_t ino;
- ext2_file_t e2_file;
-};
-
-/* Structure for one opened quota file */
-struct quota_handle {
- int qh_type; /* Type of quotafile */
- int qh_fmt; /* Quotafile format */
- int qh_io_flags; /* IO flags for file */
- struct quota_file qh_qf;
- unsigned int (*e2fs_read)(struct quota_file *qf, ext2_loff_t offset,
- void *buf, unsigned int size);
- unsigned int (*e2fs_write)(struct quota_file *qf, ext2_loff_t offset,
- void *buf, unsigned int size);
- struct quotafile_ops *qh_ops; /* Operations on quotafile */
- struct util_dqinfo qh_info; /* Generic quotafile info */
-};
-
-/* Utility quota block */
-struct util_dqblk {
- qsize_t dqb_ihardlimit;
- qsize_t dqb_isoftlimit;
- qsize_t dqb_curinodes;
- qsize_t dqb_bhardlimit;
- qsize_t dqb_bsoftlimit;
- qsize_t dqb_curspace;
- time_t dqb_btime;
- time_t dqb_itime;
- union {
- struct v2_mem_dqblk v2_mdqb;
- } u; /* Format specific dquot information */
-};
-
-/* Structure for one loaded quota */
-struct dquot {
- struct dquot *dq_next; /* Pointer to next dquot in the list */
- qid_t dq_id; /* ID dquot belongs to */
- int dq_flags; /* Some flags for utils */
- struct quota_handle *dq_h; /* Handle of quotafile for this dquot */
- struct util_dqblk dq_dqb; /* Parsed data of dquot */
-};
-
-/* Structure of quotafile operations */
-struct quotafile_ops {
- /* Check whether quotafile is in our format */
- int (*check_file) (struct quota_handle *h, int type, int fmt);
- /* Open quotafile */
- int (*init_io) (struct quota_handle *h);
- /* Create new quotafile */
- int (*new_io) (struct quota_handle *h);
- /* Write all changes and close quotafile */
- int (*end_io) (struct quota_handle *h);
- /* Write info about quotafile */
- int (*write_info) (struct quota_handle *h);
- /* Read dquot into memory */
- struct dquot *(*read_dquot) (struct quota_handle *h, qid_t id);
- /* Write given dquot to disk */
- int (*commit_dquot) (struct dquot *dquot);
- /* Scan quotafile and call callback on every structure */
- int (*scan_dquots) (struct quota_handle *h,
- int (*process_dquot) (struct dquot *dquot,
- void *data),
- void *data);
- /* Function to print format specific file information */
- int (*report) (struct quota_handle *h, int verbose);
-};
-
-/* This might go into a special header file but that sounds a bit silly... */
-extern struct quotafile_ops quotafile_ops_meta;
-
-/* Open existing quotafile of given type (and verify its format) on given
- * filesystem. */
-errcode_t quota_file_open(struct quota_handle *h, ext2_filsys fs,
- ext2_ino_t qf_ino, int type, int fmt, int flags);
-
-
-/* Create new quotafile of specified format on given filesystem */
-errcode_t quota_file_create(struct quota_handle *h, ext2_filsys fs,
- int type, int fmt);
-
-/* Close quotafile */
-errcode_t quota_file_close(struct quota_handle *h);
-
-/* Get empty quota structure */
-struct dquot *get_empty_dquot(void);
-
-errcode_t quota_inode_truncate(ext2_filsys fs, ext2_ino_t ino);
-
-const char *type2name(int type);
-
-void update_grace_times(struct dquot *q);
-
-/* size for the buffer returned by quota_get_qf_name(); must be greater
- than maxlen of extensions[] and fmtnames[] (plus 2) found in quotaio.c */
-#define QUOTA_NAME_LEN 16
-
-const char *quota_get_qf_name(int type, int fmt, char *buf);
-const char *quota_get_qf_path(const char *mntpt, int qtype, int fmt,
- char *path_buf, size_t path_buf_size);
-
-#endif /* GUARD_QUOTAIO_H */
diff --git a/lib/quota/quotaio_tree.c b/lib/quota/quotaio_tree.c
deleted file mode 100644
index 964494d1..00000000
--- a/lib/quota/quotaio_tree.c
+++ /dev/null
@@ -1,655 +0,0 @@
-/*
- * Implementation of new quotafile format
- *
- * Jan Kara <jack@suse.cz> - sponsored by SuSE CR
- */
-
-#include <sys/types.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "common.h"
-#include "quotaio_tree.h"
-#include "quotaio.h"
-
-typedef char *dqbuf_t;
-
-#define freedqbuf(buf) ext2fs_free_mem(&buf)
-
-static inline dqbuf_t getdqbuf(void)
-{
- dqbuf_t buf;
- if (ext2fs_get_memzero(QT_BLKSIZE, &buf)) {
- log_err("Failed to allocate dqbuf");
- return NULL;
- }
-
- return buf;
-}
-
-/* Is given dquot empty? */
-int qtree_entry_unused(struct qtree_mem_dqinfo *info, char *disk)
-{
- int i;
-
- for (i = 0; i < info->dqi_entry_size; i++)
- if (disk[i])
- return 0;
- return 1;
-}
-
-int qtree_dqstr_in_blk(struct qtree_mem_dqinfo *info)
-{
- return (QT_BLKSIZE - sizeof(struct qt_disk_dqdbheader)) /
- info->dqi_entry_size;
-}
-
-static int get_index(qid_t id, int depth)
-{
- return (id >> ((QT_TREEDEPTH - depth - 1) * 8)) & 0xff;
-}
-
-static inline void mark_quotafile_info_dirty(struct quota_handle *h)
-{
- h->qh_io_flags |= IOFL_INFODIRTY;
-}
-
-/* Read given block */
-static void read_blk(struct quota_handle *h, uint blk, dqbuf_t buf)
-{
- int err;
-
- err = h->e2fs_read(&h->qh_qf, blk << QT_BLKSIZE_BITS, buf,
- QT_BLKSIZE);
- if (err < 0)
- log_err("Cannot read block %u: %s", blk, strerror(errno));
- else if (err != QT_BLKSIZE)
- memset(buf + err, 0, QT_BLKSIZE - err);
-}
-
-/* Write block */
-static int write_blk(struct quota_handle *h, uint blk, dqbuf_t buf)
-{
- int err;
-
- err = h->e2fs_write(&h->qh_qf, blk << QT_BLKSIZE_BITS, buf,
- QT_BLKSIZE);
- if (err < 0 && errno != ENOSPC)
- log_err("Cannot write block (%u): %s", blk, strerror(errno));
- if (err != QT_BLKSIZE)
- return -ENOSPC;
- return 0;
-}
-
-/* Get free block in file (either from free list or create new one) */
-static int get_free_dqblk(struct quota_handle *h)
-{
- dqbuf_t buf = getdqbuf();
- struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf;
- struct qtree_mem_dqinfo *info = &h->qh_info.u.v2_mdqi.dqi_qtree;
- int blk;
-
- if (!buf)
- return -ENOMEM;
-
- if (info->dqi_free_blk) {
- blk = info->dqi_free_blk;
- read_blk(h, blk, buf);
- info->dqi_free_blk = ext2fs_le32_to_cpu(dh->dqdh_next_free);
- } else {
- memset(buf, 0, QT_BLKSIZE);
- /* Assure block allocation... */
- if (write_blk(h, info->dqi_blocks, buf) < 0) {
- freedqbuf(buf);
- log_err("Cannot allocate new quota block "
- "(out of disk space).");
- return -ENOSPC;
- }
- blk = info->dqi_blocks++;
- }
- mark_quotafile_info_dirty(h);
- freedqbuf(buf);
- return blk;
-}
-
-/* Put given block to free list */
-static void put_free_dqblk(struct quota_handle *h, dqbuf_t buf, uint blk)
-{
- struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf;
- struct qtree_mem_dqinfo *info = &h->qh_info.u.v2_mdqi.dqi_qtree;
-
- dh->dqdh_next_free = ext2fs_cpu_to_le32(info->dqi_free_blk);
- dh->dqdh_prev_free = ext2fs_cpu_to_le32(0);
- dh->dqdh_entries = ext2fs_cpu_to_le16(0);
- info->dqi_free_blk = blk;
- mark_quotafile_info_dirty(h);
- write_blk(h, blk, buf);
-}
-
-/* Remove given block from the list of blocks with free entries */
-static void remove_free_dqentry(struct quota_handle *h, dqbuf_t buf, uint blk)
-{
- dqbuf_t tmpbuf = getdqbuf();
- struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf;
- uint nextblk = ext2fs_le32_to_cpu(dh->dqdh_next_free), prevblk =
-
- ext2fs_le32_to_cpu(dh->dqdh_prev_free);
-
- if (!tmpbuf)
- return;
-
- if (nextblk) {
- read_blk(h, nextblk, tmpbuf);
- ((struct qt_disk_dqdbheader *)tmpbuf)->dqdh_prev_free =
- dh->dqdh_prev_free;
- write_blk(h, nextblk, tmpbuf);
- }
- if (prevblk) {
- read_blk(h, prevblk, tmpbuf);
- ((struct qt_disk_dqdbheader *)tmpbuf)->dqdh_next_free =
- dh->dqdh_next_free;
- write_blk(h, prevblk, tmpbuf);
- } else {
- h->qh_info.u.v2_mdqi.dqi_qtree.dqi_free_entry = nextblk;
- mark_quotafile_info_dirty(h);
- }
- freedqbuf(tmpbuf);
- dh->dqdh_next_free = dh->dqdh_prev_free = ext2fs_cpu_to_le32(0);
- write_blk(h, blk, buf); /* No matter whether write succeeds
- * block is out of list */
-}
-
-/* Insert given block to the beginning of list with free entries */
-static void insert_free_dqentry(struct quota_handle *h, dqbuf_t buf, uint blk)
-{
- dqbuf_t tmpbuf = getdqbuf();
- struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf;
- struct qtree_mem_dqinfo *info = &h->qh_info.u.v2_mdqi.dqi_qtree;
-
- if (!tmpbuf)
- return;
-
- dh->dqdh_next_free = ext2fs_cpu_to_le32(info->dqi_free_entry);
- dh->dqdh_prev_free = ext2fs_cpu_to_le32(0);
- write_blk(h, blk, buf);
- if (info->dqi_free_entry) {
- read_blk(h, info->dqi_free_entry, tmpbuf);
- ((struct qt_disk_dqdbheader *)tmpbuf)->dqdh_prev_free =
- ext2fs_cpu_to_le32(blk);
- write_blk(h, info->dqi_free_entry, tmpbuf);
- }
- freedqbuf(tmpbuf);
- info->dqi_free_entry = blk;
- mark_quotafile_info_dirty(h);
-}
-
-/* Find space for dquot */
-static uint find_free_dqentry(struct quota_handle *h, struct dquot *dquot,
- int *err)
-{
- int blk, i;
- struct qt_disk_dqdbheader *dh;
- struct qtree_mem_dqinfo *info = &h->qh_info.u.v2_mdqi.dqi_qtree;
- char *ddquot;
- dqbuf_t buf;
-
- *err = 0;
- buf = getdqbuf();
- if (!buf) {
- *err = -ENOMEM;
- return 0;
- }
-
- dh = (struct qt_disk_dqdbheader *)buf;
- if (info->dqi_free_entry) {
- blk = info->dqi_free_entry;
- read_blk(h, blk, buf);
- } else {
- blk = get_free_dqblk(h);
- if (blk < 0) {
- freedqbuf(buf);
- *err = blk;
- return 0;
- }
- memset(buf, 0, QT_BLKSIZE);
- info->dqi_free_entry = blk;
- mark_quotafile_info_dirty(h);
- }
-
- /* Block will be full? */
- if (ext2fs_le16_to_cpu(dh->dqdh_entries) + 1 >=
- qtree_dqstr_in_blk(info))
- remove_free_dqentry(h, buf, blk);
-
- dh->dqdh_entries =
- ext2fs_cpu_to_le16(ext2fs_le16_to_cpu(dh->dqdh_entries) + 1);
- /* Find free structure in block */
- ddquot = buf + sizeof(struct qt_disk_dqdbheader);
- for (i = 0;
- i < qtree_dqstr_in_blk(info) && !qtree_entry_unused(info, ddquot);
- i++)
- ddquot += info->dqi_entry_size;
-
- if (i == qtree_dqstr_in_blk(info))
- log_err("find_free_dqentry(): Data block full unexpectedly.");
-
- write_blk(h, blk, buf);
- dquot->dq_dqb.u.v2_mdqb.dqb_off =
- (blk << QT_BLKSIZE_BITS) + sizeof(struct qt_disk_dqdbheader) +
- i * info->dqi_entry_size;
- freedqbuf(buf);
- return blk;
-}
-
-/* Insert reference to structure into the trie */
-static int do_insert_tree(struct quota_handle *h, struct dquot *dquot,
- uint * treeblk, int depth)
-{
- dqbuf_t buf;
- int newson = 0, newact = 0;
- u_int32_t *ref;
- uint newblk;
- int ret = 0;
-
- log_debug("inserting in tree: treeblk=%u, depth=%d", *treeblk, depth);
- buf = getdqbuf();
- if (!buf)
- return -ENOMEM;
-
- if (!*treeblk) {
- ret = get_free_dqblk(h);
- if (ret < 0)
- goto out_buf;
- *treeblk = ret;
- memset(buf, 0, QT_BLKSIZE);
- newact = 1;
- } else {
- read_blk(h, *treeblk, buf);
- }
-
- ref = (u_int32_t *) buf;
- newblk = ext2fs_le32_to_cpu(ref[get_index(dquot->dq_id, depth)]);
- if (!newblk)
- newson = 1;
- if (depth == QT_TREEDEPTH - 1) {
- if (newblk)
- log_err("Inserting already present quota entry "
- "(block %u).",
- ref[get_index(dquot->dq_id, depth)]);
- newblk = find_free_dqentry(h, dquot, &ret);
- } else {
- ret = do_insert_tree(h, dquot, &newblk, depth + 1);
- }
-
- if (newson && ret >= 0) {
- ref[get_index(dquot->dq_id, depth)] =
- ext2fs_cpu_to_le32(newblk);
- write_blk(h, *treeblk, buf);
- } else if (newact && ret < 0) {
- put_free_dqblk(h, buf, *treeblk);
- }
-
-out_buf:
- freedqbuf(buf);
- return ret;
-}
-
-/* Wrapper for inserting quota structure into tree */
-static void dq_insert_tree(struct quota_handle *h, struct dquot *dquot)
-{
- uint tmp = QT_TREEOFF;
-
- if (do_insert_tree(h, dquot, &tmp, 0) < 0)
- log_err("Cannot write quota (id %u): %s",
- (uint) dquot->dq_id, strerror(errno));
-}
-
-/* Write dquot to file */
-void qtree_write_dquot(struct dquot *dquot)
-{
- ssize_t ret;
- char *ddquot;
- struct quota_handle *h = dquot->dq_h;
- struct qtree_mem_dqinfo *info =
- &dquot->dq_h->qh_info.u.v2_mdqi.dqi_qtree;
- log_debug("writing ddquot 1: off=%llu, info->dqi_entry_size=%u",
- dquot->dq_dqb.u.v2_mdqb.dqb_off,
- info->dqi_entry_size);
- ret = ext2fs_get_mem(info->dqi_entry_size, &ddquot);
- if (ret) {
- errno = ENOMEM;
- log_err("Quota write failed (id %u): %s",
- (uint)dquot->dq_id, strerror(errno));
- return;
- }
-
- if (!dquot->dq_dqb.u.v2_mdqb.dqb_off)
- dq_insert_tree(dquot->dq_h, dquot);
- info->dqi_ops->mem2disk_dqblk(ddquot, dquot);
- log_debug("writing ddquot 2: off=%llu, info->dqi_entry_size=%u",
- dquot->dq_dqb.u.v2_mdqb.dqb_off,
- info->dqi_entry_size);
- ret = h->e2fs_write(&h->qh_qf, dquot->dq_dqb.u.v2_mdqb.dqb_off, ddquot,
- info->dqi_entry_size);
-
- if (ret != info->dqi_entry_size) {
- if (ret > 0)
- errno = ENOSPC;
- log_err("Quota write failed (id %u): %s",
- (uint)dquot->dq_id, strerror(errno));
- }
- ext2fs_free_mem(&ddquot);
-}
-
-/* Free dquot entry in data block */
-static void free_dqentry(struct quota_handle *h, struct dquot *dquot, uint blk)
-{
- struct qt_disk_dqdbheader *dh;
- struct qtree_mem_dqinfo *info = &h->qh_info.u.v2_mdqi.dqi_qtree;
- dqbuf_t buf = getdqbuf();
-
- if (!buf)
- return;
-
- if (dquot->dq_dqb.u.v2_mdqb.dqb_off >> QT_BLKSIZE_BITS != blk)
- log_err("Quota structure has offset to other block (%u) "
- "than it should (%u).", blk,
- (uint) (dquot->dq_dqb.u.v2_mdqb.dqb_off >>
- QT_BLKSIZE_BITS));
-
- read_blk(h, blk, buf);
- dh = (struct qt_disk_dqdbheader *)buf;
- dh->dqdh_entries =
- ext2fs_cpu_to_le16(ext2fs_le16_to_cpu(dh->dqdh_entries) - 1);
-
- if (!ext2fs_le16_to_cpu(dh->dqdh_entries)) { /* Block got free? */
- remove_free_dqentry(h, buf, blk);
- put_free_dqblk(h, buf, blk);
- } else {
- memset(buf + (dquot->dq_dqb.u.v2_mdqb.dqb_off &
- ((1 << QT_BLKSIZE_BITS) - 1)),
- 0, info->dqi_entry_size);
-
- /* First free entry? */
- if (ext2fs_le16_to_cpu(dh->dqdh_entries) ==
- qtree_dqstr_in_blk(info) - 1)
- /* This will also write data block */
- insert_free_dqentry(h, buf, blk);
- else
- write_blk(h, blk, buf);
- }
- dquot->dq_dqb.u.v2_mdqb.dqb_off = 0;
- freedqbuf(buf);
-}
-
-/* Remove reference to dquot from tree */
-static void remove_tree(struct quota_handle *h, struct dquot *dquot,
- uint * blk, int depth)
-{
- dqbuf_t buf = getdqbuf();
- uint newblk;
- u_int32_t *ref = (u_int32_t *) buf;
-
- if (!buf)
- return;
-
- read_blk(h, *blk, buf);
- newblk = ext2fs_le32_to_cpu(ref[get_index(dquot->dq_id, depth)]);
- if (depth == QT_TREEDEPTH - 1) {
- free_dqentry(h, dquot, newblk);
- newblk = 0;
- } else {
- remove_tree(h, dquot, &newblk, depth + 1);
- }
-
- if (!newblk) {
- int i;
-
- ref[get_index(dquot->dq_id, depth)] = ext2fs_cpu_to_le32(0);
-
- /* Block got empty? */
- for (i = 0; i < QT_BLKSIZE && !buf[i]; i++);
-
- /* Don't put the root block into the free block list */
- if (i == QT_BLKSIZE && *blk != QT_TREEOFF) {
- put_free_dqblk(h, buf, *blk);
- *blk = 0;
- } else {
- write_blk(h, *blk, buf);
- }
- }
- freedqbuf(buf);
-}
-
-/* Delete dquot from tree */
-void qtree_delete_dquot(struct dquot *dquot)
-{
- uint tmp = QT_TREEOFF;
-
- if (!dquot->dq_dqb.u.v2_mdqb.dqb_off) /* Even not allocated? */
- return;
- remove_tree(dquot->dq_h, dquot, &tmp, 0);
-}
-
-/* Find entry in block */
-static ext2_loff_t find_block_dqentry(struct quota_handle *h,
- struct dquot *dquot, uint blk)
-{
- struct qtree_mem_dqinfo *info = &h->qh_info.u.v2_mdqi.dqi_qtree;
- dqbuf_t buf = getdqbuf();
- int i;
- char *ddquot = buf + sizeof(struct qt_disk_dqdbheader);
-
- if (!buf)
- return -ENOMEM;
-
- read_blk(h, blk, buf);
- for (i = 0;
- i < qtree_dqstr_in_blk(info) && !info->dqi_ops->is_id(ddquot, dquot);
- i++)
- ddquot += info->dqi_entry_size;
-
- if (i == qtree_dqstr_in_blk(info))
- log_err("Quota for id %u referenced but not present.",
- dquot->dq_id);
- freedqbuf(buf);
- return (blk << QT_BLKSIZE_BITS) + sizeof(struct qt_disk_dqdbheader) +
- i * info->dqi_entry_size;
-}
-
-/* Find entry for given id in the tree */
-static ext2_loff_t find_tree_dqentry(struct quota_handle *h,
- struct dquot *dquot,
- uint blk, int depth)
-{
- dqbuf_t buf = getdqbuf();
- ext2_loff_t ret = 0;
- u_int32_t *ref = (u_int32_t *) buf;
-
- if (!buf)
- return -ENOMEM;
-
- read_blk(h, blk, buf);
- ret = 0;
- blk = ext2fs_le32_to_cpu(ref[get_index(dquot->dq_id, depth)]);
- if (!blk) /* No reference? */
- goto out_buf;
- if (depth < QT_TREEDEPTH - 1)
- ret = find_tree_dqentry(h, dquot, blk, depth + 1);
- else
- ret = find_block_dqentry(h, dquot, blk);
-out_buf:
- freedqbuf(buf);
- return ret;
-}
-
-/* Find entry for given id in the tree - wrapper function */
-static inline ext2_loff_t find_dqentry(struct quota_handle *h,
- struct dquot *dquot)
-{
- return find_tree_dqentry(h, dquot, QT_TREEOFF, 0);
-}
-
-/*
- * Read dquot from disk.
- */
-struct dquot *qtree_read_dquot(struct quota_handle *h, qid_t id)
-{
- struct qtree_mem_dqinfo *info = &h->qh_info.u.v2_mdqi.dqi_qtree;
- ext2_loff_t offset;
- ssize_t ret;
- char *ddquot;
- struct dquot *dquot = get_empty_dquot();
-
- if (!dquot)
- return NULL;
- if (ext2fs_get_mem(info->dqi_entry_size, &ddquot)) {
- ext2fs_free_mem(&dquot);
- return NULL;
- }
-
- dquot->dq_id = id;
- dquot->dq_h = h;
- dquot->dq_dqb.u.v2_mdqb.dqb_off = 0;
- memset(&dquot->dq_dqb, 0, sizeof(struct util_dqblk));
-
- offset = find_dqentry(h, dquot);
- if (offset > 0) {
- dquot->dq_dqb.u.v2_mdqb.dqb_off = offset;
- ret = h->e2fs_read(&h->qh_qf, offset, ddquot,
- info->dqi_entry_size);
- if (ret != info->dqi_entry_size) {
- if (ret > 0)
- errno = EIO;
- log_err("Cannot read quota structure for id %u: %s",
- dquot->dq_id, strerror(errno));
- }
- info->dqi_ops->disk2mem_dqblk(dquot, ddquot);
- }
- ext2fs_free_mem(&ddquot);
- return dquot;
-}
-
-/*
- * Scan all dquots in file and call callback on each
- */
-#define set_bit(bmp, ind) ((bmp)[(ind) >> 3] |= (1 << ((ind) & 7)))
-#define get_bit(bmp, ind) ((bmp)[(ind) >> 3] & (1 << ((ind) & 7)))
-
-static int report_block(struct dquot *dquot, uint blk, char *bitmap,
- int (*process_dquot) (struct dquot *, void *),
- void *data)
-{
- struct qtree_mem_dqinfo *info =
- &dquot->dq_h->qh_info.u.v2_mdqi.dqi_qtree;
- dqbuf_t buf = getdqbuf();
- struct qt_disk_dqdbheader *dh;
- char *ddata;
- int entries, i;
-
- if (!buf)
- return 0;
-
- set_bit(bitmap, blk);
- read_blk(dquot->dq_h, blk, buf);
- dh = (struct qt_disk_dqdbheader *)buf;
- ddata = buf + sizeof(struct qt_disk_dqdbheader);
- entries = ext2fs_le16_to_cpu(dh->dqdh_entries);
- for (i = 0; i < qtree_dqstr_in_blk(info);
- i++, ddata += info->dqi_entry_size)
- if (!qtree_entry_unused(info, ddata)) {
- dquot->dq_dqb.u.v2_mdqb.dqb_off =
- (blk << QT_BLKSIZE_BITS) +
- sizeof(struct qt_disk_dqdbheader) +
- i * info->dqi_entry_size;
- info->dqi_ops->disk2mem_dqblk(dquot, ddata);
- if (process_dquot(dquot, data) < 0)
- break;
- }
- freedqbuf(buf);
- return entries;
-}
-
-static void check_reference(struct quota_handle *h, uint blk)
-{
- if (blk >= h->qh_info.u.v2_mdqi.dqi_qtree.dqi_blocks)
- log_err("Illegal reference (%u >= %u) in %s quota file. "
- "Quota file is probably corrupted.\n"
- "Please run e2fsck (8) to fix it.",
- blk,
- h->qh_info.u.v2_mdqi.dqi_qtree.dqi_blocks,
- type2name(h->qh_type));
-}
-
-static int report_tree(struct dquot *dquot, uint blk, int depth, char *bitmap,
- int (*process_dquot) (struct dquot *, void *),
- void *data)
-{
- int entries = 0, i;
- dqbuf_t buf = getdqbuf();
- u_int32_t *ref = (u_int32_t *) buf;
-
- if (!buf)
- return 0;
-
- read_blk(dquot->dq_h, blk, buf);
- if (depth == QT_TREEDEPTH - 1) {
- for (i = 0; i < QT_BLKSIZE >> 2; i++) {
- blk = ext2fs_le32_to_cpu(ref[i]);
- check_reference(dquot->dq_h, blk);
- if (blk && !get_bit(bitmap, blk))
- entries += report_block(dquot, blk, bitmap,
- process_dquot, data);
- }
- } else {
- for (i = 0; i < QT_BLKSIZE >> 2; i++) {
- blk = ext2fs_le32_to_cpu(ref[i]);
- if (blk) {
- check_reference(dquot->dq_h, blk);
- entries += report_tree(dquot, blk, depth + 1,
- bitmap, process_dquot,
- data);
- }
- }
- }
- freedqbuf(buf);
- return entries;
-}
-
-static uint find_set_bits(char *bmp, int blocks)
-{
- uint i, used = 0;
-
- for (i = 0; i < blocks; i++)
- if (get_bit(bmp, i))
- used++;
- return used;
-}
-
-int qtree_scan_dquots(struct quota_handle *h,
- int (*process_dquot) (struct dquot *, void *),
- void *data)
-{
- char *bitmap;
- struct v2_mem_dqinfo *v2info = &h->qh_info.u.v2_mdqi;
- struct qtree_mem_dqinfo *info = &v2info->dqi_qtree;
- struct dquot *dquot = get_empty_dquot();
-
- if (!dquot)
- return -1;
-
- dquot->dq_h = h;
- if (ext2fs_get_memzero((info->dqi_blocks + 7) >> 3, &bitmap)) {
- ext2fs_free_mem(&dquot);
- return -1;
- }
- v2info->dqi_used_entries = report_tree(dquot, QT_TREEOFF, 0, bitmap,
- process_dquot, data);
- v2info->dqi_data_blocks = find_set_bits(bitmap, info->dqi_blocks);
- ext2fs_free_mem(&bitmap);
- ext2fs_free_mem(&dquot);
- return 0;
-}
diff --git a/lib/quota/quotaio_tree.h b/lib/quota/quotaio_tree.h
deleted file mode 100644
index 6ee54c99..00000000
--- a/lib/quota/quotaio_tree.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Definitions of structures for vfsv0 quota format
- */
-
-#ifndef _LINUX_QUOTA_TREE_H
-#define _LINUX_QUOTA_TREE_H
-
-#include <sys/types.h>
-
-typedef u_int32_t qid_t; /* Type in which we store ids in memory */
-
-#define QT_TREEOFF 1 /* Offset of tree in file in blocks */
-#define QT_TREEDEPTH 4 /* Depth of quota tree */
-#define QT_BLKSIZE_BITS 10
-#define QT_BLKSIZE (1 << QT_BLKSIZE_BITS) /* Size of block with quota
- * structures */
-
-/*
- * Structure of header of block with quota structures. It is padded to 16 bytes
- * so there will be space for exactly 21 quota-entries in a block
- */
-struct qt_disk_dqdbheader {
- u_int32_t dqdh_next_free; /* Number of next block with free
- * entry */
- u_int32_t dqdh_prev_free; /* Number of previous block with free
- * entry */
- u_int16_t dqdh_entries; /* Number of valid entries in block */
- u_int16_t dqdh_pad1;
- u_int32_t dqdh_pad2;
-} __attribute__ ((packed));
-
-struct dquot;
-struct quota_handle;
-
-/* Operations */
-struct qtree_fmt_operations {
- /* Convert given entry from in memory format to disk one */
- void (*mem2disk_dqblk)(void *disk, struct dquot *dquot);
- /* Convert given entry from disk format to in memory one */
- void (*disk2mem_dqblk)(struct dquot *dquot, void *disk);
- /* Is this structure for given id? */
- int (*is_id)(void *disk, struct dquot *dquot);
-};
-
-/* Inmemory copy of version specific information */
-struct qtree_mem_dqinfo {
- unsigned int dqi_blocks; /* # of blocks in quota file */
- unsigned int dqi_free_blk; /* First block in list of free blocks */
- unsigned int dqi_free_entry; /* First block with free entry */
- unsigned int dqi_entry_size; /* Size of quota entry in quota file */
- struct qtree_fmt_operations *dqi_ops; /* Operations for entry
- * manipulation */
-};
-
-void qtree_write_dquot(struct dquot *dquot);
-struct dquot *qtree_read_dquot(struct quota_handle *h, qid_t id);
-void qtree_delete_dquot(struct dquot *dquot);
-int qtree_entry_unused(struct qtree_mem_dqinfo *info, char *disk);
-int qtree_scan_dquots(struct quota_handle *h,
- int (*process_dquot) (struct dquot *, void *), void *data);
-
-int qtree_dqstr_in_blk(struct qtree_mem_dqinfo *info);
-
-#endif /* _LINUX_QUOTAIO_TREE_H */
diff --git a/lib/quota/quotaio_v2.c b/lib/quota/quotaio_v2.c
deleted file mode 100644
index de53e7d4..00000000
--- a/lib/quota/quotaio_v2.c
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * Implementation of new quotafile format
- *
- * Jan Kara <jack@suse.cz> - sponsored by SuSE CR
- */
-
-#include <sys/types.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "common.h"
-#include "quotaio_v2.h"
-#include "dqblk_v2.h"
-#include "quotaio.h"
-#include "quotaio_tree.h"
-
-static int v2_check_file(struct quota_handle *h, int type, int fmt);
-static int v2_init_io(struct quota_handle *h);
-static int v2_new_io(struct quota_handle *h);
-static int v2_write_info(struct quota_handle *h);
-static struct dquot *v2_read_dquot(struct quota_handle *h, qid_t id);
-static int v2_commit_dquot(struct dquot *dquot);
-static int v2_scan_dquots(struct quota_handle *h,
- int (*process_dquot) (struct dquot *dquot,
- void *data),
- void *data);
-static int v2_report(struct quota_handle *h, int verbose);
-
-struct quotafile_ops quotafile_ops_2 = {
- .check_file = v2_check_file,
- .init_io = v2_init_io,
- .new_io = v2_new_io,
- .write_info = v2_write_info,
- .read_dquot = v2_read_dquot,
- .commit_dquot = v2_commit_dquot,
- .scan_dquots = v2_scan_dquots,
- .report = v2_report,
-};
-
-/*
- * Copy dquot from disk to memory
- */
-static void v2r1_disk2memdqblk(struct dquot *dquot, void *dp)
-{
- struct util_dqblk *m = &dquot->dq_dqb;
- struct v2r1_disk_dqblk *d = dp, empty;
-
- dquot->dq_id = ext2fs_le32_to_cpu(d->dqb_id);
- m->dqb_ihardlimit = ext2fs_le64_to_cpu(d->dqb_ihardlimit);
- m->dqb_isoftlimit = ext2fs_le64_to_cpu(d->dqb_isoftlimit);
- m->dqb_bhardlimit = ext2fs_le64_to_cpu(d->dqb_bhardlimit);
- m->dqb_bsoftlimit = ext2fs_le64_to_cpu(d->dqb_bsoftlimit);
- m->dqb_curinodes = ext2fs_le64_to_cpu(d->dqb_curinodes);
- m->dqb_curspace = ext2fs_le64_to_cpu(d->dqb_curspace);
- m->dqb_itime = ext2fs_le64_to_cpu(d->dqb_itime);
- m->dqb_btime = ext2fs_le64_to_cpu(d->dqb_btime);
-
- memset(&empty, 0, sizeof(struct v2r1_disk_dqblk));
- empty.dqb_itime = ext2fs_cpu_to_le64(1);
- if (!memcmp(&empty, dp, sizeof(struct v2r1_disk_dqblk)))
- m->dqb_itime = 0;
-}
-
-/*
- * Copy dquot from memory to disk
- */
-static void v2r1_mem2diskdqblk(void *dp, struct dquot *dquot)
-{
- struct util_dqblk *m = &dquot->dq_dqb;
- struct v2r1_disk_dqblk *d = dp;
-
- d->dqb_ihardlimit = ext2fs_cpu_to_le64(m->dqb_ihardlimit);
- d->dqb_isoftlimit = ext2fs_cpu_to_le64(m->dqb_isoftlimit);
- d->dqb_bhardlimit = ext2fs_cpu_to_le64(m->dqb_bhardlimit);
- d->dqb_bsoftlimit = ext2fs_cpu_to_le64(m->dqb_bsoftlimit);
- d->dqb_curinodes = ext2fs_cpu_to_le64(m->dqb_curinodes);
- d->dqb_curspace = ext2fs_cpu_to_le64(m->dqb_curspace);
- d->dqb_itime = ext2fs_cpu_to_le64(m->dqb_itime);
- d->dqb_btime = ext2fs_cpu_to_le64(m->dqb_btime);
- d->dqb_id = ext2fs_cpu_to_le32(dquot->dq_id);
- if (qtree_entry_unused(&dquot->dq_h->qh_info.u.v2_mdqi.dqi_qtree, dp))
- d->dqb_itime = ext2fs_cpu_to_le64(1);
-}
-
-static int v2r1_is_id(void *dp, struct dquot *dquot)
-{
- struct v2r1_disk_dqblk *d = dp;
- struct qtree_mem_dqinfo *info =
- &dquot->dq_h->qh_info.u.v2_mdqi.dqi_qtree;
-
- if (qtree_entry_unused(info, dp))
- return 0;
- return ext2fs_le32_to_cpu(d->dqb_id) == dquot->dq_id;
-}
-
-static struct qtree_fmt_operations v2r1_fmt_ops = {
- .mem2disk_dqblk = v2r1_mem2diskdqblk,
- .disk2mem_dqblk = v2r1_disk2memdqblk,
- .is_id = v2r1_is_id,
-};
-
-/*
- * Copy dqinfo from disk to memory
- */
-static inline void v2_disk2memdqinfo(struct util_dqinfo *m,
- struct v2_disk_dqinfo *d)
-{
- m->dqi_bgrace = ext2fs_le32_to_cpu(d->dqi_bgrace);
- m->dqi_igrace = ext2fs_le32_to_cpu(d->dqi_igrace);
- m->u.v2_mdqi.dqi_flags = ext2fs_le32_to_cpu(d->dqi_flags) & V2_DQF_MASK;
- m->u.v2_mdqi.dqi_qtree.dqi_blocks = ext2fs_le32_to_cpu(d->dqi_blocks);
- m->u.v2_mdqi.dqi_qtree.dqi_free_blk =
- ext2fs_le32_to_cpu(d->dqi_free_blk);
- m->u.v2_mdqi.dqi_qtree.dqi_free_entry =
- ext2fs_le32_to_cpu(d->dqi_free_entry);
-}
-
-/*
- * Copy dqinfo from memory to disk
- */
-static inline void v2_mem2diskdqinfo(struct v2_disk_dqinfo *d,
- struct util_dqinfo *m)
-{
- d->dqi_bgrace = ext2fs_cpu_to_le32(m->dqi_bgrace);
- d->dqi_igrace = ext2fs_cpu_to_le32(m->dqi_igrace);
- d->dqi_flags = ext2fs_cpu_to_le32(m->u.v2_mdqi.dqi_flags & V2_DQF_MASK);
- d->dqi_blocks = ext2fs_cpu_to_le32(m->u.v2_mdqi.dqi_qtree.dqi_blocks);
- d->dqi_free_blk =
- ext2fs_cpu_to_le32(m->u.v2_mdqi.dqi_qtree.dqi_free_blk);
- d->dqi_free_entry =
- ext2fs_cpu_to_le32(m->u.v2_mdqi.dqi_qtree.dqi_free_entry);
-}
-
-static int v2_read_header(struct quota_handle *h, struct v2_disk_dqheader *dqh)
-{
- if (h->e2fs_read(&h->qh_qf, 0, dqh, sizeof(struct v2_disk_dqheader)) !=
- sizeof(struct v2_disk_dqheader))
- return 0;
-
- return 1;
-}
-
-/*
- * Check whether given quota file is in our format
- */
-static int v2_check_file(struct quota_handle *h, int type, int fmt)
-{
- struct v2_disk_dqheader dqh;
- int file_magics[] = INITQMAGICS;
-
- if (fmt != QFMT_VFS_V1)
- return 0;
-
- if (!v2_read_header(h, &dqh))
- return 0;
-
- if (ext2fs_le32_to_cpu(dqh.dqh_magic) != file_magics[type]) {
- if (ext2fs_be32_to_cpu(dqh.dqh_magic) == file_magics[type])
- log_err("Your quota file is stored in wrong endianity");
- return 0;
- }
- if (V2_VERSION != ext2fs_le32_to_cpu(dqh.dqh_version))
- return 0;
- return 1;
-}
-
-/*
- * Open quotafile
- */
-static int v2_init_io(struct quota_handle *h)
-{
- struct v2_disk_dqinfo ddqinfo;
-
- h->qh_info.u.v2_mdqi.dqi_qtree.dqi_entry_size =
- sizeof(struct v2r1_disk_dqblk);
- h->qh_info.u.v2_mdqi.dqi_qtree.dqi_ops = &v2r1_fmt_ops;
-
- /* Read information about quotafile */
- if (h->e2fs_read(&h->qh_qf, V2_DQINFOOFF, &ddqinfo,
- sizeof(ddqinfo)) != sizeof(ddqinfo))
- return -1;
- v2_disk2memdqinfo(&h->qh_info, &ddqinfo);
- return 0;
-}
-
-/*
- * Initialize new quotafile
- */
-static int v2_new_io(struct quota_handle *h)
-{
- int file_magics[] = INITQMAGICS;
- struct v2_disk_dqheader ddqheader;
- struct v2_disk_dqinfo ddqinfo;
-
- if (h->qh_fmt != QFMT_VFS_V1)
- return -1;
-
- /* Write basic quota header */
- ddqheader.dqh_magic = ext2fs_cpu_to_le32(file_magics[h->qh_type]);
- ddqheader.dqh_version = ext2fs_cpu_to_le32(V2_VERSION);
- if (h->e2fs_write(&h->qh_qf, 0, &ddqheader, sizeof(ddqheader)) !=
- sizeof(ddqheader))
- return -1;
-
- /* Write information about quotafile */
- h->qh_info.dqi_bgrace = MAX_DQ_TIME;
- h->qh_info.dqi_igrace = MAX_IQ_TIME;
- h->qh_info.u.v2_mdqi.dqi_flags = 0;
- h->qh_info.u.v2_mdqi.dqi_qtree.dqi_blocks = QT_TREEOFF + 1;
- h->qh_info.u.v2_mdqi.dqi_qtree.dqi_free_blk = 0;
- h->qh_info.u.v2_mdqi.dqi_qtree.dqi_free_entry = 0;
- h->qh_info.u.v2_mdqi.dqi_qtree.dqi_entry_size =
- sizeof(struct v2r1_disk_dqblk);
- h->qh_info.u.v2_mdqi.dqi_qtree.dqi_ops = &v2r1_fmt_ops;
- v2_mem2diskdqinfo(&ddqinfo, &h->qh_info);
- if (h->e2fs_write(&h->qh_qf, V2_DQINFOOFF, &ddqinfo,
- sizeof(ddqinfo)) !=
- sizeof(ddqinfo))
- return -1;
-
- return 0;
-}
-
-/*
- * Write information (grace times to file)
- */
-static int v2_write_info(struct quota_handle *h)
-{
- struct v2_disk_dqinfo ddqinfo;
-
- v2_mem2diskdqinfo(&ddqinfo, &h->qh_info);
- if (h->e2fs_write(&h->qh_qf, V2_DQINFOOFF, &ddqinfo, sizeof(ddqinfo)) !=
- sizeof(ddqinfo))
- return -1;
-
- return 0;
-}
-
-/*
- * Read dquot from disk
- */
-static struct dquot *v2_read_dquot(struct quota_handle *h, qid_t id)
-{
- return qtree_read_dquot(h, id);
-}
-
-/*
- * Commit changes of dquot to disk - it might also mean deleting it when quota
- * became fake one and user has no blocks.
- * User can process use 'errno' to detect errstr.
- */
-static int v2_commit_dquot(struct dquot *dquot)
-{
- struct util_dqblk *b = &dquot->dq_dqb;
-
- if (!b->dqb_curspace && !b->dqb_curinodes && !b->dqb_bsoftlimit &&
- !b->dqb_isoftlimit && !b->dqb_bhardlimit && !b->dqb_ihardlimit)
- qtree_delete_dquot(dquot);
- else
- qtree_write_dquot(dquot);
- return 0;
-}
-
-static int v2_scan_dquots(struct quota_handle *h,
- int (*process_dquot) (struct dquot *, void *),
- void *data)
-{
- return qtree_scan_dquots(h, process_dquot, data);
-}
-
-/* Report information about quotafile.
- * TODO: Not used right now, but we should be able to use this when we add
- * support to debugfs to read quota files.
- */
-static int v2_report(struct quota_handle *h, int verbose)
-{
- log_err("Not Implemented.");
- return -1;
-}
diff --git a/lib/quota/quotaio_v2.h b/lib/quota/quotaio_v2.h
deleted file mode 100644
index 0bb4363e..00000000
--- a/lib/quota/quotaio_v2.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- *
- * Header file for disk format of new quotafile format
- *
- */
-
-#ifndef GUARD_QUOTAIO_V2_H
-#define GUARD_QUOTAIO_V2_H
-
-#include <sys/types.h>
-#include "quotaio.h"
-
-/* Offset of info header in file */
-#define V2_DQINFOOFF sizeof(struct v2_disk_dqheader)
-/* Supported version of quota-tree format */
-#define V2_VERSION 1
-
-struct v2_disk_dqheader {
- u_int32_t dqh_magic; /* Magic number identifying file */
- u_int32_t dqh_version; /* File version */
-} __attribute__ ((packed));
-
-/* Flags for version specific files */
-#define V2_DQF_MASK 0x0000 /* Mask for all valid ondisk flags */
-
-/* Header with type and version specific information */
-struct v2_disk_dqinfo {
- u_int32_t dqi_bgrace; /* Time before block soft limit becomes
- * hard limit */
- u_int32_t dqi_igrace; /* Time before inode soft limit becomes
- * hard limit */
- u_int32_t dqi_flags; /* Flags for quotafile (DQF_*) */
- u_int32_t dqi_blocks; /* Number of blocks in file */
- u_int32_t dqi_free_blk; /* Number of first free block in the list */
- u_int32_t dqi_free_entry; /* Number of block with at least one
- * free entry */
-} __attribute__ ((packed));
-
-struct v2r1_disk_dqblk {
- u_int32_t dqb_id; /* id this quota applies to */
- u_int32_t dqb_pad;
- u_int64_t dqb_ihardlimit; /* absolute limit on allocated inodes */
- u_int64_t dqb_isoftlimit; /* preferred inode limit */
- u_int64_t dqb_curinodes; /* current # allocated inodes */
- u_int64_t dqb_bhardlimit; /* absolute limit on disk space
- * (in QUOTABLOCK_SIZE) */
- u_int64_t dqb_bsoftlimit; /* preferred limit on disk space
- * (in QUOTABLOCK_SIZE) */
- u_int64_t dqb_curspace; /* current space occupied (in bytes) */
- u_int64_t dqb_btime; /* time limit for excessive disk use */
- u_int64_t dqb_itime; /* time limit for excessive inode use */
-} __attribute__ ((packed));
-
-#endif
diff --git a/lib/ss/MODULE_LICENSE_MIT b/lib/ss/MODULE_LICENSE_MIT
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/lib/ss/MODULE_LICENSE_MIT
diff --git a/lib/ss/Makefile.in b/lib/ss/Makefile.in
index 1b23b38d..4a2bdb1b 100644
--- a/lib/ss/Makefile.in
+++ b/lib/ss/Makefile.in
@@ -20,7 +20,7 @@ ELF_SO_VERSION = 2
ELF_IMAGE = libss
ELF_MYDIR = ss
ELF_INSTALL_DIR = $(root_libdir)
-ELF_OTHER_LIBS = -lcom_err $(DLOPEN_LIB)
+ELF_OTHER_LIBS = -L../.. -lcom_err $(DLOPEN_LIB)
BSDLIB_VERSION = 1.0
BSDLIB_IMAGE = libss
@@ -31,10 +31,14 @@ TAGS=etags
COMPILE_ET=../et/compile_et --build-tree
MK_CMDS=_SS_DIR_OVERRIDE=. ./mk_cmds
+# -I.. is so that ss/ss_err.h works
+# -I$(srcdir)/.. is so that ss/ss.h works
+# -I$(srcdir)/../et is so com_err.h works
+XTRA_CFLAGS= -I$(srcdir)/../et
+
.c.o:
$(E) " CC $<"
$(Q) $(CC) $(ALL_CFLAGS) -c $<
- $(Q) $(CHECK_CMD) $(ALL_CFLAGS) $<
@PROFILE_CMT@ $(Q) $(CC) $(ALL_CFLAGS) -g -pg -o profiled/$*.o -c $<
@CHECKER_CMT@ $(Q) $(CC) $(ALL_CFLAGS) -checker -g -o checker/$*.o -c $<
@ELF_CMT@ $(Q) $(CC) $(ALL_CFLAGS) -DSHARED_ELF_LIB -fPIC -o elfshared/$*.o -c $<
@@ -192,42 +196,31 @@ $(OBJS): subdirs
# Makefile dependencies follow. This must be the last section in
# the Makefile.in file
#
-invocation.o: $(srcdir)/invocation.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ss_internal.h $(srcdir)/ss.h \
- $(top_builddir)/lib/ss/ss_err.h $(top_srcdir)/lib/et/com_err.h
-help.o: $(srcdir)/help.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ss_internal.h $(srcdir)/ss.h \
+invocation.o: $(srcdir)/invocation.c $(srcdir)/ss_internal.h $(srcdir)/ss.h \
$(top_builddir)/lib/ss/ss_err.h $(top_srcdir)/lib/et/com_err.h
-execute_cmd.o: $(srcdir)/execute_cmd.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ss_internal.h $(srcdir)/ss.h \
+help.o: $(srcdir)/help.c $(srcdir)/ss_internal.h $(srcdir)/ss.h \
$(top_builddir)/lib/ss/ss_err.h $(top_srcdir)/lib/et/com_err.h
-listen.o: $(srcdir)/listen.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ss_internal.h $(srcdir)/ss.h \
+execute_cmd.o: $(srcdir)/execute_cmd.c $(srcdir)/ss_internal.h $(srcdir)/ss.h \
$(top_builddir)/lib/ss/ss_err.h $(top_srcdir)/lib/et/com_err.h
-parse.o: $(srcdir)/parse.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ss_internal.h $(srcdir)/ss.h \
+listen.o: $(srcdir)/listen.c $(srcdir)/ss_internal.h $(srcdir)/ss.h \
$(top_builddir)/lib/ss/ss_err.h $(top_srcdir)/lib/et/com_err.h
-error.o: $(srcdir)/error.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(top_srcdir)/lib/et/com_err.h \
- $(srcdir)/ss_internal.h $(srcdir)/ss.h $(top_builddir)/lib/ss/ss_err.h
-prompt.o: $(srcdir)/prompt.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ss_internal.h $(srcdir)/ss.h \
+parse.o: $(srcdir)/parse.c $(srcdir)/ss_internal.h $(srcdir)/ss.h \
$(top_builddir)/lib/ss/ss_err.h $(top_srcdir)/lib/et/com_err.h
-request_tbl.o: $(srcdir)/request_tbl.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ss_internal.h $(srcdir)/ss.h \
+error.o: $(srcdir)/error.c $(top_srcdir)/lib/et/com_err.h \
+ $(srcdir)/ss_internal.h $(srcdir)/ss.h $(top_builddir)/lib/ss/ss_err.h \
+ $(top_srcdir)/lib/et/com_err.h
+prompt.o: $(srcdir)/prompt.c $(srcdir)/ss_internal.h $(srcdir)/ss.h \
$(top_builddir)/lib/ss/ss_err.h $(top_srcdir)/lib/et/com_err.h
-list_rqs.o: $(srcdir)/list_rqs.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ss_internal.h $(srcdir)/ss.h \
+request_tbl.o: $(srcdir)/request_tbl.c $(srcdir)/ss_internal.h $(srcdir)/ss.h \
$(top_builddir)/lib/ss/ss_err.h $(top_srcdir)/lib/et/com_err.h
-pager.o: $(srcdir)/pager.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ss_internal.h $(srcdir)/ss.h \
+list_rqs.o: $(srcdir)/list_rqs.c $(srcdir)/ss_internal.h $(srcdir)/ss.h \
$(top_builddir)/lib/ss/ss_err.h $(top_srcdir)/lib/et/com_err.h
-requests.o: $(srcdir)/requests.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ss_internal.h $(srcdir)/ss.h \
+pager.o: $(srcdir)/pager.c $(srcdir)/ss_internal.h $(srcdir)/ss.h \
$(top_builddir)/lib/ss/ss_err.h $(top_srcdir)/lib/et/com_err.h
-data.o: $(srcdir)/data.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ss_internal.h $(srcdir)/ss.h \
+requests.o: $(srcdir)/requests.c $(srcdir)/ss_internal.h $(srcdir)/ss.h \
$(top_builddir)/lib/ss/ss_err.h $(top_srcdir)/lib/et/com_err.h
-get_readline.o: $(srcdir)/get_readline.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/ss_internal.h $(srcdir)/ss.h \
+data.o: $(srcdir)/data.c $(srcdir)/ss_internal.h $(srcdir)/ss.h \
$(top_builddir)/lib/ss/ss_err.h $(top_srcdir)/lib/et/com_err.h
+get_readline.o: $(srcdir)/get_readline.c $(srcdir)/ss_internal.h \
+ $(srcdir)/ss.h $(top_builddir)/lib/ss/ss_err.h \
+ $(top_srcdir)/lib/et/com_err.h
diff --git a/lib/ss/error.c b/lib/ss/error.c
index c7ebc4a2..9a4b5269 100644
--- a/lib/ss/error.c
+++ b/lib/ss/error.c
@@ -14,12 +14,13 @@
#include <stdio.h>
-#include "et/com_err.h"
+#include <com_err.h>
#include "ss_internal.h"
#include <stdarg.h>
-char *ss_name(int sci_idx)
+char * ss_name(sci_idx)
+ int sci_idx;
{
register char *ret_val;
register ss_data *infop;
@@ -68,7 +69,10 @@ void ss_error (int sci_idx, long code, const char * fmt, ...)
va_end(pvar);
}
-void ss_perror(int sci_idx, long code, char const *msg) /* for compatibility */
+void ss_perror (sci_idx, code, msg) /* for compatibility */
+ int sci_idx;
+ long code;
+ char const *msg;
{
ss_error (sci_idx, code, "%s", msg);
}
diff --git a/lib/ss/execute_cmd.c b/lib/ss/execute_cmd.c
index 02dfbfde..bc2a2046 100644
--- a/lib/ss/execute_cmd.c
+++ b/lib/ss/execute_cmd.c
@@ -81,8 +81,11 @@ static struct _ss_request_entry * get_request (tbl, idx)
* Notes:
*/
-static int check_request_table(register ss_request_table *rqtbl, int argc,
- char *argv[], int sci_idx)
+static int check_request_table (rqtbl, argc, argv, sci_idx)
+ register ss_request_table *rqtbl;
+ int argc;
+ char *argv[];
+ int sci_idx;
{
#ifdef __SABER__
struct _ss_request_entry *request;
@@ -131,7 +134,10 @@ static int check_request_table(register ss_request_table *rqtbl, int argc,
* Notes:
*/
-static int really_execute_command(int sci_idx, int argc, char **argv[])
+static int really_execute_command (sci_idx, argc, argv)
+ int sci_idx;
+ int argc;
+ char **argv[];
{
register ss_request_table **rqtbl;
register ss_data *info;
@@ -161,7 +167,9 @@ static int really_execute_command(int sci_idx, int argc, char **argv[])
* Notes:
*/
-int ss_execute_command(int sci_idx, register char *argv[])
+int ss_execute_command(sci_idx, argv)
+ int sci_idx;
+ register char *argv[];
{
register int i, argc;
char **argp;
@@ -193,7 +201,9 @@ int ss_execute_command(int sci_idx, register char *argv[])
* Notes:
*/
-int ss_execute_line(int sci_idx, char *line_ptr)
+int ss_execute_line (sci_idx, line_ptr)
+ int sci_idx;
+ char *line_ptr;
{
char **argv;
int argc, ret;
diff --git a/lib/ss/help.c b/lib/ss/help.c
index fbc040f8..c1a167d1 100644
--- a/lib/ss/help.c
+++ b/lib/ss/help.c
@@ -35,7 +35,11 @@ extern int errno;
#endif
#include "ss_internal.h"
-void ss_help(int argc, char const * const *argv, int sci_idx, pointer info_ptr)
+void ss_help (argc, argv, sci_idx, info_ptr)
+ int argc;
+ char const * const *argv;
+ int sci_idx;
+ pointer info_ptr;
{
char *buffer;
char const *request_name;
@@ -105,14 +109,13 @@ void ss_help(int argc, char const * const *argv, int sci_idx, pointer info_ptr)
switch (child = fork()) {
case -1:
ss_perror(sci_idx, errno, "Can't fork for pager");
- (void) close(fd);
return;
case 0:
(void) dup2(fd, 0); /* put file on stdin */
ss_page_stdin();
default:
(void) close(fd); /* what can we do if it fails? */
- while (wait(NULL) != child) {
+ while (wait(0) != child) {
/* do nothing if wrong pid */
};
}
@@ -124,7 +127,10 @@ void ss_help(int argc, char const * const *argv, int sci_idx, pointer info_ptr)
#include <dirent.h>
#endif
-void ss_add_info_dir(int sci_idx, char *info_dir, int *code_ptr)
+void ss_add_info_dir(sci_idx, info_dir, code_ptr)
+ int sci_idx;
+ char *info_dir;
+ int *code_ptr;
{
register ss_data *info;
DIR *d;
@@ -158,7 +164,10 @@ void ss_add_info_dir(int sci_idx, char *info_dir, int *code_ptr)
*code_ptr = 0;
}
-void ss_delete_info_dir(int sci_idx, char *info_dir, int *code_ptr)
+void ss_delete_info_dir(sci_idx, info_dir, code_ptr)
+ int sci_idx;
+ char *info_dir;
+ int *code_ptr;
{
register char **i_d;
register char **info_dirs;
diff --git a/lib/ss/invocation.c b/lib/ss/invocation.c
index 57666ecc..74fcb144 100644
--- a/lib/ss/invocation.c
+++ b/lib/ss/invocation.c
@@ -19,11 +19,13 @@
#ifdef HAVE_DLOPEN
#include <dlfcn.h>
#endif
-#include <errno.h>
-int ss_create_invocation(const char *subsystem_name, const char *version_string,
- void *info_ptr, ss_request_table *request_table_ptr,
- int *code_ptr)
+int ss_create_invocation(subsystem_name, version_string, info_ptr,
+ request_table_ptr, code_ptr)
+ const char *subsystem_name, *version_string;
+ void *info_ptr;
+ ss_request_table *request_table_ptr;
+ int *code_ptr;
{
register int sci_idx;
register ss_data *new_table;
@@ -43,10 +45,6 @@ int ss_create_invocation(const char *subsystem_name, const char *version_string,
;
table = (ss_data **) realloc((char *)table,
((unsigned)sci_idx+2)*size);
- if (table == NULL) {
- *code_ptr = errno;
- return 0;
- }
table[sci_idx+1] = (ss_data *) NULL;
table[sci_idx] = new_table;
@@ -86,7 +84,8 @@ int ss_create_invocation(const char *subsystem_name, const char *version_string,
}
void
-ss_delete_invocation(int sci_idx)
+ss_delete_invocation(sci_idx)
+ int sci_idx;
{
register ss_data *t;
int ignored_code;
diff --git a/lib/ss/list_rqs.c b/lib/ss/list_rqs.c
index 220534c7..770f5f02 100644
--- a/lib/ss/list_rqs.c
+++ b/lib/ss/list_rqs.c
@@ -44,11 +44,6 @@ void ss_list_requests(int argc __SS_ATTR((unused)),
sigprocmask(SIG_BLOCK, &igmask, &omask);
func = signal(SIGINT, SIG_IGN);
fd = ss_pager_create();
- if (fd < 0) {
- perror("ss_pager_create");
- (void) signal(SIGINT, func);
- return;
- }
output = fdopen(fd, "w");
sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
diff --git a/lib/ss/pager.c b/lib/ss/pager.c
index bb149d69..67fc1044 100644
--- a/lib/ss/pager.c
+++ b/lib/ss/pager.c
@@ -14,9 +14,6 @@
* express or implied warranty.
*/
-#if HAVE_SECURE_GETENV
-#define _GNU_SOURCE
-#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
@@ -41,6 +38,7 @@ extern int errno;
#endif
static char MORE[] = "more";
+extern char *_ss_pager_name;
extern char *getenv PROTOTYPE((const char *));
char *ss_safe_getenv(const char *arg)
@@ -57,9 +55,7 @@ char *ss_safe_getenv(const char *arg)
#endif
#endif
-#if defined(HAVE_SECURE_GETENV)
- return secure_getenv(arg);
-#elif defined(HAVE___SECURE_GETENV)
+#ifdef HAVE___SECURE_GETENV
return __secure_getenv(arg);
#else
return getenv(arg);
@@ -129,7 +125,7 @@ static int write_all(int fd, char *buf, size_t count)
return c;
}
-void ss_page_stdin(void)
+void ss_page_stdin()
{
int i;
sigset_t mask;
diff --git a/lib/ss/parse.c b/lib/ss/parse.c
index 54b768b8..495030a2 100644
--- a/lib/ss/parse.c
+++ b/lib/ss/parse.c
@@ -42,7 +42,10 @@ enum parse_mode { WHITESPACE, TOKEN, QUOTED_STRING };
#define NEW_ARGV(old,n) (char **)realloc((char *)old,\
(unsigned)(n+2)*sizeof(char*))
-char **ss_parse(int sci_idx, register char *line_ptr, int *argc_ptr)
+char **ss_parse (sci_idx, line_ptr, argc_ptr)
+ int sci_idx;
+ register char *line_ptr;
+ int *argc_ptr;
{
register char **argv, *cp;
register int argc;
@@ -86,10 +89,6 @@ char **ss_parse(int sci_idx, register char *line_ptr, int *argc_ptr)
parse_mode = TOKEN;
cp = line_ptr;
argv = NEW_ARGV (argv, argc);
- if (argv == NULL) {
- *argc_ptr = errno;
- return argv;
- }
argv[argc++] = line_ptr;
argv[argc] = NULL;
}
diff --git a/lib/ss/request_tbl.c b/lib/ss/request_tbl.c
index 16cb4213..4632d65d 100644
--- a/lib/ss/request_tbl.c
+++ b/lib/ss/request_tbl.c
@@ -19,7 +19,11 @@
#define ssrt ss_request_table /* for some readable code... */
-void ss_add_request_table(int sci_idx, ssrt *rqtbl_ptr, int position, int *code_ptr)
+void ss_add_request_table(sci_idx, rqtbl_ptr, position, code_ptr)
+ int sci_idx;
+ ssrt *rqtbl_ptr;
+ int position; /* 1 -> becomes second... */
+ int *code_ptr;
{
register ss_data *info;
register int i, size;
@@ -30,7 +34,7 @@ void ss_add_request_table(int sci_idx, ssrt *rqtbl_ptr, int position, int *code_
;
/* size == C subscript of NULL == #elements */
size += 2; /* new element, and NULL */
- t = (ssrt **)realloc(info->rqt_tables, (unsigned)size*sizeof(ssrt *));
+ t = (ssrt **)realloc(info->rqt_tables, (unsigned)size*sizeof(ssrt));
if (t == (ssrt **)NULL) {
*code_ptr = errno;
return;
@@ -48,7 +52,10 @@ void ss_add_request_table(int sci_idx, ssrt *rqtbl_ptr, int position, int *code_
*code_ptr = 0;
}
-void ss_delete_request_table(int sci_idx, ssrt *rqtbl_ptr, int *code_ptr)
+void ss_delete_request_table(sci_idx, rqtbl_ptr, code_ptr)
+ int sci_idx;
+ ssrt *rqtbl_ptr;
+ int *code_ptr;
{
register ss_data *info;
register ssrt **rt1, **rt2;
diff --git a/lib/ss/ss.h b/lib/ss/ss.h
index 7333ffc9..6cc050bd 100644
--- a/lib/ss/ss.h
+++ b/lib/ss/ss.h
@@ -90,7 +90,6 @@ void ss_unimplemented(int argc, const char * const *argv,
void ss_set_prompt(int sci_idx, char *new_prompt);
char *ss_get_prompt(int sci_idx);
void ss_get_readline(int sci_idx);
-char *ss_safe_getenv(const char *arg);
extern ss_request_table ss_std_requests;
#endif /* _ss_h */
diff --git a/lib/ss/ss.pc.in b/lib/ss/ss.pc.in
index 5c9eccb1..cf893611 100644
--- a/lib/ss/ss.pc.in
+++ b/lib/ss/ss.pc.in
@@ -7,6 +7,6 @@ Name: ss
Description: Subsystem command parsing library
Version: @E2FSPROGS_VERSION@
Requires.private: com_err
-Cflags: -I${includedir}/ss -I${includedir}
+Cflags: -I${includedir}/ss
Libs: -L${libdir} -lss
Libs.private: @DLOPEN_LIB@
diff --git a/lib/ss/ss_internal.h b/lib/ss/ss_internal.h
index 19a6be7a..15d618ee 100644
--- a/lib/ss/ss_internal.h
+++ b/lib/ss/ss_internal.h
@@ -94,7 +94,6 @@ char **ss_rl_completion(const char *text, int start, int end);
extern ss_data **_ss_table;
extern char *ss_et_msgs[];
-extern char *_ss_pager_name;
#ifdef USE_SIGPROCMASK
/* fake sigmask, sigblock, sigsetmask */
diff --git a/lib/uuid/MODULE_LICENSE_BSD_LIKE b/lib/uuid/MODULE_LICENSE_BSD_LIKE
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/lib/uuid/MODULE_LICENSE_BSD_LIKE
diff --git a/lib/uuid/Makefile.in b/lib/uuid/Makefile.in
index 14d08c16..141b8dca 100644
--- a/lib/uuid/Makefile.in
+++ b/lib/uuid/Makefile.in
@@ -62,7 +62,6 @@ BSDLIB_INSTALL_DIR = $(root_libdir)
.c.o:
$(E) " CC $<"
$(Q) $(CC) $(ALL_CFLAGS) -c $< -o $@
- $(Q) $(CHECK_CMD) $(ALL_CFLAGS) $<
@PROFILE_CMT@ $(Q) $(CC) $(ALL_CFLAGS) -g -pg -o profiled/$*.o -c $<
@CHECKER_CMT@ $(Q) $(CC) $(ALL_CFLAGS) -checker -g -o checker/$*.o -c $<
@ELF_CMT@ $(Q) $(CC) $(ALL_CFLAGS) -fPIC -o elfshared/$*.o -c $<
@@ -77,7 +76,7 @@ uuid.h: $(srcdir)/uuid.h.in
$(top_builddir)/lib/uuid/uuid_types.h: $(srcdir)/uuid_types.h.in $(top_builddir)/config.status
cd $(top_builddir); CONFIG_FILES=$(my_dir)/uuid_types.h ./config.status
-tst_uuid.o: $(srcdir)/tst_uuid.c uuid.h
+tst_uuid.o: $(srcdir)/tst_uuid.c
$(E) " CC $@"
$(Q) $(CC) $(ALL_CFLAGS) -c $(srcdir)/tst_uuid.c -o tst_uuid.o
@@ -87,8 +86,8 @@ tst_uuid: tst_uuid.o $(DEPSTATIC_LIBUUID)
uuid_time: $(srcdir)/uuid_time.c $(DEPLIBUUID)
$(E) " LD $@"
- $(Q) $(CC) $(ALL_CFLAGS) $(LDFLAGS) -DDEBUG -o uuid_time \
- $(srcdir)/uuid_time.c $(LIBUUID)
+ $(Q) $(CC) $(ALL_CFLAGS) -DDEBUG -o uuid_time $(srcdir)/uuid_time.c \
+ $(LIBUUID)
uuid.3: $(DEP_SUBSTITUTE) $(srcdir)/uuid.3.in
$(E) " SUBST $@"
@@ -193,23 +192,13 @@ $(OBJS): subdirs uuid.h
# Makefile dependencies follow. This must be the last section in
# the Makefile.in file
#
-clear.o: $(srcdir)/clear.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/uuidP.h
-compare.o: $(srcdir)/compare.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/uuidP.h
-copy.o: $(srcdir)/copy.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/uuidP.h
-gen_uuid.o: $(srcdir)/gen_uuid.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/uuidP.h $(srcdir)/uuidd.h
-isnull.o: $(srcdir)/isnull.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/uuidP.h
-pack.o: $(srcdir)/pack.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/uuidP.h
-parse.o: $(srcdir)/parse.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/uuidP.h
-unpack.o: $(srcdir)/unpack.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/uuidP.h
-unparse.o: $(srcdir)/unparse.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/uuidP.h
-uuid_time.o: $(srcdir)/uuid_time.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(srcdir)/uuidP.h
+clear.o: $(srcdir)/clear.c $(srcdir)/uuidP.h
+compare.o: $(srcdir)/compare.c $(srcdir)/uuidP.h
+copy.o: $(srcdir)/copy.c $(srcdir)/uuidP.h
+gen_uuid.o: $(srcdir)/gen_uuid.c $(srcdir)/uuidP.h $(srcdir)/uuidd.h
+isnull.o: $(srcdir)/isnull.c $(srcdir)/uuidP.h
+pack.o: $(srcdir)/pack.c $(srcdir)/uuidP.h
+parse.o: $(srcdir)/parse.c $(srcdir)/uuidP.h
+unpack.o: $(srcdir)/unpack.c $(srcdir)/uuidP.h
+unparse.o: $(srcdir)/unparse.c $(srcdir)/uuidP.h
+uuid_time.o: $(srcdir)/uuid_time.c $(srcdir)/uuidP.h
diff --git a/lib/uuid/gen_uuid.c b/lib/uuid/gen_uuid.c
index ddc14d71..420ca2b2 100644
--- a/lib/uuid/gen_uuid.c
+++ b/lib/uuid/gen_uuid.c
@@ -38,7 +38,6 @@
*/
#define _SVID_SOURCE
-
#ifdef _WIN32
#define _WIN32_WINNT 0x0500
#include <windows.h>
@@ -175,7 +174,8 @@ static void get_random_bytes(void *buf, int nbytes)
{
int i, n = nbytes, fd = get_random_fd();
int lose_counter = 0;
- unsigned char *cp = buf;
+ unsigned char *cp = (unsigned char *) buf;
+ unsigned short tmp_seed[3];
if (fd >= 0) {
while (n > 0) {
@@ -198,16 +198,12 @@ static void get_random_bytes(void *buf, int nbytes)
for (cp = buf, i = 0; i < nbytes; i++)
*cp++ ^= (rand() >> 7) & 0xFF;
#ifdef DO_JRAND_MIX
- {
- unsigned short tmp_seed[3];
-
- memcpy(tmp_seed, jrand_seed, sizeof(tmp_seed));
- jrand_seed[2] = jrand_seed[2] ^ syscall(__NR_gettid);
- for (cp = buf, i = 0; i < nbytes; i++)
- *cp++ ^= (jrand48(tmp_seed) >> 7) & 0xFF;
- memcpy(jrand_seed, tmp_seed,
- sizeof(jrand_seed) - sizeof(unsigned short));
- }
+ memcpy(tmp_seed, jrand_seed, sizeof(tmp_seed));
+ jrand_seed[2] = jrand_seed[2] ^ syscall(__NR_gettid);
+ for (cp = buf, i = 0; i < nbytes; i++)
+ *cp++ ^= (jrand48(tmp_seed) >> 7) & 0xFF;
+ memcpy(jrand_seed, tmp_seed,
+ sizeof(jrand_seed)-sizeof(unsigned short));
#endif
return;
@@ -400,10 +396,9 @@ try_again:
if (state_fd > 0) {
rewind(state_f);
- len = fprintf(state_f,
+ len = fprintf(state_f,
"clock: %04x tv: %016lu %08lu adj: %08d\n",
- clock_seq, last.tv_sec, (long)last.tv_usec,
- adjustment);
+ clock_seq, last.tv_sec, last.tv_usec, adjustment);
fflush(state_f);
if (ftruncate(state_fd, len) < 0) {
fprintf(state_f, " \n");
diff --git a/lib/uuid/tst_uuid.c b/lib/uuid/tst_uuid.c
index 8c1b6552..7ac0207e 100644
--- a/lib/uuid/tst_uuid.c
+++ b/lib/uuid/tst_uuid.c
@@ -32,7 +32,6 @@
* %End-Header%
*/
-
#ifdef _WIN32
#define _WIN32_WINNT 0x0500
#include <windows.h>
@@ -73,7 +72,7 @@ main(int argc ATTR((unused)) , char **argv ATTR((unused)))
uuid_t buf, tst;
char str[100];
struct timeval tv;
- time_t time_reg, time_gen;
+ time_t time_reg;
unsigned char *cp;
int i;
int failed = 0;
@@ -103,8 +102,7 @@ main(int argc ATTR((unused)) , char **argv ATTR((unused)))
printf("%02x", *cp++);
}
printf("\n");
- type = uuid_type(buf);
- variant = uuid_variant(buf);
+ type = uuid_type(buf); variant = uuid_variant(buf);
printf("UUID type = %d, UUID variant = %d\n", type, variant);
if (variant != UUID_VARIANT_DCE) {
printf("Incorrect UUID Variant; was expecting DCE!\n");
@@ -117,7 +115,6 @@ main(int argc ATTR((unused)) , char **argv ATTR((unused)))
}
printf("\n");
- time_gen = time(0);
uuid_generate_time(buf);
uuid_unparse(buf, str);
printf("UUID string = %s\n", str);
@@ -126,8 +123,7 @@ main(int argc ATTR((unused)) , char **argv ATTR((unused)))
printf("%02x", *cp++);
}
printf("\n");
- type = uuid_type(buf);
- variant = uuid_variant(buf);
+ type = uuid_type(buf); variant = uuid_variant(buf);
printf("UUID type = %d, UUID variant = %d\n", type, variant);
if (variant != UUID_VARIANT_DCE) {
printf("Incorrect UUID Variant; was expecting DCE!\n");
@@ -138,25 +134,15 @@ main(int argc ATTR((unused)) , char **argv ATTR((unused)))
"1 (time-based type)!\\n");
failed++;
}
-
tv.tv_sec = 0;
tv.tv_usec = 0;
time_reg = uuid_time(buf, &tv);
- printf("UUID generated at %lu reports %lu (%ld.%ld)\n",
- time_gen, time_reg, tv.tv_sec, (long)tv.tv_usec);
- /* allow 1s margin in case of rollover between sampling
- * the current time and when the UUID is generated. */
- if (time_reg > time_gen + 1) {
- printf("UUID time comparison failed!\n");
- failed++;
- } else {
- printf("UUID time comparison succeeded.\n");
- }
-
+ printf("UUID time is: (%ld, %ld): %s\n", tv.tv_sec, tv.tv_usec,
+ ctime(&time_reg));
uuid_parse(str, tst);
- if (!uuid_compare(buf, tst)) {
+ if (!uuid_compare(buf, tst))
printf("UUID parse and compare succeeded.\n");
- } else {
+ else {
printf("UUID parse and compare failed!\n");
failed++;
}
@@ -174,7 +160,6 @@ main(int argc ATTR((unused)) , char **argv ATTR((unused)))
printf("UUID copy and compare failed!\n");
failed++;
}
-
failed += test_uuid("84949cc5-4701-4a84-895b-354c584a981b", 1);
failed += test_uuid("84949CC5-4701-4A84-895B-354C584A981B", 1);
failed += test_uuid("84949cc5-4701-4a84-895b-354c584a981bc", 0);
diff --git a/lib/uuid/uuid.pc.in b/lib/uuid/uuid.pc.in
index eaa4e4d5..9e38a326 100644
--- a/lib/uuid/uuid.pc.in
+++ b/lib/uuid/uuid.pc.in
@@ -7,5 +7,5 @@ Name: uuid
Description: Universally unique id library
Version: @E2FSPROGS_VERSION@
Requires:
-Cflags: -I${includedir}/uuid -I${includedir}
+Cflags: -I${includedir}/uuid
Libs: -L${libdir} -luuid
diff --git a/lib/uuid/uuid_time.c b/lib/uuid/uuid_time.c
index 849427f1..f25f5c90 100644
--- a/lib/uuid/uuid_time.c
+++ b/lib/uuid/uuid_time.c
@@ -163,7 +163,7 @@ main(int argc, char **argv)
printf("Warning: not a time-based UUID, so UUID time "
"decoding will likely not work!\n");
}
- printf("UUID time is: (%ld, %ld): %s\n", tv.tv_sec, (long)tv.tv_usec,
+ printf("UUID time is: (%ld, %ld): %s\n", tv.tv_sec, tv.tv_usec,
ctime(&time_reg));
return 0;