X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=extras%2Fvolume_id%2Fvol_id.c;h=889bd3483da174b13f8dac46b55a2cb332720bea;hp=df47501a6bee079f0289ba4f03057f09cb13994f;hb=bc4c751802147f1ff21bf52a57a2976754949453;hpb=92f4313665bc726baf055f81e2daae48c77123fc diff --git a/extras/volume_id/vol_id.c b/extras/volume_id/vol_id.c index df47501a6..889bd3483 100644 --- a/extras/volume_id/vol_id.c +++ b/extras/volume_id/vol_id.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -214,9 +215,17 @@ int main(int argc, char *argv[]) } if (size == 0) { - if (ioctl(fd, BLKGETSIZE64, &size) != 0) - size = 0; - info(udev_ctx, "BLKGETSIZE64=%" PRIu64 " (%" PRIu64 "GB)\n", size, size >> 30); + if (ioctl(fd, BLKGETSIZE64, &size) == 0) { + info(udev_ctx, "BLKGETSIZE64=%" PRIu64 " (%" PRIu64 "GB)\n", size, size >> 30); + } else { + struct stat statbuf; + + if (fstat(fd, &statbuf) == 0 && S_ISREG(statbuf.st_mode)) + size = statbuf.st_size; + else + size = 0; + info(udev_ctx, "stat=%" PRIu64 " (%" PRIu64 "GB)\n", size, size >> 30); + } } /* try to drop all privileges before reading disk content */ @@ -242,7 +251,8 @@ int main(int argc, char *argv[]) else retval = volume_id_probe_all(vid, offset, size); if (retval != 0) { - fprintf(stderr, "%s: unknown volume type\n", node); + fprintf(stderr, "unknown or non-unique volume type " + "(--probe-all lists possibly conflicting types)\n"); rc = 4; goto exit; }