2021-11-30 13:00:03 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* fs/rpmsgfs/rpmsgfs.c
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/statfs.h>
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <debug.h>
|
|
|
|
#include <limits.h>
|
|
|
|
|
2023-08-08 00:11:20 +02:00
|
|
|
#include <nuttx/lib/lib.h>
|
2022-09-06 08:18:45 +02:00
|
|
|
#include <nuttx/mutex.h>
|
2021-11-30 13:00:03 +01:00
|
|
|
#include <nuttx/fs/fs.h>
|
|
|
|
#include <nuttx/fs/ioctl.h>
|
2023-10-25 05:08:56 +02:00
|
|
|
#include <nuttx/signal.h>
|
2021-11-30 13:00:03 +01:00
|
|
|
|
|
|
|
#include "rpmsgfs.h"
|
|
|
|
|
2022-01-05 15:09:47 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#define RPMSGFS_RETRY_DELAY_MS 10
|
|
|
|
|
2021-11-30 13:00:03 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Private Types
|
|
|
|
****************************************************************************/
|
|
|
|
|
2022-08-05 06:31:25 +02:00
|
|
|
struct rpmsgfs_dir_s
|
|
|
|
{
|
|
|
|
struct fs_dirent_s base;
|
|
|
|
FAR void *dir;
|
|
|
|
};
|
|
|
|
|
2021-11-30 13:00:03 +01:00
|
|
|
/* This structure describes the state of one open file. This structure
|
|
|
|
* is protected by the volume semaphore.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct rpmsgfs_ofile_s
|
|
|
|
{
|
|
|
|
struct rpmsgfs_ofile_s *fnext; /* Supports a singly linked list */
|
|
|
|
int16_t crefs; /* Reference count */
|
|
|
|
mode_t oflags; /* Open mode */
|
|
|
|
int fd;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* This structure represents the overall mountpoint state. An instance of
|
|
|
|
* this structure is retained as inode private data on each mountpoint that
|
|
|
|
* is mounted with a rpmsgfs filesystem.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct rpmsgfs_mountpt_s
|
|
|
|
{
|
2022-09-06 08:18:45 +02:00
|
|
|
mutex_t fs_lock; /* Assure thread-safe access */
|
2021-11-30 13:00:03 +01:00
|
|
|
FAR struct rpmsgfs_ofile_s *fs_head; /* Singly-linked list of open files */
|
|
|
|
char fs_root[PATH_MAX];
|
|
|
|
void *handle;
|
2022-01-05 15:09:47 +01:00
|
|
|
int timeout; /* Connect timeout */
|
2021-11-30 13:00:03 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int rpmsgfs_open(FAR struct file *filep, FAR const char *relpath,
|
|
|
|
int oflags, mode_t mode);
|
|
|
|
static int rpmsgfs_close(FAR struct file *filep);
|
|
|
|
static ssize_t rpmsgfs_read(FAR struct file *filep, FAR char *buffer,
|
|
|
|
size_t buflen);
|
|
|
|
static ssize_t rpmsgfs_write(FAR struct file *filep, FAR const char *buffer,
|
|
|
|
size_t buflen);
|
|
|
|
static off_t rpmsgfs_seek(FAR struct file *filep, off_t offset,
|
|
|
|
int whence);
|
|
|
|
static int rpmsgfs_ioctl(FAR struct file *filep, int cmd,
|
|
|
|
unsigned long arg);
|
|
|
|
|
|
|
|
static int rpmsgfs_sync(FAR struct file *filep);
|
|
|
|
static int rpmsgfs_dup(FAR const struct file *oldp,
|
|
|
|
FAR struct file *newp);
|
|
|
|
static int rpmsgfs_fstat(FAR const struct file *filep,
|
|
|
|
FAR struct stat *buf);
|
|
|
|
static int rpmsgfs_fchstat(FAR const struct file *filep,
|
|
|
|
FAR const struct stat *buf, int flags);
|
2023-01-02 18:27:25 +01:00
|
|
|
static int rpmsgfs_truncate(FAR struct file *filep,
|
2021-11-30 13:00:03 +01:00
|
|
|
off_t length);
|
|
|
|
|
|
|
|
static int rpmsgfs_opendir(FAR struct inode *mountpt,
|
|
|
|
FAR const char *relpath,
|
2022-08-05 06:31:25 +02:00
|
|
|
FAR struct fs_dirent_s **dir);
|
2021-11-30 13:00:03 +01:00
|
|
|
static int rpmsgfs_closedir(FAR struct inode *mountpt,
|
|
|
|
FAR struct fs_dirent_s *dir);
|
|
|
|
static int rpmsgfs_readdir(FAR struct inode *mountpt,
|
2022-07-26 08:56:41 +02:00
|
|
|
FAR struct fs_dirent_s *dir,
|
|
|
|
FAR struct dirent *entry);
|
2021-11-30 13:00:03 +01:00
|
|
|
static int rpmsgfs_rewinddir(FAR struct inode *mountpt,
|
|
|
|
FAR struct fs_dirent_s *dir);
|
|
|
|
|
|
|
|
static int rpmsgfs_bind(FAR struct inode *blkdriver,
|
|
|
|
FAR const void *data, FAR void **handle);
|
|
|
|
static int rpmsgfs_unbind(FAR void *handle, FAR struct inode **blkdriver,
|
|
|
|
unsigned int flags);
|
|
|
|
static int rpmsgfs_statfs(FAR struct inode *mountpt,
|
|
|
|
FAR struct statfs *buf);
|
|
|
|
|
|
|
|
static int rpmsgfs_unlink(FAR struct inode *mountpt,
|
|
|
|
FAR const char *relpath);
|
|
|
|
static int rpmsgfs_mkdir(FAR struct inode *mountpt,
|
|
|
|
FAR const char *relpath, mode_t mode);
|
|
|
|
static int rpmsgfs_rmdir(FAR struct inode *mountpt, const char *relpath);
|
|
|
|
static int rpmsgfs_rename(FAR struct inode *mountpt,
|
|
|
|
FAR const char *oldrelpath,
|
|
|
|
FAR const char *newrelpath);
|
|
|
|
static int rpmsgfs_stat(FAR struct inode *mountpt,
|
|
|
|
FAR const char *relpath, FAR struct stat *buf);
|
|
|
|
static int rpmsgfs_chstat(FAR struct inode *mountpt,
|
|
|
|
FAR const char *relpath,
|
|
|
|
FAR const struct stat *buf, int flags);
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/* See fs_mount.c -- this structure is explicitly externed there.
|
|
|
|
* We use the old-fashioned kind of initializers so that this will compile
|
|
|
|
* with any compiler.
|
|
|
|
*/
|
|
|
|
|
2023-04-22 16:53:42 +02:00
|
|
|
const struct mountpt_operations g_rpmsgfs_operations =
|
2021-11-30 13:00:03 +01:00
|
|
|
{
|
|
|
|
rpmsgfs_open, /* open */
|
|
|
|
rpmsgfs_close, /* close */
|
|
|
|
rpmsgfs_read, /* read */
|
|
|
|
rpmsgfs_write, /* write */
|
|
|
|
rpmsgfs_seek, /* seek */
|
|
|
|
rpmsgfs_ioctl, /* ioctl */
|
2023-01-02 14:02:51 +01:00
|
|
|
NULL, /* mmap */
|
2023-01-02 18:27:25 +01:00
|
|
|
rpmsgfs_truncate, /* truncate */
|
2023-11-25 13:11:03 +01:00
|
|
|
NULL, /* poll */
|
2021-11-30 13:00:03 +01:00
|
|
|
|
|
|
|
rpmsgfs_sync, /* sync */
|
|
|
|
rpmsgfs_dup, /* dup */
|
|
|
|
rpmsgfs_fstat, /* fstat */
|
|
|
|
rpmsgfs_fchstat, /* fchstat */
|
|
|
|
|
|
|
|
rpmsgfs_opendir, /* opendir */
|
|
|
|
rpmsgfs_closedir, /* closedir */
|
|
|
|
rpmsgfs_readdir, /* readdir */
|
|
|
|
rpmsgfs_rewinddir, /* rewinddir */
|
|
|
|
|
|
|
|
rpmsgfs_bind, /* bind */
|
|
|
|
rpmsgfs_unbind, /* unbind */
|
|
|
|
rpmsgfs_statfs, /* statfs */
|
|
|
|
|
|
|
|
rpmsgfs_unlink, /* unlink */
|
|
|
|
rpmsgfs_mkdir, /* mkdir */
|
|
|
|
rpmsgfs_rmdir, /* rmdir */
|
|
|
|
rpmsgfs_rename, /* rename */
|
|
|
|
rpmsgfs_stat, /* stat */
|
|
|
|
rpmsgfs_chstat, /* chstat */
|
|
|
|
};
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: rpmsgfs_mkpath
|
|
|
|
*
|
|
|
|
* Description: Build absolute host path from relative NuttX path.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2022-01-05 15:09:47 +01:00
|
|
|
static void rpmsgfs_mkpath(FAR struct rpmsgfs_mountpt_s *fs,
|
2021-11-30 13:00:03 +01:00
|
|
|
FAR const char *relpath,
|
|
|
|
FAR char *path, int pathlen)
|
|
|
|
{
|
|
|
|
int depth = 0;
|
|
|
|
int first;
|
|
|
|
int x;
|
|
|
|
|
|
|
|
/* Copy base host path to output */
|
|
|
|
|
2021-12-29 13:17:34 +01:00
|
|
|
strlcpy(path, fs->fs_root, pathlen);
|
2021-11-30 13:00:03 +01:00
|
|
|
|
|
|
|
/* Be sure we aren't trying to use ".." to display outside of our
|
|
|
|
* mounted path.
|
|
|
|
*/
|
|
|
|
|
|
|
|
x = 0;
|
|
|
|
while (relpath[x] == '/')
|
|
|
|
{
|
|
|
|
x++;
|
|
|
|
}
|
|
|
|
|
|
|
|
first = x;
|
|
|
|
|
|
|
|
while (relpath[x] != '\0')
|
|
|
|
{
|
|
|
|
/* Test for ".." occurrence */
|
|
|
|
|
|
|
|
if (strncmp(&relpath[x], "..", 2) == 0)
|
|
|
|
{
|
|
|
|
/* Reduce depth by 1 */
|
|
|
|
|
|
|
|
depth--;
|
|
|
|
x += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (relpath[x] == '/' && relpath[x + 1] != '/' &&
|
|
|
|
relpath[x + 1] != '\0')
|
|
|
|
{
|
|
|
|
depth++;
|
|
|
|
x++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (depth >= 0)
|
|
|
|
{
|
2023-03-05 18:35:34 +01:00
|
|
|
strlcat(path, &relpath[first], pathlen - strlen(path));
|
2021-11-30 13:00:03 +01:00
|
|
|
}
|
2022-01-05 15:09:47 +01:00
|
|
|
|
|
|
|
while (fs->timeout > 0)
|
|
|
|
{
|
|
|
|
struct stat buf;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = rpmsgfs_client_stat(fs->handle, fs->fs_root, &buf);
|
|
|
|
if (ret == 0)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-10-25 05:08:56 +02:00
|
|
|
nxsig_usleep(RPMSGFS_RETRY_DELAY_MS * USEC_PER_MSEC);
|
2022-01-05 15:09:47 +01:00
|
|
|
fs->timeout -= RPMSGFS_RETRY_DELAY_MS;
|
|
|
|
}
|
2021-11-30 13:00:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: rpmsgfs_open
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int rpmsgfs_open(FAR struct file *filep, FAR const char *relpath,
|
|
|
|
int oflags, mode_t mode)
|
|
|
|
{
|
|
|
|
FAR struct inode *inode;
|
|
|
|
FAR struct rpmsgfs_mountpt_s *fs;
|
|
|
|
FAR struct rpmsgfs_ofile_s *hf;
|
|
|
|
char path[PATH_MAX];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Sanity checks */
|
|
|
|
|
|
|
|
DEBUGASSERT((filep->f_priv == NULL) && (filep->f_inode != NULL));
|
|
|
|
|
|
|
|
/* Get the mountpoint inode reference from the file structure and the
|
|
|
|
* mountpoint private data from the inode structure
|
|
|
|
*/
|
|
|
|
|
|
|
|
inode = filep->f_inode;
|
|
|
|
fs = inode->i_private;
|
|
|
|
|
|
|
|
DEBUGASSERT(fs != NULL);
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
/* Take the lock */
|
2021-11-30 13:00:03 +01:00
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
ret = nxmutex_lock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate memory for the open file */
|
|
|
|
|
2023-08-28 09:39:47 +02:00
|
|
|
hf = kmm_malloc(sizeof *hf);
|
2021-11-30 13:00:03 +01:00
|
|
|
if (hf == NULL)
|
|
|
|
{
|
|
|
|
ret = -ENOMEM;
|
2022-09-06 08:18:45 +02:00
|
|
|
goto errout_with_lock;
|
2021-11-30 13:00:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Append to the host's root directory */
|
|
|
|
|
|
|
|
rpmsgfs_mkpath(fs, relpath, path, sizeof(path));
|
|
|
|
|
|
|
|
/* Try to open the file in the host file system */
|
|
|
|
|
|
|
|
hf->fd = rpmsgfs_client_open(fs->handle, path, oflags, mode);
|
|
|
|
if (hf->fd < 0)
|
|
|
|
{
|
|
|
|
/* Error opening file */
|
|
|
|
|
|
|
|
ret = -EBADF;
|
|
|
|
goto errout_with_buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* In write/append mode, we need to set the file pointer to the end of the
|
|
|
|
* file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ((oflags & (O_APPEND | O_WRONLY)) == (O_APPEND | O_WRONLY))
|
|
|
|
{
|
|
|
|
ret = rpmsgfs_client_lseek(fs->handle, hf->fd, 0, SEEK_END);
|
|
|
|
if (ret >= 0)
|
|
|
|
{
|
|
|
|
filep->f_pos = ret;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
goto errout_with_buffer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Attach the private date to the struct file instance */
|
|
|
|
|
|
|
|
filep->f_priv = hf;
|
|
|
|
|
|
|
|
/* Then insert the new instance into the mountpoint structure.
|
|
|
|
* It needs to be there (1) to handle error conditions that effect
|
|
|
|
* all files, and (2) to inform the umount logic that we are busy
|
|
|
|
* (but a simple reference count could have done that).
|
|
|
|
*/
|
|
|
|
|
|
|
|
hf->fnext = fs->fs_head;
|
|
|
|
hf->crefs = 1;
|
|
|
|
hf->oflags = oflags;
|
|
|
|
fs->fs_head = hf;
|
|
|
|
|
|
|
|
ret = OK;
|
2022-09-06 08:18:45 +02:00
|
|
|
goto errout_with_lock;
|
2021-11-30 13:00:03 +01:00
|
|
|
|
|
|
|
errout_with_buffer:
|
|
|
|
kmm_free(hf);
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
errout_with_lock:
|
|
|
|
nxmutex_unlock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
if (ret == -EINVAL)
|
|
|
|
{
|
|
|
|
ret = -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: rpmsgfs_close
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int rpmsgfs_close(FAR struct file *filep)
|
|
|
|
{
|
|
|
|
FAR struct inode *inode;
|
|
|
|
FAR struct rpmsgfs_mountpt_s *fs;
|
|
|
|
FAR struct rpmsgfs_ofile_s *hf;
|
|
|
|
FAR struct rpmsgfs_ofile_s *nextfile;
|
|
|
|
FAR struct rpmsgfs_ofile_s *prevfile;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Sanity checks */
|
|
|
|
|
2023-08-28 11:17:05 +02:00
|
|
|
DEBUGASSERT(filep->f_priv != NULL);
|
2021-11-30 13:00:03 +01:00
|
|
|
|
|
|
|
/* Recover our private data from the struct file instance */
|
|
|
|
|
|
|
|
inode = filep->f_inode;
|
|
|
|
fs = inode->i_private;
|
|
|
|
hf = filep->f_priv;
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
/* Take the lock */
|
2021-11-30 13:00:03 +01:00
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
ret = nxmutex_lock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if we are the last one with a reference to the file and
|
|
|
|
* only close if we are.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (hf->crefs > 1)
|
|
|
|
{
|
|
|
|
/* The file is opened more than once. Just decrement the
|
|
|
|
* reference count and return.
|
|
|
|
*/
|
|
|
|
|
|
|
|
hf->crefs--;
|
|
|
|
goto okout;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Remove ourselves from the linked list */
|
|
|
|
|
|
|
|
nextfile = fs->fs_head;
|
|
|
|
prevfile = nextfile;
|
|
|
|
while ((nextfile != hf) && (nextfile != NULL))
|
|
|
|
{
|
|
|
|
/* Save the previous file pointer too */
|
|
|
|
|
|
|
|
prevfile = nextfile;
|
|
|
|
nextfile = nextfile->fnext;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nextfile != NULL)
|
|
|
|
{
|
|
|
|
/* Test if we were the first entry */
|
|
|
|
|
|
|
|
if (nextfile == fs->fs_head)
|
|
|
|
{
|
|
|
|
/* Assign a new head */
|
|
|
|
|
|
|
|
fs->fs_head = nextfile->fnext;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Take ourselves out of the list */
|
|
|
|
|
|
|
|
prevfile->fnext = nextfile->fnext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Close the host file */
|
|
|
|
|
|
|
|
rpmsgfs_client_close(fs->handle, hf->fd);
|
|
|
|
|
|
|
|
/* Now free the pointer */
|
|
|
|
|
|
|
|
filep->f_priv = NULL;
|
|
|
|
kmm_free(hf);
|
|
|
|
|
|
|
|
okout:
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_unlock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: rpmsgfs_read
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static ssize_t rpmsgfs_read(FAR struct file *filep, FAR char *buffer,
|
|
|
|
size_t buflen)
|
|
|
|
{
|
|
|
|
FAR struct inode *inode;
|
|
|
|
FAR struct rpmsgfs_mountpt_s *fs;
|
|
|
|
FAR struct rpmsgfs_ofile_s *hf;
|
|
|
|
ssize_t ret;
|
|
|
|
|
|
|
|
/* Sanity checks */
|
|
|
|
|
2023-08-28 11:17:05 +02:00
|
|
|
DEBUGASSERT(filep->f_priv != NULL);
|
2021-11-30 13:00:03 +01:00
|
|
|
|
|
|
|
/* Recover our private data from the struct file instance */
|
|
|
|
|
|
|
|
hf = filep->f_priv;
|
|
|
|
inode = filep->f_inode;
|
|
|
|
fs = inode->i_private;
|
|
|
|
|
|
|
|
DEBUGASSERT(fs != NULL);
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
/* Take the lock */
|
2021-11-30 13:00:03 +01:00
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
ret = nxmutex_lock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call the host to perform the read */
|
|
|
|
|
|
|
|
ret = rpmsgfs_client_read(fs->handle, hf->fd, buffer, buflen);
|
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
filep->f_pos += ret;
|
|
|
|
}
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_unlock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: rpmsgfs_write
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static ssize_t rpmsgfs_write(FAR struct file *filep, const char *buffer,
|
|
|
|
size_t buflen)
|
|
|
|
{
|
|
|
|
FAR struct inode *inode;
|
|
|
|
FAR struct rpmsgfs_mountpt_s *fs;
|
|
|
|
FAR struct rpmsgfs_ofile_s *hf;
|
|
|
|
ssize_t ret;
|
|
|
|
|
2023-08-28 11:17:05 +02:00
|
|
|
DEBUGASSERT(filep->f_priv != NULL);
|
2021-11-30 13:00:03 +01:00
|
|
|
|
|
|
|
/* Recover our private data from the struct file instance */
|
|
|
|
|
|
|
|
hf = filep->f_priv;
|
|
|
|
inode = filep->f_inode;
|
|
|
|
fs = inode->i_private;
|
|
|
|
|
|
|
|
DEBUGASSERT(fs != NULL);
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
/* Take the lock */
|
2021-11-30 13:00:03 +01:00
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
ret = nxmutex_lock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Test the permissions. Only allow write if the file was opened with
|
|
|
|
* write flags.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ((hf->oflags & O_WROK) == 0)
|
|
|
|
{
|
|
|
|
ret = -EACCES;
|
2022-09-06 08:18:45 +02:00
|
|
|
goto errout_with_lock;
|
2021-11-30 13:00:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Call the host to perform the write */
|
|
|
|
|
|
|
|
ret = rpmsgfs_client_write(fs->handle, hf->fd, buffer, buflen);
|
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
filep->f_pos += ret;
|
|
|
|
}
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
errout_with_lock:
|
|
|
|
nxmutex_unlock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: rpmsgfs_seek
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static off_t rpmsgfs_seek(FAR struct file *filep, off_t offset, int whence)
|
|
|
|
{
|
|
|
|
FAR struct inode *inode;
|
|
|
|
FAR struct rpmsgfs_mountpt_s *fs;
|
|
|
|
FAR struct rpmsgfs_ofile_s *hf;
|
|
|
|
off_t ret;
|
|
|
|
|
|
|
|
/* Sanity checks */
|
|
|
|
|
2023-08-28 11:17:05 +02:00
|
|
|
DEBUGASSERT(filep->f_priv != NULL);
|
2021-11-30 13:00:03 +01:00
|
|
|
|
|
|
|
/* Recover our private data from the struct file instance */
|
|
|
|
|
|
|
|
hf = filep->f_priv;
|
|
|
|
inode = filep->f_inode;
|
|
|
|
fs = inode->i_private;
|
|
|
|
|
|
|
|
DEBUGASSERT(fs != NULL);
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
/* Take the lock */
|
2021-11-30 13:00:03 +01:00
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
ret = nxmutex_lock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call our internal routine to perform the seek */
|
|
|
|
|
|
|
|
ret = rpmsgfs_client_lseek(fs->handle, hf->fd, offset, whence);
|
|
|
|
if (ret >= 0)
|
|
|
|
{
|
|
|
|
filep->f_pos = ret;
|
|
|
|
}
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_unlock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: rpmsgfs_ioctl
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int rpmsgfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|
|
|
{
|
|
|
|
FAR struct inode *inode;
|
|
|
|
FAR struct rpmsgfs_mountpt_s *fs;
|
|
|
|
FAR struct rpmsgfs_ofile_s *hf;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Sanity checks */
|
|
|
|
|
2023-08-28 11:17:05 +02:00
|
|
|
DEBUGASSERT(filep->f_priv != NULL);
|
2021-11-30 13:00:03 +01:00
|
|
|
|
|
|
|
/* Recover our private data from the struct file instance */
|
|
|
|
|
|
|
|
hf = filep->f_priv;
|
|
|
|
inode = filep->f_inode;
|
|
|
|
fs = inode->i_private;
|
|
|
|
|
|
|
|
DEBUGASSERT(fs != NULL);
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
/* Take the lock */
|
2021-11-30 13:00:03 +01:00
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
ret = nxmutex_lock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call our internal routine to perform the ioctl */
|
|
|
|
|
|
|
|
ret = rpmsgfs_client_ioctl(fs->handle, hf->fd, cmd, arg);
|
2022-08-12 14:35:02 +02:00
|
|
|
if (ret == 0 && (cmd == FIONBIO || cmd == FIOCLEX || cmd == FIONCLEX))
|
|
|
|
{
|
|
|
|
ret = -ENOTTY;
|
|
|
|
}
|
2021-11-30 13:00:03 +01:00
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_unlock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: rpmsgfs_sync
|
|
|
|
*
|
|
|
|
* Description: Synchronize the file state on disk to match internal, in-
|
|
|
|
* memory state.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int rpmsgfs_sync(FAR struct file *filep)
|
|
|
|
{
|
|
|
|
FAR struct inode *inode;
|
|
|
|
FAR struct rpmsgfs_mountpt_s *fs;
|
|
|
|
FAR struct rpmsgfs_ofile_s *hf;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Sanity checks */
|
|
|
|
|
2023-08-28 11:17:05 +02:00
|
|
|
DEBUGASSERT(filep->f_priv != NULL);
|
2021-11-30 13:00:03 +01:00
|
|
|
|
|
|
|
/* Recover our private data from the struct file instance */
|
|
|
|
|
|
|
|
hf = filep->f_priv;
|
|
|
|
inode = filep->f_inode;
|
|
|
|
fs = inode->i_private;
|
|
|
|
|
|
|
|
DEBUGASSERT(fs != NULL);
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
/* Take the lock */
|
2021-11-30 13:00:03 +01:00
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
ret = nxmutex_lock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
rpmsgfs_client_sync(fs->handle, hf->fd);
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_unlock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: rpmsgfs_dup
|
|
|
|
*
|
|
|
|
* Description: Duplicate open file data in the new file structure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int rpmsgfs_dup(FAR const struct file *oldp, FAR struct file *newp)
|
|
|
|
{
|
|
|
|
FAR struct rpmsgfs_ofile_s *sf;
|
|
|
|
|
|
|
|
/* Sanity checks */
|
|
|
|
|
|
|
|
DEBUGASSERT(oldp->f_priv != NULL &&
|
|
|
|
newp->f_priv == NULL &&
|
|
|
|
newp->f_inode != NULL);
|
|
|
|
|
|
|
|
/* Recover our private data from the struct file instance */
|
|
|
|
|
|
|
|
sf = oldp->f_priv;
|
|
|
|
|
|
|
|
DEBUGASSERT(sf != NULL);
|
|
|
|
|
|
|
|
/* Just increment the reference count on the ofile */
|
|
|
|
|
|
|
|
sf->crefs++;
|
|
|
|
newp->f_priv = (FAR void *)sf;
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: rpmsgfs_fstat
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Obtain information about an open file associated with the file
|
|
|
|
* descriptor 'fd', and will write it to the area pointed to by 'buf'.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int rpmsgfs_fstat(FAR const struct file *filep, FAR struct stat *buf)
|
|
|
|
{
|
|
|
|
FAR struct inode *inode;
|
|
|
|
FAR struct rpmsgfs_mountpt_s *fs;
|
|
|
|
FAR struct rpmsgfs_ofile_s *hf;
|
|
|
|
int ret = OK;
|
|
|
|
|
|
|
|
/* Sanity checks */
|
|
|
|
|
2023-08-28 11:17:05 +02:00
|
|
|
DEBUGASSERT(buf != NULL);
|
2021-11-30 13:00:03 +01:00
|
|
|
|
|
|
|
/* Recover our private data from the struct file instance */
|
|
|
|
|
2023-08-28 11:17:05 +02:00
|
|
|
DEBUGASSERT(filep->f_priv != NULL);
|
2021-11-30 13:00:03 +01:00
|
|
|
hf = filep->f_priv;
|
|
|
|
inode = filep->f_inode;
|
|
|
|
|
|
|
|
fs = inode->i_private;
|
|
|
|
DEBUGASSERT(fs != NULL);
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
/* Take the lock */
|
2021-11-30 13:00:03 +01:00
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
ret = nxmutex_lock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call the host to perform the read */
|
|
|
|
|
|
|
|
ret = rpmsgfs_client_fstat(fs->handle, hf->fd, buf);
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_unlock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: rpmsgfs_fchstat
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Change information about an open file associated with the file
|
|
|
|
* descriptor 'fd'.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int rpmsgfs_fchstat(FAR const struct file *filep,
|
|
|
|
FAR const struct stat *buf, int flags)
|
|
|
|
{
|
|
|
|
FAR struct inode *inode;
|
|
|
|
FAR struct rpmsgfs_mountpt_s *fs;
|
|
|
|
FAR struct rpmsgfs_ofile_s *hf;
|
|
|
|
int ret = OK;
|
|
|
|
|
|
|
|
/* Sanity checks */
|
|
|
|
|
2023-08-28 11:17:05 +02:00
|
|
|
DEBUGASSERT(buf != NULL);
|
2021-11-30 13:00:03 +01:00
|
|
|
|
|
|
|
/* Recover our private data from the struct file instance */
|
|
|
|
|
2023-08-28 11:17:05 +02:00
|
|
|
DEBUGASSERT(filep->f_priv != NULL);
|
2021-11-30 13:00:03 +01:00
|
|
|
hf = filep->f_priv;
|
|
|
|
inode = filep->f_inode;
|
|
|
|
|
|
|
|
fs = inode->i_private;
|
|
|
|
DEBUGASSERT(fs != NULL);
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
/* Take the lock */
|
2021-11-30 13:00:03 +01:00
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
ret = nxmutex_lock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call the host to perform the change */
|
|
|
|
|
|
|
|
ret = rpmsgfs_client_fchstat(fs->handle, hf->fd, buf, flags);
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_unlock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
2023-01-02 18:27:25 +01:00
|
|
|
* Name: rpmsgfs_truncate
|
2021-11-30 13:00:03 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Set the length of the open, regular file associated with the file
|
|
|
|
* structure 'filep' to 'length'.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2023-01-02 18:27:25 +01:00
|
|
|
static int rpmsgfs_truncate(FAR struct file *filep, off_t length)
|
2021-11-30 13:00:03 +01:00
|
|
|
{
|
|
|
|
FAR struct inode *inode;
|
|
|
|
FAR struct rpmsgfs_mountpt_s *fs;
|
|
|
|
FAR struct rpmsgfs_ofile_s *hf;
|
|
|
|
int ret = OK;
|
|
|
|
|
|
|
|
/* Recover our private data from the struct file instance */
|
|
|
|
|
2023-08-28 11:17:05 +02:00
|
|
|
DEBUGASSERT(filep->f_priv != NULL);
|
2021-11-30 13:00:03 +01:00
|
|
|
hf = filep->f_priv;
|
|
|
|
inode = filep->f_inode;
|
|
|
|
|
|
|
|
fs = inode->i_private;
|
|
|
|
DEBUGASSERT(fs != NULL);
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
/* Take the lock */
|
2021-11-30 13:00:03 +01:00
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
ret = nxmutex_lock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call the host to perform the truncate */
|
|
|
|
|
|
|
|
ret = rpmsgfs_client_ftruncate(fs->handle, hf->fd, length);
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_unlock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: rpmsgfs_opendir
|
|
|
|
*
|
|
|
|
* Description: Open a directory for read access
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int rpmsgfs_opendir(FAR struct inode *mountpt,
|
|
|
|
FAR const char *relpath,
|
2022-08-05 06:31:25 +02:00
|
|
|
FAR struct fs_dirent_s **dir)
|
2021-11-30 13:00:03 +01:00
|
|
|
{
|
|
|
|
FAR struct rpmsgfs_mountpt_s *fs;
|
2022-08-05 06:31:25 +02:00
|
|
|
FAR struct rpmsgfs_dir_s *rdir;
|
2021-11-30 13:00:03 +01:00
|
|
|
char path[PATH_MAX];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Sanity checks */
|
|
|
|
|
|
|
|
DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL);
|
|
|
|
|
|
|
|
/* Recover our private data from the inode instance */
|
|
|
|
|
|
|
|
fs = mountpt->i_private;
|
2022-08-05 06:31:25 +02:00
|
|
|
rdir = kmm_zalloc(sizeof(struct rpmsgfs_dir_s));
|
|
|
|
if (rdir == NULL)
|
|
|
|
{
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2021-11-30 13:00:03 +01:00
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
/* Take the lock */
|
2021-11-30 13:00:03 +01:00
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
ret = nxmutex_lock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
2022-08-05 06:31:25 +02:00
|
|
|
goto errout_with_rdir;
|
2021-11-30 13:00:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Append to the host's root directory */
|
|
|
|
|
|
|
|
rpmsgfs_mkpath(fs, relpath, path, sizeof(path));
|
|
|
|
|
|
|
|
/* Call the host's opendir function */
|
|
|
|
|
2022-08-05 06:31:25 +02:00
|
|
|
rdir->dir = rpmsgfs_client_opendir(fs->handle, path);
|
|
|
|
if (rdir->dir == NULL)
|
2021-11-30 13:00:03 +01:00
|
|
|
{
|
|
|
|
ret = -ENOENT;
|
2022-09-06 08:18:45 +02:00
|
|
|
goto errout_with_lock;
|
2021-11-30 13:00:03 +01:00
|
|
|
}
|
|
|
|
|
2022-08-05 06:31:25 +02:00
|
|
|
*dir = (FAR struct fs_dirent_s *)rdir;
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_unlock(&fs->fs_lock);
|
2022-08-05 06:31:25 +02:00
|
|
|
return OK;
|
2021-11-30 13:00:03 +01:00
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
errout_with_lock:
|
|
|
|
nxmutex_unlock(&fs->fs_lock);
|
2022-08-05 06:31:25 +02:00
|
|
|
|
|
|
|
errout_with_rdir:
|
|
|
|
kmm_free(rdir);
|
2021-11-30 13:00:03 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: rpmsgfs_closedir
|
|
|
|
*
|
|
|
|
* Description: Open a directory for read access
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int rpmsgfs_closedir(FAR struct inode *mountpt,
|
|
|
|
FAR struct fs_dirent_s *dir)
|
|
|
|
{
|
2022-08-05 06:31:25 +02:00
|
|
|
FAR struct rpmsgfs_mountpt_s *fs;
|
|
|
|
FAR struct rpmsgfs_dir_s *rdir;
|
2021-11-30 13:00:03 +01:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Sanity checks */
|
|
|
|
|
|
|
|
DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL);
|
|
|
|
|
|
|
|
/* Recover our private data from the inode instance */
|
|
|
|
|
|
|
|
fs = mountpt->i_private;
|
2022-08-05 06:31:25 +02:00
|
|
|
rdir = (FAR struct rpmsgfs_dir_s *)dir;
|
2021-11-30 13:00:03 +01:00
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
/* Take the lock */
|
2021-11-30 13:00:03 +01:00
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
ret = nxmutex_lock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call the host's closedir function */
|
|
|
|
|
2022-08-05 06:31:25 +02:00
|
|
|
rpmsgfs_client_closedir(fs->handle, rdir->dir);
|
2021-11-30 13:00:03 +01:00
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_unlock(&fs->fs_lock);
|
2022-08-05 06:31:25 +02:00
|
|
|
kmm_free(rdir);
|
2021-11-30 13:00:03 +01:00
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: rpmsgfs_readdir
|
|
|
|
*
|
|
|
|
* Description: Read the next directory entry
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int rpmsgfs_readdir(FAR struct inode *mountpt,
|
2022-07-26 08:56:41 +02:00
|
|
|
FAR struct fs_dirent_s *dir,
|
|
|
|
FAR struct dirent *entry)
|
2021-11-30 13:00:03 +01:00
|
|
|
{
|
|
|
|
FAR struct rpmsgfs_mountpt_s *fs;
|
2022-08-05 06:31:25 +02:00
|
|
|
FAR struct rpmsgfs_dir_s *rdir;
|
2021-11-30 13:00:03 +01:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Sanity checks */
|
|
|
|
|
|
|
|
DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL);
|
|
|
|
|
|
|
|
/* Recover our private data from the inode instance */
|
|
|
|
|
|
|
|
fs = mountpt->i_private;
|
2022-08-05 06:31:25 +02:00
|
|
|
rdir = (FAR struct rpmsgfs_dir_s *)dir;
|
2021-11-30 13:00:03 +01:00
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
/* Take the lock */
|
2021-11-30 13:00:03 +01:00
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
ret = nxmutex_lock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call the host OS's readdir function */
|
|
|
|
|
2022-08-05 06:31:25 +02:00
|
|
|
ret = rpmsgfs_client_readdir(fs->handle, rdir->dir, entry);
|
2021-11-30 13:00:03 +01:00
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_unlock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: rpmsgfs_rewindir
|
|
|
|
*
|
|
|
|
* Description: Reset directory read to the first entry
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int rpmsgfs_rewinddir(FAR struct inode *mountpt,
|
|
|
|
FAR struct fs_dirent_s *dir)
|
|
|
|
{
|
|
|
|
FAR struct rpmsgfs_mountpt_s *fs;
|
2022-08-05 06:31:25 +02:00
|
|
|
FAR struct rpmsgfs_dir_s *rdir;
|
2021-11-30 13:00:03 +01:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Sanity checks */
|
|
|
|
|
|
|
|
DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL);
|
|
|
|
|
|
|
|
/* Recover our private data from the inode instance */
|
|
|
|
|
|
|
|
fs = mountpt->i_private;
|
2022-08-05 06:31:25 +02:00
|
|
|
rdir = (FAR struct rpmsgfs_dir_s *)dir;
|
2021-11-30 13:00:03 +01:00
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
/* Take the lock */
|
2021-11-30 13:00:03 +01:00
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
ret = nxmutex_lock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call the host and let it do all the work */
|
|
|
|
|
2022-08-05 06:31:25 +02:00
|
|
|
rpmsgfs_client_rewinddir(fs->handle, rdir->dir);
|
2021-11-30 13:00:03 +01:00
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_unlock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: rpmsgfs_bind
|
|
|
|
*
|
|
|
|
* Description: This implements a portion of the mount operation. This
|
|
|
|
* function allocates and initializes the mountpoint private data and
|
|
|
|
* binds the blockdriver inode to the filesystem private data. The final
|
|
|
|
* binding of the private data (containing the blockdriver) to the
|
|
|
|
* mountpoint is performed by mount().
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int rpmsgfs_bind(FAR struct inode *blkdriver, FAR const void *data,
|
|
|
|
FAR void **handle)
|
|
|
|
{
|
|
|
|
FAR struct rpmsgfs_mountpt_s *fs;
|
|
|
|
FAR const char *cpuname = NULL;
|
|
|
|
FAR char *options;
|
|
|
|
char *saveptr;
|
|
|
|
char *ptr;
|
|
|
|
int len;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Validate the block driver is NULL */
|
|
|
|
|
|
|
|
if (blkdriver || !data)
|
|
|
|
{
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create an instance of the mountpt state structure */
|
|
|
|
|
|
|
|
fs = (FAR struct rpmsgfs_mountpt_s *)
|
|
|
|
kmm_zalloc(sizeof(struct rpmsgfs_mountpt_s));
|
|
|
|
|
|
|
|
if (fs == NULL)
|
|
|
|
{
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The options we support are:
|
|
|
|
* "fs=whatever,cpu=cpuname", remote dir
|
2022-01-05 15:09:47 +01:00
|
|
|
* "timeout=xx", connect timeout, unit (ms)
|
2021-11-30 13:00:03 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
options = strdup(data);
|
|
|
|
if (!options)
|
|
|
|
{
|
|
|
|
kmm_free(fs);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2022-01-05 15:09:47 +01:00
|
|
|
/* Set timeout default value */
|
|
|
|
|
|
|
|
fs->timeout = INT_MAX;
|
|
|
|
|
2021-11-30 13:00:03 +01:00
|
|
|
ptr = strtok_r(options, ",", &saveptr);
|
|
|
|
while (ptr != NULL)
|
|
|
|
{
|
|
|
|
if ((strncmp(ptr, "fs=", 3) == 0))
|
|
|
|
{
|
2021-12-29 13:17:34 +01:00
|
|
|
strlcpy(fs->fs_root, &ptr[3], sizeof(fs->fs_root));
|
2021-11-30 13:00:03 +01:00
|
|
|
}
|
|
|
|
else if ((strncmp(ptr, "cpu=", 4) == 0))
|
|
|
|
{
|
|
|
|
cpuname = &ptr[4];
|
|
|
|
}
|
2022-01-05 15:09:47 +01:00
|
|
|
else if ((strncmp(ptr, "timeout=", 8) == 0))
|
|
|
|
{
|
|
|
|
fs->timeout = atoi(&ptr[8]);
|
|
|
|
}
|
2021-11-30 13:00:03 +01:00
|
|
|
|
|
|
|
ptr = strtok_r(NULL, ",", &saveptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = rpmsgfs_client_bind(&fs->handle, cpuname);
|
2023-08-08 00:11:20 +02:00
|
|
|
lib_free(options);
|
2021-11-30 13:00:03 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
kmm_free(fs);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
/* Initialize the mutex that controls access */
|
2021-11-30 13:00:03 +01:00
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_init(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
|
|
|
|
/* Initialize the allocated mountpt state structure. The filesystem is
|
|
|
|
* responsible for one reference ont the blkdriver inode and does not
|
|
|
|
* have to addref() here (but does have to release in ubind().
|
|
|
|
*/
|
|
|
|
|
|
|
|
fs->fs_head = NULL;
|
|
|
|
|
|
|
|
/* Now perform the mount. */
|
|
|
|
|
|
|
|
len = strlen(fs->fs_root);
|
|
|
|
if (len > 1 && fs->fs_root[len - 1] == '/')
|
|
|
|
{
|
|
|
|
/* Remove trailing '/' */
|
|
|
|
|
|
|
|
fs->fs_root[len - 1] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Append a '/' to the name now */
|
|
|
|
|
|
|
|
if (fs->fs_root[len - 1] != '/')
|
|
|
|
{
|
2023-03-05 14:48:08 +01:00
|
|
|
strlcat(fs->fs_root, "/", sizeof(fs->fs_root));
|
2021-11-30 13:00:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
*handle = (FAR void *)fs;
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: rpmsgfs_unbind
|
|
|
|
*
|
|
|
|
* Description: This implements the filesystem portion of the umount
|
|
|
|
* operation.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int rpmsgfs_unbind(FAR void *handle, FAR struct inode **blkdriver,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
FAR struct rpmsgfs_mountpt_s *fs = (FAR struct rpmsgfs_mountpt_s *)handle;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!fs)
|
|
|
|
{
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if there are sill any files opened on the filesystem. */
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
ret = nxmutex_lock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fs->fs_head != NULL)
|
|
|
|
{
|
|
|
|
/* We cannot unmount now.. there are open files */
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_unlock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
|
|
|
|
/* This implementation currently only supports unmounting if there are
|
|
|
|
* no open file references.
|
|
|
|
*/
|
|
|
|
|
|
|
|
return (flags != 0) ? -ENOSYS : -EBUSY;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = rpmsgfs_client_unbind(fs->handle);
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_unlock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_destroy(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
kmm_free(fs);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: rpmsgfs_statfs
|
|
|
|
*
|
|
|
|
* Description: Return filesystem statistics
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int rpmsgfs_statfs(FAR struct inode *mountpt, FAR struct statfs *buf)
|
|
|
|
{
|
|
|
|
FAR struct rpmsgfs_mountpt_s *fs;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Sanity checks */
|
|
|
|
|
|
|
|
DEBUGASSERT(mountpt && mountpt->i_private);
|
|
|
|
|
|
|
|
/* Get the mountpoint private data from the inode structure */
|
|
|
|
|
|
|
|
fs = mountpt->i_private;
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
ret = nxmutex_lock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = rpmsgfs_client_statfs(fs->handle, fs->fs_root, buf);
|
2023-12-08 09:44:46 +01:00
|
|
|
buf->f_type = RPMSGFS_MAGIC;
|
2022-07-07 08:43:59 +02:00
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_unlock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: rpmsgfs_unlink
|
|
|
|
*
|
|
|
|
* Description: Remove a file
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int rpmsgfs_unlink(FAR struct inode *mountpt, FAR const char *relpath)
|
|
|
|
{
|
|
|
|
FAR struct rpmsgfs_mountpt_s *fs;
|
|
|
|
char path[PATH_MAX];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Sanity checks */
|
|
|
|
|
|
|
|
DEBUGASSERT(mountpt && mountpt->i_private);
|
|
|
|
|
|
|
|
/* Get the mountpoint private data from the inode structure */
|
|
|
|
|
|
|
|
fs = mountpt->i_private;
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
ret = nxmutex_lock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Append to the host's root directory */
|
|
|
|
|
|
|
|
rpmsgfs_mkpath(fs, relpath, path, sizeof(path));
|
|
|
|
|
|
|
|
/* Call the host fs to perform the unlink */
|
|
|
|
|
|
|
|
ret = rpmsgfs_client_unlink(fs->handle, path);
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_unlock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: rpmsgfs_mkdir
|
|
|
|
*
|
|
|
|
* Description: Create a directory
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int rpmsgfs_mkdir(FAR struct inode *mountpt, FAR const char *relpath,
|
|
|
|
mode_t mode)
|
|
|
|
{
|
|
|
|
FAR struct rpmsgfs_mountpt_s *fs;
|
|
|
|
char path[PATH_MAX];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Sanity checks */
|
|
|
|
|
|
|
|
DEBUGASSERT(mountpt && mountpt->i_private);
|
|
|
|
|
|
|
|
/* Get the mountpoint private data from the inode structure */
|
|
|
|
|
|
|
|
fs = mountpt->i_private;
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
ret = nxmutex_lock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Append to the host's root directory */
|
|
|
|
|
|
|
|
rpmsgfs_mkpath(fs, relpath, path, sizeof(path));
|
|
|
|
|
|
|
|
/* Call the host FS to do the mkdir */
|
|
|
|
|
|
|
|
ret = rpmsgfs_client_mkdir(fs->handle, path, mode);
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_unlock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: rpmsgfs_rmdir
|
|
|
|
*
|
|
|
|
* Description: Remove a directory
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int rpmsgfs_rmdir(FAR struct inode *mountpt, FAR const char *relpath)
|
|
|
|
{
|
|
|
|
FAR struct rpmsgfs_mountpt_s *fs;
|
|
|
|
char path[PATH_MAX];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Sanity checks */
|
|
|
|
|
|
|
|
DEBUGASSERT(mountpt && mountpt->i_private);
|
|
|
|
|
|
|
|
/* Get the mountpoint private data from the inode structure */
|
|
|
|
|
|
|
|
fs = mountpt->i_private;
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
/* Take the lock */
|
2021-11-30 13:00:03 +01:00
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
ret = nxmutex_lock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Append to the host's root directory */
|
|
|
|
|
|
|
|
rpmsgfs_mkpath(fs, relpath, path, sizeof(path));
|
|
|
|
|
|
|
|
/* Call the host FS to do the mkdir */
|
|
|
|
|
|
|
|
ret = rpmsgfs_client_rmdir(fs->handle, path);
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_unlock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: rpmsgfs_rename
|
|
|
|
*
|
|
|
|
* Description: Rename a file or directory
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int rpmsgfs_rename(FAR struct inode *mountpt, FAR const char *oldrelpath,
|
|
|
|
FAR const char *newrelpath)
|
|
|
|
{
|
|
|
|
FAR struct rpmsgfs_mountpt_s *fs;
|
|
|
|
char oldpath[PATH_MAX];
|
|
|
|
char newpath[PATH_MAX];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Sanity checks */
|
|
|
|
|
|
|
|
DEBUGASSERT(mountpt && mountpt->i_private);
|
|
|
|
|
|
|
|
/* Get the mountpoint private data from the inode structure */
|
|
|
|
|
|
|
|
fs = mountpt->i_private;
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
ret = nxmutex_lock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Append to the host's root directory */
|
|
|
|
|
2021-12-29 13:17:34 +01:00
|
|
|
strlcpy(oldpath, fs->fs_root, sizeof(oldpath));
|
|
|
|
strlcat(oldpath, oldrelpath, sizeof(oldpath));
|
|
|
|
strlcpy(newpath, fs->fs_root, sizeof(newpath));
|
|
|
|
strlcat(newpath, newrelpath, sizeof(newpath));
|
2021-11-30 13:00:03 +01:00
|
|
|
|
|
|
|
/* Call the host FS to do the mkdir */
|
|
|
|
|
|
|
|
ret = rpmsgfs_client_rename(fs->handle, oldpath, newpath);
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_unlock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: rpmsgfs_stat
|
|
|
|
*
|
|
|
|
* Description: Return information about a file or directory
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int rpmsgfs_stat(FAR struct inode *mountpt, FAR const char *relpath,
|
|
|
|
FAR struct stat *buf)
|
|
|
|
{
|
|
|
|
FAR struct rpmsgfs_mountpt_s *fs;
|
|
|
|
char path[PATH_MAX];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Sanity checks */
|
|
|
|
|
|
|
|
DEBUGASSERT(mountpt && mountpt->i_private);
|
|
|
|
|
|
|
|
/* Get the mountpoint private data from the inode structure */
|
|
|
|
|
|
|
|
fs = mountpt->i_private;
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
ret = nxmutex_lock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Append to the host's root directory */
|
|
|
|
|
|
|
|
rpmsgfs_mkpath(fs, relpath, path, sizeof(path));
|
|
|
|
|
|
|
|
/* Call the host FS to do the stat operation */
|
|
|
|
|
|
|
|
ret = rpmsgfs_client_stat(fs->handle, path, buf);
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_unlock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: rpmsgfs_chstat
|
|
|
|
*
|
|
|
|
* Description: Change information about a file or directory
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int rpmsgfs_chstat(FAR struct inode *mountpt, FAR const char *relpath,
|
|
|
|
FAR const struct stat *buf, int flags)
|
|
|
|
{
|
|
|
|
FAR struct rpmsgfs_mountpt_s *fs;
|
|
|
|
char path[PATH_MAX];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Sanity checks */
|
|
|
|
|
|
|
|
DEBUGASSERT(mountpt && mountpt->i_private);
|
|
|
|
|
|
|
|
/* Get the mountpoint private data from the inode structure */
|
|
|
|
|
|
|
|
fs = mountpt->i_private;
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
ret = nxmutex_lock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Append to the host's root directory */
|
|
|
|
|
|
|
|
rpmsgfs_mkpath(fs, relpath, path, sizeof(path));
|
|
|
|
|
|
|
|
/* Call the host FS to do the chstat operation */
|
|
|
|
|
|
|
|
ret = rpmsgfs_client_chstat(fs->handle, path, buf, flags);
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_unlock(&fs->fs_lock);
|
2021-11-30 13:00:03 +01:00
|
|
|
return ret;
|
|
|
|
}
|