diff options
Diffstat (limited to 'sbin/modload')
-rw-r--r-- | sbin/modload/modload.8 | 8 | ||||
-rw-r--r-- | sbin/modload/modload.c | 43 |
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); |