Deleted Added
full compact
geom_raid3.c (134168) geom_raid3.c (134420)
1/*-
2 * Copyright (c) 2004 Pawel Jakub Dawidek <pjd@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2004 Pawel Jakub Dawidek <pjd@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sbin/geom/class/raid3/geom_raid3.c 134168 2004-08-22 16:21:12Z pjd $");
28__FBSDID("$FreeBSD: head/sbin/geom/class/raid3/geom_raid3.c 134420 2004-08-28 02:34:10Z pjd $");
29
30#include <sys/param.h>
31#include <errno.h>
32#include <paths.h>
33#include <stdio.h>
34#include <stdlib.h>
35#include <stdint.h>
36#include <string.h>

--- 107 unchanged lines hidden (view full) ---

144raid3_label(struct gctl_req *req)
145{
146 struct g_raid3_metadata md;
147 u_char sector[512];
148 const char *str;
149 char param[16];
150 int *hardcode, *nargs, *noautosync, *round_robin, *verify;
151 int error, i;
29
30#include <sys/param.h>
31#include <errno.h>
32#include <paths.h>
33#include <stdio.h>
34#include <stdlib.h>
35#include <stdint.h>
36#include <string.h>

--- 107 unchanged lines hidden (view full) ---

144raid3_label(struct gctl_req *req)
145{
146 struct g_raid3_metadata md;
147 u_char sector[512];
148 const char *str;
149 char param[16];
150 int *hardcode, *nargs, *noautosync, *round_robin, *verify;
151 int error, i;
152 unsigned sectorsize;
153 off_t mediasize;
152 unsigned sectorsize, ssize;
153 off_t mediasize, msize;
154
155 nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
156 if (nargs == NULL) {
157 gctl_error(req, "No '%s' argument.", "nargs");
158 return;
159 }
160 if (*nargs < 4) {
161 gctl_error(req, "Too few arguments.");

--- 55 unchanged lines hidden (view full) ---

217
218 /*
219 * Calculate sectorsize by finding least common multiple from
220 * sectorsizes of every disk and find the smallest mediasize.
221 */
222 mediasize = 0;
223 sectorsize = 0;
224 for (i = 1; i < *nargs; i++) {
154
155 nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
156 if (nargs == NULL) {
157 gctl_error(req, "No '%s' argument.", "nargs");
158 return;
159 }
160 if (*nargs < 4) {
161 gctl_error(req, "Too few arguments.");

--- 55 unchanged lines hidden (view full) ---

217
218 /*
219 * Calculate sectorsize by finding least common multiple from
220 * sectorsizes of every disk and find the smallest mediasize.
221 */
222 mediasize = 0;
223 sectorsize = 0;
224 for (i = 1; i < *nargs; i++) {
225 unsigned ssize;
226 off_t msize;
227
228 snprintf(param, sizeof(param), "arg%u", i);
229 str = gctl_get_asciiparam(req, param);
230
231 msize = g_get_mediasize(str);
232 ssize = g_get_sectorsize(str);
233 if (msize == 0 || ssize == 0) {
234 gctl_error(req, "Can't get informations about %s: %s.",
235 str, strerror(errno));

--- 27 unchanged lines hidden (view full) ---

263
264 /*
265 * Ok, store metadata (use disk number as priority).
266 */
267 for (i = 1; i < *nargs; i++) {
268 snprintf(param, sizeof(param), "arg%u", i);
269 str = gctl_get_asciiparam(req, param);
270
225 snprintf(param, sizeof(param), "arg%u", i);
226 str = gctl_get_asciiparam(req, param);
227
228 msize = g_get_mediasize(str);
229 ssize = g_get_sectorsize(str);
230 if (msize == 0 || ssize == 0) {
231 gctl_error(req, "Can't get informations about %s: %s.",
232 str, strerror(errno));

--- 27 unchanged lines hidden (view full) ---

260
261 /*
262 * Ok, store metadata (use disk number as priority).
263 */
264 for (i = 1; i < *nargs; i++) {
265 snprintf(param, sizeof(param), "arg%u", i);
266 str = gctl_get_asciiparam(req, param);
267
268 msize = g_get_mediasize(str) - g_get_sectorsize(str);
269 if (mediasize < msize) {
270 fprintf(stderr,
271 "warning: %s: only %jd bytes from %jd bytes used.\n",
272 str, (intmax_t)mediasize, (intmax_t)msize);
273 }
274
271 md.md_no = i - 1;
272 if (!*hardcode)
273 bzero(md.md_provider, sizeof(md.md_provider));
274 else {
275 if (strncmp(str, _PATH_DEV, strlen(_PATH_DEV)) == 0)
276 str += strlen(_PATH_DEV);
277 strlcpy(md.md_provider, str, sizeof(md.md_provider));
278 }

--- 87 unchanged lines hidden ---
275 md.md_no = i - 1;
276 if (!*hardcode)
277 bzero(md.md_provider, sizeof(md.md_provider));
278 else {
279 if (strncmp(str, _PATH_DEV, strlen(_PATH_DEV)) == 0)
280 str += strlen(_PATH_DEV);
281 strlcpy(md.md_provider, str, sizeof(md.md_provider));
282 }

--- 87 unchanged lines hidden ---