• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2022 Huawei Technologies Co., Ltd. All rights reserved.
3  *
4  * UniProton is licensed under Mulan PSL v2.
5  * You can use this software according to the terms and conditions of the Mulan PSL v2.
6  * You may obtain a copy of Mulan PSL v2 at:
7  *          http://license.coscl.org.cn/MulanPSL2
8  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
9  * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
10  * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
11  * See the Mulan PSL v2 for more details.
12  * Create: 2022-09-21
13  * Description: 文件系统vfs层
14  */
15 #ifndef VFS_OPERATIONS_H
16 #define VFS_OPERATIONS_H
17 
18 #include "errno.h"
19 #include "fcntl.h"
20 #include "dirent.h"
21 #include "stdint.h"
22 #include "stdarg.h"
23 #include "unistd.h"
24 #include "sys/mount.h"
25 #include "sys/stat.h"
26 #include "sys/statfs.h"
27 #include "prt_fs.h"
28 
29 #define PRT_FCNTL   (O_NONBLOCK | O_NDELAY | O_APPEND | O_SYNC)
30 #define IOV_MAX_CNT 4
31 
VFS_ERRNO_SET(U32 err)32 static inline void VFS_ERRNO_SET(U32 err)
33 {
34     errno = err;
35     return;
36 }
37 
38 S32 OsVfsLock(void);
39 void OsVfsUnlock(void);
40 S32 OsVfsOpen(const char *path, S32 flags, va_list ap);
41 S32 OsVfsClose(S32 fd);
42 ssize_t OsVfsRead(S32 fd, char *buff, size_t bytes);
43 ssize_t OsVfsWrite(S32 fd, const void *buff, size_t bytes);
44 off_t OsVfsLseek(S32 fd, off_t off, S32 whence);
45 S32 OsVfsStat(const char *path, struct stat *stat);
46 S32 OsVfsStatfs(const char *path, struct statfs *buf);
47 S32 OsVfsFstat(S32 fd, struct stat *buf);
48 S32 OsVfsUnlink(const char *path);
49 S32 OsVfsRename(const char *oldName, const char *newName);
50 S32 OsVfsSync(S32 fd);
51 DIR *OsVfsOpendir(const char *path);
52 struct dirent *OsVfsReaddir(DIR *d);
53 S32 OsVfsClosedir(DIR *d);
54 S32 OsVfsMkdir(const char *path, S32 mode);
55 S32 OsVfsFcntl(S32 fd, S32 cmd, va_list ap);
56 S32 OsVfsIoctl(S32 fd, S32 func, unsigned long arg);
57 ssize_t OsVfsPread(S32 fd, void *buff, size_t bytes, off_t off);
58 ssize_t OsVfsPwrite(S32 fd, const void *buff, size_t bytes, off_t off);
59 S32 OsVfsFtruncate(S32 fd, off_t length);
60 ssize_t OsVfsReadv(S32 fd, const struct iovec *iovBuf, S32 iovcnt);
61 ssize_t OsVfsWritev(S32 fd, const struct iovec *iovBuf, S32 iovcnt);
62 
OsMapToPosixRet(S32 ret)63 static inline S32 OsMapToPosixRet(S32 ret)
64 {
65     return ((ret) < 0 ? -1 : (ret));
66 }
67 
68 #ifndef FS_OK
69 #define FS_OK   0
70 #endif
71 
72 #ifndef FS_NOK
73 #define FS_NOK (-1)
74 #endif
75 
76 #endif /* VFS_OPERATIONS_H */
77