#include #include //#include #include #define SEAGATE_REPORT_FULL_CAPACITY 0xF1 int get_identity(int fd) { unsigned char args[4+512] = {WIN_IDENTIFY,0,0,1,}; struct hd_driveid *id = (struct hd_driveid *)&args[4]; if (ioctl(fd, HDIO_DRIVE_CMD, &args)) { perror("HDIO_DRIVE_CMD"); fprintf(stderr, "WIN_IDENTIFY failed - trying WIN_PIDENTIFY\n"); args[0] = WIN_PIDENTIFY; if (ioctl(fd, HDIO_DRIVE_CMD, &args)) { perror("HDIO_DRIVE_CMD"); fprintf(stderr, "WIN_PIDENTIFY also failed - giving up\n"); exit(1); } } printf("id->command_set_1: 0x%X\n", id->command_set_1); printf("id->lba_capacity: %lu\n", id->lba_capacity); } /* * result: in LBA mode precisely what is expected * in CHS mode the correct H and S, and C mod 65536. */ int set_feature(int fd) { unsigned char args[4] = {WIN_SETFEATURES,0,0xf1,0}; int i; if (ioctl(fd, HDIO_DRIVE_CMD, &args)) { perror("HDIO_DRIVE_CMD failed WIN_SETFEATURES"); for (i=0; i<4; i++) printf("%d = 0x%X\n", args[i], args[i]); exit(1); } return 0; } main(int argc, char **argv){ int fd, c; char *device = NULL; /* e.g. "/dev/hda" */ int slave = 0; device = argv[1]; if (!device) { fprintf(stderr, "no device specified - " "use e.g. \"seagate /dev/hdb\"\n"); exit(1); } printf("Using device %s\n", device); fd = open(device, O_RDONLY); if (fd == -1) { perror("open"); exit(1); } printf("Sending Set Features F1 subcommand\n"); set_feature(fd); printf("Done.\n"); return 0; }