"Fossies" - the Fresh Open Source Software Archive

Member "glusterfs-8.2/xlators/meta/src/options-dir.c" (16 Sep 2020, 1608 Bytes) of package /linux/misc/glusterfs-8.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "options-dir.c" see the Fossies "Dox" file reference documentation.

    1 /*
    2    Copyright (c) 2014 Red Hat, Inc. <http://www.redhat.com>
    3    This file is part of GlusterFS.
    4 
    5    This file is licensed to you under your choice of the GNU Lesser
    6    General Public License, version 3 or any later version (LGPLv3 or
    7    later), or the GNU General Public License, version 2 (GPLv2), in all
    8    cases as published by the Free Software Foundation.
    9 */
   10 
   11 #include <glusterfs/xlator.h>
   12 #include <glusterfs/defaults.h>
   13 
   14 #include "meta-mem-types.h"
   15 #include "meta.h"
   16 #include "meta-hooks.h"
   17 
   18 static int
   19 dict_key_add(dict_t *dict, char *key, data_t *value, void *data)
   20 {
   21     struct meta_dirent **direntp = data;
   22 
   23     (*direntp)->name = gf_strdup(key);
   24     (*direntp)->type = IA_IFREG;
   25     (*direntp)->hook = meta_option_file_hook;
   26 
   27     (*direntp)++;
   28     return 0;
   29 }
   30 
   31 static int
   32 options_dir_fill(xlator_t *this, inode_t *inode, struct meta_dirent **dp)
   33 {
   34     struct meta_dirent *dirent = NULL;
   35     struct meta_dirent *direntp = NULL;
   36     xlator_t *xl = NULL;
   37 
   38     xl = meta_ctx_get(inode, this);
   39 
   40     dirent = GF_CALLOC(sizeof(*dirent), xl->options->count,
   41                        gf_meta_mt_dirents_t);
   42     if (!dirent)
   43         return -1;
   44 
   45     direntp = dirent;
   46 
   47     dict_foreach(xl->options, dict_key_add, &direntp);
   48 
   49     *dp = dirent;
   50 
   51     return xl->options->count;
   52 }
   53 
   54 static struct meta_ops options_dir_ops = {.dir_fill = options_dir_fill};
   55 
   56 int
   57 meta_options_dir_hook(call_frame_t *frame, xlator_t *this, loc_t *loc,
   58                       dict_t *xdata)
   59 {
   60     meta_ctx_set(loc->inode, this, meta_ctx_get(loc->parent, this));
   61 
   62     meta_ops_set(loc->inode, this, &options_dir_ops);
   63 
   64     return 0;
   65 }