mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-25 11:37:56 +00:00
Replace hardcoded references to _PATH_LOCALBASE with calls to getlocalbase.3
Reviewed by: imp, se
This commit is contained in:
parent
98b76d2227
commit
7ca0d5403e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=367687
@ -287,7 +287,7 @@ arg_parse(int argc, char * const * argv, const struct cmd *f)
|
||||
* Loads all the .so's from the specified directory.
|
||||
*/
|
||||
void
|
||||
cmd_load_dir(const char *dir __unused, cmd_load_cb_t cb __unused, void *argp __unused)
|
||||
cmd_load_dir(char *dir, cmd_load_cb_t cb, void *argp)
|
||||
{
|
||||
DIR *d;
|
||||
struct dirent *dent;
|
||||
|
@ -96,7 +96,7 @@ void cmd_register(struct cmd *, struct cmd *);
|
||||
int arg_parse(int argc, char * const *argv, const struct cmd *f);
|
||||
void arg_help(int argc, char * const *argv, const struct cmd *f);
|
||||
void cmd_init(void);
|
||||
void cmd_load_dir(const char *dir, cmd_load_cb_t *cb, void *argp);
|
||||
void cmd_load_dir(char *dir, cmd_load_cb_t *cb, void *argp);
|
||||
int cmd_dispatch(int argc, char *argv[], const struct cmd *);
|
||||
|
||||
#endif /* COMND_H */
|
||||
|
@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <libutil.h>
|
||||
#include <paths.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
@ -178,11 +179,17 @@ get_nsid(int fd, char **ctrlr_str, uint32_t *nsid)
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char locallib[MAXPATHLEN];
|
||||
size_t len;
|
||||
|
||||
cmd_init();
|
||||
|
||||
cmd_load_dir("/lib/nvmecontrol", NULL, NULL);
|
||||
cmd_load_dir(_PATH_LOCALBASE "/lib/nvmecontrol", NULL, NULL);
|
||||
snprintf(locallib, MAXPATHLEN, "/lib/nvmecontrol");
|
||||
cmd_load_dir(locallib, NULL, NULL);
|
||||
if ((len = getlocalbase(locallib, MAXPATHLEN)) > 0) {
|
||||
strlcat(locallib, "/lib/nvmecontrol", MAXPATHLEN - len);
|
||||
cmd_load_dir(locallib, NULL, NULL);
|
||||
}
|
||||
|
||||
cmd_dispatch(argc, argv, NULL);
|
||||
|
||||
|
@ -105,8 +105,10 @@ main(int argc, char *argv[], char *envp[])
|
||||
initarg(&al);
|
||||
addarg(&al, argv[0]);
|
||||
|
||||
snprintf(localmailerconf, MAXPATHLEN, "%s/etc/mail/mailer.conf",
|
||||
getenv("LOCALBASE") ? getenv("LOCALBASE") : _PATH_LOCALBASE);
|
||||
if ((len = getlocalbase(localmailerconf, MAXPATHLEN)) != 0)
|
||||
err(EX_OSERR, "cannot determine local path");
|
||||
|
||||
strlcat(localmailerconf, "/etc/mail/mailer.conf", MAXPATHLEN - len);
|
||||
|
||||
mailerconf = localmailerconf;
|
||||
if ((config = fopen(localmailerconf, "r")) == NULL)
|
||||
|
@ -25,6 +25,6 @@ MAN= pkg.7
|
||||
|
||||
CFLAGS+=-I${SRCTOP}/contrib/libucl/include
|
||||
.PATH: ${SRCTOP}/contrib/libucl/include
|
||||
LIBADD= archive fetch ucl sbuf crypto ssl
|
||||
LIBADD= archive fetch ucl sbuf crypto ssl util
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <fetch.h>
|
||||
#include <libutil.h>
|
||||
#include <paths.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
@ -1037,6 +1038,7 @@ main(int argc, char *argv[])
|
||||
{
|
||||
char pkgpath[MAXPATHLEN];
|
||||
const char *pkgarg;
|
||||
size_t len;
|
||||
int i;
|
||||
bool bootstrap_only, force, yes;
|
||||
|
||||
@ -1045,8 +1047,11 @@ main(int argc, char *argv[])
|
||||
pkgarg = NULL;
|
||||
yes = false;
|
||||
|
||||
snprintf(pkgpath, MAXPATHLEN, "%s/sbin/pkg",
|
||||
getenv("LOCALBASE") ? getenv("LOCALBASE") : _PATH_LOCALBASE);
|
||||
if ((len = getlocalbase(pkgpath, MAXPATHLEN)) != 0) {
|
||||
fprintf(stderr, "Cannot determine local path\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
strlcat(pkgpath, "/sbin/pkg", MAXPATHLEN - len);
|
||||
|
||||
if (argc > 1 && strcmp(argv[1], "bootstrap") == 0) {
|
||||
bootstrap_only = true;
|
||||
|
Loading…
Reference in New Issue
Block a user