static struct ko_section *map_file(struct ko_process *to, xstring name, page_prot_t prot, size_t __out *size) { void *fp; size_t map_size; struct ko_section *map; //TODO: 此处应该使用to 的原始启动路径来做当前路径 if (NULL == (fp = fss_open(kt_current()->current_dir, name))) goto err0; map_size = fss_get_size(fp); if (NULL == (map = create_file_map(to, fp, map_size, prot))) goto err1; if (size) *size = map_size; return map; err1: fss_close(fp); err0: return NULL; }
static struct ko_section *map_file(struct ko_process *to, xstring name, page_prot_t prot, unsigned long *map_size) { struct ko_section *ks_file; unsigned long size; void *fp; fp = fss_open(kt_current()->current_dir, name); if (!fp) goto end; *map_size = size = fss_get_size(fp); ks_file = ks_create(to, KS_TYPE_FILE, NULL, size, prot); if (!ks_file) goto err1; ks_file->priv.file.file = fp; return ks_file; err1: fss_close(fp); end: return NULL; }