示例#1
0
/*
 * __mount(): wrapper around the mount() system call which also
 * sets the underlying block device to read-only if the mount is read-only.
 * See "man 2 mount" for return values.
 */
static int __mount(const char *source, const char *target, const struct fstab_rec *rec, int encryptable)
{
    unsigned long mountflags = rec->flags;
    int ret;
    int save_errno;

    /* We need this because sometimes we have legacy symlinks
     * that are lingering around and need cleaning up.
     */
    struct stat info;
    if (!lstat(target, &info))
        if ((info.st_mode & S_IFMT) == S_IFLNK)
            unlink(target);
    mkdir(target, 0755);

    NOTICE("%s: target='%s, encryptable=%d \n", __FUNCTION__, target, encryptable);

    if(encryptable == FS_MGR_MNTALL_DEV_MIGHT_BE_ENCRYPTED && (!strcmp(target, PROTECT_1_MNT_POINT) || !strcmp(target, PROTECT_2_MNT_POINT)) ) {
         NOTICE("encryptable is FS_MGR_MNTALL_DEV_MIGHT_BE_ENCRYPTED. Need to mount '%s' as tmpfs\n", target);
         if ((ret = fs_mgr_do_tmpfs_mount((char *)target))) {
             ERROR("Mount '%s' to tmpfs fail. \n", target);
         }
         else {
             NOTICE("Try to copy modem nvram from emmc to the tmpfs of '%s'\n", target);
             char tmp_mnt_point[256];

             snprintf(tmp_mnt_point, sizeof(tmp_mnt_point),  "/mnt%s", target);
             char *mkdir_argv[] = {"/system/bin/mkdir", tmp_mnt_point};
             execute_cmd(mkdir_argv, ARRAY_SIZE(mkdir_argv));

             if (!access(tmp_mnt_point, F_OK) && (ret = mount(source, tmp_mnt_point, rec->fs_type, mountflags, rec->fs_options))) {
                 ERROR("Fail: mount '%s', errno=%d \n", tmp_mnt_point, errno);
             }
             else {
                char *cp_argv[] = {"/system/bin/cp", "-Rp", tmp_mnt_point, "/"};
                execute_cmd(cp_argv, ARRAY_SIZE(cp_argv));
            
                char *umount_argv[] = {"/system/bin/umount", tmp_mnt_point};
                if(!execute_cmd(umount_argv, ARRAY_SIZE(umount_argv))) {
                    char *rm_argv[] = {"/system/bin/rm", "-rf", tmp_mnt_point};
                    execute_cmd(rm_argv, ARRAY_SIZE(rm_argv));
                }                
             }
         }
    }
    else {
        ret = mount(source, target, rec->fs_type, mountflags, rec->fs_options);
        save_errno = errno;
        INFO("%s(source=%s,target=%s,type=%s)=%d\n", __func__, source, target, rec->fs_type, ret);
        if ((ret == 0) && (mountflags & MS_RDONLY) != 0) {
            fs_set_blk_ro(source);
        }
        errno = save_errno;
    }
    return ret;
}
示例#2
0
/*
 * __mount(): wrapper around the mount() system call which also
 * sets the underlying block device to read-only if the mount is read-only.
 * See "man 2 mount" for return values.
 */
static int __mount(const char *source, const char *target,
                   const char *filesystemtype, unsigned long mountflags,
                   const void *data)
{
    int ret = mount(source, target, filesystemtype, mountflags, data);

    if ((ret == 0) && (mountflags & MS_RDONLY) != 0) {
        fs_set_blk_ro(source);
    }

    return ret;
}
示例#3
0
/*
 * __mount(): wrapper around the mount() system call which also
 * sets the underlying block device to read-only if the mount is read-only.
 * See "man 2 mount" for return values.
 */
static int __mount(const char *source, const char *target, const struct fstab_rec *rec)
{
    unsigned long mountflags = rec->flags;
    int ret;
    int save_errno;

    /* We need this because sometimes we have legacy symlinks
     * that are lingering around and need cleaning up.
     */
    struct stat info;
    if (!lstat(target, &info))
        if ((info.st_mode & S_IFMT) == S_IFLNK)
            unlink(target);
    mkdir(target, 0755);
    ret = mount(source, target, rec->fs_type, mountflags, rec->fs_options);
    save_errno = errno;
    INFO("%s(source=%s,target=%s,type=%s)=%d\n", __func__, source, target, rec->fs_type, ret);
    if ((ret == 0) && (mountflags & MS_RDONLY) != 0) {
        fs_set_blk_ro(source);
    }
    errno = save_errno;
    return ret;
}