Esempio n. 1
0
/*
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
 Funtion	:fstat64
 Input		:int fd
 		 < open file descriptor >
 		 struct stat64_i386 *buf
 		 < stat structure >
 Output		:struct stat64_i386 *buf
 		 < stat structure >
 Return		:int
 		 < result >
 Description	:get file status
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
*/
SYSCALL int fstat64(int fd, struct stat64_i386 *buf)
{
	struct file *filp;
	struct vnode *vnode;
	int err;
	
	//printf("fstat64:fd=%d\n", fd);
	
	err = vm_check_access((void*)buf, sizeof(struct stat64_i386), PROT_WRITE);
	
	if (UNLIKELY(err)) {
		return(-EFAULT);
	}
	
	if (UNLIKELY(get_soft_limit(RLIMIT_NOFILE) < fd)) {
		return(-EBADF);
	}
	
	filp = get_open_file(fd);
	
	if (UNLIKELY(!filp)) {
		return(-EBADF);
	}
	
	vnode = filp->f_vnode;
	
	return(vfs_stat64(vnode, buf));
}
Esempio n. 2
0
/*
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
 Funtion	:lstat64
 Input		:const char *path
 		 < file path to get its status >
 		 struct stat64_i386 *buf
 		 < stat structure >
 Output		:struct stat64_i386 *buf
 		 < stat structure >
 Return		:int
 		 < result >
 Description	:get file status
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
*/
SYSCALL int lstat64(const char *path, struct stat64_i386 *buf)
{
	struct file_name *fname;
	struct vnode *vnode;
	int err;
	
	//printf("lstat64:path[%s] ", path);
	
	if (UNLIKELY(!path)) {
		return(-EFAULT);
	}
	
	err = vm_check_access((void*)buf, sizeof(struct stat64_i386), PROT_WRITE);
	
	if (UNLIKELY(err)) {
		return(-EFAULT);
	}
	
	err = vfs_lookup(path, &fname, LOOKUP_ENTRY);
	
	if (err) {
		//printf("err:%d\n", -err);
		return(err);
	}
	
	vnode = fname->dentry->d_vnode;
	
	put_file_name(fname);
	
	err = vfs_stat64(vnode, buf);
	
	return(err);
}
Esempio n. 3
0
asmlinkage long
sys32_stat64(char __user * filename, struct stat64 __user *statbuf)
{
	struct kstat64 stat;
	int ret = vfs_stat64(filename, &stat);
	if (!ret)
		ret = cp_stat64(statbuf, &stat);
	return ret;
}