1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00

ata_id: skip ATA commands if we find an optical drive

Some drives are reported to erase CD-RW media with the ATA
commands we send.

Thanks to Christoph Stritt <phoenix@jobob.com> for his debugging.

Original bug is here:
  http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=556635
This commit is contained in:
Kay Sievers 2009-11-20 03:03:27 +01:00
parent ecf61aa7fd
commit 160b069c25

View File

@ -38,6 +38,7 @@
#include <linux/types.h>
#include <linux/hdreg.h>
#include <linux/fs.h>
#include <linux/cdrom.h>
#include <arpa/inet.h>
#include "libudev.h"
@ -210,6 +211,16 @@ static int disk_identify (struct udev *udev,
goto fail;
}
/*
* do not confuse optical drive firmware with ATA commands
* some drives are reported to blank CD-RWs
*/
if (ioctl(fd, CDROM_GET_CAPABILITY, NULL) >= 0) {
errno = EIO;
ret = -1;
goto fail;
}
/* So, it's a block device. Let's make sure the ioctls work */
if ((ret = ioctl(fd, BLKGETSIZE64, &size)) < 0)
goto fail;