diff --git a/MCONFIG.in b/MCONFIG.in index 044f256b..f80da046 100644 --- a/MCONFIG.in +++ b/MCONFIG.in @@ -277,7 +277,7 @@ clean:: .depend: Makefile $(SRCS) $(top_srcdir)/depfix.sed $(top_srcdir)/wordwrap.pl if test -n "$(SRCS)" ; then \ - $(CC) -M $(ALL_CFLAGS) $(SRCS) | \ + $(CC) -M $(ALL_CFLAGS) $(DEPEND_CFLAGS) $(SRCS) | \ $(SED) -f $(top_srcdir)/depfix.sed \ -e 's; $(srcdir)/; $$(srcdir)/;g' \ -e 's; $(top_srcdir)/; $$(top_srcdir)/;g' \ diff --git a/Makefile.in b/Makefile.in index cf129db3..f5727a80 100644 --- a/Makefile.in +++ b/Makefile.in @@ -15,7 +15,7 @@ INSTALL = @INSTALL@ @BLKID_CMT@BLKID_LIB_SUBDIR= lib/blkid QUOTA_LIB_SUBDIR= lib/quota -LIB_SUBDIRS=lib/et lib/ss lib/e2p $(UUID_LIB_SUBDIR) lib/ext2fs $(BLKID_LIB_SUBDIR) $(QUOTA_LIB_SUBDIR) intl +LIB_SUBDIRS=lib/et lib/ss lib/e2p $(UUID_LIB_SUBDIR) $(BLKID_LIB_SUBDIR) $(QUOTA_LIB_SUBDIR) lib/ext2fs intl PROG_SUBDIRS=e2fsck $(DEBUGFS_DIR) misc $(RESIZE_DIR) tests/progs po SUBDIRS=util $(LIB_SUBDIRS) $(PROG_SUBDIRS) tests diff --git a/debugfs/quota.c b/debugfs/quota.c index 95d064b2..5589c1a8 100644 --- a/debugfs/quota.c +++ b/debugfs/quota.c @@ -93,18 +93,19 @@ static int parse_quota_type(const char *cmdname, const char *str) static int list_quota_callback(struct dquot *dq, void *cb_data) { printf("%8u %8lld %8lld %8lld %8lld %8lld %8lld\n", - dq->dq_id, dq->dq_dqb.dqb_curspace, - dq->dq_dqb.dqb_bsoftlimit, dq->dq_dqb.dqb_bhardlimit, - dq->dq_dqb.dqb_curinodes, - dq->dq_dqb.dqb_isoftlimit, dq->dq_dqb.dqb_ihardlimit); + dq->dq_id, (long long)dq->dq_dqb.dqb_curspace, + (long long)dq->dq_dqb.dqb_bsoftlimit, + (long long)dq->dq_dqb.dqb_bhardlimit, + (long long)dq->dq_dqb.dqb_curinodes, + (long long)dq->dq_dqb.dqb_isoftlimit, + (long long)dq->dq_dqb.dqb_ihardlimit); return 0; } void do_list_quota(int argc, char *argv[]) { errcode_t retval; - int i, type; - int flags = 0; + int type; struct quota_handle *qh; if (load_quota_ctx(argv[0])) @@ -132,9 +133,7 @@ void do_list_quota(int argc, char *argv[]) void do_get_quota(int argc, char *argv[]) { - errcode_t retval; - int i, err, type; - int flags = 0; + int err, type; struct quota_handle *qh; struct dquot *dq; qid_t id; @@ -165,7 +164,7 @@ void do_get_quota(int argc, char *argv[]) if (dq) { list_quota_callback(dq, NULL); ext2fs_free_mem(&dq); - } else + } else { com_err(argv[0], 0, "couldn't read quota record"); - + } } diff --git a/debugfs/util.c b/debugfs/util.c index 5cc4e22b..6c48fbab 100644 --- a/debugfs/util.c +++ b/debugfs/util.c @@ -245,6 +245,20 @@ time_t string_to_time(const char *arg) ts.tm_mday = 0; #endif ts.tm_isdst = -1; + /* strptime() may only update the specified fields, which does not + * necessarily include ts.tm_yday (%j). Calculate this if unset: + * + * Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec + * 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 + * + * Start with 31 days per month. Even months have only 30 days, but + * reverse in August, subtract one day for those months. February has + * only 28 days, not 30, subtract two days. Add day of month, minus + * one, since day is not finished yet. Leap years handled afterward. */ + if (ts.tm_yday == 0) + ts.tm_yday = (ts.tm_mon * 31) - + ((ts.tm_mon - (ts.tm_mon > 7)) / 2) - + 2 * (ts.tm_mon > 1) + ts.tm_mday - 1; ret = ts.tm_sec + ts.tm_min*60 + ts.tm_hour*3600 + ts.tm_yday*86400 + (ts.tm_year-70)*31536000 + ((ts.tm_year-69)/4)*86400 - ((ts.tm_year-1)/100)*86400 + ((ts.tm_year+299)/400)*86400; diff --git a/e2fsck/Makefile.in b/e2fsck/Makefile.in index 91349579..db70abcb 100644 --- a/e2fsck/Makefile.in +++ b/e2fsck/Makefile.in @@ -526,3 +526,13 @@ logfile.o: $(srcdir)/logfile.c $(top_builddir)/lib/config.h \ $(top_srcdir)/lib/quota/dqblk_v2.h $(top_srcdir)/lib/quota/quotaio_tree.h \ $(top_srcdir)/lib/../e2fsck/dict.h prof_err.o: prof_err.c +quota.o: $(srcdir)/quota.c $(top_builddir)/lib/config.h \ + $(top_builddir)/lib/dirpaths.h $(srcdir)/e2fsck.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 \ + $(srcdir)/profile.h prof_err.h $(top_srcdir)/lib/quota/quotaio.h \ + $(top_srcdir)/lib/quota/dqblk_v2.h $(top_srcdir)/lib/quota/quotaio_tree.h \ + $(top_srcdir)/lib/../e2fsck/dict.h $(srcdir)/problem.h diff --git a/lib/ext2fs/Makefile.in b/lib/ext2fs/Makefile.in index ba2b2c4e..ddf5942b 100644 --- a/lib/ext2fs/Makefile.in +++ b/lib/ext2fs/Makefile.in @@ -4,6 +4,7 @@ VPATH = @srcdir@ top_builddir = ../.. my_dir = lib/ext2fs INSTALL = @INSTALL@ +DEPEND_CFLAGS = -I$(top_srcdir)/debugfs @MCONFIG@ @@ -15,6 +16,31 @@ MK_CMDS= _SS_DIR_OVERRIDE=../ss ../ss/mk_cmds @TEST_IO_CMT@TEST_IO_LIB_OBJS = test_io.o @IMAGER_CMT@E2IMAGE_LIB_OBJS = imager.o +DEBUG_OBJS= debug_cmds.o extent_cmds.o tst_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 zap.o \ + xattrs.o quota.o tst_libext2fs.o create_inode.o + +DEBUG_SRCS= debug_cmds.c extent_cmds.c tst_cmds.c \ + $(top_srcdir)/debugfs/debugfs.c \ + $(top_srcdir)/debugfs/util.c \ + $(top_srcdir)/debugfs/ncheck.c \ + $(top_srcdir)/debugfs/icheck.c \ + $(top_srcdir)/debugfs/ls.c \ + $(top_srcdir)/debugfs/lsdel.c \ + $(top_srcdir)/debugfs/dump.c \ + $(top_srcdir)/debugfs/set_fields.c \ + $(top_srcdir)/debugfs/logdump.c \ + $(top_srcdir)/debugfs/htree.c \ + $(top_srcdir)/debugfs/unused.c \ + $(top_srcdir)/debugfs/filefrag.c \ + $(top_srcdir)/debugfs/extent_inode.c \ + $(top_srcdir)/debugfs/zap.c \ + $(top_srcdir)/debugfs/quota.c \ + $(top_srcdir)/debugfs/xattrs.c \ + $(top_srcdir)/misc/e2freefrag.c \ + $(top_srcdir)/misc/create_inode.c + OBJS= $(DEBUGFS_LIB_OBJS) $(RESIZE_LIB_OBJS) $(E2IMAGE_LIB_OBJS) \ $(TEST_IO_LIB_OBJS) \ ext2_err.o \ @@ -173,6 +199,8 @@ SRCS= ext2_err.c \ $(srcdir)/version.c \ $(srcdir)/write_bb_file.c \ $(srcdir)/rbtree.c \ + $(srcdir)/tst_libext2fs.c \ + $(DEBUG_SRCS) HFILES= bitops.h ext2fs.h ext2_io.h ext2_fs.h ext2_ext_attr.h ext3_extents.h \ tdb.h qcow2.h @@ -199,7 +227,7 @@ BSDLIB_INSTALL_DIR = $(root_libdir) @MAKEFILE_PROFILE@ @MAKEFILE_CHECKER@ -all:: ext2fs.pc +all:: ext2fs.pc tst_libext2fs .c.o: $(E) " CC $<" @@ -297,9 +325,9 @@ ext2_tdbtool: tdbtool.o $(E) " LD $@" $(Q) $(CC) -o ext2_tdbtool tdbtool.o tdb.o $(ALL_LDFLAGS) $(SYSLIBS) -extent_dbg.c: $(srcdir)/extent_dbg.ct - $(E) " MK_CMDS $<" - $(Q) $(MK_CMDS) $(srcdir)/extent_dbg.ct +tst_cmds.c tst_cmds.h: tst_cmds.ct + $(E) " MK_CMDS $@" + $(Q) $(MK_CMDS) $(srcdir)/tst_cmds.ct debug_cmds.c debug_cmds.h: $(top_srcdir)/debugfs/debug_cmds.ct $(E) " MK_CMDS $<" @@ -309,10 +337,6 @@ 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 - debugfs.o: $(top_srcdir)/debugfs/debugfs.c $(E) " CC $<" $(Q) $(CC) $(ALL_CFLAGS) -c $< -o $@ @@ -365,14 +389,30 @@ zap.o: $(top_srcdir)/debugfs/zap.c $(E) " CC $<" $(Q) $(CC) $(ALL_CFLAGS) -c $< -o $@ +quota.o: $(top_srcdir)/debugfs/quota.c + $(E) " CC $<" + $(Q) $(CC) $(ALL_CFLAGS) -c $< -o $@ + +xattrs.o: $(top_srcdir)/debugfs/xattrs.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 $@ +create_inode.o: $(top_srcdir)/misc/create_inode.c + $(E) " CC $<" + $(Q) $(CC) $(ALL_CFLAGS) -DDEBUGFS -c $< -o $@ + filefrag.o: $(top_srcdir)/debugfs/filefrag.c $(E) " CC $<" $(Q) $(CC) $(ALL_CFLAGS) -c $< -o $@ +tst_libext2fs.o: $(srcdir)/tst_libext2fs.c + $(E) " CC $<" + $(Q) $(CC) $(ALL_CFLAGS) $(DEPEND_CFLAGS) -c $< -o $@ + tst_bitmaps_cmd.c: tst_bitmaps_cmd.ct $(E) " MK_CMDS $@" $(Q) DIR=$(srcdir) $(MK_CMDS) $(srcdir)/tst_bitmaps_cmd.ct @@ -385,12 +425,23 @@ tst_bitmaps: tst_bitmaps.o tst_bitmaps_cmd.o $(srcdir)/blkmap64_rb.c \ $(STATIC_LIBEXT2FS) $(STATIC_LIBSS) $(STATIC_LIBCOM_ERR) \ $(SYSLIBS) -tst_extents: $(srcdir)/extent.c $(DEBUG_OBJS) $(DEPSTATIC_LIBSS) \ - $(STATIC_LIBE2P) $(DEPLIBUUID) $(DEPLIBBLKID) $(DEPSTATIC_LIBCOM_ERR) +tst_extents: $(srcdir)/extent.c $(DEBUG_OBJS) $(DEPSTATIC_LIBSS) libext2fs.a \ + $(STATIC_LIBE2P) $(DEPLIBUUID) $(DEPLIBBLKID) $(DEPSTATIC_LIBCOM_ERR) \ + $(DEPLIBQUOTA) $(E) " LD $@" $(Q) $(CC) -o tst_extents $(srcdir)/extent.c \ $(ALL_CFLAGS) -DDEBUG $(DEBUG_OBJS) $(STATIC_LIBSS) \ - $(STATIC_LIBE2P) $(STATIC_LIBEXT2FS) $(LIBBLKID) $(LIBUUID) \ + $(STATIC_LIBE2P) $(LIBQUOTA) $(STATIC_LIBEXT2FS) \ + $(LIBBLKID) $(LIBUUID) $(STATIC_LIBCOM_ERR) \ + $(SYSLIBS) -I $(top_srcdir)/debugfs + +tst_libext2fs: $(DEBUG_OBJS) \ + $(DEPSTATIC_LIBSS) $(STATIC_LIBE2P) $(DEPLIBUUID) libext2fs.a \ + $(DEPLIBBLKID) $(DEPSTATIC_LIBCOM_ERR) $(DEPLIBQUOTA) + $(E) " LD $@" + $(Q) $(CC) -o tst_libext2fs $(ALL_CFLAGS) -DDEBUG $(DEBUG_OBJS) \ + $(STATIC_LIBSS) $(STATIC_LIBE2P) $(LIBQUOTA) \ + $(STATIC_LIBEXT2FS) $(LIBBLKID) $(LIBUUID) \ $(STATIC_LIBCOM_ERR) $(SYSLIBS) -I $(top_srcdir)/debugfs tst_inline: $(srcdir)/inline.c $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR) @@ -480,9 +531,10 @@ clean:: 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 \ + ext2_tdbtool mkjournal debug_cmds.c tst_cmds.c extent_cmds.c \ ../libext2fs.a ../libext2fs_p.a ../libext2fs_chk.a \ - crc32c_table.h gen_crc32ctable tst_crc32c + crc32c_table.h gen_crc32ctable tst_crc32c tst_libext2fs \ + ext2fs.pc ext2_types.h mostlyclean:: clean distclean:: clean @@ -504,6 +556,10 @@ crc32c_table.h: gen_crc32ctable $(E) " GEN32CTABLE $@" $(Q) ./gen_crc32ctable > crc32c_table.h +$(top_builddir)/$(my_dir)/ext2_types.h: $(srcdir)/ext2_types.h.in \ + $(top_builddir)/config.status + cd $(top_builddir); CONFIG_FILES=$(my_dir)/ext2_types.h ./config.status + # +++ Dependency line eater +++ # # Makefile dependencies follow. This must be the last section in @@ -1002,3 +1058,214 @@ write_bb_file.o: $(srcdir)/write_bb_file.c $(top_builddir)/lib/config.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 +tst_libext2fs.o: $(srcdir)/tst_libext2fs.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 $(top_srcdir)/lib/ss/ss.h $(top_builddir)/lib/ss/ss_err.h \ + $(top_srcdir)/debugfs/debugfs.h $(srcdir)/ext2fs.h \ + $(top_srcdir)/debugfs/../misc/create_inode.h $(top_srcdir)/lib/e2p/e2p.h \ + $(top_srcdir)/debugfs/../misc/nls-enable.h $(top_srcdir)/lib/quota/quotaio.h \ + $(top_srcdir)/lib/quota/dqblk_v2.h $(top_srcdir)/lib/quota/quotaio_tree.h \ + $(top_srcdir)/lib/../e2fsck/dict.h +debug_cmds.o: debug_cmds.c $(top_srcdir)/lib/ss/ss.h \ + $(top_builddir)/lib/ss/ss_err.h $(top_srcdir)/lib/et/com_err.h +extent_cmds.o: extent_cmds.c $(top_srcdir)/lib/ss/ss.h \ + $(top_builddir)/lib/ss/ss_err.h $(top_srcdir)/lib/et/com_err.h +tst_cmds.o: tst_cmds.c $(top_srcdir)/lib/ss/ss.h \ + $(top_builddir)/lib/ss/ss_err.h $(top_srcdir)/lib/et/com_err.h +debugfs.o: $(top_srcdir)/debugfs/debugfs.c $(top_builddir)/lib/config.h \ + $(top_builddir)/lib/dirpaths.h $(top_srcdir)/debugfs/debugfs.h \ + $(top_srcdir)/lib/ss/ss.h $(top_builddir)/lib/ss/ss_err.h \ + $(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_fs.h \ + $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \ + $(srcdir)/ext3_extents.h $(srcdir)/ext2_io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \ + $(srcdir)/bitops.h $(top_srcdir)/debugfs/../misc/create_inode.h \ + $(top_srcdir)/lib/e2p/e2p.h $(top_srcdir)/debugfs/../misc/nls-enable.h \ + $(top_srcdir)/lib/quota/quotaio.h $(top_srcdir)/lib/quota/dqblk_v2.h \ + $(top_srcdir)/lib/quota/quotaio_tree.h $(top_srcdir)/lib/../e2fsck/dict.h \ + $(top_srcdir)/debugfs/../version.h $(top_srcdir)/debugfs/jfs_user.h \ + $(srcdir)/kernel-jbd.h $(srcdir)/jfs_compat.h $(srcdir)/kernel-list.h +util.o: $(top_srcdir)/debugfs/util.c $(top_builddir)/lib/config.h \ + $(top_builddir)/lib/dirpaths.h $(top_srcdir)/lib/ss/ss.h \ + $(top_builddir)/lib/ss/ss_err.h $(top_srcdir)/lib/et/com_err.h \ + $(top_srcdir)/debugfs/debugfs.h $(srcdir)/ext2_fs.h \ + $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \ + $(srcdir)/ext3_extents.h $(srcdir)/ext2_io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \ + $(srcdir)/bitops.h $(top_srcdir)/debugfs/../misc/create_inode.h \ + $(top_srcdir)/lib/e2p/e2p.h $(top_srcdir)/debugfs/../misc/nls-enable.h \ + $(top_srcdir)/lib/quota/quotaio.h $(top_srcdir)/lib/quota/dqblk_v2.h \ + $(top_srcdir)/lib/quota/quotaio_tree.h $(top_srcdir)/lib/../e2fsck/dict.h +ncheck.o: $(top_srcdir)/debugfs/ncheck.c $(top_builddir)/lib/config.h \ + $(top_builddir)/lib/dirpaths.h $(top_srcdir)/debugfs/debugfs.h \ + $(top_srcdir)/lib/ss/ss.h $(top_builddir)/lib/ss/ss_err.h \ + $(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_fs.h \ + $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \ + $(srcdir)/ext3_extents.h $(srcdir)/ext2_io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \ + $(srcdir)/bitops.h $(top_srcdir)/debugfs/../misc/create_inode.h \ + $(top_srcdir)/lib/e2p/e2p.h $(top_srcdir)/debugfs/../misc/nls-enable.h \ + $(top_srcdir)/lib/quota/quotaio.h $(top_srcdir)/lib/quota/dqblk_v2.h \ + $(top_srcdir)/lib/quota/quotaio_tree.h $(top_srcdir)/lib/../e2fsck/dict.h +icheck.o: $(top_srcdir)/debugfs/icheck.c $(top_builddir)/lib/config.h \ + $(top_builddir)/lib/dirpaths.h $(top_srcdir)/debugfs/debugfs.h \ + $(top_srcdir)/lib/ss/ss.h $(top_builddir)/lib/ss/ss_err.h \ + $(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_fs.h \ + $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \ + $(srcdir)/ext3_extents.h $(srcdir)/ext2_io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \ + $(srcdir)/bitops.h $(top_srcdir)/debugfs/../misc/create_inode.h \ + $(top_srcdir)/lib/e2p/e2p.h $(top_srcdir)/debugfs/../misc/nls-enable.h \ + $(top_srcdir)/lib/quota/quotaio.h $(top_srcdir)/lib/quota/dqblk_v2.h \ + $(top_srcdir)/lib/quota/quotaio_tree.h $(top_srcdir)/lib/../e2fsck/dict.h +ls.o: $(top_srcdir)/debugfs/ls.c $(top_builddir)/lib/config.h \ + $(top_builddir)/lib/dirpaths.h $(top_srcdir)/debugfs/debugfs.h \ + $(top_srcdir)/lib/ss/ss.h $(top_builddir)/lib/ss/ss_err.h \ + $(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_fs.h \ + $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \ + $(srcdir)/ext3_extents.h $(srcdir)/ext2_io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \ + $(srcdir)/bitops.h $(top_srcdir)/debugfs/../misc/create_inode.h \ + $(top_srcdir)/lib/e2p/e2p.h $(top_srcdir)/debugfs/../misc/nls-enable.h \ + $(top_srcdir)/lib/quota/quotaio.h $(top_srcdir)/lib/quota/dqblk_v2.h \ + $(top_srcdir)/lib/quota/quotaio_tree.h $(top_srcdir)/lib/../e2fsck/dict.h +lsdel.o: $(top_srcdir)/debugfs/lsdel.c $(top_builddir)/lib/config.h \ + $(top_builddir)/lib/dirpaths.h $(top_srcdir)/debugfs/debugfs.h \ + $(top_srcdir)/lib/ss/ss.h $(top_builddir)/lib/ss/ss_err.h \ + $(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_fs.h \ + $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \ + $(srcdir)/ext3_extents.h $(srcdir)/ext2_io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \ + $(srcdir)/bitops.h $(top_srcdir)/debugfs/../misc/create_inode.h \ + $(top_srcdir)/lib/e2p/e2p.h $(top_srcdir)/debugfs/../misc/nls-enable.h \ + $(top_srcdir)/lib/quota/quotaio.h $(top_srcdir)/lib/quota/dqblk_v2.h \ + $(top_srcdir)/lib/quota/quotaio_tree.h $(top_srcdir)/lib/../e2fsck/dict.h +dump.o: $(top_srcdir)/debugfs/dump.c $(top_builddir)/lib/config.h \ + $(top_builddir)/lib/dirpaths.h $(top_srcdir)/debugfs/debugfs.h \ + $(top_srcdir)/lib/ss/ss.h $(top_builddir)/lib/ss/ss_err.h \ + $(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_fs.h \ + $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \ + $(srcdir)/ext3_extents.h $(srcdir)/ext2_io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \ + $(srcdir)/bitops.h $(top_srcdir)/debugfs/../misc/create_inode.h \ + $(top_srcdir)/lib/e2p/e2p.h $(top_srcdir)/debugfs/../misc/nls-enable.h \ + $(top_srcdir)/lib/quota/quotaio.h $(top_srcdir)/lib/quota/dqblk_v2.h \ + $(top_srcdir)/lib/quota/quotaio_tree.h $(top_srcdir)/lib/../e2fsck/dict.h +set_fields.o: $(top_srcdir)/debugfs/set_fields.c $(top_builddir)/lib/config.h \ + $(top_builddir)/lib/dirpaths.h $(top_srcdir)/debugfs/debugfs.h \ + $(top_srcdir)/lib/ss/ss.h $(top_builddir)/lib/ss/ss_err.h \ + $(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_fs.h \ + $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \ + $(srcdir)/ext3_extents.h $(srcdir)/ext2_io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \ + $(srcdir)/bitops.h $(top_srcdir)/debugfs/../misc/create_inode.h \ + $(top_srcdir)/lib/e2p/e2p.h $(top_srcdir)/debugfs/../misc/nls-enable.h \ + $(top_srcdir)/lib/quota/quotaio.h $(top_srcdir)/lib/quota/dqblk_v2.h \ + $(top_srcdir)/lib/quota/quotaio_tree.h $(top_srcdir)/lib/../e2fsck/dict.h +logdump.o: $(top_srcdir)/debugfs/logdump.c $(top_builddir)/lib/config.h \ + $(top_builddir)/lib/dirpaths.h $(top_srcdir)/debugfs/debugfs.h \ + $(top_srcdir)/lib/ss/ss.h $(top_builddir)/lib/ss/ss_err.h \ + $(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_fs.h \ + $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \ + $(srcdir)/ext3_extents.h $(srcdir)/ext2_io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \ + $(srcdir)/bitops.h $(top_srcdir)/debugfs/../misc/create_inode.h \ + $(top_srcdir)/lib/e2p/e2p.h $(top_srcdir)/debugfs/../misc/nls-enable.h \ + $(top_srcdir)/lib/quota/quotaio.h $(top_srcdir)/lib/quota/dqblk_v2.h \ + $(top_srcdir)/lib/quota/quotaio_tree.h $(top_srcdir)/lib/../e2fsck/dict.h \ + $(top_srcdir)/debugfs/jfs_user.h $(srcdir)/kernel-jbd.h \ + $(srcdir)/jfs_compat.h $(srcdir)/kernel-list.h +htree.o: $(top_srcdir)/debugfs/htree.c $(top_builddir)/lib/config.h \ + $(top_builddir)/lib/dirpaths.h $(top_srcdir)/debugfs/debugfs.h \ + $(top_srcdir)/lib/ss/ss.h $(top_builddir)/lib/ss/ss_err.h \ + $(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_fs.h \ + $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \ + $(srcdir)/ext3_extents.h $(srcdir)/ext2_io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \ + $(srcdir)/bitops.h $(top_srcdir)/debugfs/../misc/create_inode.h \ + $(top_srcdir)/lib/e2p/e2p.h $(top_srcdir)/debugfs/../misc/nls-enable.h \ + $(top_srcdir)/lib/quota/quotaio.h $(top_srcdir)/lib/quota/dqblk_v2.h \ + $(top_srcdir)/lib/quota/quotaio_tree.h $(top_srcdir)/lib/../e2fsck/dict.h +unused.o: $(top_srcdir)/debugfs/unused.c $(top_builddir)/lib/config.h \ + $(top_builddir)/lib/dirpaths.h $(top_srcdir)/debugfs/debugfs.h \ + $(top_srcdir)/lib/ss/ss.h $(top_builddir)/lib/ss/ss_err.h \ + $(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_fs.h \ + $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \ + $(srcdir)/ext3_extents.h $(srcdir)/ext2_io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \ + $(srcdir)/bitops.h $(top_srcdir)/debugfs/../misc/create_inode.h \ + $(top_srcdir)/lib/e2p/e2p.h $(top_srcdir)/debugfs/../misc/nls-enable.h \ + $(top_srcdir)/lib/quota/quotaio.h $(top_srcdir)/lib/quota/dqblk_v2.h \ + $(top_srcdir)/lib/quota/quotaio_tree.h $(top_srcdir)/lib/../e2fsck/dict.h +filefrag.o: $(top_srcdir)/debugfs/filefrag.c $(top_builddir)/lib/config.h \ + $(top_builddir)/lib/dirpaths.h $(top_srcdir)/debugfs/debugfs.h \ + $(top_srcdir)/lib/ss/ss.h $(top_builddir)/lib/ss/ss_err.h \ + $(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_fs.h \ + $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \ + $(srcdir)/ext3_extents.h $(srcdir)/ext2_io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \ + $(srcdir)/bitops.h $(top_srcdir)/debugfs/../misc/create_inode.h \ + $(top_srcdir)/lib/e2p/e2p.h $(top_srcdir)/debugfs/../misc/nls-enable.h \ + $(top_srcdir)/lib/quota/quotaio.h $(top_srcdir)/lib/quota/dqblk_v2.h \ + $(top_srcdir)/lib/quota/quotaio_tree.h $(top_srcdir)/lib/../e2fsck/dict.h +extent_inode.o: $(top_srcdir)/debugfs/extent_inode.c \ + $(top_builddir)/lib/config.h $(top_builddir)/lib/dirpaths.h \ + $(top_srcdir)/debugfs/debugfs.h $(top_srcdir)/lib/ss/ss.h \ + $(top_builddir)/lib/ss/ss_err.h $(top_srcdir)/lib/et/com_err.h \ + $(srcdir)/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h \ + $(srcdir)/ext2fs.h $(srcdir)/ext3_extents.h $(srcdir)/ext2_io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \ + $(srcdir)/bitops.h $(top_srcdir)/debugfs/../misc/create_inode.h \ + $(top_srcdir)/lib/e2p/e2p.h $(top_srcdir)/debugfs/../misc/nls-enable.h \ + $(top_srcdir)/lib/quota/quotaio.h $(top_srcdir)/lib/quota/dqblk_v2.h \ + $(top_srcdir)/lib/quota/quotaio_tree.h $(top_srcdir)/lib/../e2fsck/dict.h +zap.o: $(top_srcdir)/debugfs/zap.c $(top_builddir)/lib/config.h \ + $(top_builddir)/lib/dirpaths.h $(top_srcdir)/debugfs/debugfs.h \ + $(top_srcdir)/lib/ss/ss.h $(top_builddir)/lib/ss/ss_err.h \ + $(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_fs.h \ + $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \ + $(srcdir)/ext3_extents.h $(srcdir)/ext2_io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \ + $(srcdir)/bitops.h $(top_srcdir)/debugfs/../misc/create_inode.h \ + $(top_srcdir)/lib/e2p/e2p.h $(top_srcdir)/debugfs/../misc/nls-enable.h \ + $(top_srcdir)/lib/quota/quotaio.h $(top_srcdir)/lib/quota/dqblk_v2.h \ + $(top_srcdir)/lib/quota/quotaio_tree.h $(top_srcdir)/lib/../e2fsck/dict.h +quota.o: $(top_srcdir)/debugfs/quota.c $(top_builddir)/lib/config.h \ + $(top_builddir)/lib/dirpaths.h $(top_srcdir)/debugfs/debugfs.h \ + $(top_srcdir)/lib/ss/ss.h $(top_builddir)/lib/ss/ss_err.h \ + $(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_fs.h \ + $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \ + $(srcdir)/ext3_extents.h $(srcdir)/ext2_io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \ + $(srcdir)/bitops.h $(top_srcdir)/debugfs/../misc/create_inode.h \ + $(top_srcdir)/lib/e2p/e2p.h $(top_srcdir)/debugfs/../misc/nls-enable.h \ + $(top_srcdir)/lib/quota/quotaio.h $(top_srcdir)/lib/quota/dqblk_v2.h \ + $(top_srcdir)/lib/quota/quotaio_tree.h $(top_srcdir)/lib/../e2fsck/dict.h +xattrs.o: $(top_srcdir)/debugfs/xattrs.c $(top_builddir)/lib/config.h \ + $(top_builddir)/lib/dirpaths.h $(top_srcdir)/debugfs/debugfs.h \ + $(top_srcdir)/lib/ss/ss.h $(top_builddir)/lib/ss/ss_err.h \ + $(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_fs.h \ + $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \ + $(srcdir)/ext3_extents.h $(srcdir)/ext2_io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \ + $(srcdir)/bitops.h $(top_srcdir)/debugfs/../misc/create_inode.h \ + $(top_srcdir)/lib/e2p/e2p.h $(top_srcdir)/debugfs/../misc/nls-enable.h \ + $(top_srcdir)/lib/quota/quotaio.h $(top_srcdir)/lib/quota/dqblk_v2.h \ + $(top_srcdir)/lib/quota/quotaio_tree.h $(top_srcdir)/lib/../e2fsck/dict.h +e2freefrag.o: $(top_srcdir)/misc/e2freefrag.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 $(top_srcdir)/misc/e2freefrag.h +create_inode.o: $(top_srcdir)/misc/create_inode.c \ + $(top_srcdir)/misc/create_inode.h $(top_srcdir)/lib/et/com_err.h \ + $(top_srcdir)/lib/e2p/e2p.h $(srcdir)/ext2_fs.h \ + $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \ + $(srcdir)/ext3_extents.h $(srcdir)/ext2_io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/ext2_ext_attr.h \ + $(srcdir)/bitops.h $(top_srcdir)/misc/nls-enable.h diff --git a/lib/ext2fs/tst_cmds.ct b/lib/ext2fs/tst_cmds.ct new file mode 100644 index 00000000..45a85947 --- /dev/null +++ b/lib/ext2fs/tst_cmds.ct @@ -0,0 +1,6 @@ +command_table libext2fs_cmds; + +request do_block_iterate, "block_iterate", + block_iterate; + +end; diff --git a/lib/ext2fs/tst_libext2fs.c b/lib/ext2fs/tst_libext2fs.c new file mode 100644 index 00000000..1f63eb7a --- /dev/null +++ b/lib/ext2fs/tst_libext2fs.c @@ -0,0 +1,70 @@ +/* + * tst_libext2fs.c + */ + +#include "config.h" +#include +#include +#if HAVE_UNISTD_H +#include +#endif +#if HAVE_ERRNO_H +#include +#endif +#if HAVE_SYS_STAT_H +#include +#endif +#if HAVE_SYS_TYPES_H +#include +#endif + +#include "ext2_fs.h" +#include "ext2fsP.h" + +#include "ss/ss.h" +#include "debugfs.h" + +/* + * Hook in new commands into debugfs + * Override debugfs's prompt + */ +const char *debug_prog_name = "tst_libext2fs"; +extern ss_request_table libext2fs_cmds; +ss_request_table *extra_cmds = &libext2fs_cmds; + +static int print_blocks_proc(ext2_filsys fs EXT2FS_ATTR((unused)), + blk64_t *blocknr, e2_blkcnt_t blockcnt, + blk64_t ref_block, int ref_offset, + void *private EXT2FS_ATTR((unused))) +{ + printf("%6d %8llu (%d %llu)\n", blockcnt, *blocknr, + ref_offset, ref_block); + return 0; +} + + +void do_block_iterate(int argc, char **argv) +{ + const char *usage = "block_iterate 2) { + flags = parse_ulong(argv[2], argv[0], "flags", &err); + if (err) + return; + } + flags |= BLOCK_FLAG_READ_ONLY; + + ext2fs_block_iterate3(current_fs, ino, flags, NULL, + print_blocks_proc, NULL); + putc('\n', stdout); +} diff --git a/misc/create_inode.c b/misc/create_inode.c index 0b1e74ea..83d24802 100644 --- a/misc/create_inode.c +++ b/misc/create_inode.c @@ -255,7 +255,7 @@ static errcode_t copy_file(ext2_filsys fs, int fd, ext2_ino_t newfile, int bufsize, int make_holes) { ext2_file_t e2_file; - errcode_t retval; + errcode_t retval, close_ret; int got; unsigned int written; char *buf; @@ -271,15 +271,14 @@ static errcode_t copy_file(ext2_filsys fs, int fd, ext2_ino_t newfile, retval = ext2fs_get_mem(bufsize, &buf); if (retval) { com_err("copy_file", retval, "can't allocate buffer\n"); - return retval; + goto out_close; } /* This is used for checking whether the whole block is zero */ retval = ext2fs_get_memzero(bufsize, &zero_buf); if (retval) { - com_err("copy_file", retval, "can't allocate buffer\n"); - ext2fs_free_mem(&buf); - return retval; + com_err("copy_file", retval, "can't allocate zero buffer\n"); + goto out_free_buf; } while (1) { @@ -318,15 +317,15 @@ static errcode_t copy_file(ext2_filsys fs, int fd, ext2_ino_t newfile, ptr += written; } } - ext2fs_free_mem(&buf); - ext2fs_free_mem(&zero_buf); - retval = ext2fs_file_close(e2_file); - return retval; fail: - ext2fs_free_mem(&buf); ext2fs_free_mem(&zero_buf); - (void) ext2fs_file_close(e2_file); +out_free_buf: + ext2fs_free_mem(&buf); +out_close: + close_ret = ext2fs_file_close(e2_file); + if (retval == 0) + retval = close_ret; return retval; } diff --git a/misc/filefrag.c b/misc/filefrag.c index 929a33bc..0abfb8ca 100644 --- a/misc/filefrag.c +++ b/misc/filefrag.c @@ -339,7 +339,7 @@ static void frag_report(const char *filename) ext2fs_struct_stat st; int blk_shift; long fd; - unsigned long numblocks; + unsigned long long numblocks; int data_blocks_per_cyl = 1; int num_extents = 1, expected = ~0; int is_ext2 = 0; @@ -411,7 +411,7 @@ static void frag_report(const char *filename) if (width > logical_width) logical_width = width; if (verbose) - printf("File size of %s is %llu (%lu block%s of %d bytes)\n", + printf("File size of %s is %llu (%llu block%s of %d bytes)\n", filename, (unsigned long long)st.st_size, numblocks * fsinfo.f_bsize >> blk_shift, numblocks == 1 ? "" : "s", 1 << blk_shift); diff --git a/misc/util.c b/misc/util.c index 1c0818f6..7e915095 100644 --- a/misc/util.c +++ b/misc/util.c @@ -194,10 +194,10 @@ int check_plausibility(const char *device, int flags, int *ret_is_dev) char *fs_type = NULL; char *fs_label = NULL; - fd = open(device, fl, 0666); + fd = ext2fs_open_file(device, fl, 0666); if ((fd < 0) && (errno == ENOENT) && (flags & CREATE_FILE)) { fl |= O_CREAT; - fd = open(device, fl, 0666); + fd = ext2fs_open_file(device, fl, 0666); if (fd >= 0 && (flags & VERBOSE_CREATE)) printf(_("Creating regular file %s\n"), device); } diff --git a/tests/f_dup_resize/script b/tests/f_dup_resize/script index 659c92ee..19fa120f 100644 --- a/tests/f_dup_resize/script +++ b/tests/f_dup_resize/script @@ -12,7 +12,7 @@ freeb 4 4 freeb 8195 4 write $TEST_DATA debugfs set_current_time 20050411000000 -set_inode_field debugfs mtime 2005041100000000 +set_inode_field debugfs mtime 20050411000000 q EOF diff --git a/tests/f_quota/script b/tests/f_quota/script index bf25e071..bbe6a9f5 100644 --- a/tests/f_quota/script +++ b/tests/f_quota/script @@ -1,4 +1,11 @@ AFTER_CMD='$DEBUGFS -f $test_dir/debugfs-cmds $TMPFILE 2>&1 | sed -f $cmd_dir/filter.sed > $test_name.0.log' PASS_ZERO=true +$TUNE2FS -h 2>&1 | grep -q quota_options +if [ $? != 0 ] ; then + rm -f $TMPFILE + echo "$test_name: $test_description: skipped (quota not enabled)" + return 0 +fi + . $cmd_dir/run_e2fsck diff --git a/tests/f_uninit_last_uninit/script b/tests/f_uninit_last_uninit/script index 2fe4f3a0..376c9782 100644 --- a/tests/f_uninit_last_uninit/script +++ b/tests/f_uninit_last_uninit/script @@ -5,7 +5,7 @@ SKIP_GUNZIP="true" touch $TMPFILE $MKE2FS -N 32 -F -o Linux -O uninit_bg -b 1024 $TMPFILE 10000 > /dev/null 2>&1 $DEBUGFS -w $TMPFILE << EOF > /dev/null 2>&1 -set_current_time 200704102100 +set_current_time 20070410210000 set_super_value lastcheck 0 set_super_value hash_seed null set_super_value mkfs_time 0