diff options
author | Guido Guenther <agx@sigxcpu.org> | 2006-11-18 23:48:07 +0100 |
---|---|---|
committer | Guido Guenther <agx@bogon.sigxcpu.org> | 2006-11-18 23:48:07 +0100 |
commit | d1e063beb43e595680c65e3804d1f8ddff53373b (patch) | |
tree | f7256dfe1b807920270ec5113df6f6e4abf1ed0f /e2fslib/et |
Imported Debian version 0.3.8.80.3.8.8
Diffstat (limited to 'e2fslib/et')
-rw-r--r-- | e2fslib/et/.cvsignore | 1 | ||||
-rw-r--r-- | e2fslib/et/ChangeLog | 210 | ||||
-rw-r--r-- | e2fslib/et/Makefile | 334 | ||||
-rw-r--r-- | e2fslib/et/Makefile.in | 129 | ||||
-rw-r--r-- | e2fslib/et/com_err.c | 120 | ||||
-rw-r--r-- | e2fslib/et/com_err.h | 40 | ||||
-rw-r--r-- | e2fslib/et/com_err.o | bin | 0 -> 7844 bytes | |||
-rw-r--r-- | e2fslib/et/com_err.texinfo | 579 | ||||
-rwxr-xr-x | e2fslib/et/compile_et | 31 | ||||
-rw-r--r-- | e2fslib/et/compile_et.sh.in | 31 | ||||
-rw-r--r-- | e2fslib/et/error_message.c | 88 | ||||
-rw-r--r-- | e2fslib/et/error_message.o | bin | 0 -> 6312 bytes | |||
-rw-r--r-- | e2fslib/et/error_table.h | 42 | ||||
-rw-r--r-- | e2fslib/et/et_c.awk | 187 | ||||
-rw-r--r-- | e2fslib/et/et_h.awk | 159 | ||||
-rw-r--r-- | e2fslib/et/et_name.c | 43 | ||||
-rw-r--r-- | e2fslib/et/et_name.o | bin | 0 -> 3192 bytes | |||
-rw-r--r-- | e2fslib/et/init_et.c | 63 | ||||
-rw-r--r-- | e2fslib/et/init_et.o | bin | 0 -> 5184 bytes | |||
-rw-r--r-- | e2fslib/et/internal.h | 30 | ||||
-rw-r--r-- | e2fslib/et/libcom_err.a | bin | 0 -> 23006 bytes | |||
-rw-r--r-- | e2fslib/et/vfprintf.c | 49 |
22 files changed, 2136 insertions, 0 deletions
diff --git a/e2fslib/et/.cvsignore b/e2fslib/et/.cvsignore new file mode 100644 index 0000000..8526e03 --- /dev/null +++ b/e2fslib/et/.cvsignore @@ -0,0 +1 @@ +compile_et diff --git a/e2fslib/et/ChangeLog b/e2fslib/et/ChangeLog new file mode 100644 index 0000000..a8fec3c --- /dev/null +++ b/e2fslib/et/ChangeLog @@ -0,0 +1,210 @@ +2001-09-20 Theodore Tso <tytso@thunk.org> + + * Release of E2fsprogs 1.25 + +2001-09-16 Theodore Tso <tytso@valinux.com> + + * compile_et.sh.in: Make the shell script safe from directory + pathnames with spaces. + +2001-09-10 Theodore Tso <tytso@valinux.com> + + * com_err.texinfo: Add appropriate @node and @menu lines so that + the a valid .info file can be made. Use @deftypefun to + define functions. Change the e-mail address where bug + reports to be sent to be is the e2fsprogs maintainer. + +2001-09-02 Theodore Tso <tytso@thunk.org> + + * Release of E2fsprogs 1.24a + +2001-08-30 Theodore Tso <tytso@thunk.org> + + * Release of E2fsprogs 1.24 + +2001-08-15 Theodore Tso <tytso@valinux.com> + + * Release of E2fsprogs 1.23 + +2001-06-23 Theodore Tso <tytso@valinux.com> + + * Release of E2fsprogs 1.22 + +2001-06-15 Theodore Tso <tytso@valinux.com> + + * Release of E2fsprogs 1.21 + +2001-05-25 Theodore Tso <tytso@valinux.com> + + * Release of E2fsprogs 1.20 + +2000-12-04 <tytso@snap.thunk.org> + + * compile_et.1: Fix simple typo in the man page. + +2000-07-13 <tytso@valinux.com> + + * Release of E2fsprogs 1.19 + +2000-07-04 Theodore Ts'o <tytso@valinux.com> + + * Makefile.in: Remove explicit link of -lc in the shared library. + (It shouldn't be necessary, and is harmful in some cases). + +1999-11-19 <tytso@valinux.com> + + * Makefile.in (distclean): Remove TAGS and Makefile.in.old from + the source directory. + +1999-11-10 <tytso@valinux.com> + + * Release of E2fsprogs 1.18 + +1999-10-26 <tytso@valinux.com> + + * Release of E2fsprogs 1.17 + +1999-10-22 <tytso@valinux.com> + + * Release of E2fsprogs 1.16 + +1999-10-22 <tytso@valinux.com> + + * com_err.3: Fix to have correct #include path for com_err.h + +1999-09-07 <tytso@rsts-11.mit.edu> + + * Updated copyright statements with permission of the original + authors. + +1999-07-18 Theodore Ts'o <tytso@rsts-11.mit.edu> + + * Release of E2fsprogs 1.15 + +1999-01-09 Theodore Ts'o <tytso@rsts-11.mit.edu> + + * Release of E2fsprogs 1.14 + +1998-12-15 Theodore Ts'o <tytso@rsts-11.mit.edu> + + * Release of E2fsprogs 1.13 + +1998-07-09 Theodore Ts'o <tytso@rsts-11.mit.edu> + + * Release of E2fsprogs 1.12 + +1998-06-27 Theodore Ts'o <tytso@rsts-11.mit.edu> + + * et_h.awk, et_c.awk: Work around libm bug on the ARM. + +1998-03-30 Theodore Ts'o <tytso@rsts-11.mit.edu> + + * Makefile.in: Fix bug where my_dir was set incorrectly. Install + the et_c.awk and et_h.awk files in $(datadir)/et (i.e., + /usr/share/et) directory. Change to use new + installation directory variables convention. Fix + uninstall rules to take $(DESTDIR) into account. + + * compile_et.1: Change man page to reflect the fact that + compile_et is now a awk/sed script, not a yacc script. + + * compile_et.sh.in: Look in $(datadir)/et for et_c.awk and + et_h.awk; if not found, look in the build directory. Add + error checking for non-existent input file. + +Fri Oct 31 01:14:41 1997 Theodore Ts'o <tytso@rsts-11.mit.edu> + + * et_c.awk, et_h.awk: Remove support for non STDC compilers, since + the workarounds caused problems with the header file. + +Sun Aug 10 09:40:54 1997 Theodore Ts'o <tytso@rsts-11.mit.edu> + + * error_table.h: + * et_name.c (error_table_name): + * error_message.c (error_message.c): Make code be 16-bit safe. + +Tue Jun 17 01:33:20 1997 Theodore Ts'o <tytso@rsts-11.mit.edu> + + * Release of E2fsprogs 1.11 + +Thu Apr 24 12:16:42 1997 Theodre Ts'o <tytso@localhost.mit.edu> + + * Release of E2fsprogs version 1.10 + +Thu Apr 17 12:23:38 1997 Theodore Ts'o <tytso@rsts-11.mit.edu> + + * Release of E2fsprogs version 1.09 + +Fri Apr 11 18:56:26 1997 Theodore Ts'o <tytso@rsts-11.mit.edu> + + * Release of E2fsprogs version 1.08 + +Wed Mar 12 13:32:05 1997 Theodore Y. Ts'o <tytso@mit.edu> + + * Release of E2fsprogs version 1.07 + +Tue Oct 8 02:02:03 1996 Theodore Ts'o <tytso@rsts-11.mit.edu> + + * Release of E2fsprogs version 1.06 + +Thu Sep 12 15:23:07 1996 Theodore Ts'o <tytso@rsts-11.mit.edu> + + * Release of E2fsprogs version 1.05 + +Thu May 16 11:12:30 1996 Theodore Ts'o <tytso@rsts-11.mit.edu> + + * Release of E2fsprogs version 1.04 + +Wed Mar 27 00:33:40 1996 <tytso@rsts-11.mit.edu> + + * Release of E2fsprogs version 1.03 + +Wed Jan 31 11:06:08 1996 <tytso@rsts-11.mit.edu> + + * Release of E2fsprogs version 1.02 + +Mon Sep 4 21:44:47 1995 Remy Card <card@bbj> + + * Makefile.in: Added support for BSD shared libraries. + +Sat Aug 12 03:11:28 1995 Remy Card <card@bbj> + + * Makefile.in (install): Install static libraries in $(ulibdir) + (/usr/lib on Linux) instead of $(libdir) (/lib on Linux). + +Sat Aug 5 11:44:17 1995 Theodore Y. Ts'o <tytso@lurch.mit.edu> + + * Makefile.in (DLL_INSTALL_DIR, ELF_INSTALL_DIR): Set the + installation directories correctly. + +Thu Jun 15 23:39:51 1995 Remy Card <card@bbj> + + * Makefile.in: Added support for ELF shared libraries. + Fixed typos in the compilation rules. + (distclean): Added compile_et.sh. + +Sat Jun 10 19:56:13 1995 Theodore Y. Ts'o <tytso@lurch.mit.edu> + + * compile_et.sh.in: Use ET_DIR instead of srcdir to determine the + location of the et directory. + +Thu Jun 8 12:45:41 1995 Miles Bader <miles@churchy.gnu.ai.mit.edu> + + * vfprintf.c (vfprintf): Only compile this function if vfprintf + doesn't already exist and _doprnt does. + + * compile_et.sh: Moved to compile_et.sh.in. + + * Makefile.in: Rewritten to conform to GNU coding standards and + support separate compilation directories. + Don't preprocess compile_et.sh, as this is now done by configure. + +Mon Nov 7 21:17:48 1994 Remy Card <card@bbj> + + * Makefile: Added a dummy install target in case shared libraries + are not built. + +Thu Sep 8 22:33:33 1994 (tytso@rsx-11) + + * com_err.c (default_com_err_proc): Reversed order of \n\r to make + jik happy. diff --git a/e2fslib/et/Makefile b/e2fslib/et/Makefile new file mode 100644 index 0000000..79b6ca7 --- /dev/null +++ b/e2fslib/et/Makefile @@ -0,0 +1,334 @@ +# Generated automatically from Makefile.in by configure. +# +# Makefile for lib/et +# + +srcdir = . +top_srcdir = ../.. +top_builddir = ../.. +my_dir = lib/et +INSTALL = /usr/bin/install -c + +DEP_MAKEFILE = $(DEP_LIB_MAKEFILES) + + +# Beginning of file MCONFIG + +all:: + +check:: + +SHELL = /bin/sh + +prefix = /usr +root_prefix = +exec_prefix = ${prefix} +root_bindir = $(root_prefix)/bin +root_sbindir = $(root_prefix)/sbin +root_libdir = $(root_prefix)/lib +bindir = ${exec_prefix}/bin +sbindir = ${exec_prefix}/sbin +libdir = ${exec_prefix}/lib +includedir = ${prefix}/include +mandir = ${prefix}/man +man1dir = $(mandir)/man1 +man3dir = $(mandir)/man3 +man8dir = $(mandir)/man8 +infodir = ${prefix}/info +datadir = ${prefix}/share + + + +INSTALL_PROGRAM = ${INSTALL} +INSTALL_DATA = ${INSTALL} -m 644 +CC = cc +BUILD_CC = cc +DEFS = -DENABLE_SWAPFS=1 -DPACKAGE=\"e2fsprogs\" -DVERSION=\"1.25\" -DSTDC_HEADERS=1 -DHAVE_ALLOCA_H=1 -DHAVE_ALLOCA=1 -DHAVE_UNISTD_H=1 -DHAVE_GETPAGESIZE=1 -DHAVE_MMAP=1 -DHAVE_ARGZ_H=1 -DHAVE_LIMITS_H=1 -DHAVE_LOCALE_H=1 -DHAVE_NL_TYPES_H=1 -DHAVE_MALLOC_H=1 -DHAVE_STRING_H=1 -DHAVE_UNISTD_H=1 -DHAVE_SYS_PARAM_H=1 -DHAVE_GETCWD=1 -DHAVE_MUNMAP=1 -DHAVE_PUTENV=1 -DHAVE_SETENV=1 -DHAVE_SETLOCALE=1 -DHAVE_STRCHR=1 -DHAVE_STRCASECMP=1 -DHAVE_STRDUP=1 -DHAVE___ARGZ_COUNT=1 -DHAVE___ARGZ_STRINGIFY=1 -DHAVE___ARGZ_NEXT=1 -DHAVE_STPCPY=1 -DHAVE_STPCPY=1 -DHAVE_LC_MESSAGES=1 -DHAVE_STDLIB_H=1 -DHAVE_UNISTD_H=1 -DHAVE_STDARG_H=1 -DHAVE_ERRNO_H=1 -DHAVE_MALLOC_H=1 -DHAVE_MNTENT_H=1 -DHAVE_PATHS_H=1 -DHAVE_DIRENT_H=1 -DHAVE_GETOPT_H=1 -DHAVE_SETJMP_H=1 -DHAVE_SIGNAL_H=1 -DHAVE_TERMIOS_H=1 -DHAVE_LINUX_FD_H=1 -DHAVE_LINUX_MAJOR_H=1 -DHAVE_SYS_IOCTL_H=1 -DHAVE_SYS_MOUNT_H=1 -DHAVE_SYS_SYSMACROS_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_NET_IF_H=1 -DHAVE_NETINET_IN_H=1 -DHAVE_VPRINTF=1 -DHAVE_LSEEK64_PROTOTYPE=1 -DSIZEOF_SHORT=2 -DSIZEOF_INT=4 -DSIZEOF_LONG=4 -DSIZEOF_LONG_LONG=8 -DWORDS_BIGENDIAN=1 -DHAVE_GETRUSAGE=1 -DHAVE_LLSEEK=1 -DHAVE_LSEEK64=1 -DHAVE_OPEN64=1 -DHAVE_STRCASECMP=1 -DHAVE_SRANDOM=1 -DHAVE_FCHOWN=1 -DHAVE_MALLINFO=1 -DHAVE_FDATASYNC=1 -DHAVE_STRNLEN=1 -DHAVE_EXT2_IOCTLS=1 +CFLAGS = -g -O2 +CPPFLAGS = +ALL_CFLAGS = $(CPPFLAGS) $(DEFS) $(USE_WFLAGS) $(CFLAGS) $(XTRA_CFLAGS) \ + -I$(top_builddir)/lib -I$(top_srcdir)/lib \ + -I$(top_srcdir)/include $(LINUX_INCLUDE) +LDFLAGS = +ALL_LDFLAGS = $(LDFLAGS) +RM = /bin/rm +LN = /bin/ln +LN_S = ln -s +MV = /bin/mv +CP = /bin/cp +CHMOD = /bin/chmod +AR = ar +AWK = /usr/bin/awk +SED = /bin/sed +PERL = /usr/bin/perl +RANLIB = ranlib +STRIP = strip +LD = $(PURE) cc +ARUPD = $(AR) r +LDCONFIG = : + +# +# Library definitions +# +LIB = $(top_builddir)/lib +LIBSS = $(LIB)/libss.a +LIBCOM_ERR = $(LIB)/libcom_err.a +LIBE2P = $(LIB)/libe2p.a +LIBEXT2FS = $(LIB)/libext2fs.a +LIBUUID = $(LIB)/libuuid.a +DEPLIBUUID = $(LIB)/libuuid.a + +STATIC_LIBSS = $(LIB)/libss.a +STATIC_LIBCOM_ERR = $(LIB)/libcom_err.a +STATIC_LIBE2P = $(LIB)/libe2p.a +STATIC_LIBEXT2FS = $(LIB)/libext2fs.a +STATIC_LIBUUID = $(LIB)/libuuid.a +DEPSTATIC_LIBUUID = $(LIB)/libuuid.a + +PROFILED_LIBSS = $(LIB)/libss +PROFILED_LIBCOM_ERR = $(LIB)/libcom_err +PROFILED_LIBE2P = $(LIB)/libe2p +PROFILED_LIBEXT2FS = $(LIB)/libext2fs +PROFILED_LIBUUID = $(LIB)/libuuid +DEPPROFILED_LIBUUID = $(LIB)/libuuid + +# +# Use these definitions is you use tools 2.x, x < 16 +# +#DLL_BIN=/usr/dll/bin +#JUMP_PREFIX=/usr/dll/jump/ + +# +# Use these definitions if you use tools 2.16 or above +# +DLL_BIN=/usr/bin +JUMP_PREFIX=/usr/bin/jump + +# An include directive pointing to a directory holding enough linux-like +# include files to satisfy some programs here +LINUX_INCLUDE= + +# +# A fast substitution command for fixing up man pages, shell scripts, etc. +# +SUBST_CONF=../util/subst.conf +SUBSTITUTE= ../util/subst -f $(SUBST_CONF) +DEP_SUBSTITUTE= ../util/subst $(SUBST_CONF) + +$(top_builddir)/util/subst: + cd $(top_builddir)/util ; $(MAKE) subst + +# +# Warning flags +# +# Run make gcc-wall to do a build with warning messages. +# +# +WFLAGS= -ansi -D_POSIX_SOURCE -pedantic \ + -Wall -Wwrite-strings -Wpointer-arith \ + -Wcast-qual -Wcast-align -Wtraditional \ + -Wstrict-prototypes -Wmissing-prototypes \ + -Wnested-externs -Winline -DNO_INLINE_FUNCS -Wshadow + +gcc-wall-new: + (make USE_WFLAGS="$(WFLAGS)" > /dev/null) 2>&1 | sed -f $(top_srcdir)/util/gcc-wall-cleanup + +gcc-wall: + make clean > /dev/null + make gcc-wall-new + +# +# Installation user and groups +# +BINGRP= bin +BINOWN= bin +BINMODE= 555 +INCGRP= bin +INCOWN= bin +INCMODE= 444 +LIBOWN= bin +LIBGRP= bin +LIBMODE= 444 +MANGRP= bin +MANOWN= bin +MANMODE= 444 + +# +# Autoconf magic... +# + +DEP_LIB_MAKEFILES = $(top_srcdir)/lib/Makefile.elf-lib \ + $(top_srcdir)/lib/Makefile.dll-lib $(top_srcdir)/lib/Makefile.bsd-lib \ + $(top_srcdir)/lib/Makefile.checker $(top_srcdir)/lib/Makefile.profile + +$(top_builddir)/config.status: $(top_srcdir)/configure + cd $(top_builddir); ./config.status --recheck + +$(top_builddir)/lib/substitute_sh: $(top_srcdir)/lib/substitute_sh.in \ + $(top_builddir)/config.status + cd $(top_builddir); CONFIG_FILES=lib/substitute_sh ./config.status + +$(top_builddir)/util/subst.conf: $(top_srcdir)/util/subst.conf.in \ + $(top_builddir)/config.status + cd $(top_builddir); CONFIG_FILES=util/subst.conf ./config.status + +$(top_srcdir)/configure: $(top_srcdir)/configure.in + cd $(top_srcdir) && autoconf + +# +# Make depend magic... +# + +.depend: Makefile $(SRCS) $(top_srcdir)/depfix.sed $(top_srcdir)/wordwrap.pl + if test -n "$(SRCS)" ; then \ + $(CC) -M $(ALL_CFLAGS) $(SRCS) | \ + $(SED) -f $(top_srcdir)/depfix.sed \ + -e 's; $(srcdir)/; $$(srcdir)/;g' \ + -e 's; $(top_srcdir)/; $$(top_srcdir)/;g' \ + -e 's; $(top_builddir)/; $$(top_builddir)/;g' \ + -e 's; \./; ;g' \ + -e '/^ *\\$$/d' | \ + $(PERL) $(top_srcdir)/wordwrap.pl > .depend; \ + else :; fi + +depend:: .depend + if test -n "$(SRCS)" ; then \ + sed -e '/^# +++ Dependency line eater +++/,$$d' \ + < $(srcdir)/Makefile.in | cat - .depend \ + > $(srcdir)/Makefile.in.new; \ + if cmp -s $(srcdir)/Makefile.in $(srcdir)/Makefile.in.new ; then \ + $(RM) $(srcdir)/Makefile.in.new ; \ + else \ + $(MV) $(srcdir)/Makefile.in $(srcdir)/Makefile.in.old; \ + $(MV) $(srcdir)/Makefile.in.new $(srcdir)/Makefile.in; \ + fi ; else :; fi + +# End of file MCONFIG + +all:: compile_et + +OBJS= error_message.o et_name.o init_et.o com_err.o +SRCS = $(srcdir)/error_message.c $(srcdir)/et_name.c $(srcdir)/init_et.c \ + $(srcdir)/com_err.c + +HFILES= com_err.h +SHARE_FILES= et_c.awk et_h.awk + +LIBRARY= libcom_err +LIBDIR= et + +DLL_ADDRESS = 0x66800000 +DLL_JUMPSIZE = 0x1000 +DLL_GOTSIZE = 0x1000 +DLL_VERSION = 1.0 +DLL_IMAGE = libet +DLL_STUB = libcom_err +DLL_MYDIR = et +DLL_INSTALL_DIR = $(root_libdir) + +ELF_VERSION = 2.0 +ELF_SO_VERSION = 2 +ELF_IMAGE = libcom_err +ELF_MYDIR = et +ELF_INSTALL_DIR = $(root_libdir) +ELF_OTHER_LIBS = + +BSDLIB_VERSION = 1.0 +BSDLIB_IMAGE = libcom_err +BSDLIB_MYDIR = et +BSDLIB_INSTALL_DIR = $(root_libdir) + +# +# what to build... +# +.c.o: + $(CC) $(ALL_CFLAGS) -c $< -o $@ +# $(CC) $(ALL_CFLAGS) -g -pg -o profiled/$*.o -c $< +# $(CC) $(ALL_CFLAGS) -checker -g -o checker/$*.o -c $< +# (export JUMP_DIR=`pwd`/jump; $(CC) -B$(JUMP_PREFIX) $(ALL_CFLAGS) \ +# -o jump/$*.o -c $<) +# $(CC) $(ALL_CFLAGS) -fPIC -o elfshared/$*.o -c $< +# $(CC) $(ALL_CFLAGS) -fpic -o pic/$*.o -c $< + + +all:: subdirs $(LIBRARY).a + +install-shlibs:: + +subdirs:: + +$(LIBRARY).a: $(OBJS) + (if test -r $@; then $(RM) -f $@.bak && $(MV) $@ $@.bak; fi) + $(ARUPD) $@ $(OBJS) + -$(RANLIB) $@ + $(RM) -f ../$@ + $(LN) $@ ../$@ + + + + + + + +compile_et: $(DEP_SUBSTITUTE) $(srcdir)/compile_et.sh.in + $(SUBSTITUTE) $(srcdir)/compile_et.sh.in compile_et + $(CHMOD) +x compile_et + +com_err.ps : com_err.dvi +com_err.dvi: com_err.texinfo + +#libcom_err.o: $(LIBOBJS) +# $(LD) -r -s -o libcom_err.o $(LIBOBJS) +# chmod -x libcom_err.o + +TAGS: $(SRCS) + $(TAGS) $(SRCS) + +installdirs:: + $(top_srcdir)/mkinstalldirs $(DESTDIR)$(libdir) \ + $(DESTDIR)$(includedir)/et $(DESTDIR)$(datadir)/et \ + $(DESTDIR)$(bindir) $(DESTDIR)$(man1dir) \ + $(DESTDIR)$(man3dir) + +install:: compile_et libcom_err.a $(HFILES) installdirs + $(INSTALL_DATA) libcom_err.a $(DESTDIR)$(libdir)/libcom_err.a + $(CHMOD) 644 $(DESTDIR)$(libdir)/libcom_err.a + -$(RANLIB) $(DESTDIR)$(libdir)/libcom_err.a + $(CHMOD) $(LIBMODE) $(DESTDIR)$(libdir)/libcom_err.a + for i in $(HFILES); do \ + $(INSTALL_DATA) $(srcdir)/$$i $(DESTDIR)$(includedir)/et/$$i; \ + done + for i in $(SHARE_FILES); do \ + $(INSTALL_DATA) $(srcdir)/$$i $(DESTDIR)$(datadir)/et/$$i; \ + done + $(INSTALL) compile_et $(DESTDIR)$(bindir)/compile_et + $(INSTALL_DATA) $(srcdir)/com_err.3 $(DESTDIR)$(man3dir)/com_err.3 + $(INSTALL_DATA) $(srcdir)/compile_et.1 \ + $(DESTDIR)$(man1dir)/compile_et.1 + +uninstall:: + $(RM) -f $(DESTDIR)$(libdir)/libcom_err.a \ + $(DESTDIR)$(bindir)/compile_et + $(RM) -rf $(DESTDIR)$(includedir)/et $(DESTDIR)$(datadir)/et + +clean:: + $(RM) -f compile_et libcom_err.a libcom_err_p.a + $(RM) -f $(OBJS) profiled/* + $(RM) -f *~ \#* *.bak *.otl *.aux *.toc *.PS *.dvi *.ps TAGS *.ln + $(RM) -f ../libcom_err.a ../libcom_err_p.a +mostlyclean:: clean +distclean:: clean + $(RM) -f .depend Makefile $(srcdir)/TAGS $(srcdir)/Makefile.in.old + +# +++ Dependency line eater +++ +# +# Makefile dependencies follow. This must be the last section in +# the Makefile.in file +# +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 $(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 diff --git a/e2fslib/et/Makefile.in b/e2fslib/et/Makefile.in new file mode 100644 index 0000000..4a9e538 --- /dev/null +++ b/e2fslib/et/Makefile.in @@ -0,0 +1,129 @@ +# +# Makefile for lib/et +# + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +top_builddir = ../.. +my_dir = lib/et +INSTALL = @INSTALL@ + +DEP_MAKEFILE = $(DEP_LIB_MAKEFILES) + +@MCONFIG@ + +all:: compile_et + +OBJS= error_message.o et_name.o init_et.o com_err.o +SRCS = $(srcdir)/error_message.c $(srcdir)/et_name.c $(srcdir)/init_et.c \ + $(srcdir)/com_err.c + +HFILES= com_err.h +SHARE_FILES= et_c.awk et_h.awk + +LIBRARY= libcom_err +LIBDIR= et + +DLL_ADDRESS = 0x66800000 +DLL_JUMPSIZE = 0x1000 +DLL_GOTSIZE = 0x1000 +DLL_VERSION = 1.0 +DLL_IMAGE = libet +DLL_STUB = libcom_err +DLL_MYDIR = et +DLL_INSTALL_DIR = $(root_libdir) + +ELF_VERSION = 2.0 +ELF_SO_VERSION = 2 +ELF_IMAGE = libcom_err +ELF_MYDIR = et +ELF_INSTALL_DIR = $(root_libdir) +ELF_OTHER_LIBS = + +BSDLIB_VERSION = 1.0 +BSDLIB_IMAGE = libcom_err +BSDLIB_MYDIR = et +BSDLIB_INSTALL_DIR = $(root_libdir) + +# +# what to build... +# +.c.o: + $(CC) $(ALL_CFLAGS) -c $< -o $@ +@PROFILE_CMT@ $(CC) $(ALL_CFLAGS) -g -pg -o profiled/$*.o -c $< +@CHECKER_CMT@ $(CC) $(ALL_CFLAGS) -checker -g -o checker/$*.o -c $< +@DLL_CMT@ (export JUMP_DIR=`pwd`/jump; $(CC) -B$(JUMP_PREFIX) $(ALL_CFLAGS) \ +@DLL_CMT@ -o jump/$*.o -c $<) +@ELF_CMT@ $(CC) $(ALL_CFLAGS) -fPIC -o elfshared/$*.o -c $< +@BSDLIB_CMT@ $(CC) $(ALL_CFLAGS) -fpic -o pic/$*.o -c $< + +@MAKEFILE_LIBRARY@ +@MAKEFILE_DLL@ +@MAKEFILE_ELF@ +@MAKEFILE_BSDLIB@ +@MAKEFILE_PROFILE@ +@MAKEFILE_CHECKER@ + +compile_et: $(DEP_SUBSTITUTE) $(srcdir)/compile_et.sh.in + $(SUBSTITUTE) $(srcdir)/compile_et.sh.in compile_et + $(CHMOD) +x compile_et + +com_err.ps : com_err.dvi +com_err.dvi: com_err.texinfo + +#libcom_err.o: $(LIBOBJS) +# $(LD) -r -s -o libcom_err.o $(LIBOBJS) +# chmod -x libcom_err.o + +TAGS: $(SRCS) + $(TAGS) $(SRCS) + +installdirs:: + $(top_srcdir)/mkinstalldirs $(DESTDIR)$(libdir) \ + $(DESTDIR)$(includedir)/et $(DESTDIR)$(datadir)/et \ + $(DESTDIR)$(bindir) $(DESTDIR)$(man1dir) \ + $(DESTDIR)$(man3dir) + +install:: compile_et libcom_err.a $(HFILES) installdirs + $(INSTALL_DATA) libcom_err.a $(DESTDIR)$(libdir)/libcom_err.a + $(CHMOD) 644 $(DESTDIR)$(libdir)/libcom_err.a + -$(RANLIB) $(DESTDIR)$(libdir)/libcom_err.a + $(CHMOD) $(LIBMODE) $(DESTDIR)$(libdir)/libcom_err.a + for i in $(HFILES); do \ + $(INSTALL_DATA) $(srcdir)/$$i $(DESTDIR)$(includedir)/et/$$i; \ + done + for i in $(SHARE_FILES); do \ + $(INSTALL_DATA) $(srcdir)/$$i $(DESTDIR)$(datadir)/et/$$i; \ + done + $(INSTALL) compile_et $(DESTDIR)$(bindir)/compile_et + $(INSTALL_DATA) $(srcdir)/com_err.3 $(DESTDIR)$(man3dir)/com_err.3 + $(INSTALL_DATA) $(srcdir)/compile_et.1 \ + $(DESTDIR)$(man1dir)/compile_et.1 + +uninstall:: + $(RM) -f $(DESTDIR)$(libdir)/libcom_err.a \ + $(DESTDIR)$(bindir)/compile_et + $(RM) -rf $(DESTDIR)$(includedir)/et $(DESTDIR)$(datadir)/et + +clean:: + $(RM) -f compile_et libcom_err.a libcom_err_p.a + $(RM) -f $(OBJS) profiled/* + $(RM) -f *~ \#* *.bak *.otl *.aux *.toc *.PS *.dvi *.ps TAGS *.ln + $(RM) -f ../libcom_err.a ../libcom_err_p.a +mostlyclean:: clean +distclean:: clean + $(RM) -f .depend Makefile $(srcdir)/TAGS $(srcdir)/Makefile.in.old + +# +++ Dependency line eater +++ +# +# Makefile dependencies follow. This must be the last section in +# the Makefile.in file +# +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 $(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 diff --git a/e2fslib/et/com_err.c b/e2fslib/et/com_err.c new file mode 100644 index 0000000..81a70cf --- /dev/null +++ b/e2fslib/et/com_err.c @@ -0,0 +1,120 @@ +/* + * Copyright 1987, 1988 by MIT Student Information Processing Board. + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose is hereby granted, provided that + * the names of M.I.T. and the M.I.T. S.I.P.B. not be used in + * advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. M.I.T. and the + * M.I.T. S.I.P.B. make no representations about the suitability of + * this software for any purpose. It is provided "as is" without + * express or implied warranty. + */ + +#include <stdio.h> +#include "com_err.h" +#include "error_table.h" +#include "internal.h" + +#if !defined(__STDC__) && !defined(STDARG_PROTOTYPES) +#include <varargs.h> +#define VARARGS +#endif + +static void +#ifdef __STDC__ + default_com_err_proc (const char *whoami, errcode_t code, const + char *fmt, va_list args) +#else + default_com_err_proc (whoami, code, fmt, args) + const char *whoami; + errcode_t code; + const char *fmt; + va_list args; +#endif +{ + if (whoami) { + fputs(whoami, stderr); + fputs(": ", stderr); + } + if (code) { + fputs(error_message(code), stderr); + fputs(" ", stderr); + } + if (fmt) { + vfprintf (stderr, fmt, args); + } + /* should do this only on a tty in raw mode */ + putc('\r', stderr); + putc('\n', stderr); + fflush(stderr); +} + +#ifdef __STDC__ +typedef void (*errf) (const char *, errcode_t, const char *, va_list); +#else +typedef void (*errf) (); +#endif + +errf com_err_hook = default_com_err_proc; + +#ifdef __STDC__ +void com_err_va (const char *whoami, errcode_t code, const char *fmt, + va_list args) +#else +void com_err_va (whoami, code, fmt, args) + const char *whoami; + errcode_t code; + const char *fmt; + va_list args; +#endif +{ + (*com_err_hook) (whoami, code, fmt, args); +} + +#ifndef VARARGS +void com_err (const char *whoami, + errcode_t code, + const char *fmt, ...) +{ +#else +void com_err (va_alist) + va_dcl +{ + const char *whoami, *fmt; + errcode_t code; +#endif + va_list pvar; + + if (!com_err_hook) + com_err_hook = default_com_err_proc; +#ifdef VARARGS + va_start (pvar); + whoami = va_arg (pvar, const char *); + code = va_arg (pvar, errcode_t); + fmt = va_arg (pvar, const char *); +#else + va_start(pvar, fmt); +#endif + com_err_va (whoami, code, fmt, pvar); + va_end(pvar); +} + +errf set_com_err_hook (new_proc) + errf new_proc; +{ + errf x = com_err_hook; + + if (new_proc) + com_err_hook = new_proc; + else + com_err_hook = default_com_err_proc; + + return x; +} + +errf reset_com_err_hook () { + errf x = com_err_hook; + com_err_hook = default_com_err_proc; + return x; +} diff --git a/e2fslib/et/com_err.h b/e2fslib/et/com_err.h new file mode 100644 index 0000000..f28dce8 --- /dev/null +++ b/e2fslib/et/com_err.h @@ -0,0 +1,40 @@ +/* + * Header file for common error description library. + * + * Copyright 1988, Student Information Processing Board of the + * Massachusetts Institute of Technology. + * + * For copyright and distribution info, see the documentation supplied + * with this package. + */ + +#ifndef __COM_ERR_H + +typedef long errcode_t; + +#ifdef __STDC__ +#include <stdarg.h> + +/* ANSI C -- use prototypes etc */ +void com_err (const char *, long, const char *, ...); +void com_err_va (const char *whoami, errcode_t code, const char *fmt, + va_list args); +char const *error_message (long); +extern void (*com_err_hook) (const char *, long, const char *, va_list); +void (*set_com_err_hook (void (*) (const char *, long, const char *, va_list))) + (const char *, long, const char *, va_list); +void (*reset_com_err_hook (void)) (const char *, long, const char *, va_list); +int init_error_table(const char * const *msgs, int base, int count); +#else +/* no prototypes */ +void com_err (); +void com_err_va (); +char *error_message (); +extern void (*com_err_hook) (); +void (*set_com_err_hook ()) (); +void (*reset_com_err_hook ()) (); +int init_error_table(); +#endif + +#define __COM_ERR_H +#endif /* ! defined(__COM_ERR_H) */ diff --git a/e2fslib/et/com_err.o b/e2fslib/et/com_err.o Binary files differnew file mode 100644 index 0000000..f851d2d --- /dev/null +++ b/e2fslib/et/com_err.o diff --git a/e2fslib/et/com_err.texinfo b/e2fslib/et/com_err.texinfo new file mode 100644 index 0000000..6ca745d --- /dev/null +++ b/e2fslib/et/com_err.texinfo @@ -0,0 +1,579 @@ +\input texinfo @c -*-texinfo-*- + +@c $Header: /home/cvs/arcboot/e2fslib/et/com_err.texinfo,v 1.1 2004/11/29 10:39:38 ladis Exp $ +@c $Source: /home/cvs/arcboot/e2fslib/et/com_err.texinfo,v $ +@c $Locker: $ + +@c Note that although this source file is in texinfo format (more +@c or less), it is not yet suitable for turning into an ``info'' +@c file. Sorry, maybe next time. +@c +@c In order to produce hardcopy documentation from a texinfo file, +@c run ``tex com_err.texinfo'' which will load in texinfo.tex, +@c provided in this distribution. (texinfo.tex is from the Free +@c Software Foundation, and is under different copyright restrictions +@c from the rest of this package.) + +@setfilename com_err +@settitle A Common Error Description Library for UNIX + +@ifinfo +@dircategory Development +@format +START-INFO-DIR-ENTRY +* com_err: (com_err.info). A Common Error Description Library for UNIX. +END-INFO-DIR-ENTRY +@end format +@end ifinfo + +@iftex +@tolerance 10000 + +@c Mutate section headers... +@begingroup + @catcode#=6 + @gdef@secheading#1#2#3{@secheadingi {#3@enspace #1}} +@endgroup +@end iftex + +@ifinfo +This file documents the use of the Common Error Description library. + +Copyright (C) 1987, 1988 Student Information Processing Board of the +Massachusetts Institute of Technology. + +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 names of M.I.T. and the M.I.T. S.I.P.B. not be +used in advertising or publicity pertaining to distribution of the software +without specific, written prior permission. M.I.T. and the M.I.T. S.I.P.B. +make no representations about the suitability of this software for any +purpose. It is provided "as is" without express or implied warranty. + +Note that the file texinfo.tex, provided with this distribution, is from +the Free Software Foundation, and is under different copyright restrictions +from the remainder of this package. + +@ignore +Permission is granted to process this file through Tex and print the +results, provided the printed document carries copying permission +notice identical to this one except for the removal of this paragraph +(this paragraph not being relevant to the printed manual). + +@end ignore + +@setchapternewpage odd + +@titlepage +@center @titlefont{A Common Error Description} +@center @titlefont{Library for UNIX} +@sp 2 +@center Ken Raeburn +@center Bill Sommerfeld +@sp 1 +@center MIT Student Information Processing Board +@sp 3 +@center last updated 1 January 1989 +@center for version 1.2 +@center ***DRAFT COPY ONLY*** + +@vskip 2in + +@center @b{Abstract} + +UNIX has always had a clean and simple system call interface, with a +standard set of error codes passed between the kernel and user +programs. Unfortunately, the same cannot be said of many of the +libraries layered on top of the primitives provided by the kernel. +Typically, each one has used a different style of indicating errors to +their callers, leading to a total hodgepodge of error handling, and +considerable amounts of work for the programmer. This paper describes +a library and associated utilities which allows a more uniform way for +libraries to return errors to their callers, and for programs to +describe errors and exceptional conditions to their users. + +@page +@vskip 0pt plus 1filll + +Copyright @copyright{} 1987, 1988 by the Student Information Processing +Board of the Massachusetts Institute of Technology. + +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 names of M.I.T. and the M.I.T. S.I.P.B. not be +used in advertising or publicity pertaining to distribution of the software +without specific, written prior permission. M.I.T. and the M.I.T. S.I.P.B. +make no representations about the suitability of this software for any +purpose. It is provided "as is" without express or implied warranty. + +Note that the file texinfo.tex, provided with this distribution, is from +the Free Software Foundation, and is under different copyright restrictions +from the remainder of this package. + +@end titlepage + + +@node Top, Why com_err?, (dir), (dir) + +@top A Common Error Description Library for UNIX + +This manual documents the com_err library. + +@menu +* Why com_err?:: +* Error codes:: +* Error table source file:: +* The error-table compiler:: +* Run-time support routines:: +* Coding Conventions:: +* Building and Installation:: +* Bug Reports:: +* Acknowledgements:: +@end menu + +@end ifinfo + +@page + +@node Why com_err?, Error codes, Top, Top +@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 +error-reporting mechanism. Sometimes one of two values is returned, +indicating simply SUCCESS or FAILURE, with no description of errors +encountered. Sometimes it is an index into a table of text strings, +where the name of the table used is dependent on the library being +used when the error is generated; since each table starts numbering at +0 or 1, additional information as to the source of the error code is +needed to determine which table to look at. Sometimes no text messages are +supplied at all, and the programmer must supply them at any point at which +he may wish to report error conditions. +Often, a global variable is assigned some value describing the error, but +the programmer has to know in each case whether to look at @code{errno}, +@code{h_errno}, the return value from @code{hes_err()}, or whatever other +variables or routines are specified. +And what happens if something +in the procedure of +examining or reporting the error changes the same variable? + +The package we have developed is an attempt to present a common +error-handling mechanism to manipulate the most common form of error code +in a fashion that does not have the problems listed above. + +A list of up to 256 text messages is supplied to a translator we have +written, along with the three- to four-character ``name'' of the error +table. The library using this error table need only call a routine +generated from this error-table source to make the table ``known'' to the +com_err library, and any error code the library generates can be converted +to the corresponding error message. There is also a default format for +error codes accidentally returned before making the table known, which is +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 +@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 +from, and the low order 8 bits are a sequential error number within +the table. An error code may thus be easily decomposed into its component +parts. Only the lowest 32 bits of an error code are considered significant +on systems which support wider values. + +Error table 0 is defined to match the UNIX system call error table +(@code{sys_errlist}); this allows @code{errno} values to be used directly +in the library (assuming that @code{errno} is of a type with the same width +as @t{long}). Other error table numbers are formed by compacting together +the first four characters of the error table name. The mapping between +characters in the name and numeric values in the error code are defined in +a system-independent fashion, so that two systems that can pass integral +values between them can reliably pass error codes without loss of meaning; +this should work even if the character sets used are not the same. +(However, if this is to be done, error table 0 should be avoided, since the +local system call error tables may differ.) + +Any variable which is to contain an error code should be declared @t{long}. +The draft proposed American National Standard for C (as of May, 1988) +requires that @t{long} variables be at least 32 bits; any system which does +not support 32-bit @t{long} values cannot make use of this package (nor +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 +@section Error table source file + +The error table source file begins with the declaration of the table name, +as + +@example +error_table @var{tablename} +@end example + +Individual error codes are +specified with + +@example +error_code @var{ERROR_NAME}, @var{"text message"} +@end example + +where @samp{ec} can also be used as a short form of @samp{error_code}. To +indicate the end of the table, use @samp{end}. Thus, a (short) sample +error table might be: + +@example + + error_table dsc + + error_code DSC_DUP_MTG_NAME, + "Meeting already exists" + + ec DSC_BAD_PATH, + "A bad meeting pathname was given" + + ec DSC_BAD_MODES, + "Invalid mode for this access control list" + + end + +@end example + +@node The error-table compiler, Run-time support routines, Error table source file, Top +@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., +@samp{dsc_err.et}) containing an error table source file. It parses the +error table, and generates two output files -- a C header file +(@samp{discuss_err.h}) which contains definitions of the numerical values +of the error codes defined in the error table, and a C source file which +should be compiled and linked with the executable. The header file must be +included in the source of a module which wishes to reference the error +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. + +This translator accepts a @kbd{-language @var{lang}} argument, which +determines for which language (or language variant) the output should be +written. At the moment, @var{lang} is currently limited to @kbd{ANSI-C} +and @kbd{K&R-C}, and some abbreviated forms of each. Eventually, this will +be extended to include some support for C++. The default is currently +@kbd{K&R-C}, though the generated sources will have ANSI-C code +conditionalized on the symbol @t{__STDC__}. + +@node Run-time support routines, Coding Conventions, The error-table compiler, Top +@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 +contains declarations and definitions which may be needed on some systems. +(Some functions cannot be referenced properly without the return type +declarations in this file. Some functions may work properly on most +architectures even without the header file, but relying on this is not +recommended.) + +The run-time support routines and variables provided via this package +include the following: + +@example +void initialize_@var{xxxx}_error_table (void); +@end example + +One of these routines is built by the error compiler for each error table. +It makes the @var{xxxx} error table ``known'' to the error reporting +system. By convention, this routine should be called in the initialization +routine of the @var{xxxx} library. If the library has no initialization +routine, some combination of routines which form the core of the library +should ensure that this routine is called. It is not advised to leave it +the caller to make this call. + +There is no harm in calling this routine more than once. + +@example +#define ERROR_TABLE_BASE_@var{xxxx} @var{nnnnn}L +@end example + +This symbol contains the value of the first error code entry in the +specified table. +This rarely needs be used by the +programmer. + +@deftypefun const char *error_message (long @var{code}); + +This routine returns the character string error message associated +with @code{code}; if this is associated with an unknown error table, or +if the code is associated with a known error table but the code is not +in the table, a string of the form @samp{Unknown code @var{xxxx nn}} is +returned, where @var{xxxx} is the error table name produced by +reversing the compaction performed on the error table number implied +by that error code, and @var{nn} is the offset from that base value. + +Although this routine is available for use when needed, its use should be +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}, ...); + +This routine provides an alternate way to print error messages to +standard error; it allows the error message to be passed in as a +parameter, rather than in an external variable. @emph{Provide grammatical +context for ``message.''} + +The module reporting the error should be passed in via @var{whoami}. +If @var{format} is @code{(char *)NULL}, the formatted message will not be +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}); + +This routine provides an interface, equivalent to @code{com_err} above, +which may be used by higher-level variadic functions (functions which +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}); + +@deftypefunx void reset_com_err_hook (); + +These two routines allow a routine to be dynamically substituted for +@samp{com_err}. After @samp{set_com_err_hook} has been called, +calls to @samp{com_err} will turn into calls to the new hook routine. +@samp{reset_com_err_hook} turns off this hook. This may intended to +be used in daemons (to use a routine which calls @cite{syslog(3)}), or +in a window system application (which could pop up a dialogue box). + +If a program is to be used in an environment in which simply printing +messages to the @code{stderr} stream would be inappropriate (such as in a +daemon program which runs without a terminal attached), +@code{set_com_err_hook} may be used to redirect output from @code{com_err}. +The following is an example of an error handler which uses @cite{syslog(3)} +as supplied in BSD 4.3: + +@example +#include <stdio.h> +#include <stdarg.h> +#include <syslog.h> + +/* extern openlog (const char * name, int logopt, int facility); */ +/* extern syslog (int priority, char * message, ...); */ + +void hook (const char * whoami, long code, + const char * format, va_list args) +@{ + char buffer[BUFSIZ]; + static int initialized = 0; + if (!initialized) @{ + openlog (whoami, + LOG_NOWAIT|LOG_CONS|LOG_PID|LOG_NDELAY, + LOG_DAEMON); + initialized = 1; + @} + vsprintf (buffer, format, args); + syslog (LOG_ERR, "%s %s", error_message (code), buffer); +@} +@end example + +After making the call +@code{set_com_err_hook (hook);}, +any calls to @code{com_err} will result in messages being sent to the +@var{syslogd} daemon for logging. +The name of the program, @samp{whoami}, is supplied to the +@samp{openlog()} call, and the message is formatted into a buffer and +passed to @code{syslog}. + +Note that since the extra arguments to @code{com_err} are passed by +reference via the @code{va_list} value @code{args}, the hook routine may +place any form of interpretation on them, including ignoring them. For +consistency, @code{printf}-style interpretation is suggested, via +@code{vsprintf} (or @code{_doprnt} on BSD systems without full support for +the ANSI C library). + +@end deftypefun + +@node Coding Conventions, Building and Installation, Run-time support routines, Top +@section Coding Conventions + +The following conventions are just some general stylistic conventions +to follow when writing robust libraries and programs. Conventions +similar to this are generally followed inside the UNIX kernel and most +routines in the Multics operating system. In general, a routine +either succeeds (returning a zero error code, and doing some side +effects in the process), or it fails, doing minimal side effects; in +any event, any invariant which the library assumes must be maintained. + +In general, it is not in the domain of non user-interface library +routines to write error messages to the user's terminal, or halt the +process. Such forms of ``error handling'' should be reserved for +failures of internal invariants and consistancy checks only, as it +provides the user of the library no way to clean up for himself in the +event of total failure. + +Library routines which can fail should be set up to return an error +code. This should usually be done as the return value of the +function; if this is not acceptable, the routine should return a +``null'' value, and put the error code into a parameter passed by +reference. + +Routines which use the first style of interface can be used from +user-interface levels of a program as follows: + +@example +@{ + if ((code = initialize_world(getuid(), random())) != 0) @{ + com_err("demo", code, + "when trying to initialize world"); + exit(1); + @} + if ((database = open_database("my_secrets", &code))==NULL) @{ + com_err("demo", code, + "while opening my_secrets"); + exit(1); + @} +@} +@end example + +A caller which fails to check the return status is in error. It is +possible to look for code which ignores error returns by using lint; +look for error messages of the form ``foobar returns value which is +sometimes ignored'' or ``foobar returns value which is always +ignored.'' + +Since libraries may be built out of other libraries, it is often necessary +for the success of one routine to depend on another. When a lower level +routine returns an error code, the middle level routine has a few possible +options. It can simply return the error code to its caller after doing +some form of cleanup, it can substitute one of its own, or it can take +corrective action of its own and continue normally. For instance, a +library routine which makes a ``connect'' system call to make a network +connection may reflect the system error code @code{ECONNREFUSED} +(Connection refused) to its caller, or it may return a ``server not +available, try again later,'' or it may try a different server. + +Cleanup which is typically necessary may include, but not be limited +to, freeing allocated memory which will not be needed any more, +unlocking concurrancy locks, dropping reference counts, closing file +descriptors, or otherwise undoing anything which the procedure did up +to this point. When there are a lot of things which can go wrong, it +is generally good to write one block of error-handling code which is +branched to, using a goto, in the event of failure. A common source +of errors in UNIX programs is failing to close file descriptors on +error returns; this leaves a number of ``zombied'' file descriptors +open, which eventually causes the process to run out of file +descriptors and fall over. + +@example +@{ + FILE *f1=NULL, *f2=NULL, *f3=NULL; + int status = 0; + + if ( (f1 = fopen(FILE1, "r")) == NULL) @{ + status = errno; + goto error; + @} + + /* + * Crunch for a while + */ + + if ( (f2 = fopen(FILE2, "w")) == NULL) @{ + status = errno; + goto error; + @} + + if ( (f3 = fopen(FILE3, "a+")) == NULL) @{ + status = errno; + goto error; + @} + + /* + * Do more processing. + */ + fclose(f1); + fclose(f2); + fclose(f3); + return 0; + +error: + if (f1) fclose(f1); + if (f2) fclose(f2); + if (f3) fclose(f3); + return status; +@} +@end example + +@node Building and Installation, Bug Reports, Coding Conventions, Top +@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. +Retrieve @samp{pub/com_err.tar.Z} and extract the contents. A subdirectory +@t{profiled} should be created to hold objects compiled for profiling. +Running ``make all'' should then be sufficient to build the library and +error-table compiler. The files @samp{libcom_err.a}, +@samp{libcom_err_p.a}, @samp{com_err.h}, and @samp{compile_et} should be +installed for use; @samp{com_err.3} and @samp{compile_et.1} can also be +installed as manual pages. + +Potential problems: + +@itemize @bullet + +@item Use of @code{strcasecmp}, a routine provided in BSD for +case-insensitive string comparisons. If an equivalent routine is +available, you can modify @code{CFLAGS} in the makefile to define +@code{strcasecmp} to the name of that routine. + +@item Compilers that defined @code{__STDC__} without providing the header +file @code{<stdarg.h>}. One such example is Metaware's High ``C'' +compiler, as provided at Project Athena on the IBM RT/PC workstation; if +@code{__HIGHC__} is defined, it is assumed that @code{<stdarg.h>} is not +available, and therefore @code{<varargs.h>} must be used. If the symbol +@code{VARARGS} is defined (e.g., in the makefile), @code{<varargs.h>} will +be used. + +@item If your linker rejects symbols that are simultaneously defined in two +library files, edit @samp{Makefile} to remove @samp{perror.c} from the +library. This file contains a version of @cite{perror(3)} which calls +@code{com_err} instead of calling @code{write} directly. + +@end itemize + +As I do not have access to non-BSD systems, there are probably +bugs present that may interfere with building or using this package on +other systems. If they are reported to me, they can probably be fixed for +the next version. + +@node Bug Reports, Acknowledgements, Building and Installation, Top +@section Bug Reports + +The principal author of this library is: Ken +Raeburn, @t{raeburn@@MIT.EDU}. + +This version of the com_err library is being maintained by Theodore +Ts'o, and so bugs and comments should be sent to @t{tytso@@thunk.org}. + + +@node Acknowledgements, , Bug Reports, Top +@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; +Honeywell Information Systems, for not killing off the @emph{Multics} +operating system before I had an opportunity to use it; Honeywell's +customers, who persuaded them not to do so, for a while; Ted Anderson of +CMU, for catching some problems before version 1.2 left the nest; Stan +Zanarotti and several others of MIT's Student Information Processing Board, +for getting us started with ``discuss,'' for which this package was +originally written; and everyone I've talked into --- I mean, asked to read +this document and the ``man'' pages. + +@bye diff --git a/e2fslib/et/compile_et b/e2fslib/et/compile_et new file mode 100755 index 0000000..ca19559 --- /dev/null +++ b/e2fslib/et/compile_et @@ -0,0 +1,31 @@ +#!/bin/sh +# +# +AWK=/usr/bin/awk +DIR="${DIR-/usr/share/et}" +ET_DIR="et" + +if test "x$1" = x ; then + echo "Usage: compile_et file" + exit 1 +fi + +if test ! -f "$DIR/et_h.awk" -o ! -f "$DIR/et_c.awk" ; then + DIR="$ET_DIR" +# echo "Falling back to $DIR..." + if test ! -f "$DIR/et_h.awk" -o ! -f "$DIR/et_c.awk" ; then + echo "compile_et: Couldn't find compile_et's template files." + exit 1 + fi +fi + +ROOT=`echo $1 | sed -e s/.et$//` +BASE=`basename $ROOT` + +if test ! -f "$ROOT.et" ; then + echo "compile_et: $ROOT.et: File not found" + exit 1; +fi + +$AWK -f "${DIR}/et_h.awk" "outfile=${BASE}.h" "$ROOT.et" +$AWK -f "${DIR}/et_c.awk" "outfile=${BASE}.c" "$ROOT.et" diff --git a/e2fslib/et/compile_et.sh.in b/e2fslib/et/compile_et.sh.in new file mode 100644 index 0000000..ad445fa --- /dev/null +++ b/e2fslib/et/compile_et.sh.in @@ -0,0 +1,31 @@ +#!/bin/sh +# +# +AWK=@AWK@ +DIR="${DIR-@datadir@/et}" +ET_DIR="@ET_DIR@" + +if test "x$1" = x ; then + echo "Usage: compile_et file" + exit 1 +fi + +if test ! -f "$DIR/et_h.awk" -o ! -f "$DIR/et_c.awk" ; then + DIR="$ET_DIR" +# echo "Falling back to $DIR..." + if test ! -f "$DIR/et_h.awk" -o ! -f "$DIR/et_c.awk" ; then + echo "compile_et: Couldn't find compile_et's template files." + exit 1 + fi +fi + +ROOT=`echo $1 | sed -e s/.et$//` +BASE=`basename $ROOT` + +if test ! -f "$ROOT.et" ; then + echo "compile_et: $ROOT.et: File not found" + exit 1; +fi + +$AWK -f "${DIR}/et_h.awk" "outfile=${BASE}.h" "$ROOT.et" +$AWK -f "${DIR}/et_c.awk" "outfile=${BASE}.c" "$ROOT.et" diff --git a/e2fslib/et/error_message.c b/e2fslib/et/error_message.c new file mode 100644 index 0000000..b9e3628 --- /dev/null +++ b/e2fslib/et/error_message.c @@ -0,0 +1,88 @@ +/* + * $ Header: lib/et/SCCS/s.error_message.c 1.16 99/10/23 01:16:05-00:00 tytso@mit.edu $ + * $ Source: /usr/src/e2fsprogs/BK/e2fsprogs/lib/et/SCCS/s.error_message.c $ + * $ Locker: <Not implemented> $ + * + * Copyright 1987 by the Student Information Processing Board + * of the Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose is hereby granted, provided that + * the names of M.I.T. and the M.I.T. S.I.P.B. not be used in + * advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. M.I.T. and the + * M.I.T. S.I.P.B. make no representations about the suitability of + * this software for any purpose. It is provided "as is" without + * express or implied warranty. + */ + +#include <stdio.h> +#include <string.h> +#include <errno.h> +#include "com_err.h" +#include "error_table.h" +#include "internal.h" + +static char buffer[25]; + +struct et_list * _et_list = (struct et_list *) NULL; + + +#ifdef __STDC__ +const char * error_message (errcode_t code) +#else +const char * error_message (code) + errcode_t code; +#endif +{ + int offset; + struct et_list *et; + errcode_t table_num; + int started = 0; + char *cp; + + offset = (int) (code & ((1<<ERRCODE_RANGE)-1)); + table_num = code - offset; + if (!table_num) { +#ifdef HAS_SYS_ERRLIST + if (offset < sys_nerr) + return(sys_errlist[offset]); + else + goto oops; +#else + cp = strerror(offset); + if (cp) + return(cp); + else + goto oops; +#endif + } + for (et = _et_list; et; et = et->next) { + if (et->table->base == table_num) { + /* This is the right table */ + if (et->table->n_msgs <= offset) + goto oops; + return(et->table->msgs[offset]); + } + } +oops: + strcpy (buffer, "Unknown code "); + if (table_num) { + strcat (buffer, error_table_name (table_num)); + strcat (buffer, " "); + } + for (cp = buffer; *cp; cp++) + ; + if (offset >= 100) { + *cp++ = '0' + offset / 100; + offset %= 100; + started++; + } + if (started || offset >= 10) { + *cp++ = '0' + offset / 10; + offset %= 10; + } + *cp++ = '0' + offset; + *cp = '\0'; + return(buffer); +} diff --git a/e2fslib/et/error_message.o b/e2fslib/et/error_message.o Binary files differnew file mode 100644 index 0000000..9223eb8 --- /dev/null +++ b/e2fslib/et/error_message.o diff --git a/e2fslib/et/error_table.h b/e2fslib/et/error_table.h new file mode 100644 index 0000000..d9a7b4b --- /dev/null +++ b/e2fslib/et/error_table.h @@ -0,0 +1,42 @@ +/* + * Copyright 1988 by the Student Information Processing Board of the + * Massachusetts Institute of Technology. + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose is hereby granted, provided that + * the names of M.I.T. and the M.I.T. S.I.P.B. not be used in + * advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. M.I.T. and the + * M.I.T. S.I.P.B. make no representations about the suitability of + * this software for any purpose. It is provided "as is" without + * express or implied warranty. + */ + +#ifndef _ET_H +/* Are we using ANSI C? */ +#ifndef __STDC__ +#define const +#endif + +struct error_table { + char const * const * msgs; + long base; + int n_msgs; +}; +struct et_list { + struct et_list *next; + const struct error_table *table; +}; +extern struct et_list * _et_list; + +#define ERRCODE_RANGE 8 /* # of bits to shift table number */ +#define BITS_PER_CHAR 6 /* # bits to shift per character in name */ + +#ifdef __STDC__ +extern const char *error_table_name(errcode_t num); +#else +extern const char *error_table_name(); +#endif + +#define _ET_H +#endif diff --git a/e2fslib/et/et_c.awk b/e2fslib/et/et_c.awk new file mode 100644 index 0000000..5f95b55 --- /dev/null +++ b/e2fslib/et/et_c.awk @@ -0,0 +1,187 @@ +BEGIN { +char_shift=64 +## "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"; +c2n["A"]=1 +c2n["B"]=2 +c2n["C"]=3 +c2n["D"]=4 +c2n["E"]=5 +c2n["F"]=6 +c2n["G"]=7 +c2n["H"]=8 +c2n["I"]=9 +c2n["J"]=10 +c2n["K"]=11 +c2n["L"]=12 +c2n["M"]=13 +c2n["N"]=14 +c2n["O"]=15 +c2n["P"]=16 +c2n["Q"]=17 +c2n["R"]=18 +c2n["S"]=19 +c2n["T"]=20 +c2n["U"]=21 +c2n["V"]=22 +c2n["W"]=23 +c2n["X"]=24 +c2n["Y"]=25 +c2n["Z"]=26 +c2n["a"]=27 +c2n["b"]=28 +c2n["c"]=29 +c2n["d"]=30 +c2n["e"]=31 +c2n["f"]=32 +c2n["g"]=33 +c2n["h"]=34 +c2n["i"]=35 +c2n["j"]=36 +c2n["k"]=37 +c2n["l"]=38 +c2n["m"]=39 +c2n["n"]=40 +c2n["o"]=41 +c2n["p"]=42 +c2n["q"]=43 +c2n["r"]=44 +c2n["s"]=45 +c2n["t"]=46 +c2n["u"]=47 +c2n["v"]=48 +c2n["w"]=49 +c2n["x"]=50 +c2n["y"]=51 +c2n["z"]=52 +c2n["0"]=53 +c2n["1"]=54 +c2n["2"]=55 +c2n["3"]=56 +c2n["4"]=57 +c2n["5"]=58 +c2n["6"]=59 +c2n["7"]=60 +c2n["8"]=61 +c2n["9"]=62 +c2n["_"]=63 +} +/^#/ { next } +/^[ \t]*(error_table|et)[ \t]+[a-zA-Z][a-zA-Z0-9_]+/ { + table_number = 0 + table_name = $2 + mod_base = 1000000 + for(i=1; i<=length(table_name); i++) { + table_number=(table_number*char_shift)+c2n[substr(table_name,i,1)] + } + + # We start playing *_high, *low games here because the some + # awk programs do not have the necessary precision (sigh) + tab_base_low = table_number % mod_base + if (tab_base_low < 0) { + # Work around stupid bug in the ARM libm + tab_base_low = tab_base_low + mod_base + } + tab_base_high = int(table_number / mod_base) + tab_base_sign = 1; + + # figure out: table_number_base=table_number*256 + tab_base_low = tab_base_low * 256 + tab_base_high = (tab_base_high * 256) + \ + int(tab_base_low / mod_base) + tab_base_low = tab_base_low % mod_base + if (tab_base_low < 0) { + # Work around stupid bug in the ARM libm + tab_base_low = tab_base_low + mod_base + } + + if (table_number > 128*256*256) { + # figure out: table_number_base -= 256*256*256*256 + # sub_high, sub_low is 256*256*256*256 + sub_low = 256*256*256 % mod_base + sub_high = int(256*256*256 / mod_base) + + sub_low = sub_low * 256 + sub_high = (sub_high * 256) + int(sub_low / mod_base) + sub_low = sub_low % mod_base + + tab_base_low = sub_low - tab_base_low; + tab_base_high = sub_high - tab_base_high; + tab_base_sign = -1; + if (tab_base_low < 0) { + tab_base_low = tab_base_low + mod_base + tab_base_high-- + } + } + print "/*" > outfile + print " * " outfile ":" > outfile + print " * This file is automatically generated; please do not edit it." > outfile + print " */" > outfile + + print "" > outfile + print "static const char * const text[] = {" > outfile + table_item_count = 0 +} + +/^[ \t]*(error_code|ec)[ \t]+[A-Z_0-9]+,[ \t]*$/ { + skipone=1 + next +} + +/^[ \t]*(error_code|ec)[ \t]+[A-Z_0-9]+,[ \t]*".*"[ \t]*$/ { + text="" + for (i=3; i<=NF; i++) { + text = text FS $i + } + text=substr(text,2,length(text)-1); + printf "\t%s,\n", text > outfile + table_item_count++ +} + +{ + if (skipone) { + printf "\t%s,\n", $0 > outfile + table_item_count++ + } + skipone=0 +} +END { + + + print " 0" > outfile + print "};" > outfile + print "" > outfile + print "struct error_table {" > outfile + print " char const * const * msgs;" > outfile + print " long base;" > outfile + print " int n_msgs;" > outfile + print "};" > outfile + print "struct et_list {" > outfile + print " struct et_list *next;" > outfile + print " const struct error_table * table;" > outfile + print "};" > outfile + print "extern struct et_list *_et_list;" > outfile + print "" > outfile + if (tab_base_high == 0) { + print "static const struct error_table et = { text, " \ + sprintf("%dL, %d };", tab_base_sign*tab_base_low, \ + table_item_count) > outfile + } else { + print "static const struct error_table et = { text, " \ + sprintf("%d%06dL, %d };", tab_base_sign*tab_base_high, \ + tab_base_low, table_item_count) > outfile + } + print "" > outfile + print "static struct et_list link = { 0, 0 };" > outfile + print "" > outfile + print "void initialize_" table_name "_error_table(void);" > outfile + print "" > outfile + print "void initialize_" table_name "_error_table(void) {" > outfile + print " if (!link.table) {" > outfile + print " link.next = _et_list;" > outfile + print " link.table = &et;" > outfile + print " _et_list = &link;" > outfile + print " }" > outfile + print "}" > outfile + + +} diff --git a/e2fslib/et/et_h.awk b/e2fslib/et/et_h.awk new file mode 100644 index 0000000..8b83a21 --- /dev/null +++ b/e2fslib/et/et_h.awk @@ -0,0 +1,159 @@ +BEGIN { +char_shift=64 +## "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"; +c2n["A"]=1 +c2n["B"]=2 +c2n["C"]=3 +c2n["D"]=4 +c2n["E"]=5 +c2n["F"]=6 +c2n["G"]=7 +c2n["H"]=8 +c2n["I"]=9 +c2n["J"]=10 +c2n["K"]=11 +c2n["L"]=12 +c2n["M"]=13 +c2n["N"]=14 +c2n["O"]=15 +c2n["P"]=16 +c2n["Q"]=17 +c2n["R"]=18 +c2n["S"]=19 +c2n["T"]=20 +c2n["U"]=21 +c2n["V"]=22 +c2n["W"]=23 +c2n["X"]=24 +c2n["Y"]=25 +c2n["Z"]=26 +c2n["a"]=27 +c2n["b"]=28 +c2n["c"]=29 +c2n["d"]=30 +c2n["e"]=31 +c2n["f"]=32 +c2n["g"]=33 +c2n["h"]=34 +c2n["i"]=35 +c2n["j"]=36 +c2n["k"]=37 +c2n["l"]=38 +c2n["m"]=39 +c2n["n"]=40 +c2n["o"]=41 +c2n["p"]=42 +c2n["q"]=43 +c2n["r"]=44 +c2n["s"]=45 +c2n["t"]=46 +c2n["u"]=47 +c2n["v"]=48 +c2n["w"]=49 +c2n["x"]=50 +c2n["y"]=51 +c2n["z"]=52 +c2n["0"]=53 +c2n["1"]=54 +c2n["2"]=55 +c2n["3"]=56 +c2n["4"]=57 +c2n["5"]=58 +c2n["6"]=59 +c2n["7"]=60 +c2n["8"]=61 +c2n["9"]=62 +c2n["_"]=63 +} +/^#/ { next } +/^[ \t]*(error_table|et)[ \t]+[a-zA-Z][a-zA-Z0-9_]+/ { + table_number = 0 + table_name = $2 + mod_base = 1000000 + for(i=1; i<=length(table_name); i++) { + table_number=(table_number*char_shift)+c2n[substr(table_name,i,1)] + } + # We start playing *_high, *low games here because the some + # awk programs do not have the necessary precision (sigh) + tab_base_low = table_number % mod_base + if (tab_base_low < 0) { + # Work around stupid bug in the ARM libm + tab_base_low = tab_base_low + mod_base + } + tab_base_high = int(table_number / mod_base) + tab_base_sign = 1; + + # figure out: table_number_base=table_number*256 + tab_base_low = tab_base_low * 256 + tab_base_high = (tab_base_high * 256) + \ + int(tab_base_low / mod_base) + tab_base_low = tab_base_low % mod_base + if (tab_base_low < 0) { + # Work around stupid bug in the ARM libm + tab_base_low = tab_base_low + mod_base + } + + if (table_number > 128*256*256) { + # figure out: table_number_base -= 256*256*256*256 + # sub_high, sub_low is 256*256*256*256 + sub_low = 256*256*256 % mod_base + sub_high = int(256*256*256 / mod_base) + + sub_low = sub_low * 256 + sub_high = (sub_high * 256) + int(sub_low / mod_base) + sub_low = sub_low % mod_base + + tab_base_low = sub_low - tab_base_low; + tab_base_high = sub_high - tab_base_high; + tab_base_sign = -1; + if (tab_base_low < 0) { + tab_base_low = tab_base_low + mod_base + tab_base_high-- + } + } + curr_low = tab_base_low + curr_high = tab_base_high + curr_sign = tab_base_sign + print "/*" > outfile + print " * " outfile ":" > outfile + print " * This file is automatically generated; please do not edit it." > outfile + print " */" > outfile + print "" > outfile +} + +/^[ \t]*(error_code|ec)[ \t]+[A-Z_0-9]+,/ { + tag=substr($2,1,length($2)-1) + if (curr_high == 0) { + printf "#define %-40s (%dL)\n", tag, \ + curr_sign*curr_low > outfile + } else { + printf "#define %-40s (%d%06dL)\n", tag, curr_high*curr_sign, \ + curr_low > outfile + } + curr_low += curr_sign; + if (curr_low >= mod_base) { + curr_low -= mod_base; + curr_high++ + } + if (curr_low < 0) { + cur_low += mod_base + cur_high-- + } +} + +END { + print "extern void initialize_" table_name "_error_table(void);" > outfile + if (tab_base_high == 0) { + print "#define ERROR_TABLE_BASE_" table_name " (" \ + sprintf("%d", tab_base_sign*tab_base_low) \ + "L)" > outfile + } else { + print "#define ERROR_TABLE_BASE_" table_name " (" \ + sprintf("%d%06d", tab_base_sign*tab_base_high, \ + tab_base_low) "L)" > outfile + } + print "" > outfile + print "/* for compatibility with older versions... */" > outfile + print "#define init_" table_name "_err_tbl initialize_" table_name "_error_table" > outfile + print "#define " table_name "_err_base ERROR_TABLE_BASE_" table_name > outfile +} diff --git a/e2fslib/et/et_name.c b/e2fslib/et/et_name.c new file mode 100644 index 0000000..1888326 --- /dev/null +++ b/e2fslib/et/et_name.c @@ -0,0 +1,43 @@ +/* + * Copyright 1987 by MIT Student Information Processing Board + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose is hereby granted, provided that + * the names of M.I.T. and the M.I.T. S.I.P.B. not be used in + * advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. M.I.T. and the + * M.I.T. S.I.P.B. make no representations about the suitability of + * this software for any purpose. It is provided "as is" without + * express or implied warranty. + */ + +#include "com_err.h" +#include "error_table.h" +#include "internal.h" + +static const char char_set[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"; + +static char buf[6]; + +const char * error_table_name(num) + errcode_t num; +{ + int ch; + int i; + char *p; + + /* num = aa aaa abb bbb bcc ccc cdd ddd d?? ??? ??? */ + p = buf; + num >>= ERRCODE_RANGE; + /* num = ?? ??? ??? aaa aaa bbb bbb ccc ccc ddd ddd */ + num &= 077777777L; + /* num = 00 000 000 aaa aaa bbb bbb ccc ccc ddd ddd */ + for (i = 4; i >= 0; i--) { + ch = (int)((num >> BITS_PER_CHAR * i) & ((1 << BITS_PER_CHAR) - 1)); + if (ch != 0) + *p++ = char_set[ch-1]; + } + *p = '\0'; + return(buf); +} diff --git a/e2fslib/et/et_name.o b/e2fslib/et/et_name.o Binary files differnew file mode 100644 index 0000000..c2510b2 --- /dev/null +++ b/e2fslib/et/et_name.o diff --git a/e2fslib/et/init_et.c b/e2fslib/et/init_et.c new file mode 100644 index 0000000..bfdb73d --- /dev/null +++ b/e2fslib/et/init_et.c @@ -0,0 +1,63 @@ +/* + * $ Header: lib/et/SCCS/s.init_et.c 1.15 99/10/23 01:16:06-00:00 tytso@mit.edu $ + * $ Source: /usr/src/e2fsprogs/BK/e2fsprogs/lib/et/SCCS/s.init_et.c $ + * $ Locker: <Not implemented> $ + * + * Copyright 1986, 1987, 1988 by MIT Information Systems and + * the MIT Student Information Processing Board. + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose is hereby granted, provided that + * the names of M.I.T. and the M.I.T. S.I.P.B. not be used in + * advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. M.I.T. and the + * M.I.T. S.I.P.B. make no representations about the suitability of + * this software for any purpose. It is provided "as is" without + * express or implied warranty. + */ + +#include <stdio.h> +#include <errno.h> +#ifdef HAVE_STDLIB_H +#include <stdlib.h> +#endif +#include "com_err.h" +#include "error_table.h" + +#ifndef __STDC__ +#define const +#endif + +struct foobar { + struct et_list etl; + struct error_table et; +}; + +extern struct et_list * _et_list; + +#ifdef __STDC__ +int init_error_table(const char * const *msgs, int base, int count) +#else +int init_error_table(msgs, base, count) + const char * const * msgs; + int base; + int count; +#endif +{ + struct foobar * new_et; + + if (!base || !count || !msgs) + return 0; + + new_et = (struct foobar *) malloc(sizeof(struct foobar)); + if (!new_et) + return ENOMEM; /* oops */ + new_et->etl.table = &new_et->et; + new_et->et.msgs = msgs; + new_et->et.base = base; + new_et->et.n_msgs= count; + + new_et->etl.next = _et_list; + _et_list = &new_et->etl; + return 0; +} diff --git a/e2fslib/et/init_et.o b/e2fslib/et/init_et.o Binary files differnew file mode 100644 index 0000000..9a7698a --- /dev/null +++ b/e2fslib/et/init_et.o diff --git a/e2fslib/et/internal.h b/e2fslib/et/internal.h new file mode 100644 index 0000000..30b1921 --- /dev/null +++ b/e2fslib/et/internal.h @@ -0,0 +1,30 @@ +/* + * internal include file for com_err package + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose is hereby granted, provided that + * the names of M.I.T. and the M.I.T. S.I.P.B. not be used in + * advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. M.I.T. and the + * M.I.T. S.I.P.B. make no representations about the suitability of + * this software for any purpose. It is provided "as is" without + * express or implied warranty. + */ +#ifndef __STDC__ +#undef const +#define const +#endif + +#include <errno.h> + +#ifdef NEED_SYS_ERRLIST +extern char const * const sys_errlist[]; +extern const int sys_nerr; +#endif + +/* AIX and Ultrix have standard conforming header files. */ +#if !defined(ultrix) && !defined(_AIX) +#ifdef __STDC__ +void perror (const char *); +#endif +#endif diff --git a/e2fslib/et/libcom_err.a b/e2fslib/et/libcom_err.a Binary files differnew file mode 100644 index 0000000..4c848dc --- /dev/null +++ b/e2fslib/et/libcom_err.a diff --git a/e2fslib/et/vfprintf.c b/e2fslib/et/vfprintf.c new file mode 100644 index 0000000..a1dc1e8 --- /dev/null +++ b/e2fslib/et/vfprintf.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * 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. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)vfprintf.c 5.2 (Berkeley) 6/27/88"; +#endif /* LIBC_SCCS and not lint */ + +#if !HAVE_VPRINTF && HAVE_DOPRNT +#include <stdio.h> +#include <varargs.h> + +int +vfprintf(iop, fmt, ap) + FILE *iop; + char *fmt; + va_list ap; +{ + int len; + char localbuf[BUFSIZ]; + + if (iop->_flag & _IONBF) { + iop->_flag &= ~_IONBF; + iop->_ptr = iop->_base = localbuf; + len = _doprnt(fmt, ap, iop); + (void) fflush(iop); + iop->_flag |= _IONBF; + iop->_base = NULL; + iop->_bufsiz = 0; + iop->_cnt = 0; + } else + len = _doprnt(fmt, ap, iop); + + return (ferror(iop) ? EOF : len); +} +#endif /* !HAVE_VPRINTF */ |