diskctl(8): move to proper location
- move from minix/commands to minix/usr.sbin; - install into /usr/sbin instead of /usr/bin; - move manual page into source directory; - resolve compilation warning; - convert to KNF. Change-Id: Iccb4a8b27ae220254bae19e9198478b40706f542
This commit is contained in:
parent
964427e0ea
commit
c175cce5e6
7 changed files with 38 additions and 31 deletions
|
@ -309,7 +309,7 @@
|
||||||
./usr/bin/dhrystone minix-sys
|
./usr/bin/dhrystone minix-sys
|
||||||
./usr/bin/diff minix-sys
|
./usr/bin/diff minix-sys
|
||||||
./usr/bin/dirname 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/dosdir minix-sys
|
||||||
./usr/bin/dosread minix-sys
|
./usr/bin/dosread minix-sys
|
||||||
./usr/bin/doswrite minix-sys
|
./usr/bin/doswrite minix-sys
|
||||||
|
@ -5311,6 +5311,7 @@
|
||||||
./usr/sbin/btrace minix-sys
|
./usr/sbin/btrace minix-sys
|
||||||
./usr/sbin/chown minix-sys
|
./usr/sbin/chown minix-sys
|
||||||
./usr/sbin/chroot minix-sys
|
./usr/sbin/chroot minix-sys
|
||||||
|
./usr/sbin/diskctl minix-sys
|
||||||
./usr/sbin/group minix-sys
|
./usr/sbin/group minix-sys
|
||||||
./usr/sbin/groupadd minix-sys
|
./usr/sbin/groupadd minix-sys
|
||||||
./usr/sbin/groupdel minix-sys
|
./usr/sbin/groupdel minix-sys
|
||||||
|
|
|
@ -7,7 +7,7 @@ SUBDIR= add_route arp at backup \
|
||||||
ci cleantmp co \
|
ci cleantmp co \
|
||||||
compress crc cron crontab \
|
compress crc cron crontab \
|
||||||
decomp16 DESCRIBE devmand devsize dhcpd \
|
decomp16 DESCRIBE devmand devsize dhcpd \
|
||||||
dhrystone diskctl \
|
dhrystone \
|
||||||
eject fbdctl \
|
eject fbdctl \
|
||||||
fix format fsck.mfs \
|
fix format fsck.mfs \
|
||||||
gcov-pull host \
|
gcov-pull host \
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
MAN= add_route.8 backup.8 boot.8 \
|
MAN= add_route.8 backup.8 boot.8 \
|
||||||
cdprobe.8 cleantmp.8 config.8 cron.8 \
|
cdprobe.8 cleantmp.8 config.8 cron.8 \
|
||||||
dhcpd.8 diskctl.8 fbdctl.8 fdisk.8 \
|
dhcpd.8 fbdctl.8 fdisk.8 \
|
||||||
getty.8 halt.8 hgfs.8 httpd.8 ifconfig.8 inet.8 init.8 \
|
getty.8 halt.8 hgfs.8 httpd.8 ifconfig.8 inet.8 init.8 \
|
||||||
intr.8 irdpd.8 loadramdisk.8 \
|
intr.8 irdpd.8 loadramdisk.8 \
|
||||||
netconf.8 newroot.8 nonamed.8 \
|
netconf.8 newroot.8 nonamed.8 \
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
.include <bsd.own.mk>
|
.include <bsd.own.mk>
|
||||||
|
|
||||||
SUBDIR+= btrace
|
SUBDIR+= btrace
|
||||||
|
SUBDIR+= diskctl
|
||||||
SUBDIR+= mkfs.mfs
|
SUBDIR+= mkfs.mfs
|
||||||
SUBDIR+= mkproto
|
SUBDIR+= mkproto
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
PROG= diskctl
|
PROG= diskctl
|
||||||
MAN=
|
MAN= diskctl.8
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
.include <bsd.prog.mk>
|
|
@ -1,26 +1,28 @@
|
||||||
/* diskctl - control disk device driver parameters - by D.C. van Moolenbroek */
|
/* diskctl - control disk device driver parameters - by D.C. van Moolenbroek */
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
static char *name, *dev;
|
static void __dead
|
||||||
|
usage(void)
|
||||||
static void usage(void)
|
|
||||||
{
|
{
|
||||||
fprintf(stderr, "usage: %s <device> <command> [args]\n"
|
fprintf(stderr,
|
||||||
"\n"
|
"usage: %s <device> <command> [args]\n"
|
||||||
"supported commands:\n"
|
"\n"
|
||||||
" getwcache return write cache status\n"
|
"supported commands:\n"
|
||||||
" setwcache [on|off] set write cache status\n"
|
" getwcache return write cache status\n"
|
||||||
" flush flush write cache\n",
|
" setwcache [on|off] set write cache status\n"
|
||||||
name);
|
" flush flush write cache\n",
|
||||||
|
getprogname());
|
||||||
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int open_dev(int flags)
|
static int
|
||||||
|
open_dev(const char * dev, int flags)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
|
@ -35,20 +37,19 @@ static int open_dev(int flags)
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int
|
||||||
|
main(int argc, char ** argv)
|
||||||
{
|
{
|
||||||
int fd, val;
|
int fd, val;
|
||||||
|
|
||||||
name = argv[0];
|
setprogname(argv[0]);
|
||||||
|
|
||||||
if (argc < 3) usage();
|
if (argc < 3) usage();
|
||||||
|
|
||||||
dev = argv[1];
|
|
||||||
|
|
||||||
if (!strcasecmp(argv[2], "getwcache")) {
|
if (!strcasecmp(argv[2], "getwcache")) {
|
||||||
if (argc != 3) usage();
|
if (argc != 3) usage();
|
||||||
|
|
||||||
fd = open_dev(O_RDONLY);
|
fd = open_dev(argv[1], O_RDONLY);
|
||||||
|
|
||||||
if (ioctl(fd, DIOCGETWC, &val) != 0) {
|
if (ioctl(fd, DIOCGETWC, &val) != 0) {
|
||||||
perror("ioctl");
|
perror("ioctl");
|
||||||
|
@ -59,15 +60,18 @@ int main(int argc, char **argv)
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
printf("write cache is %s\n", val ? "on" : "off");
|
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();
|
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;
|
fd = open_dev(argv[1], O_WRONLY);
|
||||||
else if (!strcasecmp(argv[3], "off")) val = 0;
|
|
||||||
else usage();
|
|
||||||
|
|
||||||
if (ioctl(fd, DIOCSETWC, &val) != 0) {
|
if (ioctl(fd, DIOCSETWC, &val) != 0) {
|
||||||
perror("ioctl");
|
perror("ioctl");
|
||||||
|
@ -78,11 +82,11 @@ int main(int argc, char **argv)
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
printf("write cache %sabled\n", val ? "en" : "dis");
|
printf("write cache %sabled\n", val ? "en" : "dis");
|
||||||
}
|
|
||||||
else if (!strcasecmp(argv[2], "flush")) {
|
} else if (!strcasecmp(argv[2], "flush")) {
|
||||||
if (argc != 3) usage();
|
if (argc != 3) usage();
|
||||||
|
|
||||||
fd = open_dev(O_WRONLY);
|
fd = open_dev(argv[1], O_WRONLY);
|
||||||
|
|
||||||
if (ioctl(fd, DIOCFLUSH, NULL) != 0) {
|
if (ioctl(fd, DIOCFLUSH, NULL) != 0) {
|
||||||
perror("ioctl");
|
perror("ioctl");
|
||||||
|
@ -93,8 +97,9 @@ int main(int argc, char **argv)
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
printf("write cache flushed\n");
|
printf("write cache flushed\n");
|
||||||
}
|
|
||||||
else usage();
|
} else
|
||||||
|
usage();
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
Loading…
Reference in a new issue