~ubuntu-branches/debian/sid/lvm2/sid

« back to all changes in this revision

Viewing changes to lib/misc/lvm-string.c

  • Committer: Package Import Robot
  • Author(s): Bastian Blank
  • Date: 2014-08-19 15:37:06 UTC
  • mfrom: (1.1.18)
  • Revision ID: package-import@ubuntu.com-20140819153706-i1gaio8lg534dara
Tags: 2.02.109-1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#include "metadata-exported.h"
19
19
 
20
20
#include <ctype.h>
 
21
#include <stdarg.h>
21
22
 
22
23
int emit_to_buffer(char **buffer, size_t *size, const char *fmt, ...)
23
24
{
64
65
        return 1;
65
66
}
66
67
 
67
 
static int _validate_name(const char *n)
 
68
static name_error_t _validate_name(const char *n)
68
69
{
69
70
        register char c;
70
71
        register int len = 0;
71
72
 
72
73
        if (!n || !*n)
73
 
                return -1;
 
74
                return NAME_INVALID_EMPTY;
74
75
 
75
76
        /* Hyphen used as VG-LV separator - ambiguity if LV starts with it */
76
77
        if (*n == '-')
77
 
                return -2;
 
78
                return NAME_INVALID_HYPEN;
78
79
 
79
80
        if ((*n == '.') && (!n[1] || (n[1] == '.' && !n[2]))) /* ".", ".." */
80
 
                return -3;
 
81
                return NAME_INVALID_DOTS;
81
82
 
82
83
        while ((len++, c = *n++))
83
84
                if (!isalnum(c) && c != '.' && c != '_' && c != '-' && c != '+')
84
 
                        return -4;
 
85
                        return NAME_INVALID_CHARSET;
85
86
 
86
87
        if (len > NAME_LEN)
87
 
                return -5;
 
88
                return NAME_INVALID_LENGTH;
88
89
 
89
 
        return 0;
 
90
        return NAME_VALID;
90
91
}
91
92
 
92
93
/*
97
98
 */
98
99
int validate_name(const char *n)
99
100
{
100
 
        return (_validate_name(n) < 0 ? 0 : 1);
 
101
        return (_validate_name(n) == NAME_VALID) ? 1 : 0;
101
102
}
102
103
 
103
104
static const char *_lvname_has_reserved_prefix(const char *lvname)
177
178
{
178
179
        const char *lvid = lv->lvid.s;
179
180
 
180
 
        if (!layer && lv_is_thin_pool(lv))
181
 
                layer = "pool";
 
181
        if (!layer) {
 
182
                /*
 
183
                 * Mark internal LVs with layer suffix
 
184
                 * so tools like blkid may immeditelly see it's
 
185
                 * an internal LV they should not scan.
 
186
                 * Should also make internal detection simpler.
 
187
                 */
 
188
                /* Suffixes used here MUST match lib/activate/dev_manager.c */
 
189
                layer = lv_is_cache_pool_data(lv) ? "cdata" :
 
190
                        lv_is_cache_pool_metadata(lv) ? "cmeta" :
 
191
                        // FIXME: dm-tree needs fixes for mirrors/raids
 
192
                        //lv_is_mirror_image(lv) ? "mimage" :
 
193
                        //lv_is_mirror_log(lv) ? "mlog" :
 
194
                        //lv_is_raid_image(lv) ? "rimage" :
 
195
                        //lv_is_raid_metadata(lv) ? "rmeta" :
 
196
                        lv_is_thin_pool(lv) ? "pool" :
 
197
                        lv_is_thin_pool_data(lv) ? "tdata" :
 
198
                        lv_is_thin_pool_metadata(lv) ? "tmeta" :
 
199
                        NULL;
 
200
        }
182
201
 
183
202
        return dm_build_dm_uuid(mem, UUID_PREFIX, lvid, layer);
184
203
}