| * No copyright is claimed. This code is in the public domain; do with |
| * Written by Karel Zak <kzak@redhat.com> |
| int is_whole_disk_fd(int fd, const char *name) |
| struct hd_geometry geometry; |
| int i = ioctl(fd, HDIO_GETGEO, &geometry); |
| return geometry.start == 0; |
| * The "silly heuristic" is still sexy for us, because |
| * for example Xen doesn't implement HDIO_GETGEO for virtual |
| * block devices (/dev/xvda). |
| * -- kzak@redhat.com (23-Feb-2006) |
| return !isdigit(name[-1]); |
| int is_whole_disk(const char *name) |
| fd = open(name, O_RDONLY); |
| res = is_whole_disk_fd(fd, name); |
| int main(int argc, char **argv) |
| fprintf(stderr, "usage: %s <device>\n", argv[0]); |
| printf("%s: is%s whole disk\n", argv[1], |
| is_whole_disk(argv[1]) ? "" : " NOT"); |