"Fossies" - the Fresh Open Source Software Archive

Member "glusterfs-8.2/xlators/debug/sink/src/sink.c" (16 Sep 2020, 2192 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 "sink.c" see the Fossies "Dox" file reference documentation.

    1 /*
    2    Copyright (c) 2017 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 int32_t
   15 init(xlator_t *this)
   16 {
   17     return 0;
   18 }
   19 
   20 void
   21 fini(xlator_t *this)
   22 {
   23     return;
   24 }
   25 
   26 /*
   27  * notify - when parent sends PARENT_UP, send CHILD_UP event from here
   28  */
   29 int32_t
   30 notify(xlator_t *this, int32_t event, void *data, ...)
   31 {
   32     switch (event) {
   33         case GF_EVENT_PARENT_UP:
   34             /* Tell the parent that this xlator is up */
   35             default_notify(this, GF_EVENT_CHILD_UP, data);
   36             break;
   37         case GF_EVENT_PARENT_DOWN:
   38             /* Tell the parent that this xlator is down */
   39             default_notify(this, GF_EVENT_CHILD_DOWN, data);
   40             break;
   41         default:
   42             break;
   43     }
   44 
   45     return 0;
   46 }
   47 
   48 /*
   49  * A lookup on "/" is done while mounting or glfs_init() is performed. This
   50  * needs to return a valid directory for the root of the mountpoint.
   51  *
   52  * In case this xlator is used for more advanced debugging, it will need to be
   53  * extended to support different LOOKUPs too.
   54  */
   55 static int32_t
   56 sink_lookup(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
   57 {
   58     struct iatt stbuf = {
   59         0,
   60     };
   61     struct iatt postparent = {
   62         0,
   63     };
   64 
   65     /* the root of the volume always need to be a directory */
   66     stbuf.ia_type = IA_IFDIR;
   67 
   68     STACK_UNWIND_STRICT(lookup, frame, 0, 0, loc ? loc->inode : NULL, &stbuf,
   69                         xdata, &postparent);
   70 
   71     return 0;
   72 }
   73 
   74 struct xlator_fops fops = {
   75     .lookup = sink_lookup,
   76 };
   77 
   78 struct xlator_cbks cbks = {};
   79 
   80 struct volume_options options[] = {
   81     {.key = {NULL}},
   82 };
   83 
   84 xlator_api_t xlator_api = {
   85     .init = init,
   86     .fini = fini,
   87     .notify = notify,
   88     .op_version = {GD_OP_VERSION_3_12_0},
   89     .fops = &fops,
   90     .cbks = &cbks,
   91     .options = options,
   92     .identifier = "sink",
   93     .category = GF_TECH_PREVIEW,
   94 };