66
66
SET_DEFAULT_FOP (symlink);
67
67
SET_DEFAULT_FOP (rename);
68
68
SET_DEFAULT_FOP (link);
69
SET_DEFAULT_FOP (chmod);
70
SET_DEFAULT_FOP (chown);
71
69
SET_DEFAULT_FOP (truncate);
72
SET_DEFAULT_FOP (utimens);
73
70
SET_DEFAULT_FOP (readv);
74
71
SET_DEFAULT_FOP (writev);
75
72
SET_DEFAULT_FOP (statfs);
82
79
SET_DEFAULT_FOP (removexattr);
83
80
SET_DEFAULT_FOP (opendir);
84
81
SET_DEFAULT_FOP (readdir);
82
SET_DEFAULT_FOP (readdirp);
85
83
SET_DEFAULT_FOP (fsyncdir);
86
84
SET_DEFAULT_FOP (access);
87
85
SET_DEFAULT_FOP (ftruncate);
92
90
SET_DEFAULT_FOP (entrylk);
93
91
SET_DEFAULT_FOP (fentrylk);
94
92
SET_DEFAULT_FOP (lookup);
95
SET_DEFAULT_FOP (fchown);
96
SET_DEFAULT_FOP (fchmod);
97
93
SET_DEFAULT_FOP (setdents);
98
94
SET_DEFAULT_FOP (getdents);
99
95
SET_DEFAULT_FOP (checksum);
96
SET_DEFAULT_FOP (rchecksum);
100
97
SET_DEFAULT_FOP (xattrop);
101
98
SET_DEFAULT_FOP (fxattrop);
102
99
SET_DEFAULT_FOP (lock_notify);
103
100
SET_DEFAULT_FOP (lock_fnotify);
101
SET_DEFAULT_FOP (setattr);
102
SET_DEFAULT_FOP (fsetattr);
104
SET_DEFAULT_MOP (log);
105
105
SET_DEFAULT_MOP (stats);
107
107
SET_DEFAULT_CBK (release);
246
246
switch (opt->type) {
247
247
case GF_OPTION_TYPE_PATH:
249
/* Make sure the given path is valid */
249
if (strstr (pair->value->data, "../")) {
250
gf_log (xl->name, GF_LOG_ERROR,
251
"invalid path given '%s'",
257
/* Make sure the given path is valid */
250
258
if (pair->value->data[0] != '/') {
251
259
gf_log (xl->name, GF_LOG_WARNING,
252
260
"option %s %s: '%s' is not an "
384
392
|| ((i < ZR_OPTION_MAX_ARRAY_SIZE)
385
393
&& (!opt->value[i]))) {
386
394
/* enter here only if
387
* 1. reached end of opt->value array and haven't validated input
395
* 1. reached end of opt->value array and haven't
389
* 2. valid input list is less than ZR_OPTION_MAX_ARRAY_SIZE and
390
* input has not matched all possible input values.
398
* 2. valid input list is less than
399
* ZR_OPTION_MAX_ARRAY_SIZE and input has not
400
* matched all possible input values.
392
402
char given_array[4096] = {0,};
393
403
for (i = 0; (i < ZR_OPTION_MAX_ARRAY_SIZE) &&
444
case GF_OPTION_TYPE_PERCENT_OR_SIZET:
446
uint32_t percent = 0;
447
uint64_t input_size = 0;
449
/* Check if the value is valid percentage */
450
if (gf_string2percent (pair->value->data,
453
gf_log (xl->name, GF_LOG_DEBUG,
454
"value given was greater than 100, "
455
"assuming this is actually a size");
456
if (gf_string2bytesize (pair->value->data,
458
/* Check the range */
459
if ((opt->min == 0) &&
461
gf_log (xl->name, GF_LOG_DEBUG,
471
if ((input_size < opt->min) ||
472
(input_size > opt->max)) {
473
gf_log (xl->name, GF_LOG_ERROR,
475
"'option %s %s' is out"
476
" of range [%"PRId64""
478
input_size, pair->key,
486
// It's not a percent or size
487
gf_log (xl->name, GF_LOG_ERROR,
488
"invalid number format \"%s\" "
490
pair->value->data, pair->key);
498
if (gf_string2bytesize (pair->value->data,
500
/* Check the range */
501
if ((opt->min == 0) && (opt->max == 0)) {
502
gf_log (xl->name, GF_LOG_DEBUG,
503
"no range check required for "
505
pair->key, pair->value->data);
510
if ((input_size < opt->min) ||
511
(input_size > opt->max)) {
512
gf_log (xl->name, GF_LOG_ERROR,
513
"'%"PRId64"' in 'option %s %s'"
514
" is out of range [%"PRId64" -"
516
input_size, pair->key,
521
// It's not a percent or size
522
gf_log (xl->name, GF_LOG_ERROR,
523
"invalid number format \"%s\" "
525
pair->value->data, pair->key);
434
534
case GF_OPTION_TYPE_TIME:
436
536
uint32_t input_time = 0;
590
691
xl->type = strdup (type);
592
asprintf (&name, "%s/%s.so", XLATORDIR, type);
693
ret = asprintf (&name, "%s/%s.so", XLATORDIR, type);
695
gf_log ("xlator", GF_LOG_ERROR, "asprintf failed");
594
699
gf_log ("xlator", GF_LOG_TRACE, "attempt to load file %s", name);
634
739
"dlsym(notify) on %s -- neglecting", dlerror ());
742
if (!(xl->dumpops = dlsym (handle, "dumpops"))) {
743
gf_log ("xlator", GF_LOG_DEBUG,
744
"dlsym(dumpops) on %s -- neglecting", dlerror ());
637
747
INIT_LIST_HEAD (&xl->volume_options);
639
749
vol_opt = CALLOC (1, sizeof (volume_opt_list_t));
720
ret = xlator_init_rec (trav->xlator);
723
gf_log (trav->xlator->name, GF_LOG_TRACE,
724
"Initialization done");
728
if (!ret && !xl->ready) {
832
if (trav->init && !trav->ready) {
833
ret = xlator_init (trav);
733
gf_log ("xlator", GF_LOG_ERROR,
835
gf_log (trav->name, GF_LOG_ERROR,
734
836
"Initialization of volume '%s' failed,"
735
837
" review your volfile again",
738
xl->init_succeeded = 1;
841
trav->init_succeeded = 1;
741
gf_log (xl->name, GF_LOG_DEBUG, "No init() found");
844
gf_log (trav->name, GF_LOG_DEBUG, "No init() found");
743
846
/* This 'xl' is checked */
915
xlator_notify (xlator_t *xl, int event, void *data, ...)
917
xlator_t *old_THIS = NULL;
923
ret = xl->notify (xl, event, data);
932
xlator_init (xlator_t *xl)
934
xlator_t *old_THIS = NULL;
811
949
xlator_tree_fini (xlator_t *xl)