mirror of
https://git.planet-casio.com/Lephenixnoir/gint.git
synced 2025-05-18 23:39:17 +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;
|
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();
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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,13 +138,14 @@ 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.
|
||||||
*
|
*
|
||||||
|
@ -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,
|
||||||
|
@ -300,8 +297,8 @@ int fygue_flash_cluster_get(
|
||||||
*
|
*
|
||||||
* 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
|
||||||
|
|
|
@ -15,13 +15,13 @@
|
||||||
/* 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
|
||||||
|
@ -144,16 +144,16 @@ 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
|
||||||
|
|
|
@ -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) */
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
|
Loading…
Add table
Reference in a new issue