TMPFS: Reported block size is now configurable
This commit is contained in:
parent
d80bea326f
commit
e675ddb813
2
arch
2
arch
@ -1 +1 @@
|
|||||||
Subproject commit 00acafcbb154a076f60413eb75249c5b68c6c316
|
Subproject commit 07f1151a8039a32ff09fe479869b268dd11ed514
|
@ -14,6 +14,16 @@ config FS_TMPFS
|
|||||||
|
|
||||||
if FS_TMPFS
|
if FS_TMPFS
|
||||||
|
|
||||||
|
config FS_TMPFS_BLOCKSIZE
|
||||||
|
int "Reported block size"
|
||||||
|
default 512
|
||||||
|
---help---
|
||||||
|
Various queries expect the file system to report resources in units
|
||||||
|
of blocks. There are, of course, no blocks with the TMPFS. This
|
||||||
|
options is available to control how sizes are reported. For very
|
||||||
|
small TMPFS systems, you might want to set this to something smaller
|
||||||
|
the the usual 512 bytes.
|
||||||
|
|
||||||
config FS_TMPFS_DIRECTORY_ALLOCGUARD
|
config FS_TMPFS_DIRECTORY_ALLOCGUARD
|
||||||
int "Directory object over-allocation"
|
int "Directory object over-allocation"
|
||||||
default 64
|
default 64
|
||||||
@ -39,6 +49,9 @@ config FS_TMPFS_FILE_ALLOCGUARD
|
|||||||
needed is always allocated. This permits the file to grow without
|
needed is always allocated. This permits the file to grow without
|
||||||
so many realloctions.
|
so many realloctions.
|
||||||
|
|
||||||
|
You will probably want to use smaller value than the default on tiny
|
||||||
|
TMFPS systems.
|
||||||
|
|
||||||
config FS_TMPFS_FILE_FREEGUARD
|
config FS_TMPFS_FILE_FREEGUARD
|
||||||
int "Directory under free"
|
int "Directory under free"
|
||||||
default 1024
|
default 1024
|
||||||
|
@ -2009,17 +2009,21 @@ static int tmpfs_statfs(FAR struct inode *mountpt, FAR struct statfs *buf)
|
|||||||
|
|
||||||
tmpfs_lock(fs);
|
tmpfs_lock(fs);
|
||||||
|
|
||||||
/* Traverse the file system to accurmulate statistics */
|
/* Set up the memory use for the file system and root directory object */
|
||||||
|
|
||||||
tdo = fs->tfs_root;
|
tdo = fs->tfs_root;
|
||||||
inuse = SIZEOF_TMPFS_DIRECTORY(tdo->tdo_nentries);
|
inuse = sizeof(struct tmpfs_s) +
|
||||||
avail = tdo->tdo_alloc - inuse;
|
SIZEOF_TMPFS_DIRECTORY(tdo->tdo_nentries);
|
||||||
|
avail = sizeof(struct tmpfs_s) +
|
||||||
|
tdo->tdo_alloc - inuse;
|
||||||
|
|
||||||
tmpbuf.tsf_alloc = tdo->tdo_alloc;
|
tmpbuf.tsf_alloc = tdo->tdo_alloc;
|
||||||
tmpbuf.tsf_inuse = inuse;
|
tmpbuf.tsf_inuse = inuse;
|
||||||
tmpbuf.tsf_files = 0;
|
tmpbuf.tsf_files = 0;
|
||||||
tmpbuf.tsf_ffree = avail / sizeof(struct tmpfs_dirent_s);
|
tmpbuf.tsf_ffree = avail / sizeof(struct tmpfs_dirent_s);
|
||||||
|
|
||||||
|
/* Traverse the file system to accurmulate statistics */
|
||||||
|
|
||||||
ret = tmpfs_foreach(fs->tfs_root, tmpfs_statfs_callout,
|
ret = tmpfs_foreach(fs->tfs_root, tmpfs_statfs_callout,
|
||||||
(FAR void *)&tmpbuf);
|
(FAR void *)&tmpbuf);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@ -2029,12 +2033,14 @@ static int tmpfs_statfs(FAR struct inode *mountpt, FAR struct statfs *buf)
|
|||||||
|
|
||||||
/* Return something for the file system description */
|
/* Return something for the file system description */
|
||||||
|
|
||||||
blkalloc = (tmpbuf.tsf_alloc + TMPFS_BLOCKSIZE - 1) / TMPFS_BLOCKSIZE;
|
blkalloc = (tmpbuf.tsf_alloc + CONFIG_FS_TMPFS_BLOCKSIZE - 1) /
|
||||||
blkused = (tmpbuf.tsf_inuse + TMPFS_BLOCKSIZE - 1) / TMPFS_BLOCKSIZE;
|
CONFIG_FS_TMPFS_BLOCKSIZE;
|
||||||
|
blkused = (tmpbuf.tsf_inuse + CONFIG_FS_TMPFS_BLOCKSIZE - 1) /
|
||||||
|
CONFIG_FS_TMPFS_BLOCKSIZE;
|
||||||
|
|
||||||
buf->f_type = TMPFS_MAGIC;
|
buf->f_type = TMPFS_MAGIC;
|
||||||
buf->f_namelen = NAME_MAX;
|
buf->f_namelen = NAME_MAX;
|
||||||
buf->f_bsize = TMPFS_BLOCKSIZE;
|
buf->f_bsize = CONFIG_FS_TMPFS_BLOCKSIZE;
|
||||||
buf->f_blocks = blkalloc;
|
buf->f_blocks = blkalloc;
|
||||||
buf->f_bfree = blkalloc - blkused;
|
buf->f_bfree = blkalloc - blkused;
|
||||||
buf->f_bavail = blkalloc - blkused;
|
buf->f_bavail = blkalloc - blkused;
|
||||||
@ -2487,8 +2493,9 @@ static int tmpfs_stat(FAR struct inode *mountpt, FAR const char *relpath,
|
|||||||
/* Fake the rest of the information */
|
/* Fake the rest of the information */
|
||||||
|
|
||||||
buf->st_size = objsize;
|
buf->st_size = objsize;
|
||||||
buf->st_blksize = TMPFS_BLOCKSIZE;
|
buf->st_blksize = CONFIG_FS_TMPFS_BLOCKSIZE;
|
||||||
buf->st_blocks = (objsize + TMPFS_BLOCKSIZE - 1) / TMPFS_BLOCKSIZE;
|
buf->st_blocks = (objsize + CONFIG_FS_TMPFS_BLOCKSIZE - 1) /
|
||||||
|
CONFIG_FS_TMPFS_BLOCKSIZE;
|
||||||
|
|
||||||
/* No... unlock the object and return success */
|
/* No... unlock the object and return success */
|
||||||
|
|
||||||
|
@ -50,10 +50,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
/* This is the block size reported by stat() */
|
|
||||||
|
|
||||||
#define TMPFS_BLOCKSIZE 512
|
|
||||||
|
|
||||||
/* Indicates that there is no holder of the re-entrant semaphore */
|
/* Indicates that there is no holder of the re-entrant semaphore */
|
||||||
|
|
||||||
#define TMPFS_NO_HOLDER -1
|
#define TMPFS_NO_HOLDER -1
|
||||||
|
Loading…
Reference in New Issue
Block a user