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
#include <fs/fcntl.h>
8
 
9
#include "file.h"
10
#include "dentry.h"
11
#include "fs.h"
12
 
13
/* there is no permission test yet !!! */
14
 
15
int k_access(char *newpath, int amode)
16
{
17
  declare_buffer(char,pathname,MAXPATHNAME);  
18
  int createflag=DENTRY_NOCREATE;
19
  struct dentry *d;
20
  __pid_t pid;
21
  int len;
22
 
23
  call_to_fs();
24
 
25
  if (amode&~(R_OK|R_OK|X_OK|F_OK)) return_from_fs(-EINVAL);
26
 
27
  len=__verify_read_nolen((char*)newpath);
28
  if ((!len)||(len>MAXPATHNAMELEN)) return_from_fs(-EVERIFY);
29
  __copy_from_user(pathname,newpath,len+1);
30
 
31
  pid=__get_pid();  
32
  lock_desctable(pid);
33
 
34
  d=find_dentry_from_ext(cwden_ptr(pid),(char *)pathname,&createflag);
35
  if (d==NULL) {
36
    unlock_desctable(pid);
37
    return_from_fs(-ENOENT);
38
  }
39
  unlock_dentry(d);
40
 
41
  unlock_desctable(pid);
42
 
43
  if (amode&X_OK) return_from_fs(-EACCES);
44
  return_from_fs(EOK);
45
}