154568cb3Sopenharmony_ci/*
254568cb3Sopenharmony_ci * Copyright (c) 2022-2022 Huawei Technologies Co., Ltd. All rights reserved.
354568cb3Sopenharmony_ci *
454568cb3Sopenharmony_ci * UniProton is licensed under Mulan PSL v2.
554568cb3Sopenharmony_ci * You can use this software according to the terms and conditions of the Mulan PSL v2.
654568cb3Sopenharmony_ci * You may obtain a copy of Mulan PSL v2 at:
754568cb3Sopenharmony_ci *          http://license.coscl.org.cn/MulanPSL2
854568cb3Sopenharmony_ci * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
954568cb3Sopenharmony_ci * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
1054568cb3Sopenharmony_ci * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
1154568cb3Sopenharmony_ci * See the Mulan PSL v2 for more details.
1254568cb3Sopenharmony_ci * Create: 2022-09-21
1354568cb3Sopenharmony_ci * Description: 文件系统vfs层
1454568cb3Sopenharmony_ci */
1554568cb3Sopenharmony_ci
1654568cb3Sopenharmony_ci#ifndef VFS_MOUNT_H
1754568cb3Sopenharmony_ci#define VFS_MOUNT_H
1854568cb3Sopenharmony_ci
1954568cb3Sopenharmony_ci#include "sys/statfs.h"
2054568cb3Sopenharmony_ci#include "prt_fs.h"
2154568cb3Sopenharmony_ci
2254568cb3Sopenharmony_cistruct TagFsMap;
2354568cb3Sopenharmony_cistruct TagMountPoint;
2454568cb3Sopenharmony_ci
2554568cb3Sopenharmony_cistruct TagMountOps {
2654568cb3Sopenharmony_ci    S32 (*mount)(struct TagMountPoint *mp, uintptr_t mountflags, const void *data);
2754568cb3Sopenharmony_ci    S32 (*umount)(struct TagMountPoint *mp);
2854568cb3Sopenharmony_ci    S32 (*umount2)(struct TagMountPoint *mp, S32 flag);
2954568cb3Sopenharmony_ci    S32 (*statfs)(const char *path, struct statfs *buf);
3054568cb3Sopenharmony_ci};
3154568cb3Sopenharmony_ci
3254568cb3Sopenharmony_cistruct TagMountPoint {
3354568cb3Sopenharmony_ci    struct TagFsMap      *mFs;         /* 系统文件系统信息 */
3454568cb3Sopenharmony_ci    struct TagMountPoint *mNext;       /* 指向下一个mount节点 */
3554568cb3Sopenharmony_ci    const char           *mPath;       /* 挂载的路径 */
3654568cb3Sopenharmony_ci    const char           *mDev;        /* 设备名, "emmc0p0", "emmc0p1", etc. */
3754568cb3Sopenharmony_ci    U32                  mRefs;        /* 挂载节点的引用计数 */
3854568cb3Sopenharmony_ci    void                 *mData;       /* 挂载节点的私有数据 */
3954568cb3Sopenharmony_ci    bool                 mWriteEnable; /* 是否允许写 */
4054568cb3Sopenharmony_ci};
4154568cb3Sopenharmony_ci
4254568cb3Sopenharmony_ciS32 OsVfsMount(const char *source, const char *target,
4354568cb3Sopenharmony_ci               const char *filesystemtype, uintptr_t mountflags,
4454568cb3Sopenharmony_ci               const void *data);
4554568cb3Sopenharmony_ciS32 OsVfsUmount(const char *target);
4654568cb3Sopenharmony_ciS32 OsVfsUmount2(const char *target, S32 flag);
4754568cb3Sopenharmony_cistruct TagMountPoint *OsVfsFindMp(const char *path, const char **pathInMp);
4854568cb3Sopenharmony_ciS32 OsVfsFindMountPoint(const char *fsType);
4954568cb3Sopenharmony_ci#endif /* VFS_MOUNT_H */
50