mirror of
https://git.planet-casio.com/Lephenixnoir/gint.git
synced 2025-05-18 15:29:16 +02:00
fygue: fix typo
This commit is contained in:
parent
7ff93e79f0
commit
07b04138ec
17 changed files with 74 additions and 79 deletions
|
@ -13,9 +13,9 @@ int close(int fd)
|
|||
int rc = 0;
|
||||
if(d->type->close == NULL)
|
||||
goto end;
|
||||
/* Fugue's close primitive can flush pending IO write operation. So, we
|
||||
/* Fugue's close primitive can flush pending IO write operations. So, we
|
||||
* are in the same situation than the write() primitive: force-sync
|
||||
* Fygue's descriptor to ensure data intergrity */
|
||||
* Fygue's descriptor to ensure data integrity */
|
||||
rc = d->type->close(d->data);
|
||||
if (fs_descriptor_is_fugue(d))
|
||||
fs_fygue_sync();
|
||||
|
|
|
@ -51,8 +51,7 @@ struct _fat_bpb
|
|||
*
|
||||
* notes
|
||||
* Fugue use the special sector0 to fetch critical flash information
|
||||
* (total logical sector count and number of hidden sector). Then, based
|
||||
* on fecthed information, Fugue select an hardcoded FAT configuration
|
||||
* (total logical sector count and number of hidden sector).
|
||||
*
|
||||
* return
|
||||
* -1 unable to load the sector0
|
||||
|
@ -89,8 +88,8 @@ static int _fygue_fat_sector0(struct fygue_fat *fat)
|
|||
/* _fygue_fat_configure() - configure the FAT information
|
||||
*
|
||||
* notes
|
||||
* the objectif is to find the first FAT address and the reserved root
|
||||
* cluster (at the end of FATs since we only have to handle FAT12/16)
|
||||
* Find the first FAT address and the reserved root cluster (at the end
|
||||
* of FATs since we only have to handle FAT12/16)
|
||||
*
|
||||
* note that for FAT12/16 two special cluster entry are added, this is
|
||||
* why we have a manual offset to calculate the number of sector per
|
||||
|
|
|
@ -317,9 +317,9 @@ static int _fygue_readdir_fat(struct _fat_info *finfo)
|
|||
* notes
|
||||
* check special first character of the FAT entry and try to determine
|
||||
* if it is:
|
||||
* 0x00 unused entry and all remaning entry will be unused
|
||||
* 0xe5 unused entry
|
||||
* 0x2e special "." or ".." entry
|
||||
* 0x00 unused entry and all remaning entry will be unused
|
||||
* 0xe5 unused entry
|
||||
* 0x2e special "." or ".." entry
|
||||
* then check the dirent attribute to distinguish an VFAT entry from an
|
||||
* classic FAT entry
|
||||
*
|
||||
|
@ -376,8 +376,8 @@ static int _fygue_readdir_fat_check(struct _fat_info *finfo)
|
|||
* return
|
||||
* -2 internal error
|
||||
* -1 argument error
|
||||
* 0 success
|
||||
* 1 no directory found */
|
||||
* 0 success
|
||||
* 1 no directory found */
|
||||
int fygue_fat_dir_read(
|
||||
struct fygue_fat *fat,
|
||||
struct fygue_fat_dir *dir,
|
||||
|
|
|
@ -9,11 +9,11 @@ int fygue_fat_file_open(
|
|||
struct fygue_fat_dirent *dirent
|
||||
) {
|
||||
memset(file, 0x00, sizeof(struct fygue_fat_file));
|
||||
file->attribute = dirent->attribute;
|
||||
file->cluster_entry = dirent->cluster_id;
|
||||
file->size = dirent->size;
|
||||
file->chunk = NULL;
|
||||
file->chunk_count = 0;
|
||||
file->attribute = dirent->attribute;
|
||||
file->cluster_entry = dirent->cluster_id;
|
||||
file->size = dirent->size;
|
||||
file->chunk = NULL;
|
||||
file->chunk_count = 0;
|
||||
file->chunk_table_max_index = 0;
|
||||
if (fygue_fat_file_sync(fat, file, dirent->cluster_id) != 0)
|
||||
return -1;
|
||||
|
|
|
@ -34,7 +34,7 @@ static int _get_block_nb(struct fygue_fat *fat, int cluster)
|
|||
// Public
|
||||
//---
|
||||
|
||||
/* fygue_fat_file_stat(): directory-specific stat primitive */
|
||||
/* fygue_fat_file_stat(): stat primitive */
|
||||
int fygue_fat_file_stat(
|
||||
struct fygue_fat *fat,
|
||||
struct fygue_fat_file *file,
|
||||
|
@ -44,14 +44,14 @@ int fygue_fat_file_stat(
|
|||
errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
statbuf->st_dev = 0; /* not supported */
|
||||
statbuf->st_ino = file->cluster_entry;
|
||||
statbuf->st_mode = _get_mode(file->attribute);
|
||||
statbuf->st_dev = 0; /* not supported */
|
||||
statbuf->st_ino = file->cluster_entry;
|
||||
statbuf->st_mode = _get_mode(file->attribute);
|
||||
statbuf->st_nlink = 0; /* not supported */
|
||||
statbuf->st_uid = 0; /* not supported */
|
||||
statbuf->st_gid = 0; /* not supported */
|
||||
statbuf->st_rdev = 0; /* not supported */
|
||||
statbuf->st_size = file->size;
|
||||
statbuf->st_uid = 0; /* not supported */
|
||||
statbuf->st_gid = 0; /* not supported */
|
||||
statbuf->st_rdev = 0; /* not supported */
|
||||
statbuf->st_size = file->size;
|
||||
statbuf->st_atime = 0; /* not supported */
|
||||
statbuf->st_mtime = 0; /* not supported */
|
||||
statbuf->st_ctime = 0; /* not supported */
|
||||
|
|
|
@ -29,15 +29,11 @@ struct _bfile_cluster_metadata
|
|||
*
|
||||
* notes
|
||||
* - assume that fcluster is not NULL
|
||||
* - try using P1 information first then, P2 if this greedy-read fail
|
||||
* - to ensure that the provided bfile metadata is valid we will perform
|
||||
* some test (also performed by Casio). First, ensure that the
|
||||
* fcluster "kind" is valid (only 0x88, 0x22 or 0x11 are known and
|
||||
* used) and then ensure that the "constant" part is also valid
|
||||
* some test (also performed by Casio).
|
||||
*
|
||||
* todo : ensure checksum
|
||||
* todo : ensure ecc handling (?)
|
||||
* todo : try P1 then P2
|
||||
*
|
||||
* return
|
||||
* -1 if the provided `fcluster` is not NULL
|
||||
|
@ -93,10 +89,10 @@ static int _fygue_flash_cluster_convert(
|
|||
) {
|
||||
return -5;
|
||||
}
|
||||
// on the fxcp400, have only some flash sector with the constants used
|
||||
// in other device. Internally, on the fxcp400, Casio only perform
|
||||
// a check an CRC that is performed on the whole cluster
|
||||
// TODO: CRC check
|
||||
// The fxcp400 has only some flash sectors with the constants used
|
||||
// by other devices. Internally, on the fxcp400, Casio only performs
|
||||
// a CRC check that is performed on the whole target cluster
|
||||
// TODO: CRC check ?
|
||||
#if 0
|
||||
if (
|
||||
memcmp(&(bfile_meta->constant), _constant1, 0x18) != 0 &&
|
||||
|
@ -114,7 +110,7 @@ static int _fygue_flash_cluster_convert(
|
|||
/* _fygue_flash_cluster_meta(): special metadata cluster handling
|
||||
*
|
||||
* notes:
|
||||
* metadata cluster are the last flash cluster of a flash sector it does
|
||||
* metadata clusters are the last flash cluster of a flash sector it does
|
||||
* not have Bfile information. Generate a fake flash cluster with a
|
||||
* special custom kind to allow quick identification */
|
||||
static int _fygue_flash_cluster_meta(
|
||||
|
@ -142,19 +138,20 @@ static int _fygue_flash_cluster_meta(
|
|||
/* _fygue_flash_cluster_details(): special flash sector details handling
|
||||
*
|
||||
* notes:
|
||||
* flash sector details is a particular flash cluster that contains
|
||||
* flash sector details are a particular flash cluster that contains
|
||||
* critical versioning information needed to rebuild Casio's flash
|
||||
* mapping.
|
||||
* However, this particular flash cluster are not represented in the
|
||||
* same way between machines. For example, the G35EII that use flash
|
||||
* sector of 64ko merge the details sector inside the metadata cluster to
|
||||
* keep some space which is not the case with the FXCP400 or CG50 that
|
||||
*
|
||||
* However, this particular flash cluster is not represented in the
|
||||
* same way between machines. For example, the G35EII that uses a flash
|
||||
* sector of 64ko merges the details sector inside the metadata cluster
|
||||
* to keep some space which is not the case with the FXCP400 or CG50 that
|
||||
* use 128ko flash sector and which the first cluster should be a details
|
||||
* one type.
|
||||
*
|
||||
* for 64k cluster the 0xf3c0 offset can be calculated as:
|
||||
* 0x10000 - (8*512) = 0xf000 | sector size minus cluster size
|
||||
* 15 * 0x40 = 0x3c0 | skip all data cluster meta info */
|
||||
* 0x10000 - (8*512) = 0xf000 | sector size minus cluster size
|
||||
* 15 * 0x40 = 0x3c0 | skip all data cluster meta info */
|
||||
static int _fygue_flash_cluster_details(
|
||||
struct fygue_flash *flash,
|
||||
struct fygue_flash_cluster *fcluster,
|
||||
|
@ -199,7 +196,7 @@ static int _fygue_flash_cluster_details(
|
|||
*
|
||||
* notes
|
||||
* flash cluster data (0x11 or 0x88) are handled in the same way between
|
||||
* all device */
|
||||
* all devices */
|
||||
static int _fygue_flash_cluster_data(
|
||||
struct fygue_flash *flash,
|
||||
struct fygue_flash_cluster *fcluster,
|
||||
|
@ -257,7 +254,7 @@ static int _fygue_flash_cluster_data(
|
|||
* return
|
||||
* -1 if the provided `fline` is not valid
|
||||
* -2 if the provided `fline` have invalid Bfile metadata
|
||||
* 0 if the meta information has been generated */
|
||||
* 0 if the meta information has been generated */
|
||||
int fygue_flash_cluster_get(
|
||||
struct fygue_flash *flash,
|
||||
struct fygue_flash_cluster *fcluster,
|
||||
|
@ -299,13 +296,13 @@ int fygue_flash_cluster_get(
|
|||
/* fygue_flash_cluster_geometry() - get geometry information
|
||||
*
|
||||
* notes
|
||||
* generate flash cluster geometry information. Note that we handle
|
||||
* sector as a full 32 entry table, which differ from logical cluster ID
|
||||
* that ignore the last entry which contain meta information
|
||||
* generate flash cluster geometry information. Note that we handle
|
||||
* sectors as a full 32/16 entry table, which differs from logical
|
||||
* cluster ID that ignores the last entry which contains meta information.
|
||||
*
|
||||
* returns
|
||||
* -1 if the provided address is not valid
|
||||
* 0 success */
|
||||
* -1 if the provided address is not valid
|
||||
* 0 success */
|
||||
int fygue_flash_cluster_geometry(
|
||||
struct fygue_flash *flash,
|
||||
uintptr_t addr,
|
||||
|
|
|
@ -15,19 +15,19 @@
|
|||
/* fygue_flash_cmap_update() - update the cluster redirection map
|
||||
*
|
||||
* notes
|
||||
* Since Casio use its own methods to handle flash sector and cluster we
|
||||
* Since Casio uses its own methods to handle flash sector and cluster we
|
||||
* need to rebuild the translation page between "logical cluster"
|
||||
* (lcluster) and "flash cluster" (fcluster).
|
||||
*
|
||||
* Casio do not erase systematicaly each sector when they become
|
||||
* outdated, instead, they use a `age` mechanism which indicate "when"
|
||||
* the cluster has been created a keep the more recent one
|
||||
* Casio does not erase systematically each sector when they become
|
||||
* outdated, instead, they use a `version` mechanism which indicates
|
||||
* "when" the cluster has been created to keep the more recent one.
|
||||
*
|
||||
* return
|
||||
* -1 if the provided information is not valid
|
||||
* 0 if the provided lcluster exists and has not been updated
|
||||
* 1 if the provided lcluster has been created
|
||||
* 2 if the provided lcluster exists and has been updated */
|
||||
* 0 if the provided lcluster exists and has not been updated
|
||||
* 1 if the provided lcluster has been created
|
||||
* 2 if the provided lcluster exists and has been updated */
|
||||
static int fygue_flash_cmap_update(
|
||||
struct fygue_flash_cmap *cmap,
|
||||
struct fygue_flash_cluster *fcluster
|
||||
|
@ -144,20 +144,20 @@ int fygue_flash_cmap_lsector_get_addr(
|
|||
/* fygue_flash_cmap_init() - initialize fcluster translation
|
||||
*
|
||||
* notes:
|
||||
* Casio have its own flash handling layer that hook Fugue primitives to
|
||||
* control how/when the hardware will perform IO operation
|
||||
* Casio has its own flash handling layer that hooks Fugue primitives to
|
||||
* control how/when the hardware will perform IO operations
|
||||
* (read,write,erase). This because the Flash used in recent devices use
|
||||
* sector of 128ko which imply, when you want to update one byte of
|
||||
* sector of 128ko which implies, when you want to update one byte of
|
||||
* memory, you need to:
|
||||
* - copy the whole page in RAM
|
||||
* - perform the modification
|
||||
* - write the new page information
|
||||
* - copy the whole page in RAM
|
||||
* - perform the modification
|
||||
* - write the new page information
|
||||
*
|
||||
* So, todo
|
||||
* todo: docs
|
||||
*
|
||||
* returns:
|
||||
* -1 if the sector 0 is not found
|
||||
* 0 success */
|
||||
* 0 success */
|
||||
int fygue_flash_cmap_initialize(
|
||||
struct fygue_flash *flash,
|
||||
struct fygue_flash_cmap *cmap
|
||||
|
|
|
@ -99,7 +99,7 @@ static int fygue_gfdi_file_close(struct fygue_descriptor *desc)
|
|||
}
|
||||
|
||||
//---
|
||||
// Gint File Descriptor Interface (gfdi) for file
|
||||
// Gint File Descriptor Interface (gfdi) for directory
|
||||
//---
|
||||
|
||||
/* fygue_dir_write(): write directory (EISDIR) */
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
// Internals
|
||||
//---
|
||||
|
||||
/* realloc a prepare the internal table */
|
||||
/* realloc and prepare the internal table */
|
||||
static int _fygue_dir_open_table_realloc(struct fygue_dir *dir)
|
||||
{
|
||||
void *tmp;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
/* fygue_dir_read(): directory read implementation
|
||||
*
|
||||
* notes
|
||||
* - assume that the directory have read permission */
|
||||
* - assume that the directory has read permission */
|
||||
ssize_t fygue_dir_read(
|
||||
struct fygue_fsinfo *fsinfo,
|
||||
struct fygue_dir *dir,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include <string.h>
|
||||
#include "fygue.h"
|
||||
|
||||
/* fygue_file_close(): close directory */
|
||||
/* fygue_file_close(): close file */
|
||||
int fygue_file_close(
|
||||
struct fygue_fsinfo *fsinfo,
|
||||
struct fygue_file *file
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "fygue.h"
|
||||
|
||||
/* fygue_file_write(): write directory (EISDIR) */
|
||||
/* fygue_file_write(): write file (EROFS) */
|
||||
ssize_t fygue_file_write(
|
||||
struct fygue_fsinfo *fsinfo,
|
||||
struct fygue_file *file,
|
||||
|
|
|
@ -15,7 +15,7 @@ static struct fygue_fsinfo *__fygue_fsinfo = NULL;
|
|||
/* fygue_mount() - mount (if needed) and return the filesystem information
|
||||
*
|
||||
* notes
|
||||
* - assume that this global is const after initialisation */
|
||||
* - assume that `__fygue_fsinfo` is const after initialisation */
|
||||
int fygue_mount(struct fygue_fsinfo **fsinfo)
|
||||
{
|
||||
if (fsinfo == NULL)
|
||||
|
|
|
@ -14,8 +14,7 @@
|
|||
*
|
||||
* notes
|
||||
* - assume that path is clean
|
||||
* - automatically mount the filesystem if needed
|
||||
* - the saved pathname will not be saved in stat */
|
||||
* - automatically mount the filesystem if needed */
|
||||
int fygue_open_resolve(
|
||||
char const * const path,
|
||||
struct fygue_descriptor *desc
|
||||
|
@ -59,7 +58,7 @@ int fygue_open(char const *path, int flags, GUNUSED mode_t mode)
|
|||
if ((exists < 0 && (!(flags & O_CREAT) || (flags & O_DIRECTORY))))
|
||||
FYGUE_RET_ERRNO(ENOENT);
|
||||
|
||||
/* if opening fails and the previous check as not returned an error,
|
||||
/* if opening fails and the previous check has not returned an error,
|
||||
* it is certainly because of a creation request. We are a read-only
|
||||
* file-system, so, fail */
|
||||
if (exists < 0)
|
||||
|
|
|
@ -10,8 +10,8 @@ int open(char const *path, int flags, ...)
|
|||
mode_t mode = va_arg(args, int);
|
||||
va_end(args);
|
||||
|
||||
/* Standard open() use Fugue filesystem if a write operation
|
||||
* is requested, otherwise use the Fygue filesystem */
|
||||
/* Standard open() uses Fugue filesystem if a write operation
|
||||
* is requested, otherwise uses the Fygue filesystem */
|
||||
int rc = -1;
|
||||
if ((flags & O_WRONLY) || (flags & O_RDWR)) {
|
||||
rc = fugue_open(path, flags, mode);
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
int stat(char const * restrict path, struct stat * restrict statbuf)
|
||||
{
|
||||
/* Standard stat() is also provided by Fugue, but rely on Casio's
|
||||
* syscall which do not provide all of the information and request
|
||||
* a world-switch (internally) to works */
|
||||
/* Standard stat() is also provided by Fugue, but relies on Casio's
|
||||
* syscall which does not provide all of the information and requests
|
||||
* a world-switch (internally) to work */
|
||||
return fygue_stat(path, statbuf);
|
||||
}
|
||||
|
|
|
@ -12,8 +12,8 @@ ssize_t write(int fd, const void *buf, size_t size)
|
|||
/* No write function: discard the contents but show no error */
|
||||
if(d->type->write == NULL)
|
||||
return 0;
|
||||
/* A special synchronisation must be performed to ensure that all
|
||||
* Fygue's descriptor meta information are valid */
|
||||
/* A special synchronization must be performed to ensure that all
|
||||
* Fygue's descriptor meta information is valid */
|
||||
size = d->type->write(d->data, buf, size);
|
||||
if (fs_descriptor_is_fugue(d))
|
||||
fs_fygue_sync();
|
||||
|
|
Loading…
Add table
Reference in a new issue