>From aa80da8643a3c3025b547df765886f4c5c2dc7a4 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Mon, 6 Aug 2012 13:15:16 +0200 Subject: [PATCH 1/2] adding module 'xattr' --- lib/sys_xattr.in.h | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ m4/sys_xattr_h.m4 | 53 +++++++++++++++++++++++++++++++++++++++++++ modules/xattr-h | 46 +++++++++++++++++++++++++++++++++++++ 3 files changed, 165 insertions(+) create mode 100644 lib/sys_xattr.in.h create mode 100644 m4/sys_xattr_h.m4 create mode 100644 modules/xattr-h diff --git a/lib/sys_xattr.in.h b/lib/sys_xattr.in.h new file mode 100644 index 0000000..e12303f --- /dev/null +++ b/lib/sys_xattr.in.h @@ -0,0 +1,66 @@ +#ifndef address@hidden@_ATTR_XATTR_H +#define address@hidden@_ATTR_XATTR_H + +/* Replacement for platforms that lack it. + Copyright (C) 2012 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +#ifdef HAVE_SYS_XATTR_H address@hidden@ @NEXT_SYS_XATTR_H@ +#elif defined HAVE_ATTR_XATTR_H +# include +#else +# include + +/* setting */ +static inline int setxattr (const char *path, const char *name, const void + *value, size_t size, int flags) +{ errno = ENOTSUP; return -1; } + +static inline int lsetxattr (const char *path, const char *name, const void + *value, size_t size, int flags) +{ errno = ENOTSUP; return -1; } + +static inline int fsetxattr (int filedes, const char *name, const void *value, + size_t size, int flags) +{ errno = ENOTSUP; return -1; } + + +/* getting */ +static inline ssize_t getxattr (const char *path, const char *name, void *value, + size_t size) +{ errno = ENOTSUP; return -1; } +static inline ssize_t lgetxattr (const char *path, const char *name, void + *value, size_t size) +{ errno = ENOTSUP; return -1; } +static inline ssize_t fgetxattr (int filedes, const char *name, void *value, + size_t size) +{ errno = ENOTSUP; return -1; } + + +/* listing */ +static inline ssize_t listxattr (const char *path, char *list, size_t size) +{ errno = ENOTSUP; return -1; } + +static inline ssize_t llistxattr (const char *path, char *list, size_t size) +{ errno = ENOTSUP; return -1; } + +static inline ssize_t flistxattr (int filedes, char *list, size_t size) +{ errno = ENOTSUP; return -1; } + +#endif +#endif /* address@hidden@_ATTR_XATTR_H */ diff --git a/m4/sys_xattr_h.m4 b/m4/sys_xattr_h.m4 new file mode 100644 index 0000000..4f005dd --- /dev/null +++ b/m4/sys_xattr_h.m4 @@ -0,0 +1,53 @@ +# Copyright (C) 2012 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# Provide , if necessary + +AC_DEFUN([gl_HEADERS_SYS_XATTR_H], +[ + AC_ARG_WITH([xattrs], + AS_HELP_STRING([--without-xattrs], [don't use linux exteneded atttributes]), + [], [with_xattrs=maybe] + ) + + if test "x$with_xattrs" != "xno"; then + found=no + + # check for regular glibcs implementation of extended attributes + AC_CHECK_HEADERS([sys/xattr.h], + [ + AC_CHECK_FUNCS(getxattr fgetxattr lgetxattr \ + setxattr fsetxattr lsetxattr \ + listxattr flistxattr llistxattr, + # only when functions are present + AC_DEFINE([HAVE_SYS_XATTR_H], [1], + [define to 1 if we have header]) + found=glibc + ) + ], + [], + [[#include ]] + ) + + # before xattr support was added into glibc, -lattr & attr/xattr.h was used + if test "$found" = "no"; then + AC_CHECK_HEADERS([attr/xattr.h], + [ + AC_SEARCH_LIBS(getxattr, attr) + if test "$ac_cv_search_getxattr" != "no"; then + AC_DEFINE([HAVE_ATTR_XATTR_H], [1], + [define to 1 if we have header] + ) + found=libattr + fi + ] + ) + fi + + if test "$found" != "no"; then + AC_DEFINE([HAVE_XATTRS],,[Define when we have working linux xattrs.]) + fi +fi +]) diff --git a/modules/xattr-h b/modules/xattr-h new file mode 100644 index 0000000..0ef5a9c --- /dev/null +++ b/modules/xattr-h @@ -0,0 +1,46 @@ +Description: +xattr headers for systems that lack them + +Files: +lib/sys_xattr.in.h +m4/sys_xattr_h.m4 + +Depends-on: +include_next +errno +sys_types +snippet/unused-parameter + +configure.ac: +gl_HEADERS_SYS_XATTR_H + +Makefile.am: +lib_SOURCES += sys_xattr.in.h + +BUILT_SOURCES += sys/xattr.h +sys/xattr.h: sys_xattr.in.h $(top_builddir)/config.status $(UNUSED_PARAMETER_H) + $(AM_V_at)$(MKDIR_P) sys + $(AM_V_GEN)rm -f address@hidden $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ + sed -e 's|@''GUARD_PREFIX''@|${gl_include_guard_prefix}|g' \ + -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''NEXT_SYS_XATTR_H''@||g' \ + -e '/definition of _GL_UNUSED_PARAMETER/r $(UNUSED_PARAMETER_H)' \ + < $(srcdir)/sys_xattr.in.h; \ + } > address@hidden && \ + chmod a-x address@hidden && \ + mv address@hidden $@ +MOSTLYCLEANFILES += sys/xattr.h sys/xattr.h-t +MOSTLYCLEANDIRS += sys + +Include: + + + +Link: + +License: +LGPLv2+ + +Maintainer: +all -- 1.7.11.2