1*2a5a03e6Swiz /* $NetBSD: mkfs_msdos.h,v 1.6 2017/02/17 09:29:35 wiz Exp $ */ 2aed35c48Schristos 3aed35c48Schristos /*- 4aed35c48Schristos * Copyright (c) 2013 The NetBSD Foundation, Inc. 5aed35c48Schristos * All rights reserved. 6aed35c48Schristos * 7aed35c48Schristos * This code is derived from software contributed to The NetBSD Foundation 8aed35c48Schristos * by Christos Zoulas. 9aed35c48Schristos * 10aed35c48Schristos * Redistribution and use in source and binary forms, with or without 11aed35c48Schristos * modification, are permitted provided that the following conditions 12aed35c48Schristos * are met: 13aed35c48Schristos * 1. Redistributions of source code must retain the above copyright 14aed35c48Schristos * notice, this list of conditions and the following disclaimer. 15aed35c48Schristos * 2. Redistributions in binary form must reproduce the above copyright 16aed35c48Schristos * notice, this list of conditions and the following disclaimer in the 17aed35c48Schristos * documentation and/or other materials provided with the distribution. 18aed35c48Schristos * 19aed35c48Schristos * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20aed35c48Schristos * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21aed35c48Schristos * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22aed35c48Schristos * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23aed35c48Schristos * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24aed35c48Schristos * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25aed35c48Schristos * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26aed35c48Schristos * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27aed35c48Schristos * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28aed35c48Schristos * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29aed35c48Schristos * POSSIBILITY OF SUCH DAMAGE. 30aed35c48Schristos */ 31aed35c48Schristos 32aed35c48Schristos #include <sys/types.h> 33aed35c48Schristos #include <stdbool.h> 34aed35c48Schristos #define ALLOPTS \ 3530441591Schristos AOPT('@', off_t, offset, 0, "Offset in device") \ 3630441591Schristos AOPT('B', char *, bootstrap, -1, "Bootstrap file") \ 3730441591Schristos AOPT('C', off_t, create_size, 0, "Create file") \ 3830441591Schristos AOPT('F', uint8_t, fat_type, 12, "FAT type (12, 16, or 32)") \ 3930441591Schristos AOPT('I', uint32_t, volume_id, 0, "Volume ID") \ 4030441591Schristos AOPT('L', char *, volume_label, -1, "Volume Label") \ 4130441591Schristos AOPT('N', bool, no_create, -2, "Don't create file system, print params only") \ 4230441591Schristos AOPT('O', char *, OEM_string, -1, "OEM string") \ 4330441591Schristos AOPT('S', uint16_t, bytes_per_sector, 1, "Bytes per sector") \ 4430441591Schristos AOPT('a', uint32_t, sectors_per_fat, 1, "Sectors per FAT") \ 4530441591Schristos AOPT('b', uint32_t, block_size, 1, "Block size") \ 4630441591Schristos AOPT('c', uint8_t, sectors_per_cluster, 1, "Sectors per cluster") \ 4730441591Schristos AOPT('e', uint16_t, directory_entries, 1, "Directory entries") \ 4830441591Schristos AOPT('f', char *, floppy, -1, "Standard format floppies (160,180,320,360,640,720,1200,1232,1440,2880)") \ 4930441591Schristos AOPT('h', uint16_t, drive_heads, 1, "Drive heads") \ 5030441591Schristos AOPT('i', uint16_t, info_sector, 1, "Info sector") \ 5130441591Schristos AOPT('k', uint16_t, backup_sector, 1, "Backup sector") \ 5230441591Schristos AOPT('m', uint8_t, media_descriptor, 0, "Media descriptor") \ 5330441591Schristos AOPT('n', uint8_t, num_FAT, 1, "Number of FATs") \ 5430441591Schristos AOPT('o', uint32_t, hidden_sectors, 0, "Hidden sectors") \ 5530441591Schristos AOPT('r', uint16_t, reserved_sectors, 1, "Reserved sectors") \ 5630441591Schristos AOPT('s', uint32_t, size, 1, "File System size") \ 5730441591Schristos AOPT('u', uint16_t, sectors_per_track, 1, "Sectors per track") 58aed35c48Schristos 59aed35c48Schristos struct msdos_options { 6030441591Schristos #define AOPT(_opt, _type, _name, _min, _desc) _type _name; 61aed35c48Schristos ALLOPTS 62aed35c48Schristos #undef AOPT 6329723468Schristos time_t timestamp; 64285cf569Schristos uint32_t timestamp_set:1; 65aed35c48Schristos uint32_t volume_id_set:1; 66aed35c48Schristos uint32_t media_descriptor_set:1; 67aed35c48Schristos uint32_t hidden_sectors_set:1; 68aed35c48Schristos }; 69aed35c48Schristos 70aed35c48Schristos int mkfs_msdos(const char *, const char *, const struct msdos_options *); 71