Index: head/sys/compat/linux/linux_getcwd.c =================================================================== --- head/sys/compat/linux/linux_getcwd.c +++ head/sys/compat/linux/linux_getcwd.c @@ -57,6 +57,7 @@ #include #include #endif +#include #include #include @@ -423,14 +424,14 @@ len = args->bufsize; - if (len > MAXPATHLEN*4) - len = MAXPATHLEN*4; + if (len > LINUX_PATH_MAX) + len = LINUX_PATH_MAX; else if (len < 2) return ERANGE; path = malloc(len, M_TEMP, M_WAITOK); - error = kern___getcwd(td, path, UIO_SYSSPACE, len); + error = kern___getcwd(td, path, UIO_SYSSPACE, len, LINUX_PATH_MAX); if (!error) { lenused = strlen(path) + 1; if (lenused <= args->bufsize) { Index: head/sys/compat/linux/linux_misc.h =================================================================== --- head/sys/compat/linux/linux_misc.h +++ head/sys/compat/linux/linux_misc.h @@ -55,6 +55,8 @@ #define LINUX_MREMAP_MAYMOVE 1 #define LINUX_MREMAP_FIXED 2 +#define LINUX_PATH_MAX 4096 + extern const char *linux_platform; /* Index: head/sys/kern/vfs_cache.c =================================================================== --- head/sys/kern/vfs_cache.c +++ head/sys/kern/vfs_cache.c @@ -1053,11 +1053,13 @@ struct __getcwd_args *uap; { - return (kern___getcwd(td, uap->buf, UIO_USERSPACE, uap->buflen)); + return (kern___getcwd(td, uap->buf, UIO_USERSPACE, uap->buflen, + MAXPATHLEN)); } int -kern___getcwd(struct thread *td, char *buf, enum uio_seg bufseg, u_int buflen) +kern___getcwd(struct thread *td, char *buf, enum uio_seg bufseg, u_int buflen, + u_int path_max) { char *bp, *tmpbuf; struct filedesc *fdp; @@ -1068,8 +1070,8 @@ return (ENODEV); if (buflen < 2) return (EINVAL); - if (buflen > MAXPATHLEN) - buflen = MAXPATHLEN; + if (buflen > path_max) + buflen = path_max; tmpbuf = malloc(buflen, M_TEMP, M_WAITOK); fdp = td->td_proc->p_fd; Index: head/sys/sys/syscallsubr.h =================================================================== --- head/sys/sys/syscallsubr.h +++ head/sys/sys/syscallsubr.h @@ -58,7 +58,7 @@ struct __wrusage; int kern___getcwd(struct thread *td, char *buf, enum uio_seg bufseg, - u_int buflen); + u_int buflen, u_int path_max); int kern_accept(struct thread *td, int s, struct sockaddr **name, socklen_t *namelen, struct file **fp); int kern_accept4(struct thread *td, int s, struct sockaddr **name,