Lines Matching refs:fh
41 static char *basename(struct file_handle *fh) in basename() argument
43 char *s = strrchr(fh->path, '/'); in basename()
46 return fh->path; in basename()
49 static int set_blk_dev(struct file_handle *fh) in set_blk_dev() argument
51 return fs_set_blk_dev_with_part(fh->fs->desc, fh->fs->part); in set_blk_dev()
54 static int is_dir(struct file_handle *fh) in is_dir() argument
58 set_blk_dev(fh); in is_dir()
59 dirs = fs_opendir(fh->path); in is_dir()
135 struct file_handle *fh; in file_open() local
153 fh = calloc(1, sizeof(*fh) + plen + (flen * MAX_UTF8_PER_UTF16) + 2); in file_open()
155 fh->base = efi_file_handle_protocol; in file_open()
156 fh->fs = fs; in file_open()
159 char *p = fh->path; in file_open()
169 if (sanitize_path(fh->path)) in file_open()
173 if (set_blk_dev(fh)) in file_open()
176 if (!((mode & EFI_FILE_MODE_CREATE) || fs_exists(fh->path))) in file_open()
180 fh->isdir = is_dir(fh); in file_open()
182 fh->isdir = 1; in file_open()
183 strcpy(fh->path, ""); in file_open()
186 return &fh->base; in file_open()
189 free(fh); in file_open()
197 struct file_handle *fh = to_fh(file); in efi_file_open() local
202 *new_handle = file_open(fh->fs, fh, file_name, open_mode); in efi_file_open()
209 static efi_status_t file_close(struct file_handle *fh) in file_close() argument
211 fs_closedir(fh->dirs); in file_close()
212 free(fh); in file_close()
218 struct file_handle *fh = to_fh(file); in efi_file_close() local
220 return EFI_EXIT(file_close(fh)); in efi_file_close()
225 struct file_handle *fh = to_fh(file); in efi_file_delete() local
227 file_close(fh); in efi_file_delete()
231 static efi_status_t file_read(struct file_handle *fh, u64 *buffer_size, in file_read() argument
236 if (fs_read(fh->path, (ulong)buffer, fh->offset, in file_read()
241 fh->offset += actread; in file_read()
246 static efi_status_t dir_read(struct file_handle *fh, u64 *buffer_size, in dir_read() argument
253 if (!fh->dirs) { in dir_read()
254 assert(fh->offset == 0); in dir_read()
255 fh->dirs = fs_opendir(fh->path); in dir_read()
256 if (!fh->dirs) in dir_read()
266 if (fh->dent) { in dir_read()
267 dent = fh->dent; in dir_read()
268 fh->dent = NULL; in dir_read()
270 dent = fs_readdir(fh->dirs); in dir_read()
297 fh->dent = dent; in dir_read()
313 fh->offset++; in dir_read()
321 struct file_handle *fh = to_fh(file); in efi_file_read() local
332 if (set_blk_dev(fh)) { in efi_file_read()
338 if (fh->isdir) in efi_file_read()
339 ret = dir_read(fh, &bs, buffer); in efi_file_read()
341 ret = file_read(fh, &bs, buffer); in efi_file_read()
355 struct file_handle *fh = to_fh(file); in efi_file_write() local
361 if (set_blk_dev(fh)) { in efi_file_write()
366 if (fs_write(fh->path, (ulong)buffer, fh->offset, *buffer_size, in efi_file_write()
373 fh->offset += actwrite; in efi_file_write()
382 struct file_handle *fh = to_fh(file); in efi_file_getpos() local
386 if (fh->offset <= SIZE_MAX) { in efi_file_getpos()
387 *pos = fh->offset; in efi_file_getpos()
397 struct file_handle *fh = to_fh(file); in efi_file_setpos() local
402 if (fh->isdir) { in efi_file_setpos()
407 fs_closedir(fh->dirs); in efi_file_setpos()
408 fh->dirs = NULL; in efi_file_setpos()
414 if (set_blk_dev(fh)) { in efi_file_setpos()
419 if (fs_size(fh->path, &file_size)) { in efi_file_setpos()
427 fh->offset = pos; in efi_file_setpos()
438 struct file_handle *fh = to_fh(file); in efi_file_getinfo() local
445 char *filename = basename(fh); in efi_file_getinfo()
457 if (set_blk_dev(fh)) { in efi_file_getinfo()
462 if (fs_size(fh->path, &file_size)) { in efi_file_getinfo()
473 if (fh->isdir) in efi_file_getinfo()
483 if (fh->fs->part >= 1) in efi_file_getinfo()
484 r = part_get_info(fh->fs->desc, fh->fs->part, &part); in efi_file_getinfo()
486 r = part_get_info_whole_disk(fh->fs->desc, &part); in efi_file_getinfo()