/*************************************************************************\ * Copyright (c) 2009 Helmholtz-Zentrum Berlin fuer Materialien und Energie. * Copyright (c) 2002 The University of Chicago, as Operator of Argonne * National Laboratory. * Copyright (c) 2002 The Regents of the University of California, as * Operator of Los Alamos National Laboratory. * EPICS BASE Versions 3.13.7 * and higher are distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. \*************************************************************************/ /* osdFdUsage.c - File descriptor usage: Solaris implementation = use /proc//fd and getrlimit() */ /* * Author: Ralph Lange (HZB/BESSY) * * Modification History * 2009-05-28 Ralph Lange (HZB/BESSY) * Restructured OSD parts * */ #include #include #include #include #include static char fddir[40] = ""; int devIocStatsInitFDUsage (void) { sprintf(fddir, "/proc/%d/fd", (int)getpid()); return 0;} int devIocStatsGetFDUsage (fdInfo *pval) { DIR *pdir; struct dirent *pdit; struct rlimit lim; int i = 0; if ((pdir = opendir(fddir)) == NULL) return -1; while ((pdit = readdir(pdir)) != NULL) i++; if (closedir(pdir) == -1) return -1; pval->used = i - 3; /* Don't count this operation, '.' and '..' */ if (getrlimit(RLIMIT_NOFILE, &lim)) return -1; pval->max = lim.rlim_cur; return 0; }