mirror of
https://github.com/apache/nuttx.git
synced 2026-09-22 22:55:02 +08:00
fs: Add fchstat and chstat callback into mountpt_operations
and implement all status related change function. the individual file system change will provide in other upcoming patchset. Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com> Change-Id: I8fde9db8eba9586e9c8da078b67e020c26623cf4
This commit is contained in:
committed by
Gustavo Henrique Nihei
parent
68a345e248
commit
307cc61893
+39
-4
@@ -154,6 +154,16 @@
|
||||
#define DIRENT_SETPSEUDONODE(f) do (f) |= DIRENTFLAGS_PSEUDONODE; while (0)
|
||||
#define DIRENT_ISPSEUDONODE(f) (((f) & DIRENTFLAGS_PSEUDONODE) != 0)
|
||||
|
||||
/* The status change flags.
|
||||
* These should be or-ed together to figure out what want to change.
|
||||
*/
|
||||
|
||||
#define CH_STAT_MODE (1 << 0)
|
||||
#define CH_STAT_UID (1 << 1)
|
||||
#define CH_STAT_GID (1 << 2)
|
||||
#define CH_STAT_ATIME (1 << 3)
|
||||
#define CH_STAT_MTIME (1 << 4)
|
||||
|
||||
/* nx_umount() is equivalent to nx_umount2() with flags = 0 */
|
||||
|
||||
#define umount(t) umount2(t,0)
|
||||
@@ -276,6 +286,8 @@ struct mountpt_operations
|
||||
int (*sync)(FAR struct file *filep);
|
||||
int (*dup)(FAR const struct file *oldp, FAR struct file *newp);
|
||||
int (*fstat)(FAR const struct file *filep, FAR struct stat *buf);
|
||||
int (*fchstat)(FAR const struct file *filep,
|
||||
FAR const struct stat *buf, int flags);
|
||||
int (*truncate)(FAR struct file *filep, off_t length);
|
||||
|
||||
/* Directory operations */
|
||||
@@ -307,10 +319,8 @@ struct mountpt_operations
|
||||
FAR const char *newrelpath);
|
||||
int (*stat)(FAR struct inode *mountpt, FAR const char *relpath,
|
||||
FAR struct stat *buf);
|
||||
|
||||
/* NOTE: More operations will be needed here to support: disk usage
|
||||
* stats file stat(), file attributes, file truncation, etc.
|
||||
*/
|
||||
int (*chstat)(FAR struct inode *mountpt, FAR const char *relpath,
|
||||
FAR const struct stat *buf, int flags);
|
||||
};
|
||||
#endif /* CONFIG_DISABLE_MOUNTPOINT */
|
||||
|
||||
@@ -1358,6 +1368,31 @@ int file_fstat(FAR struct file *filep, FAR struct stat *buf);
|
||||
|
||||
int nx_stat(FAR const char *path, FAR struct stat *buf, int resolve);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: file_fchstat
|
||||
*
|
||||
* Description:
|
||||
* file_fchstat() is an internal OS interface. It is functionally similar
|
||||
* to the combination of fchmod/fchown/futimens standard interface except:
|
||||
*
|
||||
* - It does not modify the errno variable,
|
||||
* - It is not a cancellation point,
|
||||
* - It does not handle socket descriptors, and
|
||||
* - It accepts a file structure instance instead of file descriptor.
|
||||
*
|
||||
* Input Parameters:
|
||||
* filep - File structure instance
|
||||
* buf - The stat to be modified
|
||||
* flags - The vaild field in buf
|
||||
*
|
||||
* Returned Value:
|
||||
* Upon successful completion, 0 shall be returned. Otherwise, the
|
||||
* negative errno shall be returned to indicate the error.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int file_fchstat(FAR struct file *filep, FAR struct stat *buf, int flags);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nx_unlink
|
||||
*
|
||||
|
||||
@@ -107,6 +107,11 @@
|
||||
#define S_TYPEISMQ(buf) S_ISMQ((buf)->st_mode)
|
||||
#define S_TYPEISSHM(buf) S_ISSHM((buf)->st_mode)
|
||||
|
||||
/* Special value for tv_nsec field of timespec */
|
||||
|
||||
#define UTIME_NOW ((1l << 30) - 1l)
|
||||
#define UTIME_OMIT ((1l << 30) - 2l)
|
||||
|
||||
/* The following macros are required by POSIX to achieve backward
|
||||
* compatibility with earlier versions of struct stat.
|
||||
*/
|
||||
@@ -162,6 +167,7 @@ int stat(FAR const char *path, FAR struct stat *buf);
|
||||
int lstat(FAR const char *path, FAR struct stat *buf);
|
||||
int fstat(int fd, FAR struct stat *buf);
|
||||
int chmod(FAR const char *path, mode_t mode);
|
||||
int lchmod(FAR const char *path, mode_t mode);
|
||||
int fchmod(int fd, mode_t mode);
|
||||
int futimens(int fd, const struct timespec times[2]);
|
||||
|
||||
|
||||
@@ -248,6 +248,15 @@ SYSCALL_LOOKUP(statfs, 2)
|
||||
SYSCALL_LOOKUP(fstatfs, 2)
|
||||
SYSCALL_LOOKUP(telldir, 1)
|
||||
SYSCALL_LOOKUP(sendfile, 4)
|
||||
SYSCALL_LOOKUP(chmod, 2)
|
||||
SYSCALL_LOOKUP(lchmod, 2)
|
||||
SYSCALL_LOOKUP(fchmod, 2)
|
||||
SYSCALL_LOOKUP(chown, 3)
|
||||
SYSCALL_LOOKUP(lchown, 3)
|
||||
SYSCALL_LOOKUP(fchown, 3)
|
||||
SYSCALL_LOOKUP(utimes, 2)
|
||||
SYSCALL_LOOKUP(lutimes, 2)
|
||||
SYSCALL_LOOKUP(futimens, 2)
|
||||
|
||||
#if defined(CONFIG_FS_RAMMAP)
|
||||
SYSCALL_LOOKUP(munmap, 2)
|
||||
|
||||
@@ -372,6 +372,7 @@ int setitimer(int which, FAR const struct itimerval *value,
|
||||
****************************************************************************/
|
||||
|
||||
int utimes(FAR const char *path, const struct timeval times[2]);
|
||||
int lutimes(FAR const char *path, const struct timeval times[2]);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: futimes
|
||||
|
||||
@@ -317,6 +317,7 @@ ssize_t write(int fd, FAR const void *buf, size_t nbytes);
|
||||
ssize_t pread(int fd, FAR void *buf, size_t nbytes, off_t offset);
|
||||
ssize_t pwrite(int fd, FAR const void *buf, size_t nbytes, off_t offset);
|
||||
int ftruncate(int fd, off_t length);
|
||||
int fchown(int fd, uid_t owner, gid_t group);
|
||||
|
||||
#ifdef CONFIG_SERIAL_TERMIOS
|
||||
/* Check if a file descriptor corresponds to a terminal I/O file */
|
||||
@@ -356,6 +357,8 @@ int unlink(FAR const char *pathname);
|
||||
int truncate(FAR const char *path, off_t length);
|
||||
int symlink(FAR const char *path1, FAR const char *path2);
|
||||
ssize_t readlink(FAR const char *path, FAR char *buf, size_t bufsize);
|
||||
int chown(FAR const char *path, uid_t owner, gid_t group);
|
||||
int lchown(FAR const char *path, uid_t owner, gid_t group);
|
||||
|
||||
/* Execution of programs from files */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user