Skip to content

Commit

Permalink
mgmt: mcumgr: grp: fs_mgmt: Update file upload errors
Browse files Browse the repository at this point in the history
Updates possible return errors for fs mgmt file upload, to clarify
when a provided path is on a read-only filesystem or if the mount
point does not exist.

(cherry picked from commit 0d5c508)

Original-Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
GitOrigin-RevId: 0d5c508
Change-Id: Ie0cbd96febc2aac1e5281ab64b5539409d526b5b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/4882968
Reviewed-by: Al Semjonovs <asemjonovs@google.com>
Commit-Queue: Al Semjonovs <asemjonovs@google.com>
Tested-by: ChromeOS Prod (Robot) <chromeos-ci-prod@chromeos-bot.iam.gserviceaccount.com>
Tested-by: Al Semjonovs <asemjonovs@google.com>
  • Loading branch information
nordicjm authored and Chromeos LUCI committed Sep 21, 2023
1 parent 8e15691 commit ac8bda0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
6 changes: 6 additions & 0 deletions include/zephyr/mgmt/mcumgr/grp/fs_mgmt/fs_mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ enum fs_mgmt_err_code_t {

/** The requested checksum or hash type was not found or is not supported by this build. */
FS_MGMT_ERR_CHECKSUM_HASH_NOT_FOUND,

/** The specified mount point was not found or is not mounted. */
FS_MGMT_ERR_MOUNT_POINT_NOT_FOUND,

/** The specified mount point is that of a read-only filesystem. */
FS_MGMT_ERR_READ_ONLY_FILESYSTEM,
};

#ifdef __cplusplus
Expand Down
16 changes: 15 additions & 1 deletion subsys/mgmt/mcumgr/grp/fs_mgmt/src/fs_mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,9 @@ static int fs_mgmt_file_upload(struct smp_streamer *ctxt)
if (rc == -EINVAL) {
rc = FS_MGMT_ERR_FILE_INVALID_NAME;
} else if (rc == -ENOENT) {
rc = FS_MGMT_ERR_FILE_NOT_FOUND;
rc = FS_MGMT_ERR_MOUNT_POINT_NOT_FOUND;
} else if (rc == -EROFS) {
rc = FS_MGMT_ERR_READ_ONLY_FILESYSTEM;
} else {
rc = FS_MGMT_ERR_UNKNOWN;
}
Expand Down Expand Up @@ -909,7 +911,18 @@ static int fs_mgmt_translate_error_code(uint16_t err)
int rc;

switch (err) {
case FS_MGMT_ERR_FILE_INVALID_NAME:
case FS_MGMT_ERR_CHECKSUM_HASH_NOT_FOUND:
rc = MGMT_ERR_EINVAL;
break;

case FS_MGMT_ERR_FILE_NOT_FOUND:
case FS_MGMT_ERR_MOUNT_POINT_NOT_FOUND:
rc = MGMT_ERR_ENOENT;
break;

case FS_MGMT_ERR_UNKNOWN:
case FS_MGMT_ERR_FILE_IS_DIRECTORY:
case FS_MGMT_ERR_FILE_OPEN_FAILED:
case FS_MGMT_ERR_FILE_SEEK_FAILED:
case FS_MGMT_ERR_FILE_READ_FAILED:
Expand All @@ -918,6 +931,7 @@ static int fs_mgmt_translate_error_code(uint16_t err)
case FS_MGMT_ERR_FILE_WRITE_FAILED:
case FS_MGMT_ERR_FILE_OFFSET_NOT_VALID:
case FS_MGMT_ERR_FILE_OFFSET_LARGER_THAN_FILE:
case FS_MGMT_ERR_READ_ONLY_FILESYSTEM:
default:
rc = MGMT_ERR_EUNKNOWN;
}
Expand Down

0 comments on commit ac8bda0

Please sign in to comment.