-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sys/fs/constfs: drop dummy implementations #17651
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,46 +33,34 @@ | |
#include "debug.h" | ||
|
||
/* File system operations */ | ||
static int constfs_mount(vfs_mount_t *mountp); | ||
static int constfs_umount(vfs_mount_t *mountp); | ||
static int constfs_unlink(vfs_mount_t *mountp, const char *name); | ||
static int constfs_stat(vfs_mount_t *mountp, const char *restrict name, struct stat *restrict buf); | ||
static int constfs_statvfs(vfs_mount_t *mountp, const char *restrict path, struct statvfs *restrict buf); | ||
|
||
/* File operations */ | ||
static int constfs_close(vfs_file_t *filp); | ||
static int constfs_fstat(vfs_file_t *filp, struct stat *buf); | ||
static off_t constfs_lseek(vfs_file_t *filp, off_t off, int whence); | ||
static int constfs_open(vfs_file_t *filp, const char *name, int flags, mode_t mode, const char *abs_path); | ||
static ssize_t constfs_read(vfs_file_t *filp, void *dest, size_t nbytes); | ||
static ssize_t constfs_write(vfs_file_t *filp, const void *src, size_t nbytes); | ||
|
||
/* Directory operations */ | ||
static int constfs_opendir(vfs_DIR *dirp, const char *dirname, const char *abs_path); | ||
static int constfs_readdir(vfs_DIR *dirp, vfs_dirent_t *entry); | ||
static int constfs_closedir(vfs_DIR *dirp); | ||
|
||
static const vfs_file_system_ops_t constfs_fs_ops = { | ||
.mount = constfs_mount, | ||
.umount = constfs_umount, | ||
.unlink = constfs_unlink, | ||
.statvfs = constfs_statvfs, | ||
.stat = constfs_stat, | ||
}; | ||
|
||
static const vfs_file_ops_t constfs_file_ops = { | ||
.close = constfs_close, | ||
.fstat = constfs_fstat, | ||
.lseek = constfs_lseek, | ||
.open = constfs_open, | ||
.read = constfs_read, | ||
.write = constfs_write, | ||
}; | ||
|
||
static const vfs_dir_ops_t constfs_dir_ops = { | ||
.opendir = constfs_opendir, | ||
.readdir = constfs_readdir, | ||
.closedir = constfs_closedir, | ||
}; | ||
|
||
const vfs_file_system_t constfs_file_system = { | ||
|
@@ -91,28 +79,6 @@ const vfs_file_system_t constfs_file_system = { | |
*/ | ||
static void _constfs_write_stat(const constfs_file_t *fp, struct stat *restrict buf); | ||
|
||
static int constfs_mount(vfs_mount_t *mountp) | ||
{ | ||
/* perform any extra initialization here */ | ||
(void) mountp; /* prevent warning: unused parameter */ | ||
return 0; | ||
} | ||
|
||
static int constfs_umount(vfs_mount_t *mountp) | ||
{ | ||
/* free resources and perform any clean up here */ | ||
(void) mountp; /* prevent warning: unused parameter */ | ||
return 0; | ||
} | ||
|
||
static int constfs_unlink(vfs_mount_t *mountp, const char *name) | ||
{ | ||
/* Removing files is prohibited */ | ||
(void) mountp; /* prevent warning: unused parameter */ | ||
(void) name; /* prevent warning: unused parameter */ | ||
return -EROFS; | ||
} | ||
|
||
static int constfs_stat(vfs_mount_t *mountp, const char *restrict name, struct stat *restrict buf) | ||
{ | ||
(void) name; | ||
|
@@ -162,13 +128,6 @@ static int constfs_statvfs(vfs_mount_t *mountp, const char *restrict path, struc | |
return 0; | ||
} | ||
|
||
static int constfs_close(vfs_file_t *filp) | ||
{ | ||
/* perform any necessary clean ups */ | ||
(void) filp; /* prevent warning: unused parameter */ | ||
return 0; | ||
} | ||
|
||
static int constfs_fstat(vfs_file_t *filp, struct stat *buf) | ||
{ | ||
constfs_file_t *fp = filp->private_data.ptr; | ||
|
@@ -244,18 +203,6 @@ static ssize_t constfs_read(vfs_file_t *filp, void *dest, size_t nbytes) | |
return nbytes; | ||
} | ||
|
||
static ssize_t constfs_write(vfs_file_t *filp, const void *src, size_t nbytes) | ||
{ | ||
DEBUG("constfs_write: %p, %p, %lu\n", (void *)filp, src, (unsigned long)nbytes); | ||
/* Read only file system */ | ||
DEBUG("constfs_write: read only FS\n"); | ||
/* prevent warning: unused parameter */ | ||
(void) filp; | ||
(void) src; | ||
(void) nbytes; | ||
return -EBADF; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is technically a change (vfs_write without a write returns -EINVAL), but I'd say it's for the better. |
||
} | ||
|
||
static int constfs_opendir(vfs_DIR *dirp, const char *dirname, const char *abs_path) | ||
{ | ||
(void) abs_path; | ||
|
@@ -298,14 +245,6 @@ static int constfs_readdir(vfs_DIR *dirp, vfs_dirent_t *entry) | |
return 1; | ||
} | ||
|
||
static int constfs_closedir(vfs_DIR *dirp) | ||
{ | ||
/* Just an example, it's not necessary to define closedir if there is | ||
* nothing to clean up */ | ||
(void) dirp; | ||
return 0; | ||
} | ||
|
||
static void _constfs_write_stat(const constfs_file_t *fp, struct stat *restrict buf) | ||
{ | ||
/* buffer is cleared by vfs already */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is technically a change from -EPERM (which is the default) to -EROFS; probably OK (but may be worth a second thought).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the default then rather be changed to
-EROFS
? The function not being implemented is not a permission issue.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no strong opinions on the concrete standard error values we return due to POSIXish conventions; EROFS sounds just as good as EPERM to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to change it to
-EROFS
in VFS.