Subversion Repositories shark

Rev

Rev 2 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
 
2
#include <fs/types.h>
3
#include <fs/errno.h>
4
#include <fs/task.h>
5
#include <fs/util.h>
6
#include <fs/maccess.h>
7
 
8
#include "file.h"
9
#include "dentry.h"
10
#include "fs.h"
11
 
12
int k_chdir(char *newpath)
13
{
14
  declare_buffer(char,pathname,MAXPATHNAME);  
15
  int createflag=DENTRY_NOCREATE;
16
  struct dentry *d;
17
  __pid_t pid;
18
  int len;
19
 
20
  call_to_fs();
21
 
22
  len=__verify_read_nolen((char*)newpath);
23
  if ((!len)||(len>MAXPATHNAMELEN)) return_from_fs(-EVERIFY);
24
  __copy_from_user(pathname,newpath,len+1);
25
 
26
  pid=__get_pid();  
27
  lock_desctable(pid);
28
 
29
  d=find_dentry_from_ext(cwden_ptr(pid),(char *)pathname,&createflag);
30
  if (d==NULL) {
31
    unlock_desctable(pid);
32
    return_from_fs(-ENOENT);
33
  }
34
 
35
  unlock_dentry(cwden_ptr(pid));
36
  /* dovrebbe essere: cwden_ptr(pid)=d; */
37
  desctable[pid].fd_cwden=d;
38
  strcpy(cwd_ptr(pid),pathname);
39
 
40
  unlock_desctable(pid);
41
  return_from_fs(EOK);
42
}