3 // Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; version 2 of the License.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 int wrapper_exit_code = 1;
32 #define VROOT_SET_DEV 0x5600
33 #define VROOT_CLR_DEV 0x5601
34 #define VROOT_INC_USE 0x56FE
35 #define VROOT_DEC_USE 0x56FF
39 { "help", no_argument, 0, 'h' },
40 { "version", no_argument, 0, 'v' },
45 showHelp(int fd, char const *cmd, int res)
47 WRITE_MSG(fd, "Usage: ");
54 " <rootdev> <real-rootdev>\n\n"
55 "Please report bugs to " PACKAGE_BUGREPORT "\n");
63 "vrsetup " VERSION " -- set up and control vroot devices\n"
64 "This program is part of " PACKAGE_STRING "\n\n"
65 "Copyright (C) 2003 Enrico Scholz\n"
66 VERSION_COPYRIGHT_DISCLAIMER);
71 int main(int argc, char *argv[])
73 bool do_delete = false;
74 bool do_decrement = false;
75 bool do_increment = false;
76 bool do_setup = false;
77 char const * root_device = 0;
78 char const * real_root_device = 0;
82 int c = getopt_long(argc, argv, "dID", CMDLINE_OPTIONS, 0);
86 case 'h' : showHelp(1, argv[0], 0);
87 case 'v' : showVersion();
88 case 'd' : do_delete = true; break;
89 case 'D' : do_decrement = true; break;
90 case 'I' : do_increment = true; break;
92 WRITE_MSG(2, "Try '");
93 WRITE_STR(2, argv[0]);
94 WRITE_MSG(2, " --help\" for more information.\n");
100 do_setup = !(do_delete || do_decrement || do_increment);
103 WRITE_MSG(2, "No vroot-device given\n");
107 if (do_setup && optind+2>argc) {
108 WRITE_MSG(2, "No real root-device given\n");
112 root_device = argv[optind];
113 if (do_setup) real_root_device = argv[optind+1];
115 fd = Eopen(root_device, O_RDONLY, 0);
116 if (do_increment) Eioctl(fd, VROOT_INC_USE, 0);
117 else if (do_decrement) Eioctl(fd, VROOT_DEC_USE, 0);
118 else if (do_delete) Eioctl(fd, VROOT_CLR_DEV, 0);
120 int dfd = Eopen(real_root_device, O_RDONLY, 0);
121 Eioctl(fd, VROOT_SET_DEV, (void*)dfd);