示例#1
0
文件: file.c 项目: cty12/ucore_plus
int file_close(int fd)
{
	int ret;
	struct file *file;
	if ((ret = fd2file(fd, &file)) != 0) {
		return ret;
	}
	filemap_close(file);
	return 0;
}
示例#2
0
void
fs_closeall(struct fs_struct *fs_struct) {
    assert(fs_struct != NULL && fs_count(fs_struct) > 0);
    int i;
    struct file *file = fs_struct->filemap;
    for (i = 2, file += 2; i < FS_STRUCT_NENTRY; i ++, file ++) {
        if (file->status == FD_OPENED) {
            filemap_close(file);
        }
    }
}
示例#3
0
void
fs_destroy(struct fs_struct *fs_struct) {
    assert(fs_struct != NULL && fs_count(fs_struct) == 0);
    if (fs_struct->pwd != NULL) {
        vop_ref_dec(fs_struct->pwd);
    }
    int i;
    struct file *file = fs_struct->filemap;
    for (i = 0; i < FS_STRUCT_NENTRY; i ++, file ++) {
        if (file->status == FD_OPENED) {
            filemap_close(file);
        }
        assert(file->status == FD_NONE);
    }
    kfree(fs_struct);
}