]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blobdiff - db/attrset.c
apply gettext translation to more strings
[thirdparty/xfsprogs-dev.git] / db / attrset.c
index 84193c205f6f248e799af51d7c34a78029d0d843..35fea111ce9ec3dd4a9b9b9f8eaedffa7a2a1211 100644 (file)
@@ -1,33 +1,19 @@
 /*
- * Copyright (c) 2005 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2005 Silicon Graphics, Inc.
+ * All Rights Reserved.
  *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
  * published by the Free Software Foundation.
  *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
 #include <xfs/libxfs.h>
@@ -37,6 +23,9 @@
 #include "output.h"
 #include "type.h"
 #include "init.h"
+#include "fprint.h"
+#include "faddr.h"
+#include "field.h"
 #include "inode.h"
 #include "malloc.h"
 
@@ -46,17 +35,17 @@ static void         attrset_help(void);
 
 static const cmdinfo_t attr_set_cmd =
        { "attr_set", "aset", attr_set_f, 1, -1, 0,
-         "[-r|-s|-p|-u] [-R|-C] [-v n] name",
-         "set the named attribute on the current inode", attrset_help };
+         N_("[-r|-s|-p|-u] [-n] [-R|-C] [-v n] name"),
+         N_("set the named attribute on the current inode"), attrset_help };
 static const cmdinfo_t attr_remove_cmd =
        { "attr_remove", "aremove", attr_remove_f, 1, -1, 0,
-         "[-r|-s|-p|-u] name",
-         "remove the named attribute from the current inode", attrset_help };
+         N_("[-r|-s|-p|-u] [-n] name"),
+         N_("remove the named attribute from the current inode"), attrset_help };
 
 static void
 attrset_help(void)
 {
-       dbprintf(
+       dbprintf(_(
 "\n"
 " The 'attr_set' and 'attr_remove' commands provide interfaces for debugging\n"
 " the extended attribute allocation and removal code.\n"
@@ -67,10 +56,11 @@ attrset_help(void)
 "  -u -- 'user'                (default)\n"
 "  -s -- 'secure'\n"
 "\n"
-" For attr_set, these options further define the type of set:\n"
+" For attr_set, these options further define the type of set operation:\n"
 "  -C -- 'create'    - create attribute, fail if it already exists\n"
 "  -R -- 'replace'   - replace attribute, fail if it does not exist\n"
-"\n");
+" The backward compatibility mode 'noattr2' can be emulated (-n) also.\n"
+"\n"));
 }
 
 void
@@ -93,15 +83,15 @@ attr_set_f(
        int             c, namelen, valuelen = 0, flags = 0;
 
        if (cur_typ == NULL) {
-               dbprintf("no current type\n");
+               dbprintf(_("no current type\n"));
                return 0;
        }
        if (cur_typ->typnm != TYP_INODE) {
-               dbprintf("current type is not inode\n");
+               dbprintf(_("current type is not inode\n"));
                return 0;
        }
 
-       while ((c = getopt(argc, argv, "rusCRv:")) != EOF) {
+       while ((c = getopt(argc, argv, "rusCRnv:")) != EOF) {
                switch (c) {
                /* namespaces */
                case 'r':
@@ -124,23 +114,27 @@ attr_set_f(
                        flags |= LIBXFS_ATTR_REPLACE;
                        break;
 
+               case 'n':
+                       mp->m_flags |= LIBXFS_MOUNT_COMPAT_ATTR;
+                       break;
+
                /* value length */
                case 'v':
                        valuelen = (int)strtol(optarg, &sp, 0);
                        if (*sp != '\0' || valuelen < 0 || valuelen > 64*1024) {
-                               dbprintf("bad attr_set valuelen %s\n", optarg);
+                               dbprintf(_("bad attr_set valuelen %s\n"), optarg);
                                return 0;
                        }
                        break;
 
                default:
-                       dbprintf("bad option for attr_set command\n");
+                       dbprintf(_("bad option for attr_set command\n"));
                        return 0;
                }
        }
 
        if (optind != argc - 1) {
-               dbprintf("too few options for attr_set (no name given)\n");
+               dbprintf(_("too few options for attr_set (no name given)\n"));
                return 0;
        }
 
@@ -150,7 +144,7 @@ attr_set_f(
        if (valuelen) {
                value = (char *)memalign(getpagesize(), valuelen);
                if (!value) {
-                       dbprintf("cannot allocate buffer (%d)\n", valuelen);
+                       dbprintf(_("cannot allocate buffer (%d)\n"), valuelen);
                        goto out;
                }
                memset(value, 0xfeedface, valuelen);
@@ -164,7 +158,7 @@ attr_set_f(
                goto out;
        }
 
-       if (libxfs_attr_set_int(ip, name, namelen, value, valuelen, flags)) {
+       if (libxfs_attr_set(ip, name, value, valuelen, flags)) {
                dbprintf(_("failed to set attr %s on inode %llu\n"),
                        name, (unsigned long long)iocur_top->ino);
                goto out;
@@ -174,6 +168,7 @@ attr_set_f(
        set_cur_inode(iocur_top->ino);
 
 out:
+       mp->m_flags &= ~LIBXFS_MOUNT_COMPAT_ATTR;
        if (ip)
                libxfs_iput(ip, 0);
        if (value)
@@ -191,15 +186,15 @@ attr_remove_f(
        int             c, namelen, flags = 0;
 
        if (cur_typ == NULL) {
-               dbprintf("no current type\n");
+               dbprintf(_("no current type\n"));
                return 0;
        }
        if (cur_typ->typnm != TYP_INODE) {
-               dbprintf("current type is not inode\n");
+               dbprintf(_("current type is not inode\n"));
                return 0;
        }
 
-       while ((c = getopt(argc, argv, "rus")) != EOF) {
+       while ((c = getopt(argc, argv, "rusn")) != EOF) {
                switch (c) {
                /* namespaces */
                case 'r':
@@ -214,14 +209,18 @@ attr_remove_f(
                        flags &= ~LIBXFS_ATTR_ROOT;
                        break;
 
+               case 'n':
+                       mp->m_flags |= LIBXFS_MOUNT_COMPAT_ATTR;
+                       break;
+
                default:
-                       dbprintf("bad option for attr_remove command\n");
+                       dbprintf(_("bad option for attr_remove command\n"));
                        return 0;
                }
        }
 
        if (optind != argc - 1) {
-               dbprintf("too few options for attr_remove (no name given)\n");
+               dbprintf(_("too few options for attr_remove (no name given)\n"));
                return 0;
        }
 
@@ -234,7 +233,7 @@ attr_remove_f(
                goto out;
        }
 
-       if (libxfs_attr_remove_int(ip, name, namelen, flags)) {
+       if (libxfs_attr_remove(ip, name, flags)) {
                dbprintf(_("failed to remove attr %s from inode %llu\n"),
                        name, (unsigned long long)iocur_top->ino);
                goto out;
@@ -244,6 +243,7 @@ attr_remove_f(
        set_cur_inode(iocur_top->ino);
 
 out:
+       mp->m_flags &= ~LIBXFS_MOUNT_COMPAT_ATTR;
        if (ip)
                libxfs_iput(ip, 0);
        return 0;