rpms/procps/F-10 procps-3.2.7-ps-cgroup.patch, NONE, 1.1 procps-3.2.7-vmstat-partstats-long.patch, NONE, 1.1 procps.spec, 1.74, 1.75

Daniel Novotny dnovotny at fedoraproject.org
Mon Feb 16 12:47:45 UTC 2009


Author: dnovotny

Update of /cvs/extras/rpms/procps/F-10
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv16425

Modified Files:
	procps.spec 
Added Files:
	procps-3.2.7-ps-cgroup.patch 
	procps-3.2.7-vmstat-partstats-long.patch 
Log Message:

add cgroup support, fix #485246


procps-3.2.7-ps-cgroup.patch:

--- NEW FILE procps-3.2.7-ps-cgroup.patch ---
diff -up procps-3.2.7/ps/output.c.pom procps-3.2.7/ps/output.c
--- procps-3.2.7/ps/output.c.pom	2009-02-15 13:16:27.000000000 +0100
+++ procps-3.2.7/ps/output.c	2009-02-15 14:02:34.000000000 +0100
@@ -1097,6 +1097,40 @@ static int pr_sgi_p(char *restrict const
   return snprintf(outbuf, COLWID, "*");
 }
 
+static int pr_cgroup(char *restrict const outbuf, const proc_t *restrict const pp){
+  char filename[48];
+  FILE *fd;
+  int counter = 0;
+  int c;
+  int is_cgroup = 0;
+
+  outbuf[0]='\0';
+  snprintf(filename, sizeof filename, "/proc/%d/cgroup", pp->tgid);
+  fd = fopen(filename, "r");
+  if (likely(fd == NULL)) goto fail;
+  while (( (c = fgetc(fd)) != EOF) && (counter<665)) {
+    if (is_cgroup == 0) {
+      if (c == ':') {
+        is_cgroup = 1;
+        if (counter>0)
+          outbuf[counter++]=';';
+      }
+    }else
+      if ((c == '\n') || (c == '\0'))
+        is_cgroup = 0;
+      else
+        outbuf[counter++]=c;
+  }
+  outbuf[counter]='\0';
+  close(fd);
+  if (counter>0) 
+    return counter;
+fail:
+  outbuf[0] = '-';
+  outbuf[1] = '\0';
+  return 1;
+}
+
 #ifdef STATICLIB
 /****************** FLASK & seLinux security stuff **********************/
 // move the bulk of this to libproc sometime
@@ -1291,6 +1325,7 @@ static const format_struct format_array[
 {"bsdtime",   "TIME",    pr_bsdtime,  sr_nop,     6,   0,    LNX, ET|RIGHT},
 {"c",         "C",       pr_c,        sr_pcpu,    2,   0,    SUN, ET|RIGHT},
 {"caught",    "CAUGHT",  pr_sigcatch, sr_nop,     9,   0,    BSD, TO|SIGNAL}, /*sigcatch*/
+{"cgroup",    "CGROUP",  pr_cgroup,   sr_nop,    35,   0,    LNX, PO|LEFT},  /* cgroups*/
 {"class",     "CLS",     pr_class,    sr_sched,   3,   0,    XXX, TO|LEFT},
 {"cls",       "CLS",     pr_class,    sr_sched,   3,   0,    HPU, TO|RIGHT}, /*says HPUX or RT*/
 {"cmaj_flt",  "-",       pr_nop,      sr_cmaj_flt, 1,  0,    LNX, AN|RIGHT},
diff -up procps-3.2.7/ps/ps.1.pom procps-3.2.7/ps/ps.1
--- procps-3.2.7/ps/ps.1.pom	2009-02-15 13:16:27.000000000 +0100
+++ procps-3.2.7/ps/ps.1	2009-02-15 14:00:33.000000000 +0100
@@ -908,6 +908,10 @@ width of the field, a 32 or 64 bits mask
 displayed.  (alias\ \fBsig_catch\fR,\ \fBsigcatch\fR).
 T}
 
+cgroup	CGROUP	T{
+display control groups to which the process belonges.
+t}
+
 class	CLS	T{
 scheduling class of the process.  (alias\ \fBpolicy\fR,\ \fBcls\fR).
 Field's possible values are:


procps-3.2.7-vmstat-partstats-long.patch:

--- NEW FILE procps-3.2.7-vmstat-partstats-long.patch ---
diff -up procps-3.2.7/proc/sysinfo.c.vmstat procps-3.2.7/proc/sysinfo.c
--- procps-3.2.7/proc/sysinfo.c.vmstat	2008-12-04 15:25:50.000000000 +0100
+++ procps-3.2.7/proc/sysinfo.c	2008-12-04 16:54:29.000000000 +0100
@@ -784,6 +784,18 @@ unsigned int getpartitions_num(struct di
 }
 
 /////////////////////////////////////////////////////////////////////////////
+static int is_disk(char *dev)
+{
+  char syspath[PATH_MAX];
+  char *slash;
+
+  while ((slash = strchr(dev, '/')))
+    *slash = '!';
+  snprintf(syspath, sizeof(syspath), "/sys/block/%s", dev);
+  return !(access(syspath, F_OK));
+}
+
+/////////////////////////////////////////////////////////////////////////////
 
 unsigned int getdiskstat(struct disk_stat **disks, struct partition_stat **partitions){
   FILE* fd;
@@ -791,6 +803,7 @@ unsigned int getdiskstat(struct disk_sta
   int cPartition = 0;
   int fields;
   unsigned dummy;
+  char devname[PATH_MAX];
 
   *disks = NULL;
   *partitions = NULL;
@@ -803,10 +816,11 @@ unsigned int getdiskstat(struct disk_sta
       fclose(fd);
       break;
     }
-    fields = sscanf(buff, " %*d %*d %*s %*u %*u %*u %*u %*u %*u %*u %*u %*u %*u %u", &dummy);
-    if (fields == 1){
+    fields = sscanf(buff, " %*d %*d %15s %*u %*u %*u %*u %*u %*u %*u %*u %*u %*u %u",
+            &devname, &dummy);
+    if (fields == 2 && is_disk(devname)){
       (*disks) = realloc(*disks, (cDisk+1)*sizeof(struct disk_stat));
-      sscanf(buff,  "   %*d    %*d %15s %u %u %llu %u %u %u %llu %u %u %u %u",
+      sscanf(buff,  "   %*d    %*d %15s %lu %lu %llu %lu %lu %lu %llu %lu %lu %lu %lu",
         //&disk_major,
         //&disk_minor,
         (*disks)[cDisk].disk_name,
@@ -827,7 +841,9 @@ unsigned int getdiskstat(struct disk_sta
     }else{
       (*partitions) = realloc(*partitions, (cPartition+1)*sizeof(struct partition_stat));
       fflush(stdout);
-      sscanf(buff,  "   %*d    %*d %15s %u %llu %u %u",
+      sscanf(buff,  (fields == 2)
+          ? "   %*d    %*d %15s %u %*u %llu %*u %u %*u %llu %*u %*u %*u %*u"
+          : "   %*d    %*d %15s %u %llu %u %llu",
         //&part_major,
         //&part_minor,
         (*partitions)[cPartition].partition_name,
diff -up procps-3.2.7/proc/sysinfo.h.vmstat procps-3.2.7/proc/sysinfo.h
--- procps-3.2.7/proc/sysinfo.h.vmstat	2008-12-04 15:25:41.000000000 +0100
+++ procps-3.2.7/proc/sysinfo.h	2008-12-04 16:54:32.000000000 +0100
@@ -95,16 +95,16 @@ typedef struct disk_stat{
 	unsigned long long reads_sectors;
 	unsigned long long written_sectors;
 	char               disk_name [16];
-	unsigned           inprogress_IO;
-	unsigned           merged_reads;
-	unsigned           merged_writes;
-	unsigned           milli_reading;
-	unsigned           milli_spent_IO;
-	unsigned           milli_writing;
-	unsigned           partitions;
-	unsigned           reads;
-	unsigned           weighted_milli_spent_IO;
-	unsigned           writes;
+	unsigned long          inprogress_IO;
+	unsigned long          merged_reads;
+	unsigned long          merged_writes;
+	unsigned long          milli_reading;
+	unsigned long          milli_spent_IO;
+	unsigned long          milli_writing;
+	unsigned long          partitions;
+	unsigned long          reads;
+	unsigned long          weighted_milli_spent_IO;
+	unsigned long          writes;
 }disk_stat;
 
 typedef struct partition_stat{
@@ -113,7 +113,7 @@ typedef struct partition_stat{
 	unsigned           parent_disk;  // index into a struct disk_stat array
 	unsigned           reads;
 	unsigned           writes;
-	unsigned           requested_writes;
+	unsigned long long requested_writes;
 }partition_stat;
 
 extern unsigned int getpartitions_num(struct disk_stat *disks, int ndisks);


Index: procps.spec
===================================================================
RCS file: /cvs/extras/rpms/procps/F-10/procps.spec,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -r1.74 -r1.75
--- procps.spec	3 Feb 2009 12:25:44 -0000	1.74
+++ procps.spec	16 Feb 2009 12:47:15 -0000	1.75
@@ -1,7 +1,7 @@
 Summary: System and process monitoring utilities
 Name: procps
 Version: 3.2.7
-Release: 22%{?dist}
+Release: 23%{?dist}
 License: GPLv2+ and LGPLv2+
 Group: Applications/System
 URL: http://procps.sourceforge.net
@@ -76,6 +76,10 @@
 Patch36: procps-3.2.7-vmstat-timestamp.patch
 #manual page updated to document the -t functionality
 Patch37: procps-3.2.7-vmstat-timestamp-manpage.patch
+#485246 vmstat -p broken
+Patch38: procps-3.2.7-vmstat-partstats-long.patch
+#add cgroup support
+Patch39: procps-3.2.7-ps-cgroup.patch
 
 BuildRequires: ncurses-devel
 
@@ -138,6 +142,8 @@
 %patch35 -p1
 %patch36 -p1
 %patch37 -p1
+%patch38 -p1
+%patch39 -p1
 
 cp %SOURCE1 .
 
@@ -175,7 +181,11 @@
 %attr(0644,root,root) %{_mandir}/man5/*
 
 %changelog
-*Tue Feb 03 2009 Daniel Novotny <dnovotny at redhat.com> 3.2.7-22
+* Mon Feb 16 2009 Daniel Novotny <dnovotny at redhat.com> 3.2.7-23
+- added cgroup support (Ivana Varekova)
+- fix #485246 (vmstat -p)
+
+* Tue Feb 03 2009 Daniel Novotny <dnovotny at redhat.com> 3.2.7-22
 - added timestamp to vmstat with new option -t (#476134)
 
 * Mon Sep 01 2008 Tomas Smetana <tsmetana at redhat.com> 3.2.7-21




More information about the fedora-extras-commits mailing list