#define ASC(errcode) (((errcode) >> 8) & 0xFF)
#define ASCQ(errcode) ((errcode) & 0xFF)
-static bool is_mounted(const char *device) {
- struct stat statbuf;
- FILE *fp;
- int maj, min;
- bool mounted = false;
-
- if (stat(device, &statbuf) < 0)
- return false;
-
- fp = fopen("/proc/self/mountinfo", "re");
- if (!fp)
- return false;
- while (fscanf(fp, "%*s %*s %i:%i %*[^\n]", &maj, &min) == 2) {
- if (makedev(maj, min) == statbuf.st_rdev) {
- mounted = true;
- break;
- }
- }
- fclose(fp);
- return mounted;
-}
-
static void info_scsi_cmd_err(const char *cmd, int err) {
if (err == -1)
log_debug("%s failed", cmd);
for (cnt = 20; cnt > 0; cnt--) {
struct timespec duration;
- fd = open(node, O_RDONLY|O_NONBLOCK|O_CLOEXEC|(is_mounted(node) ? 0 : O_EXCL));
+ fd = open(node, O_RDONLY|O_NONBLOCK|O_CLOEXEC);
if (fd >= 0 || errno != EBUSY)
break;
duration.tv_sec = 0;