summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1995-10-28 17:06:05 +0000
committerpeter <peter@FreeBSD.org>1995-10-28 17:06:05 +0000
commit5ec08ccc15209ff8fcd054ebb8fde7bb3b50e232 (patch)
tree2d3fce06c2d3a3faed385d288d82ca16f9e528c7 /sbin
parent85ca1766d44601de1681f6233412bfc6e251d9dd (diff)
downloadFreeBSD-src-5ec08ccc15209ff8fcd054ebb8fde7bb3b50e232.zip
FreeBSD-src-5ec08ccc15209ff8fcd054ebb8fde7bb3b50e232.tar.gz
Add a few more heuristics to modload:
1: generate the outfile in /tmp if it's not specified explicitly. 2: if the outfile was implicitly placed in /tmp, automatically remove it. This means that you can type: modload /lkm/ipfw_mod.o and it'll work, it wont try and write to /lkm, and it wont leave the (normally) useless symbol file. This should not interfere with things like ibcs2 and atapi, which export some symbols from one LKM to the other by leaving the symbol file.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/modload/modload.88
-rw-r--r--sbin/modload/modload.c43
2 files changed, 32 insertions, 19 deletions
diff --git a/sbin/modload/modload.8 b/sbin/modload/modload.8
index b6fcc67..1043e92 100644
--- a/sbin/modload/modload.8
+++ b/sbin/modload/modload.8
@@ -23,7 +23,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $Id: modload.8,v 1.5 1994/09/22 22:35:50 wollman Exp $
+.\" $Id: modload.8,v 1.6 1995/10/28 13:06:09 peter Exp $
.\"
.Dd September 22, 1994
.Dt MODLOAD 8
@@ -58,7 +58,8 @@ Be very quiet.
.It Fl u
Delete the loaded module
.Pq Ar output_file
-after loading.
+after loading. If the output file was not specified, this option causes the
+temporary file to be kept rather than deleted.
.It Fl v
Print comments about the loading process.
.It Fl A Ar kernel
@@ -85,7 +86,8 @@ For a loadable system call, the third argument is the system
call number.
.It Fl o Ar output_file
Specify the name of the output file that is produced by
-the linker.
+the linker. If this option is not specified, a file in the /tmp directory
+is used with the name generated from the module name with a `.out' extension.
.El
.Sh FILES
.Bl -tag -width /usr/include/sys/lkm.h -compact
diff --git a/sbin/modload/modload.c b/sbin/modload/modload.c
index 96cb837..c8f737f 100644
--- a/sbin/modload/modload.c
+++ b/sbin/modload/modload.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: modload.c,v 1.8 1995/05/30 06:09:20 rgrimes Exp $
+ * $Id: modload.c,v 1.9 1995/10/28 13:06:11 peter Exp $
*/
#include <stdio.h>
@@ -214,16 +214,6 @@ main(argc, argv)
modobj = argv[0];
- if (!entry) { /* calculate default entry point */
- entry = strrchr(modobj, '/');
- if (entry)
- entry++; /* skip over '/' */
- else
- entry = modobj;
- entry = strdup(entry); /* so we can modify it */
- entry[strlen(entry) - 2] = '\0'; /* chop off .o */
- }
-
atexit(cleanup);
/*
@@ -235,14 +225,35 @@ main(argc, argv)
err(3, _PATH_LKM);
fileopen |= DEV_OPEN;
- strcpy(modout, modobj);
-
- p = strchr(modout, '.');
+ p = strchr(modobj, '.');
if (!p || strcmp(p, ".o"))
errx(2, "module object must end in .o");
- if (out == NULL) {
+
+ if (!out) {
+ p = strrchr(modobj, '/');
+ if (p)
+ p++; /* skip over '/' */
+ else
+ p = modobj;
+ sprintf(modout, "%s%sut", _PATH_TMP, p);
out = modout;
- *p = 0;
+ /*
+ * reverse meaning of -u - if we've generated a /tmp
+ * file, remove it automatically...
+ */
+ dounlink = !dounlink;
+ }
+
+ if (!entry) { /* calculate default entry point */
+ entry = strrchr(modobj, '/');
+ if (entry)
+ entry++; /* skip over '/' */
+ else
+ entry = modobj;
+ entry = strdup(entry); /* so we can modify it */
+ if (!entry)
+ errx(1, "Could not allocate memory");
+ entry[strlen(entry) - 2] = '\0'; /* chop off .o */
}
modfd = open(out, O_RDWR | O_CREAT, 0666);
OpenPOWER on IntegriCloud