aboutsummaryrefslogtreecommitdiff
path: root/sys/miscfs/procfs
diff options
context:
space:
mode:
Diffstat (limited to 'sys/miscfs/procfs')
-rw-r--r--sys/miscfs/procfs/procfs_dbregs.c17
-rw-r--r--sys/miscfs/procfs/procfs_fpregs.c16
-rw-r--r--sys/miscfs/procfs/procfs_regs.c14
-rw-r--r--sys/miscfs/procfs/procfs_rlimit.c16
-rw-r--r--sys/miscfs/procfs/procfs_status.c18
5 files changed, 9 insertions, 72 deletions
diff --git a/sys/miscfs/procfs/procfs_dbregs.c b/sys/miscfs/procfs/procfs_dbregs.c
index 9fe4968d37c6..971c09eb0af7 100644
--- a/sys/miscfs/procfs/procfs_dbregs.c
+++ b/sys/miscfs/procfs/procfs_dbregs.c
@@ -59,30 +59,17 @@ procfs_dodbregs(curp, p, pfs, uio)
{
int error;
struct dbreg r;
- char *kv;
- int kl;
/* Can't trace a process that's currently exec'ing. */
if ((p->p_flag & P_INEXEC) != 0)
return EAGAIN;
if (!CHECKIO(curp, p) || p_trespass(curp, p))
return (EPERM);
- kl = sizeof(r);
- kv = (char *) &r;
-
- kv += uio->uio_offset;
- kl -= uio->uio_offset;
- if (kl > uio->uio_resid)
- kl = uio->uio_resid;
PHOLD(p);
-
- if (kl < 0)
- error = EINVAL;
- else
- error = procfs_read_dbregs(p, &r);
+ error = procfs_read_dbregs(p, &r);
if (error == 0)
- error = uiomove(kv, kl, uio);
+ error = uiomove_frombuf(&r, sizeof(r), uio);
if (error == 0 && uio->uio_rw == UIO_WRITE) {
if (p->p_stat != SSTOP)
error = EBUSY;
diff --git a/sys/miscfs/procfs/procfs_fpregs.c b/sys/miscfs/procfs/procfs_fpregs.c
index 7074148cfbfc..c8afd55d96d9 100644
--- a/sys/miscfs/procfs/procfs_fpregs.c
+++ b/sys/miscfs/procfs/procfs_fpregs.c
@@ -56,30 +56,18 @@ procfs_dofpregs(curp, p, pfs, uio)
{
int error;
struct fpreg r;
- char *kv;
- int kl;
/* Can't trace a process that's currently exec'ing. */
if ((p->p_flag & P_INEXEC) != 0)
return EAGAIN;
if (!CHECKIO(curp, p) || p_trespass(curp, p))
return EPERM;
- kl = sizeof(r);
- kv = (char *) &r;
-
- kv += uio->uio_offset;
- kl -= uio->uio_offset;
- if (kl > uio->uio_resid)
- kl = uio->uio_resid;
PHOLD(p);
- if (kl < 0)
- error = EINVAL;
- else
- error = procfs_read_fpregs(p, &r);
+ error = procfs_read_fpregs(p, &r);
if (error == 0)
- error = uiomove(kv, kl, uio);
+ error = uiomove_frombuf(&r, sizeof(r), uio);
if (error == 0 && uio->uio_rw == UIO_WRITE) {
if (p->p_stat != SSTOP)
error = EBUSY;
diff --git a/sys/miscfs/procfs/procfs_regs.c b/sys/miscfs/procfs/procfs_regs.c
index ccde00af6da5..8604d0a4a9a7 100644
--- a/sys/miscfs/procfs/procfs_regs.c
+++ b/sys/miscfs/procfs/procfs_regs.c
@@ -65,22 +65,12 @@ procfs_doregs(curp, p, pfs, uio)
return EAGAIN;
if (!CHECKIO(curp, p) || p_trespass(curp, p))
return EPERM;
- kl = sizeof(r);
- kv = (char *) &r;
-
- kv += uio->uio_offset;
- kl -= uio->uio_offset;
- if (kl > uio->uio_resid)
- kl = uio->uio_resid;
PHOLD(p);
- if (kl < 0)
- error = EINVAL;
- else
- error = procfs_read_regs(p, &r);
+ error = procfs_read_regs(p, &r);
if (error == 0)
- error = uiomove(kv, kl, uio);
+ error = uiomove(&r, sizeof(r), uio);
if (error == 0 && uio->uio_rw == UIO_WRITE) {
if (p->p_stat != SSTOP)
error = EBUSY;
diff --git a/sys/miscfs/procfs/procfs_rlimit.c b/sys/miscfs/procfs/procfs_rlimit.c
index 361f6f6e9d7d..552e901c9798 100644
--- a/sys/miscfs/procfs/procfs_rlimit.c
+++ b/sys/miscfs/procfs/procfs_rlimit.c
@@ -64,7 +64,6 @@ procfs_dorlimit(curp, p, pfs, uio)
{
char *ps;
int i;
- int xlen;
int error;
char psbuf[512]; /* XXX - conservative */
@@ -109,20 +108,7 @@ procfs_dorlimit(curp, p, pfs, uio)
}
}
- /*
- * This logic is rather tasty - but its from procfs_status.c, so
- * I guess I'll use it here.
- */
-
- xlen = ps - psbuf;
- xlen -= uio->uio_offset;
- ps = psbuf + uio->uio_offset;
- xlen = imin(xlen, uio->uio_resid);
- if (xlen <= 0)
- error = 0;
- else
- error = uiomove(ps, xlen, uio);
-
+ error = uiomove_frombuf(psbuf, ps - psbuf, uio);
return (error);
}
diff --git a/sys/miscfs/procfs/procfs_status.c b/sys/miscfs/procfs/procfs_status.c
index b8cc6dbe9f91..370f23a6efb2 100644
--- a/sys/miscfs/procfs/procfs_status.c
+++ b/sys/miscfs/procfs/procfs_status.c
@@ -166,15 +166,7 @@ procfs_dostatus(curp, p, pfs, uio)
ps += snprintf(ps, psbuf + sizeof(psbuf) - ps, "\n");
DOCHECK();
- xlen = ps - psbuf;
- xlen -= uio->uio_offset;
- ps = psbuf + uio->uio_offset;
- xlen = imin(xlen, uio->uio_resid);
- if (xlen <= 0)
- error = 0;
- else
- error = uiomove(ps, xlen, uio);
-
+ error = uiomove_frombuf(psbuf, ps - psbuf, uio);
return (error);
bailout:
@@ -246,13 +238,7 @@ procfs_docmdline(curp, p, pfs, uio)
buflen = ps - buf;
}
- buflen -= uio->uio_offset;
- ps = bp + uio->uio_offset;
- xlen = min(buflen, uio->uio_resid);
- if (xlen <= 0)
- error = 0;
- else
- error = uiomove(ps, xlen, uio);
+ error = uiomove_frombuf(bp, buflen, uio);
if (buf)
FREE(buf, M_TEMP);
return (error);