You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/01/26 01:39:34 UTC
[1/2] incubator-mynewt-larva git commit: Add 'rm',
'mkdir' and 'mv' CLI commands.
Repository: incubator-mynewt-larva
Updated Branches:
refs/heads/master 0cbef2dde -> 80cd4fd96
Add 'rm', 'mkdir' and 'mv' CLI commands.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/7381d787
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/7381d787
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/7381d787
Branch: refs/heads/master
Commit: 7381d787d570c2835aa4e752a620c476c9d4e615
Parents: 0cbef2d
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Mon Jan 25 16:37:54 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon Jan 25 16:37:54 2016 -0800
----------------------------------------------------------------------
fs/fs/src/fs_cli.c | 58 ++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 53 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/7381d787/fs/fs/src/fs_cli.c
----------------------------------------------------------------------
diff --git a/fs/fs/src/fs_cli.c b/fs/fs/src/fs_cli.c
index e26e003..57d7aae 100644
--- a/fs/fs/src/fs_cli.c
+++ b/fs/fs/src/fs_cli.c
@@ -25,6 +25,9 @@
#include "fs/fs.h"
static struct shell_cmd fs_ls_struct;
+static struct shell_cmd fs_rm_struct;
+static struct shell_cmd fs_mkdir_struct;
+static struct shell_cmd fs_mv_struct;
static void
fs_ls_file(const char *name, struct fs_file *file)
@@ -110,14 +113,59 @@ done:
return 0;
}
-void
-fs_cli_init(void)
+static int
+fs_rm_cmd(int argc, char **argv)
+{
+ int i;
+ int rc;
+
+ for (i = 1; i < argc; i++) {
+ rc = fs_unlink(argv[i]);
+ if (rc) {
+ console_printf("Error removing %s - %d\n", argv[i], rc);
+ }
+ }
+ return 0;
+}
+
+static int
+fs_mkdir_cmd(int argc, char **argv)
+{
+ int i;
+ int rc;
+
+ for (i = 1; i < argc; i++) {
+ rc = fs_mkdir(argv[1]);
+ if (rc) {
+ console_printf("Error creating %s - %d\n", argv[i], rc);
+ }
+ }
+ return 0;
+}
+
+static int
+fs_mv_cmd(int argc, char **argv)
{
int rc;
- rc = shell_cmd_register(&fs_ls_struct, "ls", fs_ls_cmd);
- if (rc != 0) {
- return;
+ if (argc != 3) {
+ rc = -1;
+ goto out;
+ }
+ rc = fs_rename(argv[1], argv[2]);
+out:
+ if (rc) {
+ console_printf("Error moving - %d\n", rc);
}
+ return 0;
+}
+
+void
+fs_cli_init(void)
+{
+ shell_cmd_register(&fs_ls_struct, "ls", fs_ls_cmd);
+ shell_cmd_register(&fs_rm_struct, "rm", fs_rm_cmd);
+ shell_cmd_register(&fs_mkdir_struct, "mkdir", fs_mkdir_cmd);
+ shell_cmd_register(&fs_mv_struct, "mv", fs_mv_cmd);
}
#endif /* SHELL_PRESENT */
[2/2] incubator-mynewt-larva git commit: Close the file if error
occurs during file upload.
Posted by ma...@apache.org.
Close the file if error occurs during file upload.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/80cd4fd9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/80cd4fd9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/80cd4fd9
Branch: refs/heads/master
Commit: 80cd4fd962ec73f5ca942c72dd48e36a4a65143a
Parents: 7381d78
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Mon Jan 25 16:38:36 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon Jan 25 16:38:36 2016 -0800
----------------------------------------------------------------------
libs/imgmgr/src/imgmgr_fs.c | 5 +++++
1 file changed, 5 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/80cd4fd9/libs/imgmgr/src/imgmgr_fs.c
----------------------------------------------------------------------
diff --git a/libs/imgmgr/src/imgmgr_fs.c b/libs/imgmgr/src/imgmgr_fs.c
index cc5582f..529e801 100644
--- a/libs/imgmgr/src/imgmgr_fs.c
+++ b/libs/imgmgr/src/imgmgr_fs.c
@@ -222,6 +222,11 @@ imgr_file_upload(struct nmgr_jbuf *njb)
if (len && imgr_state.upload.file) {
rc = fs_write(imgr_state.upload.file, img_data, len);
+ if (rc) {
+ fs_close(imgr_state.upload.file);
+ imgr_state.upload.file = NULL;
+ return OS_EINVAL;
+ }
imgr_state.upload.off += len;
if (imgr_state.upload.size == imgr_state.upload.off) {
/* Done */