- if ((f = open(argv[1], O_RDWR)) == -1) {
- fatalError( "freeramdisk: cannot open %s: %s\n", argv[1], strerror(errno));
- }
- if (ioctl(f, BLKFLSBUF) < 0) {
- fatalError( "freeramdisk: failed ioctl on %s: %s\n", argv[1], strerror(errno));
+ f = xfopen(argv[1], "r+");
+
+ if (ioctl(fileno(f), BLKFLSBUF) < 0) {
+ perror_msg_and_die("failed ioctl on %s", argv[1]);