diff options
Diffstat (limited to 'winsup/cygwin')
41 files changed, 204 insertions, 151 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 71aa9d5..8da7575 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,47 @@ +2003-11-11 Robert Collins <rbtcollins@hotmail.com> + Ron Parker <rdparker@butlermfg.com> + + * bsdlib.cc: Update throughout to use CYG_MAX_PATH rather than MAX_PATH. + * cygheap.h: Ditto. + * dcrt0.cc: Ditto. + * delqueue.cc: Ditto. + * dlfcn.cc: Ditto. + * dll_init.cc: Ditto. + * dll_init.h: Ditto. + * dtable.cc: Ditto. + * environ.cc: Ditto. + * environ.h: Ditto. + * exceptions.cc: Ditto. + * external.cc: Ditto. + * fhandler_disk_file.cc: Ditto. + * fhandler_proc.cc: Ditto. + * fhandler_process.cc: Ditto. + * fhandler_raw.cc: Ditto. + * fhandler_registry.cc: Ditto. + * fhandler_socket.cc: Ditto. + * fhandler_virtual.cc: Ditto. + * miscfuncs.cc: Ditto. + * mmap.cc: Ditto. + * netdb.cc: Ditto. + * path.cc: Ditto. + * path.h: Ditto. + * pinfo.cc: Ditto. + * pinfo.h: Ditto. + * pthread.cc: Ditto. + * registry.cc: Ditto. + * shared.cc: Ditto. + * shared_info.h: Ditto. + * smallprint.c: Ditto. + * spawn.cc: Ditto. + * strace.cc: Ditto. + * syscalls.cc: Ditto. + * thread.h: Ditto. + * uinfo.cc: Ditto. + * winsup.h: Ditto. + * include/limits.h: Ditto. + * include/cygwin/config.h: Ditto. + * include/sys/param.h: Ditto. + 2003-11-12 Brian Ford <ford@vss.fsi.com> * dtable.cc (build_fh_pc): Use DEV_SERIAL_MAJOR to catch all serial diff --git a/winsup/cygwin/cygheap.h b/winsup/cygwin/cygheap.h index fc46118..8b84e64 100644 --- a/winsup/cygwin/cygheap.h +++ b/winsup/cygwin/cygheap.h @@ -42,9 +42,9 @@ struct _cmalloc_entry struct cygheap_root_mount_info { - char posix_path[MAX_PATH]; + char posix_path[CYG_MAX_PATH]; unsigned posix_pathlen; - char native_path[MAX_PATH]; + char native_path[CYG_MAX_PATH]; unsigned native_pathlen; }; @@ -215,7 +215,7 @@ struct cwdstuff char *win32; DWORD hash; muto *cwd_lock; - char *get (char *buf, int need_posix = 1, int with_chroot = 0, unsigned ulen = MAX_PATH); + char *get (char *buf, int need_posix = 1, int with_chroot = 0, unsigned ulen = CYG_MAX_PATH); DWORD get_hash (); void init (); void fixup_after_exec (char *win32, char *posix, DWORD hash); diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index b862ee1..693868c 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -722,7 +722,7 @@ dll_crt0_1 () win32 style. */ if ((strchr (__argv[0], ':')) || (strchr (__argv[0], '\\'))) { - char *new_argv0 = (char *) alloca (MAX_PATH); + char *new_argv0 = (char *) alloca (CYG_MAX_PATH); cygwin_conv_to_posix_path (__argv[0], new_argv0); __argv[0] = new_argv0; } @@ -805,20 +805,20 @@ void initial_env () { DWORD len; - char buf[MAX_PATH + 1]; + char buf[CYG_MAX_PATH + 1]; #ifdef DEBUGGING if (GetEnvironmentVariable ("CYGWIN_SLEEP", buf, sizeof (buf) - 1)) { DWORD ms = atoi (buf); buf[0] = '\0'; - len = GetModuleFileName (NULL, buf, MAX_PATH); + len = GetModuleFileName (NULL, buf, CYG_MAX_PATH); console_printf ("Sleeping %d, pid %u %s\n", ms, GetCurrentProcessId (), buf); Sleep (ms); } if (GetEnvironmentVariable ("CYGWIN_DEBUG", buf, sizeof (buf) - 1)) { - char buf1[MAX_PATH + 1]; - len = GetModuleFileName (NULL, buf1, MAX_PATH); + char buf1[CYG_MAX_PATH + 1]; + len = GetModuleFileName (NULL, buf1, CYG_MAX_PATH); strlwr (buf1); strlwr (buf); char *p = strchr (buf, ':'); @@ -838,7 +838,7 @@ initial_env () if (GetEnvironmentVariable ("CYGWIN_TESTING", buf, sizeof (buf) - 1)) { _cygwin_testing = 1; - if ((len = GetModuleFileName (cygwin_hmodule, buf, MAX_PATH)) + if ((len = GetModuleFileName (cygwin_hmodule, buf, CYG_MAX_PATH)) && len > sizeof ("new-cygwin1.dll") && strcasematch (buf + len - sizeof ("new-cygwin1.dll"), "\\new-cygwin1.dll")) diff --git a/winsup/cygwin/delqueue.cc b/winsup/cygwin/delqueue.cc index 11c8c50..76f2d6d 100644 --- a/winsup/cygwin/delqueue.cc +++ b/winsup/cygwin/delqueue.cc @@ -30,7 +30,7 @@ delqueue_list::init () void delqueue_list::queue_file (const char *dosname) { - char temp[MAX_PATH], *end; + char temp[CYG_MAX_PATH], *end; GetFullPathName (dosname, sizeof (temp), temp, &end); /* Note about race conditions: The only time we get to this point is diff --git a/winsup/cygwin/dlfcn.cc b/winsup/cygwin/dlfcn.cc index 563f2db..3032cc4 100644 --- a/winsup/cygwin/dlfcn.cc +++ b/winsup/cygwin/dlfcn.cc @@ -49,7 +49,7 @@ get_full_path_of_dll (const char* str, char *name) int len = strlen (str); /* empty string or too long to be legal win32 pathname? */ - if (len == 0 || len >= MAX_PATH - 1) + if (len == 0 || len >= CYG_MAX_PATH - 1) return str; /* Yes. Let caller deal with it. */ const char *ret; @@ -93,7 +93,7 @@ dlopen (const char *name, int) ret = (void *) GetModuleHandle (NULL); /* handle for the current module */ else { - char buf[MAX_PATH]; + char buf[CYG_MAX_PATH]; /* handle for the named library */ const char *fullpath = get_full_path_of_dll (name, buf); if (!fullpath) diff --git a/winsup/cygwin/dll_init.cc b/winsup/cygwin/dll_init.cc index 38af9aa..1bfd61c 100644 --- a/winsup/cygwin/dll_init.cc +++ b/winsup/cygwin/dll_init.cc @@ -103,7 +103,7 @@ dll_list::operator[] (const char *name) dll * dll_list::alloc (HINSTANCE h, per_process *p, dll_type type) { - char name[MAX_PATH + 1]; + char name[CYG_MAX_PATH + 1]; DWORD namelen = GetModuleFileName (h, name, sizeof (name)); /* Already loaded? */ diff --git a/winsup/cygwin/dll_init.h b/winsup/cygwin/dll_init.h index 24cd79b..5d6c6ab 100644 --- a/winsup/cygwin/dll_init.h +++ b/winsup/cygwin/dll_init.h @@ -51,7 +51,7 @@ struct dll int count; dll_type type; int namelen; - char name[MAX_PATH + 1]; + char name[CYG_MAX_PATH + 1]; void detach (); int init (); }; diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc index 630b93b..854f334 100644 --- a/winsup/cygwin/dtable.cc +++ b/winsup/cygwin/dtable.cc @@ -251,7 +251,7 @@ dtable::init_std_file_from_handle (int fd, HANDLE handle) dev.parse ("/dev/ttyS0"); else { - name = handle_to_fn (handle, (char *) alloca (MAX_PATH + 100)); + name = handle_to_fn (handle, (char *) alloca (CYG_MAX_PATH + 100)); bin = 0; } } @@ -768,7 +768,7 @@ handle_to_fn (HANDLE h, char *posix_fn) ntfn->Name.Buffer[ntfn->Name.Length / sizeof (WCHAR)] = 0; - char win32_fn[MAX_PATH + 100]; + char win32_fn[CYG_MAX_PATH + 100]; sys_wcstombs (win32_fn, ntfn->Name.Buffer, ntfn->Name.Length); debug_printf ("nt name '%s'", win32_fn); if (!strncasematch (win32_fn, DEVICE_PREFIX, DEVICE_PREFIX_LEN) @@ -782,8 +782,8 @@ handle_to_fn (HANDLE h, char *posix_fn) char *maxmatchdos = NULL; for (char *s = fnbuf; *s; s = strchr (s, '\0') + 1) { - char device[MAX_PATH + 10]; - device[MAX_PATH + 9] = '\0'; + char device[CYG_MAX_PATH + 10]; + device[CYG_MAX_PATH + 9] = '\0'; if (strchr (s, ':') == NULL) continue; if (!QueryDosDevice (s, device, sizeof (device) - 1)) diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index b8e6a3c..fd04e1f 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -53,7 +53,7 @@ static char **lastenviron; PATH needs to be here because CreateProcess uses it and gdb uses CreateProcess. HOME is here because most shells use it and would be confused by Windows style path names. */ -static int return_MAX_PATH (const char *) {return MAX_PATH;} +static int return_MAX_PATH (const char *) {return CYG_MAX_PATH;} static NO_COPY win_env conv_envvars[] = { {NL ("PATH="), NULL, NULL, cygwin_win32_to_posix_path_list, @@ -539,7 +539,7 @@ parse_options (char *buf) if (buf == NULL) { - char newbuf[MAX_PATH + 7]; + char newbuf[CYG_MAX_PATH + 7]; newbuf[0] = '\0'; for (k = known; k->name != NULL; k++) if (k->remember) @@ -624,7 +624,7 @@ regopt (const char *name) bool parsed_something = false; /* FIXME: should not be under mount */ reg_key r (KEY_READ, CYGWIN_INFO_PROGRAM_OPTIONS_NAME, NULL); - char buf[MAX_PATH]; + char buf[CYG_MAX_PATH]; char lname[strlen (name) + 1]; strlwr (strcpy (lname, name)); diff --git a/winsup/cygwin/environ.h b/winsup/cygwin/environ.h index 1a616b2..f6a1797 100644 --- a/winsup/cygwin/environ.h +++ b/winsup/cygwin/environ.h @@ -16,7 +16,7 @@ void environ_init (char **, int) file specs. Currently, only PATH and HOME are converted, but PATH needs to use a "convert path list" function while HOME needs a simple "convert to posix/win32". For the simple case, where a calculated length - is required, just return MAX_PATH. *FIXME* */ + is required, just return CYG_MAX_PATH. *FIXME* */ struct win_env { const char *name; diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 194aa33..4baa505 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -28,7 +28,7 @@ details. */ #define CALL_HANDLER_RETRY 20 -char debugger_command[2 * MAX_PATH + 20]; +char debugger_command[2 * CYG_MAX_PATH + 20]; extern "C" { static int handle_exceptions (EXCEPTION_RECORD *, void *, CONTEXT *, void *); @@ -141,8 +141,8 @@ error_start_init (const char *buf) return; } - char pgm[MAX_PATH + 1]; - if (!GetModuleFileName (NULL, pgm, MAX_PATH)) + char pgm[CYG_MAX_PATH + 1]; + if (!GetModuleFileName (NULL, pgm, CYG_MAX_PATH)) strcpy (pgm, "cygwin1.dll"); for (char *p = strchr (pgm, '\\'); p; p = strchr (p, '\\')) *p = '/'; @@ -1125,7 +1125,7 @@ void events_init (void) { char *name; - char mutex_name[MAX_PATH]; + char mutex_name[CYG_MAX_PATH]; /* title_mutex protects modification of console title. It's necessary while finding console window handle */ diff --git a/winsup/cygwin/external.cc b/winsup/cygwin/external.cc index 1e75dc1..fcb2b21 100644 --- a/winsup/cygwin/external.cc +++ b/winsup/cygwin/external.cc @@ -114,8 +114,8 @@ get_cygdrive_info (char *user, char *system, char *user_flags, static DWORD get_cygdrive_prefixes (char *user, char *system) { - char user_flags[MAX_PATH]; - char system_flags[MAX_PATH]; + char user_flags[CYG_MAX_PATH]; + char system_flags[CYG_MAX_PATH]; DWORD res = get_cygdrive_info (user, system, user_flags, system_flags); return res; } diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index 743e33b..e19c196 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -611,7 +611,7 @@ fhandler_disk_file::opendir () if (!pc.isdir ()) set_errno (ENOTDIR); - else if ((len = strlen (pc))> MAX_PATH - 3) + else if ((len = strlen (pc))> CYG_MAX_PATH - 3) set_errno (ENAMETOOLONG); else if ((dir = (DIR *) malloc (sizeof (DIR))) == NULL) set_errno (ENOMEM); @@ -718,7 +718,7 @@ fhandler_disk_file::readdir (DIR *dir) int len = strlen (c); if (strcasematch (c + len - 4, ".lnk")) { - char fbuf[MAX_PATH + 1]; + char fbuf[CYG_MAX_PATH + 1]; strcpy (fbuf, dir->__d_dirname); strcpy (fbuf + strlen (fbuf) - 1, dir->__d_dirent->d_name); path_conv fpath (fbuf, PC_SYM_NOFOLLOW); diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc index d1fc273..a05615a 100644 --- a/winsup/cygwin/fhandler_proc.cc +++ b/winsup/cygwin/fhandler_proc.cc @@ -862,7 +862,7 @@ format_proc_partitions (char *destbuf, size_t maxsize) { for (int drive_number=0;;drive_number++) { - CHAR szDriveName[MAX_PATH]; + CHAR szDriveName[CYG_MAX_PATH]; __small_sprintf (szDriveName, "\\\\.\\PHYSICALDRIVE%d", drive_number); HANDLE hDevice; hDevice = CreateFile (szDriveName, diff --git a/winsup/cygwin/fhandler_process.cc b/winsup/cygwin/fhandler_process.cc index 3b61cd9..28dc78f 100644 --- a/winsup/cygwin/fhandler_process.cc +++ b/winsup/cygwin/fhandler_process.cc @@ -305,7 +305,7 @@ fhandler_process::fill_filebuf () } case PROCESS_EXENAME: { - filebuf = (char *) realloc (filebuf, bufalloc = MAX_PATH); + filebuf = (char *) realloc (filebuf, bufalloc = CYG_MAX_PATH); if (p->process_state & (PID_ZOMBIE | PID_EXITED)) strcpy (filebuf, "<defunct>"); else @@ -364,7 +364,7 @@ fhandler_process::fill_filebuf () static _off64_t format_process_stat (_pinfo *p, char *destbuf, size_t maxsize) { - char cmd[MAX_PATH]; + char cmd[CYG_MAX_PATH]; int state = 'R'; unsigned long fault_count = 0UL, utime = 0UL, stime = 0UL, @@ -501,7 +501,7 @@ format_process_stat (_pinfo *p, char *destbuf, size_t maxsize) static _off64_t format_process_status (_pinfo *p, char *destbuf, size_t maxsize) { - char cmd[MAX_PATH]; + char cmd[CYG_MAX_PATH]; int state = 'R'; const char *state_str = "unknown"; unsigned long vmsize = 0UL, vmrss = 0UL, vmdata = 0UL, vmlib = 0UL, vmtext = 0UL, diff --git a/winsup/cygwin/fhandler_raw.cc b/winsup/cygwin/fhandler_raw.cc index ba74d7e..1ece531 100644 --- a/winsup/cygwin/fhandler_raw.cc +++ b/winsup/cygwin/fhandler_raw.cc @@ -183,7 +183,7 @@ fhandler_dev_raw::open (int flags, mode_t) extern void str2buf2uni (UNICODE_STRING &, WCHAR *, const char *); UNICODE_STRING dev; - WCHAR devname[MAX_PATH + 1]; + WCHAR devname[CYG_MAX_PATH + 1]; str2buf2uni (dev, devname, get_win32_name ()); OBJECT_ATTRIBUTES attr; InitializeObjectAttributes (&attr, &dev, OBJ_CASE_INSENSITIVE, NULL, NULL); diff --git a/winsup/cygwin/fhandler_registry.cc b/winsup/cygwin/fhandler_registry.cc index e9bc37e..f80096f 100644 --- a/winsup/cygwin/fhandler_registry.cc +++ b/winsup/cygwin/fhandler_registry.cc @@ -97,7 +97,7 @@ int fhandler_registry::exists () { int file_type = 0, index = 0, pathlen; - DWORD buf_size = MAX_PATH; + DWORD buf_size = CYG_MAX_PATH; LONG error; char buf[buf_size]; const char *file; @@ -152,7 +152,7 @@ fhandler_registry::exists () file_type = 1; goto out; } - buf_size = MAX_PATH; + buf_size = CYG_MAX_PATH; } if (error != ERROR_NO_MORE_ITEMS) { @@ -160,7 +160,7 @@ fhandler_registry::exists () goto out; } index = 0; - buf_size = MAX_PATH; + buf_size = CYG_MAX_PATH; while (ERROR_SUCCESS == (error = RegEnumValue (hKey, index++, buf, &buf_size, NULL, NULL, NULL, NULL)) @@ -172,7 +172,7 @@ fhandler_registry::exists () file_type = -1; goto out; } - buf_size = MAX_PATH; + buf_size = CYG_MAX_PATH; } if (error != ERROR_NO_MORE_ITEMS) { @@ -276,7 +276,7 @@ fhandler_registry::fstat (struct __stat64 *buf) struct dirent * fhandler_registry::readdir (DIR * dir) { - DWORD buf_size = MAX_PATH; + DWORD buf_size = CYG_MAX_PATH; char buf[buf_size]; HANDLE handle; struct dirent *res = NULL; @@ -324,7 +324,7 @@ retry: { /* If we're finished with sub-keys, start on values under this key. */ dir->__d_position |= REG_ENUM_VALUES_MASK; - buf_size = MAX_PATH; + buf_size = CYG_MAX_PATH; goto retry; } if (error != ERROR_SUCCESS && error != ERROR_MORE_DATA) @@ -592,7 +592,7 @@ fhandler_registry::fill_filebuf () } return true; value_not_found: - DWORD buf_size = MAX_PATH; + DWORD buf_size = CYG_MAX_PATH; char buf[buf_size]; int index = 0; while (ERROR_SUCCESS == @@ -604,7 +604,7 @@ value_not_found: set_errno (EISDIR); return false; } - buf_size = MAX_PATH; + buf_size = CYG_MAX_PATH; } if (error != ERROR_NO_MORE_ITEMS) { @@ -622,7 +622,7 @@ open_key (const char *name, REGSAM access, bool isValue) HKEY hKey = (HKEY) INVALID_HANDLE_VALUE; HKEY hParentKey = (HKEY) INVALID_HANDLE_VALUE; bool parentOpened = false; - char component[MAX_PATH]; + char component[CYG_MAX_PATH]; while (*name) { diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index 5ff45df..f796c28 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -189,7 +189,7 @@ fhandler_socket::create_secret_event (int* secret) return NULL; } - char event_name[MAX_PATH]; + char event_name[CYG_MAX_PATH]; secret_event_name (event_name, sin.sin_port, secret ?: connect_secret); LPSECURITY_ATTRIBUTES sec = get_inheritance (true); secret_event = CreateEvent (sec, FALSE, FALSE, event_name); @@ -230,7 +230,7 @@ int fhandler_socket::check_peer_secret_event (struct sockaddr_in* peer, int* secret) { - char event_name[MAX_PATH]; + char event_name[CYG_MAX_PATH]; secret_event_name (event_name, peer->sin_port, secret ?: connect_secret); HANDLE ev = CreateEvent (&sec_all_nih, FALSE, FALSE, event_name); diff --git a/winsup/cygwin/fhandler_virtual.cc b/winsup/cygwin/fhandler_virtual.cc index f2ca944..957aaff 100644 --- a/winsup/cygwin/fhandler_virtual.cc +++ b/winsup/cygwin/fhandler_virtual.cc @@ -52,7 +52,7 @@ fhandler_virtual::opendir () if (exists () <= 0) set_errno (ENOTDIR); - else if ((len = strlen (get_name ())) > MAX_PATH - 3) + else if ((len = strlen (get_name ())) > CYG_MAX_PATH - 3) set_errno (ENAMETOOLONG); else if ((dir = (DIR *) malloc (sizeof (DIR))) == NULL) set_errno (ENOMEM); diff --git a/winsup/cygwin/include/cygwin/config.h b/winsup/cygwin/include/cygwin/config.h index e3e09f0..2613c44 100644 --- a/winsup/cygwin/include/cygwin/config.h +++ b/winsup/cygwin/include/cygwin/config.h @@ -20,7 +20,7 @@ extern "C" { #define _CYGWIN_CONFIG_H #define __DYNAMIC_REENT__ -#define __FILENAME_MAX__ (260 - 1 /* NUL */) +#define __FILENAME_MAX__ (4096 - 1 /* NUL */) #define _READ_WRITE_RETURN_TYPE _ssize_t #define __LARGE64_FILES 1 #define __CYGWIN_USE_BIG_TYPES__ 1 diff --git a/winsup/cygwin/include/limits.h b/winsup/cygwin/include/limits.h index 9fa3cf4..cefbbac 100644 --- a/winsup/cygwin/include/limits.h +++ b/winsup/cygwin/include/limits.h @@ -125,7 +125,7 @@ details. */ #define SSIZE_MAX (__LONG_MAX__) /* Maximum length of a path */ -#define PATH_MAX (260 - 1 /*NUL*/) +#define PATH_MAX (4096 - 1 /*NUL*/) /* Max num groups for a user, value taken from NT documentation */ /* Must match <sys/param.h> NGROUPS */ diff --git a/winsup/cygwin/include/sys/param.h b/winsup/cygwin/include/sys/param.h index 811b5ee..e067bbf 100644 --- a/winsup/cygwin/include/sys/param.h +++ b/winsup/cygwin/include/sys/param.h @@ -31,7 +31,7 @@ /* This is defined to be the same as MAX_PATH which is used internally. The Posix version is PATH_MAX. */ -#define MAXPATHLEN (260 - 1 /*NUL*/) +#define MAXPATHLEN (4096 - 1 /*NUL*/) /* This is the number of bytes per block given in the st_blocks stat member. It should be in sync with S_BLKSIZE in sys/stat.h. S_BLKSIZE is the diff --git a/winsup/cygwin/libc/bsdlib.cc b/winsup/cygwin/libc/bsdlib.cc index 6d23753..0fad852 100644 --- a/winsup/cygwin/libc/bsdlib.cc +++ b/winsup/cygwin/libc/bsdlib.cc @@ -115,7 +115,7 @@ openpty (int *amaster, int *aslave, char *name, struct termios *termp, struct winsize *winp) { int master, slave; - char pts[MAX_PATH]; + char pts[CYG_MAX_PATH]; if ((master = open ("/dev/ptmx", O_RDWR | O_NOCTTY)) >= 0) { diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc index fc72793..5fdef4d 100644 --- a/winsup/cygwin/miscfuncs.cc +++ b/winsup/cygwin/miscfuncs.cc @@ -147,7 +147,7 @@ strcasestr (const char *searchee, const char *lookfor) int __stdcall check_null_str (const char *name) { - if (name && !IsBadStringPtr (name, MAX_PATH)) + if (name && !IsBadStringPtr (name, CYG_MAX_PATH)) return 0; return EFAULT; @@ -156,7 +156,7 @@ check_null_str (const char *name) int __stdcall check_null_empty_str (const char *name) { - if (name && !IsBadStringPtr (name, MAX_PATH)) + if (name && !IsBadStringPtr (name, CYG_MAX_PATH)) return !*name ? ENOENT : 0; return EFAULT; diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc index c572b08..fe67978 100644 --- a/winsup/cygwin/mmap.cc +++ b/winsup/cygwin/mmap.cc @@ -900,7 +900,7 @@ fhandler_disk_file::mmap (caddr_t *addr, size_t len, DWORD access, /* Grrr, the whole stuff is just needed to try to get a reliable mapping of the same file. Even that uprising isn't bullet proof but it does it's best... */ - char namebuf[MAX_PATH]; + char namebuf[CYG_MAX_PATH]; cygwin_conv_to_full_posix_path (get_name (), namebuf); for (int i = strlen (namebuf) - 1; i >= 0; --i) namebuf[i] = cyg_tolower (namebuf [i]); diff --git a/winsup/cygwin/netdb.cc b/winsup/cygwin/netdb.cc index 689fb3e..53f0412 100644 --- a/winsup/cygwin/netdb.cc +++ b/winsup/cygwin/netdb.cc @@ -30,17 +30,17 @@ details. */ static FILE * open_system_file (const char *relative_path) { - char win32_name[MAX_PATH]; - char posix_name[MAX_PATH]; + char win32_name[CYG_MAX_PATH]; + char posix_name[CYG_MAX_PATH]; if (wincap.is_winnt ()) { - if (!GetSystemDirectory (win32_name, MAX_PATH)) + if (!GetSystemDirectory (win32_name, CYG_MAX_PATH)) return NULL; strcat (win32_name, "\\drivers\\etc\\"); } else { - if (!GetWindowsDirectory (win32_name, MAX_PATH)) + if (!GetWindowsDirectory (win32_name, CYG_MAX_PATH)) return NULL; strcat (win32_name, "\\"); } diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 499ccd0..e938685 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -88,7 +88,7 @@ static void backslashify (const char *src, char *dst, int trailing_slash_p); struct symlink_info { - char contents[MAX_PATH + 4]; + char contents[CYG_MAX_PATH + 4]; char *ext_here; int extn; unsigned pflags; @@ -302,7 +302,7 @@ normalize_posix_path (const char *src, char *dst) *dst++ = '/'; } - if ((dst - dst_start) >= MAX_PATH) + if ((dst - dst_start) >= CYG_MAX_PATH) { debug_printf ("ENAMETOOLONG = normalize_posix_path (%s)", src); return ENAMETOOLONG; @@ -333,7 +333,7 @@ static void __stdcall mkrelpath (char *dst) __attribute__ ((regparm (2))); static void __stdcall mkrelpath (char *path) { - char cwd_win32[MAX_PATH]; + char cwd_win32[CYG_MAX_PATH]; if (!cygheap->cwd.get (cwd_win32, 0)) return; @@ -359,8 +359,8 @@ mkrelpath (char *path) bool fs_info::update (const char *win32_path) { - char tmp_buf [MAX_PATH]; - strncpy (tmp_buf, win32_path, MAX_PATH); + char tmp_buf [CYG_MAX_PATH]; + strncpy (tmp_buf, win32_path, CYG_MAX_PATH); if (!rootdir (tmp_buf)) { @@ -373,7 +373,7 @@ fs_info::update (const char *win32_path) if (strcmp (tmp_buf, root_dir_storage) == 0) return 1; - strncpy (root_dir_storage, tmp_buf, MAX_PATH); + strncpy (root_dir_storage, tmp_buf, CYG_MAX_PATH); drive_type_storage = GetDriveType (root_dir_storage); if (drive_type_storage == DRIVE_REMOTE || (drive_type_storage == DRIVE_UNKNOWN && (root_dir_storage[0] == '\\' && root_dir_storage[1] == '\\'))) is_remote_drive_storage = 1; @@ -449,11 +449,11 @@ void path_conv::check (const char *src, unsigned opt, const suffix_info *suffixes) { - /* This array is used when expanding symlinks. It is MAX_PATH * 2 + /* This array is used when expanding symlinks. It is CYG_MAX_PATH * 2 in length so that we can hold the expanded symlink plus a trailer. */ - char path_copy[MAX_PATH + 3]; - char tmp_buf[2 * MAX_PATH + 3]; + char path_copy[CYG_MAX_PATH + 3]; + char tmp_buf[2 * CYG_MAX_PATH + 3]; symlink_info sym; bool need_directory = 0; bool saw_symlinks = 0; @@ -463,7 +463,7 @@ path_conv::check (const char *src, unsigned opt, #if 0 static path_conv last_path_conv; - static char last_src[MAX_PATH + 1]; + static char last_src[CYG_MAX_PATH + 1]; if (*last_src && strcmp (last_src, src) == 0) { @@ -529,7 +529,7 @@ path_conv::check (const char *src, unsigned opt, for (;;) { const suffix_info *suff; - char pathbuf[MAX_PATH]; + char pathbuf[CYG_MAX_PATH]; char *full_path; /* Don't allow symlink.check to set anything in the path_conv @@ -737,7 +737,7 @@ path_conv::check (const char *src, unsigned opt, \0 added to path_copy above. */ int taillen = strlen (++tail); int buflen = strlen (sym.contents); - if (buflen + taillen > MAX_PATH) + if (buflen + taillen > CYG_MAX_PATH) { error = ENAMETOOLONG; strcpy (path, "::ENAMETOOLONG::"); @@ -953,7 +953,7 @@ normalize_win32_path (const char *src, char *dst) *p = '\0'; } } - if (strlen (dst) + 1 + strlen (src) >= MAX_PATH) + if (strlen (dst) + 1 + strlen (src) >= CYG_MAX_PATH) { debug_printf ("ENAMETOOLONG = normalize_win32_path (%s)", src); return ENAMETOOLONG; @@ -998,7 +998,7 @@ normalize_win32_path (const char *src, char *dst) *dst++ = *src; ++src; } - if ((dst - dst_start) >= MAX_PATH) + if ((dst - dst_start) >= CYG_MAX_PATH) return ENAMETOOLONG; } *dst = 0; @@ -1103,8 +1103,8 @@ conv_path_list (const char *src, char *dst, int to_posix) { s = strccpy (srcbuf, &src, src_delim); int len = s - srcbuf; - if (len >= MAX_PATH) - srcbuf[MAX_PATH - 1] = '\0'; + if (len >= CYG_MAX_PATH) + srcbuf[CYG_MAX_PATH - 1] = '\0'; (*conv_fn) (len ? srcbuf : ".", d); if (!*src++) break; @@ -1301,7 +1301,7 @@ mount_item::build_win32 (char *dst, const char *src, unsigned *outflags, unsigne The result is zero for success, or an errno value. - {,full_}win32_path must have sufficient space (i.e. MAX_PATH bytes). */ + {,full_}win32_path must have sufficient space (i.e. CYG_MAX_PATH bytes). */ int mount_info::conv_to_win32_path (const char *src_path, char *dst, device& dev, @@ -1325,7 +1325,7 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst, device& dev, *flags = 0; debug_printf ("conv_to_win32_path (%s)", src_path); - if (src_path_len >= MAX_PATH) + if (src_path_len >= CYG_MAX_PATH) { debug_printf ("ENAMETOOLONG = conv_to_win32_path (%s)", src_path); return ENAMETOOLONG; @@ -1333,7 +1333,7 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst, device& dev, int i, rc; mount_item *mi = NULL; /* initialized to avoid compiler warning */ - char pathbuf[MAX_PATH]; + char pathbuf[CYG_MAX_PATH]; if (dst == NULL) goto out; /* Sanity check. */ @@ -1530,7 +1530,7 @@ mount_info::cygdrive_win32_path (const char *src, char *dst, int& unit) /* conv_to_posix_path: Ensure src_path is a POSIX path. The result is zero for success, or an errno value. - posix_path must have sufficient space (i.e. MAX_PATH bytes). + posix_path must have sufficient space (i.e. CYG_MAX_PATH bytes). If keep_rel_p is non-zero, relative paths stay that way. */ int @@ -1554,7 +1554,7 @@ mount_info::conv_to_posix_path (const char *src_path, char *posix_path, trailing_slash_p ? "add-slash" : "no-add-slash"); MALLOC_CHECK; - if (src_path_len >= MAX_PATH) + if (src_path_len >= CYG_MAX_PATH) { debug_printf ("ENAMETOOLONG"); return ENAMETOOLONG; @@ -1570,7 +1570,7 @@ mount_info::conv_to_posix_path (const char *src_path, char *posix_path, return 0; } - char pathbuf[MAX_PATH]; + char pathbuf[CYG_MAX_PATH]; int rc = normalize_win32_path (src_path, pathbuf); if (rc != 0) { @@ -1600,7 +1600,7 @@ mount_info::conv_to_posix_path (const char *src_path, char *posix_path, nextchar = 1; int addslash = nextchar > 0 ? 1 : 0; - if ((mi.posix_pathlen + (pathbuflen - mi.native_pathlen) + addslash) >= MAX_PATH) + if ((mi.posix_pathlen + (pathbuflen - mi.native_pathlen) + addslash) >= CYG_MAX_PATH) return ENAMETOOLONG; strcpy (posix_path, mi.posix_path); if (addslash) @@ -1617,7 +1617,7 @@ mount_info::conv_to_posix_path (const char *src_path, char *posix_path, } if (mi.flags & MOUNT_ENC) { - char tmpbuf[MAX_PATH + 1]; + char tmpbuf[CYG_MAX_PATH + 1]; if (fnunmunge (tmpbuf, posix_path)) strcpy (posix_path, tmpbuf); } @@ -1680,7 +1680,7 @@ mount_info::set_flags_from_win32_path (const char *p) void mount_info::read_mounts (reg_key& r) { - char posix_path[MAX_PATH]; + char posix_path[CYG_MAX_PATH]; HKEY key = r.get_key (); DWORD i, posix_path_size; int res; @@ -1691,13 +1691,13 @@ mount_info::read_mounts (reg_key& r) arbitrarily large number of mounts. */ for (i = 0; ; i++) { - char native_path[MAX_PATH]; + char native_path[CYG_MAX_PATH]; int mount_flags; - posix_path_size = MAX_PATH; + posix_path_size = CYG_MAX_PATH; /* FIXME: if maximum posix_path_size is 256, we're going to run into problems if we ever try to store a mount point that's - over 256 but is under MAX_PATH. */ + over 256 but is under CYG_MAX_PATH. */ res = RegEnumKeyEx (key, i, posix_path, &posix_path_size, NULL, NULL, NULL, NULL); @@ -1987,7 +1987,7 @@ mount_info::get_cygdrive_info (char *user, char *system, char* user_flags, { /* Get the user path prefix from HKEY_CURRENT_USER. */ reg_key r; - int res = r.get_string (CYGWIN_INFO_CYGDRIVE_PREFIX, user, MAX_PATH, ""); + int res = r.get_string (CYGWIN_INFO_CYGDRIVE_PREFIX, user, CYG_MAX_PATH, ""); /* Get the user flags, if appropriate */ if (res == ERROR_SUCCESS) @@ -2001,7 +2001,7 @@ mount_info::get_cygdrive_info (char *user, char *system, char* user_flags, CYGWIN_INFO_CYGNUS_REGISTRY_NAME, CYGWIN_REGNAME, CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME, NULL); - int res2 = r2.get_string (CYGWIN_INFO_CYGDRIVE_PREFIX, system, MAX_PATH, ""); + int res2 = r2.get_string (CYGWIN_INFO_CYGDRIVE_PREFIX, system, CYG_MAX_PATH, ""); /* Get the system flags, if appropriate */ if (res2 == ERROR_SUCCESS) @@ -2121,8 +2121,8 @@ mount_info::add_item (const char *native, const char *posix, unsigned mountflags } /* Make sure both paths do not end in /. */ - char nativetmp[MAX_PATH]; - char posixtmp[MAX_PATH]; + char nativetmp[CYG_MAX_PATH]; + char posixtmp[CYG_MAX_PATH]; backslashify (native, nativetmp, 0); nofinalslash (nativetmp, nativetmp); @@ -2181,7 +2181,7 @@ mount_info::add_item (const char *native, const char *posix, unsigned mountflags int mount_info::del_item (const char *path, unsigned flags, int reg_p) { - char pathtmp[MAX_PATH]; + char pathtmp[CYG_MAX_PATH]; int posix_path_p = false; /* Something's wrong if path is NULL or empty. */ @@ -2304,7 +2304,7 @@ static struct mntent * cygdrive_getmntent () { char native_path[4]; - char posix_path[MAX_PATH]; + char posix_path[CYG_MAX_PATH]; DWORD mask = 1, drive = 'a'; struct mntent *ret = NULL; @@ -2486,9 +2486,9 @@ symlink_worker (const char *topath, const char *frompath, bool use_winsym, HANDLE h; int res = -1; path_conv win32_path, win32_topath; - char from[MAX_PATH + 5]; - char cwd[MAX_PATH + 1], *cp = NULL, c = 0; - char w32topath[MAX_PATH + 1]; + char from[CYG_MAX_PATH + 5]; + char cwd[CYG_MAX_PATH + 1], *cp = NULL, c = 0; + char w32topath[CYG_MAX_PATH + 1]; DWORD written; SECURITY_ATTRIBUTES sa = sec_none_nih; @@ -2499,7 +2499,7 @@ symlink_worker (const char *topath, const char *frompath, bool use_winsym, check_null_empty_str_errno (frompath)) goto done; - if (strlen (topath) >= MAX_PATH) + if (strlen (topath) >= CYG_MAX_PATH) { set_errno (ENAMETOOLONG); goto done; @@ -2540,7 +2540,7 @@ symlink_worker (const char *topath, const char *frompath, bool use_winsym, { if (!isabspath (topath)) { - getcwd (cwd, MAX_PATH + 1); + getcwd (cwd, CYG_MAX_PATH + 1); if ((cp = strrchr (from, '/')) || (cp = strrchr (from, '\\'))) { c = *cp; @@ -2597,7 +2597,7 @@ symlink_worker (const char *topath, const char *frompath, bool use_winsym, else { /* This is the old technique creating a symlink. */ - char buf[sizeof (SYMLINK_COOKIE) + MAX_PATH + 10]; + char buf[sizeof (SYMLINK_COOKIE) + CYG_MAX_PATH + 10]; __small_sprintf (buf, "%s%s", SYMLINK_COOKIE, topath); DWORD len = strlen (buf) + 1; @@ -2677,7 +2677,7 @@ check_shortcut (const char *path, DWORD fileattr, HANDLE h, *error = EIO; goto close_it; } - if (got != sizeof len || len == 0 || len > MAX_PATH) + if (got != sizeof len || len == 0 || len > CYG_MAX_PATH) goto file_not_symlink; /* Now read description entry. */ if (!ReadFile (h, contents, len, &got, 0)) @@ -2723,7 +2723,7 @@ check_sysfile (const char *path, DWORD fileattr, HANDLE h, /* It's a symlink. */ *pflags = PATH_SYMLINK; - res = ReadFile (h, contents, MAX_PATH + 1, &got, 0); + res = ReadFile (h, contents, CYG_MAX_PATH + 1, &got, 0); if (!res) { debug_printf ("ReadFile2 failed"); @@ -3219,7 +3219,7 @@ getcwd (char *buf, size_t ulen) extern "C" char * getwd (char *buf) { - return getcwd (buf, MAX_PATH); + return getcwd (buf, CYG_MAX_PATH); } /* chdir: POSIX 5.2.1.1 */ @@ -3640,7 +3640,7 @@ cwdstuff::get_initial () int i; DWORD len, dlen; - for (i = 0, dlen = MAX_PATH, len = 0; i < 3; dlen *= 2, i++) + for (i = 0, dlen = CYG_MAX_PATH, len = 0; i < 3; dlen *= 2, i++) { win32 = (char *) crealloc (win32, dlen + 2); if ((len = GetCurrentDirectoryA (dlen, win32)) < dlen) @@ -3665,7 +3665,7 @@ cwdstuff::get_initial () void cwdstuff::set (const char *win32_cwd, const char *posix_cwd) { - char pathbuf[MAX_PATH]; + char pathbuf[CYG_MAX_PATH]; if (win32_cwd) { diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h index b6ab6cf..b1d1a27 100644 --- a/winsup/cygwin/path.h +++ b/winsup/cygwin/path.h @@ -73,8 +73,8 @@ enum path_types class symlink_info; struct fs_info { - char name_storage[MAX_PATH]; - char root_dir_storage[MAX_PATH]; + char name_storage[CYG_MAX_PATH]; + char root_dir_storage[CYG_MAX_PATH]; DWORD flags_storage; DWORD serial_storage; DWORD sym_opt_storage; /* additional options to pass to symlink_info resolver */ @@ -199,7 +199,7 @@ class path_conv size_t normalized_path_size; void set_normalized_path (const char *) __attribute__ ((regparm (2))); private: - char path[MAX_PATH]; + char path[CYG_MAX_PATH]; }; /* Symlink marker */ diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index ce210c3..faf6b86 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -146,7 +146,7 @@ pinfo::init (pid_t n, DWORD flag, HANDLE in_h) for (int i = 0; i < 10; i++) { int created; - char mapname[MAX_PATH]; + char mapname[CYG_MAX_PATH]; /* XXX Not a path */ __small_sprintf (mapname, "cygpid.%x", n); int mapsize; diff --git a/winsup/cygwin/pinfo.h b/winsup/cygwin/pinfo.h index 4988ca7..573e050 100644 --- a/winsup/cygwin/pinfo.h +++ b/winsup/cygwin/pinfo.h @@ -66,7 +66,7 @@ public: DWORD dwProcessId; /* Used to spawn a child for fork(), among other things. */ - char progname[MAX_PATH]; + char progname[CYG_MAX_PATH]; /* User information. The information is derived from the GetUserName system call, diff --git a/winsup/cygwin/pthread.cc b/winsup/cygwin/pthread.cc index 275e566..78c7f46 100644 --- a/winsup/cygwin/pthread.cc +++ b/winsup/cygwin/pthread.cc @@ -168,8 +168,8 @@ mangle_sem_name (char *mangled, const char *name) if (check_null_empty_str_errno (name)) return false; int len = strlen (name); - if (len > MAX_PATH - || (wincap.has_terminal_services () && len > MAX_PATH - 7)) + if (len > CYG_MAX_PATH + || (wincap.has_terminal_services () && len > CYG_MAX_PATH - 7)) { set_errno (EINVAL); return false; @@ -196,7 +196,7 @@ sem_open (const char *name, int oflag, ...) value = va_arg (ap, unsigned int); va_end (ap); } - char mangled_name[MAX_PATH + 1]; + char mangled_name[CYG_MAX_PATH + 1]; if (!mangle_sem_name (mangled_name, name)) return NULL; return semaphore::open (mangled_name, oflag, mode, value); diff --git a/winsup/cygwin/registry.cc b/winsup/cygwin/registry.cc index d1443ee..0a36b3a 100644 --- a/winsup/cygwin/registry.cc +++ b/winsup/cygwin/registry.cc @@ -226,7 +226,7 @@ void load_registry_hive (PSID psid) { char sid[256]; - char path[MAX_PATH + 1]; + char path[CYG_MAX_PATH + 1]; HKEY hkey; LONG ret; diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc index 911465a..9bec8c0 100644 --- a/winsup/cygwin/shared.cc +++ b/winsup/cygwin/shared.cc @@ -87,7 +87,7 @@ open_shared (const char *name, int n, HANDLE &shared_h, DWORD size, if (!shared_h) { char *mapname; - char map_buf[MAX_PATH]; + char map_buf[CYG_MAX_PATH]; if (!name) mapname = NULL; else diff --git a/winsup/cygwin/shared_info.h b/winsup/cygwin/shared_info.h index fd197bd..3a462be 100644 --- a/winsup/cygwin/shared_info.h +++ b/winsup/cygwin/shared_info.h @@ -20,11 +20,11 @@ class mount_item area [with the user being able to configure at runtime the max size]. */ /* Win32-style mounted partition source ("C:\foo\bar"). native_path[0] == 0 for unused entries. */ - char native_path[MAX_PATH]; + char native_path[CYG_MAX_PATH]; int native_pathlen; /* POSIX-style mount point ("/foo/bar") */ - char posix_path[MAX_PATH]; + char posix_path[CYG_MAX_PATH]; int posix_pathlen; unsigned flags; @@ -62,7 +62,7 @@ class mount_info /* cygdrive_prefix is used as the root of the path automatically prepended to a path when the path has no associated mount. cygdrive_flags are the default flags for the cygdrives. */ - char cygdrive[MAX_PATH]; + char cygdrive[CYG_MAX_PATH]; size_t cygdrive_len; unsigned cygdrive_flags; private: @@ -120,7 +120,7 @@ class mount_info class delqueue_list { - char name[MAX_DELQUEUES_PENDING][MAX_PATH]; + char name[MAX_DELQUEUES_PENDING][CYG_MAX_PATH]; char inuse[MAX_DELQUEUES_PENDING]; int empty; diff --git a/winsup/cygwin/smallprint.c b/winsup/cygwin/smallprint.c index ec31afa..740248e 100644 --- a/winsup/cygwin/smallprint.c +++ b/winsup/cygwin/smallprint.c @@ -63,7 +63,7 @@ rn (char *dst, int base, int dosign, long long val, int len, int pad) int __small_vsprintf (char *dst, const char *fmt, va_list ap) { - char tmp[MAX_PATH + 1]; + char tmp[CYG_MAX_PATH + 1]; char *orig = dst; const char *s; @@ -149,7 +149,7 @@ __small_vsprintf (char *dst, const char *fmt, va_list ap) dst = rn (dst, 16, 0, va_arg (ap, long long), len, pad); break; case 'P': - if (!GetModuleFileName (NULL, tmp, MAX_PATH)) + if (!GetModuleFileName (NULL, tmp, CYG_MAX_PATH)) s = "cygwin program"; else s = tmp; diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index ab749d6..02afbf3 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -35,7 +35,7 @@ details. */ #include "environ.h" #include "cygthread.h" -#define LINE_BUF_CHUNK (MAX_PATH * 2) +#define LINE_BUF_CHUNK (CYG_MAX_PATH * 2) static suffix_info std_suffixes[] = { @@ -88,7 +88,7 @@ find_exec (const char *name, path_conv& buf, const char *mywinenv, const char *suffix = ""; debug_printf ("find_exec (%s)", name); const char *retval = buf; - char tmp[MAX_PATH]; + char tmp[CYG_MAX_PATH]; const char *posix = (opt & FE_NATIVE) ? NULL : name; bool has_slash = strchr (name, '/'); @@ -307,7 +307,7 @@ av::unshift (const char *what, int conv) argv = av; memmove (argv + 1, argv, (argc + 1) * sizeof (char *)); - char buf[MAX_PATH + 1]; + char buf[CYG_MAX_PATH + 1]; if (conv) { cygwin_conv_to_posix_path (what, buf); @@ -462,7 +462,7 @@ spawn_guts (const char * prog_arg, const char *const *argv, DWORD done; - char buf[2 * MAX_PATH + 1]; + char buf[2 * CYG_MAX_PATH + 1]; buf[0] = buf[1] = buf[2] = buf[sizeof (buf) - 1] = '\0'; if (!ReadFile (hnd, buf, sizeof (buf) - 1, &done, 0)) { diff --git a/winsup/cygwin/strace.cc b/winsup/cygwin/strace.cc index 57ad3ba..fc0fe58 100644 --- a/winsup/cygwin/strace.cc +++ b/winsup/cygwin/strace.cc @@ -133,7 +133,7 @@ strace::vsprntf (char *buf, const char *func, const char *infmt, va_list ap) count = 0; else { - char *p, progname[MAX_PATH + 1]; + char *p, progname[CYG_MAX_PATH + 1]; if (!pn) p = (char *) "*** unknown ***"; else if ((p = strrchr (pn, '\\')) != NULL) diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index dfc5f0f..adf19e2 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -689,7 +689,7 @@ link (const char *a, const char *b) } /* Shortcut hack. */ - char new_lnk_buf[MAX_PATH + 5]; + char new_lnk_buf[CYG_MAX_PATH + 5]; if (allow_winsymlinks && real_a.is_lnk_symlink () && !real_b.case_clash) { strcpy (new_lnk_buf, b); @@ -710,7 +710,7 @@ link (const char *a, const char *b) LPVOID lpContext; DWORD cbPathLen; DWORD StreamSize; - WCHAR wbuf[MAX_PATH]; + WCHAR wbuf[CYG_MAX_PATH]; BOOL bSuccess; @@ -725,7 +725,7 @@ link (const char *a, const char *b) goto docopy; } - cbPathLen = sys_mbstowcs (wbuf, real_b, MAX_PATH) * sizeof (WCHAR); + cbPathLen = sys_mbstowcs (wbuf, real_b, CYG_MAX_PATH) * sizeof (WCHAR); StreamId.dwStreamId = BACKUP_LINK; StreamId.dwStreamAttributes = 0; @@ -1365,7 +1365,7 @@ rename (const char *oldpath, const char *newpath) path_conv real_new (newpath, PC_SYM_NOFOLLOW); /* Shortcut hack. */ - char new_lnk_buf[MAX_PATH + 5]; + char new_lnk_buf[CYG_MAX_PATH + 5]; if (real_old.is_lnk_symlink () && !real_new.error && !real_new.case_clash) { strcpy (new_lnk_buf, newpath); @@ -2044,7 +2044,7 @@ static int __stdcall mknod_worker (const char *path, mode_t type, mode_t mode, _major_t major, _minor_t minor) { - char buf[sizeof (":\\00000000:00000000:00000000") + MAX_PATH]; + char buf[sizeof (":\\00000000:00000000:00000000") + CYG_MAX_PATH]; sprintf (buf, ":\\%x:%x:%x", major, minor, type | (mode & (S_IRWXU | S_IRWXG | S_IRWXO))); return symlink_worker (buf, path, true, true); @@ -2056,7 +2056,7 @@ mknod32 (const char *path, mode_t mode, __dev32_t dev) if (check_null_empty_str_errno (path)) return -1; - if (strlen (path) >= MAX_PATH) + if (strlen (path) >= CYG_MAX_PATH) return -1; path_conv w32path (path, PC_SYM_NOFOLLOW | PC_FULL); @@ -2595,7 +2595,7 @@ extern "C" void updwtmp (const char *wtmp_file, const struct utmp *ut) { /* Writing to wtmp must be atomic to prevent mixed up data. */ - char mutex_name[MAX_PATH]; + char mutex_name[CYG_MAX_PATH]; HANDLE mutex; int fd; @@ -2833,7 +2833,7 @@ pututline (struct utmp *ut) ut->ut_user, ut->ut_host); /* Read/write to utmp must be atomic to prevent overriding data by concurrent processes. */ - char mutex_name[MAX_PATH]; + char mutex_name[CYG_MAX_PATH]; HANDLE mutex = CreateMutex (NULL, FALSE, shared_name (mutex_name, "utmp_mutex", 0)); if (mutex) @@ -2987,7 +2987,7 @@ getusershell () "/usr/bin/csh", NULL }; - static char buf[MAX_PATH]; + static char buf[CYG_MAX_PATH]; int ch, buf_idx; if (!shell_fp && !(shell_fp = fopen64 (ETC_SHELLS, "rt"))) @@ -3002,11 +3002,11 @@ getusershell () /* Get each non-whitespace character as part of the shell path as long as it fits in buf. */ for (buf_idx = 0; - ch != EOF && !isspace (ch) && buf_idx < MAX_PATH; + ch != EOF && !isspace (ch) && buf_idx < CYG_MAX_PATH; buf_idx++, ch = getc (shell_fp)) buf[buf_idx] = ch; /* Skip any trailing non-whitespace character not fitting in buf. If the - path is longer than MAX_PATH, it's invalid anyway. */ + path is longer than CYG_MAX_PATH, it's invalid anyway. */ while (ch != EOF && !isspace (ch)) ch = getc (shell_fp); if (buf_idx) diff --git a/winsup/cygwin/thread.h b/winsup/cygwin/thread.h index 2cf9174..364ed39 100644 --- a/winsup/cygwin/thread.h +++ b/winsup/cygwin/thread.h @@ -78,8 +78,8 @@ struct _winsup_t DWORD available_drives; char mnt_type[80]; char mnt_opts[80]; - char mnt_fsname[MAX_PATH]; - char mnt_dir[MAX_PATH]; + char mnt_fsname[CYG_MAX_PATH]; + char mnt_dir[CYG_MAX_PATH]; /* strerror */ char _strerror_buf[20]; diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc index 6cd162b..b35e775 100644 --- a/winsup/cygwin/uinfo.cc +++ b/winsup/cygwin/uinfo.cc @@ -254,7 +254,7 @@ cygheap_user::ontherange (homebodies what, struct passwd *pw) LPUSER_INFO_3 ui = NULL; WCHAR wuser[UNLEN + 1]; NET_API_STATUS ret; - char homepath_env_buf[MAX_PATH + 1]; + char homepath_env_buf[CYG_MAX_PATH + 1]; char homedrive_env_buf[3]; char *newhomedrive = NULL; char *newhomepath = NULL; @@ -287,8 +287,8 @@ cygheap_user::ontherange (homebodies what, struct passwd *pw) setenv ("HOME", "/", 1); else { - char home[MAX_PATH]; - char buf[MAX_PATH + 1]; + char home[CYG_MAX_PATH]; + char buf[CYG_MAX_PATH + 1]; strcpy (buf, newhomedrive); strcat (buf, newhomepath); cygwin_conv_to_full_posix_path (buf, home); @@ -315,11 +315,11 @@ cygheap_user::ontherange (homebodies what, struct passwd *pw) sys_mbstowcs (wuser, winname (), sizeof (wuser) / sizeof (*wuser)); if (!(ret = NetUserGetInfo (wlogsrv, wuser, 3,(LPBYTE *)&ui))) { - sys_wcstombs (homepath_env_buf, ui->usri3_home_dir, MAX_PATH); + sys_wcstombs (homepath_env_buf, ui->usri3_home_dir, CYG_MAX_PATH); if (!homepath_env_buf[0]) { sys_wcstombs (homepath_env_buf, ui->usri3_home_dir_drive, - MAX_PATH); + CYG_MAX_PATH); if (homepath_env_buf[0]) strcat (homepath_env_buf, "\\"); else @@ -421,7 +421,7 @@ cygheap_user::env_userprofile (const char *name, size_t namelen) if (test_uid (puserprof, name, namelen)) return puserprof; - char userprofile_env_buf[MAX_PATH + 1]; + char userprofile_env_buf[CYG_MAX_PATH + 1]; cfree_and_set (puserprof, almost_null); /* FIXME: Should this just be setting a puserprofile like everything else? */ const char *myname = winname (); diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h index adaa6a3..9d65398 100644 --- a/winsup/cygwin/winsup.h +++ b/winsup/cygwin/winsup.h @@ -55,6 +55,23 @@ extern unsigned long cygwin_inet_addr (const char *cp); } #endif +/* Note that MAX_PATH is defined in the windows headers */ +/* There is also PATH_MAX and MAXPATHLEN. + PATH_MAX is from Posix and does *not* include the trailing NUL. + MAXPATHLEN is from Unix. + + Thou shalt use CYG_MAX_PATH throughout. It avoids the NUL vs no-NUL + issue and is neither of the Unixy ones [so we can punt on which + one is the right one to use]. + + Windows ANSI calls are limited to MAX_PATH in length. Cygwin calls that + thunk through to Windows Wide calls are limited to 32K. We define + CYG_MAX_PATH as a convenient, not to short, not too long 'happy medium'. + + */ + +#define CYG_MAX_PATH (MAX_PATH) + #ifdef __cplusplus extern const char case_folded_lower[]; @@ -306,14 +323,6 @@ extern SYSTEM_INFO system_info; #define WM_ASYNCIO 0x8000 // WM_APP -/* Note that MAX_PATH is defined in the windows headers */ -/* There is also PATH_MAX and MAXPATHLEN. - PATH_MAX is from Posix and does *not* include the trailing NUL. - MAXPATHLEN is from Unix. - - Thou shalt use MAX_PATH throughout. It avoids the NUL vs no-NUL - issue and is neither of the Unixy ones [so we can punt on which - one is the right one to use]. */ #define STD_RBITS (S_IRUSR | S_IRGRP | S_IROTH) #define STD_WBITS (S_IWUSR) |