mds/dev-libs/apr/files/apr-xattr-headers.patch
Mario Fetka 31ea2d3abf dev-libs/apr: add privsep patch & Multilib Patch
(Portage version: 2.2.0_alpha75-r1/git/Linux x86_64, RepoMan options: --force, unsigned Manifest commit)
2011-11-21 20:16:43 +01:00

367 lines
14 KiB
Diff

Index: include/apr_file_xattr.h
===================================================================
--- include/apr_file_xattr.h (revision 0)
+++ include/apr_file_xattr.h (revision 0)
@@ -0,0 +1,249 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef APR_FILE_XATTR_H
+#define APR_FILE_XATTR_H
+
+/**
+ * @file apr_file_xattr.h
+ * @brief APR File Extended Attributes
+ */
+
+#include "apr.h"
+#include "apr_pools.h"
+#include "apr_tables.h"
+#include "apr_file_io.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @defgroup apr_xattr File Extended Attribute Functions
+ * @ingroup APR
+ * @{
+ */
+
+/** When setting values, fail if the attribute already exists */
+#define APR_XATTR_CREATE 1
+
+/** When setting values, fail if the attribute does not already exist */
+#define APR_XATTR_REPLACE 2
+
+typedef struct apr_xattr_t apr_xattr_t;
+
+/**
+ * Open a context for access to the extended attributes of a file or
+ * directory specified by a path name
+ *
+ * @param new the context allocated for access to extended attributes
+ * @param pathname the path name of the file or directory
+ * @param p the pool to allocate any memory from
+ * @return the status of the operation:
+ * <PRE>
+ * APR_SUCCESS the path was opened for attribute access
+ * APR_STATUS_IS_ENOENT() the file or directory does not exist
+ * </PRE>
+ * Other operating system dependant error codes may be returned.
+ *
+ * @warning Platforms which do not implement this feature will return
+ * APR_ENOTIMPL.
+ */
+APR_DECLARE(apr_status_t) apr_xattr_open_path(apr_xattr_t **new,
+ const char *pathname,
+ apr_pool_t *p);
+
+/**
+ * Open a context for access to the extended attributes of an open file
+ *
+ * @param new the context allocated for access to extended attributes
+ * @param file the open file to access the extended attributes on
+ * @param p the pool to allocate any memory from
+ * @return the status of the operation:
+ * <PRE>
+ * APR_SUCCESS the file was opened for attribute access
+ * </PRE>
+ *
+ * @warning Platforms which do not implement this feature will return
+ * APR_ENOTIMPL.
+ */
+APR_DECLARE(apr_status_t) apr_xattr_open_file(apr_xattr_t **new,
+ apr_file_t *file,
+ apr_pool_t *p);
+
+/**
+ * Open a context for access to the extended attributes of an open directory
+ *
+ * @param new the context allocated for access to extended attributes
+ * @param dir the open directory to access the extended attributes on
+ * @param p the pool to allocate any memory from if required
+ * @return the status of the operation:
+ * <PRE>
+ * APR_SUCCESS the directory was opened for attribute access
+ * </PRE>
+ *
+ * @warning Platforms which do not implement this feature will return
+ * APR_ENOTIMPL.
+ */
+APR_DECLARE(apr_status_t) apr_xattr_open_dir(apr_xattr_t **new,
+ apr_dir_t *dir,
+ apr_pool_t *p);
+
+/**
+ * Destroy a context used for access to extended attributes
+ *
+ * @param xattr the context to destroy
+ * <PRE>
+ * APR_SUCCESS the context was destroyed
+ * </PRE>
+ *
+ * @warning Platforms which do not implement this feature will return
+ * APR_ENOTIMPL.
+ */
+APR_DECLARE(apr_status_t) apr_xattr_destroy(apr_xattr_t *xattr);
+
+/**
+ * Set an extended attribute on a file or directory
+ * @param xattr the opened extended attribute file or directory context
+ * @param name the attribute name to set
+ * @param value the attribute value
+ * @param size the size in bytes of the attribute value
+ * @param flags to control how the attribute is set
+ * <PRE>
+ * APR_XATTR_CREATE return an error if the attribute name
+ * already exists.
+ * APR_XATTR_REPLACE return an error if the attribute name
+ * does not already exist.
+ * </PRE>
+ * @param p the pool to allocate any memory from if required
+ * @return the status of the operation:
+ * <PRE>
+ * APR_SUCCESS the attribute was set
+ * APR_STATUS_IS_EEXIST() create flag and the attribute exists
+ * APR_STATUS_IS_ENOATTR() replace flag and the attribute doesn't exist
+ * </PRE>
+ * Other operating system dependant error codes may be returned
+ * in the cases not listed above.
+ *
+ * @remark if neither flag APR_XATTR_CREATE or APR_XATTR_REPLACE are
+ * given then the attribute will either be created if it does not
+ * already exist or replaced if it does exist.
+ *
+ * @warning Platforms which do not implement this feature will return
+ * APR_ENOTIMPL.
+ */
+APR_DECLARE(apr_status_t) apr_xattr_set(const apr_xattr_t *xattr,
+ const char *name,
+ const void *value,
+ apr_size_t size,
+ apr_uint32_t flags);
+
+/**
+ * Get an extended attribute from a file or directory
+ * @param xattr the opened extended attribute file or directory context
+ * @param name the name of the attribute to get
+ * @param value the returned attribute value allocated from the pool
+ * @param size the returned size of the attribute value
+ * @param flags to control how the attribute is got (reserved for future use)
+ * @param p the pool to allocate any memory from if required
+ * @return the status of the operation:
+ * <PRE>
+ * APR_SUCCESS the attribute was retrieved
+ * APR_STATUS_IS_ENOATTR() the attribute does not exist
+ * </PRE>
+ * Other operating system dependant error codes may be returned
+ * in the cases not listed above.
+ *
+ * @warning Platforms which do not implement this feature will return
+ * APR_ENOTIMPL.
+ */
+APR_DECLARE(apr_status_t) apr_xattr_get(const apr_xattr_t *xattr,
+ const char *name,
+ void **value,
+ apr_size_t *size,
+ apr_uint32_t flags);
+
+/**
+ * Check for the existence of an extended attribute on a file or directory
+ * @param xattr the opened extended attribute file or directory context
+ * @param name the name of the attribute to get
+ * @param exists the returned value indicating whether the attribute exists
+ * @param flags to control how the attribute is got (reserved for future use)
+ * @param p the pool to allocate any memory from if required
+ * @return the status of the operation:
+ * <PRE>
+ * APR_SUCCESS the existence was successfully tested
+ * </PRE>
+ * Other operating system dependant error codes may be returned
+ * in the cases not listed above.
+ *
+ * @warning Platforms which do not implement this feature will return
+ * APR_ENOTIMPL.
+ */
+APR_DECLARE(apr_status_t) apr_xattr_exists(const apr_xattr_t *xattr,
+ const char *name,
+ int *exists,
+ apr_uint32_t flags);
+
+/**
+ * List the extended attributes on a file or directory
+ * @param xattr the opened extended attribute file or directory context
+ * @param list the returned array of attributes names
+ * @param flags to control how the file is listed (reserved for future use)
+ * @param p the pool to allocate any memory from if required
+ * @return the status of the operation:
+ * <PRE>
+ * APR_SUCCESS the attributes were listed
+ * </PRE>
+ * Other operating system dependant error codes may be returned
+ * in the cases not listed above.
+ *
+ * @remark list is an array containing simple null terminated strings.
+ *
+ * @warning Platforms which do not implement this feature will return
+ * APR_ENOTIMPL.
+ */
+APR_DECLARE(apr_status_t) apr_xattr_list(const apr_xattr_t *xattr,
+ apr_array_header_t **list,
+ apr_uint32_t flags);
+
+/**
+ * Remove an extended attribute from a file or directory
+ * @param xattr the opened extended attribute file or directory context
+ * @param name the attribute name to remove
+ * @param flags to control how the attribute is removed (reserved for future use)
+ * @param p the pool to allocate any memory from if required
+ * @return the status of the operation:
+ * <PRE>
+ * APR_SUCCESS the attribute was removed
+ * APR_STATUS_IS_ENOATTR() the attribute does not exist
+ * </PRE>
+ * Other operating system dependant error codes may be returned
+ * in the cases not listed above.
+ *
+ * @warning Platforms which do not implement this feature will return
+ * APR_ENOTIMPL.
+ */
+APR_DECLARE(apr_status_t) apr_xattr_remove(const apr_xattr_t *xattr,
+ const char *name,
+ apr_uint32_t flags);
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ! APR_FILE_XATTR_H */
Index: include/arch/unix/apr_arch_xattr.h
===================================================================
--- include/arch/unix/apr_arch_xattr.h (revision 0)
+++ include/arch/unix/apr_arch_xattr.h (revision 0)
@@ -0,0 +1,51 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FILE_XATTR_H
+#define FILE_XATTR_H
+
+#if APR_HAVE_CTYPE_H
+#include <ctype.h>
+#endif
+#if APR_HAVA_ERRNO_H
+#include <errno.h>
+#endif
+#if APR_HAVE_SYS_XATTR_H
+#include <sys/xattr.h>
+#endif
+#if APR_HAVE_SYS_EXTATTR_H
+#include <sys/extattr.h>
+#endif
+#if APR_HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+#if APR_HAVE_DIRENT_H
+#include <dirent.h>
+#endif
+
+#ifdef _LARGEFILE64_SOURCE
+#define XATTR_OPEN_FLAGS O_RDONLY | O_LARGEFILE
+#else
+#define XATTR_OPEN_FLAGS O_RDONLY
+#endif
+
+struct apr_xattr_t {
+ int fd;
+ apr_uint32_t flags;
+ apr_pool_t *pool;
+};
+
+#endif
Index: include/apr_errno.h
===================================================================
--- include/apr_errno.h (revision 606453)
+++ include/apr_errno.h (working copy)
@@ -851,6 +851,13 @@
#define APR_EAFNOSUPPORT (APR_OS_START_CANONERR + 27)
#endif
+/** @see APR_STATUS_IS_ENOATTR */
+#ifdef ENOATTR
+#define APR_ENOATTR ENOATTR
+#else
+#define APR_ENOATTR (APR_OS_START_CANONERR + 28)
+#endif
+
/** @} */
#if defined(OS2) && !defined(DOXYGEN)
@@ -995,6 +1002,7 @@
|| (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED)
#define APR_STATUS_IS_EAFNOSUPPORT(s) ((s) == APR_AFNOSUPPORT \
|| (s) == APR_OS_START_SYSERR + SOCEAFNOSUPPORT)
+#define APR_STATUS_IS_ENOATTR(s) ((s) == APR_ENOATTR)
/*
Sorry, too tired to wrap this up for OS2... feel free to
@@ -1139,6 +1147,7 @@
|| (s) == APR_OS_START_SYSERR + ERROR_DIR_NOT_EMPTY)
#define APR_STATUS_IS_EAFNOSUPPORT(s) ((s) == APR_EAFNOSUPPORT \
|| (s) == APR_OS_START_SYSERR + WSAEAFNOSUPPORT)
+#define APR_STATUS_IS_ENOATTR(s) ((s) == APR_ENOATTR)
#elif defined(NETWARE) && defined(USE_WINSOCK) && !defined(DOXYGEN) /* !defined(OS2) && !defined(WIN32) */
@@ -1200,6 +1209,7 @@
#define APR_STATUS_IS_ENOTEMPTY(s) ((s) == APR_ENOTEMPTY)
#define APR_STATUS_IS_EAFNOSUPPORT(s) ((s) == APR_EAFNOSUPPORT \
|| (s) == APR_OS_START_SYSERR + WSAEAFNOSUPPORT)
+#define APR_STATUS_IS_ENOATTR(s) ((s) == APR_ENOATTR)
#else /* !defined(NETWARE) && !defined(OS2) && !defined(WIN32) */
@@ -1319,6 +1329,13 @@
(s) == APR_EEXIST)
/** Address Family not supported */
#define APR_STATUS_IS_EAFNOSUPPORT(s) ((s) == APR_EAFNOSUPPORT)
+/** Attribute does not exists */
+#ifdef ENODATA
+#define APR_STATUS_IS_ENOATTR(s) ((s) == APR_ENOATTR \
+ || (s) == ENODATA)
+#else
+#define APR_STATUS_IS_ENOATTR(s) ((s) == APR_ENOATTR)
+#endif
/** @} */
#endif /* !defined(NETWARE) && !defined(OS2) && !defined(WIN32) */