Subversion Repositories shark

Rev

Rev 3 | 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
 
24
#include "fsconst.h"
25
#include "file.h"
26
#include "inode.h"
27
#include "fileop.h"
28
#include "dentry.h"
29
#include "fs.h"
30
 
31
#include "debug.h"
32
 
33
int k_stat(char *upathname, struct stat *buf)
34
{
35
  declare_buffer(char,pathname,MAXPATHNAME);
36
  struct dentry *d;
37
  const __pid_t pid=__get_pid();
38
  int len;
39
 
40
  call_to_fs();
41
 
42
  printk6("k_stat: START");
43
 
44
  len=__verify_read_nolen((char*)upathname);
45
  if ((!len)||(len>MAXPATHNAMELEN)) {
46
    printk6("k_stat: verify user memory failed");
47
    printk6("k_stat: END");
48
    return_from_fs(-EVERIFY);
49
  }
50
  __copy_from_user(pathname,upathname,len+1);
51
 
52
  printk6("k_stat: for '%s'",pathname);
53
 
54
  d=find_dentry_from(cwden_ptr(pid),(char *)pathname);
55
  if (d==NULL) {
56
    printk6("k_stat: not found!");
57
    printk6("k_stat: END");
58
    return_from_fs(-ENOENT);
59
  }
60
  printk6("k_stat: found... copying to user");
61
 
62
  if (!__verify_write(buf,sizeof(struct stat))) return_from_fs(-EVERIFY);
63
  __copy_to_user(buf,&(d->d_inode->i_st),sizeof(struct stat));
64
 
65
  unlock_dentry(d);
66
 
67
  printk6("k_stat: END");
68
  return_from_fs(EOK);
69
}