openbsd-ports/shells/sash/patches/patch-cmds_c
lebel ff5323bd8f initial import of sash-3.4:
--
SASH - Stand-alone shell with built-in commands.

The sash program is a stand-alone shell which is useful for recovering
from certain types of system failures. In particular, it was created
in order to cope with the problem of missing shared libraries or
important executable.

WWW: http://www.canb.auug.org.au/~dbell/

Submitted by Albert Chang <vedge@vedge.com.ar>
2001-07-06 13:33:47 +00:00

158 lines
2.9 KiB
Plaintext

$OpenBSD: patch-cmds_c,v 1.1.1.1 2001/07/06 13:33:48 lebel Exp $
--- cmds.c.orig Thu Jun 3 17:42:17 1999
+++ cmds.c Fri Jul 6 09:21:42 2001
@@ -10,14 +10,20 @@
#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/mount.h>
#include <signal.h>
#include <pwd.h>
#include <grp.h>
#include <utime.h>
#include <errno.h>
+
+#ifdef __Linux__
#include <linux/fs.h>
+#endif
+#ifdef __OpenBSD__
+#include <sys/param.h>
+#endif
+#include <sys/mount.h>
void
do_echo(int argc, const char ** argv)
@@ -511,8 +517,15 @@ do_mount(int argc, const char ** argv)
argc--;
argv++;
+
+#ifdef __OpenBSD__
+ type = "ffs";
+#endif
+
+#ifdef __Linux__
type = "ext2";
flags = MS_MGC_VAL;
+#endif
while ((argc > 0) && (**argv == '-'))
{
@@ -533,6 +546,21 @@ do_mount(int argc, const char ** argv)
argc--;
break;
+#ifdef __OpenBSD__
+ case 'r':
+ flags |= MNT_RDONLY;
+ break;
+
+ case 's':
+ flags |= MNT_NOSUID;
+ break;
+
+ case 'e':
+ flags |= MNT_NOEXEC;
+ break;
+#endif
+
+#ifdef __Linux__
case 'r':
flags |= MS_RDONLY;
break;
@@ -540,6 +568,7 @@ do_mount(int argc, const char ** argv)
case 'm':
flags |= MS_REMOUNT;
break;
+#endif
default:
fprintf(stderr, "Unknown option\n");
@@ -555,16 +584,85 @@ do_mount(int argc, const char ** argv)
return;
}
+#ifdef __OpenBSD__
+
+ {
+ struct ufs_args ufs;
+ struct adosfs_args adosfs;
+ struct iso_args iso;
+ struct mfs_args mfs;
+ struct msdosfs_args msdosfs;
+ void * args;
+
+ if(!strcmp(type, "ffs") || !strcmp(type, "ufs")) {
+ ufs.fspec = (char*) argv[0];
+ args = &ufs;
+ } else if(!strcmp(type, "adosfs")) {
+ adosfs.fspec = (char*) argv[0];
+ adosfs.uid = 0;
+ adosfs.gid = 0;
+ args = &adosfs;
+ } else if(!strcmp(type, "cd9660")) {
+ iso.fspec = (char*) argv[0];
+ args = &iso;
+ } else if(!strcmp(type, "mfs")) {
+ mfs.fspec = (char*) argv[0];
+ args = &mfs;
+ } else if(!strcmp(type, "msdos")) {
+ msdosfs.fspec = (char*) argv[0];
+ msdosfs.uid = 0;
+ msdosfs.gid = 0;
+ args = &msdosfs;
+ } else {
+ fprintf(stderr, "Unknown filesystem type: %s", type);
+ }
+
+ fprintf(stderr, "type=%s, dev=%s, point=%s\n", type,
+ argv[0], argv[1]);
+ if (mount(type, argv[1], flags, args) < 0)
+ perror(argv[0]);
+ }
+#endif
+
+#ifdef __Linux__
if (mount(argv[0], argv[1], type, flags, 0) < 0)
perror("mount failed");
+#endif
+
}
void
do_umount(int argc, const char ** argv)
{
+ const char * str;
+ int flags = 0;
+
+#ifdef __OpenBSD__
+ argc--;
+ argv++;
+
+ while ((argc > 0) && (**argv == '-'))
+ {
+ argc--;
+ str = *argv++;
+
+ while (*++str) switch (*str)
+ {
+ case 'r':
+ flags = MNT_FORCE;
+ break;
+ }
+ }
+
+ if (unmount(argv[0], flags) < 0)
+ perror(argv[0]);
+#endif
+
+#ifdef __Linux__
if (umount(argv[1]) < 0)
perror(argv[1]);
+#endif
}