commit
b76bb3f66c
|
|
@ -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);
|
ret = isobusfs_recv_err(priv->sock_ccm, &emsg);
|
||||||
if (ret && ret != -EINTR)
|
if (ret)
|
||||||
return ret;
|
pr_warn("error queue reported error: %i", ret);
|
||||||
}
|
}
|
||||||
} else if (ev->data.fd == STDIN_FILENO) {
|
} else if (ev->data.fd == STDIN_FILENO) {
|
||||||
if (!priv->interactive) {
|
if (!priv->interactive) {
|
||||||
|
|
|
||||||
|
|
@ -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);
|
ret = isobusfs_recv_err(priv->sock_fss, &emsg);
|
||||||
if (ret && ret != -EINTR)
|
if (ret)
|
||||||
return ret;
|
pr_warn("error queue reported error: %i", ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -464,15 +464,17 @@ 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 *req =
|
||||||
(struct isobusfs_cm_vol_stat_req *)msg->buf;
|
(struct isobusfs_cm_vol_stat_req *)msg->buf;
|
||||||
char isobusfs_volume_path[ISOBUSFS_MAX_VOLUME_NAME_LENGTH];
|
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];
|
char linux_path[ISOBUSFS_SRV_MAX_PATH_LEN];
|
||||||
struct isobusfs_srv_volume *volume = NULL;
|
struct isobusfs_srv_volume *volume = NULL;
|
||||||
struct isobusfs_srv_client *client;
|
struct isobusfs_srv_client *client;
|
||||||
const char *path;
|
const char *path;
|
||||||
size_t path_len;
|
|
||||||
int ret, i;
|
int ret, i;
|
||||||
|
|
||||||
|
req_name_len = le16toh(req->name_len);
|
||||||
|
|
||||||
pr_debug("< rx volume status request. mode: %x, length: %d, name: %s",
|
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);
|
client = isobusfs_srv_get_client_by_msg(priv, msg);
|
||||||
if (!client) {
|
if (!client) {
|
||||||
|
|
@ -480,12 +482,12 @@ static int isobusfs_srv_process_volume_status_request(struct isobusfs_srv_priv *
|
||||||
return ISOBUSFS_ERR_OTHER;
|
return ISOBUSFS_ERR_OTHER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req->name_len == 0) {
|
if (req_name_len == 0) {
|
||||||
path = client->current_dir;
|
path = client->current_dir;
|
||||||
path_len = sizeof(client->current_dir);
|
path_len = sizeof(client->current_dir);
|
||||||
} else {
|
} else {
|
||||||
path = req->name;
|
path = req->name;
|
||||||
path_len = req->name_len;
|
path_len = req_name_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = isobusfs_extract_volume_name(path, path_len, isobusfs_volume_path,
|
ret = isobusfs_extract_volume_name(path, path_len, isobusfs_volume_path,
|
||||||
|
|
@ -495,11 +497,12 @@ static int isobusfs_srv_process_volume_status_request(struct isobusfs_srv_priv *
|
||||||
return ISOBUSFS_ERR_OTHER;
|
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
|
/* the isobusfs_volume_path is already null terminated
|
||||||
* by isobusfs_extract_volume_name()
|
* 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,
|
ret = isobusfs_path_to_linux_path(priv, isobusfs_volume_path,
|
||||||
sizeof(isobusfs_volume_path),
|
sizeof(isobusfs_volume_path),
|
||||||
|
|
@ -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 (req->volume_mode & ISOBUSFS_VOL_MODE_PREP_TO_REMOVE) {
|
||||||
if (!volume->removable ||
|
if (!volume->removable ||
|
||||||
(req->name_len == 0 &&
|
(req_name_len == 0 &&
|
||||||
0 /* Current directory is not set condition */)) {
|
0 /* Current directory is not set condition */)) {
|
||||||
/* Volume is not removable, or the Path Name Length of
|
/* Volume is not removable, or the Path Name Length of
|
||||||
* request is zero and the current directory is not set
|
* request is zero and the current directory is not set
|
||||||
|
|
@ -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);
|
ret = isobusfs_srv_process_volume_status_request(priv, msg, &resp);
|
||||||
resp.error_code = ret;
|
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) {
|
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;
|
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) {
|
} else if (buf_size > ISOBUSFS_MAX_TRANSFER_LENGH) {
|
||||||
pr_warn("volume status response too long");
|
pr_warn("volume status response too long");
|
||||||
resp.error_code = ISOBUSFS_ERR_OUT_OF_MEM;
|
resp.error_code = ISOBUSFS_ERR_OUT_OF_MEM;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue