> + if (lstat(filename, &sb) < 0) { > + fprintf(stderr, "%s: stat failed: %s\n", filename, > strerror(errno)); > + return -errno; > + } > + > + if (S_ISBLK(sb.st_mode)) > + filename = raw_get_rawdevice(filename);
Please move the lstat and S_ISBLK check into raw_get_rawdevice. Also it might be worth to rename it to something like raw_normalize_devicepath.