-
Notifications
You must be signed in to change notification settings - Fork 785
Isobusfs clt srv transfer fixes #629
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
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -603,23 +603,24 @@ struct isobusfs_cli_test_rf_path { | |
| uint8_t flags; | ||
| uint32_t offset; | ||
| uint32_t read_size; | ||
| uint32_t expected_size; | ||
| bool expect_pass; | ||
| }; | ||
|
|
||
| static struct isobusfs_cli_test_rf_path test_rf_patterns[] = { | ||
| /* expected result \\vol1\dir1\dir2\ */ | ||
| { "\\\\vol1\\dir1\\dir2\\file1k", 0, 0, 0, true }, | ||
| { "\\\\vol1\\dir1\\dir2\\file1k", 0, 0, 1, true }, | ||
| { "\\\\vol1\\dir1\\dir2\\file1k", 0, 1, 1, true }, | ||
| { "\\\\vol1\\dir1\\dir2\\file1k", 0, 2, 1, true }, | ||
| { "\\\\vol1\\dir1\\dir2\\file1k", 0, 3, 1, true }, | ||
| { "\\\\vol1\\dir1\\dir2\\file1m", 0, 0, 8, true }, | ||
| { "\\\\vol1\\dir1\\dir2\\file1m", 0, 0, 8 * 100, true }, | ||
| { "\\\\vol1\\dir1\\dir2\\file1m", 0, 100, 8 * 100, true }, | ||
| { "\\\\vol1\\dir1\\dir2\\file1m", 0, 0, ISOBUSFS_MAX_DATA_LENGH, true }, | ||
| { "\\\\vol1\\dir1\\dir2\\file1m", 0, 0, (ISOBUSFS_MAX_DATA_LENGH & ~3) + 16, true }, | ||
| { "\\\\vol1\\dir1\\dir2\\file1m", 0, 0, ISOBUSFS_MAX_DATA_LENGH + 1, true }, | ||
| { "\\\\vol1\\dir1\\dir2\\file1m", 0, 0, -1, true }, | ||
| { "\\\\vol1\\dir1\\dir2\\file1k", 0, 0, 0, 0, true }, | ||
| { "\\\\vol1\\dir1\\dir2\\file1k", 0, 0, 1, 1, true }, | ||
| { "\\\\vol1\\dir1\\dir2\\file1k", 0, 1, 1, 1, true }, | ||
| { "\\\\vol1\\dir1\\dir2\\file1k", 0, 2, 1, 1, true }, | ||
| { "\\\\vol1\\dir1\\dir2\\file1k", 0, 3, 1, 1, true }, | ||
| { "\\\\vol1\\dir1\\dir2\\file1m", 0, 0, 8, 8, true }, | ||
| { "\\\\vol1\\dir1\\dir2\\file1m", 0, 0, 8 * 100, 8 * 100, true }, | ||
| { "\\\\vol1\\dir1\\dir2\\file1m", 0, 100, 8 * 100, 8 * 100, true }, | ||
| { "\\\\vol1\\dir1\\dir2\\file1m", 0, 0, ISOBUSFS_MAX_DATA_LENGH, ISOBUSFS_MAX_DATA_LENGH, true }, | ||
| { "\\\\vol1\\dir1\\dir2\\file1m", 0, 0, (ISOBUSFS_MAX_DATA_LENGH & ~3) + 16, (ISOBUSFS_MAX_DATA_LENGH & ~3) + 16, true }, | ||
| { "\\\\vol1\\dir1\\dir2\\file1m", 0, 0, ISOBUSFS_MAX_DATA_LENGH + 1, ISOBUSFS_MAX_DATA_LENGH + 1, true }, | ||
| { "\\\\vol1\\dir1\\dir2\\file1m", 0, 0, UINT32_MAX, 1024 * 1024, true }, | ||
| }; | ||
|
|
||
| size_t current_rf_pattern_test; | ||
|
|
@@ -678,7 +679,8 @@ static int isobusfs_cli_test_rf_req(struct isobusfs_priv *priv, bool *complete) | |
| &test_rf_patterns[current_rf_pattern_test]; | ||
| uint32_t actual_sum, expected_sum; | ||
| struct timespec current_time; | ||
| ssize_t remaining_size, read_size; | ||
| int64_t remaining_size; | ||
| ssize_t read_size; | ||
| int ret; | ||
|
|
||
| clock_gettime(CLOCK_MONOTONIC, ¤t_time); | ||
|
|
@@ -801,16 +803,23 @@ static int isobusfs_cli_test_rf_req(struct isobusfs_priv *priv, bool *complete) | |
| free(priv->read_data); | ||
| priv->read_data = NULL; | ||
|
|
||
| remaining_size = (tp->offset + tp->read_size) - | ||
| (priv->read_offset + priv->read_data_len); | ||
| pr_debug("remaining_size: %zd, read_offset: %zu, read_data_len: %zu, test read size: %zu, test offset %zu", | ||
| remaining_size, priv->read_offset, priv->read_data_len, | ||
| remaining_size = ((int64_t)tp->offset + tp->read_size) - | ||
|
Contributor
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. I need to verify maximal sizes supported by protocol.. |
||
| ((int64_t)priv->read_offset + priv->read_data_len); | ||
| pr_debug("remaining_size: %lld, read_offset: %zu, read_data_len: %zu, test read size: %u, test offset %u", | ||
| (long long)remaining_size, priv->read_offset, priv->read_data_len, | ||
|
Member
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. If there isn'a max file size defined by the protocol, I suggest to use |
||
| tp->read_size, tp->offset); | ||
| if (remaining_size < 0) { | ||
| pr_err("pattern test failed: %s. Read size is too big", | ||
| tp->path_name); | ||
| ret = -EINVAL; | ||
| goto test_fail; | ||
| } else if (remaining_size == 0) { | ||
| if (tp->read_size > tp->expected_size) { | ||
| pr_err("read test failed: %s. Server returned more data than expected file size (%u > %u)", | ||
| tp->path_name, tp->read_size, tp->expected_size); | ||
| ret = -EINVAL; | ||
| goto test_fail; | ||
| } | ||
| } else if (remaining_size > 0 && priv->read_data_len != 0) { | ||
| priv->read_offset += priv->read_data_len; | ||
|
|
||
|
|
@@ -825,11 +834,20 @@ static int isobusfs_cli_test_rf_req(struct isobusfs_priv *priv, bool *complete) | |
| goto test_fail; | ||
| test_start_time = current_time; | ||
| break; | ||
| } else if (remaining_size > 0 && priv->read_data_len == 0 && tp->expect_pass) { | ||
| pr_err("read test failed: %s. Read size is zero, but expected more data: %zd", | ||
| tp->path_name, remaining_size); | ||
| ret = -EINVAL; | ||
| goto test_fail; | ||
| } else if (remaining_size > 0 && priv->read_data_len == 0) { | ||
| if (tp->read_size > tp->expected_size && | ||
| tp->read_size - remaining_size == tp->expected_size) { | ||
| /* this is acceptable case when read size | ||
| * is larger than actual file size | ||
| */ | ||
| pr_info("read test passed: %s. Reached end of file as expected.", | ||
| tp->path_name); | ||
| } else { | ||
| pr_err("read test failed: %s. Server returned zero bytes, but expected more data: %lld", | ||
| tp->path_name, (long long)remaining_size); | ||
| ret = -EINVAL; | ||
| goto test_fail; | ||
| } | ||
| } | ||
|
|
||
| /* fall troth */ | ||
|
|
||
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.
Do we need here signed variable?