Lines Matching refs:mdio

57 static struct md_ioctl mdio;
103 bzero(&mdio, sizeof(mdio));
104 mdio.md_file = malloc(PATH_MAX);
105 if (mdio.md_file == NULL)
108 bzero(mdio.md_file, PATH_MAX);
126 mdio.md_options |= MD_AUTOUNIT;
133 mdio.md_options |= MD_AUTOUNIT;
140 mdio.md_options |= MD_AUTOUNIT;
150 mdio.md_type = MD_MALLOC;
151 mdio.md_options |= MD_AUTOUNIT | MD_COMPRESS;
153 mdio.md_type = MD_VNODE;
154 mdio.md_options |= MD_CLUSTER | MD_AUTOUNIT | MD_COMPRESS;
156 mdio.md_type = MD_SWAP;
157 mdio.md_options |= MD_CLUSTER | MD_AUTOUNIT | MD_COMPRESS;
159 mdio.md_type = MD_NULL;
160 mdio.md_options |= MD_CLUSTER | MD_AUTOUNIT | MD_COMPRESS;
173 mdio.md_options |= MD_ASYNC;
175 mdio.md_options &= ~MD_ASYNC;
177 mdio.md_options |= MD_CLUSTER;
179 mdio.md_options &= ~MD_CLUSTER;
181 mdio.md_options |= MD_COMPRESS;
183 mdio.md_options &= ~MD_COMPRESS;
185 mdio.md_options |= MD_FORCE;
187 mdio.md_options &= ~MD_FORCE;
189 mdio.md_options |= MD_READONLY;
191 mdio.md_options &= ~MD_READONLY;
193 mdio.md_options |= MD_RESERVE;
195 mdio.md_options &= ~MD_RESERVE;
200 mdio.md_sectorsize = strtoul(optarg, &p, 0);
206 mdio.md_mediasize = (off_t)strtoumax(optarg, &p, 0);
208 mdio.md_mediasize *= DEV_BSIZE;
212 mdio.md_mediasize <<= 10;
214 mdio.md_mediasize <<= 20;
216 mdio.md_mediasize <<= 30;
218 mdio.md_mediasize <<= 30;
219 mdio.md_mediasize <<= 10;
221 mdio.md_mediasize <<= 30;
222 mdio.md_mediasize <<= 20;
237 mdio.md_fwsectors = strtoul(optarg, &p, 0);
240 mdio.md_fwheads = strtoul(optarg, &p, 0);
260 mdio.md_type = MD_VNODE;
261 mdio.md_options |= MD_CLUSTER | MD_AUTOUNIT |
265 mdio.md_type = MD_SWAP;
266 mdio.md_options |= MD_CLUSTER | MD_AUTOUNIT |
272 if ((fflag != NULL || argc > 0) && mdio.md_type != MD_VNODE)
275 if (mdio.md_type == MD_VNODE) {
286 if ((mdio.md_options & MD_READONLY) == 0 &&
287 access(mdio.md_file, W_OK) < 0 &&
291 "readonly", mdio.md_file);
292 mdio.md_options |= MD_READONLY;
296 if ((mdio.md_type == MD_MALLOC || mdio.md_type == MD_SWAP ||
297 mdio.md_type == MD_NULL) && sflag == NULL)
300 if (mdio.md_type == MD_VNODE && mdio.md_file[0] == '\0')
303 if (mdio.md_sectorsize != 0)
307 if (mdio.md_fwsectors != 0)
309 if (mdio.md_fwheads != 0)
318 (mdio.md_options & ~MD_AUTOUNIT) != 0)
321 (mdio.md_options & ~(MD_FORCE | MD_AUTOUNIT)) != 0)
324 (mdio.md_options & ~(MD_FORCE | MD_RESERVE | MD_AUTOUNIT)) != 0)
335 mdio.md_unit = strtoul(uflag, &p, 0);
336 if (mdio.md_unit == (unsigned)ULONG_MAX || *p != '\0')
338 mdio.md_options &= ~MD_AUTOUNIT;
341 mdio.md_version = MDIOVERSION;
351 i = ioctl(fd, MDIOCATTACH, &mdio);
354 if (mdio.md_options & MD_AUTOUNIT)
355 printf("%s%d\n", nflag ? "" : MD_NAME, mdio.md_unit);
357 if (mdio.md_options & MD_AUTOUNIT)
359 i = ioctl(fd, MDIOCDETACH, &mdio);
363 if (mdio.md_options & MD_AUTOUNIT)
365 i = ioctl(fd, MDIOCRESIZE, &mdio);
369 if (mdio.md_options & MD_AUTOUNIT) {
389 if (realpath(fn, mdio.md_file) == NULL)
391 fd = open(mdio.md_file, O_RDONLY);
398 if (mdio.md_mediasize == 0)
399 mdio.md_mediasize = sb.st_size;