[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 23/25: procfs: Gracefully degrade meminfo.
From: |
Samuel Thibault |
Subject: |
[hurd] 23/25: procfs: Gracefully degrade meminfo. |
Date: |
Mon, 24 Oct 2016 00:16:46 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit 587704fc6a85e3ac080c58b7dfa9ebc73c72fede
Author: Justus Winter <address@hidden>
Date: Thu Oct 13 22:52:49 2016 +0200
procfs: Gracefully degrade meminfo.
* procfs/rootdir.c (rootdir_gc_meminfo): Just omit the swap
information if the default pager is unreachable.
---
procfs/rootdir.c | 44 ++++++++++++++++++++++++++++++++------------
1 file changed, 32 insertions(+), 12 deletions(-)
diff --git a/procfs/rootdir.c b/procfs/rootdir.c
index 8e7c659..748805e 100644
--- a/procfs/rootdir.c
+++ b/procfs/rootdir.c
@@ -272,27 +272,37 @@ rootdir_gc_meminfo (void *hook, char **contents, ssize_t
*contents_len)
struct vm_statistics vmstats;
struct vm_cache_statistics cache_stats;
default_pager_info_t swap;
+ FILE *m;
error_t err;
+ m = open_memstream (contents, (size_t *) contents_len);
+ if (m == NULL)
+ {
+ err = ENOMEM;
+ goto out;
+ }
+
err = vm_statistics (mach_task_self (), &vmstats);
if (err)
- return EIO;
+ {
+ err = EIO;
+ goto out;
+ }
err = vm_cache_statistics (mach_task_self (), &cache_stats);
if (err)
- return EIO;
+ {
+ err = EIO;
+ goto out;
+ }
cnt = HOST_BASIC_INFO_COUNT;
err = host_info (mach_host_self (), HOST_BASIC_INFO, (host_info_t) &hbi,
&cnt);
if (err)
- return err;
-
- err = get_swapinfo (&swap);
- if (err)
- return err;
+ goto out;
assert (cnt == HOST_BASIC_INFO_COUNT);
- *contents_len = asprintf (contents,
+ fprintf (m,
"MemTotal: %14lu kB\n"
"MemFree: %14lu kB\n"
"Buffers: %14lu kB\n"
@@ -300,8 +310,6 @@ rootdir_gc_meminfo (void *hook, char **contents, ssize_t
*contents_len)
"Active: %14lu kB\n"
"Inactive: %14lu kB\n"
"Mlocked: %14lu kB\n"
- "SwapTotal:%14lu kB\n"
- "SwapFree: %14lu kB\n"
,
(long unsigned) hbi.memory_size / 1024,
(long unsigned) vmstats.free_count * PAGE_SIZE / 1024,
@@ -309,11 +317,23 @@ rootdir_gc_meminfo (void *hook, char **contents, ssize_t
*contents_len)
(long unsigned) cache_stats.cache_count * PAGE_SIZE / 1024,
(long unsigned) vmstats.active_count * PAGE_SIZE / 1024,
(long unsigned) vmstats.inactive_count * PAGE_SIZE / 1024,
- (long unsigned) vmstats.wire_count * PAGE_SIZE / 1024,
+ (long unsigned) vmstats.wire_count * PAGE_SIZE / 1024);
+
+ err = get_swapinfo (&swap);
+ if (err)
+ /* This is not fatal, we just omit the information. */
+ err = 0;
+ else
+ fprintf (m,
+ "SwapTotal:%14lu kB\n"
+ "SwapFree: %14lu kB\n"
+ ,
(long unsigned) swap.dpi_total_space / 1024,
(long unsigned) swap.dpi_free_space / 1024);
- return 0;
+ out:
+ fclose (m);
+ return err;
}
static error_t
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 18/25: ext2fs: Rename parameter., (continued)
- [hurd] 18/25: ext2fs: Rename parameter., Samuel Thibault, 2016/10/23
- [hurd] 09/25: Fix installing runsystem.hurd, Samuel Thibault, 2016/10/23
- [hurd] 12/25: fakeroot: set FAKED_MODE, Samuel Thibault, 2016/10/23
- [hurd] 14/25: ext2fs: Disable option to specify alternate superblock., Samuel Thibault, 2016/10/23
- [hurd] 17/25: trans/crash: Fix setting core file template at runtime., Samuel Thibault, 2016/10/23
- [hurd] 21/25: fshelp: Fix fetching the control port., Samuel Thibault, 2016/10/23
- [hurd] 06/25: startup: Fix looping over runsystem, Samuel Thibault, 2016/10/23
- [hurd] 16/25: trans/crash: Use empty core file templates to disable the feature., Samuel Thibault, 2016/10/23
- [hurd] 13/25: libdiskfs: Fix short-circuiting translators., Samuel Thibault, 2016/10/23
- [hurd] 11/25: random: Hash continuous areas in the csprng pool., Samuel Thibault, 2016/10/23
- [hurd] 23/25: procfs: Gracefully degrade meminfo.,
Samuel Thibault <=
- [hurd] 22/25: Fix some RPC request headers #ifdef guards, Samuel Thibault, 2016/10/23