aboutsummaryrefslogtreecommitdiff
path: root/libps/spec.c
Commit message (Collapse)AuthorAgeFilesLines
* Add "comm" as a format spec to psAndrea Monaco2021-12-081-0/+13
| | | | | comm was not recognized by Hurd's ps as a format spec, but is required by POSIX to display the command name (like "exe", but without the full path).
* libps: support getting RPC names for WAIT outputSamuel Thibault2020-11-231-1/+7
| | | | | | | | | | | * libps/Makefile (SRCS): Add ../utils/msgids.c. (../utils/msgids-CPPFLAGS): Add DATADIR macro. * libps/spec.c: Include "../utils/msgids.h". (get_rpc_name): Implement with msgid_info. * utils/msgids.c (parse_opt): Move end code to ... (msgids_scan_std): ... new function. * utils/msgids.h (msgids_scan_std): New prototype. * utils/ps.c (main): Call msgids_scan_std.
* Implement /proc/<pid>/exeSamuel Thibault2018-01-081-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | by adding proc_set/get_exe to the proc server, making exec call proc_set_exe, and libps call proc_get_exe. procfs can then just retrieve the information to make the "exe" symlink. * hurd/process.defs (proc_set_exe, proc_get_exe): New RPCs. * hurd/process_request.defs: Likewise. * hurd/process_reply.defs: Add skips for proc_set_exe and proc_get_exe RPCs. * proc/proc.h (struct proc): Add `exe' field. * proc/info.c (S_proc_set_exe, S_proc_get_exe): New functions. * proc/mgt.c (process_has_exited): Free p->exe. (S_proc_child): Duplicate parent `exe' into child's `exe'. * exec/exec.c (do_exec): Call proc_set_exe when a filename is available. * libps/ps.h (struct proc_stat): Add `exe_vm_alloced', `exe', and `exe_len' field. (PSTAT_EXE): New macro. (PSTAT_USER_BASE): Change value to make room. (proc_stat_exe, proc_stat_exe_len): New macros. * libps/procstat.c (proc_stat_set_flags): Handle PSTAT_EXE case by calling proc_get_exe. * libps/spec.c (ps_get_exe): New function. (ps_exe_getter): New structure. (ps_fmt_spec): Add "Exe" specification. * procfs/process.c (process_file_symlink_make_node, process_file_gc_exe): New functions. (procfs_dir_entry): Add "exe" entry. * startup/startup.c (launch_core_servers): Set exe paths for startup, auth, proc, and fs servers. (frob_kernel_process): Set exe path for kernel task. (S_startup_essential_task): Set exe path for exec server.
* Replace bcopy with memcpy or memmove as appropriate.Justus Winter2017-08-051-1/+1
| | | | | | | | | | | * boot/boot.c: Replace bcopy with memcpy or memmove as appropriate. * exec/hashexec.c: Likewise. * libps/proclist.c: Likewise, but also fix the amount of data copied. * libps/procstat.c: Likewise. * libps/spec.c: Likewise. * libshouldbeinlibc/cacheq.c: Likewise. * libshouldbeinlibc/idvec.c: Likewise. * libshouldbeinlibc/timefmt.c: Likewise.
* Use our own variant of 'assert' and 'assert_perror'.Justus Winter2017-08-051-1/+2
| | | | | Our variants print stack traces on failures. This will make locating errors much easier.
* libps: Fix time comparisonSamuel Thibault2016-12-191-1/+1
| | | | | * libps/spec.c (ps_cmp_times): Actually compare tv_usec fields of tv1 and tv2.
* Replace `bzero' with `memset'Justus Winter2014-12-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For reference, this patch was created using the following semantic patch, and then manually applying the change in all functions containing nested functions, as those are not supported by Coccinelle. @@ expression A, B; @@ - bzero (A, B) + memset (A, 0, B) * auth/auth.c: Replace `bzero' with `memset'. * boot/boot.c: Likewise. * defpager/defpager.c: Likewise. * exec/exec.c: Likewise. Also, drop `safe_bzero' and just use `hurd_safe_memset' directly. * ext2fs/ext2fs.c: Likewise. * ext2fs/getblk.c: Likewise. * ext2fs/pager.c: Likewise. * fatfs/pager.c: Likewise. * ftpfs/dir.c: Likewise. * ftpfs/netfs.c: Likewise. * isofs/inode.c: Likewise. * isofs/pager.c: Likewise. * libdiskfs/file-getfh.c: Likewise. * libdiskfs/file-statfs.c: Likewise. * libfshelp/fetch-root.c: Likewise. * libfshelp/start-translator.c: Likewise. * libftpconn/create.c: Likewise. * libftpconn/open.c: Likewise. * libftpconn/unix.c: Likewise. * libpipe/pipe.c: Likewise. * libps/procstat.c: Likewise. * libps/spec.c: Likewise. * libshouldbeinlibc/cacheq.c: Likewise. * libshouldbeinlibc/idvec.c: Likewise. * libshouldbeinlibc/ugids.c: Likewise. * libstore/argp.c: Likewise. * libstore/enc.c: Likewise. * libstore/kids.c: Likewise. * libthreads/alpha/thread.c: Likewise. * libtreefs/fsys.c: Likewise. * libtrivfs/file-statfs.c: Likewise. * mach-defpager/default_pager.c: Likewise. * pfinet/glue-include/asm/uaccess.h: Likewise. * pfinet/io-ops.c: Likewise. * pfinet/options.c: Likewise. * pfinet/socket.c: Likewise. * pfinet/timer-emul.c: Likewise. * pflocal/io.c: Likewise. * startup/startup.c: Likewise. * storeio/storeio.c: Likewise. * sutils/fstab.c: Likewise. * usermux/usermux.c: Likewise. * utils/fakeauth.c: Likewise. * utils/frobauth.c: Likewise. * utils/login.c: Likewise. * utils/x.c: Likewise.
* libps: fix task/thread times fetchingRichard Braun2014-01-161-3/+3
| | | | | | | | | | | | | | | | | | | | | Introduce PSTAT_TIMES to force the retrieval of both PSTAT_TASK_BASIC and PSTAT_THREAD_BASIC. Task basic info contain the user and system times of terminated threads which the code wrongly assumes is always present along with process info. * libps/procstat.c (add_preconditions): Set both PSTAT_TASK_BASIC and PSTAT_THREAD_BASIC as preconditions for PSTAT_TIMES. (summarize_thread_basic_info): Add terminated threads times only if task basic info are available. (set_procinfo_flags): Provide summarize_thread_basic_info with flags of available info. (proc_stat_set_flags): Set PSTAT_TIMES as available if it was needed and any of PSTAT_TASK_BASIC or PSTAT_THREAD_BASIC could be fetched. * libps/ps.h (PSTAT_TIMES): New macro. * libps/spec.c (ps_get_usr_time): Indicate the getter needs PSTAT_TIMES instead of PSTAT_THREAD_BASIC. (ps_sys_time_getter): Likewise. (ps_tot_time_getter): Likewise.
* libps: fix the length computation in fprint_frac_valueJustus Winter2013-11-211-1/+1
| | | | | | Found using the Clang Static Analyzer. * libps/spec.c (fprint_frac_value): Fix computation of value_len.
* Fix NULL dereferenceSamuel Thibault2010-12-251-1/+1
| | | | | * libps/spec.c (ps_emit_user_name): Do not dereference pw when it is NULL, dereference u instead.
* Obtain number of ports in proc and libpsantrik2010-09-181-0/+10
| | | | | | | | | | | | | | | | | | | Add (and implement) a proc RPC to obtain the number of Mach ports used by the target task. Add infrastructure in libps to read this information. * hurd/process.defs (proc_getnports): New RPC. * hurd/process_request.defs (proc_getnports_request): New RPC. * libps/procstat.c (proc_stat_set_flags): Call proc_getnports RPC if needed. * libps/ps.h (proc_stat): New `num_ports' field. (PSTAT_NUM_PORTS): New macro. (proc_stat_num_ports): New macro. * libps/spec.c (ps_get_num_ports): New function. (ps_num_ports_getter): New variable. (specs): New entry for `ps_num_ports_getter'. * proc/info.c (S_proc_getnports): New function.
* 2002-06-04 James A. Morrison <ja2morri@uwaterloo.ca>Marcus Brinkmann2002-06-051-20/+31
| | | | | | | | | | | | | * spec.c (sprint_frac_value): Added case for values between 1000 and 1023. Make VALUE, FRAC size_t's and return a value of type size_t. (ps_emit_nice_int): Removed function. Replaced by ... (ps_emit_nice_size_t): ... this. New Function. (ps_cmp_size_ts): New function. (ps_vsize_getter): Return a size_t instead of an int. (ps_rsize_getter): Likewise. (ps_get_rmem_frac): MEM_SIZE is now a size_t. (specs): Use ps_emit_nice_size_t instead of ps_emit_nice_int and use ps_cmp_size_ts instead of ps_cmp_ints for RSize and VSize.
* 2001-12-22 Roland McGrath <roland@frob.com>Roland McGrath2001-12-221-3/+1
| | | | | * spec.c (ps_emit_wait): Remove local extern decls for functions actually defined static.
* 1999-06-02 Roland McGrath <roland@baalperazim.frob.com>Roland McGrath1999-06-021-0/+11
| | | | | | | | | | | * ps.h (PSTAT_ENV): New macro. (struct proc_stat): New members `env', `env_len', `env_vm_alloced'. (proc_stat_env, proc_stat_env_len): New accessor macros. (PSTAT_USER_BASE): Increase value to leave more room for additions. * procstat.c (proc_stat_set_flags): Handle environment. (_proc_stat_free): Likewise. * spec.c (ps_get_env, ps_env_getter): New function and constant. (specs): New spec "Env" using ps_env_getter and ps_emit_args.
* 1999-05-29 Roland McGrath <roland@baalperazim.frob.com>Roland McGrath1999-05-291-43/+55
| | | | | | | | | * spec.c (ps_emit_past_time, ps_emit_minutes): Fix return type of getter fn (int to void). * spec.c (ps_get_start_time, ps_start_time_getter): New function and constant to report task_basic_info.creation_time time stamp via "start_time" spec. (specs): Add "Start" fmt for it.
* (ps_emit_wait):Miles Bader1997-06-081-6/+11
| | | | Provide slightly better abbreviations for various port types.
* (ps_nominal_string):Miles Bader1996-10-091-6/+16
| | | | | | | | New function. (specs): Use ps_nominal_string for `Args' and `Arg0' fields. (ps_emit_args, ps_emit_string): Use `-' for empty values.
* (ps_emit_seconds, ps_emit_minutes):Miles Bader1996-10-081-4/+10
| | | | Interpret PS_FMT_FIELD_COLON_MOD flag to mean `print zero as "-"'.
* (ps_emit_wait): Correct mapping of init ports.Miles Bader1996-10-061-3/+5
|
* (ps_emit_wait): Never truncate what we write.Miles Bader1996-06-031-2/+2
|
* (struct ps_fmt_spec_block): New type.Miles Bader1996-06-021-28/+31
| | | | | | (specs_add_alias): Use a linked list of ps_fmt_spec_blocks instead of reallocing a block of specs. (ps_fmt_specs_find): Change searching accordingly.
* (specs): Give runtime specs 2 fraction digits by default.Miles Bader1996-05-121-3/+3
|
* (ps_emit_user_name): New function.Miles Bader1996-05-071-106/+140
| | | | | | | (specs_add_alias): Pass on flags field. (specs): Add precision & flags fields. (FG): New macro. (ps_emit_*): Take FIELD argument instead of WIDTH.
* (ps_emit_past_time): Implement.Miles Bader1996-05-011-3/+14
| | | | | (ps_emit_seconds): Use new args to fmt_seconds. (ps_emit_minutes): Use new args to fmt_minutes.
* (state_shadows): If a process has no parent don't show various processMiles Bader1996-04-231-2/+6
| | | | attributes (that are likely to be noise).
* (ps_emit_past_time): Return zero.Michael I. Bushnell1996-04-111-1/+1
|
* (ps_fmt_specs_find): Use new alias expansion method.Miles Bader1996-03-261-212/+295
| | | | | | (specv_find, specs_add_alias): New functions. Get rid of mega typedefs, and just use structure pointers like other hurd libraries. Other misc cleanups.
* (specs): Right-align the TTY column.Miles Bader1996-02-151-1/+1
|
* (specs): Change `Rpc' entry to `Wait'.Miles Bader1996-02-131-12/+82
| | | | | | | | (ps_emit_wait): New function. (ps_emit_string, ps_emit_string0): Use ps_stream_write_trunc_field. (ps_get_wait): Renamed from ps_get_rpc; calling convention changed. (ps_wait_getter): Renamed from ps_rpc_getter & contents changed accord. (get_syscall_name, get_rpc_name): New stub functions.
* (specs, state_shadows, ps_pid_getter, ps_thread_index_getter,Miles Bader1996-02-091-39/+39
| | | | | | | | | | | | | | ps_owner_getter, ps_owner_uid_getter, ps_ppid_getter, ps_pgrp_getter, ps_session_getter, ps_login_col_getter, ps_num_threads_getter, ps_args_getter, ps_state_getter, ps_rpc_getter, ps_vsize_getter, ps_rsize_getter, ps_cur_priority_getter, ps_base_priority_getter, ps_max_priority_getter, ps_usr_time_getter, ps_sys_time_getter, ps_tot_time_getter, ps_rmem_frac_getter, ps_cpu_frac_getter, ps_sleep_getter, ps_susp_count_getter, ps_proc_susp_count_getter, ps_thread_susp_count_getter, ps_tty_getter, ps_page_faults_getter, ps_cow_faults_getter, ps_pageins_getter, ps_msgs_sent_getter, ps_msgs_rcvd_getter, ps_zero_fills_getter): Make const.
* (state_shadows): Don't reflect a suspended thread in the process stateMiles Bader1996-02-041-209/+189
| | | | | | | | | | | | | | | display if any thread isn't suspended. (ps_get_usr_time, ps_get_sys_time, ps_get_tot_time): Return a struct timeval instead of mach time_value_t. (ps_cmp_times): New function. (specs): Rearrange to use new field layout. (ps_fmt_specs_find): Renamed from find_ps_fmt_spec; now uses a struct ps_fmt_specs instead of an array of specs. (specs): Renamed from ps_std_fmt_specs; (ps_std_fmt_specs): Now of type struct ps_fmt_specs, pointing to specs. (ps_emit_seconds, ps_emit_minutes): Use timefmt functions. (append_fraction, sprint_long_time, ps_emit_nice_seconds): Deleted. Include <timefmt.h>.
* (ps_emit_nz_int):Miles Bader1995-12-211-16/+42
| | | | | | | | | | | Write `-' when the value is 0, rather than mangling the output. (ps_emit_uid): Use an int uid, and emit "-" for none. (ps_emit_uname, ps_cmp_uids, ps_cmp_unames, ps_nominal_user): Handle NULL users. (ps_owner_uid_getter): New variable. (ps_get_owner_uid, ps_nominal_uid): New functions. (ps_std_fmt_specs): Make "UID" use owner_uid rather than owner. (own_uid): New variable (was function local).
* (ps_emit_int, ps_emit_nz_int, ps_emit_priority,Miles Bader1995-11-201-40/+43
| | | | | | | | ps_emit_percent, ps_emit_num_blocks, ps_emit_nice_int, ps_emit_nice_seconds, ps_emit_seconds, ps_emit_uid, ps_emit_uname, ps_emit_string0, ps_emit_string, ps_emit_tty_name, ps_emit_state): Use new STREAM parameter instead of old one and count. Use new function names.
* (ps_base_priority_getter, ps_cur_priority_getter, ps_get_base_priority,Miles Bader1995-11-081-4/+4
| | | | | ps_get_cur_priority): Get this info using PSTAT_THREAD_BASIC instead of PSTAT_THREAD_SCHED.
* (ps_rpc_getter): New variable.Miles Bader1995-11-031-30/+53
| | | | | | | | | | | | | | | | | | | (ps_get_rpc): New function. (ps_std_fmt_specs): Add "RPC" entry. (ps_emit_nz_int): New function. (ps_ppid_getter, ps_pgrp_getter, ps_session_getter, ps_login_col_getter): Use PSTAT_PROC_INFO, not PSTAT_INFO. (ps_get_ppid, ps_get_pgrp, ps_get_session, ps_get_login_col): Use proc_stat_proc_info, not proc_stat_info. (ps_vsize_getter, ps_rsize_getter, ps_rmem_frac_getter, ps_proc_susp_count_getter): Use PSTAT_TASK_BASIC, not PSTAT_INFO. (ps_get_vsize, ps_get_rsize, ps_get_rmem_frac, ps_get_proc_susp_count): Use proc_stat_task_basic_info, not proc_stat_info. (ps_cur_priority_getter, ps_base_priority_getter, ps_max_priority_getter): Use PSTAT_THREAD_SCHED, not PSTAT_THREAD_INFO. (ps_usr_time_getter, ps_sys_time_getter, ps_tot_time_getter, ps_cpu_frac_getter, ps_sleep_getter): Use PSTAT_THREAD_BASIC, not PSTAT_THREAD_INFO.
* (ps_emit_state): Rearrange things to reflect the new state bits.Miles Bader1995-08-191-10/+29
| | | | | (state_shadows): New variable. (ps_emit_state): Use the state_shadows list to turn off some states.
* (ps_std_fmt_specs): Add values for the new nominal_fn field.Miles Bader1995-05-031-33/+106
| | | | | (ps_nominal_zint, ps_nominal_user, ps_nominal_pri, ps_nominal_nth): Possible nominal funs.
* Add the Susp (task/thread suspend count), PSusp (task suspend count), andMiles Bader1995-05-021-0/+27
| | | | TSusp (thread suspend count) output specs.
* (ps_emit_state): If a process is marked as stopped, then don't mentionMiles Bader1995-04-071-46/+17
| | | | | | sleeping or idle threads' status (as that's presumably the signal thread). (ps_emit_tty_name): Move guts into into ps_tty_short_name. Tighten up types used (i.e., don't use int for everything).
* Add the `Arg0' spec, which is the same as `Args', but only prints the firstMiles Bader1995-04-061-2/+3
| | | | one. Change MsgsIn and MsgsOut to MsgIn and MsgOut.
* Include <string.h>.Michael I. Bushnell1995-03-211-3/+4
| | | | | (ps_emit_num_blocks): Use int format for int arg. (sprint_frac_value): Likewise.
* Don't include pshost.h.Michael I. Bushnell1995-03-211-1/+0
|
* Add the output function ps_emit_priority that prints priorities in unix-Miles Bader1995-03-151-3/+12
| | | | | | compatible way (that is, 20 .. -20 instead of 0 .. 24). Use this instead of ps_emit_int to print all priority fields. This also increases the min field width for them to 3.
* Use ps_tty_t routines instead of the ps tty_name field.Miles Bader1995-03-141-57/+70
| | | | | | Use ps_user_t routines instead of querying passwd or getting the owner from ps->info. Increase the width of the user name field to 8.
* Initial revisionMiles Bader1995-03-131-0/+756