From e27a08abb743d32c8834d79fc7741c32e618e476 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 26 Nov 2007 14:58:29 +0100 Subject: [PATCH] namei: non-linux support (get_current_dir_name() and PATH_MAX) Co-Author: Samuel Thibault Signed-off-by: Karel Zak --- configure.ac | 1 + misc-utils/namei.c | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index dacc7962..ed12e60b 100644 --- a/configure.ac +++ b/configure.ac @@ -56,6 +56,7 @@ AC_CHECK_FUNCS( [inet_aton \ fsync \ getdomainname \ + get_current_dir_name \ nanosleep \ personality \ updwtmp \ diff --git a/misc-utils/namei.c b/misc-utils/namei.c index 0db176a6..e8f7a8bd 100644 --- a/misc-utils/namei.c +++ b/misc-utils/namei.c @@ -73,6 +73,10 @@ int xflag = 0; #define MAXSYMLINKS 256 #endif +#ifndef PATH_MAX +#define PATH_MAX 4096 +#endif + static char *pperm(unsigned short); static void namei(char *, int, mode_t *); static void usage(void); @@ -81,7 +85,11 @@ int main(int argc, char **argv) { extern int optind; int c; - char curdir[MAXPATHLEN]; +#ifdef HAVE_GET_CURRENT_DIR_NAME + char *curdir; +#else + char curdir[PATH_MAX]; +#endif setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); @@ -106,7 +114,12 @@ main(int argc, char **argv) { } } - if(getcwd(curdir, sizeof(curdir)) == NULL){ +#ifdef HAVE_GET_CURRENT_DIR_NAME + if (!(curdir = get_current_dir_name())) +#else + if(getcwd(curdir, sizeof(curdir)) == NULL) +#endif + { (void)fprintf(stderr, _("namei: unable to get current directory - %s\n"), curdir); @@ -140,8 +153,6 @@ usage(void) { #define NODEV (dev_t)(-1) #endif -int kzak; - static void namei(char *file, int lev, mode_t *lastmode) { char *cp; -- 2.39.5