]> git.ipfire.org Git - thirdparty/util-linux.git/blobdiff - misc-utils/blkid.c
libblkid: check status for the current CDROM slot
[thirdparty/util-linux.git] / misc-utils / blkid.c
index c03e1bb8d3aa037cf5064aefe899331d71aa60fb..88a90578b030b1658860ed5fedadeefd3a3c11da 100644 (file)
@@ -225,13 +225,18 @@ static void pretty_print_dev(blkid_dev dev)
        mtpt[0] = 0;
        retval = check_mount_point(devname, &mount_flags, mtpt, sizeof(mtpt));
        if (retval == 0) {
+               const char *msg = NULL;
+
                if (mount_flags & MF_MOUNTED) {
                        if (!mtpt[0])
-                               strcpy(mtpt, _("(mounted, mtpt unknown)"));
+                               msg = _("(mounted, mtpt unknown)");
                } else if (mount_flags & MF_BUSY)
-                       strcpy(mtpt, _("(in use)"));
+                       msg = _("(in use)");
                else
-                       strcpy(mtpt, _("(not mounted)"));
+                       msg = _("(not mounted)");
+
+               if (msg)
+                       xstrncpy(mtpt, msg, sizeof(mtpt));
        }
 
        pretty_print_line(devname, fs_type, label, mtpt, uuid);
@@ -494,13 +499,17 @@ static int lowprobe_device(blkid_probe pr, const char *devname,
        int rc = 0;
        static int first = 1;
 
-       fd = open(devname, O_RDONLY|O_CLOEXEC);
+       fd = open(devname, O_RDONLY|O_CLOEXEC|O_NONBLOCK);
        if (fd < 0) {
                warn(_("error: %s"), devname);
                return BLKID_EXIT_NOTFOUND;
        }
-       if (blkid_probe_set_device(pr, fd, ctl->offset, ctl->size))
+       errno = 0;
+       if (blkid_probe_set_device(pr, fd, ctl->offset, ctl->size)) {
+               if (errno)
+                       warn(_("error: %s"), devname);
                goto done;
+       }
 
        if (ctl->lowprobe_topology)
                rc = lowprobe_topology(pr);
@@ -686,7 +695,7 @@ int main(int argc, char **argv)
        setlocale(LC_ALL, "");
        bindtextdomain(PACKAGE, LOCALEDIR);
        textdomain(PACKAGE);
-       atexit(close_stdout);
+       close_stdout_atexit();
 
        strutils_set_exitcode(BLKID_EXIT_OTHER);