mirror of
https://github.com/freebsd/freebsd-src
synced 2024-11-05 18:22:52 +00:00
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.
This commit is contained in:
parent
54b50b1dc8
commit
185156015b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=11879
2 changed files with 32 additions and 19 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue