create_floppy_devices.c revision ad29a9f14fa8b1932c0e418bfcf1c10ce6a35a33
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering * Create all possible floppy device based on the CMOS type.
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering * Based upon code from drivers/block/floppy.c
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering * Copyright(C) 2005, SUSE Linux Products GmbH
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering * Author: Hannes Reinecke <hare@suse.de>
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering * This program is free software: you can redistribute it and/or modify
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering * it under the terms of the GNU General Public License as published by
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering * the Free Software Foundation, either version 2 of the License, or
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering * (at your option) any later version.
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering * This program is distributed in the hope that it will be useful,
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering * but WITHOUT ANY WARRANTY; without even the implied warranty of
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering * GNU General Public License for more details.
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering * You should have received a copy of the GNU General Public License
1b00a255225bd65bcc3f6257bd4b1e2089f231b4Tollef Fog Heen * along with this program. If not, see <http://www.gnu.org/licenses/>.
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poetteringstatic char *table[] = {
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering "", "d360", "h1200", "u360", "u720", "h360", "h720",
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering "u1440", "u2880", "CompaQ", "h1440", "u1680", "h410",
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering "u820", "h1476", "u1722", "h420", "u830", "h1494", "u1743",
e9da3678fcfc774b325dc1eaa054d0e00028a1fcLennart Poettering "h880", "u1040", "u1120", "h1600", "u1760", "u1920",
e9da3678fcfc774b325dc1eaa054d0e00028a1fcLennart Poettering "u3200", "u3520", "u3840", "u1840", "u800", "u1600",
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poetteringstatic int t1200[] = { 2, 5, 6, 10, 12, 14, 16, 18, 20, 23, 0 };
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poetteringstatic int t3in[] = { 8, 9, 26, 27, 28, 7, 11, 15, 19, 24, 25, 29, 31, 3, 4, 13, 17, 21, 22, 30, 0 };
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poetteringstatic int *table_sup[] = { NULL, t360, t1200, t3in+5+8, t3in+5, t3in, t3in };
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poetteringstatic void log_fn(struct udev *udev, int priority,
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poettering const char *file, int line, const char *fn,
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poettering while ((c = getopt(argc, argv, "cudm:U:G:M:t:")) != -1) {
a9b5b03212f9c854938483b8901e433c2ba6619bMichael Tremer " -c create\n"
a9b5b03212f9c854938483b8901e433c2ba6619bMichael Tremer " -d debug\n"
a9b5b03212f9c854938483b8901e433c2ba6619bMichael Tremer " -m Major number\n"
a9b5b03212f9c854938483b8901e433c2ba6619bMichael Tremer " -t floppy type number\n"
a9b5b03212f9c854938483b8901e433c2ba6619bMichael Tremer " -U device node user ownership\n"
a9b5b03212f9c854938483b8901e433c2ba6619bMichael Tremer " -G device node group owner\n"
a9b5b03212f9c854938483b8901e433c2ba6619bMichael Tremer " -M device node mode\n"
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poettering fprintf(stderr,"Device '%s' is not a floppy device\n", dev);
0571e0111d76cf96aa4069d9c7a6e24d97aa7e48Lennart Poettering fprintf(stderr,"Floppy device number %d out of range (0-7)\n", fdnum);
65c8976ab12f13fc339a16d108e620bf2fd703f4Malcolm Studd fprintf(stderr,"Invalid major number %d\n", major);
0571e0111d76cf96aa4069d9c7a6e24d97aa7e48Lennart Poettering if (type < 0 || type >= (int) ARRAY_SIZE(table_sup)) {
0571e0111d76cf96aa4069d9c7a6e24d97aa7e48Lennart Poettering fprintf(stderr,"Invalid CMOS type %d\n", type);
34eff652cedec3cac34b92629ead5f140334b689Lennart Poettering sprintf(node, "%s%s", dev, table[table_sup[type][i]]);
12e84679cc81cdf5f042540e54131a0ce37147adLennart Poettering minor = (table_sup[type][i] << 2) + fdnum;
0571e0111d76cf96aa4069d9c7a6e24d97aa7e48Lennart Poettering printf("%s b %.4o %d %d\n", node, mode, major, minor);
0571e0111d76cf96aa4069d9c7a6e24d97aa7e48Lennart Poettering udev_selinux_setfscreatecon(udev, node, S_IFBLK | mode);