"Fossies" - the Fresh Open Source Software Archive

Member "glusterfs-8.2/xlators/meta/src/graphs-dir.c" (16 Sep 2020, 1709 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 "graphs-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 struct meta_dirent graphs_dir_dirents[] = {
   19     DOT_DOTDOT,
   20 
   21     {
   22         .name = "active",
   23         .type = IA_IFLNK,
   24         .hook = meta_active_link_hook,
   25     },
   26     {.name = NULL}};
   27 
   28 static int
   29 graphs_dir_fill(xlator_t *this, inode_t *dir, struct meta_dirent **dp)
   30 {
   31     glusterfs_graph_t *graph = NULL;
   32     int graphs_count = 0;
   33     int i = 0;
   34     struct meta_dirent *dirents = NULL;
   35 
   36     list_for_each_entry(graph, &this->ctx->graphs, list) { graphs_count++; }
   37 
   38     dirents = GF_CALLOC(sizeof(*dirents), graphs_count + 3,
   39                         gf_meta_mt_dirents_t);
   40     if (!dirents)
   41         return -1;
   42 
   43     i = 0;
   44     list_for_each_entry(graph, &this->ctx->graphs, list)
   45     {
   46         dirents[i].name = gf_strdup(graph->graph_uuid);
   47         dirents[i].type = IA_IFDIR;
   48         dirents[i].hook = meta_graph_dir_hook;
   49         i++;
   50     }
   51 
   52     *dp = dirents;
   53 
   54     return i;
   55 }
   56 
   57 struct meta_ops graphs_dir_ops = {.fixed_dirents = graphs_dir_dirents,
   58                                   .dir_fill = graphs_dir_fill};
   59 
   60 int
   61 meta_graphs_dir_hook(call_frame_t *frame, xlator_t *this, loc_t *loc,
   62                      dict_t *xdata)
   63 {
   64     meta_ops_set(loc->inode, this, &graphs_dir_ops);
   65 
   66     return 0;
   67 }