Date: Mon, 2 Oct 2017 22:39:12 +0000 (UTC) From: Alan Somers <asomers@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r324223 - head/cddl/contrib/opensolaris/cmd/zdb Message-ID: <201710022239.v92MdCCN079340@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: asomers Date: Mon Oct 2 22:39:12 2017 New Revision: 324223 URL: https://svnweb.freebsd.org/changeset/base/324223 Log: MFV r319743: 8108 zdb -l fails to read labels 2 and 3 illumos/illumos-gate@22c8b9583d07895c16549075a53668d7bc988cf3 https://github.com/illumos/illumos-gate/commit/22c8b9583d07895c16549075a53668d7bc988cf3 https://www.illumos.org/issues/8108 Reviewed by: Matthew Ahrens <mahrens@delphix.com> Reviewed by: Toomas Soome <tsoome@me.com> Reviewed by: Igor Kozhukhov <igor@dilos.org> Reviewed by: Andrew Stormont <andyjstormont@gmail.com> Approved by: Robert Mustacchi <rm@joyent.com> Author: Yuri Pankov <yuri.pankov@nexenta.com> MFC after: 3 weeks Modified: head/cddl/contrib/opensolaris/cmd/zdb/zdb.c Directory Properties: head/cddl/contrib/opensolaris/ (props changed) head/cddl/contrib/opensolaris/cmd/zdb/ (props changed) Modified: head/cddl/contrib/opensolaris/cmd/zdb/zdb.c ============================================================================== --- head/cddl/contrib/opensolaris/cmd/zdb/zdb.c Mon Oct 2 22:35:35 2017 (r324222) +++ head/cddl/contrib/opensolaris/cmd/zdb/zdb.c Mon Oct 2 22:39:12 2017 (r324223) @@ -2186,24 +2186,29 @@ dump_label(const char *dev) (void) snprintf(path, sizeof (path), "%s%s", ZFS_RDISK_ROOTD, dev); - if ((s = strrchr(dev, 's')) == NULL || !isdigit(*(s + 1))) + if (((s = strrchr(dev, 's')) == NULL && + (s = strchr(dev, 'p')) == NULL) || + !isdigit(*(s + 1))) (void) strlcat(path, "s0", sizeof (path)); } - if (stat64(path, &statbuf) != 0) { - (void) printf("failed to stat '%s': %s\n", path, + if ((fd = open64(path, O_RDONLY)) < 0) { + (void) fprintf(stderr, "cannot open '%s': %s\n", path, strerror(errno)); exit(1); } - if (S_ISBLK(statbuf.st_mode)) { - (void) printf("cannot use '%s': character device required\n", - path); + if (fstat64(fd, &statbuf) != 0) { + (void) fprintf(stderr, "failed to stat '%s': %s\n", path, + strerror(errno)); + (void) close(fd); exit(1); } - if ((fd = open64(path, O_RDONLY)) < 0) { - (void) printf("cannot open '%s': %s\n", path, strerror(errno)); + if (S_ISBLK(statbuf.st_mode)) { + (void) fprintf(stderr, + "cannot use '%s': character device required\n", path); + (void) close(fd); exit(1); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201710022239.v92MdCCN079340>