mirror of
https://github.com/sheumann/hush.git
synced 2024-12-27 01:32:08 +00:00
Hurd compat fixes. Mostly dealing with absent PATH_MAX
Signed-off-by: Jérémie Koenig <jk@jk.fr.eu.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
35fdb1bc9c
commit
fbedacfc8c
@ -17,30 +17,20 @@ int realpath_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
{
|
{
|
||||||
int retval = EXIT_SUCCESS;
|
int retval = EXIT_SUCCESS;
|
||||||
|
|
||||||
#if PATH_MAX > (BUFSIZ+1)
|
|
||||||
RESERVE_CONFIG_BUFFER(resolved_path, PATH_MAX);
|
|
||||||
# define resolved_path_MUST_FREE 1
|
|
||||||
#else
|
|
||||||
#define resolved_path bb_common_bufsiz1
|
|
||||||
# define resolved_path_MUST_FREE 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!*++argv) {
|
if (!*++argv) {
|
||||||
bb_show_usage();
|
bb_show_usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (realpath(*argv, resolved_path) != NULL) {
|
char *resolved_path = xmalloc_realpath(*argv);
|
||||||
|
if (resolved_path != NULL) {
|
||||||
puts(resolved_path);
|
puts(resolved_path);
|
||||||
|
free(resolved_path);
|
||||||
} else {
|
} else {
|
||||||
retval = EXIT_FAILURE;
|
retval = EXIT_FAILURE;
|
||||||
bb_simple_perror_msg(*argv);
|
bb_simple_perror_msg(*argv);
|
||||||
}
|
}
|
||||||
} while (*++argv);
|
} while (*++argv);
|
||||||
|
|
||||||
#if ENABLE_FEATURE_CLEAN_UP && resolved_path_MUST_FREE
|
|
||||||
RELEASE_CONFIG_BUFFER(resolved_path);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fflush_stdout_and_exit(retval);
|
fflush_stdout_and_exit(retval);
|
||||||
}
|
}
|
||||||
|
@ -89,16 +89,17 @@ enum {
|
|||||||
#define TEST (option_mask32 & OPT_TEST)
|
#define TEST (option_mask32 & OPT_TEST)
|
||||||
|
|
||||||
struct globals {
|
struct globals {
|
||||||
struct pid_list *found;
|
struct pid_list *found_procs;
|
||||||
char *userspec;
|
char *userspec;
|
||||||
char *cmdname;
|
char *cmdname;
|
||||||
char *execname;
|
char *execname;
|
||||||
char *pidfile;
|
char *pidfile;
|
||||||
|
char *execname_cmpbuf;
|
||||||
|
unsigned execname_sizeof;
|
||||||
int user_id;
|
int user_id;
|
||||||
smallint signal_nr;
|
smallint signal_nr;
|
||||||
} FIX_ALIASING;
|
} FIX_ALIASING;
|
||||||
#define G (*(struct globals*)&bb_common_bufsiz1)
|
#define G (*(struct globals*)&bb_common_bufsiz1)
|
||||||
#define found (G.found )
|
|
||||||
#define userspec (G.userspec )
|
#define userspec (G.userspec )
|
||||||
#define cmdname (G.cmdname )
|
#define cmdname (G.cmdname )
|
||||||
#define execname (G.execname )
|
#define execname (G.execname )
|
||||||
@ -118,7 +119,7 @@ struct globals {
|
|||||||
static int pid_is_exec(pid_t pid)
|
static int pid_is_exec(pid_t pid)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
char buf[sizeof("/proc//exe") + sizeof(int)*3];
|
char buf[sizeof("/proc/%u/exe") + sizeof(int)*3];
|
||||||
|
|
||||||
sprintf(buf, "/proc/%u/exe", (unsigned)pid);
|
sprintf(buf, "/proc/%u/exe", (unsigned)pid);
|
||||||
if (stat(buf, &st) < 0)
|
if (stat(buf, &st) < 0)
|
||||||
@ -133,13 +134,13 @@ static int pid_is_exec(pid_t pid)
|
|||||||
static int pid_is_exec(pid_t pid)
|
static int pid_is_exec(pid_t pid)
|
||||||
{
|
{
|
||||||
ssize_t bytes;
|
ssize_t bytes;
|
||||||
char buf[PATH_MAX];
|
char buf[sizeof("/proc/%u/cmdline") + sizeof(int)*3];
|
||||||
|
|
||||||
sprintf(buf, "/proc/%u/cmdline", (unsigned)pid);
|
sprintf(buf, "/proc/%u/cmdline", (unsigned)pid);
|
||||||
bytes = open_read_close(buf, buf, sizeof(buf) - 1);
|
bytes = open_read_close(buf, G.execname_cmpbuf, G.execname_sizeof);
|
||||||
if (bytes > 0) {
|
if (bytes > 0) {
|
||||||
buf[bytes] = '\0';
|
G.execname_cmpbuf[bytes] = '\0';
|
||||||
return strcmp(buf, execname) == 0;
|
return strcmp(execname, G.execname_cmpbuf) == 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -194,9 +195,9 @@ static void check(int pid)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
p = xmalloc(sizeof(*p));
|
p = xmalloc(sizeof(*p));
|
||||||
p->next = found;
|
p->next = G.found_procs;
|
||||||
p->pid = pid;
|
p->pid = pid;
|
||||||
found = p;
|
G.found_procs = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_pidfile(void)
|
static void do_pidfile(void)
|
||||||
@ -266,13 +267,13 @@ static int do_stop(void)
|
|||||||
bb_error_msg_and_die("internal error, please report");
|
bb_error_msg_and_die("internal error, please report");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found) {
|
if (!G.found_procs) {
|
||||||
if (!QUIET)
|
if (!QUIET)
|
||||||
printf("no %s found; none killed\n", what);
|
printf("no %s found; none killed\n", what);
|
||||||
killed = -1;
|
killed = -1;
|
||||||
goto ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
for (p = found; p; p = p->next) {
|
for (p = G.found_procs; p; p = p->next) {
|
||||||
if (TEST || kill(p->pid, signal_nr) == 0) {
|
if (TEST || kill(p->pid, signal_nr) == 0) {
|
||||||
killed++;
|
killed++;
|
||||||
} else {
|
} else {
|
||||||
@ -282,7 +283,7 @@ static int do_stop(void)
|
|||||||
}
|
}
|
||||||
if (!QUIET && killed) {
|
if (!QUIET && killed) {
|
||||||
printf("stopped %s (pid", what);
|
printf("stopped %s (pid", what);
|
||||||
for (p = found; p; p = p->next)
|
for (p = G.found_procs; p; p = p->next)
|
||||||
if (p->pid)
|
if (p->pid)
|
||||||
printf(" %u", (unsigned)p->pid);
|
printf(" %u", (unsigned)p->pid);
|
||||||
puts(")");
|
puts(")");
|
||||||
@ -365,6 +366,10 @@ int start_stop_daemon_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
startas = execname;
|
startas = execname;
|
||||||
if (!execname) /* in case -a is given and -x is not */
|
if (!execname) /* in case -a is given and -x is not */
|
||||||
execname = startas;
|
execname = startas;
|
||||||
|
if (execname) {
|
||||||
|
G.execname_sizeof = strlen(execname) + 1;
|
||||||
|
G.execname_cmpbuf = xmalloc(G.execname_sizeof + 1);
|
||||||
|
}
|
||||||
|
|
||||||
// IF_FEATURE_START_STOP_DAEMON_FANCY(
|
// IF_FEATURE_START_STOP_DAEMON_FANCY(
|
||||||
// if (retry_arg)
|
// if (retry_arg)
|
||||||
@ -386,9 +391,9 @@ int start_stop_daemon_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
return (opt & OPT_OKNODO) ? 0 : (i <= 0);
|
return (opt & OPT_OKNODO) ? 0 : (i <= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found) {
|
if (G.found_procs) {
|
||||||
if (!QUIET)
|
if (!QUIET)
|
||||||
printf("%s is already running\n%u\n", execname, (unsigned)found->pid);
|
printf("%s is already running\n%u\n", execname, (unsigned)G.found_procs->pid);
|
||||||
return !(opt & OPT_OKNODO);
|
return !(opt & OPT_OKNODO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,7 +339,7 @@ void xmove_fd(int, int) FAST_FUNC;
|
|||||||
DIR *xopendir(const char *path) FAST_FUNC;
|
DIR *xopendir(const char *path) FAST_FUNC;
|
||||||
DIR *warn_opendir(const char *path) FAST_FUNC;
|
DIR *warn_opendir(const char *path) FAST_FUNC;
|
||||||
|
|
||||||
/* UNUSED: char *xmalloc_realpath(const char *path) FAST_FUNC RETURNS_MALLOC; */
|
char *xmalloc_realpath(const char *path) FAST_FUNC RETURNS_MALLOC;
|
||||||
char *xmalloc_readlink(const char *path) FAST_FUNC RETURNS_MALLOC;
|
char *xmalloc_readlink(const char *path) FAST_FUNC RETURNS_MALLOC;
|
||||||
char *xmalloc_readlink_or_warn(const char *path) FAST_FUNC RETURNS_MALLOC;
|
char *xmalloc_readlink_or_warn(const char *path) FAST_FUNC RETURNS_MALLOC;
|
||||||
/* !RETURNS_MALLOC: it's a realloc-like function */
|
/* !RETURNS_MALLOC: it's a realloc-like function */
|
||||||
|
@ -59,8 +59,12 @@ char* FAST_FUNC safe_gethostname(void)
|
|||||||
*/
|
*/
|
||||||
char* FAST_FUNC safe_getdomainname(void)
|
char* FAST_FUNC safe_getdomainname(void)
|
||||||
{
|
{
|
||||||
|
/* The field domainname of struct utsname is Linux specific. */
|
||||||
|
#if defined(__linux__)
|
||||||
struct utsname uts;
|
struct utsname uts;
|
||||||
|
|
||||||
uname(&uts);
|
uname(&uts);
|
||||||
return xstrndup(!uts.domainname[0] ? "?" : uts.domainname, sizeof(uts.domainname));
|
return xstrndup(!uts.domainname[0] ? "?" : uts.domainname, sizeof(uts.domainname));
|
||||||
|
#else
|
||||||
|
return xstrdup("?");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,8 @@ int FAST_FUNC setsockopt_broadcast(int fd)
|
|||||||
{
|
{
|
||||||
return setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &const_int_1, sizeof(const_int_1));
|
return setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &const_int_1, sizeof(const_int_1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SO_BINDTODEVICE
|
||||||
int FAST_FUNC setsockopt_bindtodevice(int fd, const char *iface)
|
int FAST_FUNC setsockopt_bindtodevice(int fd, const char *iface)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
@ -36,6 +38,14 @@ int FAST_FUNC setsockopt_bindtodevice(int fd, const char *iface)
|
|||||||
bb_perror_msg("can't bind to interface %s", iface);
|
bb_perror_msg("can't bind to interface %s", iface);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
int FAST_FUNC setsockopt_bindtodevice(int fd UNUSED_PARAM,
|
||||||
|
const char *iface UNUSED_PARAM)
|
||||||
|
{
|
||||||
|
bb_error_msg("SO_BINDTODEVICE is not supported on this system");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
len_and_sockaddr* FAST_FUNC get_sock_lsa(int fd)
|
len_and_sockaddr* FAST_FUNC get_sock_lsa(int fd)
|
||||||
{
|
{
|
||||||
|
@ -100,18 +100,16 @@ char* FAST_FUNC xmalloc_readlink_or_warn(const char *path)
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* UNUSED */
|
|
||||||
#if 0
|
|
||||||
char* FAST_FUNC xmalloc_realpath(const char *path)
|
char* FAST_FUNC xmalloc_realpath(const char *path)
|
||||||
{
|
{
|
||||||
#if defined(__GLIBC__) && !defined(__UCLIBC__)
|
#if defined(__GLIBC__) && !defined(__UCLIBC__)
|
||||||
/* glibc provides a non-standard extension */
|
/* glibc provides a non-standard extension */
|
||||||
|
/* new: POSIX.1-2008 specifies this behavior as well */
|
||||||
return realpath(path, NULL);
|
return realpath(path, NULL);
|
||||||
#else
|
#else
|
||||||
char buf[PATH_MAX+1];
|
char buf[PATH_MAX+1];
|
||||||
|
|
||||||
/* on error returns NULL (xstrdup(NULL) ==NULL) */
|
/* on error returns NULL (xstrdup(NULL) == NULL) */
|
||||||
return xstrdup(realpath(path, buf));
|
return xstrdup(realpath(path, buf));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
@ -79,7 +79,9 @@ void exec_kernel_doc(char **svec)
|
|||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int ret;
|
int ret;
|
||||||
char real_filename[PATH_MAX + 1];
|
char *real_filename;
|
||||||
|
int rflen;
|
||||||
|
|
||||||
/* Make sure output generated so far are flushed */
|
/* Make sure output generated so far are flushed */
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
switch(pid=fork()) {
|
switch(pid=fork()) {
|
||||||
@ -87,10 +89,11 @@ void exec_kernel_doc(char **svec)
|
|||||||
perror("fork");
|
perror("fork");
|
||||||
exit(1);
|
exit(1);
|
||||||
case 0:
|
case 0:
|
||||||
memset(real_filename, 0, sizeof(real_filename));
|
rflen = strlen(getenv("SRCTREE"));
|
||||||
strncat(real_filename, getenv("SRCTREE"), PATH_MAX);
|
rflen += strlen(KERNELDOCPATH KERNELDOC);
|
||||||
strncat(real_filename, KERNELDOCPATH KERNELDOC,
|
real_filename = alloca(rflen + 1);
|
||||||
PATH_MAX - strlen(real_filename));
|
strcpy(real_filename, getenv("SRCTREE"));
|
||||||
|
strcat(real_filename, KERNELDOCPATH KERNELDOC);
|
||||||
execvp(real_filename, svec);
|
execvp(real_filename, svec);
|
||||||
fprintf(stderr, "exec ");
|
fprintf(stderr, "exec ");
|
||||||
perror(real_filename);
|
perror(real_filename);
|
||||||
@ -166,11 +169,10 @@ void find_export_symbols(char * filename)
|
|||||||
struct symfile *sym;
|
struct symfile *sym;
|
||||||
char line[MAXLINESZ];
|
char line[MAXLINESZ];
|
||||||
if (filename_exist(filename) == NULL) {
|
if (filename_exist(filename) == NULL) {
|
||||||
char real_filename[PATH_MAX + 1];
|
int rflen = strlen(getenv("SRCTREE")) + strlen(filename);
|
||||||
memset(real_filename, 0, sizeof(real_filename));
|
char *real_filename = alloca(rflen + 1);
|
||||||
strncat(real_filename, getenv("SRCTREE"), PATH_MAX);
|
strcpy(real_filename, getenv("SRCTREE"));
|
||||||
strncat(real_filename, filename,
|
strcat(real_filename, filename);
|
||||||
PATH_MAX - strlen(real_filename));
|
|
||||||
sym = add_new_file(filename);
|
sym = add_new_file(filename);
|
||||||
fp = fopen(real_filename, "r");
|
fp = fopen(real_filename, "r");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
|
@ -203,7 +203,7 @@ void clear_config(void)
|
|||||||
*/
|
*/
|
||||||
void use_config(char *m, int slen)
|
void use_config(char *m, int slen)
|
||||||
{
|
{
|
||||||
char s[PATH_MAX];
|
char *s = alloca(slen+1);
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
if (is_defined_config(m, slen))
|
if (is_defined_config(m, slen))
|
||||||
@ -310,7 +310,7 @@ void parse_dep_file(void *map, size_t len)
|
|||||||
char *m = map;
|
char *m = map;
|
||||||
char *end = m + len;
|
char *end = m + len;
|
||||||
char *p;
|
char *p;
|
||||||
char s[PATH_MAX];
|
char *s = alloca(len);
|
||||||
|
|
||||||
p = memchr(m, ':', len);
|
p = memchr(m, ':', len);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
|
@ -70,12 +70,13 @@ static char *conf_expand_value(const char *in)
|
|||||||
char *conf_get_default_confname(void)
|
char *conf_get_default_confname(void)
|
||||||
{
|
{
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
static char fullname[PATH_MAX+1];
|
static char *fullname = NULL;
|
||||||
char *env, *name;
|
char *env, *name;
|
||||||
|
|
||||||
name = conf_expand_value(conf_defname);
|
name = conf_expand_value(conf_defname);
|
||||||
env = getenv(SRCTREE);
|
env = getenv(SRCTREE);
|
||||||
if (env) {
|
if (env) {
|
||||||
|
fullname = realloc(fullname, strlen(env) + strlen(name) + 2);
|
||||||
sprintf(fullname, "%s/%s", env, name);
|
sprintf(fullname, "%s/%s", env, name);
|
||||||
if (!stat(fullname, &buf))
|
if (!stat(fullname, &buf))
|
||||||
return fullname;
|
return fullname;
|
||||||
|
@ -258,7 +258,7 @@ search_help[] = N_(
|
|||||||
|
|
||||||
static char buf[4096], *bufptr = buf;
|
static char buf[4096], *bufptr = buf;
|
||||||
static char input_buf[4096];
|
static char input_buf[4096];
|
||||||
static char filename[PATH_MAX+1] = ".config";
|
static const char filename[] = ".config";
|
||||||
static char *args[1024], **argptr = args;
|
static char *args[1024], **argptr = args;
|
||||||
static int indent;
|
static int indent;
|
||||||
static struct termios ios_org;
|
static struct termios ios_org;
|
||||||
|
@ -265,13 +265,14 @@ static void zconf_endhelp(void)
|
|||||||
*/
|
*/
|
||||||
FILE *zconf_fopen(const char *name)
|
FILE *zconf_fopen(const char *name)
|
||||||
{
|
{
|
||||||
char *env, fullname[PATH_MAX+1];
|
char *env;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
f = fopen(name, "r");
|
f = fopen(name, "r");
|
||||||
if (!f && name[0] != '/') {
|
if (!f && name[0] != '/') {
|
||||||
env = getenv(SRCTREE);
|
env = getenv(SRCTREE);
|
||||||
if (env) {
|
if (env) {
|
||||||
|
char *fullname = alloca(strlen(env) + strlen(name) + 2);
|
||||||
sprintf(fullname, "%s/%s", env, name);
|
sprintf(fullname, "%s/%s", env, name);
|
||||||
f = fopen(fullname, "r");
|
f = fopen(fullname, "r");
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,6 @@
|
|||||||
#define LKC_DIRECT_LINK
|
#define LKC_DIRECT_LINK
|
||||||
#include "lkc.h"
|
#include "lkc.h"
|
||||||
|
|
||||||
#include "zconf.hash.c"
|
|
||||||
|
|
||||||
#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt)
|
#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt)
|
||||||
|
|
||||||
#define PRINTD 0x0001
|
#define PRINTD 0x0001
|
||||||
@ -99,6 +97,10 @@ static struct menu *current_menu, *current_entry;
|
|||||||
menu_end_menu();
|
menu_end_menu();
|
||||||
} if_entry menu_entry choice_entry
|
} if_entry menu_entry choice_entry
|
||||||
|
|
||||||
|
%{
|
||||||
|
#include "zconf.hash.c"
|
||||||
|
%}
|
||||||
|
|
||||||
%%
|
%%
|
||||||
input: stmt_list;
|
input: stmt_list;
|
||||||
|
|
||||||
|
@ -39,6 +39,10 @@
|
|||||||
# define MS_RELATIME (1 << 21)
|
# define MS_RELATIME (1 << 21)
|
||||||
#endif
|
#endif
|
||||||
#include "libbb.h"
|
#include "libbb.h"
|
||||||
|
#ifndef PATH_MAX
|
||||||
|
# define PATH_MAX (4*1024)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(__dietlibc__)
|
#if defined(__dietlibc__)
|
||||||
/* 16.12.2006, Sampo Kellomaki (sampo@iki.fi)
|
/* 16.12.2006, Sampo Kellomaki (sampo@iki.fi)
|
||||||
@ -69,7 +73,7 @@ int umount_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
|||||||
int umount_main(int argc UNUSED_PARAM, char **argv)
|
int umount_main(int argc UNUSED_PARAM, char **argv)
|
||||||
{
|
{
|
||||||
int doForce;
|
int doForce;
|
||||||
char *const path = xmalloc(PATH_MAX + 2); /* to save stack */
|
char *const buf = xmalloc(PATH_MAX * 2 + 128); /* to save stack */
|
||||||
struct mntent me;
|
struct mntent me;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char *fstype = NULL;
|
char *fstype = NULL;
|
||||||
@ -100,7 +104,7 @@ int umount_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
if (opt & OPT_ALL)
|
if (opt & OPT_ALL)
|
||||||
bb_error_msg_and_die("can't open '%s'", bb_path_mtab_file);
|
bb_error_msg_and_die("can't open '%s'", bb_path_mtab_file);
|
||||||
} else {
|
} else {
|
||||||
while (getmntent_r(fp, &me, path, PATH_MAX)) {
|
while (getmntent_r(fp, &me, buf, PATH_MAX * 2 + 128)) {
|
||||||
/* Match fstype if passed */
|
/* Match fstype if passed */
|
||||||
if (!match_fstype(&me, fstype))
|
if (!match_fstype(&me, fstype))
|
||||||
continue;
|
continue;
|
||||||
@ -124,10 +128,11 @@ int umount_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
int curstat;
|
int curstat;
|
||||||
char *zapit = *argv;
|
char *zapit = *argv;
|
||||||
|
char *path;
|
||||||
|
|
||||||
// Do we already know what to umount this time through the loop?
|
// Do we already know what to umount this time through the loop?
|
||||||
if (m)
|
if (m)
|
||||||
safe_strncpy(path, m->dir, PATH_MAX);
|
path = xstrdup(m->dir);
|
||||||
// For umount -a, end of mtab means time to exit.
|
// For umount -a, end of mtab means time to exit.
|
||||||
else if (opt & OPT_ALL)
|
else if (opt & OPT_ALL)
|
||||||
break;
|
break;
|
||||||
@ -136,10 +141,12 @@ int umount_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
if (!zapit)
|
if (!zapit)
|
||||||
break;
|
break;
|
||||||
argv++;
|
argv++;
|
||||||
realpath(zapit, path);
|
path = xmalloc_realpath(zapit);
|
||||||
for (m = mtl; m; m = m->next)
|
if (path) {
|
||||||
if (!strcmp(path, m->dir) || !strcmp(path, m->device))
|
for (m = mtl; m; m = m->next)
|
||||||
break;
|
if (strcmp(path, m->dir) == 0 || strcmp(path, m->device) == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// If we couldn't find this sucker in /etc/mtab, punt by passing our
|
// If we couldn't find this sucker in /etc/mtab, punt by passing our
|
||||||
// command line argument straight to the umount syscall. Otherwise,
|
// command line argument straight to the umount syscall. Otherwise,
|
||||||
@ -181,9 +188,13 @@ int umount_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
// Find next matching mtab entry for -a or umount /dev
|
// Find next matching mtab entry for -a or umount /dev
|
||||||
// Note this means that "umount /dev/blah" will unmount all instances
|
// Note this means that "umount /dev/blah" will unmount all instances
|
||||||
// of /dev/blah, not just the most recent.
|
// of /dev/blah, not just the most recent.
|
||||||
if (m) while ((m = m->next) != NULL)
|
if (m) {
|
||||||
if ((opt & OPT_ALL) || !strcmp(path, m->device))
|
while ((m = m->next) != NULL)
|
||||||
break;
|
// NB: if m is non-NULL, path is non-NULL as well
|
||||||
|
if ((opt & OPT_ALL) || strcmp(path, m->device) == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
free(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free mtab list if necessary
|
// Free mtab list if necessary
|
||||||
@ -195,7 +206,7 @@ int umount_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
free(mtl);
|
free(mtl);
|
||||||
mtl = m;
|
mtl = m;
|
||||||
}
|
}
|
||||||
free(path);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
|
Loading…
Reference in New Issue
Block a user