Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
 
2
#include <bits/utime.h>
3
#include <fs/types.h>
4
#include <fs/errno.h>
5
#include <fs/task.h>
6
#include <fs/util.h>
7
#include <fs/maccess.h>
8
 
9
 
10
#include "file.h"
11
#include "dentry.h"
12
#include "inode.h"
13
#include "rwlock.h"
14
#include "fs.h"
15
 
16
/*
17
struct utimbuf {
18
  __time_t acctime;
19
  __time_t modtime;
20
};
21
*/
22
 
23
int k_utime(char *path, struct utimbuf *times)
24
{
25
  declare_buffer(char,pathname,MAXPATHNAME);
26
  declare_buffer(struct utimbuf,t,1);
27
  int createflag=DENTRY_NOCREATE;
28
  struct dentry *d;
29
  __pid_t pid;
30
  int len;
31
 
32
  call_to_fs();
33
 
34
  len=__verify_read_nolen((char*)path);
35
  if ((!len)||(len>MAXPATHNAMELEN)) return_from_fs(-EVERIFY);
36
  __copy_from_user(pathname,path,len+1);
37
  init_buffer(t);
38
  if (times!=NULL) {
39
    len=__verify_read((char*)times,sizeof(struct utimbuf));
40
    if (!len) return_from_fs(-EPERM);
41
    __copy_from_user(t,times,len);
42
  }
43
 
44
  pid=__get_pid();  
45
  lock_desctable(pid);
46
 
47
  d=find_dentry_from_ext(cwden_ptr(pid),(char *)pathname,&createflag);
48
  if (d==NULL) {
49
    unlock_desctable(pid);
50
    return_from_fs(-ENOENT);
51
  }
52
 
53
  __rwlock_wrlock(&d->d_inode->i_lock);
54
  if (times==NULL) {
55
    d->d_inode->i_st.st_atime=d->d_inode->i_st.st_mtime=gettimek();
56
  } else {
57
    d->d_inode->i_st.st_atime=t->actime;
58
    d->d_inode->i_st.st_mtime=t->modtime;
59
  }  
60
  d->d_inode->i_dirty=1;
61
  __rwlock_wrunlock(&d->d_inode->i_lock);
62
 
63
  unlock_dentry(d);
64
  unlock_desctable(pid);
65
  return_from_fs(EOK);
66
}