1999-09-15 00:17:38 +04:00
|
|
|
/*
|
|
|
|
* feature.c --- convert between features and strings
|
2008-08-28 07:07:54 +04:00
|
|
|
*
|
1999-09-15 00:17:38 +04:00
|
|
|
* Copyright (C) 1999 Theodore Ts'o <tytso@mit.edu>
|
2008-08-28 07:07:54 +04:00
|
|
|
*
|
2010-05-18 05:31:56 +04:00
|
|
|
* %Begin-Header%
|
|
|
|
* This file may be redistributed under the terms of the GNU Library
|
|
|
|
* General Public License, version 2.
|
|
|
|
* %End-Header%
|
1999-09-15 00:17:38 +04:00
|
|
|
*/
|
|
|
|
|
2011-09-19 01:34:37 +04:00
|
|
|
#include "config.h"
|
1999-09-15 00:17:38 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
1999-10-26 18:29:22 +04:00
|
|
|
#include <ctype.h>
|
1999-09-15 00:17:38 +04:00
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include "e2p.h"
|
2008-08-24 07:42:46 +04:00
|
|
|
#include <ext2fs/ext2fs.h>
|
|
|
|
#include <ext2fs/jfs_user.h>
|
1999-09-15 00:17:38 +04:00
|
|
|
|
|
|
|
struct feature {
|
|
|
|
int compat;
|
|
|
|
unsigned int mask;
|
1999-10-26 18:29:22 +04:00
|
|
|
const char *string;
|
1999-09-15 00:17:38 +04:00
|
|
|
};
|
|
|
|
|
ChangeLog, Makefile.in, jump.funcs, jump.import, jump.params:
Makefile.in (uuid_time): Compile uuid_time in two steps (first create
.o, then link it against the libraries) to work around bug in a.out
linker.
dll/jump.funcs, dll/jump.import, dll/jump.params: Update a.out shared
library control files to reflect new added files.
ChangeLog, feature.c, jump.funcs:
feature.c: Make feature_list static; it shouldn't be exported.
dll/jump.funcs: Update a.out shared library control file.
ChangeLog, badblocks.c:
badblocks.c (flush_bufs): Use fsync() if the system doesn't support
fdatasync().
2000-04-07 01:51:18 +04:00
|
|
|
static struct feature feature_list[] = {
|
1999-09-15 00:17:38 +04:00
|
|
|
{ E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_DIR_PREALLOC,
|
|
|
|
"dir_prealloc" },
|
|
|
|
{ E2P_FEATURE_COMPAT, EXT3_FEATURE_COMPAT_HAS_JOURNAL,
|
|
|
|
"has_journal" },
|
|
|
|
{ E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_IMAGIC_INODES,
|
|
|
|
"imagic_inodes" },
|
2001-07-02 19:54:09 +04:00
|
|
|
{ E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_EXT_ATTR,
|
|
|
|
"ext_attr" },
|
2001-05-14 02:21:52 +04:00
|
|
|
{ E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_DIR_INDEX,
|
|
|
|
"dir_index" },
|
|
|
|
{ E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_RESIZE_INODE,
|
|
|
|
"resize_inode" },
|
2006-05-09 04:17:26 +04:00
|
|
|
{ E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_LAZY_BG,
|
|
|
|
"lazy_bg" },
|
2011-09-15 18:38:55 +04:00
|
|
|
{ E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP,
|
2011-09-15 21:38:41 +04:00
|
|
|
"snapshot_bitmap" },
|
2006-11-13 06:50:18 +03:00
|
|
|
|
1999-09-15 00:17:38 +04:00
|
|
|
{ E2P_FEATURE_RO_INCOMPAT, EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER,
|
|
|
|
"sparse_super" },
|
|
|
|
{ E2P_FEATURE_RO_INCOMPAT, EXT2_FEATURE_RO_COMPAT_LARGE_FILE,
|
|
|
|
"large_file" },
|
2006-11-13 06:50:18 +03:00
|
|
|
{ E2P_FEATURE_RO_INCOMPAT, EXT4_FEATURE_RO_COMPAT_HUGE_FILE,
|
|
|
|
"huge_file" },
|
2008-04-18 07:31:44 +04:00
|
|
|
{ E2P_FEATURE_RO_INCOMPAT, EXT4_FEATURE_RO_COMPAT_GDT_CSUM,
|
|
|
|
"uninit_bg" },
|
2006-11-13 06:50:18 +03:00
|
|
|
{ E2P_FEATURE_RO_INCOMPAT, EXT4_FEATURE_RO_COMPAT_GDT_CSUM,
|
2007-10-22 06:03:30 +04:00
|
|
|
"uninit_groups" },
|
2006-11-13 06:50:18 +03:00
|
|
|
{ E2P_FEATURE_RO_INCOMPAT, EXT4_FEATURE_RO_COMPAT_DIR_NLINK,
|
|
|
|
"dir_nlink" },
|
|
|
|
{ E2P_FEATURE_RO_INCOMPAT, EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE,
|
|
|
|
"extra_isize" },
|
2011-02-16 01:27:27 +03:00
|
|
|
{ E2P_FEATURE_RO_INCOMPAT, EXT4_FEATURE_RO_COMPAT_QUOTA,
|
|
|
|
"quota" },
|
2011-02-26 05:43:54 +03:00
|
|
|
{ E2P_FEATURE_RO_INCOMPAT, EXT4_FEATURE_RO_COMPAT_BIGALLOC,
|
|
|
|
"bigalloc"},
|
2011-09-15 18:38:55 +04:00
|
|
|
{ E2P_FEATURE_RO_INCOMPAT, EXT4_FEATURE_RO_COMPAT_METADATA_CSUM,
|
|
|
|
"metadata_csum"},
|
libext2fs, libe2p: Reserve RO_COMPAT_REPLICA feature
The replica is a feature which stores multiple copies of the key
metadata blocks so a single block failure in failure-prone media
(read: certain types of flash storage) doesn't take out the entire
file system.
Discussion on the upstream list proved not to be very positive on this
feature; the arguments were that it added complexity that wasn't
warrented, since common practice in industry is to insist on reliable
media, and if media is unreliable, you're kind of toast anyway (unless
the file system is being used as the back-end store of a cluster file
system where checksuming and data replication is happening above the
local disk file system level). So, this feature is being developed
out of tree.
We reserve the code points so that other people won't accidentally
step on them. Since it's not upstream, it's a soft reservation, but
it's not like we have any shortage of RO_COMPAT features. We are a
bit more tight on reserved inodes, but EXT2_BOOT_LOADER_INO and
EXT2_UNDEL_DIR_INO are not currently used anywhere, and
EXT2_EXCLUDE_INO is a reservation for another out-of-tree feature.
There are no features currently being discussed which require a
reserved inode, but if a need were to arise, we can claw back code
point reservations that were never used or not in tree, as those will
always be considered lower priority than in-tree features.
Cc: Aditya Kali <adityakali@google.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-02-17 22:54:47 +04:00
|
|
|
{ E2P_FEATURE_RO_INCOMPAT, EXT4_FEATURE_RO_COMPAT_REPLICA,
|
|
|
|
"replica" },
|
2006-11-13 06:50:18 +03:00
|
|
|
|
1999-09-15 00:17:38 +04:00
|
|
|
{ E2P_FEATURE_INCOMPAT, EXT2_FEATURE_INCOMPAT_COMPRESSION,
|
|
|
|
"compression" },
|
|
|
|
{ E2P_FEATURE_INCOMPAT, EXT2_FEATURE_INCOMPAT_FILETYPE,
|
|
|
|
"filetype" },
|
|
|
|
{ E2P_FEATURE_INCOMPAT, EXT3_FEATURE_INCOMPAT_RECOVER,
|
|
|
|
"needs_recovery" },
|
2001-01-14 21:10:49 +03:00
|
|
|
{ E2P_FEATURE_INCOMPAT, EXT3_FEATURE_INCOMPAT_JOURNAL_DEV,
|
|
|
|
"journal_dev" },
|
2008-04-18 07:33:05 +04:00
|
|
|
{ E2P_FEATURE_INCOMPAT, EXT3_FEATURE_INCOMPAT_EXTENTS,
|
|
|
|
"extent" },
|
2004-11-30 06:14:23 +03:00
|
|
|
{ E2P_FEATURE_INCOMPAT, EXT3_FEATURE_INCOMPAT_EXTENTS,
|
|
|
|
"extents" },
|
2002-10-20 08:38:57 +04:00
|
|
|
{ E2P_FEATURE_INCOMPAT, EXT2_FEATURE_INCOMPAT_META_BG,
|
|
|
|
"meta_bg" },
|
2006-11-13 06:50:18 +03:00
|
|
|
{ E2P_FEATURE_INCOMPAT, EXT4_FEATURE_INCOMPAT_64BIT,
|
|
|
|
"64bit" },
|
2011-09-24 21:48:55 +04:00
|
|
|
{ E2P_FEATURE_INCOMPAT, EXT4_FEATURE_INCOMPAT_MMP,
|
|
|
|
"mmp" },
|
2007-08-14 08:32:57 +04:00
|
|
|
{ E2P_FEATURE_INCOMPAT, EXT4_FEATURE_INCOMPAT_FLEX_BG,
|
2011-09-24 21:48:55 +04:00
|
|
|
"flex_bg"},
|
2012-05-12 02:39:27 +04:00
|
|
|
{ E2P_FEATURE_INCOMPAT, EXT4_FEATURE_INCOMPAT_EA_INODE,
|
|
|
|
"ea_inode"},
|
|
|
|
{ E2P_FEATURE_INCOMPAT, EXT4_FEATURE_INCOMPAT_DIRDATA,
|
|
|
|
"dirdata"},
|
|
|
|
{ E2P_FEATURE_INCOMPAT, EXT4_FEATURE_INCOMPAT_LARGEDIR,
|
|
|
|
"large_dir"},
|
|
|
|
{ E2P_FEATURE_INCOMPAT, EXT4_FEATURE_INCOMPAT_INLINEDATA,
|
|
|
|
"inline_data"},
|
1999-09-15 00:17:38 +04:00
|
|
|
{ 0, 0, 0 },
|
|
|
|
};
|
|
|
|
|
2008-08-24 07:42:46 +04:00
|
|
|
static struct feature jrnl_feature_list[] = {
|
|
|
|
{ E2P_FEATURE_COMPAT, JFS_FEATURE_COMPAT_CHECKSUM,
|
|
|
|
"journal_checksum" },
|
|
|
|
|
|
|
|
{ E2P_FEATURE_INCOMPAT, JFS_FEATURE_INCOMPAT_REVOKE,
|
|
|
|
"journal_incompat_revoke" },
|
2012-05-21 18:59:01 +04:00
|
|
|
{ E2P_FEATURE_INCOMPAT, JFS_FEATURE_INCOMPAT_64BIT,
|
|
|
|
"journal_64bit" },
|
2008-08-24 07:42:46 +04:00
|
|
|
{ E2P_FEATURE_INCOMPAT, JFS_FEATURE_INCOMPAT_ASYNC_COMMIT,
|
|
|
|
"journal_async_commit" },
|
|
|
|
{ 0, 0, 0 },
|
|
|
|
};
|
|
|
|
|
1999-10-26 18:29:22 +04:00
|
|
|
const char *e2p_feature2string(int compat, unsigned int mask)
|
1999-09-15 00:17:38 +04:00
|
|
|
{
|
|
|
|
struct feature *f;
|
|
|
|
static char buf[20];
|
|
|
|
char fchar;
|
|
|
|
int fnum;
|
|
|
|
|
|
|
|
for (f = feature_list; f->string; f++) {
|
|
|
|
if ((compat == f->compat) &&
|
|
|
|
(mask == f->mask))
|
|
|
|
return f->string;
|
|
|
|
}
|
|
|
|
switch (compat) {
|
|
|
|
case E2P_FEATURE_COMPAT:
|
|
|
|
fchar = 'C';
|
|
|
|
break;
|
|
|
|
case E2P_FEATURE_INCOMPAT:
|
|
|
|
fchar = 'I';
|
|
|
|
break;
|
|
|
|
case E2P_FEATURE_RO_INCOMPAT:
|
|
|
|
fchar = 'R';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fchar = '?';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
for (fnum = 0; mask >>= 1; fnum++);
|
|
|
|
sprintf(buf, "FEATURE_%c%d", fchar, fnum);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
1999-10-26 18:29:22 +04:00
|
|
|
int e2p_string2feature(char *string, int *compat_type, unsigned int *mask)
|
1999-09-15 00:17:38 +04:00
|
|
|
{
|
|
|
|
struct feature *f;
|
|
|
|
char *eptr;
|
|
|
|
int num;
|
|
|
|
|
|
|
|
for (f = feature_list; f->string; f++) {
|
|
|
|
if (!strcasecmp(string, f->string)) {
|
1999-10-26 18:29:22 +04:00
|
|
|
*compat_type = f->compat;
|
1999-09-15 00:17:38 +04:00
|
|
|
*mask = f->mask;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (strncasecmp(string, "FEATURE_", 8))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
switch (string[8]) {
|
|
|
|
case 'c':
|
|
|
|
case 'C':
|
1999-10-26 18:29:22 +04:00
|
|
|
*compat_type = E2P_FEATURE_COMPAT;
|
1999-09-15 00:17:38 +04:00
|
|
|
break;
|
|
|
|
case 'i':
|
|
|
|
case 'I':
|
1999-10-26 18:29:22 +04:00
|
|
|
*compat_type = E2P_FEATURE_INCOMPAT;
|
1999-09-15 00:17:38 +04:00
|
|
|
break;
|
|
|
|
case 'r':
|
|
|
|
case 'R':
|
1999-10-26 18:29:22 +04:00
|
|
|
*compat_type = E2P_FEATURE_RO_INCOMPAT;
|
1999-09-15 00:17:38 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (string[9] == 0)
|
|
|
|
return 1;
|
|
|
|
num = strtol(string+9, &eptr, 10);
|
|
|
|
if (num > 32 || num < 0)
|
|
|
|
return 1;
|
|
|
|
if (*eptr)
|
|
|
|
return 1;
|
|
|
|
*mask = 1 << num;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-08-24 07:42:46 +04:00
|
|
|
const char *e2p_jrnl_feature2string(int compat, unsigned int mask)
|
|
|
|
{
|
|
|
|
struct feature *f;
|
|
|
|
static char buf[20];
|
|
|
|
char fchar;
|
|
|
|
int fnum;
|
|
|
|
|
|
|
|
for (f = jrnl_feature_list; f->string; f++) {
|
|
|
|
if ((compat == f->compat) &&
|
|
|
|
(mask == f->mask))
|
|
|
|
return f->string;
|
|
|
|
}
|
|
|
|
switch (compat) {
|
|
|
|
case E2P_FEATURE_COMPAT:
|
|
|
|
fchar = 'C';
|
|
|
|
break;
|
|
|
|
case E2P_FEATURE_INCOMPAT:
|
|
|
|
fchar = 'I';
|
|
|
|
break;
|
|
|
|
case E2P_FEATURE_RO_INCOMPAT:
|
|
|
|
fchar = 'R';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fchar = '?';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
for (fnum = 0; mask >>= 1; fnum++);
|
|
|
|
sprintf(buf, "FEATURE_%c%d", fchar, fnum);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
int e2p_jrnl_string2feature(char *string, int *compat_type, unsigned int *mask)
|
|
|
|
{
|
|
|
|
struct feature *f;
|
|
|
|
char *eptr;
|
|
|
|
int num;
|
|
|
|
|
|
|
|
for (f = jrnl_feature_list; f->string; f++) {
|
|
|
|
if (!strcasecmp(string, f->string)) {
|
|
|
|
*compat_type = f->compat;
|
|
|
|
*mask = f->mask;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (strncasecmp(string, "FEATURE_", 8))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
switch (string[8]) {
|
|
|
|
case 'c':
|
|
|
|
case 'C':
|
|
|
|
*compat_type = E2P_FEATURE_COMPAT;
|
|
|
|
break;
|
|
|
|
case 'i':
|
|
|
|
case 'I':
|
|
|
|
*compat_type = E2P_FEATURE_INCOMPAT;
|
|
|
|
break;
|
|
|
|
case 'r':
|
|
|
|
case 'R':
|
|
|
|
*compat_type = E2P_FEATURE_RO_INCOMPAT;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (string[9] == 0)
|
|
|
|
return 1;
|
|
|
|
num = strtol(string+9, &eptr, 10);
|
|
|
|
if (num > 32 || num < 0)
|
|
|
|
return 1;
|
|
|
|
if (*eptr)
|
|
|
|
return 1;
|
|
|
|
*mask = 1 << num;
|
|
|
|
return 0;
|
|
|
|
}
|
1999-09-15 00:17:38 +04:00
|
|
|
static char *skip_over_blanks(char *cp)
|
|
|
|
{
|
|
|
|
while (*cp && isspace(*cp))
|
|
|
|
cp++;
|
|
|
|
return cp;
|
|
|
|
}
|
|
|
|
|
1999-10-26 18:29:22 +04:00
|
|
|
static char *skip_over_word(char *cp)
|
1999-09-15 00:17:38 +04:00
|
|
|
{
|
1999-10-23 05:01:09 +04:00
|
|
|
while (*cp && !isspace(*cp) && *cp != ',')
|
1999-09-15 00:17:38 +04:00
|
|
|
cp++;
|
|
|
|
return cp;
|
|
|
|
}
|
|
|
|
|
1999-10-23 05:01:09 +04:00
|
|
|
/*
|
|
|
|
* Edit a feature set array as requested by the user. The ok_array,
|
|
|
|
* if set, allows the application to limit what features the user is
|
2008-08-28 07:07:54 +04:00
|
|
|
* allowed to set or clear using this function. If clear_ok_array is set,
|
2008-02-26 22:26:01 +03:00
|
|
|
* then use it tell whether or not it is OK to clear a filesystem feature.
|
1999-10-23 05:01:09 +04:00
|
|
|
*/
|
2008-02-26 22:26:01 +03:00
|
|
|
int e2p_edit_feature2(const char *str, __u32 *compat_array, __u32 *ok_array,
|
2008-08-28 07:07:54 +04:00
|
|
|
__u32 *clear_ok_array, int *type_err,
|
2008-02-26 22:26:01 +03:00
|
|
|
unsigned int *mask_err)
|
1999-09-15 00:17:38 +04:00
|
|
|
{
|
2007-03-21 23:48:47 +03:00
|
|
|
char *cp, *buf, *next;
|
|
|
|
int neg;
|
1999-10-26 18:29:22 +04:00
|
|
|
unsigned int mask;
|
|
|
|
int compat_type;
|
2007-03-21 23:48:47 +03:00
|
|
|
int rc = 0;
|
1999-09-15 00:17:38 +04:00
|
|
|
|
2008-02-26 22:26:01 +03:00
|
|
|
if (!clear_ok_array)
|
|
|
|
clear_ok_array = ok_array;
|
|
|
|
|
|
|
|
if (type_err)
|
|
|
|
*type_err = 0;
|
|
|
|
if (mask_err)
|
|
|
|
*mask_err = 0;
|
|
|
|
|
1999-09-15 00:17:38 +04:00
|
|
|
buf = malloc(strlen(str)+1);
|
1999-10-23 05:01:09 +04:00
|
|
|
if (!buf)
|
1999-09-15 00:17:38 +04:00
|
|
|
return 1;
|
|
|
|
strcpy(buf, str);
|
2006-03-24 06:00:01 +03:00
|
|
|
for (cp = buf; cp && *cp; cp = next ? next+1 : 0) {
|
1999-09-15 00:17:38 +04:00
|
|
|
neg = 0;
|
|
|
|
cp = skip_over_blanks(cp);
|
|
|
|
next = skip_over_word(cp);
|
2008-08-28 07:07:54 +04:00
|
|
|
|
1999-09-15 00:17:38 +04:00
|
|
|
if (*next == 0)
|
|
|
|
next = 0;
|
|
|
|
else
|
|
|
|
*next = 0;
|
2006-03-24 06:00:01 +03:00
|
|
|
|
|
|
|
if ((strcasecmp(cp, "none") == 0) ||
|
|
|
|
(strcasecmp(cp, "clear") == 0)) {
|
|
|
|
compat_array[0] = 0;
|
|
|
|
compat_array[1] = 0;
|
|
|
|
compat_array[2] = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
1999-09-15 00:17:38 +04:00
|
|
|
switch (*cp) {
|
|
|
|
case '-':
|
|
|
|
case '^':
|
|
|
|
neg++;
|
2011-09-17 00:49:23 +04:00
|
|
|
/* fallthrough */
|
1999-09-15 00:17:38 +04:00
|
|
|
case '+':
|
|
|
|
cp++;
|
|
|
|
break;
|
|
|
|
}
|
2007-03-21 23:48:47 +03:00
|
|
|
if (e2p_string2feature(cp, &compat_type, &mask)) {
|
|
|
|
rc = 1;
|
|
|
|
break;
|
|
|
|
}
|
2008-02-26 22:26:01 +03:00
|
|
|
if (neg) {
|
2008-08-28 07:07:54 +04:00
|
|
|
if (clear_ok_array &&
|
2008-02-26 22:26:01 +03:00
|
|
|
!(clear_ok_array[compat_type] & mask)) {
|
|
|
|
rc = 1;
|
|
|
|
if (type_err)
|
2008-08-28 07:07:54 +04:00
|
|
|
*type_err = (compat_type |
|
2008-02-26 22:26:01 +03:00
|
|
|
E2P_FEATURE_NEGATE_FLAG);
|
|
|
|
if (mask_err)
|
|
|
|
*mask_err = mask;
|
|
|
|
break;
|
|
|
|
}
|
1999-10-26 18:29:22 +04:00
|
|
|
compat_array[compat_type] &= ~mask;
|
2008-02-26 22:26:01 +03:00
|
|
|
} else {
|
|
|
|
if (ok_array && !(ok_array[compat_type] & mask)) {
|
|
|
|
rc = 1;
|
|
|
|
if (type_err)
|
|
|
|
*type_err = compat_type;
|
|
|
|
if (mask_err)
|
|
|
|
*mask_err = mask;
|
|
|
|
break;
|
|
|
|
}
|
1999-10-26 18:29:22 +04:00
|
|
|
compat_array[compat_type] |= mask;
|
2008-02-26 22:26:01 +03:00
|
|
|
}
|
1999-09-15 00:17:38 +04:00
|
|
|
}
|
2007-03-21 23:48:47 +03:00
|
|
|
free(buf);
|
|
|
|
return rc;
|
1999-09-15 00:17:38 +04:00
|
|
|
}
|
2008-02-26 22:26:01 +03:00
|
|
|
|
|
|
|
int e2p_edit_feature(const char *str, __u32 *compat_array, __u32 *ok_array)
|
|
|
|
{
|
|
|
|
return e2p_edit_feature2(str, compat_array, ok_array, 0, 0, 0);
|
|
|
|
}
|
2008-08-24 07:42:46 +04:00
|
|
|
|
|
|
|
#ifdef TEST_PROGRAM
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
int compat, compat2, i;
|
|
|
|
unsigned int mask, mask2;
|
|
|
|
const char *str;
|
|
|
|
struct feature *f;
|
|
|
|
|
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
if (i == 0) {
|
|
|
|
f = feature_list;
|
|
|
|
printf("Feature list:\n");
|
|
|
|
} else {
|
|
|
|
printf("\nJournal feature list:\n");
|
|
|
|
f = jrnl_feature_list;
|
|
|
|
}
|
|
|
|
for (; f->string; f++) {
|
|
|
|
if (i == 0) {
|
|
|
|
e2p_string2feature((char *)f->string, &compat,
|
|
|
|
&mask);
|
|
|
|
str = e2p_feature2string(compat, mask);
|
|
|
|
} else {
|
|
|
|
e2p_jrnl_string2feature((char *)f->string,
|
|
|
|
&compat, &mask);
|
|
|
|
str = e2p_jrnl_feature2string(compat, mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\tCompat = %d, Mask = %u, %s\n",
|
|
|
|
compat, mask, f->string);
|
|
|
|
if (strcmp(f->string, str)) {
|
|
|
|
if (e2p_string2feature((char *) str, &compat2,
|
|
|
|
&mask2) ||
|
|
|
|
(compat2 != compat) ||
|
|
|
|
(mask2 != mask)) {
|
|
|
|
fprintf(stderr, "Failure!\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
#endif
|