|
|
#include <scsi/sg.h> | #include <scsi/sg.h> |
#include <scsi/scsi_ioctl.h> | #include <scsi/scsi_ioctl.h> |
| |
|
#define CLOSE(fd) if (close(fd)==-1) { \ |
|
perror(programName); \ |
|
exit(1); \ |
|
} |
|
|
|
#define FCLOSE(fd) if (fclose(fd)==-1) { \ |
|
perror(programName); \ |
|
exit(1); \ |
|
} |
|
|
/* Global Variables */ | /* Global Variables */ |
const char *version = VERSION; /* program version */ | const char *version = VERSION; /* program version */ |
int a_option = 0; /* command flags and arguments */ | int a_option = 0; /* command flags and arguments */ |
|
|
GetMajorMinor(s1, &mtabmaj, &mtabmin); | GetMajorMinor(s1, &mtabmaj, &mtabmin); |
if (((strcmp(s1, name) == 0) || (strcmp(s2, name) == 0)) || | if (((strcmp(s1, name) == 0) || (strcmp(s2, name) == 0)) || |
((maj != -1) && (maj == mtabmaj) && (min == mtabmin))) { | ((maj != -1) && (maj == mtabmaj) && (min == mtabmin))) { |
fclose(fp); |
FCLOSE(fp); |
*deviceName = strdup(s1); | *deviceName = strdup(s1); |
*mountName = strdup(s2); | *mountName = strdup(s2); |
return 1; | return 1; |
|
|
} | } |
*deviceName = 0; | *deviceName = 0; |
*mountName = 0; | *mountName = 0; |
fclose(fp); |
FCLOSE(fp); |
return 0; | return 0; |
} | } |
| |
|
|
while (fgets(line, sizeof(line), fp) != 0) { | while (fgets(line, sizeof(line), fp) != 0) { |
rc = sscanf(line, "%1023s %1023s", s1, s2); | rc = sscanf(line, "%1023s %1023s", s1, s2); |
if (rc >= 2 && s1[0] != '#' && strcmp(s2, name) == 0) { | if (rc >= 2 && s1[0] != '#' && strcmp(s2, name) == 0) { |
fclose(fp); |
FCLOSE(fp); |
*deviceName = strdup(s1); | *deviceName = strdup(s1); |
*mountName = strdup(s2); | *mountName = strdup(s2); |
return 1; | return 1; |
} | } |
} | } |
fclose(fp); |
FCLOSE(fp); |
return 0; | return 0; |
} | } |
| |
|
|
} | } |
} | } |
} | } |
fclose(fp); |
FCLOSE(fp); |
} | } |
| |
| |
|
|
} | } |
| |
/* cleanup */ | /* cleanup */ |
close(fd); |
CLOSE(fd); |
free(device); | free(device); |
free(deviceName); | free(deviceName); |
free(fullName); | free(fullName); |