aboutsummaryrefslogtreecommitdiff
path: root/sys/compat
diff options
context:
space:
mode:
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/ia32/ia32_sysvec.c24
-rw-r--r--sys/compat/linprocfs/linprocfs.c77
-rw-r--r--sys/compat/linux/linux.c26
-rw-r--r--sys/compat/linux/linux_common.h2
-rw-r--r--sys/compat/linux/linux_event.c2
-rw-r--r--sys/compat/linux/linux_futex.c2
-rw-r--r--sys/compat/linux/linux_socket.c32
-rw-r--r--sys/compat/linuxkpi/common/src/linux_compat.c2
8 files changed, 134 insertions, 33 deletions
diff --git a/sys/compat/ia32/ia32_sysvec.c b/sys/compat/ia32/ia32_sysvec.c
index 0ea7d072e911..b9dada4eee7b 100644
--- a/sys/compat/ia32/ia32_sysvec.c
+++ b/sys/compat/ia32/ia32_sysvec.c
@@ -145,7 +145,7 @@ struct sysentvec ia32_freebsd_sysvec = {
};
INIT_SYSENTVEC(elf_ia32_sysvec, &ia32_freebsd_sysvec);
-static Elf32_Brandinfo ia32_brand_info = {
+static const Elf32_Brandinfo ia32_brand_info = {
.brand = ELFOSABI_FREEBSD,
.machine = EM_386,
.compat_3_brand = "FreeBSD",
@@ -155,12 +155,10 @@ static Elf32_Brandinfo ia32_brand_info = {
.brand_note = &elf32_freebsd_brandnote,
.flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
};
+C_SYSINIT(ia32, SI_SUB_EXEC, SI_ORDER_MIDDLE,
+ (sysinit_cfunc_t)elf32_insert_brand_entry, &ia32_brand_info);
-SYSINIT(ia32, SI_SUB_EXEC, SI_ORDER_MIDDLE,
- (sysinit_cfunc_t) elf32_insert_brand_entry,
- &ia32_brand_info);
-
-static Elf32_Brandinfo ia32_brand_oinfo = {
+static const Elf32_Brandinfo ia32_brand_oinfo = {
.brand = ELFOSABI_FREEBSD,
.machine = EM_386,
.compat_3_brand = "FreeBSD",
@@ -170,12 +168,10 @@ static Elf32_Brandinfo ia32_brand_oinfo = {
.brand_note = &elf32_freebsd_brandnote,
.flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
};
+C_SYSINIT(oia32, SI_SUB_EXEC, SI_ORDER_ANY,
+ (sysinit_cfunc_t)elf32_insert_brand_entry, &ia32_brand_oinfo);
-SYSINIT(oia32, SI_SUB_EXEC, SI_ORDER_ANY,
- (sysinit_cfunc_t) elf32_insert_brand_entry,
- &ia32_brand_oinfo);
-
-static Elf32_Brandinfo kia32_brand_info = {
+static const Elf32_Brandinfo kia32_brand_info = {
.brand = ELFOSABI_FREEBSD,
.machine = EM_386,
.compat_3_brand = "FreeBSD",
@@ -184,10 +180,8 @@ static Elf32_Brandinfo kia32_brand_info = {
.brand_note = &elf32_kfreebsd_brandnote,
.flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE_MANDATORY
};
-
-SYSINIT(kia32, SI_SUB_EXEC, SI_ORDER_ANY,
- (sysinit_cfunc_t) elf32_insert_brand_entry,
- &kia32_brand_info);
+C_SYSINIT(kia32, SI_SUB_EXEC, SI_ORDER_ANY,
+ (sysinit_cfunc_t)elf32_insert_brand_entry, &kia32_brand_info);
void
elf32_dump_thread(struct thread *td, void *dst, size_t *off)
diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c
index 95b212be1306..7ac48786c77b 100644
--- a/sys/compat/linprocfs/linprocfs.c
+++ b/sys/compat/linprocfs/linprocfs.c
@@ -2216,6 +2216,67 @@ linprocfs_dosysvipc_shm(PFS_FILL_ARGS)
return (0);
}
+static int
+linprocfs_doinotify(const char *sysctl, PFS_FILL_ARGS)
+{
+ size_t size;
+ int error, val;
+
+ if (uio->uio_rw == UIO_READ) {
+ size = sizeof(val);
+ error = kernel_sysctlbyname(curthread,
+ __DECONST(void *, sysctl), &val, &size, NULL, 0, 0, 0);
+ if (error == 0)
+ sbuf_printf(sb, "%d\n", val);
+ } else {
+ char *endp, *newval;
+ long vall;
+
+ sbuf_trim(sb);
+ sbuf_finish(sb);
+ newval = sbuf_data(sb);
+ vall = strtol(newval, &endp, 10);
+ if (vall < 0 || vall > INT_MAX || endp == newval ||
+ *endp != '\0')
+ return (EINVAL);
+ val = (int)vall;
+ error = kernel_sysctlbyname(curthread,
+ __DECONST(void *, sysctl), NULL, NULL,
+ &val, sizeof(val), 0, 0);
+ }
+ return (error);
+}
+
+/*
+ * Filler function for proc/sys/fs/inotify/max_queued_events
+ */
+static int
+linprocfs_doinotify_max_queued_events(PFS_FILL_ARGS)
+{
+ return (linprocfs_doinotify("vfs.inotify.max_queued_events",
+ PFS_FILL_ARGNAMES));
+}
+
+/*
+ * Filler function for proc/sys/fs/inotify/max_user_instances
+ */
+static int
+linprocfs_doinotify_max_user_instances(PFS_FILL_ARGS)
+{
+ return (linprocfs_doinotify("vfs.inotify.max_user_instances",
+ PFS_FILL_ARGNAMES));
+}
+
+/*
+ * Filler function for proc/sys/fs/inotify/max_user_watches
+ */
+static int
+linprocfs_doinotify_max_user_watches(PFS_FILL_ARGS)
+{
+ return (linprocfs_doinotify("vfs.inotify.max_user_watches",
+ PFS_FILL_ARGNAMES));
+}
+
/*
* Filler function for proc/sys/fs/mqueue/msg_default
*/
@@ -2313,9 +2374,7 @@ linprocfs_domqueue_queues_max(PFS_FILL_ARGS)
static int
linprocfs_init(PFS_INIT_ARGS)
{
- struct pfs_node *root;
- struct pfs_node *dir;
- struct pfs_node *sys;
+ struct pfs_node *dir, *fs, *root, *sys;
root = pi->pi_root;
@@ -2466,10 +2525,18 @@ linprocfs_init(PFS_INIT_ARGS)
NULL, PFS_RD);
/* /proc/sys/fs/... */
- pfs_create_dir(sys, &dir, "fs", NULL, NULL, NULL, 0);
+ pfs_create_dir(sys, &fs, "fs", NULL, NULL, NULL, 0);
+
+ pfs_create_dir(fs, &dir, "inotify", NULL, NULL, NULL, 0);
+ pfs_create_file(dir, NULL, "max_queued_events",
+ &linprocfs_doinotify_max_queued_events, NULL, NULL, NULL, PFS_RDWR);
+ pfs_create_file(dir, NULL, "max_user_instances",
+ &linprocfs_doinotify_max_user_instances, NULL, NULL, NULL, PFS_RDWR);
+ pfs_create_file(dir, NULL, "max_user_watches",
+ &linprocfs_doinotify_max_user_watches, NULL, NULL, NULL, PFS_RDWR);
/* /proc/sys/fs/mqueue/... */
- pfs_create_dir(dir, &dir, "mqueue", NULL, NULL, NULL, 0);
+ pfs_create_dir(fs, &dir, "mqueue", NULL, NULL, NULL, 0);
pfs_create_file(dir, NULL, "msg_default",
&linprocfs_domqueue_msg_default, NULL, NULL, NULL, PFS_RD);
pfs_create_file(dir, NULL, "msgsize_default",
diff --git a/sys/compat/linux/linux.c b/sys/compat/linux/linux.c
index 61b207070963..a40f110634f7 100644
--- a/sys/compat/linux/linux.c
+++ b/sys/compat/linux/linux.c
@@ -578,8 +578,13 @@ bsd_to_linux_sockaddr(const struct sockaddr *sa, struct l_sockaddr **lsa,
return (0);
}
+/*
+ * If sap is NULL, then osa points at already copied in linux sockaddr that
+ * should be edited in place. Otherwise memory is allocated, sockaddr
+ * copied in and returned in *sap.
+ */
int
-linux_to_bsd_sockaddr(const struct l_sockaddr *osa, struct sockaddr **sap,
+linux_to_bsd_sockaddr(struct l_sockaddr *osa, struct sockaddr **sap,
socklen_t *len)
{
struct sockaddr *sa;
@@ -609,10 +614,12 @@ linux_to_bsd_sockaddr(const struct l_sockaddr *osa, struct sockaddr **sap,
}
#endif
- kosa = malloc(salen, M_SONAME, M_WAITOK);
-
- if ((error = copyin(osa, kosa, *len)))
- goto out;
+ if (sap != NULL) {
+ kosa = malloc(salen, M_SONAME, M_WAITOK);
+ if ((error = copyin(osa, kosa, *len)))
+ goto out;
+ } else
+ kosa = osa;
bdom = linux_to_bsd_domain(kosa->sa_family);
if (bdom == AF_UNKNOWN) {
@@ -686,12 +693,15 @@ linux_to_bsd_sockaddr(const struct l_sockaddr *osa, struct sockaddr **sap,
sa->sa_family = bdom;
sa->sa_len = salen;
- *sap = sa;
- *len = salen;
+ if (sap != NULL) {
+ *sap = sa;
+ *len = salen;
+ }
return (0);
out:
- free(kosa, M_SONAME);
+ if (sap != NULL)
+ free(kosa, M_SONAME);
return (error);
}
diff --git a/sys/compat/linux/linux_common.h b/sys/compat/linux/linux_common.h
index 97f5a259f300..814c183b338a 100644
--- a/sys/compat/linux/linux_common.h
+++ b/sys/compat/linux/linux_common.h
@@ -43,7 +43,7 @@ sa_family_t bsd_to_linux_domain(sa_family_t domain);
#define AF_UNKNOWN UINT8_MAX
int bsd_to_linux_sockaddr(const struct sockaddr *sa,
struct l_sockaddr **lsa, socklen_t len);
-int linux_to_bsd_sockaddr(const struct l_sockaddr *lsa,
+int linux_to_bsd_sockaddr(struct l_sockaddr *lsa,
struct sockaddr **sap, socklen_t *len);
void linux_to_bsd_poll_events(struct thread *td, int fd,
short lev, short *bev);
diff --git a/sys/compat/linux/linux_event.c b/sys/compat/linux/linux_event.c
index e88791659f1f..fc3ef7c3e90a 100644
--- a/sys/compat/linux/linux_event.c
+++ b/sys/compat/linux/linux_event.c
@@ -104,7 +104,7 @@ static int
epoll_create_common(struct thread *td, int flags)
{
- return (kern_kqueue(td, flags, NULL));
+ return (kern_kqueue(td, flags, false, NULL));
}
#ifdef LINUX_LEGACY_SYSCALLS
diff --git a/sys/compat/linux/linux_futex.c b/sys/compat/linux/linux_futex.c
index 37d0142bae8b..0586eb55a8f3 100644
--- a/sys/compat/linux/linux_futex.c
+++ b/sys/compat/linux/linux_futex.c
@@ -251,7 +251,7 @@ linux_futex(struct thread *td, struct linux_futex_args *args)
* set LINUX_BI_FUTEX_REQUEUE bit of Brandinfo flags.
*/
p = td->td_proc;
- Elf_Brandinfo *bi = p->p_elf_brandinfo;
+ const Elf_Brandinfo *bi = p->p_elf_brandinfo;
if (bi == NULL || ((bi->flags & LINUX_BI_FUTEX_REQUEUE)) == 0)
return (EINVAL);
args->val3_compare = false;
diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c
index 0e07b0a60ced..b1a483ce611c 100644
--- a/sys/compat/linux/linux_socket.c
+++ b/sys/compat/linux/linux_socket.c
@@ -2146,7 +2146,8 @@ linux_setsockopt(struct thread *td, struct linux_setsockopt_args *args)
return (ENOPROTOOPT);
}
- if (name == IPV6_NEXTHOP) {
+ switch (name) {
+ case IPV6_NEXTHOP: {
len = args->optlen;
error = linux_to_bsd_sockaddr(PTRIN(args->optval), &sa, &len);
if (error != 0)
@@ -2155,7 +2156,34 @@ linux_setsockopt(struct thread *td, struct linux_setsockopt_args *args)
error = kern_setsockopt(td, args->s, level,
name, sa, UIO_SYSSPACE, len);
free(sa, M_SONAME);
- } else {
+ break;
+ }
+ case MCAST_JOIN_GROUP:
+ case MCAST_LEAVE_GROUP:
+ case MCAST_JOIN_SOURCE_GROUP:
+ case MCAST_LEAVE_SOURCE_GROUP: {
+ struct group_source_req req;
+ size_t size;
+
+ size = (name == MCAST_JOIN_SOURCE_GROUP ||
+ name == MCAST_LEAVE_SOURCE_GROUP) ?
+ sizeof(struct group_source_req) : sizeof(struct group_req);
+
+ if ((error = copyin(PTRIN(args->optval), &req, size)))
+ return (error);
+ len = sizeof(struct sockaddr_storage);
+ if ((error = linux_to_bsd_sockaddr(
+ (struct l_sockaddr *)&req.gsr_group, NULL, &len)))
+ return (error);
+ if (size == sizeof(struct group_source_req) &&
+ (error = linux_to_bsd_sockaddr(
+ (struct l_sockaddr *)&req.gsr_source, NULL, &len)))
+ return (error);
+ error = kern_setsockopt(td, args->s, level, name, &req,
+ UIO_SYSSPACE, size);
+ break;
+ }
+ default:
error = kern_setsockopt(td, args->s, level,
name, PTRIN(args->optval), UIO_USERSPACE, args->optlen);
}
diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c
index 458744a9fec6..ff0f477ea8cc 100644
--- a/sys/compat/linuxkpi/common/src/linux_compat.c
+++ b/sys/compat/linuxkpi/common/src/linux_compat.c
@@ -1171,12 +1171,14 @@ static const struct filterops linux_dev_kqfiltops_read = {
.f_isfd = 1,
.f_detach = linux_file_kqfilter_detach,
.f_event = linux_file_kqfilter_read_event,
+ .f_copy = knote_triv_copy,
};
static const struct filterops linux_dev_kqfiltops_write = {
.f_isfd = 1,
.f_detach = linux_file_kqfilter_detach,
.f_event = linux_file_kqfilter_write_event,
+ .f_copy = knote_triv_copy,
};
static void