Subversion Repositories shark

Rev

Rev 3 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
 
1063 tullio 2
/*
3
 * This program is free software; you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License as published by
5
 * the Free Software Foundation; either version 2 of the License, or
6
 * (at your option) any later version.
7
 *
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 * GNU General Public License for more details.
12
 *
13
 * You should have received a copy of the GNU General Public License
14
 * along with this program; if not, write to the Free Software
15
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
 *
17
 */
18
 
2 pj 19
#include <fs/types.h>
20
#include <fs/errno.h>
21
#include <fs/task.h>
22
#include <fs/util.h>
23
#include <fs/maccess.h>
24
#include <fs/fcntl.h>
25
 
26
#include "file.h"
27
#include "dentry.h"
28
#include "fs.h"
29
 
30
/* there is no permission test yet !!! */
31
 
32
int k_access(char *newpath, int amode)
33
{
34
  declare_buffer(char,pathname,MAXPATHNAME);  
35
  int createflag=DENTRY_NOCREATE;
36
  struct dentry *d;
37
  __pid_t pid;
38
  int len;
39
 
40
  call_to_fs();
41
 
42
  if (amode&~(R_OK|R_OK|X_OK|F_OK)) return_from_fs(-EINVAL);
43
 
44
  len=__verify_read_nolen((char*)newpath);
45
  if ((!len)||(len>MAXPATHNAMELEN)) return_from_fs(-EVERIFY);
46
  __copy_from_user(pathname,newpath,len+1);
47
 
48
  pid=__get_pid();  
49
  lock_desctable(pid);
50
 
51
  d=find_dentry_from_ext(cwden_ptr(pid),(char *)pathname,&createflag);
52
  if (d==NULL) {
53
    unlock_desctable(pid);
54
    return_from_fs(-ENOENT);
55
  }
56
  unlock_dentry(d);
57
 
58
  unlock_desctable(pid);
59
 
60
  if (amode&X_OK) return_from_fs(-EACCES);
61
  return_from_fs(EOK);
62
}