Esempio n. 1
0
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;
}
Esempio n. 2
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;
    
}
Esempio n. 3
0
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);
	}
}
Esempio n. 4
0
/*
 * 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]);
}
Esempio n. 5
0
/* 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;
}
Esempio n. 6
0
/* 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;
	
}
Esempio n. 7
0
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;
}
Esempio n. 8
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);
}
Esempio n. 9
0
/*
 * 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;
}
Esempio n. 10
0
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;
}
Esempio n. 11
0
SYSCALL_HANDLER2(sys_chdir, const char *path, int *ret) {
    *ret = vfs_chdir(path);
}