Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 Sep 2009 08:16:24 GMT
From:      Fedor Dikarev <fedor.dikarev@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/139203: sysutils/freebsd-snapshot more careful patch not depending of LANG/LC_ALL
Message-ID:  <200909280816.n8S8GOSV036542@www.freebsd.org>
Resent-Message-ID: <200909280820.n8S8K1Lc086456@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         139203
>Category:       ports
>Synopsis:       sysutils/freebsd-snapshot more careful patch not depending of LANG/LC_ALL
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Sep 28 08:20:00 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     Fedor Dikarev
>Release:        7.2
>Organization:
Rambler
>Environment:
FreeBSD net.park.rambler.ru 7.2-STABLE FreeBSD 7.2-STABLE #1: Tue Jun  2 10:49:29 MSD 2009     root@net.park.rambler.ru:/usr/obj/usr/src/sys/MNGMT  amd64

>Description:
This is another way to solve bug ports/137105 (http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/137105)

But it's not only fix those bug, it make code more neatly, and allow to use different languages depending of user sets LANG/LC_ALL in the future.

So with current version snapshot program output is always as LC_ALL=C. With my version, output depends on user settings, so it's more flexible.
>How-To-Repeat:
Problem in original "snapshot":

LANG="ru_RU.KOI8-R" ~/snapshot.orig.orig -v list
Filesystem      Type     User   User%     Snap   Snap%  Snapshot Name   Snapshot Time
/                ufs    661MB   66,9%      5MB    0,6%  test.0          2009-07-01T14:02
/home            ufs      5GB   68,2%      1GB   19,8%  test.1          2009-07-01T14:03
/home            ufs      5GB   68,2%      9MB    0,1%  test.0          2009-07-01T14:10
[: 88,6: bad number
[: 88,6: bad number
/zraid/rrd       zfs      4GB    0,2%   88,6KB    0,0%  test.1          2009-07-01T13:19
[: 88,6: bad number
[: 88,6: bad number
/zraid/rrd       zfs      4GB    0,2%   88,6KB    0,0%  test.0          2009-07-01T13:20
/zraid/svn       zfs     35MB    0,0%      0KB    0,0%  dump1           2009-06-09T10:07
/zraid/svn       zfs     35MB    0,0%      0KB    0,0%  dump2           2009-06-09T10:07

>Fix:
Using option "-p", when running "zfs get" commands

Patch attached with submission follows:

--- snapshot    2009-09-28 11:58:03.000000000 +0400
+++ snapshot.orig       2009-09-28 11:59:40.000000000 +0400
@@ -30,6 +30,8 @@

 #   make sure system tools are used first
 PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/sbin:$PATH"
+LC_ALL=C
+LANG=C

 #   option defaults
 verbose=no
@@ -165,12 +167,19 @@
                 #   determine sizes
                 fs_size=`df -k $fs_dir | tail -n1 | awk '{ print $2; }'`
                 used_size=`df -k $fs_dir | tail -n1 | awk '{ print $3; }'`
-                snap_size=`zfs get -H -p -o value used $snap | sed -e 's;\.[0-9][0-9]*;;'`
+                snap_size=`zfs get -H -o value used $snap | sed -e 's;\.[0-9][0-9]*;;'`
+                case "$snap_size" in
+                    *B ) snap_size=`echo "$snap_size" | sed -e 's;B$;;'`; snap_size=$(($snap_size / 1024))               ;;
+                    *K ) snap_size=`echo "$snap_size" | sed -e 's;K$;;'`                                                 ;;
+                    *M ) snap_size=`echo "$snap_size" | sed -e 's;M$;;'`; snap_size=$(($snap_size * 1024))               ;;
+                    *G ) snap_size=`echo "$snap_size" | sed -e 's;G$;;'`; snap_size=$(($snap_size * 1024 * 1024))        ;;
+                    *T ) snap_size=`echo "$snap_size" | sed -e 's;T$;;'`; snap_size=$(($snap_size * 1024 * 1024 * 1024)) ;;
+                esac

                 #   determine snapshot creation time
                 if [ ".$verbose" = .yes ]; then
-                    snap_time=`zfs get -H -p -o value creation $snap`
-                    snap_time=`date -r "$snap_time" "+%Y-%m-%dT%H:%M"`
+                    snap_time=`zfs get -H -o value creation $snap`
+                    snap_time=`date -j -f "%a %b %d %H:%M %Y" "$snap_time" "+%Y-%m-%dT%H:%M"`
                 fi

                 #   calculate percentages


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200909280816.n8S8GOSV036542>