From 02f43564629f54847c04cc32f77cb1b6ba3b89c2 Mon Sep 17 00:00:00 2001 From: Nathan Scott Date: Mon, 15 Jan 2001 03:18:30 +0000 Subject: initial version for reworked extended attributes build environment. --- include/Makefile | 45 +++++++++ include/attributes.h | 260 +++++++++++++++++++++++++++++++++++++++++++++++++++ include/builddefs.in | 167 +++++++++++++++++++++++++++++++++ include/buildrules | 77 +++++++++++++++ 4 files changed, 549 insertions(+) create mode 100644 include/Makefile create mode 100644 include/attributes.h create mode 100644 include/builddefs.in create mode 100644 include/buildrules (limited to 'include') diff --git a/include/Makefile b/include/Makefile new file mode 100644 index 0000000..53f77db --- /dev/null +++ b/include/Makefile @@ -0,0 +1,45 @@ +# +# Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# Further, this software is distributed without any warranty that it is +# free of the rightful claim of any third person regarding infringement +# or the like. Any license provided herein, whether implied or +# otherwise, applies only to this software file. Patent licenses, if +# any, provided herein do not apply to combinations of this program with +# other software, or any other product whatsoever. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write the Free Software Foundation, Inc., 59 +# Temple Place - Suite 330, Boston MA 02111-1307, USA. +# +# Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, +# Mountain View, CA 94043, or: +# +# http://www.sgi.com +# +# For further information regarding this notice, see: +# +# http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ +# + +TOPDIR = .. +include $(TOPDIR)/include/builddefs + +HFILES = attributes.h +LSRCFILES = builddefs.in buildrules + +default install : + +include $(BUILDRULES) + +install-dev: default + $(INSTALL) -m 755 -d $(PKG_INC_DIR) + $(INSTALL) -m 644 $(HFILES) $(PKG_INC_DIR) diff --git a/include/attributes.h b/include/attributes.h new file mode 100644 index 0000000..e670438 --- /dev/null +++ b/include/attributes.h @@ -0,0 +1,260 @@ +/* + * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it would be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Further, this software is distributed without any warranty that it is + * free of the rightful claim of any third person regarding infringement + * or the like. Any license provided herein, whether implied or + * otherwise, applies only to this software file. Patent licenses, if + * any, provided herein do not apply to combinations of this program with + * other software, or any other product whatsoever. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write the Free Software Foundation, Inc., 59 + * Temple Place - Suite 330, Boston MA 02111-1307, USA. + * + * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, + * Mountain View, CA 94043, or: + * + * http://www.sgi.com + * + * For further information regarding this notice, see: + * + * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ + */ +#ifndef __ATTRIBUTES_H__ +#define __ATTRIBUTES_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The (experimental) Linux generic attribute syscall - attrctl(2) + */ + +typedef union attr_obj { + char *path; + int fd; + pid_t pid; +} attr_obj_t; + +typedef struct attr_op { + int opcode; /* which operation to perform */ + int error; /* result (an errno) of this operation [out] */ + char *name; /* attribute name */ + char *value; /* attribute value [in/out] */ + int length; /* value length [in/out] */ + int flags; /* bitwise OR of #defines below */ + void *aux; /* optional cmd specific data */ +} attr_op_t; + +extern int attrctl (attr_obj_t __obj, int __type, attr_op_t *__ops, int __count); + +/* + * attr_obj_t type identifiers + */ +#define ATTR_TYPE_FD 1 /* file descriptor */ +#define ATTR_TYPE_PATH 2 /* path - follow symlinks */ +#define ATTR_TYPE_LPATH 3 /* path - don't follow symlinks */ +#define ATTR_TYPE_PID 4 /* process id */ + +/* + * attrctl(2) commands + */ +#define ATTR_OP_GET 1 /* return the indicated attr's value */ +#define ATTR_OP_SET 2 /* set/create the indicated attr/value pair */ +#define ATTR_OP_REMOVE 3 /* remove the indicated attr */ +#define ATTR_OP_LIST 4 /* list attributes associated with a file */ +#define ATTR_OP_EXT 32 /* for supporting extensions */ + +/* + * Valid command flags, may be used with all attrctl(2) commands. + * Flags should be bitwise OR'ed together. + */ +#define ATTR_ROOT 0x0001 /* use attrs in root namespace, not user */ +#define ATTR_CREATE 0x0002 /* pure create: fail if attr already exists */ +#define ATTR_REPLACE 0x0004 /* pure set: fail if attr does not exist */ +#define ATTR_SHIFT 16 /* for supporting extensions */ + +/* + * Additional API specific opcodes & flags + */ +#define ATTR_OP_IRIX_LIST (ATTR_OP_EXT + 0) /* IRIX: for supporting strange */ + /* attr_list(f) API semantics */ +#define ATTR_DONTFOLLOW (0x0001 << ATTR_SHIFT) /* IRIX: do not follow symlinks */ + /* (now redundant) */ +#define ATTR_TRUST (0x0002 << ATTR_SHIFT) /* IRIX: tell server we can be */ + /* trusted to properly handle */ + /* extended attributes */ + +/* + * + * The IRIX extended attributes API, fully implemented by XFS + * + */ + +/* + * The maximum size (into the kernel or returned from the kernel) of an + * attribute value or the buffer used for an attr_list() call. Larger + * sizes will result in an E2BIG return code. + */ +#define ATTR_MAX_VALUELEN (64*1024) /* max length of a value */ + +/* + * Define how lists of attribute names are returned to the user from + * the attr_list() syscall. A large, 32bit aligned, buffer is passed in + * along with its size. We put an array of offsets at the top that each + * reference an attrlist_ent_t and pack the attrlist_ent_t's at the bottom. + */ +typedef struct attrlist { + __s32 al_count; /* number of entries in attrlist */ + __s32 al_more; /* T/F: more attrs (do syscall again) */ + __s32 al_offset[1]; /* byte offsets of attrs [var-sized] */ +} attrlist_t; + +/* + * Show the interesting info about one attribute. This is what the + * al_offset[i] entry points to. + */ +typedef struct attrlist_ent { /* data from attr_list() */ + __u32 a_valuelen; /* number bytes in value of attr */ + char a_name[1]; /* attr name (NULL terminated) */ +} attrlist_ent_t; + +/* + * Given a pointer to the (char*) buffer containing the attr_list() result, + * and an index, return a pointer to the indicated attribute in the buffer. + */ +#define ATTR_ENTRY(buffer, index) \ + ((attrlist_ent_t *) \ + &((char *)buffer)[ ((attrlist_t *)(buffer))->al_offset[index] ]) + + +/* + * Implement a "cursor" for use in successive attr_list() system calls. + * It provides a way to find the last attribute that was returned in the + * last attr_list() syscall so that we can get the next one without missing + * any. This should be bzero()ed before use and whenever it is desired to + * start over from the beginning of the attribute list. The only valid + * operation on a cursor is to bzero() it. + */ +typedef struct attrlist_cursor { + __u32 opaque[4]; /* an opaque cookie */ +} attrlist_cursor_t; + +/* + * Multi-attribute operation vector. + */ +typedef struct attr_multiop { + int am_opcode; /* which operation to perform (ATTR_OP_GET etc.)*/ + int am_error; /* [out arg] result of this sub-op (an errno) */ + char *am_attrname; /* attribute name to work with */ + char *am_attrvalue; /* [in/out arg] attribute value (raw bytes) */ + int am_length; /* [in/out arg] length of value */ + int am_flags; /* bitwise OR of attrctl(2) flags defined above */ +} attr_multiop_t; +#define ATTR_MAX_MULTIOPS 128 /* max number ops in an oplist array */ + +/* + * Get the value of an attribute. + * Valuelength must be set to the maximum size of the value buffer, it will + * be set to the actual number of bytes used in the value buffer upon return. + * The return value is -1 on error (w/errno set appropriately), 0 on success. + */ +extern int attr_get (const char *path, const char *attrname, char *attrvalue, + int *valuelength, int flags); +extern int attr_getf (int fd, const char *attrname, char *attrvalue, + int *valuelength, int flags); + +/* + * Set the value of an attribute, creating the attribute if necessary. + * The return value is -1 on error (w/errno set appropriately), 0 on success. + */ +extern int attr_set (const char *__path, const char *__attrname, + const char *__attrvalue, const int __valuelength, + int __flags); +extern int attr_setf (int __fd, const char *__attrname, + const char *__attrvalue, const int __valuelength, + int __flags); + +/* + * Remove an attribute. + * The return value is -1 on error (w/errno set appropriately), 0 on success. + */ +extern int attr_remove (const char *__path, const char *__attrname, + int __flags); +extern int attr_removef (int __fd, const char *__attrname, int __flags); + +/* + * List the names and sizes of the values of all the attributes of an object. + * "Cursor" must be allocated and zeroed before the first call, it is used + * to maintain context between system calls if all the attribute names won't + * fit into the buffer on the first system call. + * The return value is -1 on error (w/errno set appropriately), 0 on success. + */ +extern int attr_list (const char *__path, char *__buffer, + const int __buffersize, int __flags, + attrlist_cursor_t *__cursor); +extern int attr_listf (int __fd, char *__buffer, const int __buffersize, + int __flags, attrlist_cursor_t *__cursor); + +/* + * Operate on multiple attributes of the same object simultaneously. + * + * This call will save on system call overhead when many attributes are + * going to be operated on. + * + * The return value is -1 on error (w/errno set appropriately), 0 on success. + * Note that this call will not return -1 as a result of failure of any + * of the sub-operations, their return value is stored in each element + * of the operation array. This call will return -1 for a failure of the + * call as a whole, eg: if the pathname doesn't exist, or the fd is bad. + * + * The semantics and allowable values for the fields in a attr_multiop_t + * are the same as the semantics and allowable values for the arguments to + * the corresponding "simple" attribute interface. For example: the args + * to a ATTR_OP_GET are the same as the args to an attr_get() call. + */ +extern int attr_multi (const char *__path, attr_multiop_t *__oplist, + int __count, int __flags); +extern int attr_multif (int __fd, attr_multiop_t *__oplist, + int __count, int __flags); + +#ifdef __KERNEL__ + +/* + * The DMI needs a way to update attributes without affecting the inode + * timestamps. Note that this flag is not settable from user mode, it is + * kernel internal only, but it must not conflict with the above flags either. + */ +#define ATTR_KERNOTIME (0x0004 << ATTR_SHIFT) /* IRIX: don't update the inode */ + /* timestamps */ + +/* + * Kernel-internal version of the attrlist cursor. + */ +typedef struct attrlist_cursor_kern { + __u32 hashval; /* hash value of next entry to add */ + __u32 blkno; /* block containing entry (suggestion)*/ + __u32 offset; /* offset in list of equal-hashvals */ + __u16 pad1; /* padding to match user-level */ + __u8 pad2; /* padding to match user-level */ + __u8 initted; /* T/F: cursor has been initialized */ +} attrlist_cursor_kern_t; + +#endif /* __KERNEL__ */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __ATTRIBUTES_H__ */ diff --git a/include/builddefs.in b/include/builddefs.in new file mode 100644 index 0000000..58a736f --- /dev/null +++ b/include/builddefs.in @@ -0,0 +1,167 @@ +# +# Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# Further, this software is distributed without any warranty that it is +# free of the rightful claim of any third person regarding infringement +# or the like. Any license provided herein, whether implied or +# otherwise, applies only to this software file. Patent licenses, if +# any, provided herein do not apply to combinations of this program with +# other software, or any other product whatsoever. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write the Free Software Foundation, Inc., 59 +# Temple Place - Suite 330, Boston MA 02111-1307, USA. +# +# Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, +# Mountain View, CA 94043, or: +# +# http://www.sgi.com +# +# For further information regarding this notice, see: +# +# http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ +# +# @configure_input@ +# + +ifndef _BUILDDEFS_INCLUDED_ +_BUILDDEFS_INCLUDED_ = 1 + +DEBUG = @debug_build@ +OPTIMIZER = @opt_build@ +MALLOCLIB = @malloc_lib@ + +#LIBATTR = -lattr +LIBATTR = $(TOPDIR)/libattr/libattr.a + +BUILDRULES = $(TOPDIR)/include/buildrules + +# General package information +PKG_NAME = @pkg_name@ +PKG_RELEASE = @pkg_release@ +PKG_VERSION = @pkg_version@ +PKG_DISTRIBUTION = @pkg_distribution@ +PKG_BUILDER = @pkg_builder@ +PKG_BIN_DIR = @pkg_bin_dir@ +PKG_LIB_DIR = @pkg_lib_dir@ +PKG_SBIN_DIR = @pkg_sbin_dir@ +PKG_SLIB_DIR = @pkg_slib_dir@ +PKG_INC_DIR = @pkg_inc_dir@ +PKG_MAN_DIR = @pkg_man_dir@ +PKG_DOC_DIR = @pkg_doc_dir@ + +# LCFLAGS, LLDFLAGS, LLDLIBS, LSRCFILES and LDIRT may be specified in +# user Makefiles. Note: LSRCFILES is anything other than Makefile, $(CFILES) +# $(CXXFILES), or $(HFILES) and is used to construct the manifest list +# during the "dist" phase (packaging). + +CFLAGS += $(OPTIMIZER) $(DEBUG) -funsigned-char -Wall -Wno-parentheses \ + $(LCFLAGS) -I$(TOPDIR)/include '-DVERSION="$(PKG_VERSION)"' \ + -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE + +LDFLAGS = $(LLDFLAGS) +LDLIBS = $(LLDLIBS) $(MALLOCLIB) + +MAKEOPTS = --no-print-directory +SRCFILES = Makefile $(HFILES) $(CFILES) $(LSRCFILES) $(LFILES) $(YFILES) +DIRT = $(LDIRT) dep dep.bak $(OBJECTS) $(CMDTARGET) $(LIBTARGET) \ + $(STATICLIBTARGET) *.[1-9].gz + +OBJECTS = $(ASFILES:.s=.o) \ + $(CFILES:.c=.o) \ + $(LFILES:.l=.o) \ + $(YFILES:%.y=%.tab.o) + +MAKE = @make@ +CC = @cc@ +LD = @ld@ +AWK = @awk@ +SED = @sed@ +INSTALL = $(TOPDIR)/install-sh -o root -g root +ECHO = @echo@ +LN_S = @LN_S@ + +CCF = $(CC) $(CFLAGS) +MAKEF = $(MAKE) $(MAKEOPTS) +CXXF = $(CXX) $(CXXFLAGS) +LDF = $(LD) $(LDFLAGS) +MAKEDEPEND = @makedepend@ + +ZIP = @zip@ +TAR = @tar@ +RPM = @rpm@ +RPM_VERSION = @rpm_version@ + +HAVE_ZIPPED_MANPAGES = @have_zipped_manpages@ + +SHELL = /bin/sh +IMAGES_DIR = $(TOPDIR)/all-images +DIST_DIR = $(TOPDIR)/dist + +SUBDIRS_MAKERULE = \ + @for d in $(SUBDIRS) ""; do \ + if test -d "$$d" -a ! -z "$$d"; then \ + $(ECHO) === $$d ===; \ + $(MAKEF) -C $$d $@ || exit $$?; \ + fi; \ + done + +MAN_MAKERULE = \ + @for f in *.[12345678] ""; do \ + if test ! -z "$$f"; then \ + $(ZIP) --best -c < $$f > $$f.gz; \ + fi; \ + done + +INSTALL_MAN = \ + @for d in $(MAN_PAGES); do \ + first=true; \ + for m in `$(AWK) '/^\.SH NAME/ {ok=1; next} ok {print; exit}' $$d \ + | sed -e 's/,/ /g' -e 's/\\-.*//' -e 's/\\\f[0-9]//g' -e 's/ / /g;q'`; \ + do \ + [ -z "$$m" -o "$$m" = "\\" ] && continue; \ + t=$(MAN_DEST)/$$m.$(MAN_SECTION); \ + if $$first; then \ + if $(HAVE_ZIPPED_MANPAGES); then \ + $(ZIP) --best -c $$d > $$d.gz; _sfx=.gz; \ + fi; \ + u=$$m.$(MAN_SECTION)$$_sfx; \ + echo $(INSTALL) -m 644 $${d}$$_sfx $${t}$$_sfx; \ + $(INSTALL) -m 644 $${d}$$_sfx $${t}$$_sfx; \ + else \ + echo $(INSTALL) -S $$u $${t}$$_sfx; \ + $(INSTALL) -S $$u $${t}$$_sfx; \ + fi; \ + first=false; \ + done; \ + done + +DIST_MAKERULE = \ + $(MAKEF) -C build dist + +SOURCE_MAKERULE = \ + @test -z "$$DIR" && DIR="."; \ + for f in $(SRCFILES) ""; do \ + if test ! -z "$$f"; then $(ECHO) $$DIR/$$f; fi;\ + done; \ + for d in `echo $(SUBDIRS)` ; do \ + if test -d "$$d" -a ! -z "$$d"; then \ + $(MAKEF) DIR=$$DIR/$$d -C $$d $@ || exit $$?; \ + fi; \ + done + +endif + +# +# For targets that should always be rebuilt, +# define a target that is never up-to-date. +# Targets needing this should depend on $(_FORCE) +_FORCE = __force_build diff --git a/include/buildrules b/include/buildrules new file mode 100644 index 0000000..dab3fae --- /dev/null +++ b/include/buildrules @@ -0,0 +1,77 @@ +# +# Copyright (C) 1999 Silicon Graphics, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Fondation. +# +# This program is distributed in the hope that it would be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. Further, any license provided herein, +# whether implied or otherwise, is limited to this program in accordance with +# the express provisions of the GNU General Public License. Patent licenses, +# if any, provided herein do not apply to combinations of this program with +# other product or programs, or any other product whatsoever. This program is +# distributed without any warranty that the program is delivered free of the +# rightful claim of any third person by way of infringement or the like. See +# the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write the Free Software Foundation, Inc., 59 Temple +# Place - Suite 330, Boston MA 02111-1307, USA. +# Common build rules for gmake +# +ifndef _BUILDRULES_INCLUDED_ +_BUILDRULES_INCLUDED_ = 1 + +include $(TOPDIR)/include/builddefs + +# +# Standard targets +# +ifdef CMDTARGET +$(CMDTARGET) : $(SUBDIRS) $(OBJECTS) + $(CCF) -o $(CMDTARGET) $(LDFLAGS) $(OBJECTS) $(LDLIBS) +$(CMDTARGET).static : $(SUBDIRS) $(OBJECTS) + $(CCF) -static -o $(CMDTARGET).static $(LDFLAGS) $(OBJECTS) $(LDLIBS) +endif + +ifdef LIBTARGET +$(LIBTARGET) : $(SUBDIRS) $(OBJECTS) + $(CC) $(LDFLAGS) -fPIC -shared -Wl,-soname,$(LIBTARGET) -o $(LIBTARGET) $(OBJECTS) $(LDLIBS) +endif + +ifdef STATICLIBTARGET +$(STATICLIBTARGET) : $(SUBDIRS) $(OBJECTS) + $(AR) crf $(STATICLIBTARGET) $? +endif + +clean clobber : $(SUBDIRS) + rm -f $(DIRT) + $(SUBDIRS_MAKERULE) + +# Never blow away subdirs +ifdef SUBDIRS +.PRECIOUS: $(SUBDIRS) +$(SUBDIRS): + $(SUBDIRS_MAKERULE) +endif + +source : + $(SOURCE_MAKERULE) + +endif + +$(_FORCE): + +.PHONY : depend + +depend : $(CFILES) $(HFILES) + $(SUBDIRS_MAKERULE) + touch dep + $(MAKEDEPEND) -fdep -- $(CFLAGS) -- $(CFILES) + +# Include dep, but only if it exists +ifeq ($(shell test -f dep && echo dep), dep) +include dep +endif -- cgit v1.2.3