Rev 3 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
#include <fs/types.h>
#include <fs/errno.h>
#include <fs/task.h>
#include <fs/maccess.h>
#include "fsconst.h"
#include "file.h"
#include "inode.h"
#include "fileop.h"
#include "dentry.h"
#include "fs.h"
#include "debug.h"
int k_stat(char *upathname, struct stat *buf)
{
declare_buffer(char,pathname,MAXPATHNAME);
struct dentry *d;
const __pid_t pid=__get_pid();
int len;
call_to_fs();
printk6("k_stat: START");
len=__verify_read_nolen((char*)upathname);
if ((!len)||(len>MAXPATHNAMELEN)) {
printk6("k_stat: verify user memory failed");
printk6("k_stat: END");
return_from_fs(-EVERIFY);
}
__copy_from_user(pathname,upathname,len+1);
printk6("k_stat: for '%s'",pathname);
d=find_dentry_from(cwden_ptr(pid),(char *)pathname);
if (d==NULL) {
printk6("k_stat: not found!");
printk6("k_stat: END");
return_from_fs(-ENOENT);
}
printk6("k_stat: found... copying to user");
if (!__verify_write(buf,sizeof(struct stat))) return_from_fs(-EVERIFY);
__copy_to_user(buf,&(d->d_inode->i_st),sizeof(struct stat));
unlock_dentry(d);
printk6("k_stat: END");
return_from_fs(EOK);
}