"Fossies" - the Fresh Open Source Software Archive

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

    1 /*
    2   Copyright (c) 2018 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 "utime-helpers.h"
   12 #include "utime.h"
   13 
   14 void
   15 gl_timespec_get(struct timespec *ts)
   16 {
   17 #ifdef TIME_UTC
   18     timespec_get(ts, TIME_UTC);
   19 #else
   20     timespec_now_realtime(ts);
   21 #endif
   22 }
   23 
   24 void
   25 utime_update_attribute_flags(call_frame_t *frame, xlator_t *this,
   26                              glusterfs_fop_t fop)
   27 {
   28     utime_priv_t *utime_priv = NULL;
   29 
   30     if (!frame || !this) {
   31         goto out;
   32     }
   33 
   34     utime_priv = this->private;
   35 
   36     switch (fop) {
   37         case GF_FOP_SETXATTR:
   38         case GF_FOP_FSETXATTR:
   39             frame->root->flags |= MDATA_CTIME;
   40             break;
   41 
   42         case GF_FOP_FALLOCATE:
   43         case GF_FOP_ZEROFILL:
   44             frame->root->flags |= MDATA_MTIME;
   45             frame->root->flags |= MDATA_ATIME;
   46             break;
   47 
   48         case GF_FOP_OPENDIR:
   49         case GF_FOP_OPEN:
   50         case GF_FOP_READ:
   51             if (!utime_priv->noatime) {
   52                 frame->root->flags |= MDATA_ATIME;
   53             }
   54             break;
   55         case GF_FOP_MKNOD:
   56         case GF_FOP_MKDIR:
   57         case GF_FOP_SYMLINK:
   58         case GF_FOP_CREATE:
   59             frame->root->flags |= MDATA_ATIME;
   60             frame->root->flags |= MDATA_CTIME;
   61             frame->root->flags |= MDATA_MTIME;
   62             frame->root->flags |= MDATA_PAR_CTIME;
   63             frame->root->flags |= MDATA_PAR_MTIME;
   64             break;
   65 
   66         case GF_FOP_UNLINK:
   67         case GF_FOP_RMDIR:
   68             frame->root->flags |= MDATA_CTIME;
   69             frame->root->flags |= MDATA_PAR_CTIME;
   70             frame->root->flags |= MDATA_PAR_MTIME;
   71             break;
   72 
   73         case GF_FOP_WRITE:
   74             frame->root->flags |= MDATA_MTIME;
   75             frame->root->flags |= MDATA_CTIME;
   76             break;
   77 
   78         case GF_FOP_LINK:
   79         case GF_FOP_RENAME:
   80             frame->root->flags |= MDATA_CTIME;
   81             frame->root->flags |= MDATA_PAR_CTIME;
   82             frame->root->flags |= MDATA_PAR_MTIME;
   83             break;
   84 
   85         case GF_FOP_TRUNCATE:
   86         case GF_FOP_FTRUNCATE:
   87             frame->root->flags |= MDATA_CTIME;
   88             frame->root->flags |= MDATA_MTIME;
   89             break;
   90 
   91         case GF_FOP_REMOVEXATTR:
   92         case GF_FOP_FREMOVEXATTR:
   93             frame->root->flags |= MDATA_CTIME;
   94             break;
   95 
   96         case GF_FOP_COPY_FILE_RANGE:
   97             /* Below 2 are for destination fd */
   98             frame->root->flags |= MDATA_CTIME;
   99             frame->root->flags |= MDATA_MTIME;
  100             /* Below flag is for the source fd */
  101             if (!utime_priv->noatime) {
  102                 frame->root->flags |= MDATA_ATIME;
  103             }
  104             break;
  105         default:
  106             frame->root->flags = 0;
  107     }
  108 out:
  109     return;
  110 }