You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ig...@apache.org on 2013/01/15 16:37:48 UTC

[2/4] git commit: remove old, obsolete ways of retrieving disk-size information

remove old, obsolete ways of retrieving disk-size information

on FreeBSD there used to be very arcane handling of disk related
information. Starting 5.1 this was all obsoleted, our code however,
having been stashed, was not updated.
This commit simplified the retrieval of the size information,
using phk's ~src/usr.sbin/diskinfo code as example.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/dc8c5550
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/dc8c5550
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/dc8c5550

Branch: refs/heads/3.2.x
Commit: dc8c5550ae369ec5ac5d24e94df89fccfdab2dac
Parents: a5f590b
Author: Igor Galic <i....@brainsware.org>
Authored: Fri Oct 12 21:40:36 2012 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Tue Jan 15 16:22:51 2013 +0100

----------------------------------------------------------------------
 iocore/cache/Store.cc |   54 ++++---------------------------------------
 1 files changed, 5 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dc8c5550/iocore/cache/Store.cc
----------------------------------------------------------------------
diff --git a/iocore/cache/Store.cc b/iocore/cache/Store.cc
index 35a7eed..740f43d 100644
--- a/iocore/cache/Store.cc
+++ b/iocore/cache/Store.cc
@@ -374,8 +374,8 @@ Store::write_config_data(int fd)
 #include <sys/param.h>
 #include <sys/mount.h>
 #if defined(freebsd)
+#include <sys/disk.h>
 #include <sys/disklabel.h>
-//#include <sys/diskslice.h>
 #elif defined(darwin)
 #include <sys/disk.h>
 #include <sys/statvfs.h>
@@ -447,57 +447,13 @@ Span::init(char *an, int64_t size)
 
   case S_IFBLK:{
   case S_IFCHR:
-      struct disklabel dl;
-      struct diskslices ds;
-      if (ioctl(fd, DIOCGDINFO, &dl) < 0) {
-      lvolError:
-        Warning("unable to get label information for '%s': %s", n, strerror(errno));
+      if (ioctl(fd, DIOCGMEDIASIZE, &size) < 0) {
+        Warning("unable to get disk information for '%s': %s", n, strerror(errno));
         err = "unable to get label information";
         goto Lfail;
       }
-      {
-        char *s1 = n, *s2;
-        int slice = -1, part = -1;
-        if ((s2 = strrchr(s1, '/')))
-          s1 = s2 + 1;
-        else
-          goto lvolError;
-        for (s2 = s1; *s2 && !ParseRules::is_digit(*s2); s2++);
-        if (!*s2 || s2 == s1)
-          goto lvolError;
-        while (ParseRules::is_digit(*++s2));
-        s1 = s2;
-        if (*s2 == 's') {
-          slice = ink_atoi(s2 + 1);
-          if (slice<1 || slice> MAX_SLICES - BASE_SLICE)
-            goto lvolError;
-          slice = BASE_SLICE + slice - 1;
-          while (ParseRules::is_digit(*++s2));
-        }
-        if (*s2 >= 'a' && *s2 <= 'a' + MAXPARTITIONS - 1) {
-          if (slice == -1)
-            slice = COMPATIBILITY_SLICE;
-          part = *s2++ - 'a';
-        }
-        if (slice >= 0) {
-          if (ioctl(fd, DIOCGSLICEINFO, &ds) < 0)
-            goto lvolError;
-          if (slice >= (int) ds.dss_nslices || !ds.dss_slices[slice].ds_size)
-            goto lvolError;
-          fsize = (int64_t) ds.dss_slices[slice].ds_size * dl.d_secsize;
-        } else {
-          if (part < 0)
-            goto lvolError;
-          // This is odd, the dl struct isn't defined anywhere ...
-          fsize = (int64_t) dl.d_partitions[part].p_size * dl.d_secsize;
-        }
-        devnum = s.st_rdev;
-        if (size <= 0)
-          size = fsize;
-        if (size > fsize)
-          size = fsize;
-        break;
-      }
+      devnum = s.st_rdev;
+      break;
     }
   case S_IFDIR:
   case S_IFREG: