svn commit: r195992 - in projects/libprocstat: sys/sys usr.bin/fstat
Stanislav Sedov
stas at FreeBSD.org
Fri Jul 31 12:30:24 UTC 2009
Author: stas
Date: Fri Jul 31 12:30:23 2009
New Revision: 195992
URL: http://svn.freebsd.org/changeset/base/195992
Log:
- Use platform-independent types universally.
- Correct inconsistencies between kinfo and procstat types.
- Use 64 bit integer type to store fileid to support future
filesystems with 64 bit inode numbers.
- Sort and pad structures accordingly.
Modified:
projects/libprocstat/sys/sys/user.h
projects/libprocstat/usr.bin/fstat/fstat.c
projects/libprocstat/usr.bin/fstat/fuser.c
projects/libprocstat/usr.bin/fstat/libprocstat.c
projects/libprocstat/usr.bin/fstat/libprocstat.h
Modified: projects/libprocstat/sys/sys/user.h
==============================================================================
--- projects/libprocstat/sys/sys/user.h Fri Jul 31 11:49:26 2009 (r195991)
+++ projects/libprocstat/sys/sys/user.h Fri Jul 31 12:30:23 2009 (r195992)
@@ -361,13 +361,13 @@ struct kinfo_file {
/* Global file id. */
uint64_t kf_file_fileid;
/* File size. */
- off_t kf_file_size;
+ uint64_t kf_file_size;
/* Vnode filesystem id. */
- dev_t kf_file_fsid;
+ uint32_t kf_file_fsid;
/* File device. */
- dev_t kf_file_rdev;
+ uint32_t kf_file_rdev;
/* File mode. */
- mode_t kf_file_mode;
+ uint16_t kf_file_mode;
/* Round to 64 bit alignment. */
uint16_t kf_file_pad0;
uint32_t kf_file_pad1;
@@ -380,7 +380,7 @@ struct kinfo_file {
uint32_t kf_pipe_pad0[3];
} kf_pipe;
struct {
- dev_t kf_pts_dev;
+ uint32_t kf_pts_dev;
/* Round to 64 bit alignment. */
uint32_t kf_pts_pad0[7];
} kf_pts;
@@ -458,12 +458,11 @@ struct kinfo_vmentry {
int kve_ref_count; /* VM obj ref count. */
int kve_shadow_count; /* VM obj shadow count. */
int kve_vn_type; /* Vnode type. */
- off_t kve_vn_size; /* File size. */
- dev_t kve_vn_rdev; /* Device id if device. */
- mode_t kve_vn_mode; /* File mode. */
+ uint64_t kve_vn_size; /* File size. */
+ uint32_t kve_vn_rdev; /* Device id if device. */
+ uint16_t kve_vn_mode; /* File mode. */
uint16_t kve_status; /* Status flags. */
- int _kve_pad0; /* 64bit align next field */
- int _kve_ispare[11]; /* Space for more stuff. */
+ int _kve_ispare[12]; /* Space for more stuff. */
/* Truncated before copyout in sysctl */
char kve_path[PATH_MAX]; /* Path to VM obj, if any. */
};
Modified: projects/libprocstat/usr.bin/fstat/fstat.c
==============================================================================
--- projects/libprocstat/usr.bin/fstat/fstat.c Fri Jul 31 11:49:26 2009 (r195991)
+++ projects/libprocstat/usr.bin/fstat/fstat.c Fri Jul 31 12:30:23 2009 (r195992)
@@ -250,7 +250,7 @@ print_file_info(struct procstat *procsta
for (d = devs; d != NULL; d = d->next)
if (d->fsid == vn.vn_fsid) {
fsmatch = 1;
- if (d->ino == vn.vn_fileid) {
+ if ((unsigned)d->ino == vn.vn_fileid) {
filename = d->name;
break;
}
@@ -448,8 +448,8 @@ print_vnode_info(struct procstat *procst
if (nflg)
printf(" %2d,%-2d", major(vn.vn_fsid), minor(vn.vn_fsid));
- else if (vn.mntdir != NULL)
- (void)printf(" %-8s", vn.mntdir);
+ else if (vn.vn_mntdir != NULL)
+ (void)printf(" %-8s", vn.vn_mntdir);
/*
* Print access mode.
Modified: projects/libprocstat/usr.bin/fstat/fuser.c
==============================================================================
--- projects/libprocstat/usr.bin/fstat/fuser.c Fri Jul 31 11:49:26 2009 (r195991)
+++ projects/libprocstat/usr.bin/fstat/fuser.c Fri Jul 31 12:30:23 2009 (r195992)
@@ -91,8 +91,8 @@ struct consumer {
STAILQ_ENTRY(consumer) next;
};
struct reqfile {
- long fsid;
- long fileid;
+ uint32_t fsid;
+ uint64_t fileid;
const char *name;
STAILQ_HEAD(, consumer) consumers;
};
Modified: projects/libprocstat/usr.bin/fstat/libprocstat.c
==============================================================================
--- projects/libprocstat/usr.bin/fstat/libprocstat.c Fri Jul 31 11:49:26 2009 (r195991)
+++ projects/libprocstat/usr.bin/fstat/libprocstat.c Fri Jul 31 12:30:23 2009 (r195992)
@@ -877,7 +877,7 @@ procstat_get_vnode_info_kvm(kvm_t *kd, s
snprintf(errbuf, _POSIX2_LINE_MAX, "?(%s)", tagstr);
return (1);
}
- vn->mntdir = getmnton(kd, vnode.v_mount);
+ vn->vn_mntdir = getmnton(kd, vnode.v_mount);
if ((vnode.v_type == VBLK || vnode.v_type == VCHR) &&
vnode.v_rdev != NULL){
vn->vn_dev = dev2udev(kd, vnode.v_rdev);
@@ -930,14 +930,14 @@ procstat_get_vnode_info_sysctl(struct fi
struct statfs stbuf;
struct kinfo_file *kif;
struct kinfo_vmentry *kve;
- int vntype;
- dev_t rdev;
- off_t size;
- mode_t mode;
- int status;
uint64_t fileid;
- uint32_t fsid;
+ uint64_t size;
char *name, *path;
+ uint32_t fsid;
+ uint16_t mode;
+ uint32_t rdev;
+ int vntype;
+ int status;
assert(fst);
assert(vn);
@@ -971,7 +971,7 @@ procstat_get_vnode_info_sysctl(struct fi
return (0);
if (path && *path) {
statfs(path, &stbuf);
- vn->mntdir = strdup(stbuf.f_mntonname);
+ vn->vn_mntdir = strdup(stbuf.f_mntonname);
}
vn->vn_dev =rdev;
if (vntype == KF_VTYPE_VBLK) {
Modified: projects/libprocstat/usr.bin/fstat/libprocstat.h
==============================================================================
--- projects/libprocstat/usr.bin/fstat/libprocstat.h Fri Jul 31 11:49:26 2009 (r195991)
+++ projects/libprocstat/usr.bin/fstat/libprocstat.h Fri Jul 31 12:30:23 2009 (r195992)
@@ -103,39 +103,37 @@ struct filestat {
STAILQ_ENTRY(filestat) next;
};
struct vnstat {
- dev_t vn_dev;
- char vn_devname[SPECNAMELEN + 1];
- int vn_type;
- long vn_fsid;
- long vn_fileid;
- mode_t vn_mode;
- u_long vn_size;
- char *mntdir;
+ uint64_t vn_fileid;
+ uint64_t vn_size;
+ char *vn_mntdir;
+ uint32_t vn_dev;
+ uint32_t vn_fsid;
+ int vn_type;
+ uint16_t vn_mode;
+ char vn_devname[SPECNAMELEN + 1];
};
struct ptsstat {
- dev_t dev;
- char devname[SPECNAMELEN + 1];
+ uint32_t dev;
+ char devname[SPECNAMELEN + 1];
};
struct pipestat {
+ size_t buffer_cnt;
uint64_t addr;
uint64_t peer;
- size_t buffer_cnt;
};
struct sockstat {
- int type;
- int proto;
- int dom_family;
+ uint64_t inp_ppcb;
uint64_t so_addr;
uint64_t so_pcb;
- uint64_t inp_ppcb;
uint64_t unp_conn;
- int so_snd_sb_state;
+ int dom_family;
+ int proto;
int so_rcv_sb_state;
+ int so_snd_sb_state;
+ int type;
char dname[32];
};
-/* XXX: sort structs. */
-
STAILQ_HEAD(filestat_list, filestat);
void procstat_close(struct procstat *procstat);
More information about the svn-src-projects
mailing list