Add the profile library code to e2fsck

The profile library was originally written by Theodore Ts'o in 1995
for use in the MIT Kerberos v5 library.  It has been
modified/enhanced/bug-fixed over time by other members of the MIT
Kerberos team.  This version was originally taken from the Kerberos
v5 distribution, version 1.4.2, and radically simplified for use in
e2fsprogs.  (Support for locking for multi-threaded operations,
being able to modify and update the configuration file
programmatically, and Mac/Windows portability have been removed.
It has been folded into a single C source file to make it easier to
fold into an application program.)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
bitmap-optimize
Theodore Ts'o 2005-12-30 23:57:32 -05:00
parent 02ef196210
commit 2fa9ba9833
7 changed files with 2683 additions and 30 deletions

View File

@ -1,3 +1,22 @@
2005-12-30 Theodore Ts'o <tytso@mit.edu>
* profile.c, profile.h, prof_err.et: Add the profile library code
to e2fsck. The profile library was originally written by
Theodore Ts'o in 1995 for use in the MIT Kerberos v5
library. It has been modified/enhanced/bug-fixed over
time by other members of the MIT Kerberos team. This
version was originally taken from the Kerberos v5
distribution, version 1.4.2, and radically simplified for
use in e2fsprogs. (Support for locking for multi-threaded
operations, being able to modify and update the
configuration file programmatically, and Mac/Windows
portability have been removed. It has been folded into a
single C source file to make it easier to fold into an
application program.)
* argv_parse.c, argv_parse.h: Added auxiliary programs used only
for building the profile test program.
2005-12-18 Theodore Ts'o <tytso@mit.edu>
* problem.c (PR_0_FUTURE_SB_LAST_MOUNT,

View File

@ -14,7 +14,7 @@ LDFLAG_STATIC = @LDFLAG_STATIC@
PROGS= e2fsck
MANPAGES= e2fsck.8
XTRA_CFLAGS= -DRESOURCE_TRACK
XTRA_CFLAGS= -DRESOURCE_TRACK -I.
LIBS= $(LIBEXT2FS) $(LIBCOM_ERR) $(LIBBLKID) $(LIBUUID) $(LIBINTL)
DEPLIBS= $(LIBEXT2FS) $(LIBCOM_ERR) $(LIBBLKID) $(DEPLIBUUID)
@ -29,6 +29,8 @@ PROFILED_LIBS= $(PROFILED_LIBEXT2FS) $(PROFILED_LIBCOM_ERR) \
PROFILED_DEPLIBS= $(PROFILED_LIBEXT2FS) $(PROFILED_LIBCOM_ERR) \
$(PROFILED_LIBBLKID) $(DEPPROFILED_LIBUUID)
COMPILE_ET=$(top_builddir)/lib/et/compile_et --build-tree
.c.o:
@echo " CC $<"
@$(CC) -c $(ALL_CFLAGS) $< -o $@
@ -61,7 +63,7 @@ PROFILED_DEPLIBS= $(PROFILED_LIBEXT2FS) $(PROFILED_LIBCOM_ERR) \
OBJS= dict.o unix.o e2fsck.o super.o pass1.o pass1b.o pass2.o pass3.o pass4.o \
pass5.o journal.o swapfs.o badblocks.o util.o dirinfo.o dx_dirinfo.o \
ehandler.o problem.o message.o recovery.o region.o revoke.o \
ea_refcount.o rehash.o $(MTRACE_OBJ)
ea_refcount.o rehash.o profile.o prof_err.o $(MTRACE_OBJ)
PROFILED_OBJS= profiled/dict.o profiled/unix.o profiled/e2fsck.o \
profiled/super.o profiled/pass1.o profiled/pass1b.o \
@ -70,7 +72,8 @@ PROFILED_OBJS= profiled/dict.o profiled/unix.o profiled/e2fsck.o \
profiled/dirinfo.o profiled/dx_dirinfo.o profiled/ehandler.o \
profiled/message.o profiled/problem.o profiled/swapfs.o \
profiled/recovery.o profiled/region.o profiled/revoke.o \
profiled/ea_refcount.o profiled/rehash.o
profiled/ea_refcount.o profiled/rehash.o profiled/profile.o \
profiled/prof_err.o
SRCS= $(srcdir)/e2fsck.c \
$(srcdir)/dict.c \
@ -96,12 +99,18 @@ SRCS= $(srcdir)/e2fsck.c \
$(srcdir)/ea_refcount.c \
$(srcdir)/rehash.c \
$(srcdir)/region.c \
$(srcdir)/profile.c \
prof_err.c \
$(MTRACE_SRC)
all:: profiled $(PROGS) e2fsck.static e2fsck.shared $(MANPAGES)
@PROFILE_CMT@all:: e2fsck.profiled
prof_err.c prof_err.h: prof_err.et
@echo " COMPILE_ET prof_err.et"
@$(COMPILE_ET) $(srcdir)/prof_err.et
e2fsck: e2fsck.@E2FSCK_TYPE@
@echo " CP $@"
@$(CP) e2fsck.@E2FSCK_TYPE@ e2fsck
@ -142,6 +151,12 @@ iscan: iscan.o util.o ehandler.o $(DEPLIBS)
@echo " LD $@"
@$(LD) $(ALL_LDFLAGS) -o iscan iscan.o util.o ehandler.o $(LIBS)
test_profile: $(srcdir)/profile.c argv_parse.o prof_err.o profile.h \
$(STATIC_LIBCOM_ERR)
@echo " LD $@"
@$(CC) -o test_profile -DDEBUG_PROGRAM $(srcdir)/profile.c prof_err.o \
argv_parse.o $(STATIC_LIBCOM_ERR) $(ALL_CFLAGS)
profiled:
@PROFILE_CMT@ @echo " MKDIR $@"
@PROFILE_CMT@ @mkdir profiled
@ -218,7 +233,7 @@ e2fsck.o: $(srcdir)/e2fsck.c $(srcdir)/e2fsck.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/bitops.h \
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h \
$(srcdir)/problem.h
$(srcdir)/profile.h prof_err.h $(srcdir)/problem.h
dict.o: $(srcdir)/dict.c $(srcdir)/dict.h
super.o: $(srcdir)/super.c $(top_srcdir)/lib/uuid/uuid.h $(srcdir)/e2fsck.h \
$(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h \
@ -226,147 +241,159 @@ super.o: $(srcdir)/super.c $(top_srcdir)/lib/uuid/uuid.h $(srcdir)/e2fsck.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/bitops.h \
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h \
$(srcdir)/problem.h
$(srcdir)/profile.h prof_err.h $(srcdir)/problem.h
pass1.o: $(srcdir)/pass1.c $(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/ext2_fs.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/bitops.h \
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h \
$(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(srcdir)/problem.h
$(srcdir)/profile.h prof_err.h $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h \
$(srcdir)/problem.h
pass1b.o: $(srcdir)/pass1b.c $(top_srcdir)/lib/et/com_err.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/ext2_fs.h $(top_srcdir)/lib/ext2fs/ext2_io.h \
$(top_builddir)/lib/ext2fs/ext2_err.h $(top_srcdir)/lib/ext2fs/bitops.h \
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h \
$(srcdir)/problem.h $(srcdir)/dict.h
$(srcdir)/profile.h prof_err.h $(srcdir)/problem.h $(srcdir)/dict.h
pass2.o: $(srcdir)/pass2.c $(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/ext2_fs.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/bitops.h \
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h \
$(srcdir)/problem.h $(srcdir)/dict.h
$(srcdir)/profile.h prof_err.h $(srcdir)/problem.h $(srcdir)/dict.h
pass3.o: $(srcdir)/pass3.c $(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/ext2_fs.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/bitops.h \
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h \
$(srcdir)/problem.h
$(srcdir)/profile.h prof_err.h $(srcdir)/problem.h
pass4.o: $(srcdir)/pass4.c $(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/ext2_fs.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/bitops.h \
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h \
$(srcdir)/problem.h
$(srcdir)/profile.h prof_err.h $(srcdir)/problem.h
pass5.o: $(srcdir)/pass5.c $(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/ext2_fs.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/bitops.h \
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h \
$(srcdir)/problem.h
$(srcdir)/profile.h prof_err.h $(srcdir)/problem.h
journal.o: $(srcdir)/journal.c $(srcdir)/jfs_user.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/ext2_fs.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/bitops.h \
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h \
$(top_srcdir)/lib/ext2fs/kernel-jbd.h $(top_srcdir)/lib/ext2fs/jfs_compat.h \
$(top_srcdir)/lib/ext2fs/kernel-list.h $(srcdir)/problem.h \
$(top_srcdir)/lib/uuid/uuid.h
$(srcdir)/profile.h prof_err.h $(top_srcdir)/lib/ext2fs/kernel-jbd.h \
$(top_srcdir)/lib/ext2fs/jfs_compat.h $(top_srcdir)/lib/ext2fs/kernel-list.h \
$(srcdir)/problem.h $(top_srcdir)/lib/uuid/uuid.h
recovery.o: $(srcdir)/recovery.c $(srcdir)/jfs_user.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/ext2_fs.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/bitops.h \
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h \
$(top_srcdir)/lib/ext2fs/kernel-jbd.h $(top_srcdir)/lib/ext2fs/jfs_compat.h \
$(top_srcdir)/lib/ext2fs/kernel-list.h
$(srcdir)/profile.h prof_err.h $(top_srcdir)/lib/ext2fs/kernel-jbd.h \
$(top_srcdir)/lib/ext2fs/jfs_compat.h $(top_srcdir)/lib/ext2fs/kernel-list.h
revoke.o: $(srcdir)/revoke.c $(srcdir)/jfs_user.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/ext2_fs.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/bitops.h \
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h \
$(top_srcdir)/lib/ext2fs/kernel-jbd.h $(top_srcdir)/lib/ext2fs/jfs_compat.h \
$(top_srcdir)/lib/ext2fs/kernel-list.h
$(srcdir)/profile.h prof_err.h $(top_srcdir)/lib/ext2fs/kernel-jbd.h \
$(top_srcdir)/lib/ext2fs/jfs_compat.h $(top_srcdir)/lib/ext2fs/kernel-list.h
badblocks.o: $(srcdir)/badblocks.c $(top_srcdir)/lib/et/com_err.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/ext2_fs.h $(top_srcdir)/lib/ext2fs/ext2_io.h \
$(top_builddir)/lib/ext2fs/ext2_err.h $(top_srcdir)/lib/ext2fs/bitops.h \
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h \
$(srcdir)/profile.h prof_err.h
util.o: $(srcdir)/util.c $(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/ext2_fs.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/bitops.h \
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h \
$(srcdir)/profile.h prof_err.h
unix.o: $(srcdir)/unix.c $(top_srcdir)/lib/et/com_err.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/ext2_fs.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/bitops.h \
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h \
$(srcdir)/problem.h $(top_srcdir)/version.h
$(srcdir)/profile.h prof_err.h $(srcdir)/problem.h $(top_srcdir)/version.h
dirinfo.o: $(srcdir)/dirinfo.c $(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/ext2_fs.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/bitops.h \
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h \
$(srcdir)/profile.h prof_err.h
dx_dirinfo.o: $(srcdir)/dx_dirinfo.c $(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/ext2_fs.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/bitops.h \
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h \
$(srcdir)/profile.h prof_err.h
ehandler.o: $(srcdir)/ehandler.c $(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/ext2_fs.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/bitops.h \
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h \
$(srcdir)/profile.h prof_err.h
problem.o: $(srcdir)/problem.c $(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/ext2_fs.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/bitops.h \
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h \
$(srcdir)/problem.h $(srcdir)/problemP.h
$(srcdir)/profile.h prof_err.h $(srcdir)/problem.h $(srcdir)/problemP.h
message.o: $(srcdir)/message.c $(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/ext2_fs.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/bitops.h \
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h \
$(srcdir)/problem.h
$(srcdir)/profile.h prof_err.h $(srcdir)/problem.h
swapfs.o: $(srcdir)/swapfs.c $(top_srcdir)/lib/et/com_err.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/ext2_fs.h $(top_srcdir)/lib/ext2fs/ext2_io.h \
$(top_builddir)/lib/ext2fs/ext2_err.h $(top_srcdir)/lib/ext2fs/bitops.h \
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h \
$(srcdir)/profile.h prof_err.h
ea_refcount.o: $(srcdir)/ea_refcount.c $(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/ext2_fs.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/bitops.h \
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h \
$(srcdir)/profile.h prof_err.h
rehash.o: $(srcdir)/rehash.c $(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/ext2_fs.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/bitops.h \
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h \
$(srcdir)/problem.h
$(srcdir)/profile.h prof_err.h $(srcdir)/problem.h
region.o: $(srcdir)/region.c $(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/ext2_fs.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/bitops.h \
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h
$(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h \
$(srcdir)/profile.h prof_err.h
profile.o: $(srcdir)/profile.c $(top_builddir)/lib/ext2fs/prof_err.h \
$(top_srcdir)/lib/et/com_err.h $(srcdir)/profile.h
prof_err.o: prof_err.c

166
e2fsck/argv_parse.c Normal file
View File

@ -0,0 +1,166 @@
/*
* argv_parse.c --- utility function for parsing a string into a
* argc, argv array.
*
* This file defines a function argv_parse() which parsing a
* passed-in string, handling double quotes and backslashes, and
* creates an allocated argv vector which can be freed using the
* argv_free() function.
*
* See argv_parse.h for the formal definition of the functions.
*
* Copyright 1999 by Theodore Ts'o.
*
* Permission to use, copy, modify, and distribute this software for
* any purpose with or without fee is hereby granted, provided that
* the above copyright notice and this permission notice appear in all
* copies. THE SOFTWARE IS PROVIDED "AS IS" AND THEODORE TS'O (THE
* AUTHOR) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. (Isn't
* it sick that the U.S. culture of lawsuit-happy lawyers requires
* this kind of disclaimer?)
*
* Version 1.1, modified 2/27/1999
*/
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <ctype.h>
#include <string.h>
#include "argv_parse.h"
#define STATE_WHITESPACE 1
#define STATE_TOKEN 2
#define STATE_QUOTED 3
/*
* Returns 0 on success, -1 on failure.
*/
int argv_parse(char *in_buf, int *ret_argc, char ***ret_argv)
{
int argc = 0, max_argc = 0;
char **argv, **new_argv, *buf, ch;
char *cp = 0, *outcp = 0;
int state = STATE_WHITESPACE;
buf = malloc(strlen(in_buf)+1);
if (!buf)
return -1;
max_argc = 0; argc = 0; argv = 0;
outcp = buf;
for (cp = in_buf; (ch = *cp); cp++) {
if (state == STATE_WHITESPACE) {
if (isspace((int) ch))
continue;
/* Not whitespace, so start a new token */
state = STATE_TOKEN;
if (argc >= max_argc) {
max_argc += 3;
new_argv = realloc(argv,
(max_argc+1)*sizeof(char *));
if (!new_argv) {
if (argv) free(argv);
free(buf);
return -1;
}
argv = new_argv;
}
argv[argc++] = outcp;
}
if (state == STATE_QUOTED) {
if (ch == '"')
state = STATE_TOKEN;
else
*outcp++ = ch;
continue;
}
/* Must be processing characters in a word */
if (isspace((int) ch)) {
/*
* Terminate the current word and start
* looking for the beginning of the next word.
*/
*outcp++ = 0;
state = STATE_WHITESPACE;
continue;
}
if (ch == '"') {
state = STATE_QUOTED;
continue;
}
if (ch == '\\') {
ch = *++cp;
switch (ch) {
case '\0':
ch = '\\'; cp--; break;
case 'n':
ch = '\n'; break;
case 't':
ch = '\t'; break;
case 'b':
ch = '\b'; break;
}
}
*outcp++ = ch;
}
if (state != STATE_WHITESPACE)
*outcp++ = '\0';
if (argv == 0) {
argv = malloc(sizeof(char *));
free(buf);
}
argv[argc] = 0;
if (ret_argc)
*ret_argc = argc;
if (ret_argv)
*ret_argv = argv;
return 0;
}
void argv_free(char **argv)
{
if (*argv)
free(*argv);
free(argv);
}
#ifdef DEBUG
/*
* For debugging
*/
#include <stdio.h>
int main(int argc, char **argv)
{
int ac, ret;
char **av, **cpp;
char buf[256];
while (!feof(stdin)) {
if (fgets(buf, sizeof(buf), stdin) == NULL)
break;
ret = argv_parse(buf, &ac, &av);
if (ret != 0) {
printf("Argv_parse returned %d!\n", ret);
continue;
}
printf("Argv_parse returned %d arguments...\n", ac);
for (cpp = av; *cpp; cpp++) {
if (cpp != av)
printf(", ");
printf("'%s'", *cpp);
}
printf("\n");
argv_free(av);
}
exit(0);
}
#endif /* DEBUG */

43
e2fsck/argv_parse.h Normal file
View File

@ -0,0 +1,43 @@
/*
* argv_parse.h --- header file for the argv parser.
*
* This file defines the interface for the functions argv_parse() and
* argv_free().
*
***********************************************************************
* int argv_parse(char *in_buf, int *ret_argc, char ***ret_argv)
*
* This function takes as its first argument a string which it will
* parse into an argv argument vector, with each white-space separated
* word placed into its own slot in the argv. This function handles
* double quotes and backslashes so that the parsed words can contain
* special characters. The count of the number words found in the
* parsed string, as well as the argument vector, are returned into
* ret_argc and ret_argv, respectively.
***********************************************************************
* extern void argv_free(char **argv);
*
* This function frees the argument vector created by argv_parse().
***********************************************************************
*
* Copyright 1999 by Theodore Ts'o.
*
* Permission to use, copy, modify, and distribute this software for
* any purpose with or without fee is hereby granted, provided that
* the above copyright notice and this permission notice appear in all
* copies. THE SOFTWARE IS PROVIDED "AS IS" AND THEODORE TS'O (THE
* AUTHOR) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. (Isn't
* it sick that the U.S. culture of lawsuit-happy lawyers requires
* this kind of disclaimer?)
*
* Version 1.1, modified 2/27/1999
*/
extern int argv_parse(char *in_buf, int *ret_argc, char ***ret_argv);
extern void argv_free(char **argv);

66
e2fsck/prof_err.et Normal file
View File

@ -0,0 +1,66 @@
error_table prof
error_code PROF_VERSION, "Profile version 0.0"
#
# generated by prof_tree.c
#
error_code PROF_MAGIC_NODE, "Bad magic value in profile_node"
error_code PROF_NO_SECTION, "Profile section not found"
error_code PROF_NO_RELATION, "Profile relation not found"
error_code PROF_ADD_NOT_SECTION,
"Attempt to add a relation to node which is not a section"
error_code PROF_SECTION_WITH_VALUE,
"A profile section header has a non-zero value"
error_code PROF_BAD_LINK_LIST, "Bad linked list in profile structures"
error_code PROF_BAD_GROUP_LVL, "Bad group level in profile strctures"
error_code PROF_BAD_PARENT_PTR,
"Bad parent pointer in profile strctures"
error_code PROF_MAGIC_ITERATOR, "Bad magic value in profile iterator"
error_code PROF_SET_SECTION_VALUE, "Can't set value on section node"
error_code PROF_EINVAL, "Invalid argument passed to profile library"
error_code PROF_READ_ONLY, "Attempt to modify read-only profile"
#
# generated by prof_parse.c
#
error_code PROF_SECTION_NOTOP, "Profile section header not at top level"
error_code PROF_SECTION_SYNTAX, "Syntax error in profile section header"
error_code PROF_RELATION_SYNTAX, "Syntax error in profile relation"
error_code PROF_EXTRA_CBRACE, "Extra closing brace in profile"
error_code PROF_MISSING_OBRACE, "Missing open brace in profile"
#
# generated by prof_init.c
#
error_code PROF_MAGIC_PROFILE, "Bad magic value in profile_t"
error_code PROF_MAGIC_SECTION, "Bad magic value in profile_section_t"
error_code PROF_TOPSECTION_ITER_NOSUPP,
"Iteration through all top level section not supported"
error_code PROF_INVALID_SECTION, "Invalid profile_section object"
error_code PROF_END_OF_SECTIONS, "No more sections"
error_code PROF_BAD_NAMESET, "Bad nameset passed to query routine"
error_code PROF_NO_PROFILE, "No profile file open"
#
# generated by prof_file.c
#
error_code PROF_MAGIC_FILE, "Bad magic value in profile_file_t"
error_code PROF_FAIL_OPEN, "Couldn't open profile file"
#
# generated by prof_set.c
#
error_code PROF_EXISTS, "Section already exists"
#
# generated by prof_get.c
#
error_code PROF_BAD_BOOLEAN, "Invalid boolean value"
error_code PROF_BAD_INTEGER, "Invalid integer value"
error_code PROF_MAGIC_FILE_DATA, "Bad magic value in profile_file_data_t"
end

2226
e2fsck/profile.c Normal file

File diff suppressed because it is too large Load Diff

106
e2fsck/profile.h Normal file
View File

@ -0,0 +1,106 @@
/*
* profile.h
*
* Copyright (C) 2005 by Theodore Ts'o.
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Public
* License.
* %End-Header%
*
* Copyright (C) 1985-2005 by the Massachusetts Institute of Technology.
*
* All rights reserved.
*
* Export of this software from the United States of America may require
* a specific license from the United States Government. It is the
* responsibility of any person or organization contemplating export to
* obtain such a license before exporting.
*
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
* distribute this software and its documentation for any purpose and
* without fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright notice and
* this permission notice appear in supporting documentation, and that
* the name of M.I.T. not be used in advertising or publicity pertaining
* to distribution of the software without specific, written prior
* permission. Furthermore if you modify this software you must label
* your software as modified software and not distribute it in such a
* fashion that it might be confused with the original MIT software.
* M.I.T. makes no representations about the suitability of this software
* for any purpose. It is provided "as is" without express or implied
* warranty.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef _PROFILE_H
#define _PROFILE_H
typedef struct _profile_t *profile_t;
/*
* Used by the profile iterator in prof_get.c
*/
#define PROFILE_ITER_LIST_SECTION 0x0001
#define PROFILE_ITER_SECTIONS_ONLY 0x0002
#define PROFILE_ITER_RELATIONS_ONLY 0x0004
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
long profile_init
(const char * *files, profile_t *ret_profile);
long profile_init_path
(const char * filelist, profile_t *ret_profile);
void profile_release
(profile_t profile);
long profile_get_values
(profile_t profile, const char *const *names, char ***ret_values);
void profile_free_list
(char **list);
long profile_get_string
(profile_t profile, const char *name, const char *subname,
const char *subsubname, const char *def_val,
char **ret_string);
long profile_get_integer
(profile_t profile, const char *name, const char *subname,
const char *subsubname, int def_val,
int *ret_default);
long profile_get_boolean
(profile_t profile, const char *name, const char *subname,
const char *subsubname, int def_val,
int *ret_default);
long profile_get_relation_names
(profile_t profile, const char **names, char ***ret_names);
long profile_get_subsection_names
(profile_t profile, const char **names, char ***ret_names);
long profile_iterator_create
(profile_t profile, const char *const *names,
int flags, void **ret_iter);
void profile_iterator_free
(void **iter_p);
long profile_iterator
(void **iter_p, char **ret_name, char **ret_value);
void profile_release_string (char *str);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _KRB5_H */