Subversion Repositories shark

Rev

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
 
7
#include "fsconst.h"
8
#include "file.h"
9
#include "inode.h"
10
#include "fileop.h"
11
#include "dentry.h"
12
#include "fs.h"
13
 
14
#include "debug.h"
15
 
16
int k_stat(char *upathname, struct stat *buf)
17
{
18
  declare_buffer(char,pathname,MAXPATHNAME);
19
  struct dentry *d;
20
  const __pid_t pid=__get_pid();
21
  int len;
22
 
23
  call_to_fs();
24
 
25
  printk6("k_stat: START");
26
 
27
  len=__verify_read_nolen((char*)upathname);
28
  if ((!len)||(len>MAXPATHNAMELEN)) {
29
    printk6("k_stat: verify user memory failed");
30
    printk6("k_stat: END");
31
    return_from_fs(-EVERIFY);
32
  }
33
  __copy_from_user(pathname,upathname,len+1);
34
 
35
  printk6("k_stat: for '%s'",pathname);
36
 
37
  d=find_dentry_from(cwden_ptr(pid),(char *)pathname);
38
  if (d==NULL) {
39
    printk6("k_stat: not found!");
40
    printk6("k_stat: END");
41
    return_from_fs(-ENOENT);
42
  }
43
  printk6("k_stat: found... copying to user");
44
 
45
  if (!__verify_write(buf,sizeof(struct stat))) return_from_fs(-EVERIFY);
46
  __copy_to_user(buf,&(d->d_inode->i_st),sizeof(struct stat));
47
 
48
  unlock_dentry(d);
49
 
50
  printk6("k_stat: END");
51
  return_from_fs(EOK);
52
}