sync with OpenBSD -current
This commit is contained in:
parent
665ee5434a
commit
5c45f68af5
20 changed files with 207 additions and 131 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: drm_linux.c,v 1.115 2024/07/13 15:38:21 kettenis Exp $ */
|
||||
/* $OpenBSD: drm_linux.c,v 1.119 2024/09/30 12:21:17 jsg Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2013 Jonathan Gray <jsg@openbsd.org>
|
||||
* Copyright (c) 2015, 2016 Mark Kettenis <kettenis@openbsd.org>
|
||||
|
@ -982,18 +982,12 @@ SPLAY_GENERATE(xarray_tree, xarray_entry, entry, xarray_cmp);
|
|||
void
|
||||
xa_init_flags(struct xarray *xa, gfp_t flags)
|
||||
{
|
||||
static int initialized;
|
||||
|
||||
if (!initialized) {
|
||||
pool_init(&xa_pool, sizeof(struct xarray_entry), 0, IPL_NONE, 0,
|
||||
"xapl", NULL);
|
||||
initialized = 1;
|
||||
}
|
||||
SPLAY_INIT(&xa->xa_tree);
|
||||
if (flags & XA_FLAGS_LOCK_IRQ)
|
||||
mtx_init(&xa->xa_lock, IPL_TTY);
|
||||
else
|
||||
mtx_init(&xa->xa_lock, IPL_NONE);
|
||||
xa->xa_flags = flags;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1009,11 +1003,15 @@ xa_destroy(struct xarray *xa)
|
|||
|
||||
/* Don't wrap ids. */
|
||||
int
|
||||
__xa_alloc(struct xarray *xa, u32 *id, void *entry, int limit, gfp_t gfp)
|
||||
__xa_alloc(struct xarray *xa, u32 *id, void *entry, struct xarray_range xr,
|
||||
gfp_t gfp)
|
||||
{
|
||||
struct xarray_entry *xid;
|
||||
int start = (xa->xa_flags & XA_FLAGS_ALLOC1) ? 1 : 0;
|
||||
int begin;
|
||||
uint32_t start = xr.start;
|
||||
uint32_t end = xr.end;
|
||||
|
||||
if (start == 0 && (xa->xa_flags & XA_FLAGS_ALLOC1))
|
||||
start = 1;
|
||||
|
||||
if (gfp & GFP_NOWAIT) {
|
||||
xid = pool_get(&xa_pool, PR_NOWAIT);
|
||||
|
@ -1026,17 +1024,14 @@ __xa_alloc(struct xarray *xa, u32 *id, void *entry, int limit, gfp_t gfp)
|
|||
if (xid == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
if (limit <= 0)
|
||||
limit = INT_MAX;
|
||||
|
||||
xid->id = begin = start;
|
||||
xid->id = start;
|
||||
|
||||
while (SPLAY_INSERT(xarray_tree, &xa->xa_tree, xid)) {
|
||||
if (xid->id == limit)
|
||||
if (xid->id == end)
|
||||
xid->id = start;
|
||||
else
|
||||
xid->id++;
|
||||
if (xid->id == begin) {
|
||||
if (xid->id == start) {
|
||||
pool_put(&xa_pool, xid);
|
||||
return -EBUSY;
|
||||
}
|
||||
|
@ -1052,10 +1047,10 @@ __xa_alloc(struct xarray *xa, u32 *id, void *entry, int limit, gfp_t gfp)
|
|||
* The only caller of this (i915_drm_client.c) doesn't use next id.
|
||||
*/
|
||||
int
|
||||
__xa_alloc_cyclic(struct xarray *xa, u32 *id, void *entry, int limit, u32 *next,
|
||||
gfp_t gfp)
|
||||
__xa_alloc_cyclic(struct xarray *xa, u32 *id, void *entry,
|
||||
struct xarray_range xr, u32 *next, gfp_t gfp)
|
||||
{
|
||||
int r = __xa_alloc(xa, id, entry, limit, gfp);
|
||||
int r = __xa_alloc(xa, id, entry, xr, gfp);
|
||||
*next = *id + 1;
|
||||
return r;
|
||||
}
|
||||
|
@ -2853,6 +2848,8 @@ drm_linux_init(void)
|
|||
|
||||
pool_init(&idr_pool, sizeof(struct idr_entry), 0, IPL_TTY, 0,
|
||||
"idrpl", NULL);
|
||||
pool_init(&xa_pool, sizeof(struct xarray_entry), 0, IPL_NONE, 0,
|
||||
"xapl", NULL);
|
||||
|
||||
kmap_atomic_va =
|
||||
(vaddr_t)km_alloc(PAGE_SIZE, &kv_any, &kp_none, &kd_waitok);
|
||||
|
@ -2868,6 +2865,7 @@ drm_linux_init(void)
|
|||
void
|
||||
drm_linux_exit(void)
|
||||
{
|
||||
pool_destroy(&xa_pool);
|
||||
pool_destroy(&idr_pool);
|
||||
|
||||
taskq_destroy(taskletq);
|
||||
|
@ -2946,20 +2944,25 @@ unregister_shrinker(struct shrinker *shrinker)
|
|||
TAILQ_REMOVE(&shrinkers, shrinker, next);
|
||||
}
|
||||
|
||||
void
|
||||
unsigned long
|
||||
drmbackoff(long npages)
|
||||
{
|
||||
struct shrink_control sc;
|
||||
struct shrinker *shrinker;
|
||||
u_long ret;
|
||||
u_long ret, freed = 0;
|
||||
|
||||
shrinker = TAILQ_FIRST(&shrinkers);
|
||||
while (shrinker && npages > 0) {
|
||||
sc.nr_to_scan = npages;
|
||||
ret = shrinker->scan_objects(shrinker, &sc);
|
||||
if (ret == SHRINK_STOP)
|
||||
break;
|
||||
npages -= ret;
|
||||
freed += ret;
|
||||
shrinker = TAILQ_NEXT(shrinker, next);
|
||||
}
|
||||
|
||||
return freed;
|
||||
}
|
||||
|
||||
void *
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
#include <sys/tree.h>
|
||||
|
||||
#define XA_FLAGS_ALLOC 1
|
||||
#define XA_FLAGS_ALLOC1 2
|
||||
#define XA_FLAGS_LOCK_IRQ 4
|
||||
#define XA_FLAGS_ALLOC (1 << 0)
|
||||
#define XA_FLAGS_ALLOC1 (1 << 1)
|
||||
#define XA_FLAGS_LOCK_IRQ (1 << 2)
|
||||
|
||||
/*
|
||||
* lower bits of pointer are tagged:
|
||||
|
@ -29,10 +29,19 @@ struct xarray {
|
|||
SPLAY_HEAD(xarray_tree, xarray_entry) xa_tree;
|
||||
};
|
||||
|
||||
struct xarray_range {
|
||||
uint32_t start;
|
||||
uint32_t end;
|
||||
};
|
||||
|
||||
#define XA_LIMIT(_start, _end) (struct xarray_range){ _start, _end }
|
||||
#define xa_limit_32b XA_LIMIT(0, UINT_MAX)
|
||||
|
||||
void xa_init_flags(struct xarray *, gfp_t);
|
||||
void xa_destroy(struct xarray *);
|
||||
int __xa_alloc(struct xarray *, u32 *, void *, int, gfp_t);
|
||||
int __xa_alloc_cyclic(struct xarray *, u32 *, void *, int, u32 *, gfp_t);
|
||||
int __xa_alloc(struct xarray *, u32 *, void *, struct xarray_range, gfp_t);
|
||||
int __xa_alloc_cyclic(struct xarray *, u32 *, void *, struct xarray_range,
|
||||
u32 *, gfp_t);
|
||||
void *__xa_load(struct xarray *, unsigned long);
|
||||
void *__xa_store(struct xarray *, unsigned long, void *, gfp_t);
|
||||
void *__xa_erase(struct xarray *, unsigned long);
|
||||
|
@ -41,8 +50,6 @@ void *xa_get_next(struct xarray *, unsigned long *);
|
|||
#define xa_for_each(xa, index, entry) \
|
||||
for (index = 0; ((entry) = xa_get_next(xa, &(index))) != NULL; index++)
|
||||
|
||||
#define xa_limit_32b 0
|
||||
|
||||
#define xa_lock(_xa) do { \
|
||||
mtx_enter(&(_xa)->xa_lock); \
|
||||
} while (0)
|
||||
|
@ -112,11 +119,12 @@ xa_is_err(const void *e)
|
|||
}
|
||||
|
||||
static inline int
|
||||
xa_alloc(struct xarray *xa, u32 *id, void *entry, int limit, gfp_t gfp)
|
||||
xa_alloc(struct xarray *xa, u32 *id, void *entry, struct xarray_range xr,
|
||||
gfp_t gfp)
|
||||
{
|
||||
int r;
|
||||
mtx_enter(&xa->xa_lock);
|
||||
r = __xa_alloc(xa, id, entry, limit, gfp);
|
||||
r = __xa_alloc(xa, id, entry, xr, gfp);
|
||||
mtx_leave(&xa->xa_lock);
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: wsconsio.h,v 1.101 2024/01/19 17:51:15 kettenis Exp $ */
|
||||
/* $OpenBSD: wsconsio.h,v 1.102 2024/09/30 01:41:49 jsg Exp $ */
|
||||
/* $NetBSD: wsconsio.h,v 1.74 2005/04/28 07:15:44 martin Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -476,15 +476,6 @@ struct wsdisplay_fbinfo {
|
|||
};
|
||||
#define WSDISPLAYIO_GINFO _IOR('W', 65, struct wsdisplay_fbinfo)
|
||||
|
||||
/* Backwards compat; remove after OpenBSD 7.3 is released. */
|
||||
struct wsdisplay_ofbinfo {
|
||||
u_int height; /* height in pixels */
|
||||
u_int width; /* width in pixels */
|
||||
u_int depth; /* bits per pixel */
|
||||
u_int cmsize; /* color map size (entries) */
|
||||
};
|
||||
#define WSDISPLAYIO_OGINFO _IOR('W', 65, struct wsdisplay_ofbinfo)
|
||||
|
||||
/* Colormap operations. Not applicable to all display types. */
|
||||
struct wsdisplay_cmap {
|
||||
u_int index; /* first element (0 origin) */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: wsdisplay.c,v 1.152 2023/01/10 16:33:18 tobhe Exp $ */
|
||||
/* $OpenBSD: wsdisplay.c,v 1.153 2024/09/30 01:41:49 jsg Exp $ */
|
||||
/* $NetBSD: wsdisplay.c,v 1.82 2005/02/27 00:27:52 perry Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -1315,25 +1315,6 @@ wsdisplay_driver_ioctl(struct wsdisplay_softc *sc, u_long cmd, caddr_t data,
|
|||
{
|
||||
int error;
|
||||
|
||||
#if defined(OpenBSD7_1) || defined(OpenBSD7_2) || defined(OpenBSD7_3)
|
||||
if (cmd == WSDISPLAYIO_OGINFO) {
|
||||
struct wsdisplay_ofbinfo *oinfo =
|
||||
(struct wsdisplay_ofbinfo *)data;
|
||||
struct wsdisplay_fbinfo info;
|
||||
|
||||
error = (*sc->sc_accessops->ioctl)(sc->sc_accesscookie,
|
||||
WSDISPLAYIO_GINFO, (caddr_t)&info, flag, p);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
oinfo->height = info.height;
|
||||
oinfo->width = info.width;
|
||||
oinfo->depth = info.depth;
|
||||
oinfo->cmsize = info.cmsize;
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
error = ((*sc->sc_accessops->ioctl)(sc->sc_accesscookie, cmd, data,
|
||||
flag, p));
|
||||
/* Do not report parameters with empty ranges to userland. */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: kern_exec.c,v 1.258 2024/08/21 03:07:45 deraadt Exp $ */
|
||||
/* $OpenBSD: kern_exec.c,v 1.259 2024/09/30 11:49:44 claudio Exp $ */
|
||||
/* $NetBSD: kern_exec.c,v 1.75 1996/02/09 18:59:28 christos Exp $ */
|
||||
|
||||
/*-
|
||||
|
@ -796,11 +796,7 @@ exec_abort:
|
|||
free_pack_abort:
|
||||
free(pack.ep_hdr, M_EXEC, pack.ep_hdrlen);
|
||||
exit1(p, 0, SIGABRT, EXIT_NORMAL);
|
||||
|
||||
/* NOTREACHED */
|
||||
atomic_clearbits_int(&pr->ps_flags, PS_INEXEC);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: kern_exit.c,v 1.233 2024/09/06 08:21:21 mpi Exp $ */
|
||||
/* $OpenBSD: kern_exit.c,v 1.234 2024/09/30 12:32:26 claudio Exp $ */
|
||||
/* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -746,7 +746,7 @@ proc_finish_wait(struct proc *waiter, struct process *pr)
|
|||
* If we got the child via a ptrace 'attach',
|
||||
* we need to give it back to the old parent.
|
||||
*/
|
||||
if (pr->ps_oppid != 0 && (pr->ps_oppid != pr->ps_pptr->ps_pid) &&
|
||||
if (pr->ps_oppid != 0 && (pr->ps_oppid != pr->ps_ppid) &&
|
||||
(tr = prfind(pr->ps_oppid))) {
|
||||
pr->ps_oppid = 0;
|
||||
atomic_clearbits_int(&pr->ps_flags, PS_TRACED);
|
||||
|
@ -774,7 +774,7 @@ process_untrace(struct process *pr)
|
|||
KASSERT(pr->ps_flags & PS_TRACED);
|
||||
|
||||
if (pr->ps_oppid != 0 &&
|
||||
(pr->ps_oppid != pr->ps_pptr->ps_pid))
|
||||
(pr->ps_oppid != pr->ps_ppid))
|
||||
ppr = prfind(pr->ps_oppid);
|
||||
|
||||
/* not being traced any more */
|
||||
|
@ -803,7 +803,7 @@ process_reparent(struct process *child, struct process *parent)
|
|||
return;
|
||||
|
||||
KASSERT(child->ps_oppid == 0 ||
|
||||
child->ps_oppid == child->ps_pptr->ps_pid);
|
||||
child->ps_oppid == child->ps_ppid);
|
||||
|
||||
LIST_REMOVE(child, ps_sibling);
|
||||
LIST_INSERT_HEAD(&parent->ps_children, child, ps_sibling);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: kern_sysctl.c,v 1.447 2024/09/24 12:37:11 bluhm Exp $ */
|
||||
/* $OpenBSD: kern_sysctl.c,v 1.448 2024/09/30 12:32:26 claudio Exp $ */
|
||||
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
|
||||
|
||||
/*-
|
||||
|
@ -1996,8 +1996,6 @@ fill_kproc(struct process *pr, struct kinfo_proc *ki, struct proc *p,
|
|||
show_pointers);
|
||||
|
||||
/* stuff that's too painful to generalize into the macros */
|
||||
if (pr->ps_pptr)
|
||||
ki->p_ppid = pr->ps_ppid;
|
||||
if (s->s_leader)
|
||||
ki->p_sid = s->s_leader->ps_pid;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: sys_process.c,v 1.98 2024/06/03 12:48:25 claudio Exp $ */
|
||||
/* $OpenBSD: sys_process.c,v 1.99 2024/09/30 12:32:26 claudio Exp $ */
|
||||
/* $NetBSD: sys_process.c,v 1.55 1996/05/15 06:17:47 tls Exp $ */
|
||||
|
||||
/*-
|
||||
|
@ -291,7 +291,7 @@ ptrace_ctrl(struct proc *p, int req, pid_t pid, caddr_t addr, int data)
|
|||
if (ISSET(tr->ps_flags, PS_TRACED))
|
||||
return EBUSY;
|
||||
atomic_setbits_int(&tr->ps_flags, PS_TRACED);
|
||||
tr->ps_oppid = tr->ps_pptr->ps_pid;
|
||||
tr->ps_oppid = tr->ps_ppid;
|
||||
if (tr->ps_ptstat == NULL)
|
||||
tr->ps_ptstat = malloc(sizeof(*tr->ps_ptstat),
|
||||
M_SUBPROC, M_WAITOK);
|
||||
|
@ -520,7 +520,7 @@ ptrace_ctrl(struct proc *p, int req, pid_t pid, caddr_t addr, int data)
|
|||
* Stop the target.
|
||||
*/
|
||||
atomic_setbits_int(&tr->ps_flags, PS_TRACED);
|
||||
tr->ps_oppid = tr->ps_pptr->ps_pid;
|
||||
tr->ps_oppid = tr->ps_ppid;
|
||||
process_reparent(tr, p->p_p);
|
||||
if (tr->ps_ptstat == NULL)
|
||||
tr->ps_ptstat = malloc(sizeof(*tr->ps_ptstat),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: tty_tty.c,v 1.32 2022/08/14 01:58:28 jsg Exp $ */
|
||||
/* $OpenBSD: tty_tty.c,v 1.33 2024/09/30 12:32:26 claudio Exp $ */
|
||||
/* $NetBSD: tty_tty.c,v 1.13 1996/03/30 22:24:46 christos Exp $ */
|
||||
|
||||
/*-
|
||||
|
@ -117,7 +117,7 @@ cttyioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
|
|||
return EINVAL;
|
||||
sess = p->p_p->ps_pgrp->pg_session;
|
||||
sess->s_verauthuid = p->p_ucred->cr_ruid;
|
||||
sess->s_verauthppid = p->p_p->ps_pptr->ps_pid;
|
||||
sess->s_verauthppid = p->p_p->ps_ppid;
|
||||
timeout_add_sec(&sess->s_verauthto, secs);
|
||||
return 0;
|
||||
case TIOCCLRVERAUTH:
|
||||
|
@ -135,7 +135,7 @@ cttyioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
|
|||
*/
|
||||
sess = p->p_p->ps_pgrp->pg_session;
|
||||
if (sess->s_verauthuid == p->p_ucred->cr_ruid &&
|
||||
sess->s_verauthppid == p->p_p->ps_pptr->ps_pid)
|
||||
sess->s_verauthppid == p->p_p->ps_ppid)
|
||||
return 0;
|
||||
return EPERM;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: sysctl.h,v 1.237 2024/08/02 14:34:45 mvs Exp $ */
|
||||
/* $OpenBSD: sysctl.h,v 1.238 2024/09/30 12:32:26 claudio Exp $ */
|
||||
/* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -568,7 +568,7 @@ struct kinfo_vmentry {
|
|||
* lim - source struct plimits
|
||||
* sa - source struct sigacts
|
||||
* There are some members that are not handled by these macros
|
||||
* because they're too painful to generalize: p_ppid, p_sid, p_tdev,
|
||||
* because they're too painful to generalize: p_sid, p_tdev,
|
||||
* p_tpgid, p_tsess, p_vm_rssize, p_u[us]time_{sec,usec}, p_cpuid
|
||||
*/
|
||||
|
||||
|
@ -645,6 +645,7 @@ do { \
|
|||
(kp)->p_sigmask = (p)->p_sigmask; \
|
||||
\
|
||||
PR_LOCK(pr); \
|
||||
(kp)->p_ppid = (pr)->ps_ppid; \
|
||||
(kp)->p_sigignore = (sa) ? (sa)->ps_sigignore : 0; \
|
||||
(kp)->p_sigcatch = (sa) ? (sa)->ps_sigcatch : 0; \
|
||||
\
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: uvm_pdaemon.c,v 1.114 2024/05/01 12:54:27 mpi Exp $ */
|
||||
/* $OpenBSD: uvm_pdaemon.c,v 1.115 2024/09/30 08:09:39 mpi Exp $ */
|
||||
/* $NetBSD: uvm_pdaemon.c,v 1.23 2000/08/20 10:24:14 bjh21 Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -84,7 +84,7 @@
|
|||
#include "drm.h"
|
||||
|
||||
#if NDRM > 0
|
||||
extern void drmbackoff(long);
|
||||
extern unsigned long drmbackoff(long);
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: colour.c,v 1.27 2024/08/26 13:02:15 nicm Exp $ */
|
||||
/* $OpenBSD: colour.c,v 1.28 2024/09/29 20:05:42 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||
|
@ -948,7 +948,7 @@ colour_byname(const char *name)
|
|||
|
||||
if (strncmp(name, "grey", 4) == 0 || strncmp(name, "gray", 4) == 0) {
|
||||
if (name[4] == '\0')
|
||||
return (-1);
|
||||
return (0xbebebe|COLOUR_FLAG_RGB);
|
||||
c = strtonum(name + 4, 0, 100, &errstr);
|
||||
if (errstr != NULL)
|
||||
return (-1);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: job.c,v 1.68 2024/05/15 09:59:12 nicm Exp $ */
|
||||
/* $OpenBSD: job.c,v 1.69 2024/09/30 07:54:51 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||
|
@ -71,9 +71,10 @@ static LIST_HEAD(joblist, job) all_jobs = LIST_HEAD_INITIALIZER(all_jobs);
|
|||
|
||||
/* Start a job running. */
|
||||
struct job *
|
||||
job_run(const char *cmd, int argc, char **argv, struct environ *e, struct session *s,
|
||||
const char *cwd, job_update_cb updatecb, job_complete_cb completecb,
|
||||
job_free_cb freecb, void *data, int flags, int sx, int sy)
|
||||
job_run(const char *cmd, int argc, char **argv, struct environ *e,
|
||||
struct session *s, const char *cwd, job_update_cb updatecb,
|
||||
job_complete_cb completecb, job_free_cb freecb, void *data, int flags,
|
||||
int sx, int sy)
|
||||
{
|
||||
struct job *job;
|
||||
struct environ *env;
|
||||
|
@ -83,6 +84,7 @@ job_run(const char *cmd, int argc, char **argv, struct environ *e, struct sessio
|
|||
sigset_t set, oldset;
|
||||
struct winsize ws;
|
||||
char **argvp, tty[TTY_NAME_MAX], *argv0;
|
||||
struct options *oo;
|
||||
|
||||
/*
|
||||
* Do not set TERM during .tmux.conf (second argument here), it is nice
|
||||
|
@ -93,12 +95,17 @@ job_run(const char *cmd, int argc, char **argv, struct environ *e, struct sessio
|
|||
if (e != NULL)
|
||||
environ_copy(e, env);
|
||||
|
||||
if (~flags & JOB_DEFAULTSHELL)
|
||||
shell = _PATH_BSHELL;
|
||||
else {
|
||||
if (s != NULL)
|
||||
shell = options_get_string(s->options, "default-shell");
|
||||
oo = s->options;
|
||||
else
|
||||
shell = options_get_string(global_s_options, "default-shell");
|
||||
oo = global_s_options;
|
||||
shell = options_get_string(oo, "default-shell");
|
||||
if (!checkshell(shell))
|
||||
shell = _PATH_BSHELL;
|
||||
}
|
||||
argv0 = shell_argv0(shell, 0);
|
||||
|
||||
sigfillset(&set);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: popup.c,v 1.54 2024/08/21 04:17:09 nicm Exp $ */
|
||||
/* $OpenBSD: popup.c,v 1.55 2024/09/30 07:54:51 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2020 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||
|
@ -718,7 +718,7 @@ popup_display(int flags, enum box_lines lines, struct cmdq_item *item, u_int px,
|
|||
|
||||
pd->job = job_run(shellcmd, argc, argv, env, s, cwd,
|
||||
popup_job_update_cb, popup_job_complete_cb, NULL, pd,
|
||||
JOB_NOWAIT|JOB_PTY|JOB_KEEPWRITE, jx, jy);
|
||||
JOB_NOWAIT|JOB_PTY|JOB_KEEPWRITE|JOB_DEFAULTSHELL, jx, jy);
|
||||
pd->ictx = input_init(NULL, job_get_event(pd->job), &pd->palette);
|
||||
|
||||
server_client_set_overlay(c, 0, popup_check_cb, popup_mode_cb,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: tmux.c,v 1.212 2024/05/15 09:59:12 nicm Exp $ */
|
||||
/* $OpenBSD: tmux.c,v 1.213 2024/09/29 20:05:42 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: tmux.h,v 1.1227 2024/09/16 20:28:22 nicm Exp $ */
|
||||
/* $OpenBSD: tmux.h,v 1.1229 2024/09/30 08:10:20 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||
|
@ -1474,6 +1474,7 @@ struct tty {
|
|||
#define TTY_HAVEXDA 0x200
|
||||
#define TTY_SYNCING 0x400
|
||||
#define TTY_HAVEDA2 0x800 /* Secondary DA. */
|
||||
#define TTY_WINSIZEQUERY 0x1000
|
||||
#define TTY_ALL_REQUEST_FLAGS \
|
||||
(TTY_HAVEDA|TTY_HAVEDA2|TTY_HAVEXDA)
|
||||
int flags;
|
||||
|
@ -2307,6 +2308,7 @@ typedef void (*job_free_cb) (void *);
|
|||
#define JOB_NOWAIT 0x1
|
||||
#define JOB_KEEPWRITE 0x2
|
||||
#define JOB_PTY 0x4
|
||||
#define JOB_DEFAULTSHELL 0x8
|
||||
struct job *job_run(const char *, int, char **, struct environ *,
|
||||
struct session *, const char *, job_update_cb,
|
||||
job_complete_cb, job_free_cb, void *, int, int, int);
|
||||
|
@ -2369,6 +2371,7 @@ void tty_cell(struct tty *, const struct grid_cell *,
|
|||
int tty_init(struct tty *, struct client *);
|
||||
void tty_resize(struct tty *);
|
||||
void tty_set_size(struct tty *, u_int, u_int, u_int, u_int);
|
||||
void tty_invalidate(struct tty *);
|
||||
void tty_start_tty(struct tty *);
|
||||
void tty_send_requests(struct tty *);
|
||||
void tty_repeat_requests(struct tty *);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: tty-keys.c,v 1.178 2024/08/26 07:45:05 nicm Exp $ */
|
||||
/* $OpenBSD: tty-keys.c,v 1.179 2024/09/30 08:10:20 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||
|
@ -654,6 +654,74 @@ tty_keys_next1(struct tty *tty, const char *buf, size_t len, key_code *key,
|
|||
return (-1);
|
||||
}
|
||||
|
||||
/* Process window size change escape sequences. */
|
||||
static int
|
||||
tty_keys_winsz(struct tty *tty, const char *buf, size_t len, size_t *size)
|
||||
{
|
||||
struct client *c = tty->client;
|
||||
size_t end;
|
||||
char tmp[64];
|
||||
u_int sx, sy, xpixel, ypixel, char_x, char_y;
|
||||
|
||||
*size = 0;
|
||||
|
||||
/* If we did not request this, ignore it. */
|
||||
if (!(tty->flags & TTY_WINSIZEQUERY))
|
||||
return (-1);
|
||||
|
||||
/* First two bytes are always \033[. */
|
||||
if (buf[0] != '\033')
|
||||
return (-1);
|
||||
if (len == 1)
|
||||
return (1);
|
||||
if (buf[1] != '[')
|
||||
return (-1);
|
||||
if (len == 2)
|
||||
return (1);
|
||||
|
||||
/*
|
||||
* Stop at either 't' or anything that isn't a
|
||||
* number or ';'.
|
||||
*/
|
||||
for (end = 2; end < len && end != sizeof tmp; end++) {
|
||||
if (buf[end] == 't')
|
||||
break;
|
||||
if (!isdigit((u_char)buf[end]) && buf[end] != ';')
|
||||
break;
|
||||
}
|
||||
if (end == len)
|
||||
return (1);
|
||||
if (end == sizeof tmp || buf[end] != 't')
|
||||
return (-1);
|
||||
|
||||
/* Copy to the buffer. */
|
||||
memcpy(tmp, buf + 2, end - 2);
|
||||
tmp[end - 2] = '\0';
|
||||
|
||||
/* Try to parse the window size sequence. */
|
||||
if (sscanf(tmp, "8;%u;%u", &sy, &sx) == 2) {
|
||||
/* Window size in characters. */
|
||||
tty_set_size(tty, sx, sy, tty->xpixel, tty->ypixel);
|
||||
|
||||
*size = end + 1;
|
||||
return (0);
|
||||
} else if (sscanf(tmp, "4;%u;%u", &ypixel, &xpixel) == 2) {
|
||||
/* Window size in pixels. */
|
||||
char_x = (xpixel && tty->sx) ? xpixel / tty->sx : 0;
|
||||
char_y = (ypixel && tty->sy) ? ypixel / tty->sy : 0;
|
||||
tty_set_size(tty, tty->sx, tty->sy, char_x, char_y);
|
||||
tty_invalidate(tty);
|
||||
|
||||
tty->flags &= ~TTY_WINSIZEQUERY;
|
||||
*size = end + 1;
|
||||
return (0);
|
||||
}
|
||||
|
||||
log_debug("%s: unrecognized window size sequence: %s", c->name, tmp);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
||||
/* Process at least one key in the buffer. Return 0 if no keys present. */
|
||||
int
|
||||
tty_keys_next(struct tty *tty)
|
||||
|
@ -754,6 +822,17 @@ tty_keys_next(struct tty *tty)
|
|||
goto partial_key;
|
||||
}
|
||||
|
||||
/* Check for window size query */
|
||||
switch (tty_keys_winsz(tty, buf, len, &size)) {
|
||||
case 0: /* yes */
|
||||
key = KEYC_UNKNOWN;
|
||||
goto complete_key;
|
||||
case -1: /* no, or not valid */
|
||||
break;
|
||||
case 1: /* partial */
|
||||
goto partial_key;
|
||||
}
|
||||
|
||||
first_key:
|
||||
/* Try to lookup complete key. */
|
||||
n = tty_keys_next1(tty, buf, len, &key, &size, expired);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: tty.c,v 1.438 2024/08/04 09:42:23 nicm Exp $ */
|
||||
/* $OpenBSD: tty.c,v 1.439 2024/09/30 08:10:20 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||
|
@ -42,7 +42,6 @@ static void tty_cursor_pane(struct tty *, const struct tty_ctx *, u_int,
|
|||
u_int);
|
||||
static void tty_cursor_pane_unless_wrap(struct tty *,
|
||||
const struct tty_ctx *, u_int, u_int);
|
||||
static void tty_invalidate(struct tty *);
|
||||
static void tty_colours(struct tty *, const struct grid_cell *);
|
||||
static void tty_check_fg(struct tty *, struct colour_palette *,
|
||||
struct grid_cell *);
|
||||
|
@ -135,6 +134,14 @@ tty_resize(struct tty *tty)
|
|||
ypixel = 0;
|
||||
} else
|
||||
ypixel = ws.ws_ypixel / sy;
|
||||
|
||||
if ((xpixel == 0 || ypixel == 0) &&
|
||||
tty->out != NULL &&
|
||||
!(tty->flags & TTY_WINSIZEQUERY) &&
|
||||
(tty->term->flags & TERM_VT100LIKE)) {
|
||||
tty_puts(tty, "\033[18t\033[14t");
|
||||
tty->flags |= TTY_WINSIZEQUERY;
|
||||
}
|
||||
} else {
|
||||
sx = 80;
|
||||
sy = 24;
|
||||
|
@ -2247,7 +2254,7 @@ tty_reset(struct tty *tty)
|
|||
memcpy(&tty->last_cell, &grid_default_cell, sizeof tty->last_cell);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
tty_invalidate(struct tty *tty)
|
||||
{
|
||||
memcpy(&tty->cell, &grid_default_cell, sizeof tty->cell);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: bgpd.c,v 1.267 2024/09/04 15:06:36 claudio Exp $ */
|
||||
/* $OpenBSD: bgpd.c,v 1.268 2024/09/30 09:42:24 claudio Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
|
||||
|
@ -1381,6 +1381,29 @@ bgpd_rtr_connect(struct rtr_config *r)
|
|||
return;
|
||||
}
|
||||
|
||||
switch (r->remote_addr.aid) {
|
||||
case AID_INET:
|
||||
if (setsockopt(ce->fd, IPPROTO_IP, IP_TOS, &pre, sizeof(pre)) ==
|
||||
-1) {
|
||||
log_warn("rtr %s: setsockopt IP_TOS", r->descr);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case AID_INET6:
|
||||
if (setsockopt(ce->fd, IPPROTO_IPV6, IPV6_TCLASS, &pre,
|
||||
sizeof(pre)) == -1) {
|
||||
log_warn("rtr %s: setsockopt IP_TOS", r->descr);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (setsockopt(ce->fd, IPPROTO_TCP, TCP_NODELAY, &nodelay,
|
||||
sizeof(nodelay)) == -1) {
|
||||
log_warn("rtr %s: setsockopt TCP_NODELAY", r->descr);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((sa = addr2sa(&r->local_addr, 0, &len)) != NULL) {
|
||||
if (bind(ce->fd, sa, len) == -1) {
|
||||
log_warn("rtr %s: bind to %s", r->descr,
|
||||
|
@ -1405,29 +1428,6 @@ bgpd_rtr_connect(struct rtr_config *r)
|
|||
return;
|
||||
}
|
||||
|
||||
switch (r->remote_addr.aid) {
|
||||
case AID_INET:
|
||||
if (setsockopt(ce->fd, IPPROTO_IP, IP_TOS, &pre, sizeof(pre)) ==
|
||||
-1) {
|
||||
log_warn("rtr %s: setsockopt IP_TOS", r->descr);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case AID_INET6:
|
||||
if (setsockopt(ce->fd, IPPROTO_IPV6, IPV6_TCLASS, &pre,
|
||||
sizeof(pre)) == -1) {
|
||||
log_warn("rtr %s: setsockopt IP_TOS", r->descr);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (setsockopt(ce->fd, IPPROTO_TCP, TCP_NODELAY, &nodelay,
|
||||
sizeof(nodelay)) == -1) {
|
||||
log_warn("rtr %s: setsockopt TCP_NODELAY", r->descr);
|
||||
return;
|
||||
}
|
||||
|
||||
imsg_compose(ibuf_rtr, IMSG_SOCKET_CONN, ce->id, 0, ce->fd, NULL, 0);
|
||||
free(ce);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: util.c,v 1.87 2024/07/03 08:39:43 job Exp $ */
|
||||
/* $OpenBSD: util.c,v 1.88 2024/09/30 12:54:12 claudio Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org>
|
||||
|
@ -161,14 +161,16 @@ const struct ext_comm_pairs iana_ext_comms[] = IANA_EXT_COMMUNITIES;
|
|||
const char *
|
||||
log_ext_subtype(int type, uint8_t subtype)
|
||||
{
|
||||
static char etype[6];
|
||||
static char etype[16];
|
||||
const struct ext_comm_pairs *cp;
|
||||
|
||||
for (cp = iana_ext_comms; cp->subname != NULL; cp++) {
|
||||
if ((type == cp->type || type == -1) && subtype == cp->subtype)
|
||||
return (cp->subname);
|
||||
}
|
||||
snprintf(etype, sizeof(etype), "[%u]", subtype);
|
||||
if (type == -1)
|
||||
return ("???");
|
||||
snprintf(etype, sizeof(etype), "[%hhx:%hhx]", (uint8_t)type, subtype);
|
||||
return (etype);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue