Merge "Header improvements."

This commit is contained in:
Elliott Hughes 2019-11-04 21:58:20 +00:00 committed by Gerrit Code Review
commit 590bdbe6e9
2 changed files with 258 additions and 23 deletions

View file

@ -26,9 +26,14 @@
* SUCH DAMAGE.
*/
#ifndef _FCNTL_H
#pragma once
#define _FCNTL_H
/**
* @file fcntl.h
* @brief File control operations.
*/
#include <sys/cdefs.h>
#include <sys/types.h>
#include <linux/fadvise.h>
@ -48,47 +53,180 @@ __BEGIN_DECLS
#ifdef __LP64__
/* LP64 kernels don't have F_*64 defines because their flock is 64-bit. */
/** Flag for flock(). */
#define F_GETLK64 F_GETLK
/** Flag for flock(). */
#define F_SETLK64 F_SETLK
/** Flag for flock(). */
#define F_SETLKW64 F_SETLKW
#endif
/** Flag for open(). */
#define O_ASYNC FASYNC
/** Flag for open(). */
#define O_RSYNC O_SYNC
#if __ANDROID_API__ >= __ANDROID_API_L__
/** Flag for splice(). */
#define SPLICE_F_MOVE 1
/** Flag for splice(). */
#define SPLICE_F_NONBLOCK 2
/** Flag for splice(). */
#define SPLICE_F_MORE 4
/** Flag for splice(). */
#define SPLICE_F_GIFT 8
#endif
#if __ANDROID_API__ >= __ANDROID_API_O__
/** Flag for sync_file_range(). */
#define SYNC_FILE_RANGE_WAIT_BEFORE 1
/** Flag for sync_file_range(). */
#define SYNC_FILE_RANGE_WRITE 2
/** Flag for sync_file_range(). */
#define SYNC_FILE_RANGE_WAIT_AFTER 4
#endif
/**
* [creat(2)](http://man7.org/linux/man-pages/man2/creat.2.html)
* creates a file.
*
* Returns a new file descriptor on success and returns -1 and sets `errno` on
* failure.
*/
int creat(const char* __path, mode_t __mode);
/** See creat(). */
int creat64(const char* __path, mode_t __mode) __INTRODUCED_IN(21);
/**
* [openat(2)](http://man7.org/linux/man-pages/man2/openat.2.html)
* opens (and possibly creates) a file.
*
* Returns a new file descriptor on success and returns -1 and sets `errno` on
* failure.
*/
int openat(int __dir_fd, const char* __path, int __flags, ...);
/** See openat(). */
int openat64(int __dir_fd, const char* __path, int __flags, ...) __INTRODUCED_IN(21);
/**
* [open(2)](http://man7.org/linux/man-pages/man2/open.2.html)
* opens (and possibly creates) a file.
*
* Returns a new file descriptor on success and returns -1 and sets `errno` on
* failure.
*/
int open(const char* __path, int __flags, ...);
/** See open(). */
int open64(const char* __path, int __flags, ...) __INTRODUCED_IN(21);
/**
* [splice(2)](http://man7.org/linux/man-pages/man2/splice.2.html)
* splices data to/from a pipe.
*
* Valid flags are `SPLICE_F_MOVE`, `SPLICE_F_NONBLOCK`, `SPLICE_F_MORE`, and
* `SPLICE_F_GIFT`.
*
* Returns the number of bytes spliced on success and returns -1 and sets
* `errno` on failure.
*
* Available since API level 21.
*/
ssize_t splice(int __in_fd, off64_t* __in_offset, int __out_fd, off64_t* __out_offset, size_t __length, unsigned int __flags) __INTRODUCED_IN(21);
/**
* [tee(2)](http://man7.org/linux/man-pages/man2/tee.2.html)
* duplicates data from one pipe to another.
*
* Valid flags are `SPLICE_F_MOVE`, `SPLICE_F_NONBLOCK`, `SPLICE_F_MORE`, and
* `SPLICE_F_GIFT`.
*
* Returns the number of bytes duplicated on success and returns -1 and sets
* `errno` on failure.
*
* Available since API level 21.
*/
ssize_t tee(int __in_fd, int __out_fd, size_t __length, unsigned int __flags) __INTRODUCED_IN(21);
/**
* [vmsplice(2)](http://man7.org/linux/man-pages/man2/vmsplice.2.html)
* splices data to/from a pipe.
*
* Valid flags are `SPLICE_F_MOVE`, `SPLICE_F_NONBLOCK`, `SPLICE_F_MORE`, and
* `SPLICE_F_GIFT`.
*
* Returns the number of bytes spliced on success and returns -1 and sets
* `errno` on failure.
*
* Available since API level 21.
*/
ssize_t vmsplice(int __fd, const struct iovec* __iov, size_t __count, unsigned int __flags) __INTRODUCED_IN(21);
/**
* [fallocate(2)](http://man7.org/linux/man-pages/man2/fallocate.2.html)
* is a Linux-specific extension of posix_fallocate().
*
* Valid flags are `FALLOC_FL_KEEP_SIZE`, `FALLOC_FL_PUNCH_HOLE`,
* `FALLOC_FL_NO_HIDE_STALE`, `FALLOC_FL_COLLAPSE_RANGE`,
* `FALLOC_FL_ZERO_RANGE`, `FALLOC_FL_INSERT_RANGE`, and
* `FALLOC_FL_UNSHARE_RANGE`.
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
*
* Available since API level 21.
*/
int fallocate(int __fd, int __mode, off_t __offset, off_t __length) __RENAME_IF_FILE_OFFSET64(fallocate64) __INTRODUCED_IN(21);
/** See fallocate(). */
int fallocate64(int __fd, int __mode, off64_t __offset, off64_t __length) __INTRODUCED_IN(21);
/**
* [posix_fadvise(2)](http://man7.org/linux/man-pages/man2/posix_fadvise.2.html)
* declares an expected access pattern for file data.
*
* Valid flags are `POSIX_FADV_NORMAL`, `POSIX_FADV_RANDOM`,
* `POSIX_FADV_SEQUENTIAL`, `POSIX_FADV_WILLNEED`, `POSIX_FADV_DONTNEED`,
* and `POSIX_FADV_NOREUSE`.
*
* Returns 0 on success and returns an error number on failure.
*
* Available since API level 21.
*/
int posix_fadvise(int __fd, off_t __offset, off_t __length, int __advice) __RENAME_IF_FILE_OFFSET64(posix_fadvise64) __INTRODUCED_IN(21);
/** See posix_fadvise(). */
int posix_fadvise64(int __fd, off64_t __offset, off64_t __length, int __advice) __INTRODUCED_IN(21);
/**
* [posix_fallocate(2)](http://man7.org/linux/man-pages/man2/posix_fallocate.2.html)
* allocates file space.
*
* Returns 0 on success and returns an error number on failure.
*
* Available since API level 21.
*/
int posix_fallocate(int __fd, off_t __offset, off_t __length) __RENAME_IF_FILE_OFFSET64(posix_fallocate64) __INTRODUCED_IN(21);
/** See posix_fallocate(). */
int posix_fallocate64(int __fd, off64_t __offset, off64_t __length) __INTRODUCED_IN(21);
#if defined(__USE_GNU)
ssize_t readahead(int __fd, off64_t __offset, size_t __length) __INTRODUCED_IN(16);
/**
* [readahead(2)](http://man7.org/linux/man-pages/man2/readahead.2.html)
* initiates readahead for the given file.
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
*/
ssize_t readahead(int __fd, off64_t __offset, size_t __length);
/**
* [sync_file_range(2)](http://man7.org/linux/man-pages/man2/sync_file_range.2.html)
* syncs part of a file with disk.
*
* Valid flags are `SYNC_FILE_RANGE_WAIT_BEFORE`, `SYNC_FILE_RANGE_WRITE`, and
* `SYNC_FILE_RANGE_WAIT_AFTER`.
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
*/
int sync_file_range(int __fd, off64_t __offset, off64_t __length, unsigned int __flags) __INTRODUCED_IN(26);
#endif
#if defined(__BIONIC_INCLUDE_FORTIFY_HEADERS)
@ -96,5 +234,3 @@ int sync_file_range(int __fd, off64_t __offset, off64_t __length, unsigned int _
#endif
__END_DECLS
#endif

View file

@ -26,8 +26,12 @@
* SUCH DAMAGE.
*/
#ifndef _SYS_XATTR_H_
#define _SYS_XATTR_H_
#pragma once
/**
* @file sys/xattr.h
* @brief Extended attribute functions.
*/
#include <linux/xattr.h>
#include <sys/cdefs.h>
@ -35,25 +39,120 @@
__BEGIN_DECLS
int fsetxattr(int __fd, const char* __name, const void* __value, size_t __size, int __flags)
__INTRODUCED_IN(16);
int setxattr(const char* __path, const char* __name, const void* __value, size_t __size, int __flags)
__INTRODUCED_IN(16);
int lsetxattr(const char* __path, const char* __name, const void* __value, size_t __size, int __flags)
__INTRODUCED_IN(16);
/**
* [fsetxattr(2)](http://man7.org/linux/man-pages/man2/fsetxattr.2.html)
* sets an extended attribute on the file referred to by the given file
* descriptor.
*
* Valid flags are `XATTR_CREATE` and `XATTR_REPLACE`.
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
*/
int fsetxattr(int __fd, const char* __name, const void* __value, size_t __size, int __flags);
ssize_t fgetxattr(int __fd, const char* __name, void* __value, size_t __size) __INTRODUCED_IN(16);
ssize_t getxattr(const char* __path, const char* __name, void* __value, size_t __size) __INTRODUCED_IN(16);
ssize_t lgetxattr(const char* __path, const char* __name, void* __value, size_t __size) __INTRODUCED_IN(16);
/**
* [setxattr(2)](http://man7.org/linux/man-pages/man2/setxattr.2.html)
* sets an extended attribute on the file referred to by the given path.
*
* Valid flags are `XATTR_CREATE` and `XATTR_REPLACE`.
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
*/
int setxattr(const char* __path, const char* __name, const void* __value, size_t __size, int __flags);
ssize_t listxattr(const char* __path, char* __list, size_t __size) __INTRODUCED_IN(16);
ssize_t llistxattr(const char* __path, char* __list, size_t __size) __INTRODUCED_IN(16);
ssize_t flistxattr(int __fd, char* __list, size_t __size) __INTRODUCED_IN(16);
/**
* [lsetxattr(2)](http://man7.org/linux/man-pages/man2/lsetxattr.2.html)
* sets an extended attribute on the file referred to by the given path, which
* is the link itself rather than its target in the case of a symbolic link.
*
* Valid flags are `XATTR_CREATE` and `XATTR_REPLACE`.
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
*/
int lsetxattr(const char* __path, const char* __name, const void* __value, size_t __size, int __flags);
int removexattr(const char* __path, const char* __name) __INTRODUCED_IN(16);
int lremovexattr(const char* __path, const char* __name) __INTRODUCED_IN(16);
int fremovexattr(int __fd, const char* __name) __INTRODUCED_IN(16);
/**
* [fgetxattr(2)](http://man7.org/linux/man-pages/man2/fgetxattr.2.html)
* gets an extended attribute on the file referred to by the given file
* descriptor.
*
* Returns the non-negative length of the value on success, or
* returns -1 and sets `errno` on failure.
*/
ssize_t fgetxattr(int __fd, const char* __name, void* __value, size_t __size);
/**
* [getxattr(2)](http://man7.org/linux/man-pages/man2/getxattr.2.html)
* gets an extended attribute on the file referred to by the given path.
*
* Returns the non-negative length of the value on success, or
* returns -1 and sets `errno` on failure.
*/
ssize_t getxattr(const char* __path, const char* __name, void* __value, size_t __size);
/**
* [lgetxattr(2)](http://man7.org/linux/man-pages/man2/lgetxattr.2.html)
* gets an extended attribute on the file referred to by the given path, which
* is the link itself rather than its target in the case of a symbolic link.
*
* Returns the non-negative length of the value on success, or
* returns -1 and sets `errno` on failure.
*/
ssize_t lgetxattr(const char* __path, const char* __name, void* __value, size_t __size);
/**
* [flistxattr(2)](http://man7.org/linux/man-pages/man2/flistxattr.2.html)
* lists the extended attributes on the file referred to by the given file
* descriptor.
*
* Returns the non-negative length of the list on success, or
* returns -1 and sets `errno` on failure.
*/
ssize_t flistxattr(int __fd, char* __list, size_t __size);
/**
* [listxattr(2)](http://man7.org/linux/man-pages/man2/listxattr.2.html)
* lists the extended attributes on the file referred to by the given path.
*
* Returns the non-negative length of the list on success, or
* returns -1 and sets `errno` on failure.
*/
ssize_t listxattr(const char* __path, char* __list, size_t __size);
/**
* [llistxattr(2)](http://man7.org/linux/man-pages/man2/llistxattr.2.html)
* lists the extended attributes on the file referred to by the given path, which
* is the link itself rather than its target in the case of a symbolic link.
*
* Returns the non-negative length of the list on success, or
* returns -1 and sets `errno` on failure.
*/
ssize_t llistxattr(const char* __path, char* __list, size_t __size);
/**
* [fremovexattr(2)](http://man7.org/linux/man-pages/man2/fremovexattr.2.html)
* removes an extended attribute on the file referred to by the given file
* descriptor.
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
*/
int fremovexattr(int __fd, const char* __name);
/**
* [lremovexattr(2)](http://man7.org/linux/man-pages/man2/lremovexattr.2.html)
* removes an extended attribute on the file referred to by the given path, which
* is the link itself rather than its target in the case of a symbolic link.
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
*/
int lremovexattr(const char* __path, const char* __name);
/**
* [removexattr(2)](http://man7.org/linux/man-pages/man2/removexattr.2.html)
* removes an extended attribute on the file referred to by the given path.
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
*/
int removexattr(const char* __path, const char* __name);
__END_DECLS
#endif