Skip to content

Commit

Permalink
Merge pull request #46 from arthursimchaev/dev
Browse files Browse the repository at this point in the history
Promote version to 4.13.5
  • Loading branch information
arthur-simchaev-wdc authored Mar 15, 2023
2 parents 44092a6 + 060c0a4 commit 18c0a84
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 39 deletions.
1 change: 1 addition & 0 deletions options.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define OK 0
#define ERROR -1
#define INVALID -1
#define WARNING -2

#ifndef _UAPI_LINUX_LIMITS_H
#define PATH_MAX 4096
Expand Down
2 changes: 1 addition & 1 deletion ufs.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "ufs_rpmb.h"
#include "ufs_hmr.h"

#define UFS_BSG_UTIL_VERSION "3.13.4"
#define UFS_BSG_UTIL_VERSION "4.13.5"

typedef int (*command_function)(struct tool_options *opt);

Expand Down
2 changes: 2 additions & 0 deletions ufs.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
#define MAX_IOCTL_BUF_SIZE (256L * 1024)

#define QUERY_DESC_MAX_SIZE 255

enum sg_struct_type {
SG4_TYPE = 0,
SG3_TYPE
Expand Down
82 changes: 44 additions & 38 deletions ufs_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -1145,13 +1145,14 @@ static int do_unit_desc(int fd, __u8 lun, char *data_file)
{
struct ufs_bsg_request bsg_req = {0};
struct ufs_bsg_reply bsg_rsp = {0};
__u8 data_buf[QUERY_DESC_UNIT_MAX_SIZE] = {0};
__u8 data_buf[QUERY_DESC_MAX_SIZE] = {0};
int rc = 0;

rc = do_read_desc(fd, &bsg_req, &bsg_rsp, QUERY_DESC_IDN_UNIT, lun,
QUERY_DESC_UNIT_MAX_SIZE, data_buf);
QUERY_DESC_MAX_SIZE, data_buf);
if (rc) {
print_error("Could not read unit descriptor error", rc);
if (rc == ERROR)
print_error("Could not read unit descriptor");
goto out;
}

Expand Down Expand Up @@ -1179,14 +1180,14 @@ static int do_interconnect_desc(int fd, char *data_file)
{
struct ufs_bsg_request bsg_req = {0};
struct ufs_bsg_reply bsg_rsp = {0};
__u8 data_buf[QUERY_DESC_INTERCONNECT_MAX_SIZE] = {0};
__u8 data_buf[QUERY_DESC_MAX_SIZE] = {0};
int rc = 0;

rc = do_read_desc(fd, &bsg_req, &bsg_rsp, QUERY_DESC_IDN_INTERCONNECT,
0, QUERY_DESC_INTERCONNECT_MAX_SIZE, data_buf);
0, QUERY_DESC_MAX_SIZE, data_buf);
if (rc) {
print_error("Could not read interconnect descriptor error %d",
rc);
if (rc == ERROR)
print_error("Could not read interconnect descriptor");
goto out;
}

Expand All @@ -1212,14 +1213,14 @@ static int do_geo_desc(int fd, char *data_file)
{
struct ufs_bsg_request bsg_req = {0};
struct ufs_bsg_reply bsg_rsp = {0};
__u8 data_buf[QUERY_DESC_GEOMETRY_MAX_SIZE] = {0};
__u8 data_buf[QUERY_DESC_MAX_SIZE] = {0};
int rc = 0;

rc = do_read_desc(fd, &bsg_req, &bsg_rsp, QUERY_DESC_IDN_GEOMETRY, 0,
QUERY_DESC_GEOMETRY_MAX_SIZE, data_buf);
QUERY_DESC_MAX_SIZE, data_buf);
if (rc) {
print_error("Could not read geometry descriptor , error %d",
rc);
if (rc == ERROR)
print_error("Could not read geometry descriptor");
goto out;
}

Expand All @@ -1245,14 +1246,15 @@ static int do_power_desc(int fd, char *data_file)
{
struct ufs_bsg_request bsg_req = {0};
struct ufs_bsg_reply bsg_rsp = {0};
__u8 data_buf[QUERY_DESC_POWER_MAX_SIZE] = {0};
__u8 data_buf[QUERY_DESC_MAX_SIZE] = {0};
int rc = 0;

rc = do_read_desc(fd, &bsg_req, &bsg_rsp,
QUERY_DESC_IDN_POWER, 0, QUERY_DESC_POWER_MAX_SIZE,
QUERY_DESC_IDN_POWER, 0, QUERY_DESC_MAX_SIZE,
data_buf);
if (rc) {
print_error("Could not read power descriptor , error %d", rc);
if (rc == ERROR)
print_error("Could not read power descriptor");
goto out;
}

Expand Down Expand Up @@ -1286,14 +1288,14 @@ static int do_health_desc(int fd, char *data_file)
{
struct ufs_bsg_request bsg_req = {0};
struct ufs_bsg_reply bsg_rsp = {0};
__u8 data_buf[QUERY_DESC_HEALTH_MAX_SIZE] = {0};
__u8 data_buf[QUERY_DESC_MAX_SIZE] = {0};
int rc = 0;

rc = do_read_desc(fd, &bsg_req, &bsg_rsp, QUERY_DESC_IDN_HEALTH, 0,
QUERY_DESC_HEALTH_MAX_SIZE, data_buf);
QUERY_DESC_MAX_SIZE, data_buf);
if (rc) {
print_error("Could not read device health descriptor error %d",
rc);
if (rc == ERROR)
print_error("Could not read device health descriptor");
goto out;
}

Expand Down Expand Up @@ -1375,7 +1377,7 @@ static int do_conf_desc(int fd, __u8 opt, __u8 index, char *data_file)
int file_size;
struct ufs_bsg_request bsg_req = {0};
struct ufs_bsg_reply bsg_rsp = {0};
__u8 conf_desc_buf[QUERY_DESC_CONFIGURAION_MAX_SIZE] = {0};
__u8 conf_desc_buf[QUERY_DESC_MAX_SIZE] = {0};
int offset, i;
int data_fd = INVALID;

Expand Down Expand Up @@ -1413,11 +1415,11 @@ static int do_conf_desc(int fd, __u8 opt, __u8 index, char *data_file)

rc = do_read_desc(fd, &bsg_req, &bsg_rsp,
QUERY_DESC_IDN_CONFIGURAION,
index, QUERY_DESC_CONFIGURAION_MAX_SIZE,
index, QUERY_DESC_MAX_SIZE,
conf_desc_buf);
if (rc) {
print_error("Coudn't read config descriptor error %d",
rc);
if (rc == ERROR)
print_error("Coudn't read config descriptor");

goto out;
}
Expand Down Expand Up @@ -1549,8 +1551,8 @@ static int check_read_desc_size(__u8 idn, __u8 *data_buf)
if (unoff) {
int file_status;

rc = ERROR;
print_error("Unofficial %s desc size, len = 0x%x",
rc = WARNING;
print_warn("Unofficial %s desc size, len = 0x%x",
(char *)desc_text[idn], data_buf[0]);
file_status = write_file("unofficial.dat", data_buf,
data_buf[0]);
Expand Down Expand Up @@ -1675,14 +1677,15 @@ int do_device_desc(int fd, __u8 *desc_buff, char *data_file)
{
struct ufs_bsg_request bsg_req = {0};
struct ufs_bsg_reply bsg_rsp = {0};
__u8 data_buf[QUERY_DESC_DEVICE_MAX_SIZE] = {0};
__u8 data_buf[QUERY_DESC_MAX_SIZE] = {0};
int rc = 0;

rc = do_read_desc(fd, &bsg_req, &bsg_rsp,
QUERY_DESC_IDN_DEVICE, 0,
QUERY_DESC_DEVICE_MAX_SIZE, data_buf);
QUERY_DESC_IDN_DEVICE, 0,
QUERY_DESC_MAX_SIZE, data_buf);
if (rc) {
print_error("Could not read device descriptor , error %d", rc);
if (rc == ERROR)
print_error("Could not read device descriptor");
goto out;
}
if (!desc_buff)
Expand Down Expand Up @@ -1710,19 +1713,22 @@ static int do_fbo_desc(int fd)
{
struct ufs_bsg_request bsg_req = {0};
struct ufs_bsg_reply bsg_rsp = {0};
__u8 data_buf[QUERY_DESC_FBO_MAX_SIZE] = {0};
int ret = 0;
__u8 data_buf[QUERY_DESC_MAX_SIZE] = {0};
int rc = 0;

ret = do_read_desc(fd, &bsg_req, &bsg_rsp, QUERY_DESC_IDN_FBO, 0,
QUERY_DESC_FBO_MAX_SIZE, data_buf);
if (ret) {
print_error("Could not read FBO descriptor error %d", ret);
} else {
print_descriptors("FBO Descriptor:", data_buf,
device_fbo_desc_field_name, data_buf[0]);
rc = do_read_desc(fd, &bsg_req, &bsg_rsp, QUERY_DESC_IDN_FBO, 0,
QUERY_DESC_MAX_SIZE, data_buf);
if (rc) {
if (rc == ERROR)
print_error("Could not read FBO descriptor");

goto out;
}

return ret;
print_descriptors("FBO Descriptor:", data_buf,
device_fbo_desc_field_name, data_buf[0]);
out:
return rc;
}

int do_desc(struct tool_options *opt)
Expand Down

0 comments on commit 18c0a84

Please sign in to comment.