static int ccfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { int rc; struct dentry *lower_dentry; struct dentry *lower_dir_dentry; lower_dentry = ccfs_get_nested_dentry(dentry); lower_dir_dentry = lock_parent(lower_dentry); mdbg(INFO3,"MKDIR w/ lower_dentry->d_name.name = [%s] DIR = [%s]", lower_dentry->d_name.name, lower_dir_dentry->d_name.name); rc = vfs_mkdir(lower_dir_dentry->d_inode, lower_dentry, mode); if (rc || !lower_dentry->d_inode) goto out; rc = ccfs_interpose(lower_dentry, dentry, dir->i_sb, 0); if (rc) goto out; fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode); fsstack_copy_inode_size(dir, lower_dir_dentry->d_inode); set_nlink(dir, lower_dir_dentry->d_inode->i_nlink); //Fix for kernel 3.7.1 use function set_nlink by Jiri Rakosnik out: unlock_dir(lower_dir_dentry); if (!dentry->d_inode) d_drop(dentry); return rc; }
int do_mkdir (struct inode *inode, const char *name, int len, int mode) { #if USE_DENTRY_F struct dentry *tmp_dent; #endif int ret_code; DOWN(&(inode->i_sem)); #if USE_DENTRY_F /* Create a temporary negative dentry for the target. */ ret_code = ovlfs_inode_get_child_dentry(inode, name, len, &tmp_dent, OVLFS_DENT_GET_NEGATIVE); if ( ret_code == 0 ) { /* Use the vfs_mkdir function to do the dirty work. */ ret_code = vfs_mkdir(inode, tmp_dent, mode); dput(tmp_dent); } #else IMARK(inode); ret_code = inode->i_op->mkdir(inode, name, len, mode); #endif UP(&(inode->i_sem)); return ret_code; }
static int ecryptfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) { int rc; struct dentry *lower_dentry; struct vfsmount *lower_mnt; struct dentry *lower_dir_dentry; lower_dentry = ecryptfs_dentry_to_lower(dentry); lower_mnt = ecryptfs_dentry_to_lower_mnt(dentry); lower_dir_dentry = lock_parent(lower_dentry); rc = vfs_mkdir(lower_dir_dentry->d_inode, lower_dentry, lower_mnt, mode); if (rc || !lower_dentry->d_inode) goto out; rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0); if (rc) goto out; fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode); fsstack_copy_inode_size(dir, lower_dir_dentry->d_inode); dir->i_nlink = lower_dir_dentry->d_inode->i_nlink; out: unlock_dir(lower_dir_dentry); if (!dentry->d_inode) d_drop(dentry); return rc; }
static int dev_mkdir(const char *name, mode_t mode) { struct nameidata nd; struct dentry *dentry; int err; err = vfs_path_lookup(dev_mnt->mnt_root, dev_mnt, name, LOOKUP_PARENT, &nd); if (err) return err; dentry = lookup_create(&nd, 1); if (!IS_ERR(dentry)) { err = vfs_mkdir(nd.path.dentry->d_inode, dentry, mode); if (!err) /* mark as kernel-created inode */ dentry->d_inode->i_private = &dev_mnt; dput(dentry); } else { err = PTR_ERR(dentry); } mutex_unlock(&nd.path.dentry->d_inode->i_mutex); path_put(&nd.path); return err; }
static int wrapfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { int err; struct dentry *lower_dentry; struct dentry *lower_parent_dentry = NULL; struct path lower_path; wrapfs_get_lower_path(dentry, &lower_path); lower_dentry = lower_path.dentry; lower_parent_dentry = lock_parent(lower_dentry); err = vfs_mkdir(lower_parent_dentry->d_inode, lower_dentry, mode); if (err) goto out; err = wrapfs_interpose(dentry, dir->i_sb, &lower_path); if (err) goto out; fsstack_copy_attr_times(dir, wrapfs_lower_inode(dir)); fsstack_copy_inode_size(dir, lower_parent_dentry->d_inode); /* update number of links on parent directory */ set_nlink(dir, wrapfs_lower_inode(dir)->i_nlink); out: unlock_dir(lower_parent_dentry); wrapfs_put_lower_path(dentry, &lower_path); #ifdef NEKTECH_LOGGER /*NEKTECH LOGGING*/ nektech_logger (dir, dentry, NEKTECH_MKDIR); #endif /*NEKTECH LOGGING*/ return err; }
static int wrapfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) { int err = 0; struct dentry *lower_dentry; struct dentry *lower_parent_dentry = NULL; struct path lower_path; wrapfs_get_lower_path(dentry, &lower_path); lower_dentry = lower_path.dentry; lower_parent_dentry = lock_parent(lower_dentry); err = mnt_want_write(lower_path.mnt); if (err) goto out_unlock; err = vfs_mkdir(lower_parent_dentry->d_inode, lower_dentry, mode); if (err) goto out; err = wrapfs_interpose(dentry, dir->i_sb, &lower_path); if (err) goto out; fsstack_copy_attr_times(dir, wrapfs_lower_inode(dir)); fsstack_copy_inode_size(dir, lower_parent_dentry->d_inode); /* update number of links on parent directory */ set_nlink(dir, wrapfs_lower_inode(dir)->i_nlink); out: mnt_drop_write(lower_path.mnt); out_unlock: unlock_dir(lower_parent_dentry); wrapfs_put_lower_path(dentry, &lower_path); return err; }
static int diaryfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { int err; struct dentry * lower_dentry; struct dentry * lower_parent_dentry = NULL; struct path lower_path; diaryfs_get_lower_path(dentry, &lower_path); lower_dentry = lower_path.dentry; lower_parent_dentry = lock_parent(lower_dentry); err = vfs_mkdir(lower_parent_dentry->d_inode, lower_dentry, mode); if (err) goto out; err = diaryfs_interpose(dentry, dir->i_sb, &lower_path); if (err) goto out; fsstack_copy_attr_times(dir, diaryfs_lower_inode(dir)); fsstack_copy_inode_size(dir, lower_parent_dentry->d_inode); /* update the # of links on parent directory */ set_nlink(dir, diaryfs_lower_inode(dir)->i_nlink); out: unlock_dir(lower_parent_dentry); diaryfs_put_lower_path(dentry, &lower_path); return err; }
/* sys_mkdir * Copies the given path into the kernel space, and call vfs_mkdir. */ int sys_mkdir(userptr_t path, int mode) { char *p; int result; if ((p = (char *)kmalloc(__PATH_MAX)) == NULL) { return ENOMEM; } /* Copy in the path */ result = copyinstr(path, p, __PATH_MAX, NULL); if (result) { kfree(p); return result; } /* Check that given path of directory is valid */ if (strcmp(p, ".") == 0 || strcmp(p, "..") == 0) { kfree(p); return EEXIST; } result = vfs_mkdir(p, mode); kfree(p); return result; }
void __u2fs_mkdir(struct work_struct *work) { struct sioq_args *args = container_of(work, struct sioq_args, work); struct mkdir_args *m = &args->mkdir; args->err = vfs_mkdir(m->parent, m->dentry, m->mode); complete(&args->comp); }
static int u2fs_mkdir(struct inode *dir, struct dentry *dentry, int mode) { int err = 0; struct dentry *lower_dentry; struct dentry *lower_parent_dentry = NULL; struct path lower_path; struct dentry *ret = NULL; /* creating parent directories if destination is read-only */ if((U2FS_D(dentry)->lower_path[LEFT].dentry) == NULL && (U2FS_D(dentry)->lower_path[LEFT].mnt) == NULL){ ret = create_parents(dir, dentry, dentry->d_name.name); if (!ret || IS_ERR(ret)) { err = PTR_ERR(ret); if (!IS_COPYUP_ERR(err)) printk(KERN_ERR "u2fs: create_parents for " "u2fs_mkdir failed" "err=%d\n", err); goto out_copyup; } u2fs_postcopyup_setmnt(dentry); u2fs_put_reset_lower_path(dentry, RIGHT); } u2fs_get_lower_path(dentry, &lower_path, LEFT); lower_dentry = lower_path.dentry; lower_parent_dentry = lock_parent(lower_dentry); err = mnt_want_write(lower_path.mnt); if (err) goto out_unlock; err = vfs_mkdir(lower_parent_dentry->d_inode, lower_dentry, mode); if (err) goto out; err = u2fs_interpose(dentry, dir->i_sb, &lower_path, LEFT); if (err) goto out; fsstack_copy_attr_times(dir, u2fs_lower_inode(dir, LEFT)); fsstack_copy_inode_size(dir, lower_parent_dentry->d_inode); /* update number of links on parent directory */ set_nlink(dir, u2fs_lower_inode(dir, LEFT)->i_nlink); out: mnt_drop_write(lower_path.mnt); out_unlock: unlock_dir(lower_parent_dentry); u2fs_put_lower_path(dentry, &lower_path); out_copyup: return err; }
static int cmd_vfs_mkdir(struct vmm_chardev *cdev, const char *path) { int rc; struct stat st; rc = vfs_stat(path, &st); if (!rc) { vmm_cprintf(cdev, "Path %s already exist.\n", path); return VMM_EEXIST; } return vfs_mkdir(path, S_IRWXU|S_IRWXG|S_IRWXO); }
int main(int argc, char *argv[]) { vfs_init(); vfs_mkdir("/fat"); errval_t err = vfs_mount("/fat", "fat32://0+0"); if (err_is_fail(err)) { USER_PANIC_ERR(err, "vfs_fat_mount failed"); } walk_dir("/fat"); return 0; }
static int sdcardfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) { int err = 0; struct dentry *lower_dentry; struct dentry *lower_parent_dentry = NULL; struct path lower_path; OVERRIDE_CRED(SDCARDFS_SB(dir->i_sb)); #if defined(LOWER_FS_MIN_FREE_SIZE) /* check disk space */ if (!check_min_free_space(dentry, 0, 1)) { REVERT_CRED(); printk(KERN_INFO "No minimum free space.\n"); return -ENOSPC; } #endif sdcardfs_get_lower_path(dentry, &lower_path); lower_dentry = lower_path.dentry; lower_parent_dentry = lock_parent(lower_dentry); err = mnt_want_write(lower_path.mnt); if (err) goto out_unlock; /* set last 16bytes of mode field to 0775 */ mode = (mode & S_IFMT) | 00775; err = vfs_mkdir(lower_parent_dentry->d_inode, lower_dentry, mode); if (err) goto out; err = sdcardfs_interpose(dentry, dir->i_sb, &lower_path); if (err) goto out; fsstack_copy_attr_times(dir, sdcardfs_lower_inode(dir)); fsstack_copy_inode_size(dir, lower_parent_dentry->d_inode); /* update number of links on parent directory */ dir->i_nlink = sdcardfs_lower_inode(dir)->i_nlink; out: mnt_drop_write(lower_path.mnt); out_unlock: unlock_dir(lower_parent_dentry); sdcardfs_put_lower_path(dentry, &lower_path); REVERT_CRED(); return err; }
int do_vfsub_mkdir(struct inode *dir, struct dentry *dentry, int mode) { int err; LKTRTrace("i%lu, %.*s, 0x%x\n", dir->i_ino, AuDLNPair(dentry), mode); IMustLock(dir); err = vfs_mkdir(dir, dentry, mode); if (!err) { /* dir inode is locked */ au_update_fuse_h_inode(NULL, dentry->d_parent); /*ignore*/ au_update_fuse_h_inode(NULL, dentry); /*ignore*/ } return err; }
static int ecryptfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { int rc; struct dentry *lower_dentry; struct dentry *lower_dir_dentry; lower_dentry = ecryptfs_dentry_to_lower(dentry); lower_dir_dentry = lock_parent(lower_dentry); #ifdef CONFIG_SDP if(!strncmp(lower_dir_dentry->d_sb->s_type->name, "sdcardfs", 8)) { struct sdcardfs_dentry_info *dinfo = SDCARDFS_D(lower_dir_dentry); int len = strlen(dentry->d_name.name); int i, numeric = 1; dinfo->under_knox = 1; dinfo->userid = -1; if(IS_UNDER_ROOT(dentry)) { for(i=0 ; i < len ; i++) if(!isdigit(dentry->d_name.name[i])) { numeric = 0; break; } if(numeric) { dinfo->userid = simple_strtoul(dentry->d_name.name, NULL, 10); } } } #endif rc = vfs_mkdir(lower_dir_dentry->d_inode, lower_dentry, mode); if (rc || !lower_dentry->d_inode) goto out; rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb); if (rc) goto out; fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode); fsstack_copy_inode_size(dir, lower_dir_dentry->d_inode); set_nlink(dir, lower_dir_dentry->d_inode->i_nlink); out: #ifdef CONFIG_SDP if(!strncmp(lower_dir_dentry->d_sb->s_type->name, "sdcardfs", 8)) { struct sdcardfs_dentry_info *dinfo = SDCARDFS_D(lower_dir_dentry); dinfo->under_knox = 0; dinfo->userid = -1; } #endif unlock_dir(lower_dir_dentry); if (!dentry->d_inode) d_drop(dentry); return rc; }
int main(int argc, char *argv[]) { errval_t err; vfs_init(); err = vfs_mkdir("/filetests"); if (err_is_fail(err)) { USER_PANIC_ERR(err, "vfs_mkdir failed"); } /* Create a file with a lot of data */ FILE *fh = fopen("/filetests/fread_test.dat", "w"); if (!fh) { USER_PANIC("fopen failed"); } for (int i = 0; i < AMOUNT; i++) { fprintf(fh, "h"); } fclose(fh); /* Read out the data in chunks */ fh = fopen("/filetests/fread_test.dat", "r"); if (!fh) { USER_PANIC("fopen failed"); } char *ptr = malloc(AMOUNT); assert(ptr); size_t size = fread(ptr, 10, 1, fh); if (size != 10) { USER_PANIC("fread did not read full amount"); } size = fread(ptr, AMOUNT - 10, 1, fh); if (size != AMOUNT - 10) { USER_PANIC("fread did not read full amount"); } size = fread(ptr, AMOUNT, 1, fh); if (size != 0) { USER_PANIC("fread did not read full amount"); } printf("client done\n"); return 0; }
static void cmd_mkd(const char *arg, struct tcp_pcb *pcb, struct ftpd_msgstate *fsm) { if (arg == NULL) { send_msg(pcb, fsm, msg501); return; } if (*arg == '\0') { send_msg(pcb, fsm, msg501); return; } if (vfs_mkdir(fsm->vfs, arg, VFS_IRWXU | VFS_IRWXG | VFS_IRWXO) != 0) { send_msg(pcb, fsm, msg550); } else { send_msg(pcb, fsm, msg257, arg); } }
static int create_path(const char *nodepath) { char *path; struct nameidata nd; int err = 0; struct vfsmount *dev_mnt = ve_devmnt(); path = kstrdup(nodepath, GFP_KERNEL); if (!path) return -ENOMEM; err = vfs_path_lookup(dev_mnt->mnt_root, dev_mnt, path, LOOKUP_PARENT, &nd); if (err == 0) { struct dentry *dentry; /* create directory right away */ dentry = lookup_create(&nd, 1); if (!IS_ERR(dentry)) { err = vfs_mkdir(nd.path.dentry->d_inode, dentry, 0755); dput(dentry); } mutex_unlock(&nd.path.dentry->d_inode->i_mutex); path_put(&nd.path); } else if (err == -ENOENT) { char *s; /* parent directories do not exist, create them */ s = path; while (1) { s = strchr(s, '/'); if (!s) break; s[0] = '\0'; err = dev_mkdir(path, 0755); if (err && err != -EEXIST) break; s[0] = '/'; s++; } } kfree(path); return err; }
static int dev_mkdir(const char *name, umode_t mode) { struct dentry *dentry; struct path path; int err; dentry = kern_path_create(AT_FDCWD, name, &path, LOOKUP_DIRECTORY); if (IS_ERR(dentry)) return PTR_ERR(dentry); err = vfs_mkdir(path.dentry->d_inode, dentry, mode); if (!err) /* mark as kernel-created inode */ dentry->d_inode->i_private = &thread; done_path_create(&path, dentry); return err; }
static int mkdir(int argc, char *argv[]) { if(argc != 2) { printf("Usage: %s dir\n", argv[0]); return 1; } char *path = vfs_path_mkabsolute(cwd, argv[1]); errval_t err = vfs_mkdir(path); free(path); if (err_is_fail(err)) { printf("%s\n", err_getstring(err)); return 1; } else { return 0; } }
int nfsd4_create_clid_dir(struct nfs4_client *clp) { char *dname = clp->cl_recdir; struct dentry *dentry; uid_t uid; gid_t gid; int status; dprintk("NFSD: nfsd4_create_clid_dir for \"%s\"\n", dname); if (!rec_dir_init || clp->cl_firststate) return 0; nfs4_save_user(&uid, &gid); /* lock the parent */ mutex_lock(&rec_dir.path.dentry->d_inode->i_mutex); dentry = lookup_one_len(dname, rec_dir.path.dentry, HEXDIR_LEN-1); if (IS_ERR(dentry)) { status = PTR_ERR(dentry); goto out_unlock; } status = -EEXIST; if (dentry->d_inode) { dprintk("NFSD: nfsd4_create_clid_dir: DIRECTORY EXISTS\n"); goto out_put; } status = mnt_want_write(rec_dir.path.mnt); if (status) goto out_put; status = vfs_mkdir(rec_dir.path.dentry->d_inode, dentry, S_IRWXU); mnt_drop_write(rec_dir.path.mnt); out_put: dput(dentry); out_unlock: mutex_unlock(&rec_dir.path.dentry->d_inode->i_mutex); if (status == 0) { clp->cl_firststate = 1; nfsd4_sync_rec_dir(); } nfs4_reset_user(uid, gid); dprintk("NFSD: nfsd4_create_clid_dir returns %d\n", status); return status; }
static int esdfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { int err = 0; struct dentry *lower_dentry; struct dentry *lower_parent_dentry = NULL; struct path lower_path; int mask; const struct cred *creds = esdfs_override_creds(ESDFS_SB(dir->i_sb), &mask); if (!creds) return -ENOMEM; esdfs_get_lower_path(dentry, &lower_path); lower_dentry = lower_path.dentry; lower_parent_dentry = lock_parent(lower_dentry); mode |= S_IFDIR; esdfs_set_lower_mode(ESDFS_SB(dir->i_sb), &mode); err = mnt_want_write(lower_path.mnt); if (err) goto out_unlock; err = vfs_mkdir(lower_parent_dentry->d_inode, lower_dentry, mode); if (err) goto out; err = esdfs_interpose(dentry, dir->i_sb, &lower_path); if (err) goto out; fsstack_copy_attr_times(dir, esdfs_lower_inode(dir)); fsstack_copy_inode_size(dir, lower_parent_dentry->d_inode); /* update number of links on parent directory */ set_nlink(dir, esdfs_lower_inode(dir)->i_nlink); if (ESDFS_DERIVE_PERMS(ESDFS_SB(dir->i_sb))) err = esdfs_derive_mkdir_contents(dentry); out: mnt_drop_write(lower_path.mnt); out_unlock: unlock_dir(lower_parent_dentry); esdfs_put_lower_path(dentry, &lower_path); esdfs_revert_creds(creds, &mask); return err; }
//==================================================================== // Create a directory for this device under the given path. Returns // 0 on success and non-zero on failure. static int create_dev_dir(const char *dev_dir_path) { struct dentry *dentry; struct path path; int lookup_flags = LOOKUP_DIRECTORY; umode_t mode = S_IRUGO | S_IXUGO; int err; dentry = kern_path_create(AT_FDCWD, dev_dir_path, &path, lookup_flags); if (IS_ERR(dentry)) { return PTR_ERR(dentry); } err = security_path_mkdir(&path, dentry, mode); if (!err) { err = vfs_mkdir(path.dentry->d_inode, dentry, mode); } done_path_create(&path, dentry); return err; }
static BOOL ui_dbase_mk_db_dir(void) { u16 uni_tmp[16] = {0}; if(file_list_get_partition(&p_partition) > 0) { g_partition_letter = p_partition[sys_status_get_usb_work_partition()].letter[0]; uni_tmp[0] = g_partition_letter; str_asc2uni((u8 *)":\\", uni_tmp + 1); str_asc2uni((u8 *)IW_DATA_FOLDER_NAME, uni_tmp + 3); OS_PRINTF("sys_status_get_usb_work_partition(%d)\n",sys_status_get_usb_work_partition()); if(vfs_mkdir(uni_tmp) != SUCCESS) { OS_PRINTF("%s, %s dir can't create or exist!\n", __FUNCTION__, "DB_DATA"); } } return 0; }
int sys_mkdir (char *pathname, uint_t mode) { register error_t err = 0; struct task_s *task = current_task; struct ku_obj ku_path; KU_BUFF(ku_path, pathname); rwlock_rdlock(&task->cwd_lock); if((err = vfs_mkdir(&task->vfs_cwd, &ku_path, mode))) { current_thread->info.errno = (err < 0) ? -err : err; rwlock_unlock(&task->cwd_lock); return -1; } rwlock_unlock(&task->cwd_lock); return 0; }
static int dev_mkdir(const char *name, mode_t mode) { struct dentry *dentry; struct path path; int err; dentry = kern_path_create(AT_FDCWD, name, &path, 1); if (IS_ERR(dentry)) return PTR_ERR(dentry); err = vfs_mkdir(path.dentry->d_inode, dentry, mode); if (!err) /* mark as kernel-created inode */ dentry->d_inode->i_private = &thread; dput(dentry); mutex_unlock(&path.dentry->d_inode->i_mutex); path_put(&path); return err; }
/* * scfs_mkdir * * Parameters: * @*dir: inode of the dir to create * @*scfs_dentry: dentry of the dir to create * @mode: * * Return: * SCFS_SUCCESS if success, otherwise if error * * Description: * mkdir() for SCFS. */ static int scfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { struct dentry *lower_dir_dentry; struct dentry *lower_parent_dentry; int ret; SCFS_DEBUG_START; lower_dir_dentry = scfs_lower_dentry(dentry); lower_parent_dentry = lock_parent(lower_dir_dentry); ret = vfs_mkdir(lower_parent_dentry->d_inode, lower_dir_dentry, mode); if (ret || !lower_dir_dentry->d_inode) { SCFS_PRINT_ERROR("dir %s vfs_mkdir failed, " "lower_dir %s lower_parent %s mode %x\n", dentry->d_name.name, lower_dir_dentry->d_name.name, lower_parent_dentry->d_name.name, mode); goto out; } ret = scfs_interpose(lower_dir_dentry, dentry, dir->i_sb); if (ret) { SCFS_PRINT_ERROR("dir %s interpose failed, " "lower_dir %s lower_parent %s mode %x\n", dentry->d_name.name, lower_dir_dentry->d_name.name, lower_parent_dentry->d_name.name, mode); vfs_rmdir(lower_parent_dentry->d_inode, lower_dir_dentry); goto out; } fsstack_copy_attr_times(dir, lower_parent_dentry->d_inode); fsstack_copy_inode_size(dir, lower_parent_dentry->d_inode); set_nlink(dir, lower_parent_dentry->d_inode->i_nlink); out: unlock_dir(lower_parent_dentry); if (!dentry->d_inode) d_drop(dentry); SCFS_DEBUG_END; return ret; }
static int ecryptfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { int rc; struct dentry *lower_dentry; struct dentry *lower_dir_dentry; lower_dentry = ecryptfs_dentry_to_lower(dentry); lower_dir_dentry = lock_parent(lower_dentry); rc = vfs_mkdir(d_inode(lower_dir_dentry), lower_dentry, mode); if (rc || d_really_is_negative(lower_dentry)) goto out; rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb); if (rc) goto out; fsstack_copy_attr_times(dir, d_inode(lower_dir_dentry)); fsstack_copy_inode_size(dir, d_inode(lower_dir_dentry)); set_nlink(dir, d_inode(lower_dir_dentry)->i_nlink); out: unlock_dir(lower_dir_dentry); if (d_really_is_negative(dentry)) d_drop(dentry); return rc; }
int main(int argc, char *argv[]) { errval_t err; // initialization vfs_init(); bench_init(); // mount nfs err = vfs_mkdir("/nfs"); assert(err_is_ok(err)); err = vfs_mount("/nfs", "nfs://10.110.4.4/local/nfs"); assert(err_is_ok(err)); // argument processing if (argc == 3) { printf("Started vfs_bench in command-line mode\n"); int32_t chunksize = atol(argv[1]); int32_t repetitions = atol(argv[2]); single_run(chunksize, repetitions); } else { printf("Started vfs_bench.\n"); for (int32_t i = 1; i < 20; i++) { single_run(4096, i * 2000); } } //err = vfs_unmount("/nfs"); // unmount is NYI //assert(err_is_ok(err)); err = vfs_rmdir("/nfs"); assert(err_is_ok(err)); return 0; }
static int walk_parents_mkdir( const char **path, struct nameidata *nd, int is_dir) { char *slash; char buf[strlen(*path)+1]; int error; while ((slash = strchr(*path, '/')) != NULL) { int len = slash - *path; memcpy(buf, *path, len); buf[len] = '\0'; error = path_walk(buf, nd); if (unlikely(error)) return error; nd->dentry = lookup_create(nd, is_dir); nd->flags |= LOOKUP_PARENT; if (IS_ERR(nd->dentry)) return PTR_ERR(nd->dentry); if (!nd->dentry->d_inode) error = vfs_mkdir(nd->dentry->d_parent->d_inode, nd->dentry, 0755); up(&nd->dentry->d_parent->d_inode->i_sem); if (unlikely(error)) return error; *path += len + 1; } return 0; }