Rev 3 | Go to most recent revision | 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/maccess.h> |
||
23 | #include <fs/fcntl.h> |
||
24 | |||
25 | #include "file.h" |
||
26 | #include "inode.h" |
||
27 | #include "dentry.h" |
||
28 | #include "super.h" |
||
29 | #include "fileop.h" |
||
30 | #include "dentryop.h" |
||
31 | #include "inodeop.h" |
||
32 | #include "fsconst.h" |
||
33 | #include "fs.h" |
||
34 | |||
35 | #include "debug.h" |
||
36 | |||
37 | int k_unlink(char *upathname) |
||
38 | { |
||
39 | declare_buffer(char,pathname,MAXPATHNAME); |
||
40 | struct dentry *d; |
||
41 | int createflag; |
||
42 | __pid_t pid; |
||
43 | int len,res; |
||
44 | |||
45 | call_to_fs(); |
||
46 | |||
47 | printkd("k_unlink: START"); |
||
48 | pid=__get_pid(); |
||
49 | |||
50 | len=__verify_read_nolen((char*)upathname); |
||
51 | if ((!len)||(len>MAXPATHNAMELEN)) return_from_fs(-EVERIFY); |
||
52 | __copy_from_user(pathname,upathname,len+1); |
||
53 | |||
54 | printkd("k_unlink: pathname copied"); |
||
55 | |||
56 | createflag=DENTRY_NOCREATE; |
||
57 | d=find_dentry_from_ext(cwden_ptr(pid),(char *)pathname,&createflag); |
||
58 | |||
59 | printkd("k_unlink: dentry found"); |
||
60 | |||
61 | if (d==NULL) return_from_fs(-ENOENT); |
||
62 | if (__S_ISDIR(d->d_inode->i_st.st_mode)) return_from_fs(-EPERM); |
||
63 | if (!(d->d_sb->sb_mopts.flags&MOUNT_FLAG_RW)) return_from_fs(-EROFS); |
||
64 | |||
65 | printkd("k_unlink: dentry is ok"); |
||
66 | |||
67 | res=unlink_dentry(d); |
||
68 | |||
69 | printkd("k_unlink: dentry unlinked"); |
||
70 | |||
71 | printkd("k_unlink: END"); |
||
72 | return_from_fs(res); |
||
73 | } |