Rev 1063 | 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 <bits/utime.h> |
20 | #include <fs/types.h> |
||
21 | #include <fs/errno.h> |
||
22 | #include <fs/task.h> |
||
23 | #include <fs/util.h> |
||
24 | #include <fs/maccess.h> |
||
25 | |||
26 | |||
27 | #include "file.h" |
||
28 | #include "dentry.h" |
||
29 | #include "inode.h" |
||
30 | #include "rwlock.h" |
||
31 | #include "fs.h" |
||
32 | |||
33 | /* |
||
34 | struct utimbuf { |
||
35 | __time_t acctime; |
||
36 | __time_t modtime; |
||
37 | }; |
||
38 | */ |
||
39 | |||
40 | int k_utime(char *path, struct utimbuf *times) |
||
41 | { |
||
42 | declare_buffer(char,pathname,MAXPATHNAME); |
||
43 | declare_buffer(struct utimbuf,t,1); |
||
44 | int createflag=DENTRY_NOCREATE; |
||
45 | struct dentry *d; |
||
46 | __pid_t pid; |
||
47 | int len; |
||
48 | |||
49 | call_to_fs(); |
||
50 | |||
51 | len=__verify_read_nolen((char*)path); |
||
52 | if ((!len)||(len>MAXPATHNAMELEN)) return_from_fs(-EVERIFY); |
||
53 | __copy_from_user(pathname,path,len+1); |
||
54 | init_buffer(t); |
||
55 | if (times!=NULL) { |
||
56 | len=__verify_read((char*)times,sizeof(struct utimbuf)); |
||
57 | if (!len) return_from_fs(-EPERM); |
||
58 | __copy_from_user(t,times,len); |
||
59 | } |
||
60 | |||
61 | pid=__get_pid(); |
||
62 | lock_desctable(pid); |
||
63 | |||
64 | d=find_dentry_from_ext(cwden_ptr(pid),(char *)pathname,&createflag); |
||
65 | if (d==NULL) { |
||
66 | unlock_desctable(pid); |
||
67 | return_from_fs(-ENOENT); |
||
68 | } |
||
69 | |||
70 | __rwlock_wrlock(&d->d_inode->i_lock); |
||
71 | if (times==NULL) { |
||
72 | d->d_inode->i_st.st_atime=d->d_inode->i_st.st_mtime=gettimek(); |
||
73 | } else { |
||
74 | d->d_inode->i_st.st_atime=t->actime; |
||
75 | d->d_inode->i_st.st_mtime=t->modtime; |
||
76 | } |
||
77 | d->d_inode->i_dirty=1; |
||
78 | __rwlock_wrunlock(&d->d_inode->i_lock); |
||
79 | |||
80 | unlock_dentry(d); |
||
81 | unlock_desctable(pid); |
||
82 | return_from_fs(EOK); |
||
83 | } |