fygue: fix typo

This commit is contained in:
Yann MAGNIN 2025-04-12 14:45:38 +02:00
parent 7ff93e79f0
commit 07b04138ec
No known key found for this signature in database
GPG key ID: D82629D933EADC59
17 changed files with 74 additions and 79 deletions

View file

@ -13,9 +13,9 @@ int close(int fd)
int rc = 0; int rc = 0;
if(d->type->close == NULL) if(d->type->close == NULL)
goto end; 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 * 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); rc = d->type->close(d->data);
if (fs_descriptor_is_fugue(d)) if (fs_descriptor_is_fugue(d))
fs_fygue_sync(); fs_fygue_sync();

View file

@ -51,8 +51,7 @@ struct _fat_bpb
* *
* notes * notes
* Fugue use the special sector0 to fetch critical flash information * Fugue use the special sector0 to fetch critical flash information
* (total logical sector count and number of hidden sector). Then, based * (total logical sector count and number of hidden sector).
* on fecthed information, Fugue select an hardcoded FAT configuration
* *
* return * return
* -1 unable to load the sector0 * -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 /* _fygue_fat_configure() - configure the FAT information
* *
* notes * notes
* the objectif is to find the first FAT address and the reserved root * Find the first FAT address and the reserved root cluster (at the end
* cluster (at the end of FATs since we only have to handle FAT12/16) * of FATs since we only have to handle FAT12/16)
* *
* note that for FAT12/16 two special cluster entry are added, this is * 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 * why we have a manual offset to calculate the number of sector per

View file

@ -317,9 +317,9 @@ static int _fygue_readdir_fat(struct _fat_info *finfo)
* notes * notes
* check special first character of the FAT entry and try to determine * check special first character of the FAT entry and try to determine
* if it is: * if it is:
* 0x00 unused entry and all remaning entry will be unused * 0x00 unused entry and all remaning entry will be unused
* 0xe5 unused entry * 0xe5 unused entry
* 0x2e special "." or ".." entry * 0x2e special "." or ".." entry
* then check the dirent attribute to distinguish an VFAT entry from an * then check the dirent attribute to distinguish an VFAT entry from an
* classic FAT entry * classic FAT entry
* *
@ -376,8 +376,8 @@ static int _fygue_readdir_fat_check(struct _fat_info *finfo)
* return * return
* -2 internal error * -2 internal error
* -1 argument error * -1 argument error
* 0 success * 0 success
* 1 no directory found */ * 1 no directory found */
int fygue_fat_dir_read( int fygue_fat_dir_read(
struct fygue_fat *fat, struct fygue_fat *fat,
struct fygue_fat_dir *dir, struct fygue_fat_dir *dir,

View file

@ -9,11 +9,11 @@ int fygue_fat_file_open(
struct fygue_fat_dirent *dirent struct fygue_fat_dirent *dirent
) { ) {
memset(file, 0x00, sizeof(struct fygue_fat_file)); memset(file, 0x00, sizeof(struct fygue_fat_file));
file->attribute = dirent->attribute; file->attribute = dirent->attribute;
file->cluster_entry = dirent->cluster_id; file->cluster_entry = dirent->cluster_id;
file->size = dirent->size; file->size = dirent->size;
file->chunk = NULL; file->chunk = NULL;
file->chunk_count = 0; file->chunk_count = 0;
file->chunk_table_max_index = 0; file->chunk_table_max_index = 0;
if (fygue_fat_file_sync(fat, file, dirent->cluster_id) != 0) if (fygue_fat_file_sync(fat, file, dirent->cluster_id) != 0)
return -1; return -1;

View file

@ -34,7 +34,7 @@ static int _get_block_nb(struct fygue_fat *fat, int cluster)
// Public // Public
//--- //---
/* fygue_fat_file_stat(): directory-specific stat primitive */ /* fygue_fat_file_stat(): stat primitive */
int fygue_fat_file_stat( int fygue_fat_file_stat(
struct fygue_fat *fat, struct fygue_fat *fat,
struct fygue_fat_file *file, struct fygue_fat_file *file,
@ -44,14 +44,14 @@ int fygue_fat_file_stat(
errno = EIO; errno = EIO;
return -1; return -1;
} }
statbuf->st_dev = 0; /* not supported */ statbuf->st_dev = 0; /* not supported */
statbuf->st_ino = file->cluster_entry; statbuf->st_ino = file->cluster_entry;
statbuf->st_mode = _get_mode(file->attribute); statbuf->st_mode = _get_mode(file->attribute);
statbuf->st_nlink = 0; /* not supported */ statbuf->st_nlink = 0; /* not supported */
statbuf->st_uid = 0; /* not supported */ statbuf->st_uid = 0; /* not supported */
statbuf->st_gid = 0; /* not supported */ statbuf->st_gid = 0; /* not supported */
statbuf->st_rdev = 0; /* not supported */ statbuf->st_rdev = 0; /* not supported */
statbuf->st_size = file->size; statbuf->st_size = file->size;
statbuf->st_atime = 0; /* not supported */ statbuf->st_atime = 0; /* not supported */
statbuf->st_mtime = 0; /* not supported */ statbuf->st_mtime = 0; /* not supported */
statbuf->st_ctime = 0; /* not supported */ statbuf->st_ctime = 0; /* not supported */

View file

@ -29,15 +29,11 @@ struct _bfile_cluster_metadata
* *
* notes * notes
* - assume that fcluster is not NULL * - 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 * - to ensure that the provided bfile metadata is valid we will perform
* some test (also performed by Casio). First, ensure that the * some test (also performed by Casio).
* fcluster "kind" is valid (only 0x88, 0x22 or 0x11 are known and
* used) and then ensure that the "constant" part is also valid
* *
* todo : ensure checksum * todo : ensure checksum
* todo : ensure ecc handling (?) * todo : ensure ecc handling (?)
* todo : try P1 then P2
* *
* return * return
* -1 if the provided `fcluster` is not NULL * -1 if the provided `fcluster` is not NULL
@ -93,10 +89,10 @@ static int _fygue_flash_cluster_convert(
) { ) {
return -5; return -5;
} }
// on the fxcp400, have only some flash sector with the constants used // The fxcp400 has only some flash sectors with the constants used
// in other device. Internally, on the fxcp400, Casio only perform // by other devices. Internally, on the fxcp400, Casio only performs
// a check an CRC that is performed on the whole cluster // a CRC check that is performed on the whole target cluster
// TODO: CRC check // TODO: CRC check ?
#if 0 #if 0
if ( if (
memcmp(&(bfile_meta->constant), _constant1, 0x18) != 0 && 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 /* _fygue_flash_cluster_meta(): special metadata cluster handling
* *
* notes: * 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 * not have Bfile information. Generate a fake flash cluster with a
* special custom kind to allow quick identification */ * special custom kind to allow quick identification */
static int _fygue_flash_cluster_meta( 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 /* _fygue_flash_cluster_details(): special flash sector details handling
* *
* notes: * 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 * critical versioning information needed to rebuild Casio's flash
* mapping. * mapping.
* However, this particular flash cluster are not represented in the *
* same way between machines. For example, the G35EII that use flash * However, this particular flash cluster is not represented in the
* sector of 64ko merge the details sector inside the metadata cluster to * same way between machines. For example, the G35EII that uses a flash
* keep some space which is not the case with the FXCP400 or CG50 that * 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 * use 128ko flash sector and which the first cluster should be a details
* one type. * one type.
* *
* for 64k cluster the 0xf3c0 offset can be calculated as: * for 64k cluster the 0xf3c0 offset can be calculated as:
* 0x10000 - (8*512) = 0xf000 | sector size minus cluster size * 0x10000 - (8*512) = 0xf000 | sector size minus cluster size
* 15 * 0x40 = 0x3c0 | skip all data cluster meta info */ * 15 * 0x40 = 0x3c0 | skip all data cluster meta info */
static int _fygue_flash_cluster_details( static int _fygue_flash_cluster_details(
struct fygue_flash *flash, struct fygue_flash *flash,
struct fygue_flash_cluster *fcluster, struct fygue_flash_cluster *fcluster,
@ -199,7 +196,7 @@ static int _fygue_flash_cluster_details(
* *
* notes * notes
* flash cluster data (0x11 or 0x88) are handled in the same way between * flash cluster data (0x11 or 0x88) are handled in the same way between
* all device */ * all devices */
static int _fygue_flash_cluster_data( static int _fygue_flash_cluster_data(
struct fygue_flash *flash, struct fygue_flash *flash,
struct fygue_flash_cluster *fcluster, struct fygue_flash_cluster *fcluster,
@ -257,7 +254,7 @@ static int _fygue_flash_cluster_data(
* return * return
* -1 if the provided `fline` is not valid * -1 if the provided `fline` is not valid
* -2 if the provided `fline` have invalid Bfile metadata * -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( int fygue_flash_cluster_get(
struct fygue_flash *flash, struct fygue_flash *flash,
struct fygue_flash_cluster *fcluster, struct fygue_flash_cluster *fcluster,
@ -299,13 +296,13 @@ int fygue_flash_cluster_get(
/* fygue_flash_cluster_geometry() - get geometry information /* fygue_flash_cluster_geometry() - get geometry information
* *
* notes * notes
* generate flash cluster geometry information. Note that we handle * generate flash cluster geometry information. Note that we handle
* sector as a full 32 entry table, which differ from logical cluster ID * sectors as a full 32/16 entry table, which differs from logical
* that ignore the last entry which contain meta information * cluster ID that ignores the last entry which contains meta information.
* *
* returns * returns
* -1 if the provided address is not valid * -1 if the provided address is not valid
* 0 success */ * 0 success */
int fygue_flash_cluster_geometry( int fygue_flash_cluster_geometry(
struct fygue_flash *flash, struct fygue_flash *flash,
uintptr_t addr, uintptr_t addr,

View file

@ -15,19 +15,19 @@
/* fygue_flash_cmap_update() - update the cluster redirection map /* fygue_flash_cmap_update() - update the cluster redirection map
* *
* notes * 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" * need to rebuild the translation page between "logical cluster"
* (lcluster) and "flash cluster" (fcluster). * (lcluster) and "flash cluster" (fcluster).
* *
* Casio do not erase systematicaly each sector when they become * Casio does not erase systematically each sector when they become
* outdated, instead, they use a `age` mechanism which indicate "when" * outdated, instead, they use a `version` mechanism which indicates
* the cluster has been created a keep the more recent one * "when" the cluster has been created to keep the more recent one.
* *
* return * return
* -1 if the provided information is not valid * -1 if the provided information is not valid
* 0 if the provided lcluster exists and has not been updated * 0 if the provided lcluster exists and has not been updated
* 1 if the provided lcluster has been created * 1 if the provided lcluster has been created
* 2 if the provided lcluster exists and has been updated */ * 2 if the provided lcluster exists and has been updated */
static int fygue_flash_cmap_update( static int fygue_flash_cmap_update(
struct fygue_flash_cmap *cmap, struct fygue_flash_cmap *cmap,
struct fygue_flash_cluster *fcluster struct fygue_flash_cluster *fcluster
@ -144,20 +144,20 @@ int fygue_flash_cmap_lsector_get_addr(
/* fygue_flash_cmap_init() - initialize fcluster translation /* fygue_flash_cmap_init() - initialize fcluster translation
* *
* notes: * notes:
* Casio have its own flash handling layer that hook Fugue primitives to * Casio has its own flash handling layer that hooks Fugue primitives to
* control how/when the hardware will perform IO operation * control how/when the hardware will perform IO operations
* (read,write,erase). This because the Flash used in recent devices use * (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: * memory, you need to:
* - copy the whole page in RAM * - copy the whole page in RAM
* - perform the modification * - perform the modification
* - write the new page information * - write the new page information
* *
* So, todo * todo: docs
* *
* returns: * returns:
* -1 if the sector 0 is not found * -1 if the sector 0 is not found
* 0 success */ * 0 success */
int fygue_flash_cmap_initialize( int fygue_flash_cmap_initialize(
struct fygue_flash *flash, struct fygue_flash *flash,
struct fygue_flash_cmap *cmap struct fygue_flash_cmap *cmap

View file

@ -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) */ /* fygue_dir_write(): write directory (EISDIR) */

View file

@ -6,7 +6,7 @@
// Internals // Internals
//--- //---
/* realloc a prepare the internal table */ /* realloc and prepare the internal table */
static int _fygue_dir_open_table_realloc(struct fygue_dir *dir) static int _fygue_dir_open_table_realloc(struct fygue_dir *dir)
{ {
void *tmp; void *tmp;

View file

@ -5,7 +5,7 @@
/* fygue_dir_read(): directory read implementation /* fygue_dir_read(): directory read implementation
* *
* notes * notes
* - assume that the directory have read permission */ * - assume that the directory has read permission */
ssize_t fygue_dir_read( ssize_t fygue_dir_read(
struct fygue_fsinfo *fsinfo, struct fygue_fsinfo *fsinfo,
struct fygue_dir *dir, struct fygue_dir *dir,

View file

@ -2,7 +2,7 @@
#include <string.h> #include <string.h>
#include "fygue.h" #include "fygue.h"
/* fygue_file_close(): close directory */ /* fygue_file_close(): close file */
int fygue_file_close( int fygue_file_close(
struct fygue_fsinfo *fsinfo, struct fygue_fsinfo *fsinfo,
struct fygue_file *file struct fygue_file *file

View file

@ -1,6 +1,6 @@
#include "fygue.h" #include "fygue.h"
/* fygue_file_write(): write directory (EISDIR) */ /* fygue_file_write(): write file (EROFS) */
ssize_t fygue_file_write( ssize_t fygue_file_write(
struct fygue_fsinfo *fsinfo, struct fygue_fsinfo *fsinfo,
struct fygue_file *file, struct fygue_file *file,

View file

@ -15,7 +15,7 @@ static struct fygue_fsinfo *__fygue_fsinfo = NULL;
/* fygue_mount() - mount (if needed) and return the filesystem information /* fygue_mount() - mount (if needed) and return the filesystem information
* *
* notes * notes
* - assume that this global is const after initialisation */ * - assume that `__fygue_fsinfo` is const after initialisation */
int fygue_mount(struct fygue_fsinfo **fsinfo) int fygue_mount(struct fygue_fsinfo **fsinfo)
{ {
if (fsinfo == NULL) if (fsinfo == NULL)

View file

@ -14,8 +14,7 @@
* *
* notes * notes
* - assume that path is clean * - assume that path is clean
* - automatically mount the filesystem if needed * - automatically mount the filesystem if needed */
* - the saved pathname will not be saved in stat */
int fygue_open_resolve( int fygue_open_resolve(
char const * const path, char const * const path,
struct fygue_descriptor *desc 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)))) if ((exists < 0 && (!(flags & O_CREAT) || (flags & O_DIRECTORY))))
FYGUE_RET_ERRNO(ENOENT); 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 * it is certainly because of a creation request. We are a read-only
* file-system, so, fail */ * file-system, so, fail */
if (exists < 0) if (exists < 0)

View file

@ -10,8 +10,8 @@ int open(char const *path, int flags, ...)
mode_t mode = va_arg(args, int); mode_t mode = va_arg(args, int);
va_end(args); va_end(args);
/* Standard open() use Fugue filesystem if a write operation /* Standard open() uses Fugue filesystem if a write operation
* is requested, otherwise use the Fygue filesystem */ * is requested, otherwise uses the Fygue filesystem */
int rc = -1; int rc = -1;
if ((flags & O_WRONLY) || (flags & O_RDWR)) { if ((flags & O_WRONLY) || (flags & O_RDWR)) {
rc = fugue_open(path, flags, mode); rc = fugue_open(path, flags, mode);

View file

@ -3,8 +3,8 @@
int stat(char const * restrict path, struct stat * restrict statbuf) int stat(char const * restrict path, struct stat * restrict statbuf)
{ {
/* Standard stat() is also provided by Fugue, but rely on Casio's /* Standard stat() is also provided by Fugue, but relies on Casio's
* syscall which do not provide all of the information and request * syscall which does not provide all of the information and requests
* a world-switch (internally) to works */ * a world-switch (internally) to work */
return fygue_stat(path, statbuf); return fygue_stat(path, statbuf);
} }

View file

@ -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 */ /* No write function: discard the contents but show no error */
if(d->type->write == NULL) if(d->type->write == NULL)
return 0; return 0;
/* A special synchronisation must be performed to ensure that all /* A special synchronization must be performed to ensure that all
* Fygue's descriptor meta information are valid */ * Fygue's descriptor meta information is valid */
size = d->type->write(d->data, buf, size); size = d->type->write(d->data, buf, size);
if (fs_descriptor_is_fugue(d)) if (fs_descriptor_is_fugue(d))
fs_fygue_sync(); fs_fygue_sync();