./usr/bin/dhrystone minix-sys
./usr/bin/diff minix-sys
./usr/bin/dirname minix-sys
-./usr/bin/diskctl minix-sys
+./usr/bin/diskctl minix-sys obsolete
./usr/bin/dosdir minix-sys
./usr/bin/dosread minix-sys
./usr/bin/doswrite minix-sys
./usr/sbin/btrace minix-sys
./usr/sbin/chown minix-sys
./usr/sbin/chroot minix-sys
+./usr/sbin/diskctl minix-sys
./usr/sbin/group minix-sys
./usr/sbin/groupadd minix-sys
./usr/sbin/groupdel minix-sys
/* diskctl - control disk device driver parameters - by D.C. van Moolenbroek */
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <fcntl.h>
-static char *name, *dev;
-
-static void usage(void)
+static void __dead
+usage(void)
{
- fprintf(stderr, "usage: %s <device> <command> [args]\n"
- "\n"
- "supported commands:\n"
- " getwcache return write cache status\n"
- " setwcache [on|off] set write cache status\n"
- " flush flush write cache\n",
- name);
+ fprintf(stderr,
+ "usage: %s <device> <command> [args]\n"
+ "\n"
+ "supported commands:\n"
+ " getwcache return write cache status\n"
+ " setwcache [on|off] set write cache status\n"
+ " flush flush write cache\n",
+ getprogname());
exit(EXIT_FAILURE);
}
-static int open_dev(int flags)
+static int
+open_dev(const char * dev, int flags)
{
int fd;
return fd;
}
-int main(int argc, char **argv)
+int
+main(int argc, char ** argv)
{
int fd, val;
- name = argv[0];
+ setprogname(argv[0]);
if (argc < 3) usage();
- dev = argv[1];
-
if (!strcasecmp(argv[2], "getwcache")) {
if (argc != 3) usage();
- fd = open_dev(O_RDONLY);
+ fd = open_dev(argv[1], O_RDONLY);
if (ioctl(fd, DIOCGETWC, &val) != 0) {
perror("ioctl");
close(fd);
printf("write cache is %s\n", val ? "on" : "off");
- }
- else if (!strcasecmp(argv[2], "setwcache")) {
+
+ } else if (!strcasecmp(argv[2], "setwcache")) {
if (argc != 4) usage();
- fd = open_dev(O_WRONLY);
+ if (!strcasecmp(argv[3], "on"))
+ val = 1;
+ else if (!strcasecmp(argv[3], "off"))
+ val = 0;
+ else
+ usage();
- if (!strcasecmp(argv[3], "on")) val = 1;
- else if (!strcasecmp(argv[3], "off")) val = 0;
- else usage();
+ fd = open_dev(argv[1], O_WRONLY);
if (ioctl(fd, DIOCSETWC, &val) != 0) {
perror("ioctl");
close(fd);
printf("write cache %sabled\n", val ? "en" : "dis");
- }
- else if (!strcasecmp(argv[2], "flush")) {
+
+ } else if (!strcasecmp(argv[2], "flush")) {
if (argc != 3) usage();
- fd = open_dev(O_WRONLY);
+ fd = open_dev(argv[1], O_WRONLY);
if (ioctl(fd, DIOCFLUSH, NULL) != 0) {
perror("ioctl");
close(fd);
printf("write cache flushed\n");
- }
- else usage();
+
+ } else
+ usage();
return EXIT_SUCCESS;
}