~aleteoryx/muditaos

eff6c3f02679b9d755a731a24acd43dedf3f9c72 — Lucjan Bryndza 5 years ago 8545fa3
[EGD-4498] Fix code after code review #1

Fixed some small minor issus in the RO mode in the vfs
M board/rt1051/newlib/include/sys/mount.h => board/rt1051/newlib/include/sys/mount.h +9 -9
@@ 8,15 8,15 @@
   supported  */
enum
{
  MS_RDONLY = 1,		/* Mount read-only.  */
  MS_NOEXEC = 8,		/* Disallow program execution.  */
  MS_SYNCHRONOUS = 16,		/* Writes are synced at once.  */
  MS_REMOUNT = 32,		/* Alter flags of a mounted FS.  */
  MS_MANDLOCK = 64,		/* Allow mandatory locks on an FS.  */
  MS_DIRSYNC = 128,		/* Directory modifications are synchronous.  */
  MS_NOATIME = 1024,		/* Do not update access times.  */
  MS_NODIRATIME = 2048,		/* Do not update directory access times.  */
  MS_BIND = 4096,		/* Bind directory at different place.  */
  MS_RDONLY = 1,                /* Mount read-only.  */
  MS_NOEXEC = 8,                /* Disallow program execution.  */
  MS_SYNCHRONOUS = 16,          /* Writes are synced at once.  */
  MS_REMOUNT = 32,              /* Alter flags of a mounted FS.  */
  MS_MANDLOCK = 64,             /* Allow mandatory locks on an FS.  */
  MS_DIRSYNC = 128,             /* Directory modifications are synchronous.  */
  MS_NOATIME = 1024,            /* Do not update access times.  */
  MS_NODIRATIME = 2048,         /* Do not update directory access times.  */
  MS_BIND = 4096,               /* Bind directory at different place.  */
};



M module-vfs/drivers/src/purefs/fs/filesystem_littlefs.cpp => module-vfs/drivers/src/purefs/fs/filesystem_littlefs.cpp +5 -5
@@ 87,10 87,10 @@ namespace
        return lfs_mode;
    }

    auto translate_attrib_to_st_mode(uint8_t type, bool ro)
    auto translate_attrib_to_st_mode(uint8_t type, bool readOnly)
    {
        decltype(static_cast<struct stat *>(nullptr)->st_mode) mode = S_IRUSR | S_IRGRP | S_IROTH;
        if (!ro) {
        decltype(std::declval<struct stat *>()->st_mode) mode = S_IRUSR | S_IRGRP | S_IROTH;
        if (!readOnly) {
            mode |= S_IWUSR | S_IWGRP | S_IWOTH;
        }
        if (type == LFS_TYPE_REG) {


@@ 102,14 102,14 @@ namespace
        return mode;
    }

    void translate_lfsinfo_to_stat(const ::lfs_info &fs, const lfs_config &cfg, bool ro, struct stat &st)
    void translate_lfsinfo_to_stat(const ::lfs_info &fs, const lfs_config &cfg, bool readOnly, struct stat &st)
    {
        std::memset(&st, 0, sizeof st);
        st.st_nlink   = 1;
        st.st_size    = fs.size;
        st.st_blksize = cfg.block_size;
        st.st_blocks  = fs.size / cfg.block_count;
        st.st_mode    = translate_attrib_to_st_mode(fs.type, ro);
        st.st_mode    = translate_attrib_to_st_mode(fs.type, readOnly);
    }

    [[gnu::nonnull(1)]] int setup_lfs_config(lfs_config *cfg, size_t sector_size, size_t part_sectors_count)

M module-vfs/src/purefs/fs/filesystem.cpp => module-vfs/src/purefs/fs/filesystem.cpp +4 -1
@@ 69,12 69,15 @@ namespace purefs::fs
            LOG_ERROR("VFS: Invalid target mountpoint path %.*s", int(target.length()), target.data());
            return -EINVAL;
        }
        if (flags & ~(mount_flags::remount | mount_flags::read_only)) {
            LOG_ERROR("VFS: passed mount flags is not supported");
            return -ENOTSUP;
        }
        {
            cpp_freertos::LockGuard _lock(*m_lock);
            const auto mpi = m_mounts.find(std::string(target));
            if (mpi != std::end(m_mounts)) {
                if (flags & mount_flags::remount) {
                    // NOTE: Currently only RO is supported
                    mpi->second->modify_flags(flags & ~mount_flags::remount);
                    return {};
                }