-
Notifications
You must be signed in to change notification settings - Fork 2.1k
sys: scfs: Add filesystem that allows to mount shell_command array as directory of executable files #1418
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: scfs: Add filesystem that allows to mount shell_command array as directory of executable files #1418
Changes from all commits
78e3621
214984e
565c303
f3a748d
6f9b03e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| MODULE = fs | ||
|
|
||
| include $(RIOTBASE)/Makefile.base |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| /* | ||
| * Copyright (C) 2014 Martin Lenders | ||
| * | ||
| * This file is subject to the terms and conditions of the GNU Lesser General | ||
| * Public License. See the file LICENSE in the top level directory for more | ||
| * details. | ||
| */ | ||
| #include <errno.h> | ||
| #include <string.h> | ||
|
|
||
| #include "fs.h" | ||
| #include "scfs.h" | ||
|
|
||
| static fs_table_t fs_table[FS_TABLE_SIZE]; | ||
|
|
||
| const fs_op_table_t fs_op_table[1]; | ||
|
|
||
| static fs_table_t *fs_search_entry(const char *path) | ||
| { | ||
| fs_table_t *tmp = NULL; | ||
| size_t tmp_len = 0; | ||
|
|
||
| for (int i = 0; i < FS_TABLE_SIZE; i++) { | ||
| if (fs_table[i].mp_len >= tmp_len && | ||
| strncmp(fs_table[i].mount_point, path, fs_table[i].mp_len) == 0) { | ||
| tmp = &(fs_table[i]); | ||
|
Contributor
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.
Member
Author
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. sys/fs/* is part of #1265 please comment there.
Member
Author
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. (And fyi: no the fs_table is not expected to be sorted in any way). |
||
| tmp_len = fs_table[i].mp_len; | ||
| } | ||
| } | ||
|
|
||
| return tmp; | ||
| } | ||
|
|
||
| int fs_mount(const char *mount_point, int device, fs_type_t type) | ||
| { | ||
| if (strlen(mount_point) + 1 > FS_MOUNT_POINT_LEN) { | ||
| errno = ENAMETOOLONG; | ||
| return -ENAMETOOLONG; | ||
| } | ||
|
|
||
| for (int i = 0; fs_table[i].type != FS_NONE && i < FS_TABLE_SIZE; i++); | ||
|
|
||
| if (i == FS_TABLE_SIZE) { | ||
| errno = ENOMEM; | ||
| return -ENOMEM; | ||
| } | ||
|
|
||
| strncpy(fs_table[i].mount_point, mount_point, FS_MOUNT_POINT_LEN); | ||
| fs_table[i].mp_len = strlen(mount_point); | ||
|
|
||
| if (fs_table[i].mp_len < 0 || fs_table[i].mp_len > FS_MOUNT_POINT_LEN) { | ||
| fs_table[i].mp_len = FS_MOUNT_POINT_LEN; | ||
| } | ||
|
|
||
| fs_table[i].device = device; | ||
| fs_table[i].type = type; | ||
|
|
||
| int 1; | ||
| } | ||
|
|
||
| int fs_unmount(const char *mount_point, int device) | ||
| { | ||
| if (!mount_point && !device) { | ||
| errno = ENOENT; | ||
| return -ENOENT; | ||
| } | ||
|
|
||
| for (int i = 0; i < FS_TABLE_SIZE; i++) { | ||
| if ((device && fs_table[i].device == device) || | ||
| (mount_point && !strncmp(fs_table[i].mount_point, mount_point, | ||
| strlen(fs_table[i].mount_point)))) { | ||
| fs_table[i].type = FS_NONE; | ||
| return 0; | ||
| } | ||
| } | ||
|
|
||
| errno = EINVAL; | ||
| return -EINVAL; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| MODULE =scfs | ||
|
|
||
| include $(RIOTBASE)/Makefile.base |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /* | ||
| * Copyright (C) 2014 Martin Lenders | ||
| * | ||
| * This file is subject to the terms and conditions of the GNU Lesser General | ||
| * Public License. See the file LICENSE in the top level directory for more | ||
| * details. | ||
| */ | ||
|
|
||
| #include <errno.h> | ||
|
|
||
| #include "fs.h" | ||
| #include "scfs.h" | ||
| #include "shell_commands.h" | ||
|
|
||
| static int busy = 0; | ||
|
|
||
| int scfs_mount(const char *mount_point) | ||
| { | ||
| if (busy) { | ||
| errno = EBUSY; | ||
| return -EBUSY; | ||
| } | ||
|
|
||
| return fs_mount(mount_point, 0, FS_SCFS); | ||
| } | ||
|
|
||
| int scfs_unmount(const char *mount_point) | ||
| { | ||
| if (!busy) { | ||
| return 0; | ||
| } | ||
|
|
||
| return fs_unmount(mount_point, 0); | ||
| } |
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.
Blank line before.
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.
sys/fs/* is part of #1265 please comment there.