diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 346437a58f56ba72eca424ace36ff23c8b896b14..b821295493734e90b6e0613f6176098805f4ff81 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,3 +1,9 @@ +# v4.NEXT + +### Features +### Bug Fixes +- cta/CTA#259 - cta-rmcd should not exit if /dev/sg0 is missing + # v4.8.7-1 ### Features diff --git a/mediachanger/castorrmc/rmc/rmc_send_scsi_cmd.c b/mediachanger/castorrmc/rmc/rmc_send_scsi_cmd.c index ba1106fd39d3e01c3477dc46a9cab583f9354d77..d453c7085a9dc9c6a860874aa2174099558e9f8e 100644 --- a/mediachanger/castorrmc/rmc/rmc_send_scsi_cmd.c +++ b/mediachanger/castorrmc/rmc/rmc_send_scsi_cmd.c @@ -164,7 +164,6 @@ int rmc_send_scsi_cmd ( int n; int resid = 0; struct stat sbuf; - struct stat sbufa; static char *sg_buffer; static int sg_bufsiz = 0; struct sg_header *sg_hd; @@ -220,19 +219,15 @@ int rmc_send_scsi_cmd ( return (-1); } - /* get the major device ID of the sg devices ... */ - if (stat ("/dev/sg0", &sbufa) < 0) { - serrno = errno; - snprintf (rmc_err_msgbuf, sizeof(rmc_err_msgbuf), "/dev/sg0 : stat error : %s\n", strerror(errno)); - rmc_err_msgbuf[sizeof(rmc_err_msgbuf) - 1] = '\0'; - *msgaddr = rmc_err_msgbuf; - return (-1); - } - /* ... to detect links and use the path directly! */ - if (major(sbuf.st_rdev) == major(sbufa.st_rdev)) { - strcpy (sgpath, path); + struct stat sbufa; + if (stat("/dev/sg0", &sbufa) == 0 && major(sbuf.st_rdev) == major(sbufa.st_rdev)) { + /* If the major device ID of the specified device is the same as the major device ID of sg0, + * we can use the path directly */ + strcpy(sgpath, path); } else { - find_sgpath(sgpath, major(sbuf.st_rdev), minor(sbuf.st_rdev)); + /* Otherwise, look up the path using the (major,minor) device ID. If no match is found, + * sgpath is set to an empty string */ + find_sgpath(sgpath, major(sbuf.st_rdev), minor(sbuf.st_rdev)); } if ((fd = open (sgpath, O_RDWR)) < 0) {