Commit Graph

115 Commits

Author SHA1 Message Date
Jim Warner
e616409aa4 build-sys: added a 'test_Itemtables' to testing scheme
This change sets the stage for exploiting the recently
added ITEMTABLE_DEBUG #define. All tests are performed
in a single module (after trying 6 separate programs).

The chances of each test detecting errors is extremely
remote (at least while I'm maintaining these modules).
However, this single program approach has one flaw and
it relates to the response whenever an error is found.

Each of those six new API modules calls Exit() if they
detect an error. Otherwise, incorrect results would be
produced at the least or an abend encountered at most.

This means that multiple 'make check' invocations will
be needed if more than 1 module actually was in error.

All in all, it is a small price for a large assurance.

Reference(s):
https://www.freelists.org/post/procps/keep-on-patchin,7

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-08-17 21:49:14 +10:00
Jim Warner
ebb57668a1 build-sys: tweak make & activate some overlooked tests
This commit is just preparing for adding an Itemtables
verification test by reorganizing stuff and activating
a few previously inactive (overlooked?) test programs.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-08-17 21:49:03 +10:00
Jim Warner
4b9c93406c build-sys: suppress '-Wunused-result' with AM_CPPFLAGS
Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-07-20 16:15:14 +10:00
Jim Warner
d974f064b5 build-sys: correct those installed development headers
These headers were used only in the library itself and
it's wrong to have them in the user include directory.

* devname.h .. is used only by: ... pids.c, readproc.c
* numa.h ..... is used only by: ....... pids.c, stat.c
* pwcache.h .. is used only by: ........... readproc.c
* readproc.h . is used only by: ..... escape.c, pids.c
* wchan.h .... is used only by: ............... pids.c

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-07-05 21:13:01 +10:00
Jim Warner
605ea4a8f7 library: make that 'escape_str' private to our library
In that commit referenced below, a promise was made to
revisit an 'escape_str' function in efforts to make it
private to the library. The problem was it's needed by
both ps plus the library which is why it was exported.

So, in an effort to remove it from libprocps.sym, this
patch duplicates all the required code in ps/output.c.
Now, each version can be made private to their caller.

[ along the way we'll use this opportunity to remove ]
[ the 'restrict' qualifiers from function parameters ]
[ while swatting a compiler warning referenced below ]

Reference(s):
. April 2016, most escape functions made private
commit d916d5db86

proc/escape.c: In function `escape_command':
proc/escape.c:182:23: warning: initialization of `const char **' from incompatible pointer type `char **' [-Wincompatible-pointer-types]
  182 |     const char **lc = (char**)pp->cmdline;
      |                       ^

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-07-05 21:13:01 +10:00
Jim Warner
1aa8b16441 library: eliminated the questionable 'procps.h' header
There was a time when that procps.h file served a more
traditional role. Prior to the commit referenced below
it held just macros plus manifest constants. But, with
that change, such items were replaced with a series of
includes embracing all the library exported functions.

That approach was known to disguise errors which would
have otherwise yielded a compiler warning. And without
such a warning, there was no way to address the error.

So this patch will trade the all inclusive header file
approach for individual includes only where necessary.

Reference(s):
. April 2016, procps.h header file revamped
commit ccb6ae8de1
. Sept 2018, top abandoned use of procps.h
commit a6dfc2382e

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-07-05 21:13:01 +10:00
Jim Warner
d64755ea5f build-sys: tweak Makefile.am for two preceding patches
This commit cleans up some man document files. It also
changes the target install directory from the original
'proc/' to 'procps/' (feels like a more natural name).

[ and, now it agrees with those 2 preceding man docs ]
[ since it is obvious the tail was wagging this dog! ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-06-23 19:09:05 +10:00
Craig Small
0aa0f92727 docs: Add namespace man pages 2020-05-18 21:42:49 +10:00
Jim Warner
c7b7ab8547 3.3.13 release candidate 1 ________________ (catch up)
--------------- Original Master Branch Commit Message:
Update NEWS with the version
Add library API change into NEWS
Update c:r:a for library to 7:0:1

This means the current and age are incremented, so old programs can
use new library but not vice-versa as they won't have the numa*
functions.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2018-05-06 07:19:38 +10:00
Jim Warner
c2a29d370c sysctl: relocate the procio code to a more proper home
Now that the procio logic was removed from the library
we must move the header file, lest we break make dist.

In the process, we will relocate that source file too.

[ we'll take a slightly different approach than that ]
[ used under the master branch by exploiting those 2 ]
[ non-library directories 'include' and 'lib', while ]
[ avoiding any sysctl hard coded function prototype. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2018-05-06 07:19:37 +10:00
Craig Small
e72f30549b sysctl: Bring procio functions out of library
The procio functions that were in the library have been
moved into sysctl. sysctl is not linked to libprocps in
newlib and none of the other procps binaries would need
to read/write large data to the procfs.

References:
 be6b048a41
2018-03-01 21:47:57 +11:00
Werner Fink
3373a58fb6 Add flexible buffered I/O based on fopencookie(3)
to be able to read and write large buffers below /proc.
The buffers and file offsets are handled dynamically
on the required buffer size at read, that is lseek(2)
is used to determine this size. Large buffers at
write are split at a delimeter into pieces and also
lseek(2) is used to write each of them.

Signed-off-by: Werner Fink <werner@suse.de>
2018-03-01 21:42:10 +11:00
Davide Madrisan
f9d8dfe01a Install some missing header files required by procps.h 2017-12-23 18:08:32 +11:00
Jim Warner
7453f8719b library: actually remove those alloc.h & alloc.c files
Signed-off-by: Jim Warner <james.warner@comcast.net>
2017-12-20 21:18:53 +11:00
Craig Small
d8fb86dbc5 Port of merge request 49 to newlib
Wayne Porter made !49 which added Cygwin support to the master branch
This is the port of those changes to newlib
2017-08-19 23:05:22 +10:00
Jim Warner
3d39e4fd88 library: set stage for NUMA node field display support
In response to that suggestion referenced below, these
changes allow display of task/thread level NUMA nodes.

Currently, only the 'top' program offers any NUMA type
support and it is limited to the Summary Area display.
With this commit both the 'top' and 'ps' programs will
be able to display NUMA nodes associated with threads.

Reference(s):
https://gitlab.com/procps-ng/procps/issues/58

Signed-off-by: Jim Warner <james.warner@comcast.net>
2017-05-22 21:38:10 +10:00
Craig Small
2598e9f2ce documentation: Update pids manual pages
Updated the full suite of manual pages for the procps_pids_*
functions. The only one missing is procps_pids_get which
may not be required.
2017-01-05 09:44:04 +11:00
Craig Small
a8f7e44233 docs: Remove old library man pages 2016-09-11 11:20:03 +10:00
Jim Warner
e3270d463d library: provide for validating result type references
During development, we now have a means for validating
that a type referenced in application code matches the
actual type set by the library. The new feature can be
activated through either of the following two methods:

1) ./configure CFLAGS='-DXTRA_PROCPS_DEBUG' (all pgms)

2) an #include <proc/xtra-procps-debug.h> (single pgm)

[ in the future, one could add a formal configure.ac ]
[ provision. but for now a manual approach is safer. ]

Lastly, for any module which provides a sort function,
the handling for both 'noop' & 'extra' enumerators was
made consistent. Now, 'noop' is not sorted and 'extra'
will be sorted as that module's widest supported type.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-08-07 21:40:48 +10:00
Jim Warner
8e5d5e44e9 library: rename 'diskstat' source as 'diskstats' files
Where possible, libprocps files convey the name of the
actual source pseudo file under the '/proc' directory.

This brings diskstats into line with such an approach.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-07-26 07:59:52 +10:00
Craig Small
f272924235 build-sys: cleanup of tests
Removed dependencies on test_nsutils as they are not used in
newlib.

Had two TESTS lines due to master merge, now only one.
2016-07-09 15:06:32 +10:00
Craig Small
0705dc8bd9 build-sys: Revert noinst and check programs
Previously there was a commit to change all noinst_PROGRAMS into
check_PROGRAMS. This was not a good idea.

check_PROGRAMS are built before TESTS are run. However they are
NOT build before the dejagnu tests are run, causing those tests
to fail.

So:
If the program is required for dejagnu, it needs to go into
noinst_PROGRAMS
If the program is required for TESTS or is one of those TESTS,
it needs to go into check_PROGRAMS
2016-07-09 15:02:45 +10:00
Craig Small
c1aa5725b2 build-sys: Make check programs before check
For some unknown reason, check_PROGRAMS are not built before check.
They are built before recheck and after check, which isn't very
useful.

This means any tests by dejagnu that need those programs will fail.
On my console I get a build error, the CI merrily reports the error
but considers the build OK; go figure.

The kludge adds check_PROGRAMS to be a dependency to check.
Note, TESTS don't need to be included in this, because they are
properly compliled after the dejagnu tests but before they are
run.
2016-07-09 15:00:19 +10:00
Jim Warner
5be4167782 library: rename the 'slab' sources as 'slabinfo' files
Where possible, libprocps files convey the name of the
actual source pseudo file under the '/proc' directory.

This patch brings slab into line with such a standard.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-06-09 20:51:06 +10:00
Jim Warner
3a48427d5d library: rename those readstat.c & h sources to 'stat'
In an attempt to normalize the 'stat' interface, we'll
first shed any reminders of the old readproc interface
by changing file names to be more descriptive & brief.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-04-26 22:27:16 +10:00
Craig Small
9c877bf636 build-sys: Enable optional hardening flags
With the configure option --enable-harden-flags the CFLAGS and
LDFLAGS are manipulated to provide some hardening protection
to the binaries.

psmisc uses these flags on by default with no troubles, however
it doesn't have a library in it either.

References:
  https://wiki.debian.org/Hardening
2016-04-25 17:07:22 +10:00
Craig Small
aa16ab0dc1 tests: update template and add pids
Generalised the library API tests and created a common
test-runner. Instead of copy and pasting the same code in
each time.

First cut of pids API test, for _new so far.
2016-04-19 21:33:02 +10:00
Craig Small
4217eddf47 docs: Start documenting the pids API
Started with procps_pids_new() and documenting this function
as well as the enum used in this function.
2016-04-18 22:57:01 +10:00
Craig Small
abc3679712 docs: Added new man pages to install 2016-04-17 08:03:35 +10:00
Craig Small
8e20fa7786 library: document and tests for uptime functions
man pages for the three procps_uptime* functions and simple
test scripts for same functions.
2016-04-16 22:02:10 +10:00
Craig Small
8639a97250 libprocps version test and documentation
test binary and man page for the version part of libprocps.
It's a simple start, but it's a start!
2016-04-14 22:28:38 +10:00
Wayne Porter
e50ad77997 Added Cygwin build support
strverscmp is included to satisfy a dependency in Cygwin.
Excluded utmp and prctl functions that are not supported currently.
2016-03-12 15:07:30 +11:00
Jim Warner
e21cc13c64 misc: eliminate accumulated trailing whitespace, again
Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-03-12 14:53:53 +11:00
Mike Frysinger
80bdaca31d set test programs to check_PROGRAMS
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2016-03-10 22:59:28 +11:00
Craig Small
03437d7dd3 A locale-independent strtod
There is a need in some utilities to have a way of accepting both
types of decimal points "." and ",". The only way seems to be to
rebuild strtod().

This new function will accept "123.456" and "123,456" as 123.456
and considers them the same number. It means we lose thousands
separator, but this is rarely used.

test scripts are added to check the function returns the proper
values. There was simpler predecessor that got stuck on negative
0 or -0.123 which these tests flushed out.

References:
2016-03-10 22:27:09 +11:00
Craig Small
471cf4cd36 Merge branch 'master' into newlib
Conflicts:
	pgrep.c
	proc/sysinfo.c
	ps/output.c
	skill.c
	top/top.c
	top/top.h
	w.c
2015-10-28 21:09:26 +11:00
Craig Small
d7791607ad watch: Correctly process [m Remove lib dependency
The commit referenced below made the ANSI sequence
[m be interpreted as [0m However this change was put
in the incorrect place and would reference an undefined
pointer, causing a crash. Thanks to Jimmy Theis for the
second heads-up.

watch doesn't need any libprocps functions so it is no
longer linked to them.

References:
 commit a5937e4e94
 https://www.freelists.org/post/procps/watch-crashes-but-its-not-the-latest-commit-fault
 https://www.freelists.org/post/procps/Segmentation-fault-in-watch-3311

Signed-off-by: Craig Small <csmall@enc.com.au>

Ported-by: Jim Warner <james.warner@comcast.net>
From original:
commit 99fa7f9f57
2015-10-14 21:34:54 +11:00
Craig Small
1b6e5ae11e build-sys: unlink kill from procps
kill doesn't use any symbols from libprocps so we don't need to
link to it.
2015-09-26 09:19:28 +10:00
Craig Small
f65121ef74 kill: split out from skill/snice
The first part of fixing skill/snice to use the library instead
of directly readdir()ing /proc which is what it does now.

Remove the kill code from the skill/snice code and put common
elements into lib/signals.c Not 100% sure that is the right
destination instead of a new lib file, but ok for now.

kill shares some parsing logic with skill/snice but mainly
around signal specifications. The "do it" code is very different.

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-09-26 09:13:13 +10:00
Craig Small
a61f78d6e0 library: rework namespace calls
Functions related to namespaces were half-in half-out of the
procps library and didn't fit the standard naming scheme.

While struct { long ns[x]} is a bit clunky, its the only way
to "lock in" x. The alternative is to use ns_* variables.

This work was needed before pgrep could be converted.
2015-09-03 22:32:19 +10:00
Craig Small
99fa7f9f57 watch: Correctly process [m Remove lib dependency
The commit referenced below made the ANSI sequence
[m be interpreted as [0m However this change was put
in the incorrect place and would reference an undefined
pointer, causing a crash. Thanks to Jimmy Theis for the
second heads-up.

watch doesn't need any libprocps functions so it is no
longer linked to them.

References:
 commit a5937e4e94
 https://www.freelists.org/post/procps/watch-crashes-but-its-not-the-latest-commit-fault
 https://www.freelists.org/post/procps/Segmentation-fault-in-watch-3311
2015-09-01 21:28:07 +10:00
Craig Small
0f44172a5e sysctl: Remove links to library
sysctl doesn't use any symbols from the libprocps library so
this  update removes those dependencies.
2015-09-01 20:57:56 +10:00
Jim Warner
7e6a371d8a library: implement task/thread support via the new api
This commit is the culmination of efforts to modernize
the library api. It should be treated as a first blush
attempt, especially since I have absolutely no library
design experience. But I did have a very strong desire
to lessen the new library's impact on the top program.

Under this new api, a 'stack' is the equivalent of the
old proc_t. It can be seen as a variable length record
whose contents & order is under complete user control.

That initial stack/record configuration is established
at procps_pids_new() time and will probably serve most
program needs. But, a dynamic & demanding program like
top will later change a stack via procps_pids_reset().

For programs like top & ps, procps_pids_reap() will be
the function that will retrieve all tasks and threads.

Any program that needs to filter / select only certain
processes or users have available other functions that
can be used: procps_pids_stacks_alloc, fill & dealloc.

This implementation attempts to maximize that existing
proven libprocps code base. As we gain more experience
such actual code can be migrated into the pids.c file.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-08-23 21:05:06 +10:00
Craig Small
57396ae39d build-sys: Update Library Version
procps v3.3.11 will bring Library API 5:0:0
The reason for the change is the removal of some calls and
the addition of others. The newlib branch should hopefully
reset some of these changes to a much slower pace.

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-08-09 17:45:19 +10:00
Craig Small
5686cc5cb5 build-sys: include .version in EXTRA_DIST
.version is created in the top_srdir which when building normally
doesn't present a problem. When make distcheck is run, the source
directory is made read-only and it fails with permission denied.

The version of misc/git-version-gen is old and is missing the
instruction to add .version to EXTRA_DIST. This commit does just
that.

make distcheck now passes.

References:
 https://github.com/gagern/gnulib/blob/master/build-aux/git-version-gen
 https://lists.gnu.org/archive/html/bug-gnulib/2011-08/msg00000.html

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-08-09 16:27:37 +10:00
Craig Small
887f2a81d7 library: tests for sysinfo
First set of tests for the library API, this lot checks the two
functions out of sysinfo.c

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-07-20 22:23:21 +10:00
Craig Small
e445f7e6c5 library: Update diskstat API
The calls for reading diskstat have been moved out of
sysinfo and into new files diskstat.[ch] These new
library calls follow the standard pattern for the
new libprocps.

vmstat is updated to use the new API and also got
the weighted IO time added.

vmstat -p previously would only show partitions, not
disks. There does not appear to be any good reason to
artifically deny a user to use this command on a disk,
rather than a partition so this restriction was lifted.

I also realised using int for devid means you can send
the library negative numbers, the index uses unsigned int.
Other similiar calls will need to be fixed too.

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-07-07 22:42:06 +10:00
Jim Warner
336748ecc0 misc: remove yet more darn trailing whitespace buildup
Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-07-01 21:28:22 +10:00
Craig Small
639daf5468 library: Update uptime calls to standard format
Changed all the uptime related functions to use the
standard naming procps_uptime_*
2015-06-29 22:09:59 +10:00
Craig Small
56399212c8 library: Remove signal name from library
Procps library previously held functions that were about either
listing or finding signal names. These are not really the right
location for a library about reading procfs.

This patch handles signal related functions in two ways:

For functions purely found in skill, these have been moved back
into this binary as they are used nowhere else.

For functions used across the binaries, these have been moved
into include/signals.h and lib/signals.c. Besides formatting,
these functions are largely the same.

To assist the skill functions, two functions to access the
signal map array have been added to lib/signals.c
2015-06-29 21:52:51 +10:00