summaryrefslogtreecommitdiff
path: root/procfs
AgeCommit message (Collapse)Author
2022-01-17Fix const warningsSamuel Thibault
Now that the RPCs have const, this forces us cleaning our const-meant functions.
2021-05-24procfs: Fix use-after-freeSergey Bugaev
Fix several issues with reference counting in rootdir_make_translated_node (): * Grab an additional reference while still holding the lock. * Give the node an additional reference for being pointed to by the ops. * Reference the existing node if we find it on the second try, not only if we find it on the first try. * Dereference, not just clean, the created node if it turns out to be unneeded. Fixes a crash with the following backtrace: #2 0x010855c8 in __assert_fail_backtrace ( assertion=0x1051148 "! (r.hard == 1 && r.weak == 0) || !\"refcount detected use-after-free!\"", file=0x1050cec "../../libshouldbeinlibc/refcount.h", line=170, function=0x1051220 <__PRETTY_FUNCTION__.3> "refcounts_ref") at ../../libshouldbeinlibc/assert-backtrace.c:64 #3 0x01050358 in refcounts_ref (result=0x0, ref=0x15009a0) at ../../libshouldbeinlibc/refcount.h:170 #4 netfs_nref (np=0x15008f0) at ../../libnetfs/nref.c:26 #5 0x0804c9f4 in rootdir_make_translated_node (dir_hook=0x10001990, entry_hook=0x8055180 <__compound_literal.8>) at ../../procfs/rootdir.c:674 #6 0x0804ace3 in procfs_dir_lookup (hook=0x10001c10, name=0x2857efc "mounts", np=0x2855d68) at ../../procfs/procfs_dir.c:88 #7 0x0804a410 in procfs_lookup (np=0x10001c40, name=0x2857efc "mounts", npp=0x2855d68) at ../../procfs/procfs.c:185 #8 0x0804cae5 in dircat_lookup (hook=0x10001d50, name=0x2857efc "mounts", np=0x2855d68) at ../../procfs/dircat.c:76 #9 0x0804a410 in procfs_lookup (np=0x10001d80, name=0x2857efc "mounts", npp=0x2855d68) at ../../procfs/procfs.c:185 #10 0x0804a96f in netfs_attempt_lookup (user=0x1401c60, dir=0x10001d80, name=0x2857efc "mounts", np=0x2855d68) at ../../procfs/netfs.c:212 #11 0x0103fd5b in netfs_S_dir_lookup (dircred=<optimized out>, filename=<optimized out>, flags=<optimized out>, mode=<optimized out>, do_retry=<optimized out>, retry_name=<optimized out>, retry_port=<optimized out>, retry_port_type=<optimized out>) at ../../libnetfs/dir-lookup.c:175 Message-Id: <20210524154340.264885-2-bugaevc@gmail.com>
2019-10-31procfs: fix getting last_processor fieldSamuel Thibault
* procfs/process.c (entries): Add PSTAT_THREAD_SCHED in `needs' field of entry for process_file_gc_stat.
2019-10-31procfs: Fix asprintf formatSamuel Thibault
Last_processor is an int in the proc info, and there aren't really plans for machines with more than 4 billion processors. * procfs/process.c (process_file_gc_stat): Make last_processor unsigned instead of long unsigned.
2019-10-31proc: add support for last_processorAlmudena Garcia
Read last_processor (new member) from thread_info structures, and fill stat structure with this. * configure.ac: Check whether thread_sched_info structure includes `last_processor' member. * proc/info.c (S_proc_getprocinfo) [HAVE_STRUCT_THREAD_SCHED_INFO_LAST_PROCESSOR]: Set `last_processor' field. * procfs/process.c (process_file_gc_stat) [HAVE_STRUCT_THREAD_SCHED_INFO_LAST_PROCESSOR]: Set last processor proc field to `thsi->last_processor'. [!HAVE_STRUCT_THREAD_SCHED_INFO_LAST_PROCESSOR]: Set last processor proc field to 0.
2018-01-08Implement /proc/<pid>/exeSamuel Thibault
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.
2017-09-01Remove unused parameter from the 'get_source' machinery.Justus Winter
* libdiskfs/diskfs.h (diskfs_get_source): Remove first parameter. * libdiskfs/file-get-source.c (diskfs_S_file_get_source): Adapt callsite. * libdiskfs/get-source.c (diskfs_get_source): Adapt default implementation. * libnetfs/netfs.h (netfs_get_source): Remove first parameter. * libnetfs/file-get-source.c (netfs_S_file_get_source): Adapt callsite. * libnetfs/get-source.c (netfs_get_source): Adapt default implementation. * libtrivfs/trivfs.h (trivfs_get_source): Remove first parameter. * libtrivfs/file-get-source.c (trivfs_S_file_get_source): Adapt callsite. * libtrivfs/get-source.c (trivfs_get_source): Adapt default implementation. * nfs/main.c (netfs_get_source): Adapt implementation. * procfs/main.c (netfs_get_source): Likewise. * trans/firmlink.c (trivfs_get_source): Likewise.
2017-08-05Use our own variant of 'assert' and 'assert_perror'.Justus Winter
Our variants print stack traces on failures. This will make locating errors much easier.
2017-08-05procfs: Provide 'hostinfo'.Justus Winter
* procfs/rootdir.c (rootdir_gc_hostinfo): New function. (rootdir_entries): New entry 'hostinfo'.
2017-06-03procfs: Remove superfluous calls.Justus Winter
* procfs/rootdir.c (rootdir_gc_vmstat): Remove superfluous 'host_info' calls.
2016-12-19procfs: provide magic retry response for /proc/selfJustus Winter
* hurd/hurd_types.h: Document the magic retry string `pid'. * hurd/paths.h (_HURD_MAGIC): New macro. * procfs/main.c: Remove all code related to faking /proc/self. * procfs/main.h: Likewise. * procfs/rootdir.c: Likewise. Instead, return the magic retry response `pid' for the `self' node.
2016-12-17Fix "procfs" ChangeLog handlingThomas Schwinge
..., so that the correct things get done for "make dist". * procfs/ChangeLog: Merge file into... * ChangeLog: ... this one, and elaborate some more. * Makefile (gen_start_commit, ChangeLog_files): Merge into... (ChangeLog_specs): ... this new variable. (ChangeLog_files): Rewrite in terms of that one. (gitlog-to-changelog_rev, ChangeLog_specs): Add entries for "procfs". (gen-ChangeLog): Handle that.
2016-10-15procfs: Gracefully degrade meminfo.Justus Winter
* procfs/rootdir.c (rootdir_gc_meminfo): Just omit the swap information if the default pager is unreachable.
2016-03-24Use swapon path as pager partition pathSamuel Thibault
When /dev/hd* entries are parted-partition storeio, the store name is only the disk name, thus not unique. We should just use the path being used instead. * sutils/swapon.c (swaponoff): Use `file' instead of `store->name' to default_pager_paging_file. (main): Drop hardcoded "/dev/". * procfs/rootdir.c (rootdir_gc_swaps): Drop hardcoded "/dev/".
2016-03-24Fix swap information numbersSamuel Thibault
* procfs/rootdir.c (rootdir_gc_swaps): Fix default_pager_storage_info call parameter order. * sutils/swapon.c (main): Likewise.
2016-03-21netfs: Remove global reference count lock.Flavio Cruz
* libnetfs/drop-node.c: Remove use of netfs_node_refcnt_lock. * libnetfs/init-init.c: Remove netfs_node_refcnt_lock. * libnetfs/make-node.c: Initialize refcounts in refcounts_init. * libnetfs/netfs.h: Use refcounts_t for tracking node references. Remove netfs_node_refcnt_lock. Add netfs_nref_light, netfs_nrele_light and handler netfs_try_dropping_softrefs. Adjust comments. * libnetfs/nput.c: Use refcounts_t. Call netfs_try_dropping_softrefs to remove any soft reference that the translator might have acquired during the lifetime of the node. Implement empty netfs_try_dropping_softrefs. * libnetfs/nref.c: Implement netfs_nref_light. * libnetfs/nrele.c: Use refcounts_t and netfs_try_dropping_softrefs. Implement netfs_nrele_light. * ftpfs/dir.c: Use netfs_nref without locking the old netfs_node_refcnt_lock. * ftpfs/node.c: Likewise. * usermux/mux.c: Use netfs_nref to increase hard references of the node. * hostmux/mux.c: Use netfs_nref to increase hard references of the node. * trans/fakeroot.c (new_node): Use a light reference when storing a node in the hash table. * trans/fakeroot.c (netfs_try_dropping_softrefs): Implement netfs_try_dropping_softrefs to remove the node from the hash table. * trans/fakeroot.c (netfs_node_norefs): Remove code to remove the node from the hash table. * trans/fakeroot.c (netfs_S_dir_lookup): Simplify lookup code since we don't need to lock netfs_node_refcnt_lock anymore. * procfs/netfs.c: Remove use of netfs_node_refcnt_lock. * nfs/cache.c: Add mutex to handle exclusive access to nodehash. This replaces the use of netfs_node_refcnt_lock. * nfs/cache.c (lookup_handle): Use nodehash_ihash_lock when accessing nodehash. Use netfs_nref_light to add one soft reference to the node just added to nodehash. * nfs/cache.c (netfs_node_norefs): Use netfs_nref. Don't use netfs_node_refcnt_lock and don't remove the node from nodehash here. * nfs/cache.c (netfs_try_dropping_softrefs): Drop the light reference when the node has no more hard references. * nfs/cache.c (recache_handle): Use nodehash_ihash_lock instead. * nfs/ops.c (netds_attempt_unlink): Use refcounts_references. * console/console.c (netfs_node_norefs): Use a soft reference to store a node in dir_node, cons_node, disp_node, inp_node. * console/console.c (netfs_try_dropping_softrefs): When dropping all soft references remove node pointer from the fields above.
2016-03-16Add getting swap information from swapon and procfsSamuel Thibault
* hurd/default_pager.defs (default_pager_storage_info): New RPC. * hurd/default_pager_reply.defs: Skip default_pager_storage_info RPC. * hurd/default_pager_types.h: Include <mach/machine/vm_types.h>. (vm_size_array_t): New type. * mach-defpager/priv.h (part): Add `name' field. * mach-defpager/default_pager.c (new_partition): Allocate and fill `part->name' field. Free it on error. (destroy_paging_partition): Free `part->name' field. (S_default_pager_storage_info): New function. * procfs/Makefile (SRCS): Add default_pagerUser.c. * procfs/rootdir.c: Include "default_pager_U.h". (rootdir_gc_swaps): New function. (rootdir_entries): Add "swaps" entry. * sutils/swapon.c: Include <argz.h> (show): New variable. (options): Add --show/-S option. (def_pager, dev_master): New variables (swaponoff): Move getting `def_pager' to... (get_def_pager): ... new function. (main): Support 'S' option. * trans/proxy-defpager.c (S_default_pager_storage_info): New function.
2016-02-23procfs: adapt to kernel interface changeJustus Winter
procfs makes use of the debug interface which is subject to change. * procfs/rootdir.c (rootdir_gc_slabinfo): The flag CACHE_FLAGS_NO_RECLAIM is no longer used.
2016-02-14Fix function nameSamuel Thibault
* procfs/main.c (set_default_options): Rename to set_compatibility_options. (argp_parser): Update call accordingly.
2016-01-19procfs: Move setting default parameters to a separate functionSamuel Thibault
* procfs/main.c (set_default_options): New function (argp_parser): Call `set_default_options'.
2015-12-31Drop OTHERLIBS and use LDLIBS exclusivelyFlavio Cruz
When cross-compiling, OTHERLIBS magically turns -lpthread into the path to the host libpthread.so file, resulting in build issues. LDLIBS does not suffer from this problem and it seems that is already being used in other Makefiles. This patch removes OTHERLIBS entirely from the build system. * Makeconf: Remove references to OTHERLIBS * auth/Makefile: Replace OTHERLIBS with LDLIBS. * boot/Makefile: Likewise. * console/Makefile: Likewise. * exec/Makefile: Likewise. * ext2fs/Makefile: Likewise. * fatfs/Makefile: Likewise. * ftpfs/Makefile: Likewise. * hostmux/Makefile: Likewise. * isofs/Makefile: Likewise. * libhurd-slab/Makefile: Likewise. * nfs/Makefile: Likewise. * nfsd/Makefile: Likewise. * pfinet/Makefile: Likewise. * proc/Makefile: Likewise. * procfs/Makefile: Likewise. * random/Makefile: Likewise. * storeio/Makefile: Likewise. * term/Makefile: Likewise. * tmpfs/Makefile: Likewise. * usermux/Makefile: Likewise.
2015-12-29fix compiler warnings in hurd/procfsFlavio Cruz
procfs: Fix compiler warnings. * include/sys/procfs.h: Change uintptr_t to vm_address_t. * procfs/process.c: Fix format strings. * procfs/rootdir.c: Add missing casts.
2015-09-08Make procfs accept none or proc as "device"Samuel Thibault
This allows "mount none /proc -t proc" to work. * procfs/main.c (argp_parser): On ARGP_KEY_ARG, accept and ignore "none" and "proc".
2015-04-07procfs: fix runtime option parsingJustus Winter
* procfs/main.c (netfs_runtime_argp): Actually use the runtime option parser.
2015-04-07procfs: fix argument parsingJustus Winter
* procfs/main.c (argp_parser): Fix argument parsing.
2015-01-03procfs: Fix typos in comments (found by codespell)Stefan Weil
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2014-12-26Revert "Make sure to free content dir in procfs"Samuel Thibault
This reverts commit 5fe615a4d66f4dea48812ed9e4f250010a8f9298.
2014-12-26Make sure to free content dir in procfsLancelot SIX
In procfs/netfs.c:netfs_get_dirents, make sure to free the memory allocated with the "get_contents" callback of nodes.
2014-12-06Fix coding styleSamuel Thibault
2014-11-21procfs: do not hard-code the default argument valuesJustus Winter
* procfs/main.c (common_options): If possible, do not hard-code the default values.
2014-11-21Add proc_set_init_task, make runsystem pid 1Justus Winter
* hurd/process.defs (proc_set_init_task): New procedure. * hurd/process_reply.defs (proc_set_init_task): Likewise. * hurd/process_request.defs (proc_set_init_task): Likewise. * include/pids.h: Add HURD_PID_INIT as 1, adjust others accordingly. * init/init.c (start_child): Register the child task. * proc/proc.h (init_proc): New variable. (create_startup_proc): Rename to create_init_proc. * proc/main.c (main): Create placeholder proc object for pid 1. * proc/mgt.c: Use init_proc instead of startup_proc, as the former is the new root of the process tree. (create_startup_proc): Rename to create_init_proc. (S_proc_set_init_task): New function. * doc/hurd.texi (Server Bootstrap): Update accordingly. * procfs/main.c: Do not hard-code kernel pid, use pids.h instead.
2014-11-11Make procfs appear in /proc/mountsSamuel Thibault
d-i needs to be able to check whether /proc is mounted or not. * procfs/main.c (netfs_get_source): New function.
2014-09-29procfs: reorganize rootdir.cJustus Winter
* procfs/rootdir.c: Move the translator linkage code to the appropriate location.
2014-09-29procfs: generalize the translator linkage codeJustus Winter
Generalize the translator linkage code previously introduced for the `mounts' node. * procfs/rootdir.c (struct procfs_translated_node_ops): New specialized node operations structure for translated nodes. (rootdir_mounts_make_node): Generalize and rename to rootdir_make_translated_node. Also, pass the entry_hook to procfs_make_node so that... (rootdir_mounts_get_translator): ... can be generalized to rootdir_translated_node_get_translator and read the argz vector from the hooked structure. (ROOTDIR_DEFINE_TRANSLATED_NODE): New convenience macro to define translated nodes. (rootdir_entries): Use the new code for the `mounts' node.
2014-09-29procfs: do not test whether /hurd/mtab existsJustus Winter
Now that procfs is merged into the Hurd repository we can just assume that the mtab translator exists. * procfs/rootdir.c (rootdir_mounts_exists): Drop function. (rootdir_entries): Adjust accordingly.
2014-09-29procfs: implement /proc/filesystemsJustus Winter
* procfs/rootdir.c (rootdir_gc_filesystems): New function. (rootdir_entries): Use the new function to implement /proc/filesystems.
2014-09-29procfs: implement /proc/N/mapsJustus Winter
Fixes https://savannah.gnu.org/bugs/?32770 . * procfs/process.c (process_file_gc_maps): New function. (entries): Use the new function to implement /proc/N/maps.
2014-09-22hurd: add symbolic name for the mtab translatorJustus Winter
* hurd/paths.h (_HURD_MTAB): New macro. * procfs/rootdir.c (rootdir_mounts_get_translator): Use the new macro. (rootdir_mounts_exists): Likewise.
2014-09-18procfs: fix typo in commentJustus Winter
* procfs/process.c (process_stat_make_node): Fix typo in comment.
2014-06-17Add mach_debug defs rulesDavid Michael
* Makeconf (mach_debug_defs_names,mach_debug_defs): New variables. * Makeconf: Add rule to generate local $(mach_debug_defs) files. * procfs/Makefile: Remove vpath for mach_debug defs.
2014-06-15Prepare the procfs translator to be merged into the Hurd sourcesJustus Winter
Move the procfs translator to its own subdirectory 'procfs'. This is the last commit to this repository. Development of the procfs translator will continue in the main Hurd repository. * procfs/Makefile: Replace the standalone Makefile with the one from the Debian packaging repository.