Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions components/dfs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ if RT_USING_DFS
bool "Using working directory"
default y

config RT_USING_DFS_LARGE_FILE
bool "Enable 64-bit DFS internal file offset"
default n
help
Enable this option to use a signed 64-bit file offset type inside
DFS. The POSIX off_t type is still provided by the selected C
library/toolchain, but DFS filesystem drivers and DFS-native helper
APIs can handle file positions and file sizes larger than 2GB.

if RT_USING_DFS_V1
config RT_USING_DFS_MNTTABLE
bool "Using mount table for file system"
Expand Down
51 changes: 28 additions & 23 deletions components/dfs/dfs_v1/filesystems/9pfs/dfs_9pfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,24 +367,29 @@ rt_err_t dfs_9pfs_del_tag(struct p9_protocol *p9p)

static int p9_to_fs_err(int rc)
{
const int p9_err[] = {
[0] = RT_EOK,
[-P9_ERROR] = -EIO,
[-P9_UNKNOWN_VERSION] = -ENOSYS,
[-P9_R_ERROR] = -EIO,
[-P9_MSG_TOO_LONG] = -ENOSPC,
[-P9_UNEXPECTED_MSG] = -EINVAL,
[-P9_UNEXPECTED_TAG] = -EINVAL,
[-P9_TRANSPORT_ERROR] = -EIO,
[-P9_NO_TRANSPORT] = -EINVAL,
[-P9_NULL_PATH] = -EINVAL,
[-P9_PATH_ELEMENT_TOO_LONG] = -EINVAL,
[-P9_READ_UNEXPECTED_DATA] = -EINVAL,
[-P9_NO_BUFFER] = -ENOSPC,
[-P9_MSG_SIZE_TOO_BIG] = -ENOSPC,
};

return p9_err[-rc];
switch (rc)
{
case 0:
return RT_EOK;
case P9_UNKNOWN_VERSION:
return -ENOSYS;
case P9_MSG_TOO_LONG:
case P9_NO_BUFFER:
case P9_MSG_SIZE_TOO_BIG:
return -ENOSPC;
case P9_UNEXPECTED_MSG:
case P9_UNEXPECTED_TAG:
case P9_NO_TRANSPORT:
case P9_NULL_PATH:
case P9_PATH_ELEMENT_TOO_LONG:
case P9_READ_UNEXPECTED_DATA:
return -EINVAL;
case P9_ERROR:
case P9_R_ERROR:
case P9_TRANSPORT_ERROR:
default:
return -EIO;
}
}

static int p9_alloc_fid(struct p9_connection *conn)
Expand Down Expand Up @@ -547,7 +552,7 @@ rt_inline int p9_walk_subpath(struct p9_connection *conn, const char *path)

static int dfs_9pfs_open(struct dfs_file *fd)
{
int rc;
int rc = 0;
rt_uint32_t size;
rt_bool_t is_root;
struct p9_connection *conn;
Expand Down Expand Up @@ -807,7 +812,7 @@ static int dfs_9pfs_flush(struct dfs_file *fd)
return p9_to_fs_err(rc);
}

static off_t dfs_9pfs_lseek(struct dfs_file *fd, off_t offset)
static dfs_off_t dfs_9pfs_lseek(struct dfs_file *fd, dfs_off_t offset)
{
int ret = -EIO;

Expand Down Expand Up @@ -1049,7 +1054,7 @@ static int dfs_9pfs_unlink(struct dfs_filesystem *fs, const char *pathname)
}

static int dfs_9pfs_stat(struct dfs_filesystem *fs,
const char *filename, struct stat *st)
const char *filename, struct dfs_stat *st)
{
int rc = 0, fid;
rt_uint32_t size, mode;
Expand Down Expand Up @@ -1108,8 +1113,8 @@ static int dfs_9pfs_stat(struct dfs_filesystem *fs,
st->st_mode |= S_ISVTX;
}

st->st_atime = get_rx_value32_of(conn, P9_MSG_STAT_ATIME);
st->st_mtime = get_rx_value32_of(conn, P9_MSG_STAT_MTIME);
st->atime = get_rx_value32_of(conn, P9_MSG_STAT_ATIME);
st->mtime = get_rx_value32_of(conn, P9_MSG_STAT_MTIME);
st->st_size = get_rx_value64_of(conn, P9_MSG_STAT_LEN);

/*
Expand Down
6 changes: 3 additions & 3 deletions components/dfs/dfs_v1/filesystems/cromfs/dfs_cromfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ static int dfs_cromfs_read(struct dfs_file *file, void *buf, size_t count)
return length;
}

static int dfs_cromfs_lseek(struct dfs_file *file, off_t offset)
static dfs_off_t dfs_cromfs_lseek(struct dfs_file *file, dfs_off_t offset)
{
if (offset <= file->vnode->size)
{
Expand Down Expand Up @@ -1012,7 +1012,7 @@ static int dfs_cromfs_open(struct dfs_file *file)
return ret;
}

static int dfs_cromfs_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
static int dfs_cromfs_stat(struct dfs_filesystem *fs, const char *path, struct dfs_stat *st)
{
uint32_t size = 0, osize = 0;
int is_dir = 0;
Expand Down Expand Up @@ -1042,7 +1042,7 @@ static int dfs_cromfs_stat(struct dfs_filesystem *fs, const char *path, struct s
st->st_size = osize;
}

st->st_mtime = 0;
st->mtime = 0;

return RT_EOK;
}
Expand Down
6 changes: 3 additions & 3 deletions components/dfs/dfs_v1/filesystems/devfs/devfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ int dfs_device_fs_unlink(struct dfs_filesystem *fs, const char *path)
return RT_EOK;
}

int dfs_device_fs_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
int dfs_device_fs_stat(struct dfs_filesystem *fs, const char *path, struct dfs_stat *st)
{
st->st_dev = (dev_t)((size_t)dfs_filesystem_lookup(fs->path));
/* stat root directory */
Expand All @@ -296,7 +296,7 @@ int dfs_device_fs_stat(struct dfs_filesystem *fs, const char *path, struct stat
st->st_mode |= S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH;

st->st_size = 0;
st->st_mtime = 0;
st->mtime = 0;

return RT_EOK;
}
Expand All @@ -322,7 +322,7 @@ int dfs_device_fs_stat(struct dfs_filesystem *fs, const char *path, struct stat
st->st_mode |= S_IFREG;

st->st_size = 0;
st->st_mtime = 0;
st->mtime = 0;

return RT_EOK;
}
Expand Down
21 changes: 16 additions & 5 deletions components/dfs/dfs_v1/filesystems/elmfat/dfs_elm.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,13 +504,19 @@ int dfs_elm_ioctl(struct dfs_file *file, int cmd, void *args)
{
FIL *fd;
FSIZE_t fptr, length;
dfs_off_t dfs_length;
FRESULT result = FR_OK;
fd = (FIL *)(file->data);
RT_ASSERT(fd != RT_NULL);

/* save file read/write point */
fptr = fd->fptr;
length = *(off_t*)args;
dfs_length = *(dfs_off_t*)args;
if (dfs_length < 0 || (dfs_off_t)(FSIZE_t)dfs_length != dfs_length)
{
return -EINVAL;
}
length = (FSIZE_t)dfs_length;
if (length <= fd->obj.objsize)
{
fd->fptr = length;
Expand Down Expand Up @@ -591,9 +597,14 @@ int dfs_elm_flush(struct dfs_file *file)
return elm_result_to_dfs(result);
}

off_t dfs_elm_lseek(struct dfs_file *file, off_t offset)
dfs_off_t dfs_elm_lseek(struct dfs_file *file, dfs_off_t offset)
{
FRESULT result = FR_OK;
if (offset < 0 || (dfs_off_t)(FSIZE_t)offset != offset)
{
return -EINVAL;
}

if (file->vnode->type == FT_REGULAR)
{
FIL *fd;
Expand All @@ -602,7 +613,7 @@ off_t dfs_elm_lseek(struct dfs_file *file, off_t offset)
fd = (FIL *)(file->data);
RT_ASSERT(fd != RT_NULL);

result = f_lseek(fd, offset);
result = f_lseek(fd, (FSIZE_t)offset);
if (result == FR_OK)
{
/* return current position */
Expand Down Expand Up @@ -751,7 +762,7 @@ int dfs_elm_rename(struct dfs_filesystem *fs, const char *oldpath, const char *n
return elm_result_to_dfs(result);
}

int dfs_elm_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
int dfs_elm_stat(struct dfs_filesystem *fs, const char *path, struct dfs_stat *st)
{
FATFS *f;
FILINFO file_info;
Expand Down Expand Up @@ -836,7 +847,7 @@ int dfs_elm_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
tm_file.tm_min = min; /* Minutes: 0-59 */
tm_file.tm_sec = sec; /* Seconds: 0-59 */

st->st_mtime = timegm(&tm_file);
st->mtime = timegm(&tm_file);
} /* get st_mtime. */
}

Expand Down
8 changes: 4 additions & 4 deletions components/dfs/dfs_v1/filesystems/iso9660/dfs_iso9660.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ static ssize_t dfs_iso9660_read(struct dfs_file *fd, void *buf, size_t count)
return rcount;
}

static off_t dfs_iso9660_lseek(struct dfs_file *fd, off_t offset)
static dfs_off_t dfs_iso9660_lseek(struct dfs_file *fd, dfs_off_t offset)
{
int ret = -EIO;

Expand Down Expand Up @@ -648,7 +648,7 @@ static int dfs_iso9660_unmount(struct dfs_filesystem *fs)
}

static int dfs_iso9660_stat(struct dfs_filesystem *fs,
const char *filename, struct stat *st)
const char *filename, struct dfs_stat *st)
{
struct iso9660 *iso = fs->data;
struct iso9660_fd *fd = iso9660_lookup(iso, filename, RT_NULL);
Expand All @@ -668,9 +668,9 @@ static int dfs_iso9660_stat(struct dfs_filesystem *fs,
st->st_mode |= S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH;
}

st->st_atime = iso9660_convert_unixtime(iso->joliet ?
st->atime = iso9660_convert_unixtime(iso->joliet ?
&iso->supp.created : &iso->primary.created);
st->st_mtime = iso9660_convert_unixtime2(&fd->dirent.mtime);
st->mtime = iso9660_convert_unixtime2(&fd->dirent.mtime);
st->st_size = rt_le32_to_cpu(fd->dirent.size);

rt_free(fd);
Expand Down
4 changes: 2 additions & 2 deletions components/dfs/dfs_v1/filesystems/mqueue/dfs_mqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ int dfs_mqueue_open(struct dfs_file *file) {
return 0;
}

int dfs_mqueue_stat(struct dfs_filesystem *fs, const char *path, struct stat *st) {
int dfs_mqueue_stat(struct dfs_filesystem *fs, const char *path, struct dfs_stat *st) {
st->st_dev = 0;
st->st_mode = S_IFREG | S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | S_IWGRP | S_IWOTH;
st->st_size = 0;
st->st_mtime = 0;
st->mtime = 0;
return RT_EOK;
}

Expand Down
6 changes: 3 additions & 3 deletions components/dfs/dfs_v1/filesystems/nfs/dfs_nfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ int nfs_write(struct dfs_file *file, const void *buf, size_t count)
return total;
}

int nfs_lseek(struct dfs_file *file, off_t offset)
dfs_off_t nfs_lseek(struct dfs_file *file, dfs_off_t offset)
{
nfs_file *fd;
nfs_filesystem *nfs;
Expand Down Expand Up @@ -837,7 +837,7 @@ int nfs_open(struct dfs_file *file)
return 0;
}

int nfs_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
int nfs_stat(struct dfs_filesystem *fs, const char *path, struct dfs_stat *st)
{
GETATTR3args args;
GETATTR3res res;
Expand Down Expand Up @@ -880,7 +880,7 @@ int nfs_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
}

st->st_size = info->size;
st->st_mtime = info->mtime.seconds;
st->mtime = info->mtime.seconds;

xdr_free((xdrproc_t)xdr_GETATTR3res, (char *)&res);
xdr_free((xdrproc_t)xdr_nfs_fh3, (char *)handle);
Expand Down
8 changes: 4 additions & 4 deletions components/dfs/dfs_v1/filesystems/ramfs/dfs_ramfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ ssize_t dfs_ramfs_write(struct dfs_file *fd, const void *buf, size_t count)
return count;
}

off_t dfs_ramfs_lseek(struct dfs_file *file, off_t offset)
dfs_off_t dfs_ramfs_lseek(struct dfs_file *file, dfs_off_t offset)
{
if (offset <= (off_t)file->vnode->size)
if (offset <= file->vnode->size)
{
file->pos = offset;

Expand Down Expand Up @@ -346,7 +346,7 @@ int dfs_ramfs_open(struct dfs_file *file)

int dfs_ramfs_stat(struct dfs_filesystem *fs,
const char *path,
struct stat *st)
struct dfs_stat *st)
{
rt_size_t size;
struct ramfs_dirent *dirent;
Expand All @@ -363,7 +363,7 @@ int dfs_ramfs_stat(struct dfs_filesystem *fs,
S_IWUSR | S_IWGRP | S_IWOTH;

st->st_size = dirent->size;
st->st_mtime = 0;
st->mtime = 0;

return RT_EOK;
}
Expand Down
6 changes: 3 additions & 3 deletions components/dfs/dfs_v1/filesystems/romfs/dfs_romfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ ssize_t dfs_romfs_read(struct dfs_file *file, void *buf, size_t count)
return length;
}

off_t dfs_romfs_lseek(struct dfs_file *file, off_t offset)
dfs_off_t dfs_romfs_lseek(struct dfs_file *file, dfs_off_t offset)
{
if (offset <= file->vnode->size)
{
Expand Down Expand Up @@ -269,7 +269,7 @@ int dfs_romfs_open(struct dfs_file *file)
return RT_EOK;
}

int dfs_romfs_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
int dfs_romfs_stat(struct dfs_filesystem *fs, const char *path, struct dfs_stat *st)
{
rt_size_t size;
struct romfs_dirent *dirent;
Expand All @@ -294,7 +294,7 @@ int dfs_romfs_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
}

st->st_size = dirent->size;
st->st_mtime = 0;
st->mtime = 0;

return RT_EOK;
}
Expand Down
4 changes: 2 additions & 2 deletions components/dfs/dfs_v1/filesystems/skeleton/skeleton.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ int dfs_skt_read(struct dfs_file *file, void *buf, rt_size_t count)
return count;
}

int dfs_skt_lseek(struct dfs_file *file, rt_off_t offset)
dfs_off_t dfs_skt_lseek(struct dfs_file *file, dfs_off_t offset)
{
return -RT_EIO;
}
Expand All @@ -49,7 +49,7 @@ int dfs_skt_open(struct dfs_file *file)
return RT_EOK;
}

int dfs_skt_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
int dfs_skt_stat(struct dfs_filesystem *fs, const char *path, struct dfs_stat *st)
{
return RT_EOK;
}
Expand Down
8 changes: 4 additions & 4 deletions components/dfs/dfs_v1/filesystems/tmpfs/dfs_tmpfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,9 @@ ssize_t dfs_tmpfs_write(struct dfs_file *fd, const void *buf, size_t count)
return count;
}

off_t dfs_tmpfs_lseek(struct dfs_file *file, off_t offset)
dfs_off_t dfs_tmpfs_lseek(struct dfs_file *file, dfs_off_t offset)
{
if (offset <= (off_t)file->vnode->size)
if (offset <= file->vnode->size)
{
file->pos = offset;

Expand Down Expand Up @@ -550,7 +550,7 @@ int dfs_tmpfs_open(struct dfs_file *file)

int dfs_tmpfs_stat(struct dfs_filesystem *fs,
const char *path,
struct stat *st)
struct dfs_stat *st)
{
rt_size_t size;
struct tmpfs_file *d_file;
Expand All @@ -572,7 +572,7 @@ int dfs_tmpfs_stat(struct dfs_filesystem *fs,
}

st->st_size = d_file->size;
st->st_mtime = 0;
st->mtime = 0;

return RT_EOK;
}
Expand Down
Loading
Loading