nfs-ganesha 1.4

cache_content_truncate.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 "LRU_List.h"
00046 #include "log.h"
00047 #include "HashData.h"
00048 #include "HashTable.h"
00049 #include "fsal.h"
00050 #include "cache_inode.h"
00051 #include "cache_content.h"
00052 
00053 #include <unistd.h>
00054 #include <sys/types.h>
00055 #include <sys/param.h>
00056 #include <time.h>
00057 #include <pthread.h>
00058 #include <string.h>
00059 
00060 cache_content_status_t cache_content_truncate(cache_content_entry_t * pentry,
00061                                               fsal_size_t length,
00062                                               cache_content_client_t * pclient,
00063                                               cache_content_status_t * pstatus)
00064 {
00065   *pstatus = CACHE_CONTENT_SUCCESS;
00066 
00067   /* Perform the truncate operation */
00068   if(truncate(pentry->local_fs_entry.cache_path_data, (off_t) length) != 0)
00069     {
00070       /* Operation failed */
00071 
00072       /* LOG */
00073       LogMajor(COMPONENT_CACHE_CONTENT,
00074                         "cache_content_truncate: impossible to truncate %s on local fs, error = ( %d, '%s' )",
00075                         pentry->local_fs_entry.cache_path_data, errno, strerror(errno));
00076 
00077       /* Sets the error */
00078       *pstatus = CACHE_CONTENT_LOCAL_CACHE_ERROR;
00079     }
00080 
00081   return *pstatus;
00082 }                               /* cache_content_truncate */