Date: Fri, 8 Sep 2017 15:38:03 +0000 (UTC) From: Conrad Meyer <cem@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r323315 - head/sbin/geom/class/virstor Message-ID: <201709081538.v88Fc3re097490@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: cem Date: Fri Sep 8 15:38:02 2017 New Revision: 323315 URL: https://svnweb.freebsd.org/changeset/base/323315 Log: geom_virstor: Remove wholly unnecessary g_metadata_store copy Just code cleanup. No functional change. Sponsored by: Dell EMC Isilon Modified: head/sbin/geom/class/virstor/geom_virstor.c Modified: head/sbin/geom/class/virstor/geom_virstor.c ============================================================================== --- head/sbin/geom/class/virstor/geom_virstor.c Fri Sep 8 15:08:17 2017 (r323314) +++ head/sbin/geom/class/virstor/geom_virstor.c Fri Sep 8 15:38:02 2017 (r323315) @@ -140,62 +140,6 @@ virstor_main(struct gctl_req *req, unsigned flags) */ } -static void -pathgen(const char *name, char *path, size_t size) -{ - - if (strncmp(name, _PATH_DEV, sizeof(_PATH_DEV) - 1) != 0) - snprintf(path, size, "%s%s", _PATH_DEV, name); - else - strlcpy(path, name, size); -} - -static int -my_g_metadata_store(const char *name, u_char *md, size_t size) -{ - char path[MAXPATHLEN]; - unsigned sectorsize; - off_t mediasize; - u_char *sector; - int error, fd; - - pathgen(name, path, sizeof(path)); - sector = NULL; - error = 0; - - fd = open(path, O_RDWR); - if (fd == -1) - return (errno); - mediasize = g_get_mediasize(name); - if (mediasize == 0) { - error = errno; - goto out; - } - sectorsize = g_get_sectorsize(name); - if (sectorsize == 0) { - error = errno; - goto out; - } - assert(sectorsize >= size); - sector = malloc(sectorsize); - if (sector == NULL) { - error = ENOMEM; - goto out; - } - bcopy(md, sector, size); - bzero(sector + size, sectorsize - size); - if (pwrite(fd, sector, sectorsize, mediasize - sectorsize) != - (ssize_t)sectorsize) { - error = errno; - goto out; - } -out: - if (sector != NULL) - free(sector); - close(fd); - return (error); -} - /* * Labels a new geom Meaning: parses and checks the parameters, calculates & * writes metadata to the relevant providers so when the next round of @@ -465,7 +409,7 @@ virstor_label(struct gctl_req *req) err(1, "Cannot allocate sector of %zu bytes", ssize); bzero(sect, ssize); virstor_metadata_encode(&md, sect); - error = my_g_metadata_store(name, sect, ssize); + error = g_metadata_store(name, sect, ssize); free(sect); if (error != 0) { if (verbose)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201709081538.v88Fc3re097490>