2006-09-18 22:49:20 +00:00
# ifndef _system_filesys_h
# define _system_filesys_h
2009-09-15 20:26:24 +02:00
/*
2006-09-18 22:49:20 +00:00
Unix SMB / CIFS implementation .
filesystem system include wrappers
Copyright ( C ) Andrew Tridgell 2004
2009-09-15 20:26:24 +02:00
2007-06-02 09:10:08 +00:00
* * NOTE ! The following LGPL license applies to the replace
* * library . This does NOT imply that all of Samba is released
* * under the LGPL
2009-09-15 20:26:24 +02:00
2007-06-02 09:10:08 +00:00
This library is free software ; you can redistribute it and / or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation ; either
2007-07-10 01:44:42 +00:00
version 3 of the License , or ( at your option ) any later version .
2007-06-02 09:10:08 +00:00
This library is distributed in the hope that it will be useful ,
2006-09-18 22:49:20 +00:00
but WITHOUT ANY WARRANTY ; without even the implied warranty of
2007-06-02 09:10:08 +00:00
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU
Lesser General Public License for more details .
You should have received a copy of the GNU Lesser General Public
2007-07-10 03:42:26 +00:00
License along with this library ; if not , see < http : //www.gnu.org/licenses/>.
2007-06-02 09:10:08 +00:00
2006-09-18 22:49:20 +00:00
*/
2014-08-29 21:13:47 +10:00
# ifdef HAVE_UNISTD_H
2006-09-18 22:49:20 +00:00
# include <unistd.h>
2014-08-29 21:13:47 +10:00
# endif
2006-09-18 22:49:20 +00:00
# include <sys/stat.h>
# ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
# endif
# ifdef HAVE_SYS_MOUNT_H
# include <sys/mount.h>
# endif
2007-06-02 09:10:08 +00:00
# ifdef HAVE_MNTENT_H
# include <mntent.h>
# endif
2006-09-18 22:49:20 +00:00
# ifdef HAVE_SYS_VFS_H
# include <sys/vfs.h>
# endif
# ifdef HAVE_SYS_ACL_H
# include <sys/acl.h>
# endif
2007-03-22 18:16:36 +00:00
# ifdef HAVE_ACL_LIBACL_H
2007-03-22 17:35:34 +00:00
# include <acl/libacl.h>
# endif
2009-09-15 20:26:24 +02:00
# ifdef HAVE_SYS_FS_S5PARAM_H
2006-09-18 22:49:20 +00:00
# include <sys/fs/s5param.h>
# endif
# if defined (HAVE_SYS_FILSYS_H) && !defined (_CRAY)
2009-09-15 20:26:24 +02:00
# include <sys/filsys.h>
2006-09-18 22:49:20 +00:00
# endif
# ifdef HAVE_SYS_STATFS_H
# include <sys / statfs.h>
# endif
2009-09-15 20:26:24 +02:00
# ifdef HAVE_DUSTAT_H
2006-09-18 22:49:20 +00:00
# include <sys/dustat.h>
# endif
2009-09-15 20:26:24 +02:00
# ifdef HAVE_SYS_STATVFS_H
2006-09-18 22:49:20 +00:00
# include <sys/statvfs.h>
# endif
# ifdef HAVE_SYS_FILIO_H
# include <sys/filio.h>
# endif
2010-05-30 21:44:14 +02:00
# ifdef HAVE_SYS_FILE_H
2006-09-18 22:49:20 +00:00
# include <sys/file.h>
2010-05-30 21:44:14 +02:00
# endif
2006-09-18 22:49:20 +00:00
# ifdef HAVE_FCNTL_H
# include <fcntl.h>
# else
# ifdef HAVE_SYS_FCNTL_H
# include <sys/fcntl.h>
# endif
# endif
# ifdef HAVE_SYS_MODE_H
/* apparently AIX needs this for S_ISLNK */
# ifndef S_ISLNK
# include <sys/mode.h>
# endif
# endif
# ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
# endif
2011-09-08 08:01:30 +02:00
# ifdef HAVE_SYS_UIO_H
# include <sys/uio.h>
# endif
2006-09-18 22:49:20 +00:00
/* mutually exclusive (SuSE 8.2) */
lib/replace: prefer <sys/xattr.h> over <attr/xattr.h>
This prevents the following compile error that may happens if "system/filesys.h"
is included before "system/capability.h" on Ubuntu 16.04:
[1802/4407] Compiling source3/lib/system.c
In file included from ../../lib/replace/system/filesys.h:112:0,
from ../../source3/include/vfs.h:29,
from ../../source3/include/smb.h:150,
from ../../source3/include/includes.h:284,
from ../../source3/lib/system.c:23:
/usr/include/x86_64-linux-gnu/sys/xattr.h:32:3: error: expected identifier before numeric constant
XATTR_CREATE = 1, /* set value, fail if attr already exists. */
^
The above error is from compiling a source tree which includes a change that
adds an include "system/filesys.h" to the top of "source3/include/vfs.h".
"source3/lib/system.c" has the following includes:
#include "includes.h"
#include "system/syslog.h"
#include "system/capability.h"
#include "system/passwd.h"
#include "system/filesys.h"
#include "../lib/util/setid.h"
The first include of "includes.h" pulls in "vfs.h" which will pull in
"system/filesys.h" with the mentioned change. "system/filesys.h" pulls in
<attr/xattr.h> which has this define
#define XATTR_CREATE 0x1
Later in "source3/lib/system.c" "system/capability.h" is included which includes
<sys/xattr.h> on Ubuntu 16.04 (not in later versions of glibc). This defines the
XATTR_* values as an enum:
enum {
XATTR_CREATE = 1, /* set value, fail if attr already exists. */
XATTR_REPLACE = 2 /* set value, fail if attr does not exist. */
};
The previous define of XATTR_CREATE as 1 makes this
enum {
1 = 1, /* set value, fail if attr already exists. */
2 = 2 /* set value, fail if attr does not exist. */
};
which is invalid C. The compiler error diagnostic is a bit confusing, as it
prints the original enum from the include file.
See also:
<https://bugs.freedesktop.org/show_bug.cgi?id=78741>
<https://bugs.launchpad.net/ubuntu/+source/attr/+bug/1288091>
<https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=756097>
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Björn Baumbach <bb@samba.org>
2019-12-14 18:35:51 +01:00
# if defined(HAVE_SYS_XATTR_H)
2006-09-18 22:49:20 +00:00
# include <sys/xattr.h>
lib/replace: prefer <sys/xattr.h> over <attr/xattr.h>
This prevents the following compile error that may happens if "system/filesys.h"
is included before "system/capability.h" on Ubuntu 16.04:
[1802/4407] Compiling source3/lib/system.c
In file included from ../../lib/replace/system/filesys.h:112:0,
from ../../source3/include/vfs.h:29,
from ../../source3/include/smb.h:150,
from ../../source3/include/includes.h:284,
from ../../source3/lib/system.c:23:
/usr/include/x86_64-linux-gnu/sys/xattr.h:32:3: error: expected identifier before numeric constant
XATTR_CREATE = 1, /* set value, fail if attr already exists. */
^
The above error is from compiling a source tree which includes a change that
adds an include "system/filesys.h" to the top of "source3/include/vfs.h".
"source3/lib/system.c" has the following includes:
#include "includes.h"
#include "system/syslog.h"
#include "system/capability.h"
#include "system/passwd.h"
#include "system/filesys.h"
#include "../lib/util/setid.h"
The first include of "includes.h" pulls in "vfs.h" which will pull in
"system/filesys.h" with the mentioned change. "system/filesys.h" pulls in
<attr/xattr.h> which has this define
#define XATTR_CREATE 0x1
Later in "source3/lib/system.c" "system/capability.h" is included which includes
<sys/xattr.h> on Ubuntu 16.04 (not in later versions of glibc). This defines the
XATTR_* values as an enum:
enum {
XATTR_CREATE = 1, /* set value, fail if attr already exists. */
XATTR_REPLACE = 2 /* set value, fail if attr does not exist. */
};
The previous define of XATTR_CREATE as 1 makes this
enum {
1 = 1, /* set value, fail if attr already exists. */
2 = 2 /* set value, fail if attr does not exist. */
};
which is invalid C. The compiler error diagnostic is a bit confusing, as it
prints the original enum from the include file.
See also:
<https://bugs.freedesktop.org/show_bug.cgi?id=78741>
<https://bugs.launchpad.net/ubuntu/+source/attr/+bug/1288091>
<https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=756097>
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Björn Baumbach <bb@samba.org>
2019-12-14 18:35:51 +01:00
# elif defined(HAVE_ATTR_XATTR_H)
# include <attr/xattr.h>
2019-12-12 10:46:21 +01:00
# elif defined(HAVE_SYS_ATTRIBUTES_H)
# include <sys/attributes.h>
# elif defined(HAVE_ATTR_ATTRIBUTES_H)
# include <attr/attributes.h>
2006-09-18 22:49:20 +00:00
# endif
2012-06-01 13:29:38 +10:00
# ifdef HAVE_SYS_EA_H
# include <sys/ea.h>
# endif
# ifdef HAVE_SYS_EXTATTR_H
# include <sys/extattr.h>
# endif
2006-09-18 22:49:20 +00:00
# ifdef HAVE_SYS_RESOURCE_H
# include <sys/resource.h>
# endif
2012-06-01 13:29:38 +10:00
# ifndef XATTR_CREATE
# define XATTR_CREATE 0x1 /* set value, fail if attr already exists */
# endif
# ifndef XATTR_REPLACE
# define XATTR_REPLACE 0x2 /* set value, fail if attr does not exist */
# endif
2006-09-18 22:49:20 +00:00
/* Some POSIX definitions for those without */
2009-09-15 20:26:24 +02:00
2006-09-18 22:49:20 +00:00
# ifndef S_IFDIR
# define S_IFDIR 0x4000
# endif
# ifndef S_ISDIR
# define S_ISDIR(mode) ((mode & 0xF000) == S_IFDIR)
# endif
# ifndef S_IRWXU
# define S_IRWXU 00700 /* read, write, execute: owner */
# endif
# ifndef S_IRUSR
# define S_IRUSR 00400 /* read permission: owner */
# endif
# ifndef S_IWUSR
# define S_IWUSR 00200 /* write permission: owner */
# endif
# ifndef S_IXUSR
# define S_IXUSR 00100 /* execute permission: owner */
# endif
# ifndef S_IRWXG
# define S_IRWXG 00070 /* read, write, execute: group */
# endif
# ifndef S_IRGRP
# define S_IRGRP 00040 /* read permission: group */
# endif
# ifndef S_IWGRP
# define S_IWGRP 00020 /* write permission: group */
# endif
# ifndef S_IXGRP
# define S_IXGRP 00010 /* execute permission: group */
# endif
# ifndef S_IRWXO
# define S_IRWXO 00007 /* read, write, execute: other */
# endif
# ifndef S_IROTH
# define S_IROTH 00004 /* read permission: other */
# endif
# ifndef S_IWOTH
# define S_IWOTH 00002 /* write permission: other */
# endif
# ifndef S_IXOTH
# define S_IXOTH 00001 /* execute permission: other */
# endif
# ifndef O_ACCMODE
# define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
# endif
# ifndef MAXPATHLEN
# define MAXPATHLEN 256
# endif
# ifndef SEEK_SET
# define SEEK_SET 0
# endif
2009-04-20 15:39:48 +02:00
# ifdef _WIN32
# define mkdir(d,m) _mkdir(d)
# endif
2012-04-18 14:35:17 +10:00
/*
this allows us to use a uniform error handling for our xattr
wrappers
*/
# ifndef ENOATTR
# define ENOATTR ENODATA
# endif
2012-06-01 13:29:38 +10:00
2018-03-12 18:44:38 +01:00
# if !defined(HAVE_XATTR_XATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
2012-06-01 13:29:38 +10:00
ssize_t rep_getxattr ( const char * path , const char * name , void * value , size_t size ) ;
2012-06-03 15:56:29 +10:00
# define getxattr(path, name, value, size) rep_getxattr(path, name, value, size)
2012-06-01 13:29:38 +10:00
/* define is in "replace.h" */
ssize_t rep_fgetxattr ( int filedes , const char * name , void * value , size_t size ) ;
2012-06-03 15:56:29 +10:00
# define fgetxattr(filedes, name, value, size) rep_fgetxattr(filedes, name, value, size)
2012-06-01 13:29:38 +10:00
/* define is in "replace.h" */
ssize_t rep_listxattr ( const char * path , char * list , size_t size ) ;
2012-06-03 15:56:29 +10:00
# define listxattr(path, list, size) rep_listxattr(path, list, size)
2012-06-01 13:29:38 +10:00
/* define is in "replace.h" */
ssize_t rep_flistxattr ( int filedes , char * list , size_t size ) ;
2012-06-03 15:56:29 +10:00
# define flistxattr(filedes, value, size) rep_flistxattr(filedes, value, size)
2012-06-01 13:29:38 +10:00
/* define is in "replace.h" */
int rep_removexattr ( const char * path , const char * name ) ;
2012-06-03 15:56:29 +10:00
# define removexattr(path, name) rep_removexattr(path, name)
2012-06-01 13:29:38 +10:00
/* define is in "replace.h" */
int rep_fremovexattr ( int filedes , const char * name ) ;
2012-06-03 15:56:29 +10:00
# define fremovexattr(filedes, name) rep_fremovexattr(filedes, name)
2012-06-01 13:29:38 +10:00
/* define is in "replace.h" */
int rep_setxattr ( const char * path , const char * name , const void * value , size_t size , int flags ) ;
2012-06-03 15:56:29 +10:00
# define setxattr(path, name, value, size, flags) rep_setxattr(path, name, value, size, flags)
2012-06-01 13:29:38 +10:00
/* define is in "replace.h" */
int rep_fsetxattr ( int filedes , const char * name , const void * value , size_t size , int flags ) ;
2012-06-03 15:56:29 +10:00
# define fsetxattr(filedes, name, value, size, flags) rep_fsetxattr(filedes, name, value, size, flags)
2012-06-01 13:29:38 +10:00
/* define is in "replace.h" */
2018-03-12 18:44:38 +01:00
# endif /* !defined(HAVE_XATTR_XATTR) || defined(XATTR_ADDITIONAL_OPTIONS) */
2012-06-01 13:29:38 +10:00
2006-09-18 22:49:20 +00:00
# endif