svn commit: r281829 - in head/sys: compat/linux kern sys
Edward Tomasz Napierala
trasz at FreeBSD.org
Tue Apr 21 13:55:26 UTC 2015
Author: trasz
Date: Tue Apr 21 13:55:24 2015
New Revision: 281829
URL: https://svnweb.freebsd.org/changeset/base/281829
Log:
Modify kern___getcwd() to take max pathlen limit as an additional
argument. This will be used for the Linux emulation layer - for Linux,
PATH_MAX is 4096 and not 1024.
Differential Revision: https://reviews.freebsd.org/D2335
Reviewed by: kib@
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Modified:
head/sys/compat/linux/linux_getcwd.c
head/sys/compat/linux/linux_misc.h
head/sys/kern/vfs_cache.c
head/sys/sys/syscallsubr.h
Modified: head/sys/compat/linux/linux_getcwd.c
==============================================================================
--- head/sys/compat/linux/linux_getcwd.c Tue Apr 21 11:50:31 2015 (r281828)
+++ head/sys/compat/linux/linux_getcwd.c Tue Apr 21 13:55:24 2015 (r281829)
@@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$");
#include <machine/../linux/linux.h>
#include <machine/../linux/linux_proto.h>
#endif
+#include <compat/linux/linux_misc.h>
#include <compat/linux/linux_util.h>
#include <security/mac/mac_framework.h>
@@ -423,14 +424,14 @@ linux_getcwd(struct thread *td, struct l
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) {
Modified: head/sys/compat/linux/linux_misc.h
==============================================================================
--- head/sys/compat/linux/linux_misc.h Tue Apr 21 11:50:31 2015 (r281828)
+++ head/sys/compat/linux/linux_misc.h Tue Apr 21 13:55:24 2015 (r281829)
@@ -55,6 +55,8 @@
#define LINUX_MREMAP_MAYMOVE 1
#define LINUX_MREMAP_FIXED 2
+#define LINUX_PATH_MAX 4096
+
extern const char *linux_platform;
/*
Modified: head/sys/kern/vfs_cache.c
==============================================================================
--- head/sys/kern/vfs_cache.c Tue Apr 21 11:50:31 2015 (r281828)
+++ head/sys/kern/vfs_cache.c Tue Apr 21 13:55:24 2015 (r281829)
@@ -1053,11 +1053,13 @@ sys___getcwd(td, uap)
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 @@ kern___getcwd(struct thread *td, char *b
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;
Modified: head/sys/sys/syscallsubr.h
==============================================================================
--- head/sys/sys/syscallsubr.h Tue Apr 21 11:50:31 2015 (r281828)
+++ head/sys/sys/syscallsubr.h Tue Apr 21 13:55:24 2015 (r281829)
@@ -58,7 +58,7 @@ struct thr_param;
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,
More information about the svn-src-all
mailing list