nfs-ganesha 1.4

9p_getlock.c

Go to the documentation of this file.
00001 /*
00002  * vim:expandtab:shiftwidth=8:tabstop=8:
00003  *
00004  * Copyright CEA/DAM/DIF  (2011)
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 
00035 #ifdef HAVE_CONFIG_H
00036 #include "config.h"
00037 #endif
00038 
00039 #ifdef _SOLARIS
00040 #include "solaris_port.h"
00041 #endif
00042 
00043 #include <stdio.h>
00044 #include <string.h>
00045 #include <pthread.h>
00046 #include <sys/stat.h>
00047 #include "nfs_core.h"
00048 #include "abstract_mem.h"
00049 #include "log.h"
00050 #include "cache_inode.h"
00051 #include "sal_functions.h"
00052 #include "fsal.h"
00053 #include "9p.h"
00054 
00055 int _9p_getlock( _9p_request_data_t * preq9p, 
00056                  void  * pworker_data,
00057                  u32 * plenout, 
00058                  char * preply)
00059 {
00060   char * cursor = preq9p->_9pmsg + _9P_HDR_SIZE + _9P_TYPE_SIZE ;
00061  
00062   u16  * msgtag        = NULL ;
00063   u32  * fid           = NULL ;
00064   u8   * type          = NULL ;
00065   u64  * start         = NULL ;
00066   u64  * length        = NULL ;
00067   u32  * proc_id       = NULL ;
00068   u16  * client_id_len = NULL ;
00069   char * client_id_str = NULL ;
00070 
00071   // _9p_fid_t * pfid = NULL ;
00072 
00073   if ( !preq9p || !pworker_data || !plenout || !preply )
00074    return -1 ;
00075 
00076   /* Get data */
00077   _9p_getptr( cursor, msgtag, u16 ) ; 
00078   
00079   _9p_getptr( cursor, fid,     u32 ) ; 
00080   _9p_getptr( cursor, type,    u8 )  ;
00081   _9p_getptr( cursor, start,   u64 ) ;
00082   _9p_getptr( cursor, length,  u64 ) ;
00083   _9p_getptr( cursor, proc_id, u32 ) ;
00084   _9p_getstr( cursor, client_id_len, client_id_str ) ;
00085 
00086   LogDebug( COMPONENT_9P, "TGETLOCK: tag=%u fid=%u type=%u start=%llu length=%llu proc_id=%u client=%.*s",
00087             (u32)*msgtag, *fid, *type, (unsigned long long)*start, (unsigned long long)*length, 
00088             *proc_id, *client_id_len, client_id_str ) ;
00089 
00090   if( *fid >= _9P_FID_PER_CONN )
00091    return _9p_rerror( preq9p, msgtag, ERANGE, plenout, preply ) ;
00092 
00093    // pfid = &preq9p->pconn->fids[*fid] ;
00094 
00097    /* Build the reply */
00098   _9p_setinitptr( cursor, preply, _9P_RGETLOCK ) ;
00099   _9p_setptr( cursor, msgtag, u16 ) ;
00100 
00101   _9p_setptr( cursor, type,    u8 )  ;
00102   _9p_setptr( cursor, start,   u64 ) ;
00103   _9p_setptr( cursor, length,  u64 ) ;
00104   _9p_setptr( cursor, proc_id, u32 ) ;
00105   _9p_setstr( cursor, *client_id_len, client_id_str ) ;
00106 
00107   _9p_setendptr( cursor, preply ) ;
00108   _9p_checkbound( cursor, preply, plenout ) ;
00109 
00110   LogDebug( COMPONENT_9P, "RGETLOCK: tag=%u fid=%u type=%u start=%llu length=%llu proc_id=%u client=%.*s",
00111             (u32)*msgtag, *fid, *type, (unsigned long long)*start, (unsigned long long)*length, 
00112             *proc_id, *client_id_len, client_id_str ) ;
00113 
00114   return 1 ;
00115 }
00116