FreeBSD Bugzilla – Attachment 38477 Details for
Bug 60892
[patch] added -p option to kldxref(8) to allow creation of hints file in alternate path
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 4.52 KB, created by
Stacy Olivas
on 2004-01-04 13:20:11 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
Stacy Olivas
Created:
2004-01-04 13:20:11 UTC
Size:
4.52 KB
patch
obsolete
>--- /usr/src/usr.sbin/kldxref/kldxref.c Mon Apr 22 15:44:44 2002 >+++ kldxref.new.c Sun Jan 4 14:00:07 2004 >@@ -2,6 +2,9 @@ > * Copyright (c) 2000, Boris Popov > * All rights reserved. > * >+ * Modified by Stacy Olivas (olivas@digiflux.org) >+ * -Added the option "-p [path]" to allow creation of hints file at an alternate location >+ * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: >@@ -50,9 +53,12 @@ > #include <stdlib.h> > #include <unistd.h> > #include <errno.h> >+#include <stdio.h> > > #include "ef.h" > >+#define DEBUG 1 /* Set to 1 for debugging output */ >+ > #define MAXRECSIZE 1024 > #define check(val) if ((error = (val)) != 0) break > >@@ -81,6 +87,8 @@ > FILE *fxref; > > static const char *xref_file = "linker.hints"; >+static const char *xref_path = ""; /* path for creating hints file */ >+static int xref_flag = 0; /* 1 = filename specified */ > > static char recbuf[MAXRECSIZE]; > static int recpos, reccnt; >@@ -261,6 +269,9 @@ > strcpy(p, "lhint.XXXXXX"); > if (mkstemp(dest) == -1) > err(1, "%s", dest); >+#if DEBUG >+ printf("--> Temp file: %s\n", dest); >+#endif > } > > static char xrefname[MAXPATHLEN], tempname[MAXPATHLEN]; >@@ -275,7 +286,7 @@ > fts_options = FTS_PHYSICAL; > /* SLIST_INIT(&kldlist);*/ > >- while ((opt = getopt(argc, argv, "Rdf:v")) != -1) { >+ while ((opt = getopt(argc, argv, "Rdf:p:v")) != -1) { > switch (opt) { > case 'd': > dflag = 1; >@@ -283,6 +294,10 @@ > case 'f': > xref_file = optarg; > break; >+ case 'p': /* alternate path specified */ >+ xref_path = optarg; >+ xref_flag = 1; >+ break; > case 'v': > verbose++; > break; >@@ -299,13 +314,19 @@ > argc -= optind; > argv += optind; > >+#if DEBUG >+/* print out variable info set from command line args */ >+ printf("--> xref_file: %s\n" >+ "--> xref_path: %s\n" >+ "--> xref_flag: %d\n", xref_file, xref_path, xref_flag); >+#endif > ftsp = fts_open(argv, fts_options, 0); > if (ftsp == NULL) > exit(1); > > for (;;) { > p = fts_read(ftsp); >- if ((p == NULL || p->fts_info == FTS_D) && !dflag && fxref) { >+ if ((p == NULL || p->fts_info == FTS_D) && !dflag && fxref && !xref_flag) { > fclose(fxref); > if (reccnt) { > rename(tempname, xrefname); >@@ -314,19 +335,49 @@ > unlink(xrefname); > } > } >+ >+/* if xref_flag is set, only cleanup after everything is finished. */ >+ if (p == NULL && !dflag && xref_flag) >+ { >+ fclose(fxref); >+ if (reccnt) { >+ rename(tempname, xrefname); >+ } else { >+ unlink(tempname); >+ unlink(xrefname); >+ } >+ } > if (p == NULL) > break; >- if (p && p->fts_info == FTS_D && !dflag) { >+ >+/* if xref_flag is set, create temp file in path specified */ >+ if (p && p->fts_info == FTS_D && !dflag && xref_flag == 1) { >+ snprintf(xrefname, sizeof(xrefname), "%s/%s", xref_path, xref_file); >+#if DEBUG >+ printf("--> xrefname: %s\n", xrefname); >+#endif >+ maketempfile(tempname, xref_path); >+ xref_flag++; >+ fxref = fopen(tempname, "w+t"); >+ if (fxref == NULL) >+ err(1, "can't create %s", tempname); >+ ival = 1; >+ fwrite(&ival, sizeof(ival), 1, fxref); >+ reccnt = 0; >+ } >+ >+ if (p && p->fts_info == FTS_D && !dflag && !xref_flag) { > snprintf(xrefname, sizeof(xrefname), "%s/%s", >- ftsp->fts_path, xref_file); >+ ftsp->fts_path, xref_file); > maketempfile(tempname, ftsp->fts_path); >- fxref = fopen(tempname, "w+t"); >- if (fxref == NULL) >- err(1, "can't create %s", tempname); >- ival = 1; >- fwrite(&ival, sizeof(ival), 1, fxref); >- reccnt = 0; >- } >+ fxref = fopen(tempname, "w+t"); >+ if (fxref == NULL) >+ err(1, "can't create %s", tempname); >+ ival = 1; >+ fwrite(&ival, sizeof(ival), 1, fxref); >+ reccnt = 0; >+ } >+ > if (p->fts_info != FTS_F) > continue; > read_kld(p->fts_path, p->fts_name); >@@ -340,7 +391,7 @@ > { > > fprintf(stderr, "%s\n", >- "usage: kldxref [-Rdv] [-f hintfile] path [path..]" >+ "usage: kldxref [-Rpdv] [[-f hintfile] || [-p hintfile]] path [path..]" > ); > exit(1); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 60892
: 38477