int sys_chdir (char *pathname) { register error_t err = 0; register struct thread_s *this; register struct task_s *task; this = current_thread; task = current_task; if(!pathname) { this->info.errno = EINVAL; return -1; } rwlock_wrlock(&task->cwd_lock); if((err = vfs_chdir(pathname, task->vfs_cwd, &task->vfs_cwd))) { rwlock_unlock(&task->cwd_lock); this->info.errno = (err < 0) ? -err : err; return -1; } rwlock_unlock(&task->cwd_lock); return 0; }
/* * sys_chdir * */ int sys_chdir(userptr_t path) { char *k_path; //check for kmalloc if((k_path = (char *)kmalloc(__PATH_MAX)) ==NULL){ return ENOMEM; } //copy into kernel int result; result = copyinstr(path,k_path,__PATH_MAX,NULL); //if fail if(result){ return result; } //else use vfs_chdir to do rest of the work result = vfs_chdir(k_path); kfree(k_path); return result; }
static void cmd_cdup(const char *arg, struct tcp_pcb *pcb, struct ftpd_msgstate *fsm) { if (!vfs_chdir(fsm->vfs, "..")) { send_msg(pcb, fsm, msg250); } else { send_msg(pcb, fsm, msg550); } }
/* * Command for changing directory. */ static int cmd_chdir(int nargs, char **args) { if (nargs != 2) { kprintf("Usage: cd directory\n"); return EINVAL; } return vfs_chdir(args[1]); }
/* sysfile_chdir - change dir */ int sysfile_chdir(const char *__path) { int ret; char *path; if ((ret = copy_path(&path, __path)) != 0) { return ret; } ret = vfs_chdir(path); kfree(path); return ret; }
/* chdir() function handler */ int sys_chdir(const_userptr_t pathName){ char pathNameFromUser[BUF_SIZE]; size_t actual; int err; if (pathName == NULL || pathName == (void *) 0x40000000 || pathName == (void *) 0x80000000){ return EFAULT; } if ((err = copyinstr(pathName, pathNameFromUser, BUF_SIZE, &actual) != 0)){ return err; } err = vfs_chdir(pathNameFromUser); return err; }
int vfs_set_bootfs(char *fsname) { struct inode *node = NULL; if (fsname != NULL) { char *s; if ((s = strchr(fsname, ':')) == NULL || s[1] != '\0') { return -E_INVAL; } int ret; if ((ret = vfs_chdir(fsname)) != 0) { return ret; } if ((ret = vfs_get_curdir(&node)) != 0) { return ret; } } change_bootfs(node); return 0; }
int chdir(const_userptr_t pathname) { char new_path[PATH_MAX]; size_t get; if (pathname == NULL) { return EFAULT; } int ret = copyinstr(pathname,new_path,PATH_MAX,&get); if (ret) { return EFAULT; } return vfs_chdir(new_path); }
/* * sys_chdir * Copies the given path into the kernel space, and call vfs_chdir. */ int sys_chdir(userptr_t path) { 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; } result = vfs_chdir(p); kfree(p); return result; }
int chdir(const char *pathname) { // Error Checks if (pathname == NULL) { return EFAULT; } void* namedest = kmalloc(sizeof(pathname)); int err = copyin((const_userptr_t)pathname, namedest, sizeof(pathname)); if (err != 0) { kfree(namedest); return err; } //set_p_cwd(userproc, dest); err = vfs_chdir(namedest); kfree(namedest); return err; }
SYSCALL_HANDLER2(sys_chdir, const char *path, int *ret) { *ret = vfs_chdir(path); }