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;
170 mdio.md_options |= MD_ASYNC;
172 mdio.md_options &= ~MD_ASYNC;
174 mdio.md_options |= MD_CLUSTER;
176 mdio.md_options &= ~MD_CLUSTER;
178 mdio.md_options |= MD_COMPRESS;
180 mdio.md_options &= ~MD_COMPRESS;
182 mdio.md_options |= MD_FORCE;
184 mdio.md_options &= ~MD_FORCE;
186 mdio.md_options |= MD_READONLY;
188 mdio.md_options &= ~MD_READONLY;
190 mdio.md_options |= MD_RESERVE;
192 mdio.md_options &= ~MD_RESERVE;
197 mdio.md_sectorsize = strtoul(optarg, &p, 0);
203 mdio.md_mediasize = (off_t)strtoumax(optarg, &p, 0);
205 mdio.md_mediasize *= DEV_BSIZE;
209 mdio.md_mediasize <<= 10;
211 mdio.md_mediasize <<= 20;
213 mdio.md_mediasize <<= 30;
215 mdio.md_mediasize <<= 30;
216 mdio.md_mediasize <<= 10;
231 mdio.md_fwsectors = strtoul(optarg, &p, 0);
234 mdio.md_fwheads = strtoul(optarg, &p, 0);
254 mdio.md_type = MD_VNODE;
255 mdio.md_options |= MD_CLUSTER | MD_AUTOUNIT |
259 mdio.md_type = MD_SWAP;
260 mdio.md_options |= MD_CLUSTER | MD_AUTOUNIT |
266 if ((fflag != NULL || argc > 0) && mdio.md_type != MD_VNODE)
269 if (mdio.md_type == MD_VNODE) {
280 if ((mdio.md_options & MD_READONLY) == 0 &&
281 access(mdio.md_file, W_OK) < 0 &&
285 "readonly", mdio.md_file);
286 mdio.md_options |= MD_READONLY;
290 if ((mdio.md_type == MD_MALLOC || mdio.md_type == MD_SWAP) &&
293 if (mdio.md_type == MD_VNODE && mdio.md_file[0] == '\0')
296 if (mdio.md_sectorsize != 0)
300 if (mdio.md_fwsectors != 0)
302 if (mdio.md_fwheads != 0)
311 (mdio.md_options & ~MD_AUTOUNIT) != 0)
314 (mdio.md_options & ~(MD_FORCE | MD_AUTOUNIT)) != 0)
317 (mdio.md_options & ~(MD_FORCE | MD_RESERVE | MD_AUTOUNIT)) != 0)
328 mdio.md_unit = strtoul(uflag, &p, 0);
329 if (mdio.md_unit == (unsigned)ULONG_MAX || *p != '\0')
331 mdio.md_options &= ~MD_AUTOUNIT;
334 mdio.md_version = MDIOVERSION;
344 i = ioctl(fd, MDIOCATTACH, &mdio);
347 if (mdio.md_options & MD_AUTOUNIT)
348 printf("%s%d\n", nflag ? "" : MD_NAME, mdio.md_unit);
350 if (mdio.md_options & MD_AUTOUNIT)
352 i = ioctl(fd, MDIOCDETACH, &mdio);
356 if (mdio.md_options & MD_AUTOUNIT)
358 i = ioctl(fd, MDIOCRESIZE, &mdio);
362 if (mdio.md_options & MD_AUTOUNIT) {
382 if (realpath(fn, mdio.md_file) == NULL)
384 fd = open(mdio.md_file, O_RDONLY);
391 if (mdio.md_mediasize == 0)
392 mdio.md_mediasize = sb.st_size;