library: introduce a fatal 'proc not mounted' function

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2015-09-11 00:00:00 -05:00 committed by Craig Small
parent 42af8ffbc1
commit 007e032805
3 changed files with 41 additions and 0 deletions

View File

@ -6,6 +6,7 @@ global:
escape_str; escape_str;
escape_strlist; escape_strlist;
escaped_copy; escaped_copy;
fatal_proc_unmounted;
freeproc; freeproc;
get_pid_digits; get_pid_digits;
look_up_our_self; look_up_our_self;

View File

@ -70,6 +70,7 @@ struct procps_pidsinfo {
int alloc_total; // number of above pointers allocated int alloc_total; // number of above pointers allocated
int inuse_total; // number of above pointers occupied int inuse_total; // number of above pointers occupied
struct stacks_extent *extents; // anchor for all resettable extents struct stacks_extent *extents; // anchor for all resettable extents
struct stacks_extent *otherexts; // anchor for single stack invariant extents
int history_yes; // need historical data int history_yes; // need historical data
struct history_info *hist; // pointer to historical support data struct history_info *hist; // pointer to historical support data
int dirty_stacks; // extents need dynamic storage clean int dirty_stacks; // extents need dynamic storage clean
@ -969,6 +970,32 @@ static void validate_stacks (
// ___ Public Functions ||||||||||||||||||||||||||||||||||||||||||||||||||||||| // ___ Public Functions |||||||||||||||||||||||||||||||||||||||||||||||||||||||
PROCPS_EXPORT struct pids_stack *fatal_proc_unmounted (
struct procps_pidsinfo *info,
int return_self)
{
static proc_t self;
struct stacks_extent *ext;
// this is very likely the *only* newlib function where the
// context (procps_pidsinfo) of NULL will ever be permitted
look_up_our_self(&self);
if (!return_self)
return NULL;
if (info == NULL
|| !(ext = (struct stacks_extent *)procps_pids_stacks_alloc(info, 1))
|| !extent_cut(info, ext))
return NULL;
ext->next = info->otherexts;
info->otherexts = ext;
assign_results(info, ext->stacks[0], &self);
return ext->stacks[0];
} // end: fatal_proc_unmounted
/* /*
* procps_pids_new(): * procps_pids_new():
* *
@ -1406,6 +1433,15 @@ PROCPS_EXPORT int procps_pids_unref (
free(p); free(p);
} while ((*info)->extents); } while ((*info)->extents);
} }
if ((*info)->otherexts) {
struct stacks_extent *nextext, *ext = (*info)->otherexts;
while (ext) {
nextext = ext->next;
cleanup_stack(ext->stacks[0]->head, ext->ext_numitems);
free(ext);
ext = nextext;
};
}
if ((*info)->reaped.stacks) if ((*info)->reaped.stacks)
free((*info)->reaped.stacks); free((*info)->reaped.stacks);
if ((*info)->anchor) if ((*info)->anchor)

View File

@ -195,6 +195,10 @@ struct pids_reap {
stack -> head [ rel_enum ] . result . type stack -> head [ rel_enum ] . result . type
struct pids_stack *fatal_proc_unmounted (
struct procps_pidsinfo *info,
int return_self);
int procps_pids_new ( int procps_pids_new (
struct procps_pidsinfo **info, struct procps_pidsinfo **info,
int maxitems, int maxitems,