Skip to content

Commit

Permalink
sg_wr_mode: fix --contents and --cfile= handling; #40
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@1048 6180dd3e-e324-4e3e-922d-17de1ae2f315
  • Loading branch information
doug-gilbert committed Aug 31, 2023
1 parent ee92ca0 commit c278800
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion BSD_LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

Copyright (c) 1999-2022, Douglas Gilbert
Copyright (c) 1999-2023, Douglas Gilbert
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
4 changes: 3 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ Each utility has its own version number, date of last change and
some description at the top of its ".c" file. All utilities in the main
directory have their own "man" pages. There is also a sg3_utils man page.

Changelog for pre-release sg3_utils-1.49 [20230821] [svn: r1047]
Changelog for pre-release sg3_utils-1.49 [20230831] [svn: r1048]
- apply https://github.com/doug-gilbert/sg3_utils/pull/39
and its revision [20230807] mainly for Android
- sg_inq: update version descriptors to T10 table 20230814
- sg_wr_mode: fix --contents and --cfile= handling
https://github.com/doug-gilbert/sg3_utils/issues/40
- testing/sg_chk_inq_vd.c: test internal table against T10
version descriptor file

Expand Down
12 changes: 9 additions & 3 deletions src/sg_wr_mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* mode page on the given device.
*/

static const char * version_str = "1.30 20230623";
static const char * version_str = "1.31 20230831";

#define ME "sg_wr_mode: "

Expand Down Expand Up @@ -374,17 +374,23 @@ main(int argc, char * argv[])
}
}
if (cfile_arg || contents_arg) {
const char * inp = (cfile_arg ? cfile_arg : contents_arg);

if (cfile_arg && contents_arg) {
pr2serr("Cannot have both --contents= and --cfile= options\n");
return SG_LIB_SYNTAX_ERROR;
}
memset(read_in, 0, read_in_sz);
if ((ret = build_mode_page(optarg, !! cfile_arg, do_raw, read_in,
&read_in_len, read_in_sz))) {
if ((ret = build_mode_page(inp, !! cfile_arg, do_raw,
read_in, &read_in_len, read_in_sz))) {
pr2serr("bad argument to '%s'\n", cfile_arg ? "--cfile=" :
"--contents=");
return ret;
}
if (verbose > 5) {
pr2serr("Decoded contents:\n");
hex2stderr(read_in, read_in_len, 1);
}
got_contents = true;
}

Expand Down

0 comments on commit c278800

Please sign in to comment.