ntdll-DOS_Attributes: Restore a definition for FreeBSD.

This commit is contained in:
Zebediah Figura 2020-12-05 21:48:19 -06:00
parent 8229c98169
commit 2dc013940d

View File

@ -1,18 +1,18 @@
From 59c903c16b59c7b54479866c04532f7f501767d8 Mon Sep 17 00:00:00 2001
From e7dacaafcbdef04a9cabfdb645497f89d19ca781 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Mon, 6 Oct 2014 14:26:24 -0600
Subject: [PATCH] libport: Add support for FreeBSD style extended attributes.
Subject: [PATCH] ntdll: Add support for FreeBSD style extended attributes.
---
configure.ac | 2 +-
dlls/ntdll/unix/file.c | 25 +++++++++++++++++++++++++
2 files changed, 26 insertions(+), 1 deletion(-)
dlls/ntdll/unix/file.c | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index ec5e2da4490..b5586643fa9 100644
index f964230858e..a37b314a063 100644
--- a/configure.ac
+++ b/configure.ac
@@ -695,7 +695,7 @@ AC_CHECK_HEADERS([libprocstat.h],,,
@@ -689,7 +689,7 @@ AC_CHECK_HEADERS([libprocstat.h],,,
if test "x$with_xattr" != "xno"
then
@ -22,10 +22,10 @@ index ec5e2da4490..b5586643fa9 100644
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/xattr.h>]], [[getxattr("", "", "", 0, 0, 0);]])],
[AC_DEFINE(XATTR_ADDITIONAL_OPTIONS, 1, [Define if xattr functions take additional arguments (Mac OS X)])])])
diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c
index 099663396e5..5889ec4dd3f 100644
index 301241e2edd..4ccc74c300a 100644
--- a/dlls/ntdll/unix/file.c
+++ b/dlls/ntdll/unix/file.c
@@ -111,6 +111,10 @@
@@ -114,6 +114,10 @@
#elif defined(HAVE_SYS_XATTR_H)
#include <sys/xattr.h>
#endif
@ -36,17 +36,29 @@ index 099663396e5..5889ec4dd3f 100644
#include <time.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
@@ -378,6 +382,9 @@ NTSTATUS errno_to_status( int err )
@@ -381,6 +385,21 @@ NTSTATUS errno_to_status( int err )
#ifndef XATTR_USER_PREFIX
#define XATTR_USER_PREFIX "user."
#endif
+#ifndef XATTR_USER_PREFIX_LEN
+#define XATTR_USER_PREFIX_LEN (sizeof(XATTR_USER_PREFIX) - 1)
+#endif
+
+#ifdef HAVE_SYS_EXTATTR_H
+static inline int xattr_valid_namespace( const char *name )
+{
+ if (strncmp( XATTR_USER_PREFIX, name, XATTR_USER_PREFIX_LEN ) != 0)
+ {
+ errno = EPERM;
+ return 0;
+ }
+ return 1;
+}
+#endif
static int xattr_fremove( int filedes, const char *name )
{
@@ -385,6 +392,9 @@ static int xattr_fremove( int filedes, const char *name )
@@ -388,6 +407,9 @@ static int xattr_fremove( int filedes, const char *name )
return fremovexattr( filedes, name, 0 );
#elif defined(HAVE_SYS_XATTR_H) || defined(HAVE_ATTR_XATTR_H)
return fremovexattr( filedes, name );
@ -56,7 +68,7 @@ index 099663396e5..5889ec4dd3f 100644
#else
errno = ENOSYS;
return -1;
@@ -397,6 +407,10 @@ static int xattr_fset( int filedes, const char *name, void *value, size_t size )
@@ -400,6 +422,10 @@ static int xattr_fset( int filedes, const char *name, void *value, size_t size )
return fsetxattr( filedes, name, value, size, 0, 0 );
#elif defined(HAVE_SYS_XATTR_H) || defined(HAVE_ATTR_XATTR_H)
return fsetxattr( filedes, name, value, size, 0 );
@ -67,7 +79,7 @@ index 099663396e5..5889ec4dd3f 100644
#else
errno = ENOSYS;
return -1;
@@ -409,6 +423,10 @@ static int xattr_get( const char *path, const char *name, void *value, size_t si
@@ -412,6 +438,10 @@ static int xattr_get( const char *path, const char *name, void *value, size_t si
return getxattr( path, name, value, size, 0, 0 );
#elif defined(HAVE_SYS_XATTR_H) || defined(HAVE_ATTR_XATTR_H)
return getxattr( path, name, value, size );
@ -78,7 +90,7 @@ index 099663396e5..5889ec4dd3f 100644
#else
errno = ENOSYS;
return -1;
@@ -421,6 +439,9 @@ static int xattr_remove( const char *path, const char *name )
@@ -424,6 +454,9 @@ static int xattr_remove( const char *path, const char *name )
return removexattr( path, name, 0 );
#elif defined(HAVE_SYS_XATTR_H) || defined(HAVE_ATTR_XATTR_H)
return removexattr( path, name );
@ -88,7 +100,7 @@ index 099663396e5..5889ec4dd3f 100644
#else
errno = ENOSYS;
return -1;
@@ -433,6 +454,10 @@ static int xattr_set( const char *path, const char *name, void *value, size_t si
@@ -436,6 +469,10 @@ static int xattr_set( const char *path, const char *name, void *value, size_t si
return setxattr( path, name, value, size, 0, 0 );
#elif defined(HAVE_SYS_XATTR_H) || defined(HAVE_ATTR_XATTR_H)
return setxattr( path, name, value, size, 0 );
@ -100,5 +112,5 @@ index 099663396e5..5889ec4dd3f 100644
errno = ENOSYS;
return -1;
--
2.28.0
2.29.2