Module Name: src Committed By: mlelstv Date: Sun Oct 7 11:54:14 UTC 2018
Modified Files: src/sys/dev: vnd.c Log Message: Calculate a missing cylinder count in the geometry spec from image size. To generate a diff of this commit: cvs rdiff -u -r1.267 -r1.268 src/sys/dev/vnd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/vnd.c diff -u src/sys/dev/vnd.c:1.267 src/sys/dev/vnd.c:1.268 --- src/sys/dev/vnd.c:1.267 Sun Oct 7 11:51:26 2018 +++ src/sys/dev/vnd.c Sun Oct 7 11:54:14 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: vnd.c,v 1.267 2018/10/07 11:51:26 mlelstv Exp $ */ +/* $NetBSD: vnd.c,v 1.268 2018/10/07 11:54:14 mlelstv Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. @@ -91,7 +91,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.267 2018/10/07 11:51:26 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.268 2018/10/07 11:54:14 mlelstv Exp $"); #if defined(_KERNEL_OPT) #include "opt_vnd.h" @@ -1427,7 +1427,6 @@ vndioctl(dev_t dev, u_long cmd, void *da * Sanity-check the sector size. */ if (!DK_DEV_BSIZE_OK(vnd->sc_geom.vng_secsize) || - vnd->sc_geom.vng_ncylinders == 0 || vnd->sc_geom.vng_ntracks == 0 || vnd->sc_geom.vng_nsectors == 0) { error = EINVAL; @@ -1435,6 +1434,14 @@ vndioctl(dev_t dev, u_long cmd, void *da } /* + * Compute missing cylinder count from size + */ + if (vnd->sc_geom.vng_ncylinders == 0) + vnd->sc_geom.vng_ncylinders = vnd->sc_size / + (vnd->sc_geom.vng_ntracks * + vnd->sc_geom.vng_nsectors); + + /* * Compute the size (in DEV_BSIZE blocks) specified * by the geometry. */