Skip to content
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

Isobusfs fixes #530

Merged
merged 3 commits into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions isobusfs/isobusfs_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ static int isobusfs_cli_handle_events(struct isobusfs_priv *priv, unsigned int n
};

ret = isobusfs_recv_err(priv->sock_ccm, &emsg);
if (ret && ret != -EINTR)
return ret;
if (ret)
pr_warn("error queue reported error: %i", ret);
}
} else if (ev->data.fd == STDIN_FILENO) {
if (!priv->interactive) {
Expand Down
4 changes: 2 additions & 2 deletions isobusfs/isobusfs_srv.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ static int isobusfs_srv_handle_events(struct isobusfs_srv_priv *priv, unsigned i
};

ret = isobusfs_recv_err(priv->sock_fss, &emsg);
if (ret && ret != -EINTR)
return ret;
if (ret)
pr_warn("error queue reported error: %i", ret);
}
}

Expand Down
26 changes: 17 additions & 9 deletions isobusfs/isobusfs_srv_cm.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,28 +464,30 @@ static int isobusfs_srv_process_volume_status_request(struct isobusfs_srv_priv *
struct isobusfs_cm_vol_stat_req *req =
(struct isobusfs_cm_vol_stat_req *)msg->buf;
char isobusfs_volume_path[ISOBUSFS_MAX_VOLUME_NAME_LENGTH];
size_t path_len, req_name_len, resp_name_len;
char linux_path[ISOBUSFS_SRV_MAX_PATH_LEN];
struct isobusfs_srv_volume *volume = NULL;
struct isobusfs_srv_client *client;
const char *path;
size_t path_len;
int ret, i;

req_name_len = le16toh(req->name_len);

pr_debug("< rx volume status request. mode: %x, length: %d, name: %s",
req->volume_mode, req->name_len, req->name);
req->volume_mode, req_name_len, req->name);

client = isobusfs_srv_get_client_by_msg(priv, msg);
if (!client) {
pr_warn("can't find client");
return ISOBUSFS_ERR_OTHER;
}

if (req->name_len == 0) {
if (req_name_len == 0) {
path = client->current_dir;
path_len = sizeof(client->current_dir);
} else {
path = req->name;
path_len = req->name_len;
path_len = req_name_len;
}

ret = isobusfs_extract_volume_name(path, path_len, isobusfs_volume_path,
Expand All @@ -495,11 +497,12 @@ static int isobusfs_srv_process_volume_status_request(struct isobusfs_srv_priv *
return ISOBUSFS_ERR_OTHER;
}

resp->name_len = strlen(isobusfs_volume_path);
resp_name_len = strlen(isobusfs_volume_path);
resp->name_len = htole16(resp_name_len);
/* the isobusfs_volume_path is already null terminated
* by isobusfs_extract_volume_name()
*/
memcpy(resp->name, isobusfs_volume_path, resp->name_len + 1);
memcpy(resp->name, isobusfs_volume_path, resp_name_len + 1);

ret = isobusfs_path_to_linux_path(priv, isobusfs_volume_path,
sizeof(isobusfs_volume_path),
Expand Down Expand Up @@ -530,7 +533,7 @@ static int isobusfs_srv_process_volume_status_request(struct isobusfs_srv_priv *

if (req->volume_mode & ISOBUSFS_VOL_MODE_PREP_TO_REMOVE) {
if (!volume->removable ||
(req->name_len == 0 &&
(req_name_len == 0 &&
0 /* Current directory is not set condition */)) {
/* Volume is not removable, or the Path Name Length of
* request is zero and the current directory is not set
Expand Down Expand Up @@ -571,10 +574,15 @@ static int isobusfs_srv_volume_status_resp(struct isobusfs_srv_priv *priv,
ret = isobusfs_srv_process_volume_status_request(priv, msg, &resp);
resp.error_code = ret;

buf_size = sizeof(resp);
buf_size = sizeof(resp) - sizeof(resp.name) + le16toh(resp.name_len);
if (buf_size < ISOBUSFS_MIN_TRANSFER_LENGH) {
/* Fill the rest of the buffer with 0xFF. We need to fill
* only buffers under 8 bytes. Padding for ETP/TP is done
* by the kernel.
*/
memset(((uint8_t *) &resp) + buf_size, 0xFF,
ISOBUSFS_MIN_TRANSFER_LENGH - buf_size);
buf_size = ISOBUSFS_MIN_TRANSFER_LENGH;
memset(((uint8_t *) &resp) + sizeof(resp), 0xFF, buf_size - sizeof(resp));
} else if (buf_size > ISOBUSFS_MAX_TRANSFER_LENGH) {
pr_warn("volume status response too long");
resp.error_code = ISOBUSFS_ERR_OUT_OF_MEM;
Expand Down
Loading