Using the mount (2) function in C

I was desperately looking for a tutorial on how to use the mount () function correctly (they hide this knowledge very well).

I need to use it in MNT_UPDATE "/" (/ dev / disk0s2 in this case) in single user mode, but I cannot find an example or tutorial on how to use this function.

ps. Please do not use the "Use system ()" imp. I know / sbin / mount exists for some reason, I do this for educational purposes

+3
source share
1 answer

As you probably already read on the manual page, you use it as follows:

int ret = mount("hfs", "/", MNT_UPDATE, some_data);

- , "". , , grepping . , HFS /usr/include/hfs/hfs_mount.h:

struct hfs_mount_args {
    char     *fspec; /* <--- This is the device to mount */
    uid_t     hfs_uid;
    gid_t     hfs_gid;
    mode_t    hfs_mask;
    u_int32_t hfs_encoding;
    struct    timezone hfs_timezone;
    int       flags;
    int       journal_tbuffer_size;
    int       journal_flags;
    int       journal_disable;
};
+2

Source: https://habr.com/ru/post/1759553/


All Articles