[mynewt-mcumgr] 06/42: OS-agnostic command handlers: fs, img, os.

2018-02-12 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-mcumgr.git

commit 29e37f3760c88e3925ee7c07f95b51cff22dba6c
Author: Christopher Collins 
AuthorDate: Wed Jan 17 17:12:52 2018 -0800

OS-agnostic command handlers: fs, img, os.
---
 cmd/fs_mgmt/include/fs_mgmt/fs_mgmt.h |  41 +++
 cmd/fs_mgmt/include/fs_mgmt/fs_mgmt_impl.h|  77 +
 cmd/fs_mgmt/src/fs_mgmt.c | 250 
 cmd/fs_mgmt/src/fs_mgmt_config.h  |  26 ++
 cmd/fs_mgmt/src/stubs.c   |  46 +++
 cmd/img_mgmt/include/img_mgmt/image.h |  82 ++
 cmd/img_mgmt/include/img_mgmt/img_mgmt.h  |  49 
 cmd/img_mgmt/include/img_mgmt/img_mgmt_impl.h | 107 +++
 cmd/img_mgmt/src/img_mgmt.c   | 400 ++
 cmd/img_mgmt/src/img_mgmt_config.h|  22 ++
 cmd/img_mgmt/src/img_mgmt_priv.h  |  96 +++
 cmd/img_mgmt/src/img_mgmt_state.c | 315 
 cmd/img_mgmt/src/img_mgmt_util.c  |  39 +++
 cmd/img_mgmt/src/stubs.c  |  64 +
 cmd/os_mgmt/include/os_mgmt/os_mgmt.h |  64 +
 cmd/os_mgmt/include/os_mgmt/os_mgmt_impl.h|  62 
 cmd/os_mgmt/src/os_mgmt.c | 190 
 cmd/os_mgmt/src/os_mgmt_config.h  |  22 ++
 cmd/os_mgmt/src/stubs.c   |  38 +++
 19 files changed, 1990 insertions(+)

diff --git a/cmd/fs_mgmt/include/fs_mgmt/fs_mgmt.h 
b/cmd/fs_mgmt/include/fs_mgmt/fs_mgmt.h
new file mode 100644
index 000..38173fd
--- /dev/null
+++ b/cmd/fs_mgmt/include/fs_mgmt/fs_mgmt.h
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef H_FS_MGMT_
+#define H_FS_MGMT_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Command IDs for file system management group.
+ */
+#define FS_MGMT_ID_FILE 0
+
+/**
+ * @brief Registers the file system management command handler group.
+ */ 
+void fs_mgmt_register_group(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/cmd/fs_mgmt/include/fs_mgmt/fs_mgmt_impl.h 
b/cmd/fs_mgmt/include/fs_mgmt/fs_mgmt_impl.h
new file mode 100644
index 000..3cb30b8
--- /dev/null
+++ b/cmd/fs_mgmt/include/fs_mgmt/fs_mgmt_impl.h
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @file
+ * @brief Declares implementation-specific functions required by file system
+ *management.  The default stubs can be overridden with functions that
+ *are compatible with the host OS.
+ */
+
+#ifndef H_FS_MGMT_IMPL_
+#define H_FS_MGMT_IMPL_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Retrieves the length of the file at the specified path.
+ *
+ * @param path  The path of the file to query.
+ * @param out_len   On success, the file length gets written here.
+ *
+ * @return  0 on success, MGMT_ERR_[...] code on failure.
+ */
+int fs_mgmt_impl_filelen(const char *path, size_t *out_len);
+
+/**
+ * @brief Reads the specified chunk of file data.
+ *
+ * @param path  The path of the file to read from.
+ * @param offsetThe byte offset to read from.
+ * @param len   The number of bytes to read.
+ * @param out_data  On success, the 

[mynewt-mcumgr] 06/42: OS-agnostic command handlers: fs, img, os.

2018-02-12 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-mcumgr.git

commit 4355617a16c1a4c6974d6b4527c7a6d80ef0e9cd
Author: Christopher Collins 
AuthorDate: Wed Jan 17 17:12:52 2018 -0800

OS-agnostic command handlers: fs, img, os.
---
 cmd/fs_mgmt/include/fs_mgmt/fs_mgmt.h |  41 +++
 cmd/fs_mgmt/include/fs_mgmt/fs_mgmt_impl.h|  77 +
 cmd/fs_mgmt/src/fs_mgmt.c | 250 
 cmd/fs_mgmt/src/fs_mgmt_config.h  |  26 ++
 cmd/fs_mgmt/src/stubs.c   |  46 +++
 cmd/img_mgmt/include/img_mgmt/image.h |  82 ++
 cmd/img_mgmt/include/img_mgmt/img_mgmt.h  |  49 
 cmd/img_mgmt/include/img_mgmt/img_mgmt_impl.h | 107 +++
 cmd/img_mgmt/src/img_mgmt.c   | 400 ++
 cmd/img_mgmt/src/img_mgmt_config.h|  22 ++
 cmd/img_mgmt/src/img_mgmt_priv.h  |  96 +++
 cmd/img_mgmt/src/img_mgmt_state.c | 315 
 cmd/img_mgmt/src/img_mgmt_util.c  |  39 +++
 cmd/img_mgmt/src/stubs.c  |  64 +
 cmd/os_mgmt/include/os_mgmt/os_mgmt.h |  64 +
 cmd/os_mgmt/include/os_mgmt/os_mgmt_impl.h|  62 
 cmd/os_mgmt/src/os_mgmt.c | 190 
 cmd/os_mgmt/src/os_mgmt_config.h  |  22 ++
 cmd/os_mgmt/src/stubs.c   |  38 +++
 19 files changed, 1990 insertions(+)

diff --git a/cmd/fs_mgmt/include/fs_mgmt/fs_mgmt.h 
b/cmd/fs_mgmt/include/fs_mgmt/fs_mgmt.h
new file mode 100644
index 000..38173fd
--- /dev/null
+++ b/cmd/fs_mgmt/include/fs_mgmt/fs_mgmt.h
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef H_FS_MGMT_
+#define H_FS_MGMT_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Command IDs for file system management group.
+ */
+#define FS_MGMT_ID_FILE 0
+
+/**
+ * @brief Registers the file system management command handler group.
+ */ 
+void fs_mgmt_register_group(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/cmd/fs_mgmt/include/fs_mgmt/fs_mgmt_impl.h 
b/cmd/fs_mgmt/include/fs_mgmt/fs_mgmt_impl.h
new file mode 100644
index 000..3cb30b8
--- /dev/null
+++ b/cmd/fs_mgmt/include/fs_mgmt/fs_mgmt_impl.h
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @file
+ * @brief Declares implementation-specific functions required by file system
+ *management.  The default stubs can be overridden with functions that
+ *are compatible with the host OS.
+ */
+
+#ifndef H_FS_MGMT_IMPL_
+#define H_FS_MGMT_IMPL_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Retrieves the length of the file at the specified path.
+ *
+ * @param path  The path of the file to query.
+ * @param out_len   On success, the file length gets written here.
+ *
+ * @return  0 on success, MGMT_ERR_[...] code on failure.
+ */
+int fs_mgmt_impl_filelen(const char *path, size_t *out_len);
+
+/**
+ * @brief Reads the specified chunk of file data.
+ *
+ * @param path  The path of the file to read from.
+ * @param offsetThe byte offset to read from.
+ * @param len   The number of bytes to read.
+ * @param out_data  On success, the