mount.h 3.3 KB
Newer Older
W
wangchenyang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
/*
 * Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this list of
 *    conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
 *    of conditions and the following disclaimer in the documentation and/or other materials
 *    provided with the distribution.
 *
 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
 *    to endorse or promote products derived from this software without specific prior written
 *    permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef _MOUNT_H_
#define _MOUNT_H_

#include <sys/stat.h>
M
mucor 已提交
35 36 37 38 39
#include <sys/statfs.h>
#include "vnode.h"

#define MS_RDONLY 1
#define MS_NOSYNC 2
W
wangchenyang 已提交
40 41 42 43 44 45 46 47

struct MountOps;

struct Mount {
    LIST_ENTRY mountList;              /* mount list */
    const struct MountOps *ops;        /* operations of mount */
    struct Vnode *vnodeBeCovered;      /* vnode we mounted on */
    struct Vnode *vnodeCovered;        /* syncer vnode */
M
mucor 已提交
48
    struct Vnode *vnodeDev;            /* dev vnode */
W
wangchenyang 已提交
49 50 51 52 53 54 55
    LIST_HEAD vnodeList;               /* list of vnodes */
    int vnodeSize;                     /* size of vnode list */
    LIST_HEAD activeVnodeList;         /* list of active vnodes */
    int activeVnodeSize;               /* szie of active vnodes list */
    void *data;                        /* private data */
    uint32_t hashseed;                 /* Random seed for vfshash */
    unsigned long mountFlags;          /* Flags for mount */
C
chenjing 已提交
56
    char pathName[PATH_MAX];           /* path name of mount point */
C
chenjing 已提交
57
    char devName[PATH_MAX];            /* path name of dev point */
W
wangchenyang 已提交
58 59 60 61 62 63 64 65
};

struct MountOps {
    int (*Mount)(struct Mount *mount, struct Vnode *vnode, const void *data);
    int (*Unmount)(struct Mount *mount, struct Vnode **blkdriver);
    int (*Statfs)(struct Mount *mount, struct statfs *sbp);
};

C
chenjing 已提交
66 67
typedef int (*foreach_mountpoint_t)(const char *devpoint,
                                    const char *mountpoint,
M
mucor 已提交
68 69 70
                                    struct statfs *statbuf,
                                    void *arg);

W
wangchenyang 已提交
71 72
struct Mount* MountAlloc(struct Vnode* vnode, struct MountOps* mop);
LIST_HEAD* GetMountList(void);
M
mucor 已提交
73
int foreach_mountpoint(foreach_mountpoint_t handler, void *arg);
M
mucor 已提交
74
int ForceUmountDev(struct Vnode *dev);
W
wangchenyang 已提交
75
#endif