posix: add posix_fadvise(), only error checks.
should help for ports. Change-Id: Id504bdb79cb68db4b615f58848e0e1a86ced8d2b Reviewed-on: https://review.haiku-os.org/c/1467 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
parent
66cb2efaa8
commit
38ce902686
@ -67,6 +67,14 @@
|
||||
#define AT_REMOVEDIR 0x04 /* unlinkat() */
|
||||
#define AT_EACCESS 0x08 /* faccessat() */
|
||||
|
||||
/* file advisory information, unused by Haiku */
|
||||
#define POSIX_FADV_NORMAL 0 /* no advice */
|
||||
#define POSIX_FADV_SEQUENTIAL 1 /* expect sequential access */
|
||||
#define POSIX_FADV_RANDOM 2 /* expect access in a random order */
|
||||
#define POSIX_FADV_WILLNEED 3 /* expect access in the near future */
|
||||
#define POSIX_FADV_DONTNEED 4 /* expect no access in the near future */
|
||||
#define POSIX_FADV_NOREUSE 5 /* expect access only once */
|
||||
|
||||
/* advisory file locking */
|
||||
|
||||
struct flock {
|
||||
@ -90,6 +98,8 @@ extern int openat(int fd, const char *path, int openMode, ...);
|
||||
|
||||
extern int fcntl(int fd, int op, ...);
|
||||
|
||||
extern int posix_fadvise(int fd, off_t offset, off_t len, int advice);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -75,3 +75,23 @@ fcntl(int fd, int op, ...)
|
||||
|
||||
RETURN_AND_SET_ERRNO(error);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
posix_fadvise(int fd, off_t offset, off_t len, int advice)
|
||||
{
|
||||
if (len < 0 || offset < 0 || advice < POSIX_FADV_NORMAL
|
||||
|| advice > POSIX_FADV_NOREUSE) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
struct stat stat;
|
||||
if (fstat(fd, &stat) < 0)
|
||||
return EBADF;
|
||||
if (S_ISFIFO(stat.st_mode))
|
||||
return ESPIPE;
|
||||
|
||||
// Haiku does not use this information.
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user