Skip to content

Commit 6f9b03e

Browse files
Martin Lendersmiri64
authored andcommitted
fs : scfs: Start SCFS module
1 parent f3a748d commit 6f9b03e

File tree

5 files changed

+123
-0
lines changed

5 files changed

+123
-0
lines changed

Makefile.dep

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ endif
7171

7272
ifneq (,$(filter net_if,$(USEMODULE)))
7373
USEMODULE += transceiver
74+
endif
75+
76+
ifneq (,$(filter scfs,$(USEMODULE)))
77+
USEMODULE += fs
78+
USEMODULE += shell_commands
79+
endif
80+
81+
ifneq (,$(filter shell_commands,$(USEMODULE)))
7482
USEMODULE += net_help
7583
endif
7684

sys/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ endif
44
ifneq (,$(filter config,$(USEMODULE)))
55
DIRS += config
66
endif
7+
ifneq (,$(filter fs,$(USEMODULE)))
8+
DIRS += fs
9+
endif
710
ifneq (,$(filter lib,$(USEMODULE)))
811
DIRS += lib
912
endif
@@ -22,6 +25,9 @@ endif
2225
ifneq (,$(filter pthread,$(USEMODULE)))
2326
DIRS += posix/pthread
2427
endif
28+
ifneq (,$(filter scfs,$(USEMODULE)))
29+
DIRS += fs/scfs
30+
endif
2531
ifneq (,$(filter shell,$(USEMODULE)))
2632
DIRS += shell
2733
endif

sys/fs/scfs/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
MODULE =scfs
2+
3+
include $(RIOTBASE)/Makefile.base

sys/fs/scfs/scfs.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (C) 2014 Martin Lenders
3+
*
4+
* This file is subject to the terms and conditions of the GNU Lesser General
5+
* Public License. See the file LICENSE in the top level directory for more
6+
* details.
7+
*/
8+
9+
#include <errno.h>
10+
11+
#include "fs.h"
12+
#include "scfs.h"
13+
#include "shell_commands.h"
14+
15+
static int busy = 0;
16+
17+
int scfs_mount(const char *mount_point)
18+
{
19+
if (busy) {
20+
errno = EBUSY;
21+
return -EBUSY;
22+
}
23+
24+
return fs_mount(mount_point, 0, FS_SCFS);
25+
}
26+
27+
int scfs_unmount(const char *mount_point)
28+
{
29+
if (!busy) {
30+
return 0;
31+
}
32+
33+
return fs_unmount(mount_point, 0);
34+
}

sys/include/scfs.h

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright (C) 2014 Martin Lenders
3+
*
4+
* This file is subject to the terms and conditions of the GNU Lesser General
5+
* Public License. See the file LICENSE in the top level directory for more
6+
* details.
7+
*/
8+
9+
/**
10+
* @addtogroup fs
11+
* @{
12+
*
13+
* @file scfs.h
14+
* @brief A simple file system that emulates commands from the shell
15+
* command module as binary files
16+
*
17+
* @author Freie Universität Berlin
18+
* @author Martine Lenders
19+
*/
20+
21+
#ifndef __SCFS_H_
22+
#define __SCFS_H_
23+
24+
#include <sys/stat.h>
25+
26+
/**
27+
* @brief Initializes SCFS.
28+
*
29+
* @param[in] mount_point Path where to mount SCFS
30+
*
31+
* @return 0, on success
32+
* @return other on error, errno is set accordingly
33+
*/
34+
int scfs_mount(const char *mount_point);
35+
36+
/**
37+
* @brief Removes SCFS.
38+
*
39+
* @param[in] mount_point Path where SCFS is mounted
40+
*
41+
* @return 0, on success
42+
* @return other on error, errno is set accordingly
43+
*/
44+
int scfs_unmount(const char *mount_point);
45+
46+
/**
47+
* @brief Get file status.
48+
*
49+
* @param[in] path Path to the file.
50+
* @param[out] stat The status of the file.
51+
*
52+
* @return 0, on success.
53+
* @return -1, on failure. *errno* is set appropriatly.
54+
*/
55+
int scfs_stat(const char *path, struct stat *stat);
56+
57+
/**
58+
* @brief Executes a file.
59+
*
60+
* @param[in] path Path to the file.
61+
* @param[in] argv NULL-terminated array of command line arguments. By
62+
* convention, the first argument must the calling name of
63+
* the executed file.
64+
* @param[in] env NULL-terminated array of strings, conventionally in the
65+
* form of "key=value", that represent the environment
66+
* variables passed to the command.
67+
*
68+
* @return The return value of the executed program
69+
*/
70+
int scfs_exec(const char *path, const char *argv[], const char *env[]);
71+
72+
#endif /* __SCFS_H_ */

0 commit comments

Comments
 (0)