Beispiel #1
0
int sys_fstat(unsigned int fd, struct stat * statbuf)
{
	struct file * f;
	struct m_inode * inode;

	if (fd >= NR_OPEN || !(f=current->filp[fd]) || !(inode=f->f_inode))
		return -ENOENT;
	return cp_stat(inode,statbuf);
}
/*===========================================================================*
*                        *
*===========================================================================*/
int sys_stat(char * filename, struct stat * statbuf)
{
	struct m_inode * inode;

	if (!(inode=namei(filename)))
		return -ENOENT;
	cp_stat(inode,statbuf);
	iput(inode);
	return 0;
}
Beispiel #3
0
//// 文件状态系统调用函数 - 根据文件名获取文件状态信息。
// 参数filename 是指定的文件名,statbuf 是存放状态信息的缓冲区指针。
// 返回0,若出错则返回出错码。
int
sys_stat (char *filename, struct stat *statbuf)
{
	struct m_inode *inode;

// 首先根据文件名找出对应的i 节点,若出错则返回错误码。
	if (!(inode = namei (filename)))
		return -ENOENT;
// 将i 节点上的文件状态信息复制到用户缓冲区中,并释放该i 节点。
	cp_stat (inode, statbuf);
	iput (inode);
	return 0;
}
Beispiel #4
0
//// 文件状态系统调用 - 根据文件句柄获取文件状态信息。
// 参数fd 是指定文件的句柄(描述符),statbuf 是存放状态信息的缓冲区指针。
// 返回0,若出错则返回出错码。
int
sys_fstat (unsigned int fd, struct stat *statbuf)
{
	struct file *f;
	struct m_inode *inode;

// 如果文件句柄值大于一个程序最多打开文件数NR_OPEN,或者该句柄的文件结构指针为空,或者
// 对应文件结构的i 节点字段为空,则出错,返回出错码并退出。
	if (fd >= NR_OPEN || !(f = current->filp[fd]) || !(inode = f->f_inode))
		return -EBADF;
// 将i 节点上的文件状态信息复制到用户缓冲区中。
	cp_stat (inode, statbuf);
	return 0;
}