nfs-ganesha 1.4

cache_inode_getattr.c

Go to the documentation of this file.
00001 /*
00002  * vim:expandtab:shiftwidth=8:tabstop=8:
00003  *
00004  * Copyright CEA/DAM/DIF  (2008)
00005  * contributeur : Philippe DENIEL   philippe.deniel@cea.fr
00006  *                Thomas LEIBOVICI  thomas.leibovici@cea.fr
00007  *
00008  *
00009  * This program is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 3 of the License, or (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017  * Lesser General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU Lesser General Public
00020  * License along with this library; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00022  *
00023  * ---------------------------------------
00024  */
00025 
00037 #ifdef HAVE_CONFIG_H
00038 #include "config.h"
00039 #endif
00040 
00041 #ifdef _SOLARIS
00042 #include "solaris_port.h"
00043 #endif                          /* _SOLARIS */
00044 
00045 #include "log.h"
00046 #include "HashData.h"
00047 #include "HashTable.h"
00048 #include "fsal.h"
00049 #include "cache_inode.h"
00050 
00051 #include <unistd.h>
00052 #include <sys/types.h>
00053 #include <sys/param.h>
00054 #include <time.h>
00055 #include <pthread.h>
00056 #include <assert.h>
00057 
00075 cache_inode_status_t
00076 cache_inode_getattr(cache_entry_t *entry,
00077                     fsal_attrib_list_t *attr, /* XXX Change this so
00078                                                 * we don't just copy
00079                                                 * stuff on the stack. */
00080                     fsal_op_context_t *context,
00081                     cache_inode_status_t *status)
00082 {
00083      /* sanity check */
00084      if(entry == NULL || attr == NULL || context == NULL) {
00085           *status = CACHE_INODE_INVALID_ARGUMENT;
00086           LogDebug(COMPONENT_CACHE_INODE,
00087                    "cache_inode_getattr: returning "
00088                    "CACHE_INODE_INVALID_ARGUMENT because of bad arg");
00089           return *status;
00090      }
00091 
00092      /* Set the return default to CACHE_INODE_SUCCESS */
00093      *status = CACHE_INODE_SUCCESS;
00094 
00095 /* Lock (and refresh if necessary) the attributes, copy them out, and
00096    unlock. */
00097 
00098      if ((*status
00099           = cache_inode_lock_trust_attrs(entry,
00100                                          context))
00101          != CACHE_INODE_SUCCESS) {
00102           goto out;
00103      }
00104 
00105      *attr = entry->attributes;
00106 
00107      pthread_rwlock_unlock(&entry->attr_lock);
00108 
00109 out:
00110 
00111     return *status;
00112 }