Deleted Added
full compact
g_part_bsd.c (265912) g_part_bsd.c (268091)
1/*-
2 * Copyright (c) 2007 Marcel Moolenaar
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 *

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

20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2007 Marcel Moolenaar
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 *

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

20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: stable/10/sys/geom/part/g_part_bsd.c 265912 2014-05-12 12:04:44Z ae $");
28__FBSDID("$FreeBSD: stable/10/sys/geom/part/g_part_bsd.c 268091 2014-07-01 13:29:17Z ae $");
29
30#include <sys/param.h>
31#include <sys/bio.h>
32#include <sys/disklabel.h>
33#include <sys/endian.h>
34#include <sys/kernel.h>
35#include <sys/kobj.h>
36#include <sys/limits.h>

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

107 sizeof(struct g_part_bsd_table),
108 .gps_entrysz = sizeof(struct g_part_bsd_entry),
109 .gps_minent = 8,
110 .gps_maxent = 20, /* Only 22 entries fit in 512 byte sectors */
111 .gps_bootcodesz = BBSIZE,
112};
113G_PART_SCHEME_DECLARE(g_part_bsd);
114
29
30#include <sys/param.h>
31#include <sys/bio.h>
32#include <sys/disklabel.h>
33#include <sys/endian.h>
34#include <sys/kernel.h>
35#include <sys/kobj.h>
36#include <sys/limits.h>

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

107 sizeof(struct g_part_bsd_table),
108 .gps_entrysz = sizeof(struct g_part_bsd_entry),
109 .gps_minent = 8,
110 .gps_maxent = 20, /* Only 22 entries fit in 512 byte sectors */
111 .gps_bootcodesz = BBSIZE,
112};
113G_PART_SCHEME_DECLARE(g_part_bsd);
114
115static struct g_part_bsd_alias {
116 uint8_t type;
117 int alias;
118} bsd_alias_match[] = {
119 { FS_BSDFFS, G_PART_ALIAS_FREEBSD_UFS },
120 { FS_SWAP, G_PART_ALIAS_FREEBSD_SWAP },
121 { FS_ZFS, G_PART_ALIAS_FREEBSD_ZFS },
122 { FS_VINUM, G_PART_ALIAS_FREEBSD_VINUM },
123 { FS_NANDFS, G_PART_ALIAS_FREEBSD_NANDFS },
124 { FS_HAMMER, G_PART_ALIAS_DFBSD_HAMMER },
125 { FS_HAMMER2, G_PART_ALIAS_DFBSD_HAMMER2 },
126};
127
115static int
116bsd_parse_type(const char *type, uint8_t *fstype)
117{
118 const char *alias;
119 char *endp;
120 long lt;
128static int
129bsd_parse_type(const char *type, uint8_t *fstype)
130{
131 const char *alias;
132 char *endp;
133 long lt;
134 int i;
121
122 if (type[0] == '!') {
123 lt = strtol(type + 1, &endp, 0);
124 if (type[1] == '\0' || *endp != '\0' || lt <= 0 || lt >= 256)
125 return (EINVAL);
126 *fstype = (u_int)lt;
127 return (0);
128 }
135
136 if (type[0] == '!') {
137 lt = strtol(type + 1, &endp, 0);
138 if (type[1] == '\0' || *endp != '\0' || lt <= 0 || lt >= 256)
139 return (EINVAL);
140 *fstype = (u_int)lt;
141 return (0);
142 }
129 alias = g_part_alias_name(G_PART_ALIAS_FREEBSD_NANDFS);
130 if (!strcasecmp(type, alias)) {
131 *fstype = FS_NANDFS;
132 return (0);
143 for (i = 0;
144 i < sizeof(bsd_alias_match) / sizeof(bsd_alias_match[0]); i++) {
145 alias = g_part_alias_name(bsd_alias_match[i].alias);
146 if (strcasecmp(type, alias) == 0) {
147 *fstype = bsd_alias_match[i].type;
148 return (0);
149 }
133 }
150 }
134 alias = g_part_alias_name(G_PART_ALIAS_FREEBSD_SWAP);
135 if (!strcasecmp(type, alias)) {
136 *fstype = FS_SWAP;
137 return (0);
138 }
139 alias = g_part_alias_name(G_PART_ALIAS_FREEBSD_UFS);
140 if (!strcasecmp(type, alias)) {
141 *fstype = FS_BSDFFS;
142 return (0);
143 }
144 alias = g_part_alias_name(G_PART_ALIAS_FREEBSD_VINUM);
145 if (!strcasecmp(type, alias)) {
146 *fstype = FS_VINUM;
147 return (0);
148 }
149 alias = g_part_alias_name(G_PART_ALIAS_FREEBSD_ZFS);
150 if (!strcasecmp(type, alias)) {
151 *fstype = FS_ZFS;
152 return (0);
153 }
154 return (EINVAL);
155}
156
157static int
158g_part_bsd_add(struct g_part_table *basetable, struct g_part_entry *baseentry,
159 struct g_part_parms *gpp)
160{
161 struct g_part_bsd_entry *entry;

--- 382 unchanged lines hidden ---
151 return (EINVAL);
152}
153
154static int
155g_part_bsd_add(struct g_part_table *basetable, struct g_part_entry *baseentry,
156 struct g_part_parms *gpp)
157{
158 struct g_part_bsd_entry *entry;

--- 382 unchanged lines hidden ---