+ if (fstat(f, &st) < 0) {
+ log_fct("fstat fails %s: %s", dname, strerror(errno));
+ goto fail;
+ }
+
+ if (!S_ISBLK(st.st_mode)) {
+ log_fct("!S_ISBLK fails %s", dname);
+ goto fail;
+ }
+
+ size = (uint64_t)-1;
+ /* So, it's a block device. Let's make sure the ioctls work */
+ if (ioctl(f, BLKGETSIZE64, &size) < 0) {
+ log_fct("ioctl fails %s: %s", dname, strerror(errno));
+ goto fail;
+ }
+
+ if (size <= 0 || size == (uint64_t) -1) {
+ log_fct("ioctl wrong size %s: %ld", dname, size);
+ goto fail;
+ }