cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] conga/ricci/modules/storage parted_wrapper.cpp
@ 2007-03-09  4:15 rmccabe
  0 siblings, 0 replies; 6+ messages in thread
From: rmccabe @ 2007-03-09  4:15 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Branch: 	RHEL5
Changes by:	rmccabe at sourceware.org	2007-03-09 04:15:57

Modified files:
	ricci/modules/storage: parted_wrapper.cpp 

Log message:
	work around parted brain damage (it uses "new," 10^n" $prefixbytes)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/parted_wrapper.cpp.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.8&r2=1.8.2.1

--- conga/ricci/modules/storage/parted_wrapper.cpp	2006/10/06 03:10:13	1.8
+++ conga/ricci/modules/storage/parted_wrapper.cpp	2007/03/09 04:15:57	1.8.2.1
@@ -242,6 +242,8 @@
 {
   vector<String> args;
   args.push_back(pt_path);
+  args.push_back("unit");
+  args.push_back("B");
   args.push_back("print");
   args.push_back("-s");
   String out, err;
@@ -594,8 +596,8 @@
   long long bbb;
   list<PartedPartition> parts = plain_partitions(pt_path, aaa, bbb);
   
-  seg_begin = seg_begin / 1024 / 1024;
-  long long seg_end   = seg_begin + size / 1024 / 1024;
+  seg_begin = seg_begin / 1000000;
+  long long seg_end   = seg_begin + size / 1000000;
   
   vector<String> args;
   args.push_back("-s");
@@ -663,20 +665,21 @@
 {
   String s = utils::to_lower(utils::strip(size_str));
   long long multiplier;
+  // parted defines 1KB as 1000 bytes.
   if (s.find("b") == s.npos)
-    multiplier = 1024 * 1024;  // by old parted behavior, size is in MB
+    multiplier = 1000000;  // by old parted behavior, size is in MB
   else {
     if (s.size() < 3)
       throw String("parted size has an invalid value: ") + s;
     multiplier = 1;
     if (s[s.size()-2] == 'k')
-      multiplier = 1024;
+      multiplier = 1000;
     else if (s[s.size()-2] == 'm')
-      multiplier = 1024 * 1024;
+      multiplier = 1000000;
     else if (s[s.size()-2] == 'g')
-      multiplier = 1024 * 1024 * 1024;
+      multiplier = 1000000000;
     else if (s[s.size()-2] == 't')
-      multiplier = 1024 * 1024 * 1024 * 1024;
+      multiplier = 1000000000000;
   }
   
   return (long long) utils::to_float(s) * multiplier;



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Cluster-devel] conga/ricci/modules/storage parted_wrapper.cpp
@ 2007-03-09  4:17 rmccabe
  0 siblings, 0 replies; 6+ messages in thread
From: rmccabe @ 2007-03-09  4:17 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Branch: 	RHEL4
Changes by:	rmccabe at sourceware.org	2007-03-09 04:17:56

Modified files:
	ricci/modules/storage: parted_wrapper.cpp 

Log message:
	work around parted brain damage (it uses "new," 10^n" $prefixbytes)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/parted_wrapper.cpp.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.8&r2=1.8.4.1

--- conga/ricci/modules/storage/parted_wrapper.cpp	2006/10/06 03:10:13	1.8
+++ conga/ricci/modules/storage/parted_wrapper.cpp	2007/03/09 04:17:56	1.8.4.1
@@ -594,8 +594,8 @@
   long long bbb;
   list<PartedPartition> parts = plain_partitions(pt_path, aaa, bbb);
   
-  seg_begin = seg_begin / 1024 / 1024;
-  long long seg_end   = seg_begin + size / 1024 / 1024;
+  seg_begin = seg_begin / 1000000;
+  long long seg_end   = seg_begin + size / 1000000;
   
   vector<String> args;
   args.push_back("-s");
@@ -663,20 +663,21 @@
 {
   String s = utils::to_lower(utils::strip(size_str));
   long long multiplier;
+  // parted defines 1KB as 1000 bytes.
   if (s.find("b") == s.npos)
-    multiplier = 1024 * 1024;  // by old parted behavior, size is in MB
+    multiplier = 1000000;  // by old parted behavior, size is in MB
   else {
     if (s.size() < 3)
       throw String("parted size has an invalid value: ") + s;
     multiplier = 1;
     if (s[s.size()-2] == 'k')
-      multiplier = 1024;
+      multiplier = 1000;
     else if (s[s.size()-2] == 'm')
-      multiplier = 1024 * 1024;
+      multiplier = 1000000;
     else if (s[s.size()-2] == 'g')
-      multiplier = 1024 * 1024 * 1024;
+      multiplier = 1000000000;
     else if (s[s.size()-2] == 't')
-      multiplier = 1024 * 1024 * 1024 * 1024;
+      multiplier = 1000000000000;
   }
   
   return (long long) utils::to_float(s) * multiplier;



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Cluster-devel] conga/ricci/modules/storage parted_wrapper.cpp
@ 2007-03-09  4:19 rmccabe
  0 siblings, 0 replies; 6+ messages in thread
From: rmccabe @ 2007-03-09  4:19 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2007-03-09 04:19:12

Modified files:
	ricci/modules/storage: parted_wrapper.cpp 

Log message:
	work around parted brain damage (it uses "new," 10^n" $prefixbytes)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/parted_wrapper.cpp.diff?cvsroot=cluster&r1=1.8&r2=1.9

--- conga/ricci/modules/storage/parted_wrapper.cpp	2006/10/06 03:10:13	1.8
+++ conga/ricci/modules/storage/parted_wrapper.cpp	2007/03/09 04:19:12	1.9
@@ -242,6 +242,8 @@
 {
   vector<String> args;
   args.push_back(pt_path);
+  args.push_back("unit");
+  args.push_back("B");
   args.push_back("print");
   args.push_back("-s");
   String out, err;
@@ -594,8 +596,8 @@
   long long bbb;
   list<PartedPartition> parts = plain_partitions(pt_path, aaa, bbb);
   
-  seg_begin = seg_begin / 1024 / 1024;
-  long long seg_end   = seg_begin + size / 1024 / 1024;
+  seg_begin = seg_begin / 1000000;
+  long long seg_end   = seg_begin + size / 1000000;
   
   vector<String> args;
   args.push_back("-s");
@@ -663,20 +665,21 @@
 {
   String s = utils::to_lower(utils::strip(size_str));
   long long multiplier;
+  // parted defines 1KB as 1000 bytes.
   if (s.find("b") == s.npos)
-    multiplier = 1024 * 1024;  // by old parted behavior, size is in MB
+    multiplier = 1000000;  // by old parted behavior, size is in MB
   else {
     if (s.size() < 3)
       throw String("parted size has an invalid value: ") + s;
     multiplier = 1;
     if (s[s.size()-2] == 'k')
-      multiplier = 1024;
+      multiplier = 1000;
     else if (s[s.size()-2] == 'm')
-      multiplier = 1024 * 1024;
+      multiplier = 1000000;
     else if (s[s.size()-2] == 'g')
-      multiplier = 1024 * 1024 * 1024;
+      multiplier = 1000000000;
     else if (s[s.size()-2] == 't')
-      multiplier = 1024 * 1024 * 1024 * 1024;
+      multiplier = 1000000000000;
   }
   
   return (long long) utils::to_float(s) * multiplier;



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Cluster-devel] conga/ricci/modules/storage parted_wrapper.cpp
@ 2007-03-20 15:31 kupcevic
  0 siblings, 0 replies; 6+ messages in thread
From: kupcevic @ 2007-03-20 15:31 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	kupcevic at sourceware.org	2007-03-20 15:31:20

Modified files:
	ricci/modules/storage: parted_wrapper.cpp 

Log message:
	storage module: long long constant int to long long int conversion error? C idiocy

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/parted_wrapper.cpp.diff?cvsroot=cluster&r1=1.9&r2=1.10

--- conga/ricci/modules/storage/parted_wrapper.cpp	2007/03/09 04:19:12	1.9
+++ conga/ricci/modules/storage/parted_wrapper.cpp	2007/03/20 15:31:20	1.10
@@ -596,8 +596,9 @@
   long long bbb;
   list<PartedPartition> parts = plain_partitions(pt_path, aaa, bbb);
   
-  seg_begin = seg_begin / 1000000;
-  long long seg_end   = seg_begin + size / 1000000;
+  // parted defines 1KB as 1000 bytes
+  seg_begin = seg_begin / 1000 / 1000;
+  long long seg_end   = seg_begin + size / 1000 / 1000;
   
   vector<String> args;
   args.push_back("-s");
@@ -667,7 +668,7 @@
   long long multiplier;
   // parted defines 1KB as 1000 bytes.
   if (s.find("b") == s.npos)
-    multiplier = 1000000;  // by old parted behavior, size is in MB
+    multiplier = 1000 * 1000;  // by old parted behavior, size is in MB
   else {
     if (s.size() < 3)
       throw String("parted size has an invalid value: ") + s;
@@ -675,11 +676,11 @@
     if (s[s.size()-2] == 'k')
       multiplier = 1000;
     else if (s[s.size()-2] == 'm')
-      multiplier = 1000000;
+      multiplier = 1000 * 1000;
     else if (s[s.size()-2] == 'g')
-      multiplier = 1000000000;
+      multiplier = 1000 * 1000 * 1000;
     else if (s[s.size()-2] == 't')
-      multiplier = 1000000000000;
+      multiplier = 1000 * 1000 * 1000 * 1000;
   }
   
   return (long long) utils::to_float(s) * multiplier;



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Cluster-devel] conga/ricci/modules/storage parted_wrapper.cpp
@ 2007-03-20 15:48 kupcevic
  0 siblings, 0 replies; 6+ messages in thread
From: kupcevic @ 2007-03-20 15:48 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Branch: 	RHEL4
Changes by:	kupcevic at sourceware.org	2007-03-20 15:48:30

Modified files:
	ricci/modules/storage: parted_wrapper.cpp 

Log message:
	storage module: long long constant int to long long int conversion error? C idiocy

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/parted_wrapper.cpp.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.8.4.1&r2=1.8.4.2

--- conga/ricci/modules/storage/parted_wrapper.cpp	2007/03/09 04:17:56	1.8.4.1
+++ conga/ricci/modules/storage/parted_wrapper.cpp	2007/03/20 15:48:29	1.8.4.2
@@ -594,8 +594,9 @@
   long long bbb;
   list<PartedPartition> parts = plain_partitions(pt_path, aaa, bbb);
   
-  seg_begin = seg_begin / 1000000;
-  long long seg_end   = seg_begin + size / 1000000;
+  // parted defines 1KB as 1000 bytes
+  seg_begin = seg_begin / 1000 / 1000;
+  long long seg_end   = seg_begin + size / 1000 / 1000;
   
   vector<String> args;
   args.push_back("-s");
@@ -665,7 +666,7 @@
   long long multiplier;
   // parted defines 1KB as 1000 bytes.
   if (s.find("b") == s.npos)
-    multiplier = 1000000;  // by old parted behavior, size is in MB
+    multiplier = 1000 * 1000;  // by old parted behavior, size is in MB
   else {
     if (s.size() < 3)
       throw String("parted size has an invalid value: ") + s;
@@ -673,11 +674,11 @@
     if (s[s.size()-2] == 'k')
       multiplier = 1000;
     else if (s[s.size()-2] == 'm')
-      multiplier = 1000000;
+      multiplier = 1000 * 1000;
     else if (s[s.size()-2] == 'g')
-      multiplier = 1000000000;
+      multiplier = 1000 * 1000 * 1000;
     else if (s[s.size()-2] == 't')
-      multiplier = 1000000000000;
+      multiplier = 1000 * 1000 * 1000 * 1000;
   }
   
   return (long long) utils::to_float(s) * multiplier;



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Cluster-devel] conga/ricci/modules/storage parted_wrapper.cpp
@ 2007-03-20 16:17 kupcevic
  0 siblings, 0 replies; 6+ messages in thread
From: kupcevic @ 2007-03-20 16:17 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Branch: 	RHEL5
Changes by:	kupcevic at sourceware.org	2007-03-20 16:17:36

Modified files:
	ricci/modules/storage: parted_wrapper.cpp 

Log message:
	storage module: long long constant int to long long int conversion error? C idiocy

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/parted_wrapper.cpp.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.8.2.1&r2=1.8.2.2

--- conga/ricci/modules/storage/parted_wrapper.cpp	2007/03/09 04:15:57	1.8.2.1
+++ conga/ricci/modules/storage/parted_wrapper.cpp	2007/03/20 16:17:35	1.8.2.2
@@ -596,8 +596,9 @@
   long long bbb;
   list<PartedPartition> parts = plain_partitions(pt_path, aaa, bbb);
   
-  seg_begin = seg_begin / 1000000;
-  long long seg_end   = seg_begin + size / 1000000;
+  // parted defines 1KB as 1000 bytes
+  seg_begin = seg_begin / 1000 / 1000;
+  long long seg_end   = seg_begin + size / 1000 / 1000;
   
   vector<String> args;
   args.push_back("-s");
@@ -667,7 +668,7 @@
   long long multiplier;
   // parted defines 1KB as 1000 bytes.
   if (s.find("b") == s.npos)
-    multiplier = 1000000;  // by old parted behavior, size is in MB
+    multiplier = 1000 * 1000;  // by old parted behavior, size is in MB
   else {
     if (s.size() < 3)
       throw String("parted size has an invalid value: ") + s;
@@ -675,11 +676,11 @@
     if (s[s.size()-2] == 'k')
       multiplier = 1000;
     else if (s[s.size()-2] == 'm')
-      multiplier = 1000000;
+      multiplier = 1000 * 1000;
     else if (s[s.size()-2] == 'g')
-      multiplier = 1000000000;
+      multiplier = 1000 * 1000 * 1000;
     else if (s[s.size()-2] == 't')
-      multiplier = 1000000000000;
+      multiplier = 1000 * 1000 * 1000 * 1000;
   }
   
   return (long long) utils::to_float(s) * multiplier;



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-03-20 16:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-20 16:17 [Cluster-devel] conga/ricci/modules/storage parted_wrapper.cpp kupcevic
  -- strict thread matches above, loose matches on Subject: below --
2007-03-20 15:48 kupcevic
2007-03-20 15:31 kupcevic
2007-03-09  4:19 rmccabe
2007-03-09  4:17 rmccabe
2007-03-09  4:15 rmccabe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).