diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-12-15 00:18:32 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-12-15 00:18:32 +0000 |
commit | a4155eb61d984728e938cd4b1ab0aca7b9513d78 (patch) | |
tree | 13835bea2d34fe02e0b620abf761396f330dc860 /nuttx/fs | |
parent | d7d4a0d765d12cc152c62a37b490702c39d76447 (diff) | |
download | px4-nuttx-a4155eb61d984728e938cd4b1ab0aca7b9513d78.tar.gz px4-nuttx-a4155eb61d984728e938cd4b1ab0aca7b9513d78.tar.bz2 px4-nuttx-a4155eb61d984728e938cd4b1ab0aca7b9513d78.zip |
Switching to C99 stdint/stdbool.h types
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2341 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/fs')
46 files changed, 422 insertions, 392 deletions
diff --git a/nuttx/fs/fat/fs_configfat.c b/nuttx/fs/fat/fs_configfat.c index 5177da5b6..17a3e528d 100644 --- a/nuttx/fs/fat/fs_configfat.c +++ b/nuttx/fs/fat/fs_configfat.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/fat/fs_configfat.c * - * Copyright (C) 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -38,8 +38,8 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> +#include <stdint.h> #include <string.h> #include <debug.h> #include <errno.h> @@ -53,7 +53,7 @@ #include "fs_mkfatfs.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #define NDX12 0 @@ -77,10 +77,10 @@ struct fat_config_s { - uint32 fc_navailsects; /* The number of available sectors */ - uint32 fc_nfatsects; /* The number of sectors in one FAT */ - uint32 fc_nclusters; /* The number of clusters in the filesystem */ - uint32 fc_rsvdseccount; /* The number of reserved sectors */ + uint32_t fc_navailsects; /* The number of available sectors */ + uint32_t fc_nfatsects; /* The number of sectors in one FAT */ + uint32_t fc_nclusters; /* The number of clusters in the filesystem */ + uint32_t fc_rsvdseccount; /* The number of reserved sectors */ }; /**************************************************************************** @@ -92,7 +92,7 @@ struct fat_config_s * offset 3. */ -static ubyte g_bootcodeblob[] = +static uint8_t g_bootcodeblob[] = { 0x0e, 0x1f, 0xbe, 0x00, 0x7c, 0xac, 0x22, 0xc0, 0x74, 0x0b, 0x56, 0xb4, 0x0e, 0xbb, 0x07, 0x00, 0xcd, 0x10, 0x5e, 0xeb, 0xf0, 0x32, @@ -132,16 +132,16 @@ static ubyte g_bootcodeblob[] = * >0: The size of one FAT in sectors. * ****************************************************************************/ -static inline uint32 +static inline uint32_t mkfatfs_nfatsect12(FAR struct fat_format_s *fmt, FAR struct fat_var_s *var, - uint32 navailsects) + uint32_t navailsects) { #ifdef CONFIG_HAVE_LONG_LONG uint64 denom; uint64 numer; #else - uint32 denom; - uint32 numer; + uint32_t denom; + uint32_t numer; #endif /* For FAT12, the cluster number is held in a 12-bit number or 1.5 bytes per @@ -161,7 +161,7 @@ mkfatfs_nfatsect12(FAR struct fat_format_s *fmt, FAR struct fat_var_s *var, * nfatsects = (3 * navailsects + 6 * clustersize) / * (3 * nfats + 2 * sectorsize * clustersize) * - * The numerator would overflow uint32 if: + * The numerator would overflow uint32_t if: * * 3 * navailsects + 6 * clustersize > 0xffffffff * @@ -179,7 +179,7 @@ mkfatfs_nfatsect12(FAR struct fat_format_s *fmt, FAR struct fat_var_s *var, + (var->fv_sectorsize << (fmt->ff_clustshift + 1)); numer = (navailsects << 1) + navailsects + (1 << (fmt->ff_clustshift + 2)) + (1 << (fmt->ff_clustshift + 1)); - return (uint32)((numer + denom - 1) / denom); + return (uint32_t)((numer + denom - 1) / denom); #ifndef CONFIG_HAVE_LONG_LONG } @@ -209,16 +209,16 @@ mkfatfs_nfatsect12(FAR struct fat_format_s *fmt, FAR struct fat_var_s *var, * The size of one FAT in sectors. * ****************************************************************************/ -static inline uint32 +static inline uint32_t mkfatfs_nfatsect16(FAR struct fat_format_s *fmt, FAR struct fat_var_s *var, - uint32 navailsects) + uint32_t navailsects) { #ifdef CONFIG_HAVE_LONG_LONG uint64 denom; uint64 numer; #else - uint32 denom; - uint32 numer; + uint32_t denom; + uint32_t numer; #endif /* For FAT16, the cluster number is held in a 16-bit number or 2 bytes per @@ -253,7 +253,7 @@ mkfatfs_nfatsect16(FAR struct fat_format_s *fmt, FAR struct fat_var_s *var, denom = fmt->ff_nfats + (var->fv_sectorsize << (fmt->ff_clustshift - 1)); numer = navailsects + (1 << (fmt->ff_clustshift + 1)); } - return (uint32)((numer + denom - 1) / denom); + return (uint32_t)((numer + denom - 1) / denom); } /**************************************************************************** @@ -275,16 +275,16 @@ mkfatfs_nfatsect16(FAR struct fat_format_s *fmt, FAR struct fat_var_s *var, * The size of one FAT in sectors. * ****************************************************************************/ -static inline uint32 +static inline uint32_t mkfatfs_nfatsect32(FAR struct fat_format_s *fmt, FAR struct fat_var_s *var, - uint32 navailsects) + uint32_t navailsects) { #ifdef CONFIG_HAVE_LONG_LONG uint64 denom; uint64 numer; #else - uint32 denom; - uint32 numer; + uint32_t denom; + uint32_t numer; #endif /* For FAT32, the cluster number is held in a 32-bit number or 4 bytes per @@ -324,7 +324,7 @@ mkfatfs_nfatsect32(FAR struct fat_format_s *fmt, FAR struct fat_var_s *var, denom = fmt->ff_nfats + (var->fv_sectorsize << (fmt->ff_clustshift - 2)); numer = navailsects + (1 << (fmt->ff_clustshift + 1)) + (1 << fmt->ff_clustshift); } - return (uint32)((numer + denom - 1) / denom); + return (uint32_t)((numer + denom - 1) / denom); } /**************************************************************************** @@ -344,10 +344,10 @@ mkfatfs_nfatsect32(FAR struct fat_format_s *fmt, FAR struct fat_var_s *var, * size is the returned value. * ****************************************************************************/ -static inline ubyte +static inline uint8_t mkfatfs_clustersearchlimits(FAR struct fat_format_s *fmt, FAR struct fat_var_s *var) { - ubyte mxclustshift; + uint8_t mxclustshift; /* Did the caller already pick the cluster size? If not, the clustshift value * will be 0xff @@ -427,7 +427,7 @@ static inline int mkfatfs_tryfat12(FAR struct fat_format_s *fmt, FAR struct fat_var_s *var, FAR struct fat_config_s *config) { - uint32 maxnclusters; + uint32_t maxnclusters; /* Calculate the number sectors in one FAT required to access all of the * available sectors. @@ -493,7 +493,7 @@ static inline int mkfatfs_tryfat16(FAR struct fat_format_s *fmt, FAR struct fat_var_s *var, FAR struct fat_config_s *config) { - uint32 maxnclusters; + uint32_t maxnclusters; /* Calculate the number sectors in one FAT required to access all of the * available sectors. @@ -564,7 +564,7 @@ static inline int mkfatfs_tryfat32(FAR struct fat_format_s *fmt, FAR struct fat_var_s *var, FAR struct fat_config_s *config) { - uint32 maxnclusters; + uint32_t maxnclusters; /* Calculate the number sectors in one FAT required to access all of the * available sectors. @@ -659,7 +659,7 @@ static inline int mkfatfs_clustersearch(FAR struct fat_format_s *fmt, FAR struct fat_var_s *var) { struct fat_config_s fatconfig[3]; - ubyte mxclustshift; + uint8_t mxclustshift; memset(fatconfig, 0, 3*sizeof(struct fat_config_s)); diff --git a/nuttx/fs/fat/fs_fat32.c b/nuttx/fs/fat/fs_fat32.c index a28d57a4e..b5917d1d5 100644 --- a/nuttx/fs/fat/fs_fat32.c +++ b/nuttx/fs/fat/fs_fat32.c @@ -48,6 +48,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <sys/statfs.h> + #include <stdlib.h> #include <unistd.h> #include <string.h> @@ -196,7 +197,7 @@ static int fat_open(FAR struct file *filep, const char *relpath, if (ret == OK) { - boolean readonly; + bool readonly; /* The name exists -- but is it a file or a directory? */ @@ -293,7 +294,7 @@ static int fat_open(FAR struct file *filep, const char *relpath, /* Create a file buffer to support partial sector accesses */ - ff->ff_buffer = (ubyte*)malloc(fs->fs_hwsectorsize); + ff->ff_buffer = (uint8_t*)malloc(fs->fs_hwsectorsize); if (!ff->ff_buffer) { ret = -ENOMEM; @@ -302,7 +303,7 @@ static int fat_open(FAR struct file *filep, const char *relpath, /* Initialize the file private data (only need to initialize non-zero elements) */ - ff->ff_open = TRUE; + ff->ff_open = true; ff->ff_oflags = oflags; /* Save information that can be used later to recover the directory entry */ @@ -313,7 +314,7 @@ static int fat_open(FAR struct file *filep, const char *relpath, /* File cluster/size info */ ff->ff_startcluster = - ((uint32)DIR_GETFSTCLUSTHI(dirinfo.fd_entry) << 16) | + ((uint32_t)DIR_GETFSTCLUSTHI(dirinfo.fd_entry) << 16) | DIR_GETFSTCLUSTLO(dirinfo.fd_entry); ff->ff_currentcluster = ff->ff_startcluster; @@ -423,8 +424,8 @@ static ssize_t fat_read(FAR struct file *filep, char *buffer, size_t buflen) unsigned int readsize; unsigned int nsectors; size_t bytesleft; - sint32 cluster; - ubyte *userbuffer = (ubyte*)buffer; + int32_t cluster; + uint8_t *userbuffer = (uint8_t*)buffer; int sectorindex; int ret; @@ -618,11 +619,11 @@ static ssize_t fat_write(FAR struct file *filep, const char *buffer, struct inode *inode; struct fat_mountpt_s *fs; struct fat_file_s *ff; - sint32 cluster; + int32_t cluster; unsigned int byteswritten; unsigned int writesize; unsigned int nsectors; - ubyte *userbuffer = (ubyte*)buffer; + uint8_t *userbuffer = (uint8_t*)buffer; int sectorindex; int ret; @@ -856,7 +857,7 @@ static off_t fat_seek(FAR struct file *filep, off_t offset, int whence) struct inode *inode; struct fat_mountpt_s *fs; struct fat_file_s *ff; - sint32 cluster; + int32_t cluster; ssize_t position; unsigned int clustersize; int ret; @@ -1125,8 +1126,8 @@ static int fat_sync(FAR struct file *filep) struct inode *inode; struct fat_mountpt_s *fs; struct fat_file_s *ff; - uint32 wrttime; - ubyte *direntry; + uint32_t wrttime; + uint8_t *direntry; int ret; /* Sanity checks */ @@ -1201,7 +1202,7 @@ static int fat_sync(FAR struct file *filep) * appropriate. */ - fs->fs_dirty = TRUE; + fs->fs_dirty = true; ret = fat_updatefsinfo(fs); } @@ -1275,7 +1276,7 @@ static int fat_opendir(struct inode *mountpt, const char *relpath, struct intern /* The entry is a directory */ dir->u.fat.fd_startcluster = - ((uint32)DIR_GETFSTCLUSTHI(dirinfo.fd_entry) << 16) | + ((uint32_t)DIR_GETFSTCLUSTHI(dirinfo.fd_entry) << 16) | DIR_GETFSTCLUSTLO(dirinfo.fd_entry); dir->u.fat.fd_currcluster = dir->u.fat.fd_startcluster; dir->u.fat.fd_currsector = fat_cluster2sector(fs, dir->u.fat.fd_currcluster); @@ -1301,9 +1302,9 @@ static int fat_readdir(struct inode *mountpt, struct internal_dir_s *dir) { struct fat_mountpt_s *fs; unsigned int dirindex; - ubyte *direntry; - ubyte ch; - ubyte attribute; + uint8_t *direntry; + uint8_t ch; + uint8_t attribute; int ret = OK; /* Sanity checks */ @@ -1507,7 +1508,7 @@ static int fat_bind(FAR struct inode *blkdriver, const void *data, * by this block driver. */ - ret = fat_mount(fs, TRUE); + ret = fat_mount(fs, true); if (ret != 0) { sem_destroy(&fs->fs_sem); @@ -1678,7 +1679,7 @@ static int fat_unlink(struct inode *mountpt, const char *relpath) /* Remove the file */ - ret = fat_remove(fs, relpath, FALSE); + ret = fat_remove(fs, relpath, false); } fat_semgive(fs); @@ -1696,13 +1697,13 @@ static int fat_mkdir(struct inode *mountpt, const char *relpath, mode_t mode) { struct fat_mountpt_s *fs; struct fat_dirinfo_s dirinfo; - ubyte *direntry; - ubyte *direntry2; + uint8_t *direntry; + uint8_t *direntry2; size_t parentsector; ssize_t dirsector; - sint32 dircluster; - uint32 parentcluster; - uint32 crtime; + int32_t dircluster; + uint32_t parentcluster; + uint32_t crtime; unsigned int i; int ret; @@ -1849,7 +1850,7 @@ static int fat_mkdir(struct inode *mountpt, const char *relpath, mode_t mode) * the parentsector */ - fs->fs_dirty = TRUE; + fs->fs_dirty = true; ret = fat_fscacheread(fs, parentsector); if (ret < 0) { @@ -1881,7 +1882,7 @@ static int fat_mkdir(struct inode *mountpt, const char *relpath, mode_t mode) /* Now update the FAT32 FSINFO sector */ - fs->fs_dirty = TRUE; + fs->fs_dirty = true; ret = fat_updatefsinfo(fs); if (ret < 0) { @@ -1933,7 +1934,7 @@ int fat_rmdir(struct inode *mountpt, const char *relpath) /* Remove the directory */ - ret = fat_remove(fs, relpath, TRUE); + ret = fat_remove(fs, relpath, true); } fat_semgive(fs); @@ -1953,9 +1954,9 @@ int fat_rename(struct inode *mountpt, const char *oldrelpath, struct fat_mountpt_s *fs; struct fat_dirinfo_s dirinfo; size_t oldsector; - ubyte *olddirentry; - ubyte *newdirentry; - ubyte dirstate[32-11]; + uint8_t *olddirentry; + uint8_t *newdirentry; + uint8_t dirstate[32-11]; int ret; /* Sanity checks */ @@ -2045,7 +2046,7 @@ int fat_rename(struct inode *mountpt, const char *oldrelpath, #else DIR_PUTNTRES(newdirentry, 0); #endif - fs->fs_dirty = TRUE; + fs->fs_dirty = true; /* Now flush the new directory entry to disk and read the sector * containing the old directory entry. @@ -2060,7 +2061,7 @@ int fat_rename(struct inode *mountpt, const char *oldrelpath, /* Remove the old entry */ olddirentry[DIR_NAME] = DIR0_EMPTY; - fs->fs_dirty = TRUE; + fs->fs_dirty = true; /* Write the old entry to disk and update FSINFO if necessary */ @@ -2089,10 +2090,10 @@ static int fat_stat(struct inode *mountpt, const char *relpath, struct stat *buf { struct fat_mountpt_s *fs; struct fat_dirinfo_s dirinfo; - uint16 date; - uint16 date2; - uint16 time; - ubyte attribute; + uint16_t date; + uint16_t date2; + uint16_t time; + uint8_t attribute; int ret; /* Sanity checks */ diff --git a/nuttx/fs/fat/fs_fat32.h b/nuttx/fs/fat/fs_fat32.h index 5bced51bc..ff3bda433 100644 --- a/nuttx/fs/fat/fs_fat32.h +++ b/nuttx/fs/fat/fs_fat32.h @@ -1,7 +1,7 @@ /**************************************************************************** * fs/fat/fs_fat32.h * - * Copyright (C) 2007, 200, 2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,10 @@ ****************************************************************************/ #include <nuttx/config.h> + #include <sys/types.h> +#include <stdint.h> +#include <stdbool.h> #include <semaphore.h> #include <time.h> @@ -247,17 +250,17 @@ /**************************************************************************** * Access to data in raw sector data */ -#define UBYTE_VAL(p,o) (((ubyte*)(p))[o]) +#define UBYTE_VAL(p,o) (((uint8_t*)(p))[o]) #define UBYTE_PTR(p,o) &UBYTE_VAL(p,o) -#define UBYTE_PUT(p,o,v) (UBYTE_VAL(p,o)=(ubyte)(v)) +#define UBYTE_PUT(p,o,v) (UBYTE_VAL(p,o)=(uint8_t)(v)) -#define UINT16_PTR(p,o) ((uint16*)UBYTE_PTR(p,o)) +#define UINT16_PTR(p,o) ((uint16_t*)UBYTE_PTR(p,o)) #define UINT16_VAL(p,o) (*UINT16_PTR(p,o)) -#define UINT16_PUT(p,o,v) (UINT16_VAL(p,o)=(uint16)(v)) +#define UINT16_PUT(p,o,v) (UINT16_VAL(p,o)=(uint16_t)(v)) -#define UINT32_PTR(p,o) ((uint32*)UBYTE_PTR(p,o)) +#define UINT32_PTR(p,o) ((uint32_t*)UBYTE_PTR(p,o)) #define UINT32_VAL(p,o) (*UINT32_PTR(p,o)) -#define UINT32_PUT(p,o,v) (UINT32_VAL(p,o)=(uint32)(v)) +#define UINT32_PUT(p,o,v) (UINT32_VAL(p,o)=(uint32_t)(v)) /* Regardless of the endian-ness of the target or alignment of the data, no * special operations are required for byte, string or byte array accesses. @@ -518,20 +521,20 @@ struct fat_mountpt_s size_t fs_database; /* Logical block of start data sectors */ size_t fs_fsinfo; /* MBR: Sector number of FSINFO sector */ size_t fs_currentsector; /* The sector number buffered in fs_buffer */ - uint32 fs_nclusters; /* Maximum number of data clusters */ - uint32 fs_nfatsects; /* MBR: Count of sectors occupied by one fat */ - uint32 fs_fattotsec; /* MBR: Total count of sectors on the volume */ - uint32 fs_fsifreecount; /* FSI: Last free cluster count on volume */ - uint32 fs_fsinextfree; /* FSI: Cluster number of 1st free cluster */ - uint16 fs_fatresvdseccount; /* MBR: The total number of reserved sectors */ - uint16 fs_rootentcnt; /* MBR: Count of 32-bit root directory entries */ - boolean fs_mounted; /* TRUE: The file system is ready */ - boolean fs_dirty; /* TRUE: fs_buffer is dirty */ - boolean fs_fsidirty; /* TRUE: FSINFO sector must be written to disk */ - ubyte fs_type; /* FSTYPE_FAT12, FSTYPE_FAT16, or FSTYPE_FAT32 */ - ubyte fs_fatnumfats; /* MBR: Number of FATs (probably 2) */ - ubyte fs_fatsecperclus; /* MBR: Sectors per allocation unit: 2**n, n=0..7 */ - ubyte *fs_buffer; /* This is an allocated buffer to hold one sector + uint32_t fs_nclusters; /* Maximum number of data clusters */ + uint32_t fs_nfatsects; /* MBR: Count of sectors occupied by one fat */ + uint32_t fs_fattotsec; /* MBR: Total count of sectors on the volume */ + uint32_t fs_fsifreecount; /* FSI: Last free cluster count on volume */ + uint32_t fs_fsinextfree; /* FSI: Cluster number of 1st free cluster */ + uint16_t fs_fatresvdseccount; /* MBR: The total number of reserved sectors */ + uint16_t fs_rootentcnt; /* MBR: Count of 32-bit root directory entries */ + bool fs_mounted; /* true: The file system is ready */ + bool fs_dirty; /* true: fs_buffer is dirty */ + bool fs_fsidirty; /* true: FSINFO sector must be written to disk */ + uint8_t fs_type; /* FSTYPE_FAT12, FSTYPE_FAT16, or FSTYPE_FAT32 */ + uint8_t fs_fatnumfats; /* MBR: Number of FATs (probably 2) */ + uint8_t fs_fatsecperclus; /* MBR: Sectors per allocation unit: 2**n, n=0..7 */ + uint8_t *fs_buffer; /* This is an allocated buffer to hold one sector * from the device */ }; @@ -543,30 +546,30 @@ struct fat_mountpt_s struct fat_file_s { struct fat_file_s *ff_next; /* Retained in a singly linked list */ - boolean ff_open; /* TRUE: The file is (still) open */ - ubyte ff_bflags; /* The file buffer flags */ - ubyte ff_oflags; /* Flags provided when file was opened */ - ubyte ff_sectorsincluster; /* Sectors remaining in cluster */ - uint16 ff_dirindex; /* Index into ff_dirsector to directory entry */ - uint32 ff_currentcluster; /* Current cluster being accessed */ + bool ff_open; /* true: The file is (still) open */ + uint8_t ff_bflags; /* The file buffer flags */ + uint8_t ff_oflags; /* Flags provided when file was opened */ + uint8_t ff_sectorsincluster; /* Sectors remaining in cluster */ + uint16_t ff_dirindex; /* Index into ff_dirsector to directory entry */ + uint32_t ff_currentcluster; /* Current cluster being accessed */ size_t ff_dirsector; /* Sector containing the directory entry */ off_t ff_size; /* Size of the file in bytes */ size_t ff_startcluster; /* Start cluster of file on media */ size_t ff_currentsector; /* Current sector being operated on */ size_t ff_cachesector; /* Current sector in the file buffer */ - ubyte *ff_buffer; /* File buffer (for partial sector accesses) */ + uint8_t *ff_buffer; /* File buffer (for partial sector accesses) */ }; /* This structure is used internally for describing directory entries */ struct fat_dirinfo_s { - ubyte fd_name[8+3]; /* Filename -- directory format*/ + uint8_t fd_name[8+3]; /* Filename -- directory format*/ #ifdef CONFIG_FAT_LCNAMES - ubyte fd_ntflags; /* NTRes lower case flags */ + uint8_t fd_ntflags; /* NTRes lower case flags */ #endif struct fs_fatdir_s dir; /* Used with opendir, readdir, etc. */ - ubyte *fd_entry; /* A pointer to the raw 32-byte entry */ + uint8_t *fd_entry; /* A pointer to the raw 32-byte entry */ }; /**************************************************************************** @@ -587,10 +590,10 @@ extern "C" { /* Utitilies to handle unaligned or byte swapped accesses */ -EXTERN uint16 fat_getuint16(ubyte *ptr); -EXTERN uint32 fat_getuint32(ubyte *ptr); -EXTERN void fat_putuint16(ubyte *ptr, uint16 value16); -EXTERN void fat_putuint32(ubyte *ptr, uint32 value32); +EXTERN uint16_t fat_getuint16(uint8_t *ptr); +EXTERN uint32_t fat_getuint32(uint8_t *ptr); +EXTERN void fat_putuint16(uint8_t *ptr, uint16_t value16); +EXTERN void fat_putuint32(uint8_t *ptr, uint32_t value32); /* Manage the per-mount semaphore that protects access to shared resources */ @@ -599,29 +602,29 @@ EXTERN void fat_semgive(struct fat_mountpt_s *fs); /* Get the current time for FAT creation and write times */ -EXTERN uint32 fat_systime2fattime(void); -EXTERN time_t fat_fattime2systime(uint16 time, uint16 date); +EXTERN uint32_t fat_systime2fattime(void); +EXTERN time_t fat_fattime2systime(uint16_t time, uint16_t date); /* Handle hardware interactions for mounting */ -EXTERN int fat_mount(struct fat_mountpt_s *fs, boolean writeable); +EXTERN int fat_mount(struct fat_mountpt_s *fs, bool writeable); EXTERN int fat_checkmount(struct fat_mountpt_s *fs); /* low-level hardware access */ -EXTERN int fat_hwread(struct fat_mountpt_s *fs, ubyte *buffer, +EXTERN int fat_hwread(struct fat_mountpt_s *fs, uint8_t *buffer, size_t sector, unsigned int nsectors); -EXTERN int fat_hwwrite(struct fat_mountpt_s *fs, ubyte *buffer, +EXTERN int fat_hwwrite(struct fat_mountpt_s *fs, uint8_t *buffer, size_t sector, unsigned int nsectors); /* Cluster / cluster chain access helpers */ -EXTERN ssize_t fat_cluster2sector(struct fat_mountpt_s *fs, uint32 cluster); -EXTERN ssize_t fat_getcluster(struct fat_mountpt_s *fs, uint32 clusterno); -EXTERN int fat_putcluster(struct fat_mountpt_s *fs, uint32 clusterno, +EXTERN ssize_t fat_cluster2sector(struct fat_mountpt_s *fs, uint32_t cluster); +EXTERN ssize_t fat_getcluster(struct fat_mountpt_s *fs, uint32_t clusterno); +EXTERN int fat_putcluster(struct fat_mountpt_s *fs, uint32_t clusterno, size_t startsector); -EXTERN int fat_removechain(struct fat_mountpt_s *fs, uint32 cluster); -EXTERN sint32 fat_extendchain(struct fat_mountpt_s *fs, uint32 cluster); +EXTERN int fat_removechain(struct fat_mountpt_s *fs, uint32_t cluster); +EXTERN int32_t fat_extendchain(struct fat_mountpt_s *fs, uint32_t cluster); #define fat_createchain(fs) fat_extendchain(fs, 0) @@ -632,13 +635,13 @@ EXTERN int fat_finddirentry(struct fat_mountpt_s *fs, struct fat_dirinfo_s *d const char *path); EXTERN int fat_allocatedirentry(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo); -EXTERN int fat_dirname2path(char *path, ubyte *direntry); +EXTERN int fat_dirname2path(char *path, uint8_t *direntry); /* File creation and removal helpers */ EXTERN int fat_dirtruncate(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo); EXTERN int fat_dircreate(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo); -EXTERN int fat_remove(struct fat_mountpt_s *fs, const char *relpath, boolean directory); +EXTERN int fat_remove(struct fat_mountpt_s *fs, const char *relpath, bool directory); /* Mountpoint and file buffer cache (for partial sector accesses) */ diff --git a/nuttx/fs/fat/fs_fat32attrib.c b/nuttx/fs/fat/fs_fat32attrib.c index dee01102c..77495d5e0 100644 --- a/nuttx/fs/fat/fs_fat32attrib.c +++ b/nuttx/fs/fat/fs_fat32attrib.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/fat/fs_fat32attrib.c * - * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -38,7 +38,8 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> + +#include <stdint.h> #include <errno.h> #include <nuttx/fs.h> @@ -61,10 +62,10 @@ static int fat_attrib(const char *path, fat_attrib_t *retattrib, struct fat_mountpt_s *fs; struct fat_dirinfo_s dirinfo; FAR struct inode *inode; - const char *relpath = NULL; - ubyte oldattributes; - ubyte newattributes; - int ret; + const char *relpath = NULL; + uint8_t oldattributes; + uint8_t newattributes; + int ret; /* Get an inode for this file */ @@ -133,7 +134,7 @@ static int fat_attrib(const char *path, fat_attrib_t *retattrib, if (newattributes != oldattributes) { DIR_PUTATTRIBUTES(dirinfo.fd_entry, newattributes); - fs->fs_dirty = TRUE; + fs->fs_dirty = true; ret = fat_updatefsinfo(fs); if (ret != OK) { diff --git a/nuttx/fs/fat/fs_fat32util.c b/nuttx/fs/fat/fs_fat32util.c index b7ce20ec1..43a351faa 100644 --- a/nuttx/fs/fat/fs_fat32util.c +++ b/nuttx/fs/fat/fs_fat32util.c @@ -1,7 +1,7 @@ /**************************************************************************** - * fs_fat32util.c + * fs/fat/fs_fat32util.c * - * Copyright (C) 2007, 2008, 2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * References: @@ -46,6 +46,8 @@ #include <nuttx/config.h> #include <sys/types.h> +#include <stdint.h> +#include <stdbool.h> #include <stdlib.h> #include <string.h> #include <ctype.h> @@ -123,7 +125,7 @@ static inline int fat_path2dirname(const char **path, struct fat_dirinfo_s *diri #endif const char *node = *path; int endndx; - ubyte ch; + uint8_t ch; int ndx = 0; /* Initialized the name with all spaces */ @@ -289,10 +291,10 @@ static int fat_checkfsinfo(struct fat_mountpt_s *fs) static int fat_checkbootrecord(struct fat_mountpt_s *fs) { - uint32 ndatasectors; - uint32 ntotalfatsects; - uint16 rootdirsectors = 0; - boolean notfat32 = FALSE; + uint32_t ndatasectors; + uint32_t ntotalfatsects; + uint16_t rootdirsectors = 0; + bool notfat32 = false; /* Verify the MBR signature at offset 510 in the sector (true even * if the sector size is greater than 512. All FAT file systems have @@ -320,7 +322,7 @@ static int fat_checkbootrecord(struct fat_mountpt_s *fs) fs->fs_rootentcnt = MBR_GETROOTENTCNT(fs->fs_buffer); if (fs->fs_rootentcnt != 0) { - notfat32 = TRUE; /* Must be zero for FAT32 */ + notfat32 = true; /* Must be zero for FAT32 */ rootdirsectors = (32 * fs->fs_rootentcnt + fs->fs_hwsectorsize - 1) / fs->fs_hwsectorsize; } @@ -329,7 +331,7 @@ static int fat_checkbootrecord(struct fat_mountpt_s *fs) fs->fs_nfatsects = MBR_GETFATSZ16(fs->fs_buffer); /* Should be zero */ if (fs->fs_nfatsects) { - notfat32 = TRUE; /* Must be zero for FAT32 */ + notfat32 = true; /* Must be zero for FAT32 */ } else { @@ -346,7 +348,7 @@ static int fat_checkbootrecord(struct fat_mountpt_s *fs) fs->fs_fattotsec = MBR_GETTOTSEC16(fs->fs_buffer); /* Should be zero */ if (fs->fs_fattotsec) { - notfat32 = TRUE; /* Must be zero for FAT32 */ + notfat32 = true; /* Must be zero for FAT32 */ } else { @@ -438,16 +440,16 @@ static int fat_checkbootrecord(struct fat_mountpt_s *fs) * Name: fat_getuint16 ****************************************************************************/ -uint16 fat_getuint16(ubyte *ptr) +uint16_t fat_getuint16(uint8_t *ptr) { #ifdef CONFIG_ENDIAN_BIG /* The bytes always have to be swapped if the target is big-endian */ - return ((uint16)ptr[0] << 8) | ptr[1]; + return ((uint16_t)ptr[0] << 8) | ptr[1]; #else /* Byte-by-byte transfer is still necessary if the address is un-aligned */ - return ((uint16)ptr[1] << 8) | ptr[0]; + return ((uint16_t)ptr[1] << 8) | ptr[0]; #endif } @@ -455,16 +457,16 @@ uint16 fat_getuint16(ubyte *ptr) * Name: fat_getuint32 ****************************************************************************/ -uint32 fat_getuint32(ubyte *ptr) +uint32_t fat_getuint32(uint8_t *ptr) { #ifdef CONFIG_ENDIAN_BIG /* The bytes always have to be swapped if the target is big-endian */ - return ((uint32)fat_getuint16(&ptr[0]) << 16) | fat_getuint16(&ptr[2]); + return ((uint32_t)fat_getuint16(&ptr[0]) << 16) | fat_getuint16(&ptr[2]); #else /* Byte-by-byte transfer is still necessary if the address is un-aligned */ - return ((uint32)fat_getuint16(&ptr[2]) << 16) | fat_getuint16(&ptr[0]); + return ((uint32_t)fat_getuint16(&ptr[2]) << 16) | fat_getuint16(&ptr[0]); #endif } @@ -472,9 +474,9 @@ uint32 fat_getuint32(ubyte *ptr) * Name: fat_putuint16 ****************************************************************************/ -void fat_putuint16(ubyte *ptr, uint16 value16) +void fat_putuint16(uint8_t *ptr, uint16_t value16) { - ubyte *val = (ubyte*)&value16; + uint8_t *val = (uint8_t*)&value16; #ifdef CONFIG_ENDIAN_BIG /* The bytes always have to be swapped if the target is big-endian */ @@ -492,9 +494,9 @@ void fat_putuint16(ubyte *ptr, uint16 value16) * Name: fat_putuint32 ****************************************************************************/ -void fat_putuint32(ubyte *ptr, uint32 value32) +void fat_putuint32(uint8_t *ptr, uint32_t value32) { - uint16 *val = (uint16*)&value32; + uint16_t *val = (uint16_t*)&value32; #ifdef CONFIG_ENDIAN_BIG /* The bytes always have to be swapped if the target is big-endian */ @@ -552,7 +554,7 @@ void fat_semgive(struct fat_mountpt_s *fs) * ****************************************************************************/ -uint32 fat_systime2fattime(void) +uint32_t fat_systime2fattime(void) { #ifdef CONFIG_CPP_HAVE_WARNING # warning "Time not implemented" @@ -576,7 +578,7 @@ uint32 fat_systime2fattime(void) * ****************************************************************************/ -time_t fat_fattime2systime(uint16 fattime, uint16 fatdate) +time_t fat_fattime2systime(uint16_t fattime, uint16_t fatdate) { #ifdef CONFIG_CPP_HAVE_WARNING # warning "Time not implemented" @@ -595,7 +597,7 @@ time_t fat_fattime2systime(uint16 fattime, uint16 fatdate) * ****************************************************************************/ -int fat_mount(struct fat_mountpt_s *fs, boolean writeable) +int fat_mount(struct fat_mountpt_s *fs, bool writeable) { FAR struct inode *inode; struct geometry geo; @@ -603,7 +605,7 @@ int fat_mount(struct fat_mountpt_s *fs, boolean writeable) /* Assume that the mount is successful */ - fs->fs_mounted = TRUE; + fs->fs_mounted = true; /* Check if there is media available */ @@ -630,7 +632,7 @@ int fat_mount(struct fat_mountpt_s *fs, boolean writeable) /* Allocate a buffer to hold one hardware sector */ - fs->fs_buffer = (ubyte*)malloc(fs->fs_hwsectorsize); + fs->fs_buffer = (uint8_t*)malloc(fs->fs_hwsectorsize); if (!fs->fs_buffer) { ret = -ENOMEM; @@ -731,7 +733,7 @@ int fat_mount(struct fat_mountpt_s *fs, boolean writeable) free(fs->fs_buffer); fs->fs_buffer = 0; errout: - fs->fs_mounted = FALSE; + fs->fs_mounted = false; return ret; } @@ -746,7 +748,7 @@ int fat_mount(struct fat_mountpt_s *fs, boolean writeable) int fat_checkmount(struct fat_mountpt_s *fs) { - /* If the fs_mounted flag is FALSE, then we have already handled the loss + /* If the fs_mounted flag is false, then we have already handled the loss * of the mount. */ @@ -774,13 +776,13 @@ int fat_checkmount(struct fat_mountpt_s *fs) /* If we get here, the mount is NOT healthy */ - fs->fs_mounted = FALSE; + fs->fs_mounted = false; /* Make sure that this is flagged in every opened file */ for (file = fs->fs_head; file; file = file->ff_next) { - file->ff_open = FALSE; + file->ff_open = false; } } return -ENODEV; @@ -793,7 +795,7 @@ int fat_checkmount(struct fat_mountpt_s *fs) * ****************************************************************************/ -int fat_hwread(struct fat_mountpt_s *fs, ubyte *buffer, size_t sector, +int fat_hwread(struct fat_mountpt_s *fs, uint8_t *buffer, size_t sector, unsigned int nsectors) { int ret = -ENODEV; @@ -824,7 +826,7 @@ int fat_hwread(struct fat_mountpt_s *fs, ubyte *buffer, size_t sector, * ****************************************************************************/ -int fat_hwwrite(struct fat_mountpt_s *fs, ubyte *buffer, size_t sector, +int fat_hwwrite(struct fat_mountpt_s *fs, uint8_t *buffer, size_t sector, unsigned int nsectors) { int ret = -ENODEV; @@ -856,7 +858,7 @@ int fat_hwwrite(struct fat_mountpt_s *fs, ubyte *buffer, size_t sector, * ****************************************************************************/ -ssize_t fat_cluster2sector(struct fat_mountpt_s *fs, uint32 cluster ) +ssize_t fat_cluster2sector(struct fat_mountpt_s *fs, uint32_t cluster ) { cluster -= 2; if (cluster >= fs->fs_nclusters - 2) @@ -875,7 +877,7 @@ ssize_t fat_cluster2sector(struct fat_mountpt_s *fs, uint32 cluster ) * ****************************************************************************/ -ssize_t fat_getcluster(struct fat_mountpt_s *fs, uint32 clusterno) +ssize_t fat_getcluster(struct fat_mountpt_s *fs, uint32_t clusterno) { /* Verify that the cluster number is within range */ @@ -1001,7 +1003,7 @@ ssize_t fat_getcluster(struct fat_mountpt_s *fs, uint32 clusterno) * ****************************************************************************/ -int fat_putcluster(struct fat_mountpt_s *fs, uint32 clusterno, size_t nextcluster) +int fat_putcluster(struct fat_mountpt_s *fs, uint32_t clusterno, size_t nextcluster) { /* Verify that the cluster number is within range. Zero erases the cluster. */ @@ -1018,7 +1020,7 @@ int fat_putcluster(struct fat_mountpt_s *fs, uint32 clusterno, size_t nextcluste size_t fatsector; unsigned int fatoffset; unsigned int fatindex; - ubyte value; + uint8_t value; /* FAT12 is more complex because it has 12-bits (1.5 bytes) * per FAT entry. Get the offset to the first byte: @@ -1051,7 +1053,7 @@ int fat_putcluster(struct fat_mountpt_s *fs, uint32 clusterno, size_t nextcluste { /* Save the LS eight bits of the next cluster */ - value = (ubyte)nextcluster; + value = (uint8_t)nextcluster; } fs->fs_buffer[fatindex] = value; @@ -1071,7 +1073,7 @@ int fat_putcluster(struct fat_mountpt_s *fs, uint32 clusterno, size_t nextcluste * just modified is written out. */ - fs->fs_dirty = TRUE; + fs->fs_dirty = true; if (fat_fscacheread(fs, fatsector) < 0) { /* Read error */ @@ -1087,7 +1089,7 @@ int fat_putcluster(struct fat_mountpt_s *fs, uint32 clusterno, size_t nextcluste { /* Save the MS eight bits of the next cluster */ - value = (ubyte)(nextcluster >> 4); + value = (uint8_t)(nextcluster >> 4); } else { @@ -1149,9 +1151,9 @@ int fat_putcluster(struct fat_mountpt_s *fs, uint32 clusterno, size_t nextcluste * ****************************************************************************/ -int fat_removechain(struct fat_mountpt_s *fs, uint32 cluster) +int fat_removechain(struct fat_mountpt_s *fs, uint32_t cluster) { - sint32 nextcluster; + int32_t nextcluster; int ret; /* Loop while there are clusters in the chain */ @@ -1201,12 +1203,12 @@ int fat_removechain(struct fat_mountpt_s *fs, uint32 cluster) * ****************************************************************************/ -sint32 fat_extendchain(struct fat_mountpt_s *fs, uint32 cluster) +int32_t fat_extendchain(struct fat_mountpt_s *fs, uint32_t cluster) { - ssize_t startsector; - uint32 newcluster; - uint32 startcluster; - int ret; + ssize_t startsector; + uint32_t newcluster; + uint32_t startcluster; + int ret; /* The special value 0 is used when the new chain should start */ @@ -1450,7 +1452,7 @@ int fat_finddirentry(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo, const char *path) { size_t cluster; - ubyte *direntry = NULL; + uint8_t *direntry = NULL; char terminator; int ret; @@ -1585,7 +1587,7 @@ int fat_finddirentry(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo, /* Get the cluster number of this directory */ cluster = - ((uint32)DIR_GETFSTCLUSTHI(direntry) << 16) | + ((uint32_t)DIR_GETFSTCLUSTHI(direntry) << 16) | DIR_GETFSTCLUSTLO(direntry); /* The restart scanning at the new directory */ @@ -1605,12 +1607,12 @@ int fat_finddirentry(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo, int fat_allocatedirentry(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo) { - sint32 cluster; - size_t sector; - ubyte *direntry; - ubyte ch; - int ret; - int i; + int32_t cluster; + size_t sector; + uint8_t *direntry; + uint8_t ch; + int ret; + int i; /* Re-initialize directory object */ @@ -1726,10 +1728,10 @@ int fat_allocatedirentry(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo * ****************************************************************************/ -int fat_dirname2path(char *path, ubyte *direntry) +int fat_dirname2path(char *path, uint8_t *direntry) { #ifdef CONFIG_FAT_LCNAMES - ubyte ntflags; + uint8_t ntflags; #endif int ch; int ndx; @@ -1839,14 +1841,14 @@ int fat_dirname2path(char *path, ubyte *direntry) int fat_dirtruncate(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo) { unsigned int startcluster; - uint32 writetime; + uint32_t writetime; size_t savesector; int ret; /* Get start cluster of the file to truncate */ startcluster = - ((uint32)DIR_GETFSTCLUSTHI(dirinfo->fd_entry) << 16) | + ((uint32_t)DIR_GETFSTCLUSTHI(dirinfo->fd_entry) << 16) | DIR_GETFSTCLUSTLO(dirinfo->fd_entry); /* Clear the cluster start value in the directory and set the file size @@ -1868,7 +1870,7 @@ int fat_dirtruncate(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo) /* This sector needs to be written back to disk eventually */ - fs->fs_dirty = TRUE; + fs->fs_dirty = true; /* Now remove the entire cluster chain comprising the file */ @@ -1897,8 +1899,8 @@ int fat_dirtruncate(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo) int fat_dircreate(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo) { - ubyte *direntry; - uint32 time; + uint8_t *direntry; + uint32_t time; int ret; /* Set up the directory entry */ @@ -1933,7 +1935,7 @@ int fat_dircreate(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo) DIR_PUTWRTDATE(dirinfo->fd_entry, time >> 16); DIR_PUTCRDATE(dirinfo->fd_entry, time >> 16); - fs->fs_dirty = TRUE; + fs->fs_dirty = true; return OK; } @@ -1945,10 +1947,10 @@ int fat_dircreate(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo) * ****************************************************************************/ -int fat_remove(struct fat_mountpt_s *fs, const char *relpath, boolean directory) +int fat_remove(struct fat_mountpt_s *fs, const char *relpath, bool directory) { struct fat_dirinfo_s dirinfo; - uint32 dircluster; + uint32_t dircluster; size_t dirsector; int ret; @@ -1986,7 +1988,7 @@ int fat_remove(struct fat_mountpt_s *fs, const char *relpath, boolean directory) dirsector = fs->fs_currentsector; dircluster = - ((uint32)DIR_GETFSTCLUSTHI(dirinfo.fd_entry) << 16) | + ((uint32_t)DIR_GETFSTCLUSTHI(dirinfo.fd_entry) << 16) | DIR_GETFSTCLUSTLO(dirinfo.fd_entry); /* Is this entry a directory? */ @@ -2020,7 +2022,7 @@ int fat_remove(struct fat_mountpt_s *fs, const char *relpath, boolean directory) for (;;) { unsigned int subdirindex; - ubyte *subdirentry; + uint8_t *subdirentry; /* Make sure that the sector containing the of the * subdirectory sector is in the cache @@ -2094,7 +2096,7 @@ int fat_remove(struct fat_mountpt_s *fs, const char *relpath, boolean directory) /* Mark the directory entry 'deleted' */ dirinfo.fd_entry[DIR_NAME] = DIR0_EMPTY; - fs->fs_dirty = TRUE; + fs->fs_dirty = true; /* And remove the cluster chain making up the subdirectory */ @@ -2160,7 +2162,7 @@ int fat_fscacheflush(struct fat_mountpt_s *fs) /* No longer dirty */ - fs->fs_dirty = FALSE; + fs->fs_dirty = false; } return OK; } @@ -2357,12 +2359,12 @@ int fat_updatefsinfo(struct fat_mountpt_s *fs) /* Then flush this to disk */ fs->fs_currentsector = fs->fs_fsinfo; - fs->fs_dirty = TRUE; + fs->fs_dirty = true; ret = fat_fscacheflush(fs); /* No longer dirty */ - fs->fs_fsidirty = FALSE; + fs->fs_fsidirty = false; } } return ret; @@ -2377,7 +2379,7 @@ int fat_updatefsinfo(struct fat_mountpt_s *fs) int fat_nfreeclusters(struct fat_mountpt_s *fs, size_t *pfreeclusters) { - uint32 nfreeclusters; + uint32_t nfreeclusters; /* If number of the first free cluster is valid, then just return that value. */ @@ -2401,7 +2403,7 @@ int fat_nfreeclusters(struct fat_mountpt_s *fs, size_t *pfreeclusters) /* If the cluster is unassigned, then increment the count of free clusters */ - if ((uint16)fat_getcluster(fs, sector) == 0) + if ((uint16_t)fat_getcluster(fs, sector) == 0) { nfreeclusters++; } @@ -2466,7 +2468,7 @@ int fat_nfreeclusters(struct fat_mountpt_s *fs, size_t *pfreeclusters) fs->fs_fsifreecount = nfreeclusters; if (fs->fs_type == FSTYPE_FAT32) { - fs->fs_fsidirty = TRUE; + fs->fs_fsidirty = true; } *pfreeclusters = nfreeclusters; diff --git a/nuttx/fs/fat/fs_mkfatfs.c b/nuttx/fs/fat/fs_mkfatfs.c index d9bd8fe30..14d661f93 100644 --- a/nuttx/fs/fat/fs_mkfatfs.c +++ b/nuttx/fs/fat/fs_mkfatfs.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/fat/fs_writefat.c * - * Copyright (C) 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -38,8 +38,8 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> #include <debug.h> @@ -277,7 +277,7 @@ int mkfatfs(FAR const char *pathname, FAR struct fat_format_s *fmt) /* Allocate a buffer that will be working sector memory */ - var.fv_sect = (ubyte*)malloc(var.fv_sectorsize); + var.fv_sect = (uint8_t*)malloc(var.fv_sectorsize); if (!var.fv_sect) { fdbg("Failed to allocate working buffers\n"); diff --git a/nuttx/fs/fat/fs_mkfatfs.h b/nuttx/fs/fat/fs_mkfatfs.h index a7b64d2e9..214697c51 100644 --- a/nuttx/fs/fat/fs_mkfatfs.h +++ b/nuttx/fs/fat/fs_mkfatfs.h @@ -1,7 +1,7 @@ /**************************************************************************** * fs/fat/fs_mkfat.h * - * Copyright (C) 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -41,10 +41,10 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> +#include <stdint.h> /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Only the "hard drive" media type is used */ @@ -95,18 +95,18 @@ struct fat_var_s { - struct inode *fv_inode; /* The block driver "handle" */ - ubyte fv_jump[3]; /* 3-byte boot jump instruction */ - ubyte fv_sectshift; /* Log2 of fv_sectorsize */ - ubyte fv_nrootdirsects; /* Number of root directory sectors */ - ubyte fv_fattype; /* FAT size: 0 (not determined), 12, 16, or 32 */ - uint16 fv_bootcodesize; /* Size of array at fv_bootcode */ - uint32 fv_createtime; /* Creation time */ - uint32 fv_sectorsize; /* Size of one hardware sector */ - uint32 fv_nfatsects; /* Number of sectors in each FAT */ - uint32 fv_nclusters; /* Number of clusters */ - ubyte *fv_sect; /* Allocated working sector buffer */ - const ubyte *fv_bootcode; /* Points to boot code to put into MBR */ + struct inode *fv_inode; /* The block driver "handle" */ + uint8_t fv_jump[3]; /* 3-byte boot jump instruction */ + uint8_t fv_sectshift; /* Log2 of fv_sectorsize */ + uint8_t fv_nrootdirsects; /* Number of root directory sectors */ + uint8_t fv_fattype; /* FAT size: 0 (not determined), 12, 16, or 32 */ + uint16_t fv_bootcodesize; /* Size of array at fv_bootcode */ + uint32_t fv_createtime; /* Creation time */ + uint32_t fv_sectorsize; /* Size of one hardware sector */ + uint32_t fv_nfatsects; /* Number of sectors in each FAT */ + uint32_t fv_nclusters; /* Number of clusters */ + uint8_t *fv_sect; /* Allocated working sector buffer */ + const uint8_t *fv_bootcode; /* Points to boot code to put into MBR */ }; /**************************************************************************** diff --git a/nuttx/fs/fat/fs_writefat.c b/nuttx/fs/fat/fs_writefat.c index 401d023ba..0d35baaf7 100644 --- a/nuttx/fs/fat/fs_writefat.c +++ b/nuttx/fs/fat/fs_writefat.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/fat/fs_writefat.c * - * Copyright (C) 2008, 2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -38,8 +38,9 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> +#include <sys/types.h> +#include <stdint.h> #include <string.h> #include <errno.h> @@ -111,7 +112,7 @@ static inline void mkfatfs_initmbr(FAR struct fat_format_s *fmt, } else { - MBR_PUTTOTSEC16(var->fv_sect, (uint16)fmt->ff_nsectors); + MBR_PUTTOTSEC16(var->fv_sect, (uint16_t)fmt->ff_nsectors); } /* 1@21: Media code: f0, f8, f9-fa, fc-ff */ @@ -137,7 +138,7 @@ static inline void mkfatfs_initmbr(FAR struct fat_format_s *fmt, { /* 2@22: FAT12/16: Must be 0, see BS32_FATSZ32 */ - MBR_PUTFATSZ16(var->fv_sect, (uint16)var->fv_nfatsects); + MBR_PUTFATSZ16(var->fv_sect, (uint16_t)var->fv_nfatsects); /* The following fields are only valid for FAT12/16 */ /* 1@36: Drive number for MSDOS bootstrap -- left zero */ @@ -314,6 +315,7 @@ static inline void mkfatfs_initrootdir(FAR struct fat_format_s *fmt, * Zero on success; negated errno on failure * ****************************************************************************/ + static inline int mkfatfs_writembr(FAR struct fat_format_s *fmt, FAR struct fat_var_s *var) { @@ -382,6 +384,7 @@ static inline int mkfatfs_writembr(FAR struct fat_format_s *fmt, * Zero on success; negated errno on failure * ****************************************************************************/ + static inline int mkfatfs_writefat(FAR struct fat_format_s *fmt, FAR struct fat_var_s *var) { @@ -464,6 +467,7 @@ static inline int mkfatfs_writefat(FAR struct fat_format_s *fmt, * Zero on success; negated errno on failure * ****************************************************************************/ + static inline int mkfatfs_writerootdir(FAR struct fat_format_s *fmt, FAR struct fat_var_s *var) { @@ -512,6 +516,7 @@ static inline int mkfatfs_writerootdir(FAR struct fat_format_s *fmt, * Zero on success; negated errno on failure * ****************************************************************************/ + int mkfatfs_writefatfs(FAR struct fat_format_s *fmt, FAR struct fat_var_s *var) { diff --git a/nuttx/fs/fs_close.c b/nuttx/fs/fs_close.c index a60bc592d..a6d6dfc68 100644 --- a/nuttx/fs/fs_close.c +++ b/nuttx/fs/fs_close.c @@ -38,7 +38,7 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> + #include <unistd.h> #include <sched.h> #include <errno.h> diff --git a/nuttx/fs/fs_closeblockdriver.c b/nuttx/fs/fs_closeblockdriver.c index 07c7cacca..ae80f9532 100644 --- a/nuttx/fs/fs_closeblockdriver.c +++ b/nuttx/fs/fs_closeblockdriver.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/fs_closeblockdriver.c * - * Copyright (C) 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in pathname and binary forms, with or without @@ -38,7 +38,7 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> + #include <debug.h> #include <errno.h> #include <nuttx/fs.h> diff --git a/nuttx/fs/fs_closedir.c b/nuttx/fs/fs_closedir.c index 3b244da1d..c7824477e 100644 --- a/nuttx/fs/fs_closedir.c +++ b/nuttx/fs/fs_closedir.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/fs_closedir.c * - * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -38,11 +38,12 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> + #include <stdlib.h> #include <dirent.h> #include <errno.h> #include <nuttx/fs.h> + #include "fs_internal.h" /**************************************************************************** diff --git a/nuttx/fs/fs_dup.c b/nuttx/fs/fs_dup.c index c041aa4ca..df4e1affa 100644 --- a/nuttx/fs/fs_dup.c +++ b/nuttx/fs/fs_dup.c @@ -39,7 +39,6 @@ #include <nuttx/config.h> -#include <sys/types.h> #include <unistd.h> #include <sched.h> #include <errno.h> diff --git a/nuttx/fs/fs_dup2.c b/nuttx/fs/fs_dup2.c index 546c024dc..383d518b2 100644 --- a/nuttx/fs/fs_dup2.c +++ b/nuttx/fs/fs_dup2.c @@ -38,11 +38,10 @@ ****************************************************************************/ #include <nuttx/config.h> - -#include <sys/types.h> #include <unistd.h> #include <sched.h> #include <errno.h> + #include "fs_internal.h" /* This logic in this applies only when both socket and file descriptors are @@ -53,7 +52,7 @@ #if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0 /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/nuttx/fs/fs_fcntl.c b/nuttx/fs/fs_fcntl.c index 0639f52d6..668d7e40e 100644 --- a/nuttx/fs/fs_fcntl.c +++ b/nuttx/fs/fs_fcntl.c @@ -38,7 +38,6 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> #include <stdarg.h> #include <fcntl.h> diff --git a/nuttx/fs/fs_filedup.c b/nuttx/fs/fs_filedup.c index 10c2eba04..60dd9720a 100644 --- a/nuttx/fs/fs_filedup.c +++ b/nuttx/fs/fs_filedup.c @@ -39,7 +39,6 @@ #include <nuttx/config.h> -#include <sys/types.h> #include <sched.h> #include <errno.h> @@ -49,7 +48,7 @@ #if CONFIG_NFILE_DESCRIPTORS > 0 /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #define DUP_ISOPEN(fd, list) \ diff --git a/nuttx/fs/fs_filedup2.c b/nuttx/fs/fs_filedup2.c index e1c2462d8..b9ba2d194 100644 --- a/nuttx/fs/fs_filedup2.c +++ b/nuttx/fs/fs_filedup2.c @@ -39,7 +39,6 @@ #include <nuttx/config.h> -#include <sys/types.h> #include <unistd.h> #include <sched.h> #include <errno.h> @@ -48,7 +47,7 @@ #if CONFIG_NFILE_DESCRIPTORS > 0 /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #define DUP_ISOPEN(fd, list) \ diff --git a/nuttx/fs/fs_files.c b/nuttx/fs/fs_files.c index 1af5f704f..4ea735b69 100644 --- a/nuttx/fs/fs_files.c +++ b/nuttx/fs/fs_files.c @@ -38,6 +38,8 @@ ****************************************************************************/ #include <nuttx/config.h> + +#include <sys/types.h> #include <string.h> #include <semaphore.h> #include <assert.h> @@ -45,10 +47,11 @@ #include <errno.h> #include <nuttx/fs.h> #include <nuttx/kmalloc.h> + #include "fs_internal.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/nuttx/fs/fs_fsync.c b/nuttx/fs/fs_fsync.c index f36869214..08d47e578 100644 --- a/nuttx/fs/fs_fsync.c +++ b/nuttx/fs/fs_fsync.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/fs_fsync.c * - * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -38,7 +38,7 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> + #include <unistd.h> #include <fcntl.h> #include <errno.h> @@ -48,7 +48,7 @@ #include "fs_internal.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/nuttx/fs/fs_inode.c b/nuttx/fs/fs_inode.c index d241fd42b..f0d6b6948 100644 --- a/nuttx/fs/fs_inode.c +++ b/nuttx/fs/fs_inode.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs_inode.c * - * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -38,7 +38,6 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> #include <stdlib.h> #include <assert.h> @@ -49,7 +48,7 @@ #include "fs_internal.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/nuttx/fs/fs_inodeaddref.c b/nuttx/fs/fs_inodeaddref.c index 584c7b70b..c5dea2e4c 100644 --- a/nuttx/fs/fs_inodeaddref.c +++ b/nuttx/fs/fs_inodeaddref.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs_inodeaddref.c * - * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -38,13 +38,13 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> + #include <errno.h> #include <nuttx/fs.h> #include "fs_internal.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/nuttx/fs/fs_inodefind.c b/nuttx/fs/fs_inodefind.c index f9fb1d58f..c4cbeab9e 100644 --- a/nuttx/fs/fs_inodefind.c +++ b/nuttx/fs/fs_inodefind.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/fs_inodefind.c * - * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -38,13 +38,14 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> + #include <errno.h> #include <nuttx/fs.h> + #include "fs_internal.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/nuttx/fs/fs_inoderelease.c b/nuttx/fs/fs_inoderelease.c index b37b0100f..db114c936 100644 --- a/nuttx/fs/fs_inoderelease.c +++ b/nuttx/fs/fs_inoderelease.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs_inoderelease.c * - * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -38,14 +38,15 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> + #include <stdlib.h> #include <errno.h> #include <nuttx/fs.h> + #include "fs_internal.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/nuttx/fs/fs_inoderemove.c b/nuttx/fs/fs_inoderemove.c index 2034234db..ff8dcc2ee 100644 --- a/nuttx/fs/fs_inoderemove.c +++ b/nuttx/fs/fs_inoderemove.c @@ -38,10 +38,11 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> + #include <stdlib.h> #include <errno.h> #include <nuttx/fs.h> + #include "fs_internal.h" /**************************************************************************** diff --git a/nuttx/fs/fs_inodereserve.c b/nuttx/fs/fs_inodereserve.c index cab7d07fe..f38e349bc 100644 --- a/nuttx/fs/fs_inodereserve.c +++ b/nuttx/fs/fs_inodereserve.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/fs_registerreserve.c * - * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -38,14 +38,15 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> + #include <stdlib.h> #include <errno.h> #include <nuttx/fs.h> + #include "fs_internal.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/nuttx/fs/fs_internal.h b/nuttx/fs/fs_internal.h index 48849436f..95e4e71ef 100644 --- a/nuttx/fs/fs_internal.h +++ b/nuttx/fs/fs_internal.h @@ -33,20 +33,24 @@ * ****************************************************************************/ -#ifndef __FS_INTERNAL_H -#define __FS_INTERNAL_H +#ifndef __FS_FS_INTERNAL_H +#define __FS_FS_INTERNAL_H /**************************************************************************** * Included Files ****************************************************************************/ #include <nuttx/config.h> -#include <nuttx/fs.h> + +#include <sys/types.h> +#include <stdint.h> #include <dirent.h> + +#include <nuttx/fs.h> #include <nuttx/compiler.h> /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #define FSNODEFLAG_TYPE_MASK 0x00000003 @@ -102,8 +106,8 @@ struct fs_psuedodir_s struct fs_fatdir_s { - uint32 fd_startcluster; /* Start cluster number of the directory */ - uint32 fd_currcluster; /* Current cluster number being read */ + uint32_t fd_startcluster; /* Start cluster number of the directory */ + uint32_t fd_currcluster; /* Current cluster number being read */ size_t fd_currsector; /* Current sector being read */ unsigned int fd_index; /* Current index of the directory entry to read */ }; @@ -116,8 +120,8 @@ struct fs_fatdir_s struct fs_romfsdir_s { - uint32 fr_firstoffset; /* Offset to the first entry in the directory */ - uint32 fr_curroffset; /* Current offset into the directory contents */ + uint32_t fr_firstoffset; /* Offset to the first entry in the directory */ + uint32_t fr_curroffset; /* Current offset into the directory contents */ }; #endif /* CONFIG_FS_ROMFS */ #endif /* CONFIG_DISABLE_MOUNTPOINT */ @@ -239,4 +243,4 @@ EXTERN int find_blockdriver(FAR const char *pathname, int mountflags, } #endif -#endif /* __FS_INTERNAL_H */ +#endif /* __FS_FS_INTERNAL_H */ diff --git a/nuttx/fs/fs_ioctl.c b/nuttx/fs/fs_ioctl.c index c9bf17344..350feff00 100644 --- a/nuttx/fs/fs_ioctl.c +++ b/nuttx/fs/fs_ioctl.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/fs_ioctl.c * - * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -39,7 +39,6 @@ #include <nuttx/config.h> -#include <sys/types.h> #include <sys/ioctl.h> #include <sched.h> #include <errno.h> diff --git a/nuttx/fs/fs_mmap.c b/nuttx/fs/fs_mmap.c index 0fa0b56e1..5368b426a 100644 --- a/nuttx/fs/fs_mmap.c +++ b/nuttx/fs/fs_mmap.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/fs_mmap.c * - * Copyright (C) 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -42,6 +42,7 @@ #include <sys/types.h> #include <sys/mman.h> #include <sys/ioctl.h> +#include <stdint.h> #include <errno.h> #include <debug.h> @@ -146,12 +147,12 @@ FAR void *mmap(FAR void *start, size_t length, int prot, int flags, * only option supported * * Perform the ioctl to get the base address of the file in 'mapped' - * in memory. (casting to uintptr first eliminates complaints on some + * in memory. (casting to uintptr_t first eliminates complaints on some * architectures where the sizeof long is different from the size of * a pointer). */ - ret = ioctl(fd, FIOC_MMAP, (unsigned long)((uintptr)&addr)); + ret = ioctl(fd, FIOC_MMAP, (unsigned long)((uintptr_t)&addr)); if (ret < 0) { fdbg("ioctl(FIOC_MMAP) failed: %d\n", errno); @@ -160,7 +161,7 @@ FAR void *mmap(FAR void *start, size_t length, int prot, int flags, /* Return the offset address */ - return (void*)(((ubyte*)addr) + offset); + return (void*)(((uint8_t*)addr) + offset); #ifdef CONFIG_DEBUG errout_with_ret: diff --git a/nuttx/fs/fs_mount.c b/nuttx/fs/fs_mount.c index 9dcc21238..aa0128d6f 100644 --- a/nuttx/fs/fs_mount.c +++ b/nuttx/fs/fs_mount.c @@ -38,7 +38,7 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> + #include <sys/mount.h> #include <string.h> #include <debug.h> @@ -56,7 +56,7 @@ #ifdef CONFIG_FS_READABLE /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/nuttx/fs/fs_openblockdriver.c b/nuttx/fs/fs_openblockdriver.c index f4dcd94eb..cd5759b45 100644 --- a/nuttx/fs/fs_openblockdriver.c +++ b/nuttx/fs/fs_openblockdriver.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/fs_openblockdriver.c * - * Copyright (C) 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in pathname and binary forms, with or without @@ -38,7 +38,7 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> + #include <debug.h> #include <errno.h> #include <nuttx/fs.h> diff --git a/nuttx/fs/fs_opendir.c b/nuttx/fs/fs_opendir.c index ddb4611b8..3abdc1b3d 100644 --- a/nuttx/fs/fs_opendir.c +++ b/nuttx/fs/fs_opendir.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/fs_opendir.c * - * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -39,8 +39,8 @@ #include <nuttx/config.h> -#include <sys/types.h> #include <stdlib.h> +#include <stdbool.h> #include <dirent.h> #include <string.h> #include <assert.h> @@ -91,7 +91,7 @@ FAR DIR *opendir(FAR const char *path) FAR struct inode *inode = NULL; FAR struct internal_dir_s *dir; FAR const char *relpath; - boolean isroot = FALSE; + bool isroot = false; int ret; /* If we are given 'nothing' then we will interpret this as @@ -102,7 +102,7 @@ FAR DIR *opendir(FAR const char *path) if (!path || *path == 0 || strcmp(path, "/") == 0) { inode = root_inode; - isroot = TRUE; + isroot = true; } else { diff --git a/nuttx/fs/fs_poll.c b/nuttx/fs/fs_poll.c index 5e377de94..20a16e3e8 100644 --- a/nuttx/fs/fs_poll.c +++ b/nuttx/fs/fs_poll.c @@ -39,7 +39,8 @@ #include <nuttx/config.h> -#include <sys/types.h> +#include <stdint.h> +#include <stdbool.h> #include <poll.h> #include <wdog.h> #include <errno.h> @@ -55,7 +56,7 @@ #ifndef CONFIG_DISABLE_POLL /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #define poll_semgive(sem) sem_post(sem) @@ -93,7 +94,7 @@ static void poll_semtake(FAR sem_t *sem) ****************************************************************************/ #if CONFIG_NFILE_DESCRIPTORS > 0 -static int poll_fdsetup(int fd, FAR struct pollfd *fds, boolean setup) +static int poll_fdsetup(int fd, FAR struct pollfd *fds, bool setup) { FAR struct filelist *list; FAR struct file *this_file; @@ -169,7 +170,7 @@ static inline int poll_setup(FAR struct pollfd *fds, nfds_t nfds, sem_t *sem) /* Set up the poll */ - ret = poll_fdsetup(fds[i].fd, &fds[i], TRUE); + ret = poll_fdsetup(fds[i].fd, &fds[i], true); if (ret < 0) { return ret; @@ -202,7 +203,7 @@ static inline int poll_teardown(FAR struct pollfd *fds, nfds_t nfds, int *count) { /* Teardown the poll */ - status = poll_fdsetup(fds[i].fd, &fds[i], FALSE); + status = poll_fdsetup(fds[i].fd, &fds[i], false); if (status < 0) { ret = status; @@ -231,7 +232,7 @@ static inline int poll_teardown(FAR struct pollfd *fds, nfds_t nfds, int *count) * ****************************************************************************/ -static void poll_timeout(int argc, uint32 isem, ...) +static void poll_timeout(int argc, uint32_t isem, ...) { /* Wake up the poller */ @@ -293,7 +294,7 @@ int poll(FAR struct pollfd *fds, nfds_t nfds, int timeout) */ wdog = wd_create(); - wd_start(wdog, MSEC2TICK(timeout), poll_timeout, 1, (uint32)&sem); + wd_start(wdog, MSEC2TICK(timeout), poll_timeout, 1, (uint32_t)&sem); poll_semtake(&sem); wd_delete(wdog); } diff --git a/nuttx/fs/fs_readdir.c b/nuttx/fs/fs_readdir.c index 64b02117a..c966a9858 100644 --- a/nuttx/fs/fs_readdir.c +++ b/nuttx/fs/fs_readdir.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/fs_readdir.c * - * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -38,11 +38,12 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> + #include <string.h> #include <dirent.h> #include <errno.h> #include <nuttx/fs.h> + #include "fs_internal.h" /**************************************************************************** diff --git a/nuttx/fs/fs_readdirr.c b/nuttx/fs/fs_readdirr.c index 89ef322b6..953b43d5a 100644 --- a/nuttx/fs/fs_readdirr.c +++ b/nuttx/fs/fs_readdirr.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/fs_readdirr.c * - * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -38,7 +38,7 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> + #include <string.h> #include <dirent.h> #include <errno.h> diff --git a/nuttx/fs/fs_rename.c b/nuttx/fs/fs_rename.c index 52c8e64f9..119115595 100644 --- a/nuttx/fs/fs_rename.c +++ b/nuttx/fs/fs_rename.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/fs_rename.c * - * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -38,7 +38,7 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> + #include <stdio.h> #include <errno.h> #include <nuttx/fs.h> @@ -46,7 +46,7 @@ #include "fs_internal.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/nuttx/fs/fs_rewinddir.c b/nuttx/fs/fs_rewinddir.c index dfb883080..171f26399 100644 --- a/nuttx/fs/fs_rewinddir.c +++ b/nuttx/fs/fs_rewinddir.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/fs_rewinddir.c * - * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -38,10 +38,11 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> + #include <dirent.h> #include <errno.h> #include <nuttx/fs.h> + #include "fs_internal.h" /**************************************************************************** diff --git a/nuttx/fs/fs_rmdir.c b/nuttx/fs/fs_rmdir.c index 6909bbd60..53342f4de 100644 --- a/nuttx/fs/fs_rmdir.c +++ b/nuttx/fs/fs_rmdir.c @@ -1,7 +1,7 @@ /**************************************************************************** - * fs_rmdir.c + * fs/fs_rmdir.c * - * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -38,7 +38,7 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> + #include <unistd.h> #include <errno.h> #include <nuttx/fs.h> @@ -46,7 +46,7 @@ #include "fs_internal.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/nuttx/fs/fs_select.c b/nuttx/fs/fs_select.c index 82085bbd1..57f5c36fe 100644 --- a/nuttx/fs/fs_select.c +++ b/nuttx/fs/fs_select.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/fs_select.c * - * Copyright (C) 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -39,7 +39,6 @@ #include <nuttx/config.h> -#include <sys/types.h> #include <sys/select.h> #include <stdlib.h> @@ -57,7 +56,7 @@ #ifndef CONFIG_DISABLE_POLL /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/nuttx/fs/fs_stat.c b/nuttx/fs/fs_stat.c index 5923a04f1..85c91bd4e 100644 --- a/nuttx/fs/fs_stat.c +++ b/nuttx/fs/fs_stat.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/fs_stat.c * - * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -38,11 +38,12 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> + #include <sys/stat.h> #include <string.h> #include <sched.h> #include <errno.h> + #include "fs_internal.h" /**************************************************************************** diff --git a/nuttx/fs/fs_statfs.c b/nuttx/fs/fs_statfs.c index 4a3a39cdc..9ce15efbf 100644 --- a/nuttx/fs/fs_statfs.c +++ b/nuttx/fs/fs_statfs.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/fs_statfs.c * - * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -38,12 +38,13 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> + #include <sys/statfs.h> #include <string.h> #include <limits.h> #include <sched.h> #include <errno.h> + #include "fs_internal.h" /**************************************************************************** diff --git a/nuttx/fs/fs_umount.c b/nuttx/fs/fs_umount.c index 62408fdb0..d085ac4d0 100644 --- a/nuttx/fs/fs_umount.c +++ b/nuttx/fs/fs_umount.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/fs_umount.c * - * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -38,14 +38,15 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> + #include <sys/mount.h> #include <errno.h> #include <nuttx/fs.h> + #include "fs_internal.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/nuttx/fs/fs_unlink.c b/nuttx/fs/fs_unlink.c index 3a70bb830..013718dc8 100644 --- a/nuttx/fs/fs_unlink.c +++ b/nuttx/fs/fs_unlink.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs_unlink.c * - * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -38,7 +38,7 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> + #include <unistd.h> #include <errno.h> #include <nuttx/fs.h> @@ -46,7 +46,7 @@ #include "fs_internal.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/nuttx/fs/fs_unregisterblockdriver.c b/nuttx/fs/fs_unregisterblockdriver.c index cb737f2e3..23860205b 100644 --- a/nuttx/fs/fs_unregisterblockdriver.c +++ b/nuttx/fs/fs_unregisterblockdriver.c @@ -38,13 +38,13 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> + #include <nuttx/fs.h> #include "fs_internal.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/nuttx/fs/fs_unregisterdriver.c b/nuttx/fs/fs_unregisterdriver.c index 2455742db..8370252dc 100644 --- a/nuttx/fs/fs_unregisterdriver.c +++ b/nuttx/fs/fs_unregisterdriver.c @@ -38,13 +38,13 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> + #include <nuttx/fs.h> #include "fs_internal.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/nuttx/fs/romfs/fs_romfs.c b/nuttx/fs/romfs/fs_romfs.c index 12ddc4bf9..7abfb4b14 100644 --- a/nuttx/fs/romfs/fs_romfs.c +++ b/nuttx/fs/romfs/fs_romfs.c @@ -45,6 +45,8 @@ #include <sys/statfs.h> #include <sys/stat.h> +#include <stdint.h> +#include <stdbool.h> #include <stdlib.h> #include <unistd.h> #include <string.h> @@ -223,7 +225,7 @@ static int romfs_open(FAR struct file *filep, const char *relpath, * non-zero elements) */ - rf->rf_open = TRUE; + rf->rf_open = true; rf->rf_size = dirinfo.rd_size; /* Get the start of the file data */ @@ -325,10 +327,10 @@ static ssize_t romfs_read(FAR struct file *filep, char *buffer, size_t buflen) unsigned int bytesread; unsigned int readsize; unsigned int nsectors; - uint32 offset; + uint32_t offset; size_t bytesleft; off_t sector; - ubyte *userbuffer = (ubyte*)buffer; + uint8_t *userbuffer = (uint8_t*)buffer; int sectorndx; int ret; @@ -654,10 +656,10 @@ errout_with_semaphore: static int romfs_readdir(struct inode *mountpt, struct internal_dir_s *dir) { struct romfs_mountpt_s *rm; - uint32 linkoffset; - uint32 next; - uint32 info; - uint32 size; + uint32_t linkoffset; + uint32_t next; + uint32_t info; + uint32_t size; int ret; fvdbg("Entry\n"); diff --git a/nuttx/fs/romfs/fs_romfs.h b/nuttx/fs/romfs/fs_romfs.h index 5deffcb53..b734f094f 100644 --- a/nuttx/fs/romfs/fs_romfs.h +++ b/nuttx/fs/romfs/fs_romfs.h @@ -1,7 +1,7 @@ /**************************************************************************** * fs/romfs/fs_romfs.h * - * Copyright (C) 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * References: Linux/Documentation/filesystems/romfs.txt @@ -43,7 +43,10 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> + +#include <stdint.h> +#include <stdbool.h> + #include "../fs_internal.h" /**************************************************************************** @@ -90,7 +93,7 @@ #define RFNEXT_FIFO 7 /* rf_info = Unused, must be zero */ #define RFNEXT_EXEC 8 /* Modifier of RFNEXT_DIRECTORY and RFNEXT_FILE */ -#define IS_MODE(rfn,mode) ((((uint32)(rfn))&RFNEXT_MODEMASK)==(mode)) +#define IS_MODE(rfn,mode) ((((uint32_t)(rfn))&RFNEXT_MODEMASK)==(mode)) #define IS_HARDLINK(rfn) IS_MODE(rfn,RFNEXT_HARDLINK) #define IS_DIRECTORY(rfn) IS_MODE(rfn,RFNEXT_DIRECTORY) #define IS_FILE(rfn) IS_MODE(rfn,RFNEXT_FILE) @@ -105,8 +108,8 @@ #define ROMFS_ALIGNMENT 16 #define ROMFS_MAXPADDING (ROMFS_ALIGNMENT-1) #define ROMFS_ALIGNMASK (~ROMFS_MAXPADDING) -#define ROMFS_ALIGNUP(addr) ((((uint32)(addr))+ROMFS_MAXPADDING)&ROMFS_ALIGNMASK) -#define ROMFS_ALIGNDOWN(addr) (((uint32)(addr))&ROMFS_ALIGNMASK) +#define ROMFS_ALIGNUP(addr) ((((uint32_t)(addr))+ROMFS_MAXPADDING)&ROMFS_ALIGNMASK) +#define ROMFS_ALIGNDOWN(addr) (((uint32_t)(addr))&ROMFS_ALIGNMASK) /* Offset and sector conversions */ @@ -135,15 +138,15 @@ struct romfs_mountpt_s struct inode *rm_blkdriver; /* The block driver inode that hosts the FAT32 fs */ struct romfs_file_s *rm_head; /* A list to all files opened on this mountpoint */ - boolean rm_mounted; /* TRUE: The file system is ready */ - uint16 rm_hwsectorsize; /* HW: Sector size reported by block driver*/ + bool rm_mounted; /* true: The file system is ready */ + uint16_t rm_hwsectorsize; /* HW: Sector size reported by block driver*/ sem_t rm_sem; /* Used to assume thread-safe access */ - uint32 rm_rootoffset; /* Saved offset to the first root directory entry */ - uint32 rm_hwnsectors; /* HW: The number of sectors reported by the hardware */ - uint32 rm_volsize; /* Size of the ROMFS volume */ - uint32 rm_cachesector; /* Current sector in the rm_buffer */ - ubyte *rm_xipbase; /* Base address of directly accessible media */ - ubyte *rm_buffer; /* Device sector buffer, allocated if rm_xipbase==0 */ + uint32_t rm_rootoffset; /* Saved offset to the first root directory entry */ + uint32_t rm_hwnsectors; /* HW: The number of sectors reported by the hardware */ + uint32_t rm_volsize; /* Size of the ROMFS volume */ + uint32_t rm_cachesector; /* Current sector in the rm_buffer */ + uint8_t *rm_xipbase; /* Base address of directly accessible media */ + uint8_t *rm_buffer; /* Device sector buffer, allocated if rm_xipbase==0 */ }; /* This structure represents on open file under the mountpoint. An instance @@ -154,11 +157,11 @@ struct romfs_mountpt_s struct romfs_file_s { struct romfs_file_s *rf_next; /* Retained in a singly linked list */ - boolean rf_open; /* TRUE: The file is (still) open */ - uint32 rf_startoffset; /* Offset to the start of the file data */ - uint32 rf_size; /* Size of the file in bytes */ - uint32 rf_cachesector; /* Current sector in the rf_buffer */ - ubyte *rf_buffer; /* File sector buffer, allocated if rm_xipbase==0 */ + bool rf_open; /* true: The file is (still) open */ + uint32_t rf_startoffset; /* Offset to the start of the file data */ + uint32_t rf_size; /* Size of the file in bytes */ + uint32_t rf_cachesector; /* Current sector in the rf_buffer */ + uint8_t *rf_buffer; /* File sector buffer, allocated if rm_xipbase==0 */ }; /* This structure is used internally for describing the result of @@ -172,12 +175,12 @@ struct romfs_dirinfo_s * a directory. */ - struct fs_romfsdir_s rd_dir; /* Describes directory. */ + struct fs_romfsdir_s rd_dir; /* Describes directory. */ /* Values from the ROMFS file entry */ - uint32 rd_next; /* Offset of the next file header+flags */ - uint32 rd_size; /* Size (if file) */ + uint32_t rd_next; /* Offset of the next file header+flags */ + uint32_t rd_size; /* Size (if file) */ }; /**************************************************************************** @@ -198,10 +201,10 @@ extern "C" { EXTERN void romfs_semtake(struct romfs_mountpt_s *rm); EXTERN void romfs_semgive(struct romfs_mountpt_s *rm); -EXTERN int romfs_hwread(struct romfs_mountpt_s *rm, ubyte *buffer, - uint32 sector, unsigned int nsectors); +EXTERN int romfs_hwread(struct romfs_mountpt_s *rm, uint8_t *buffer, + uint32_t sector, unsigned int nsectors); EXTERN int romfs_filecacheread(struct romfs_mountpt_s *rm, - struct romfs_file_s *rf, uint32 sector); + struct romfs_file_s *rf, uint32_t sector); EXTERN int romfs_hwconfigure(struct romfs_mountpt_s *rm); EXTERN int romfs_fsconfigure(struct romfs_mountpt_s *rm); EXTERN int romfs_fileconfigure(struct romfs_mountpt_s *rm, @@ -211,12 +214,12 @@ EXTERN int romfs_finddirentry(struct romfs_mountpt_s *rm, struct romfs_dirinfo_s *dirinfo, const char *path); EXTERN int romfs_parsedirentry(struct romfs_mountpt_s *rm, - uint32 offset, uint32 *poffset, uint32 *pnext, - uint32 *pinfo, uint32 *psize); -EXTERN int romfs_parsefilename(struct romfs_mountpt_s *rm, uint32 offset, + uint32_t offset, uint32_t *poffset, uint32_t *pnext, + uint32_t *pinfo, uint32_t *psize); +EXTERN int romfs_parsefilename(struct romfs_mountpt_s *rm, uint32_t offset, char *pname); -EXTERN int romfs_datastart(struct romfs_mountpt_s *rm, uint32 offset, - uint32 *start); +EXTERN int romfs_datastart(struct romfs_mountpt_s *rm, uint32_t offset, + uint32_t *start); #undef EXTERN #if defined(__cplusplus) diff --git a/nuttx/fs/romfs/fs_romfsutil.c b/nuttx/fs/romfs/fs_romfsutil.c index 4f328f304..ee2eb8f16 100644 --- a/nuttx/fs/romfs/fs_romfsutil.c +++ b/nuttx/fs/romfs/fs_romfsutil.c @@ -42,6 +42,8 @@ #include <nuttx/config.h> #include <sys/types.h> +#include <stdint.h> +#include <stdbool.h> #include <stdlib.h> #include <string.h> #include <assert.h> @@ -82,7 +84,7 @@ ****************************************************************************/ #ifndef CONFIG_ENDIAN_BIG -static inline uint32 romfs_swap32(uint32 value) +static inline uint32_t romfs_swap32(uint32_t value) { return ((((value) & 0x000000ff) << 24) | (((value) & 0x0000ff00) << 8) | (((value) & 0x00ff0000) >> 8) | (((value) & 0xff000000) >> 24)); @@ -100,11 +102,11 @@ static inline uint32 romfs_swap32(uint32 value) * ****************************************************************************/ -static uint32 romfs_devread32(struct romfs_mountpt_s *rm, int ndx) +static uint32_t romfs_devread32(struct romfs_mountpt_s *rm, int ndx) { /* Extract the value */ - uint32 value = *(uint32*)&rm->rm_buffer[ndx]; + uint32_t value = *(uint32_t*)&rm->rm_buffer[ndx]; /* Value is begin endian -- return the native host endian-ness. */ #ifdef CONFIG_ENDIAN_BIG @@ -122,15 +124,15 @@ static uint32 romfs_devread32(struct romfs_mountpt_s *rm, int ndx) * ****************************************************************************/ -static inline int romfs_checkentry(struct romfs_mountpt_s *rm, uint32 offset, +static inline int romfs_checkentry(struct romfs_mountpt_s *rm, uint32_t offset, const char *entryname, int entrylen, struct romfs_dirinfo_s *dirinfo) { char name[NAME_MAX+1]; - uint32 linkoffset; - uint32 next; - uint32 info; - uint32 size; + uint32_t linkoffset; + uint32_t next; + uint32_t info; + uint32_t size; int ret; /* Parse the directory entry at this offset (which may be re-directed @@ -197,10 +199,10 @@ static inline int romfs_checkentry(struct romfs_mountpt_s *rm, uint32 offset, * ****************************************************************************/ -sint16 romfs_devcacheread(struct romfs_mountpt_s *rm, uint32 offset) +int16_t romfs_devcacheread(struct romfs_mountpt_s *rm, uint32_t offset) { - uint32 sector; - int ret; + uint32_t sector; + int ret; /* rm->rm_cachesector holds the current sector that is buffer in or referenced * by rm->tm_buffer. If the requested sector is the same as this sector, @@ -227,7 +229,7 @@ sint16 romfs_devcacheread(struct romfs_mountpt_s *rm, uint32 offset) ret = romfs_hwread(rm, rm->rm_buffer, sector, 1); if (ret < 0) { - return (sint16)ret; + return (int16_t)ret; } } @@ -251,12 +253,12 @@ sint16 romfs_devcacheread(struct romfs_mountpt_s *rm, uint32 offset) * ****************************************************************************/ -static int romfs_followhardlinks(struct romfs_mountpt_s *rm, uint32 offset, - uint32 *poffset) +static int romfs_followhardlinks(struct romfs_mountpt_s *rm, uint32_t offset, + uint32_t *poffset) { - uint32 next; - sint16 ndx; - int i; + uint32_t next; + int16_t ndx; + int i; /* Loop while we are redirected by hardlinks */ @@ -300,10 +302,10 @@ static inline int romfs_searchdir(struct romfs_mountpt_s *rm, const char *entryname, int entrylen, struct romfs_dirinfo_s *dirinfo) { - uint32 offset; - uint32 next; - sint16 ndx; - int ret; + uint32_t offset; + uint32_t next; + int16_t ndx; + int ret; /* Then loop through the current directory until the directory * with the matching name is found. Or until all of the entries @@ -391,7 +393,7 @@ void romfs_semgive(struct romfs_mountpt_s *rm) * ****************************************************************************/ -int romfs_hwread(struct romfs_mountpt_s *rm, ubyte *buffer, uint32 sector, +int romfs_hwread(struct romfs_mountpt_s *rm, uint8_t *buffer, uint32_t sector, unsigned int nsectors) { int ret = -ENODEV; @@ -441,7 +443,7 @@ int romfs_hwread(struct romfs_mountpt_s *rm, ubyte *buffer, uint32 sector, * ****************************************************************************/ -int romfs_filecacheread(struct romfs_mountpt_s *rm, struct romfs_file_s *rf, uint32 sector) +int romfs_filecacheread(struct romfs_mountpt_s *rm, struct romfs_file_s *rf, uint32_t sector) { int ret; @@ -532,7 +534,7 @@ int romfs_hwconfigure(struct romfs_mountpt_s *rm) /* Determine if block driver supports the XIP mode of operation */ - rm->rm_cachesector = (uint32)-1; + rm->rm_cachesector = (uint32_t)-1; if (inode->u.i_bops->ioctl) { @@ -552,7 +554,7 @@ int romfs_hwconfigure(struct romfs_mountpt_s *rm) /* Allocate the device cache buffer for normal sector accesses */ - rm->rm_buffer = (ubyte*)malloc(rm->rm_hwsectorsize); + rm->rm_buffer = (uint8_t*)malloc(rm->rm_hwsectorsize); if (!rm->rm_buffer) { return -ENOMEM; @@ -575,7 +577,7 @@ int romfs_hwconfigure(struct romfs_mountpt_s *rm) int romfs_fsconfigure(struct romfs_mountpt_s *rm) { const char *name; - sint16 ndx; + int16_t ndx; /* Then get information about the ROMFS filesystem on the devices managed * by this block driver. Read sector zero which contains the volume header. @@ -605,7 +607,7 @@ int romfs_fsconfigure(struct romfs_mountpt_s *rm) /* and return success */ - rm->rm_mounted = TRUE; + rm->rm_mounted = true; return OK; } @@ -636,11 +638,11 @@ int romfs_fileconfigure(struct romfs_mountpt_s *rm, struct romfs_file_s *rf) { /* Nothing in the cache buffer */ - rf->rf_cachesector = (uint32)-1; + rf->rf_cachesector = (uint32_t)-1; /* Create a file buffer to support partial sector accesses */ - rf->rf_buffer = (ubyte*)malloc(rm->rm_hwsectorsize); + rf->rf_buffer = (uint8_t*)malloc(rm->rm_hwsectorsize); if (!rf->rf_buffer) { return -ENOMEM; @@ -665,7 +667,7 @@ int romfs_checkmount(struct romfs_mountpt_s *rm) struct geometry geo; int ret; - /* If the fs_mounted flag is FALSE, then we have already handled the loss + /* If the fs_mounted flag is false, then we have already handled the loss * of the mount. */ @@ -688,13 +690,13 @@ int romfs_checkmount(struct romfs_mountpt_s *rm) /* If we get here, the mount is NOT healthy */ - rm->rm_mounted = FALSE; + rm->rm_mounted = false; /* Make sure that this is flagged in every opened file */ for (file = rm->rm_head; file; file = file->rf_next) { - file->rf_open = FALSE; + file->rf_open = false; } } return -ENODEV; @@ -808,13 +810,13 @@ int romfs_finddirentry(struct romfs_mountpt_s *rm, struct romfs_dirinfo_s *dirin * ****************************************************************************/ -int romfs_parsedirentry(struct romfs_mountpt_s *rm, uint32 offset, uint32 *poffset, - uint32 *pnext, uint32 *pinfo, uint32 *psize) +int romfs_parsedirentry(struct romfs_mountpt_s *rm, uint32_t offset, uint32_t *poffset, + uint32_t *pnext, uint32_t *pinfo, uint32_t *psize) { - uint32 save; - uint32 next; - sint16 ndx; - int ret; + uint32_t save; + uint32_t next; + int16_t ndx; + int ret; /* Read the sector into memory */ @@ -859,19 +861,19 @@ int romfs_parsedirentry(struct romfs_mountpt_s *rm, uint32 offset, uint32 *poffs * ****************************************************************************/ -int romfs_parsefilename(struct romfs_mountpt_s *rm, uint32 offset, char *pname) +int romfs_parsefilename(struct romfs_mountpt_s *rm, uint32_t offset, char *pname) { - sint16 ndx; - uint16 namelen; - uint16 chunklen; - boolean done; + int16_t ndx; + uint16_t namelen; + uint16_t chunklen; + bool done; /* Loop until the whole name is obtained or until NAME_MAX characters * of the name have been parsed. */ offset += ROMFS_FHDR_NAME; - for (namelen = 0, done = FALSE; namelen < NAME_MAX && !done;) + for (namelen = 0, done = false; namelen < NAME_MAX && !done;) { /* Read the sector into memory */ @@ -888,7 +890,7 @@ int romfs_parsefilename(struct romfs_mountpt_s *rm, uint32 offset, char *pname) /* Yes.. then this chunk is less than 16 */ chunklen = strlen((char*)&rm->rm_buffer[ndx]); - done = TRUE; + done = true; } else { @@ -902,7 +904,7 @@ int romfs_parsefilename(struct romfs_mountpt_s *rm, uint32 offset, char *pname) if (namelen + chunklen > NAME_MAX) { chunklen = NAME_MAX - namelen; - done = TRUE; + done = true; } /* Copy the chunk */ @@ -926,10 +928,10 @@ int romfs_parsefilename(struct romfs_mountpt_s *rm, uint32 offset, char *pname) * ****************************************************************************/ -int romfs_datastart(struct romfs_mountpt_s *rm, uint32 offset, uint32 *start) +int romfs_datastart(struct romfs_mountpt_s *rm, uint32_t offset, uint32_t *start) { - sint16 ndx; - int ret; + int16_t ndx; + int ret; /* Traverse hardlinks as necesssary to get to the real file header */ |