Date: Sat, 1 Aug 2009 13:58:46 +0000 (UTC) From: Stanislav Sedov <stas@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r196016 - projects/libprocstat/usr.bin/fstat Message-ID: <200908011358.n71DwksK082980@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: stas Date: Sat Aug 1 13:58:46 2009 New Revision: 196016 URL: http://svn.freebsd.org/changeset/base/196016 Log: - Improve error handling. - Handly ctty case in fstat. Modified: projects/libprocstat/usr.bin/fstat/fstat.c projects/libprocstat/usr.bin/fstat/libprocstat.c Modified: projects/libprocstat/usr.bin/fstat/fstat.c ============================================================================== --- projects/libprocstat/usr.bin/fstat/fstat.c Sat Aug 1 12:51:16 2009 (r196015) +++ projects/libprocstat/usr.bin/fstat/fstat.c Sat Aug 1 13:58:46 2009 (r196016) @@ -267,6 +267,8 @@ print_file_info(struct procstat *procsta printf(" mmap"); else if (fst->fs_uflags & PS_FST_UFLAG_JAIL) printf(" jail"); + else if (fst->fs_uflags & PS_FST_UFLAG_CTTY) + printf(" ctty"); else printf(" %4d", fst->fs_fd); Modified: projects/libprocstat/usr.bin/fstat/libprocstat.c ============================================================================== --- projects/libprocstat/usr.bin/fstat/libprocstat.c Sat Aug 1 12:51:16 2009 (r196015) +++ projects/libprocstat/usr.bin/fstat/libprocstat.c Sat Aug 1 13:58:46 2009 (r196016) @@ -232,6 +232,7 @@ procstat_freeprocs(struct procstat *proc if (p != NULL) free(p); + p = NULL; } struct filestat_list * @@ -254,10 +255,14 @@ procstat_freefiles(struct procstat *proc STAILQ_FOREACH_SAFE(fst, head, next, tmp) free(fst); free(head); - if (procstat->vmentries != NULL) + if (procstat->vmentries != NULL) { free (procstat->vmentries); - if (procstat->files != NULL) + procstat->vmentries = NULL; + } + if (procstat->files != NULL) { free (procstat->files); + procstat->files = NULL; + } } static struct filestat * @@ -931,7 +936,7 @@ kinfo_vtype2fst(int kfvtype) static int procstat_get_vnode_info_sysctl(struct filestat *fst, struct vnstat *vn, - char *errbuf __unused) + char *errbuf) { struct statfs stbuf; struct kinfo_file *kif; @@ -972,9 +977,12 @@ procstat_get_vnode_info_sysctl(struct fi status = kif->kf_status; } vn->vn_type = vntype; - if (vntype == PS_FST_VTYPE_VNON || vntype == PS_FST_VTYPE_VBAD || - (status & KF_ATTR_VALID) == 0) + if (vntype == PS_FST_VTYPE_VNON || vntype == PS_FST_VTYPE_VBAD) return (0); + if ((status & KF_ATTR_VALID) == 0) { + snprintf(errbuf, _POSIX2_LINE_MAX, "? (no info available)"); + return (1); + } if (path && *path) { statfs(path, &stbuf); vn->vn_mntdir = strdup(stbuf.f_mntonname);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200908011358.n71DwksK082980>