Rev 3 | Go to most recent revision | Details | 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/maccess.h> |
||
6 | #include <fs/fcntl.h> |
||
7 | |||
8 | #include "file.h" |
||
9 | #include "inode.h" |
||
10 | #include "dentry.h" |
||
11 | #include "super.h" |
||
12 | #include "fileop.h" |
||
13 | #include "dentryop.h" |
||
14 | #include "inodeop.h" |
||
15 | #include "fsconst.h" |
||
16 | #include "fs.h" |
||
17 | |||
18 | #include "debug.h" |
||
19 | |||
20 | int k_unlink(char *upathname) |
||
21 | { |
||
22 | declare_buffer(char,pathname,MAXPATHNAME); |
||
23 | struct dentry *d; |
||
24 | int createflag; |
||
25 | __pid_t pid; |
||
26 | int len,res; |
||
27 | |||
28 | call_to_fs(); |
||
29 | |||
30 | printkd("k_unlink: START"); |
||
31 | pid=__get_pid(); |
||
32 | |||
33 | len=__verify_read_nolen((char*)upathname); |
||
34 | if ((!len)||(len>MAXPATHNAMELEN)) return_from_fs(-EVERIFY); |
||
35 | __copy_from_user(pathname,upathname,len+1); |
||
36 | |||
37 | printkd("k_unlink: pathname copied"); |
||
38 | |||
39 | createflag=DENTRY_NOCREATE; |
||
40 | d=find_dentry_from_ext(cwden_ptr(pid),(char *)pathname,&createflag); |
||
41 | |||
42 | printkd("k_unlink: dentry found"); |
||
43 | |||
44 | if (d==NULL) return_from_fs(-ENOENT); |
||
45 | if (__S_ISDIR(d->d_inode->i_st.st_mode)) return_from_fs(-EPERM); |
||
46 | if (!(d->d_sb->sb_mopts.flags&MOUNT_FLAG_RW)) return_from_fs(-EROFS); |
||
47 | |||
48 | printkd("k_unlink: dentry is ok"); |
||
49 | |||
50 | res=unlink_dentry(d); |
||
51 | |||
52 | printkd("k_unlink: dentry unlinked"); |
||
53 | |||
54 | printkd("k_unlink: END"); |
||
55 | return_from_fs(res); |
||
56 | } |