Skip to content

Commit

Permalink
Revert "fs/mount and fs/romfs: Add support to mount a ROMFS volume us…
Browse files Browse the repository at this point in the history
…ing an MTD driver interface using the standard mount() operation."

This reverts commit 5708a1a.

Signed-off-by: dongjiuzhu1 <[email protected]>
  • Loading branch information
Donny9 authored and xiaoxiang781216 committed Sep 16, 2024
1 parent ace2683 commit d259138
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 73 deletions.
3 changes: 0 additions & 3 deletions fs/mount/fs_mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@ static const struct fsmap_t g_bdfsmap[] =
#ifdef MDFS_SUPPORT
/* File systems that require MTD drivers */

#ifdef CONFIG_FS_ROMFS
extern const struct mountpt_operations g_romfs_operations;
#endif
#ifdef CONFIG_FS_SPIFFS
extern const struct mountpt_operations g_spiffs_operations;
#endif
Expand Down
94 changes: 24 additions & 70 deletions fs/romfs/fs_romfsutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

#include <nuttx/kmalloc.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/mtd/mtd.h>

#include "fs_romfs.h"

Expand Down Expand Up @@ -538,16 +537,8 @@ int romfs_hwread(FAR struct romfs_mountpt_s *rm, FAR uint8_t *buffer,
FAR struct inode *inode = rm->rm_blkdriver;
ssize_t nsectorsread = -ENODEV;

if (INODE_IS_MTD(inode))
{
nsectorsread =
MTD_BREAD(inode->u.i_mtd, sector, nsectors, buffer);
}
else if (inode->u.i_bops->read)
{
nsectorsread =
inode->u.i_bops->read(inode, buffer, sector, nsectors);
}
nsectorsread =
inode->u.i_bops->read(inode, buffer, sector, nsectors);

if (nsectorsread == (ssize_t)nsectors)
{
Expand Down Expand Up @@ -639,6 +630,7 @@ int romfs_filecacheread(FAR struct romfs_mountpt_s *rm,
int romfs_hwconfigure(FAR struct romfs_mountpt_s *rm)
{
FAR struct inode *inode = rm->rm_blkdriver;
struct geometry geo;
int ret;

/* Get the underlying device geometry */
Expand All @@ -650,72 +642,40 @@ int romfs_hwconfigure(FAR struct romfs_mountpt_s *rm)
}
#endif

if (INODE_IS_MTD(inode))
ret = inode->u.i_bops->geometry(inode, &geo);
if (ret != OK)
{
struct mtd_geometry_s mgeo;

ret = MTD_IOCTL(inode->u.i_mtd, MTDIOC_GEOMETRY,
(unsigned long)&mgeo);
if (ret != OK)
{
return ret;
}

/* Save that information in the mount structure */

rm->rm_hwsectorsize = mgeo.blocksize;
rm->rm_hwnsectors = mgeo.neraseblocks *
(mgeo.erasesize / mgeo.blocksize);
return ret;
}
else
{
struct geometry geo;

ret = inode->u.i_bops->geometry(inode, &geo);
if (ret != OK)
{
return ret;
}

if (!geo.geo_available)
{
return -EBUSY;
}
if (!geo.geo_available)
{
return -EBUSY;
}

/* Save that information in the mount structure */
/* Save that information in the mount structure */

rm->rm_hwsectorsize = geo.geo_sectorsize;
rm->rm_hwnsectors = geo.geo_nsectors;
}
rm->rm_hwsectorsize = geo.geo_sectorsize;
rm->rm_hwnsectors = geo.geo_nsectors;

/* Determine if block driver supports the XIP mode of operation */

rm->rm_cachesector = (uint32_t)-1;

if (INODE_IS_MTD(inode))
{
ret = MTD_IOCTL(inode->u.i_mtd, BIOC_XIPBASE,
(unsigned long)&rm->rm_xipbase);
}
else if (inode->u.i_bops->ioctl != NULL)
if (inode->u.i_bops->ioctl)
{
ret = inode->u.i_bops->ioctl(inode, BIOC_XIPBASE,
(unsigned long)&rm->rm_xipbase);
}
else
{
ret = -ENOTSUP;
}

if (ret == OK && rm->rm_xipbase)
{
/* Yes.. Then we will directly access the media (vs.
* copying into an allocated sector buffer.
*/
if (ret == OK && rm->rm_xipbase)
{
/* Yes.. Then we will directly access the media (vs.
* copying into an allocated sector buffer.
*/

rm->rm_buffer = rm->rm_xipbase;
rm->rm_cachesector = 0;
return OK;
rm->rm_buffer = rm->rm_xipbase;
rm->rm_cachesector = 0;
return OK;
}
}

/* Allocate the device cache buffer for normal sector accesses */
Expand Down Expand Up @@ -868,13 +828,7 @@ int romfs_checkmount(FAR struct romfs_mountpt_s *rm)
*/

inode = rm->rm_blkdriver;
if (INODE_IS_MTD(inode))
{
/* It is impossible to remove MTD device */

return OK;
}
else if (inode->u.i_bops->geometry)
if (inode->u.i_bops->geometry)
{
ret = inode->u.i_bops->geometry(inode, &geo);
if (ret == OK && geo.geo_available && !geo.geo_mediachanged)
Expand Down

0 comments on commit d259138

Please sign in to comment.