/* sfs.c - Amiga Smart FileSystem. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2005,2006,2007,2008,2009 Free Software Foundation, Inc.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
GRUB_MOD_LICENSE ("GPLv3+");
/* The common header for a block. */
struct grub_sfs_bheader
{
} __attribute__ ((packed));
/* The sfs rootblock. */
struct grub_sfs_rblock
{
} __attribute__ ((packed));
/* A SFS object container. */
struct grub_sfs_obj
{
union
{
struct
{
struct
{
} file_dir;
} __attribute__ ((packed));
/* A SFS object container. */
struct grub_sfs_objc
{
/* The amount of objects depends on the blocksize. */
} __attribute__ ((packed));
struct grub_sfs_btree_node
{
} __attribute__ ((packed));
struct grub_sfs_btree_extent
{
} __attribute__ ((packed));
struct grub_sfs_btree
{
/* Normally this can be kind of node, but just extents are
supported. */
} __attribute__ ((packed));
struct grub_fshelp_node
{
int block;
int size;
};
/* Information about a "mounted" sfs filesystem. */
struct grub_sfs_data
{
/* Blocksize in sectors. */
unsigned int blocksize;
/* Label of the filesystem. */
char *label;
};
/* Lookup the extent starting with BLOCK in the filesystem described
by DATA. Return the extent size in SIZE and the following extent
in NEXTEXT. */
static grub_err_t
{
char *treeblock;
int i;
int next;
if (!block)
return 0;
/* Handle this level in the btree. */
do
{
if (grub_errno)
{
return grub_errno;
}
{
/* Follow the tree down to the leaf level. */
{
break;
}
/* If the leaf level is reached, just find the correct extent. */
{
/* We found a correct leaf. */
return 0;
}
}
}
static grub_disk_addr_t
{
int size = 0;
int next = 0;
while (blk)
{
/* In case of the first block we don't have to lookup the
extent, the minimum size is always 1. */
if (fileblock == 0)
return blk;
if (err)
return 0;
}
"reading a SFS block outside the extent");
return 0;
}
/* Read LEN bytes from the file described by DATA starting with byte
POS. Return the amount of read bytes in READ. */
static grub_ssize_t
{
}
static struct grub_sfs_data *
{
char *rootobjc_data = 0;
unsigned int blk;
if (!data)
return 0;
/* Read the rootblock. */
if (grub_errno)
goto fail;
/* Make sure this is a sfs filesystem. */
{
goto fail;
}
if (! rootobjc_data)
goto fail;
/* Read the root object container. */
if (grub_errno)
goto fail;
return data;
fail:
if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
return 0;
}
static char *
{
char *symlink;
char *block;
if (!block)
return 0;
if (grub_errno)
{
return 0;
}
/* This is just a wild guess, but it always worked for me. How the
SLNK block looks like is not documented in the SFS docs. */
if (!symlink)
return 0;
return symlink;
}
static int
int NESTED_FUNC_ATTR
enum grub_fshelp_filetype filetype,
{
char *objc_data;
int pos;
int block,
int block,
{
int ret;
if (!node)
return 1;
if (!name_u8)
{
return 1;
}
return ret;
}
if (!objc_data)
goto fail;
/* The Object container can consist of multiple blocks, iterate over
every block. */
while (next)
{
if (grub_errno)
goto fail;
/* Iterate over all entries in this block. */
{
int len;
unsigned int block;
/* The filename and comment dynamically increase the size of
the object. */
/* Round up to a multiple of two bytes. */
if (filename[0] == 0)
continue;
/* First check if the file was not deleted. */
continue;
else
if (type == GRUB_FSHELP_DIR)
else
{
return 1;
}
}
}
fail:
return 0;
}
/* Open a file named NAME and initialize FILE. */
static grub_err_t
{
if (!data)
goto fail;
if (grub_errno)
goto fail;
return 0;
fail:
if (data)
return grub_errno;
}
static grub_err_t
{
return GRUB_ERR_NONE;
}
/* Read LEN bytes data from FILE into BUF. */
static grub_ssize_t
{
return size;
}
static grub_err_t
const struct grub_dirhook_info *info))
{
enum grub_fshelp_filetype filetype,
enum grub_fshelp_filetype filetype,
{
}
if (!data)
goto fail;
if (grub_errno)
goto fail;
fail:
if (data)
return grub_errno;
}
static grub_err_t
{
if (data)
{
if (*label)
len) = '\0';
}
return grub_errno;
}
{
.name = "sfs",
.dir = grub_sfs_dir,
.open = grub_sfs_open,
.read = grub_sfs_read,
.close = grub_sfs_close,
.label = grub_sfs_label,
#ifdef GRUB_UTIL
.reserved_first_sector = 0,
#endif
.next = 0
};
{
}
{
}