Portál AbcLinuxu, 1. května 2025 22:58
A nejde to treba resit zavolanim nejaky funkce HALu a udisku, aby ignorovaly to jednotku DVD?Něco jako killall hald?
mount
, když nezadáš -t
, hádá typ FS právě pomocí blkid.
EVALUATE
, vyzerá to zajímavě, cituji:
The "udev" method uses udev /dev/disk/by-* symlinks and the "scan" method scans all block devices from the /proc/partitions file.
char *blkid_devno_to_devname(dev_t devno) { struct dir_list *list = NULL, *new_list = NULL; char *devname = NULL; const char **dir; /* * Add the starting directories to search in reverse order of * importance, since we are using a stack... */ for (dir = devdirs; *dir; dir++) add_to_dirlist(*dir, NULL, &list); while (list) { struct dir_list *current = list; list = list->next; DBG(DEBUG_DEVNO, printf("directory %s\n", current->name)); blkid__scan_dir(current->name, devno, &new_list, &devname); free(current->name); free(current); if (devname) break; /* * If we're done checking at this level, descend to * the next level of subdirectories. (breadth-first) */ if (list == NULL) { list = new_list; new_list = NULL; } } free_dirlist(&list); free_dirlist(&new_list); if (!devname) { DBG(DEBUG_DEVNO, printf("blkid: couldn't find devno 0x%04lx\n", (unsigned long) devno)); } else { DBG(DEBUG_DEVNO, printf("found devno 0x%04llx as %s\n", (long long)devno, devname)); } return devname; }Hledání souboru zařízení skenováním předdefinovaných adresářů a na každý nalezený soubor volat fstat(), aby ho našel, to se na mě nezlobte, ale je to prasárna. Ono to totiž zatím "nějak" funguje, tak to nikoho netrápí.
if (S_ISBLK(sb.st_mode) && ioctl(fd, CDROM_GET_CAPABILITY, NULL) >= 0) pr->flags |= BLKID_CDROM_DEV;To jako, že character device nemůže být CD-ROM? Např /dev/sg1 u mě je character device a CD-ROM to teda je. Ale pravda, že udisks testuje jen blokové zařízení.
Blkid je část e2fsprogs a je to poměrně klíčová součást systému.Niektoré distribúcie používajú verziu knižnice, ktoré je v util-linux-ng.
.... nějaký věcičky k zavádění procesu do paměti a tak .... 23:56:09 open("/dev/sr0", O_RDONLY) = 3 23:56:09 fadvise64(3, 0, 0, POSIX_FADV_RANDOM) = 0 23:56:09 fstat(3, {st_mode=S_IFBLK|0660, st_rdev=makedev(11, 0), ...}) = 0 23:56:09 uname({sys="Linux", node="Jardik-PC", ...}) = 0 23:56:09 ioctl(3, BLKGETSIZE64, 0xe11020) = 0 23:56:09 fstat(3, {st_mode=S_IFBLK|0660, st_rdev=makedev(11, 0), ...}) = 0 23:56:09 lseek(3, 0, SEEK_SET) = 0 23:56:09 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 23:56:27 lseek(3, 0, SEEK_SET) = 0 23:56:27 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 23:56:35 lseek(3, 0, SEEK_SET) = 0 23:56:35 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 23:56:44 lseek(3, 0, SEEK_SET) = 0 23:56:44 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 23:56:53 ioctl(3, BLKSSZGET, 0xe11030) = 0 23:56:53 lseek(3, 0, SEEK_SET) = 0 23:56:53 read(3, 0xe11808, 512) = -1 EIO (Input/output error) 23:57:02 lseek(3, 0, SEEK_SET) = 0 23:57:02 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 23:57:11 lseek(3, 0, SEEK_SET) = 0 23:57:11 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 23:57:20 lseek(3, 0, SEEK_SET) = 0 23:57:20 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 23:57:29 lseek(3, 0, SEEK_SET) = 0 23:57:29 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 23:57:38 lseek(3, 28672, SEEK_SET) = 28672 23:57:38 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 23:57:47 lseek(3, 0, SEEK_SET) = 0 23:57:47 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 23:57:56 lseek(3, 0, SEEK_SET) = 0 23:57:56 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 23:58:05 lseek(3, 0, SEEK_SET) = 0 23:58:05 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 23:58:14 lseek(3, 0, SEEK_SET) = 0 23:58:14 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 23:58:22 lseek(3, 0, SEEK_SET) = 0 23:58:22 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 23:58:31 lseek(3, 0, SEEK_SET) = 0 23:58:31 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 23:58:40 lseek(3, 0, SEEK_SET) = 0 23:58:40 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 23:58:49 lseek(3, 0, SEEK_SET) = 0 23:58:49 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 23:58:58 lseek(3, 0, SEEK_SET) = 0 23:58:58 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 23:59:07 lseek(3, 0, SEEK_SET) = 0 23:59:07 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 23:59:16 lseek(3, 0, SEEK_SET) = 0 23:59:16 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 23:59:25 lseek(3, 0, SEEK_SET) = 0 23:59:25 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 23:59:34 lseek(3, 3072, SEEK_SET) = 3072 23:59:34 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 23:59:43 lseek(3, 3072, SEEK_SET) = 3072 23:59:43 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 23:59:52 lseek(3, 3072, SEEK_SET) = 3072 23:59:52 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:00:00 lseek(3, 3072, SEEK_SET) = 3072 00:00:00 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:00:09 lseek(3, 7168, SEEK_SET) = 7168 00:00:09 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:00:18 lseek(3, 7168, SEEK_SET) = 7168 00:00:18 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:00:27 lseek(3, 7168, SEEK_SET) = 7168 00:00:27 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:00:36 lseek(3, 7168, SEEK_SET) = 7168 00:00:36 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:00:45 lseek(3, 15360, SEEK_SET) = 15360 00:00:45 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:00:54 lseek(3, 15360, SEEK_SET) = 15360 00:00:54 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:01:03 lseek(3, 15360, SEEK_SET) = 15360 00:01:03 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:01:12 lseek(3, 15360, SEEK_SET) = 15360 00:01:12 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:01:21 lseek(3, 31744, SEEK_SET) = 31744 00:01:21 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:01:30 lseek(3, 31744, SEEK_SET) = 31744 00:01:30 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:01:38 lseek(3, 31744, SEEK_SET) = 31744 00:01:38 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:01:47 lseek(3, 31744, SEEK_SET) = 31744 00:01:47 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:01:56 lseek(3, 64512, SEEK_SET) = 64512 00:01:56 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:02:05 lseek(3, 64512, SEEK_SET) = 64512 00:02:05 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:02:14 lseek(3, 64512, SEEK_SET) = 64512 00:02:14 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:02:23 lseek(3, 64512, SEEK_SET) = 64512 00:02:23 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:02:32 lseek(3, 3072, SEEK_SET) = 3072 00:02:32 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:02:41 lseek(3, 3072, SEEK_SET) = 3072 00:02:41 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:02:50 lseek(3, 7168, SEEK_SET) = 7168 00:02:50 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:02:59 lseek(3, 7168, SEEK_SET) = 7168 00:02:59 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:03:08 lseek(3, 15360, SEEK_SET) = 15360 00:03:08 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:03:17 lseek(3, 15360, SEEK_SET) = 15360 00:03:17 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:03:25 lseek(3, 31744, SEEK_SET) = 31744 00:03:25 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:03:34 lseek(3, 31744, SEEK_SET) = 31744 00:03:34 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:03:43 lseek(3, 64512, SEEK_SET) = 64512 00:03:43 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:03:52 lseek(3, 64512, SEEK_SET) = 64512 00:03:52 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:04:01 lseek(3, 0, SEEK_SET) = 0 00:04:01 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:04:10 lseek(3, 1024, SEEK_SET) = 1024 00:04:10 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:04:19 lseek(3, 1024, SEEK_SET) = 1024 00:04:19 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:04:28 lseek(3, 1024, SEEK_SET) = 1024 00:04:28 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:04:37 lseek(3, 1024, SEEK_SET) = 1024 00:04:37 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:04:46 lseek(3, 1024, SEEK_SET) = 1024 00:04:46 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:04:55 lseek(3, 8192, SEEK_SET) = 8192 00:04:55 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:05:04 lseek(3, 65536, SEEK_SET) = 65536 00:05:04 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:05:12 lseek(3, 65536, SEEK_SET) = 65536 00:05:12 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:05:20 lseek(3, 65536, SEEK_SET) = 65536 00:05:20 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:05:28 lseek(3, 8192, SEEK_SET) = 8192 00:05:28 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:05:37 lseek(3, 65536, SEEK_SET) = 65536 00:05:37 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:05:46 lseek(3, 32768, SEEK_SET) = 32768 00:05:46 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:05:54 lseek(3, 32768, SEEK_SET) = 32768 00:05:54 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:06:03 lseek(3, 32768, SEEK_SET) = 32768 00:06:03 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:06:12 lseek(3, 32768, SEEK_SET) = 32768 00:06:12 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:06:21 lseek(3, 32768, SEEK_SET) = 32768 00:06:21 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:06:30 lseek(3, 32768, SEEK_SET) = 32768 00:06:30 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:06:39 lseek(3, 32768, SEEK_SET) = 32768 00:06:39 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:06:48 lseek(3, 32768, SEEK_SET) = 32768 00:06:48 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:06:57 lseek(3, 32768, SEEK_SET) = 32768 00:06:57 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:07:06 lseek(3, 32768, SEEK_SET) = 32768 00:07:06 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:07:15 lseek(3, 131072, SEEK_SET) = 131072 00:07:15 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:07:23 lseek(3, 131072, SEEK_SET) = 131072 00:07:23 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:07:31 lseek(3, 135168, SEEK_SET) = 135168 00:07:31 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:07:39 lseek(3, 135168, SEEK_SET) = 135168 00:07:39 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:07:48 lseek(3, 139264, SEEK_SET) = 139264 00:07:48 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:07:56 lseek(3, 139264, SEEK_SET) = 139264 00:07:56 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:08:04 lseek(3, 393216, SEEK_SET) = 393216 00:08:04 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:08:12 lseek(3, 393216, SEEK_SET) = 393216 00:08:12 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:08:21 lseek(3, 397312, SEEK_SET) = 397312 00:08:21 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:08:29 lseek(3, 397312, SEEK_SET) = 397312 00:08:29 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:08:37 lseek(3, 401408, SEEK_SET) = 401408 00:08:37 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:08:46 lseek(3, 401408, SEEK_SET) = 401408 00:08:46 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:08:54 lseek(3, 1024, SEEK_SET) = 1024 00:08:54 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:09:03 lseek(3, 1024, SEEK_SET) = 1024 00:09:03 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:09:12 lseek(3, 1024, SEEK_SET) = 1024 00:09:12 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:09:21 lseek(3, 1024, SEEK_SET) = 1024 00:09:21 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:09:30 lseek(3, 0, SEEK_SET) = 0 00:09:30 read(3, 0xe11808, 1377) = -1 EIO (Input/output error) 00:09:39 lseek(3, 8192, SEEK_SET) = 8192 00:09:39 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:09:48 lseek(3, 512, SEEK_SET) = 512 00:09:48 read(3, 0xe11808, 512) = -1 EIO (Input/output error) 00:09:56 lseek(3, 2048, SEEK_SET) = 2048 00:09:56 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:10:05 lseek(3, 2048, SEEK_SET) = 2048 00:10:05 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:10:14 lseek(3, 0, SEEK_SET) = 0 00:10:14 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:10:23 lseek(3, 0, SEEK_SET) = 0 00:10:23 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:10:32 lseek(3, 0, SEEK_SET) = 0 00:10:32 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:10:41 lseek(3, 0, SEEK_SET) = 0 00:10:41 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:10:50 lseek(3, 1024, SEEK_SET) = 1024 00:10:50 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:10:59 lseek(3, 1024, SEEK_SET) = 1024 00:10:59 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:11:08 lseek(3, 1024, SEEK_SET) = 1024 00:11:08 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:11:17 lseek(3, 1024, SEEK_SET) = 1024 00:11:17 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:11:26 lseek(3, 1024, SEEK_SET) = 1024 00:11:26 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:11:34 lseek(3, 65536, SEEK_SET) = 65536 00:11:34 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:11:43 lseek(3, 65536, SEEK_SET) = 65536 00:11:43 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:11:51 lseek(3, 8192, SEEK_SET) = 8192 00:11:51 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:12:00 lseek(3, 1024, SEEK_SET) = 1024 00:12:00 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:12:09 lseek(3, 2048, SEEK_SET) = 2048 00:12:09 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:12:18 lseek(3, 4096, SEEK_SET) = 4096 00:12:18 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:12:27 lseek(3, 8192, SEEK_SET) = 8192 00:12:27 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:12:36 lseek(3, 0, SEEK_SET) = 0 00:12:36 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:12:45 lseek(3, 1024, SEEK_SET) = 1024 00:12:45 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:12:54 lseek(3, 0, SEEK_SET) = 0 00:12:54 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:13:03 lseek(3, 0, SEEK_SET) = 0 00:13:03 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:13:11 lseek(3, 0, SEEK_SET) = 0 00:13:11 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:13:20 lseek(3, 0, SEEK_SET) = 0 00:13:20 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:13:29 lseek(3, 4096, SEEK_SET) = 4096 00:13:29 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:13:38 lseek(3, 65536, SEEK_SET) = 65536 00:13:38 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:13:46 lseek(3, 0, SEEK_SET) = 0 00:13:46 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:13:55 lseek(3, 0, SEEK_SET) = 0 00:13:55 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:14:04 lseek(3, 2097152, SEEK_SET) = 2097152 00:14:04 read(3, 0xe11808, 1024) = -1 EIO (Input/output error) 00:14:13 close(3) = 0 00:14:13 exit_group(2) = ?Pro každej typ FS, co to zná to v podstatě hledá, jestli tam je superblok a pod. Jenže vždy čtení selže. Otázkou je proč. Schválně jsem si napsal testovací prográmek, kterej čte bloky o velikostech 512B - 32k. U CD/DVD/BD je správná velikost bloku 2k, jenže tam je taky chyba. I u 32k (velikost ECC bloku) je chyba. MMC standard nám říká:
When recorded, DVD+RW medium is ECC block readable. An intelligent controller may separate individual sector data from a decoded ECC block. Thus for the Host, DVD+RW media is 2 048 byte sector readable.
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.