mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-02 19:55:14 +00:00
* Fix libr_fs on OSX, restrict FS plugins to the only ones
that compile fine everywhere. Need more work and testing
This commit is contained in:
parent
1f4b2af502
commit
5f925ba1f8
@ -6,9 +6,9 @@ LDFLAGS+=${LINK}
|
||||
|
||||
foo: all
|
||||
|
||||
FILESYSTEMS=hfs.mk hfsplus.mk iso9660.mk
|
||||
FILESYSTEMS+= ext2.mk fat.mk jfs.mk
|
||||
FILESYSTEMS+= ntfs.mk reiserfs.mk tar.mk udf.mk ufs2.mk ufs.mk xfs.mk
|
||||
#FILESYSTEMS=hfs.mk iso9660.mk jfs.mk
|
||||
#FILESYSTEMS=hfsplus.mk
|
||||
FILESYSTEMS=ext2.mk fat.mk ntfs.mk reiserfs.mk tar.mk udf.mk ufs2.mk ufs.mk xfs.mk
|
||||
|
||||
include $(FILESYSTEMS)
|
||||
|
||||
|
@ -1,34 +0,0 @@
|
||||
p/fs_ext2.o: p/fs_ext2.c p/fs_grub_base.c ../include/r_fs.h \
|
||||
../include/r_types.h ../include/r_userconf.h ../include/r_types_base.h \
|
||||
/usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \
|
||||
/usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \
|
||||
/usr/include/gnu/stubs-32.h \
|
||||
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/stddef.h \
|
||||
/usr/include/bits/types.h /usr/include/bits/typesizes.h \
|
||||
/usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \
|
||||
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/stdarg.h \
|
||||
/usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \
|
||||
/usr/include/string.h /usr/include/xlocale.h /usr/include/stdlib.h \
|
||||
/usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h \
|
||||
/usr/include/endian.h /usr/include/bits/endian.h \
|
||||
/usr/include/bits/byteswap.h /usr/include/sys/types.h \
|
||||
/usr/include/time.h /usr/include/sys/select.h /usr/include/bits/select.h \
|
||||
/usr/include/bits/sigset.h /usr/include/bits/time.h \
|
||||
/usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \
|
||||
/usr/include/alloca.h /usr/include/sys/time.h /usr/include/sys/stat.h \
|
||||
/usr/include/bits/stat.h /usr/include/fcntl.h /usr/include/bits/fcntl.h \
|
||||
/usr/include/bits/uio.h /usr/include/dirent.h /usr/include/bits/dirent.h \
|
||||
/usr/include/bits/posix1_lim.h /usr/include/bits/local_lim.h \
|
||||
/usr/include/linux/limits.h /usr/include/unistd.h \
|
||||
/usr/include/bits/posix_opt.h /usr/include/bits/environments.h \
|
||||
/usr/include/bits/confname.h /usr/include/getopt.h ../include/r_list.h \
|
||||
../include/r_flist.h ../include/r_io.h ../include/r_util.h \
|
||||
../include/btree.h ../include/r_types.h ../include/list.h \
|
||||
/usr/include/gmp.h p/grub/include/grubfs.h p/grub/include/grub/file.h \
|
||||
p/grub/include/grub/types.h p/grub/include/config.h \
|
||||
p/grub/include/config-util.h p/grub/include/grub/cpu/types.h \
|
||||
p/grub/include/grub/err.h p/grub/include/grub/symbol.h \
|
||||
p/grub/include/grub/device.h p/grub/include/grub/fs.h \
|
||||
p/grub/include/grub/list.h p/grub/include/grub/misc.h \
|
||||
p/grub/include/grub/disk.h p/grub/include/grub/partition.h \
|
||||
p/grub/include/grub/dl.h
|
@ -10,10 +10,13 @@ KERNFILES+=kern/list.c kern/partition.c
|
||||
KERNFILES+=fs/fshelp.c
|
||||
KERNFILES+=fs/reiserfs.c fs/ext2.c
|
||||
KERNFILES+=fs/fat.c fs/ntfs.c
|
||||
#KERNFILES+=fs/hfs.c fs/hfsplus.c
|
||||
#KERNFILES+=fs/udf.c fs/iso9660.c
|
||||
KERNFILES+=fs/cpio.c fs/tar.c
|
||||
KERNFILES+=fs/xfs.c
|
||||
# TODO: remove nested functions from the following .c
|
||||
#KERNFILES+=fs/hfs.c
|
||||
#KERNFILES+=fs/hfsplus.c
|
||||
#KERNFILES+=fs/udf.c
|
||||
#KERNFILES+=fs/iso9660.c
|
||||
#fs/jfs.c
|
||||
#KERNFILES+=main.c
|
||||
KERNFILES+=grubfs.c
|
||||
@ -21,7 +24,7 @@ KERNFILES+=grubfs.c
|
||||
KERNFILES+=partmap/msdos.c
|
||||
|
||||
KERNOBJS=$(subst .c,.o,${KERNFILES})
|
||||
CFLAGS=-Iinclude -g
|
||||
CFLAGS=-Iinclude -g -fPIC
|
||||
CFLAGS+=-I../../../include
|
||||
#CFLAGS+=-fnested-functions
|
||||
BIN=test${EXT_EXE}
|
||||
|
@ -465,10 +465,10 @@ grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int (*hook) (const char *filename, struct grub_fat_dir_entry *dir);
|
||||
static grub_err_t
|
||||
grub_fat_iterate_dir (grub_disk_t disk, struct grub_fat_data *data,
|
||||
int (*_hook) (const char *filename, struct grub_fat_dir_entry *dir))
|
||||
int (*hook) (const char *filename, struct grub_fat_dir_entry *dir, void *p),
|
||||
int (*hook2) (const char *filename, const struct grub_dirhook_info *info))
|
||||
{
|
||||
struct grub_fat_dir_entry dir;
|
||||
char *filename, *filep = 0;
|
||||
@ -476,7 +476,6 @@ grub_fat_iterate_dir (grub_disk_t disk, struct grub_fat_data *data,
|
||||
int slot = -1, slots = -1;
|
||||
int checksum = -1;
|
||||
grub_ssize_t offset;
|
||||
hook = _hook;
|
||||
|
||||
if (! (data->attr & GRUB_FAT_ATTR_DIRECTORY))
|
||||
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory");
|
||||
@ -553,7 +552,7 @@ for (offset = 0;;offset+= sizeof (dir)) {
|
||||
*grub_utf16_to_utf8 ((grub_uint8_t *) filename, unibuf,
|
||||
slots * 13) = '\0';
|
||||
|
||||
if (hook (filename, &dir))
|
||||
if (hook (filename, &dir, hook2))
|
||||
break;
|
||||
|
||||
checksum = -1;
|
||||
@ -586,7 +585,7 @@ for (offset = 0;;offset+= sizeof (dir)) {
|
||||
}
|
||||
*filep = '\0';
|
||||
|
||||
if (hook (filename, &dir))
|
||||
if (hook (filename, &dir, hook2))
|
||||
break;
|
||||
}
|
||||
|
||||
@ -597,86 +596,79 @@ for (offset = 0;;offset+= sizeof (dir)) {
|
||||
}
|
||||
|
||||
static struct grub_fat_data *data;
|
||||
static char *dirname, *dirp;
|
||||
static int call_hook;
|
||||
static int found = 0;
|
||||
static char *dirname, *dirp;
|
||||
static int call_hook;
|
||||
static int found = 0;
|
||||
|
||||
static int iter_hook (const char *filename, struct grub_fat_dir_entry *dir) {
|
||||
struct grub_dirhook_info info;
|
||||
grub_memset (&info, 0, sizeof (info));
|
||||
static int iter_hook (const char *filename, struct grub_fat_dir_entry *dir,
|
||||
int (*hook) (const char *filename, const struct grub_dirhook_info *info)) {
|
||||
struct grub_dirhook_info info;
|
||||
grub_memset (&info, 0, sizeof (info));
|
||||
|
||||
info.dir = !! (dir->attr & GRUB_FAT_ATTR_DIRECTORY);
|
||||
info.case_insensitive = 1;
|
||||
info.dir = !! (dir->attr & GRUB_FAT_ATTR_DIRECTORY);
|
||||
info.case_insensitive = 1;
|
||||
|
||||
if (dir->attr & GRUB_FAT_ATTR_VOLUME_ID)
|
||||
return 0;
|
||||
if (*dirname == '\0' && call_hook)
|
||||
return hook (filename, &info);
|
||||
if (dir->attr & GRUB_FAT_ATTR_VOLUME_ID)
|
||||
return 0;
|
||||
if (*dirname == '\0' && call_hook)
|
||||
return hook (filename, &info);
|
||||
|
||||
if (grub_strcasecmp (dirname, filename) == 0)
|
||||
{
|
||||
found = 1;
|
||||
data->attr = dir->attr;
|
||||
data->file_size = grub_le_to_cpu32 (dir->file_size);
|
||||
data->file_cluster = ((grub_le_to_cpu16 (dir->first_cluster_high) << 16)
|
||||
| grub_le_to_cpu16 (dir->first_cluster_low));
|
||||
data->cur_cluster_num = ~0U;
|
||||
if (grub_strcasecmp (dirname, filename) == 0) {
|
||||
found = 1;
|
||||
data->attr = dir->attr;
|
||||
data->file_size = grub_le_to_cpu32 (dir->file_size);
|
||||
data->file_cluster = ((grub_le_to_cpu16 (dir->first_cluster_high) << 16)
|
||||
| grub_le_to_cpu16 (dir->first_cluster_low));
|
||||
data->cur_cluster_num = ~0U;
|
||||
|
||||
if (call_hook)
|
||||
hook (filename, &info);
|
||||
if (call_hook)
|
||||
hook (filename, &info);
|
||||
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Find the underlying directory or file in PATH and return the
|
||||
next path. If there is no next path or an error occurs, return NULL.
|
||||
If HOOK is specified, call it with each file name. */
|
||||
static char *
|
||||
grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *_data,
|
||||
const char *path,
|
||||
int (*hook) (const char *filename,
|
||||
const struct grub_dirhook_info *info))
|
||||
grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *_data, const char *path,
|
||||
int (*hook) (const char *filename, const struct grub_dirhook_info *info))
|
||||
{
|
||||
found = 0;
|
||||
data = _data;
|
||||
found = 0;
|
||||
data = _data;
|
||||
|
||||
if (! (data->attr & GRUB_FAT_ATTR_DIRECTORY))
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory");
|
||||
return 0;
|
||||
}
|
||||
if (! (data->attr & GRUB_FAT_ATTR_DIRECTORY)) {
|
||||
grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Extract a directory name. */
|
||||
while (*path == '/')
|
||||
path++;
|
||||
/* Extract a directory name. */
|
||||
while (*path == '/')
|
||||
path++;
|
||||
|
||||
dirp = grub_strchr (path, '/');
|
||||
if (dirp)
|
||||
{
|
||||
unsigned len = dirp - path;
|
||||
dirp = grub_strchr (path, '/');
|
||||
if (dirp) {
|
||||
unsigned len = dirp - path;
|
||||
|
||||
dirname = grub_malloc (len + 1);
|
||||
if (! dirname)
|
||||
return 0;
|
||||
dirname = grub_malloc (len + 1);
|
||||
if (! dirname)
|
||||
return 0;
|
||||
|
||||
grub_memcpy (dirname, path, len);
|
||||
dirname[len] = '\0';
|
||||
}
|
||||
else
|
||||
/* This is actually a file. */
|
||||
dirname = grub_strdup (path);
|
||||
grub_memcpy (dirname, path, len);
|
||||
dirname[len] = '\0';
|
||||
} else dirname = grub_strdup (path); /* it is a file. */
|
||||
|
||||
call_hook = (! dirp && hook);
|
||||
call_hook = (! dirp && hook);
|
||||
|
||||
grub_fat_iterate_dir (disk, data, iter_hook);
|
||||
if (grub_errno == GRUB_ERR_NONE && ! found && !call_hook)
|
||||
grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found");
|
||||
grub_fat_iterate_dir (disk, data, iter_hook, hook);
|
||||
if (grub_errno == GRUB_ERR_NONE && ! found && !call_hook)
|
||||
grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found");
|
||||
|
||||
grub_free (dirname);
|
||||
grub_free (dirname);
|
||||
|
||||
return found ? dirp : 0;
|
||||
return found ? dirp : 0;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
@ -782,45 +774,41 @@ grub_fat_close (grub_file_t file)
|
||||
}
|
||||
|
||||
static char **label;
|
||||
static int iter_hook2 (const char *filename, struct grub_fat_dir_entry *dir)
|
||||
{
|
||||
if (dir->attr == GRUB_FAT_ATTR_VOLUME_ID)
|
||||
{
|
||||
*label = grub_strdup (filename);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static grub_err_t
|
||||
grub_fat_label (grub_device_t device, char **_label)
|
||||
{
|
||||
struct grub_fat_data *data;
|
||||
grub_disk_t disk = device->disk;
|
||||
label = _label;
|
||||
static int iter_hook2 (const char *filename, struct grub_fat_dir_entry *dir, void *p) {
|
||||
if (dir->attr == GRUB_FAT_ATTR_VOLUME_ID) {
|
||||
*label = grub_strdup (filename);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_dl_ref (my_mod);
|
||||
static grub_err_t grub_fat_label (grub_device_t device, char **_label) {
|
||||
struct grub_fat_data *data;
|
||||
grub_disk_t disk = device->disk;
|
||||
label = _label;
|
||||
|
||||
data = grub_fat_mount (disk);
|
||||
if (! data)
|
||||
goto fail;
|
||||
grub_dl_ref (my_mod);
|
||||
|
||||
if (! (data->attr & GRUB_FAT_ATTR_DIRECTORY))
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory");
|
||||
return 0;
|
||||
}
|
||||
data = grub_fat_mount (disk);
|
||||
if (! data)
|
||||
goto fail;
|
||||
|
||||
*label = 0;
|
||||
if (! (data->attr & GRUB_FAT_ATTR_DIRECTORY)) {
|
||||
grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory");
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_fat_iterate_dir (disk, data, iter_hook2);
|
||||
*label = 0;
|
||||
|
||||
fail:
|
||||
grub_fat_iterate_dir (disk, data, iter_hook2, NULL);
|
||||
|
||||
grub_dl_unref (my_mod);
|
||||
fail:
|
||||
|
||||
grub_free (data);
|
||||
grub_dl_unref (my_mod);
|
||||
|
||||
return grub_errno;
|
||||
grub_free (data);
|
||||
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
|
@ -596,39 +596,30 @@ grub_hfsplus_read_symlink (grub_fshelp_node_t node)
|
||||
return symlink;
|
||||
}
|
||||
|
||||
static int
|
||||
grub_hfsplus_btree_iterate_node (struct grub_hfsplus_btree *btree,
|
||||
struct grub_hfsplus_btnode *first_node,
|
||||
int first_rec,
|
||||
int (*hook) (void *record))
|
||||
static int grub_hfsplus_btree_iterate_node (struct grub_hfsplus_btree *btree,
|
||||
struct grub_hfsplus_btnode *first_node, int first_rec, int (*hook) (void *record),
|
||||
grub_fshelp_node_t *dir)
|
||||
{
|
||||
int rec;
|
||||
int rec;
|
||||
for (;;) {
|
||||
char *cnode = (char *) first_node;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
char *cnode = (char *) first_node;
|
||||
/* Iterate over all records in this node. */
|
||||
for (rec = first_rec; rec < grub_be_to_cpu16 (first_node->count); rec++) {
|
||||
if (hook (grub_hfsplus_btree_recptr (btree, first_node, rec)))
|
||||
return 1;
|
||||
}
|
||||
if (! first_node->next)
|
||||
break;
|
||||
if (grub_hfsplus_read_file (&btree->file, 0,
|
||||
(grub_be_to_cpu32 (first_node->next) * btree->nodesize),
|
||||
btree->nodesize, cnode) <= 0)
|
||||
return 1;
|
||||
|
||||
/* Iterate over all records in this node. */
|
||||
for (rec = first_rec; rec < grub_be_to_cpu16 (first_node->count); rec++)
|
||||
{
|
||||
if (hook (grub_hfsplus_btree_recptr (btree, first_node, rec)))
|
||||
return 1;
|
||||
/* Don't skip any record in the next iteration. */
|
||||
first_rec = 0;
|
||||
}
|
||||
|
||||
if (! first_node->next)
|
||||
break;
|
||||
|
||||
if (grub_hfsplus_read_file (&btree->file, 0,
|
||||
(grub_be_to_cpu32 (first_node->next)
|
||||
* btree->nodesize),
|
||||
btree->nodesize, cnode) <= 0)
|
||||
return 1;
|
||||
|
||||
/* Don't skip any record in the next iteration. */
|
||||
first_rec = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Lookup the node described by KEY in the B+ Tree BTREE. Compare
|
||||
@ -718,76 +709,55 @@ grub_hfsplus_btree_search (struct grub_hfsplus_btree *btree,
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
grub_hfsplus_iterate_dir (grub_fshelp_node_t dir,
|
||||
int NESTED_FUNC_ATTR
|
||||
(*hook) (const char *filename,
|
||||
enum grub_fshelp_filetype filetype,
|
||||
grub_fshelp_node_t node))
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
auto int list_nodes (void *record);
|
||||
int list_nodes (void *record)
|
||||
{
|
||||
static int list_nodes (grub_fshelp_node_t dir, void *record) {
|
||||
struct grub_hfsplus_catkey *catkey;
|
||||
char *filename;
|
||||
int i;
|
||||
int i, ret = 0;
|
||||
struct grub_fshelp_node *node;
|
||||
struct grub_hfsplus_catfile *fileinfo;
|
||||
enum grub_fshelp_filetype type = GRUB_FSHELP_UNKNOWN;
|
||||
|
||||
catkey = (struct grub_hfsplus_catkey *) record;
|
||||
|
||||
fileinfo =
|
||||
(struct grub_hfsplus_catfile *) ((char *) record
|
||||
+ grub_be_to_cpu16 (catkey->keylen)
|
||||
+ 2 + (grub_be_to_cpu16(catkey->keylen)
|
||||
% 2));
|
||||
fileinfo = (struct grub_hfsplus_catfile *) ((char *) record
|
||||
+ grub_be_to_cpu16 (catkey->keylen) + 2
|
||||
+ (grub_be_to_cpu16(catkey->keylen) % 2));
|
||||
|
||||
/* Stop iterating when the last directory entry is found. */
|
||||
if (grub_be_to_cpu32 (catkey->parent) != dir->fileid)
|
||||
return 1;
|
||||
|
||||
/* Determine the type of the node that is found. */
|
||||
if (grub_be_to_cpu16 (fileinfo->type) == GRUB_HFSPLUS_FILETYPE_REG)
|
||||
{
|
||||
int mode = (grub_be_to_cpu16 (fileinfo->mode)
|
||||
& GRUB_HFSPLUS_FILEMODE_MASK);
|
||||
if (grub_be_to_cpu16 (fileinfo->type) == GRUB_HFSPLUS_FILETYPE_REG) {
|
||||
int mode = (grub_be_to_cpu16 (fileinfo->mode) & GRUB_HFSPLUS_FILEMODE_MASK);
|
||||
|
||||
if (mode == GRUB_HFSPLUS_FILEMODE_REG)
|
||||
type = GRUB_FSHELP_REG;
|
||||
else if (mode == GRUB_HFSPLUS_FILEMODE_SYMLINK)
|
||||
type = GRUB_FSHELP_SYMLINK;
|
||||
else
|
||||
type = GRUB_FSHELP_UNKNOWN;
|
||||
}
|
||||
else if (grub_be_to_cpu16 (fileinfo->type) == GRUB_HFSPLUS_FILETYPE_DIR)
|
||||
type = GRUB_FSHELP_DIR;
|
||||
if (mode == GRUB_HFSPLUS_FILEMODE_REG)
|
||||
type = GRUB_FSHELP_REG;
|
||||
else if (mode == GRUB_HFSPLUS_FILEMODE_SYMLINK)
|
||||
type = GRUB_FSHELP_SYMLINK;
|
||||
else type = GRUB_FSHELP_UNKNOWN;
|
||||
} else if (grub_be_to_cpu16 (fileinfo->type) == GRUB_HFSPLUS_FILETYPE_DIR)
|
||||
type = GRUB_FSHELP_DIR;
|
||||
|
||||
if (type == GRUB_FSHELP_UNKNOWN)
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
/* Make sure the byte order of the UTF16 string is correct. */
|
||||
for (i = 0; i < grub_be_to_cpu16 (catkey->namelen); i++)
|
||||
{
|
||||
catkey->name[i] = grub_be_to_cpu16 (catkey->name[i]);
|
||||
for (i = 0; i < grub_be_to_cpu16 (catkey->namelen); i++) {
|
||||
catkey->name[i] = grub_be_to_cpu16 (catkey->name[i]);
|
||||
|
||||
/* If the name is obviously invalid, skip this node. */
|
||||
if (catkey->name[i] == 0)
|
||||
return 0;
|
||||
}
|
||||
/* If the name is obviously invalid, skip this node. */
|
||||
if (catkey->name[i] == 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
filename = grub_malloc (grub_be_to_cpu16 (catkey->namelen) + 1);
|
||||
if (! filename)
|
||||
return 0;
|
||||
|
||||
if (! grub_utf16_to_utf8 ((grub_uint8_t *) filename, catkey->name,
|
||||
grub_be_to_cpu16 (catkey->namelen)))
|
||||
{
|
||||
grub_free (filename);
|
||||
return 0;
|
||||
}
|
||||
if (! grub_utf16_to_utf8 ((grub_uint8_t *) filename, catkey->name, grub_be_to_cpu16 (catkey->namelen))) {
|
||||
grub_free (filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
filename[grub_be_to_cpu16 (catkey->namelen)] = '\0';
|
||||
|
||||
@ -821,148 +791,115 @@ grub_hfsplus_iterate_dir (grub_fshelp_node_t dir,
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct grub_hfsplus_key_internal intern;
|
||||
struct grub_hfsplus_btnode *node;
|
||||
int ptr;
|
||||
static int grub_hfsplus_iterate_dir (grub_fshelp_node_t dir, int
|
||||
(*hook) (const char *filename, enum grub_fshelp_filetype filetype, grub_fshelp_node_t node))
|
||||
{
|
||||
struct grub_hfsplus_key_internal intern;
|
||||
struct grub_hfsplus_btnode *node;
|
||||
int ptr;
|
||||
|
||||
/* Create a key that points to the first entry in the directory. */
|
||||
intern.catkey.parent = dir->fileid;
|
||||
intern.catkey.name = "";
|
||||
/* Create a key that points to the first entry in the directory. */
|
||||
intern.catkey.parent = dir->fileid;
|
||||
intern.catkey.name = "";
|
||||
|
||||
/* First lookup the first entry. */
|
||||
if (grub_hfsplus_btree_search (&dir->data->catalog_tree, &intern,
|
||||
grub_hfsplus_cmp_catkey, &node, &ptr))
|
||||
return 0;
|
||||
/* First lookup the first entry. */
|
||||
if (grub_hfsplus_btree_search (&dir->data->catalog_tree, &intern,
|
||||
grub_hfsplus_cmp_catkey, &node, &ptr))
|
||||
return 0;
|
||||
|
||||
/* Iterate over all entries in this directory. */
|
||||
grub_hfsplus_btree_iterate_node (&dir->data->catalog_tree, node, ptr,
|
||||
list_nodes);
|
||||
|
||||
grub_free (node);
|
||||
|
||||
return ret;
|
||||
/* Iterate over all entries in this directory. */
|
||||
grub_hfsplus_btree_iterate_node (&dir->data->catalog_tree, node, ptr, list_nodes, dir);
|
||||
grub_free (node);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Open a file named NAME and initialize FILE. */
|
||||
static grub_err_t
|
||||
grub_hfsplus_open (struct grub_file *file, const char *name)
|
||||
{
|
||||
struct grub_hfsplus_data *data;
|
||||
struct grub_fshelp_node *fdiro = 0;
|
||||
static grub_err_t grub_hfsplus_open (struct grub_file *file, const char *name) {
|
||||
struct grub_hfsplus_data *data;
|
||||
struct grub_fshelp_node *fdiro = 0;
|
||||
|
||||
grub_dl_ref (my_mod);
|
||||
grub_dl_ref (my_mod);
|
||||
|
||||
data = grub_hfsplus_mount (file->device->disk);
|
||||
if (!data)
|
||||
goto fail;
|
||||
data = grub_hfsplus_mount (file->device->disk);
|
||||
if (!data)
|
||||
goto fail;
|
||||
|
||||
grub_fshelp_find_file (name, &data->dirroot, &fdiro,
|
||||
grub_hfsplus_iterate_dir,
|
||||
grub_hfsplus_read_symlink, GRUB_FSHELP_REG);
|
||||
if (grub_errno)
|
||||
goto fail;
|
||||
grub_fshelp_find_file (name, &data->dirroot, &fdiro,
|
||||
grub_hfsplus_iterate_dir, grub_hfsplus_read_symlink, GRUB_FSHELP_REG);
|
||||
if (grub_errno)
|
||||
goto fail;
|
||||
|
||||
file->size = fdiro->size;
|
||||
data->opened_file = *fdiro;
|
||||
grub_free (fdiro);
|
||||
file->size = fdiro->size;
|
||||
data->opened_file = *fdiro;
|
||||
grub_free (fdiro);
|
||||
|
||||
file->data = data;
|
||||
file->offset = 0;
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
if (data && fdiro != &data->dirroot)
|
||||
grub_free (fdiro);
|
||||
grub_free (data);
|
||||
|
||||
grub_dl_unref (my_mod);
|
||||
|
||||
return grub_errno;
|
||||
file->data = data;
|
||||
file->offset = 0;
|
||||
return 0;
|
||||
fail:
|
||||
if (data && fdiro != &data->dirroot)
|
||||
grub_free (fdiro);
|
||||
grub_free (data);
|
||||
grub_dl_unref (my_mod);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
|
||||
static grub_err_t
|
||||
grub_hfsplus_close (grub_file_t file)
|
||||
{
|
||||
grub_free (file->data);
|
||||
|
||||
grub_dl_unref (my_mod);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
static grub_err_t grub_hfsplus_close (grub_file_t file) {
|
||||
grub_free (file->data);
|
||||
grub_dl_unref (my_mod);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
|
||||
/* Read LEN bytes data from FILE into BUF. */
|
||||
static grub_ssize_t
|
||||
grub_hfsplus_read (grub_file_t file, char *buf, grub_size_t len)
|
||||
{
|
||||
struct grub_hfsplus_data *data =
|
||||
(struct grub_hfsplus_data *) file->data;
|
||||
|
||||
int size = grub_hfsplus_read_file (&data->opened_file, file->read_hook,
|
||||
file->offset, len, buf);
|
||||
|
||||
return size;
|
||||
static grub_ssize_t grub_hfsplus_read (grub_file_t file, char *buf, grub_size_t len) {
|
||||
struct grub_hfsplus_data *data = (struct grub_hfsplus_data *) file->data;
|
||||
return grub_hfsplus_read_file (&data->opened_file, file->read_hook, file->offset, len, buf);
|
||||
}
|
||||
|
||||
|
||||
static grub_err_t
|
||||
grub_hfsplus_dir (grub_device_t device, const char *path,
|
||||
int (*hook) (const char *filename,
|
||||
const struct grub_dirhook_info *info))
|
||||
{
|
||||
struct grub_hfsplus_data *data = 0;
|
||||
struct grub_fshelp_node *fdiro = 0;
|
||||
|
||||
auto int NESTED_FUNC_ATTR iterate (const char *filename,
|
||||
enum grub_fshelp_filetype filetype,
|
||||
grub_fshelp_node_t node);
|
||||
|
||||
int NESTED_FUNC_ATTR iterate (const char *filename,
|
||||
enum grub_fshelp_filetype filetype,
|
||||
grub_fshelp_node_t node)
|
||||
{
|
||||
struct grub_dirhook_info info;
|
||||
grub_memset (&info, 0, sizeof (info));
|
||||
info.dir = ((filetype & GRUB_FSHELP_TYPE_MASK) == GRUB_FSHELP_DIR);
|
||||
info.mtimeset = 1;
|
||||
info.mtime = node->mtime;
|
||||
info.case_insensitive = !! (filetype & GRUB_FSHELP_CASE_INSENSITIVE);
|
||||
grub_free (node);
|
||||
return hook (filename, &info);
|
||||
}
|
||||
|
||||
grub_dl_ref (my_mod);
|
||||
|
||||
data = grub_hfsplus_mount (device->disk);
|
||||
if (!data)
|
||||
goto fail;
|
||||
|
||||
/* Find the directory that should be opened. */
|
||||
grub_fshelp_find_file (path, &data->dirroot, &fdiro,
|
||||
grub_hfsplus_iterate_dir,
|
||||
grub_hfsplus_read_symlink, GRUB_FSHELP_DIR);
|
||||
if (grub_errno)
|
||||
goto fail;
|
||||
|
||||
/* Iterate over all entries in this directory. */
|
||||
grub_hfsplus_iterate_dir (fdiro, iterate);
|
||||
|
||||
fail:
|
||||
if (data && fdiro != &data->dirroot)
|
||||
grub_free (fdiro);
|
||||
grub_free (data);
|
||||
|
||||
grub_dl_unref (my_mod);
|
||||
|
||||
return grub_errno;
|
||||
static int iterate (const char *filename, enum grub_fshelp_filetype filetype, grub_fshelp_node_t node) {
|
||||
struct grub_dirhook_info info;
|
||||
grub_memset (&info, 0, sizeof (info));
|
||||
info.dir = ((filetype & GRUB_FSHELP_TYPE_MASK) == GRUB_FSHELP_DIR);
|
||||
info.mtimeset = 1;
|
||||
info.mtime = node->mtime;
|
||||
info.case_insensitive = !! (filetype & GRUB_FSHELP_CASE_INSENSITIVE);
|
||||
grub_free (node);
|
||||
return hook (filename, &info);
|
||||
}
|
||||
|
||||
static grub_err_t grub_hfsplus_dir (grub_device_t device, const char *path,
|
||||
int (*hook) (const char *filename, const struct grub_dirhook_info *info))
|
||||
{
|
||||
struct grub_hfsplus_data *data = 0;
|
||||
struct grub_fshelp_node *fdiro = 0;
|
||||
|
||||
grub_dl_ref (my_mod);
|
||||
data = grub_hfsplus_mount (device->disk);
|
||||
if (!data)
|
||||
goto fail;
|
||||
|
||||
/* Find the directory that should be opened. */
|
||||
grub_fshelp_find_file (path, &data->dirroot, &fdiro,
|
||||
grub_hfsplus_iterate_dir, grub_hfsplus_read_symlink, GRUB_FSHELP_DIR);
|
||||
if (grub_errno)
|
||||
goto fail;
|
||||
|
||||
/* Iterate over all entries in this directory. */
|
||||
grub_hfsplus_iterate_dir (fdiro, iterate);
|
||||
fail:
|
||||
if (data && fdiro != &data->dirroot)
|
||||
grub_free (fdiro);
|
||||
grub_free (data);
|
||||
grub_dl_unref (my_mod);
|
||||
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_hfsplus_label (grub_device_t device __attribute__((unused))
|
||||
, char **label __attribute__((unused)))
|
||||
grub_hfsplus_label (grub_device_t device __attribute__((unused)),
|
||||
char **label __attribute__((unused)))
|
||||
{
|
||||
/* XXX: It's not documented how to read a label. */
|
||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
@ -971,78 +908,48 @@ grub_hfsplus_label (grub_device_t device __attribute__((unused))
|
||||
}
|
||||
|
||||
/* Get mtime. */
|
||||
static grub_err_t
|
||||
grub_hfsplus_mtime (grub_device_t device, grub_int32_t *tm)
|
||||
{
|
||||
struct grub_hfsplus_data *data;
|
||||
grub_disk_t disk = device->disk;
|
||||
static grub_err_t grub_hfsplus_mtime (grub_device_t device, grub_int32_t *tm) {
|
||||
struct grub_hfsplus_data *data;
|
||||
grub_disk_t disk = device->disk;
|
||||
|
||||
grub_dl_ref (my_mod);
|
||||
|
||||
data = grub_hfsplus_mount (disk);
|
||||
if (!data)
|
||||
*tm = 0;
|
||||
else
|
||||
*tm = grub_be_to_cpu32 (data->volheader.utime) - 2082844800;
|
||||
|
||||
grub_dl_unref (my_mod);
|
||||
|
||||
grub_free (data);
|
||||
|
||||
return grub_errno;
|
||||
grub_dl_ref (my_mod);
|
||||
data = grub_hfsplus_mount (disk);
|
||||
if (!data)
|
||||
*tm = 0;
|
||||
else *tm = grub_be_to_cpu32 (data->volheader.utime) - 2082844800;
|
||||
|
||||
grub_dl_unref (my_mod);
|
||||
grub_free (data);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_hfsplus_uuid (grub_device_t device, char **uuid)
|
||||
{
|
||||
struct grub_hfsplus_data *data;
|
||||
grub_disk_t disk = device->disk;
|
||||
static grub_err_t grub_hfsplus_uuid (grub_device_t device, char **uuid) {
|
||||
struct grub_hfsplus_data *data;
|
||||
grub_disk_t disk = device->disk;
|
||||
|
||||
grub_dl_ref (my_mod);
|
||||
grub_dl_ref (my_mod);
|
||||
|
||||
data = grub_hfsplus_mount (disk);
|
||||
if (data)
|
||||
{
|
||||
*uuid = grub_xasprintf ("%016llx",
|
||||
(unsigned long long)
|
||||
grub_be_to_cpu64 (data->volheader.num_serial));
|
||||
}
|
||||
else
|
||||
*uuid = NULL;
|
||||
data = grub_hfsplus_mount (disk);
|
||||
if (data) {
|
||||
*uuid = grub_xasprintf ("%016llx", (unsigned long long)
|
||||
grub_be_to_cpu64 (data->volheader.num_serial));
|
||||
} else *uuid = NULL;
|
||||
|
||||
grub_dl_unref (my_mod);
|
||||
grub_dl_unref (my_mod);
|
||||
|
||||
grub_free (data);
|
||||
grub_free (data);
|
||||
|
||||
return grub_errno;
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct grub_fs grub_hfsplus_fs =
|
||||
{
|
||||
.name = "hfsplus",
|
||||
.dir = grub_hfsplus_dir,
|
||||
.open = grub_hfsplus_open,
|
||||
.read = grub_hfsplus_read,
|
||||
.close = grub_hfsplus_close,
|
||||
.label = grub_hfsplus_label,
|
||||
.mtime = grub_hfsplus_mtime,
|
||||
.uuid = grub_hfsplus_uuid,
|
||||
#ifdef GRUB_UTIL
|
||||
.reserved_first_sector = 1,
|
||||
#endif
|
||||
.next = 0
|
||||
};
|
||||
|
||||
GRUB_MOD_INIT(hfsplus)
|
||||
{
|
||||
grub_fs_register (&grub_hfsplus_fs);
|
||||
my_mod = mod;
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(hfsplus)
|
||||
{
|
||||
grub_fs_unregister (&grub_hfsplus_fs);
|
||||
}
|
||||
struct grub_fs grub_hfsplus_fs = {
|
||||
.name = "hfsplus",
|
||||
.dir = grub_hfsplus_dir,
|
||||
.open = grub_hfsplus_open,
|
||||
.read = grub_hfsplus_read,
|
||||
.close = grub_hfsplus_close,
|
||||
.label = grub_hfsplus_label,
|
||||
.mtime = grub_hfsplus_mtime,
|
||||
.uuid = grub_hfsplus_uuid,
|
||||
.next = 0
|
||||
};
|
||||
|
@ -1,3 +1,8 @@
|
||||
# fs.udf
|
||||
# fs.iso9660
|
||||
# fs.hfsplus
|
||||
# fs.hfs
|
||||
# fs.jfs
|
||||
STATIC="asm.java
|
||||
asm.arm
|
||||
asm.armthumb
|
||||
@ -35,14 +40,9 @@ debug.native
|
||||
fs.fat
|
||||
fs.ntfs
|
||||
fs.ext2
|
||||
fs.hfs
|
||||
fs.hfsplus
|
||||
fs.reiserfs
|
||||
fs.iso9660
|
||||
fs.udf
|
||||
fs.tar
|
||||
fs.cpio
|
||||
fs.jfs
|
||||
fs.xfs
|
||||
io.debug
|
||||
io.rap
|
||||
|
Loading…
x
Reference in New Issue
Block a user