nfs-ganesha 1.4
|
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 "nfs_core.h" 00047 #include "log.h" 00048 #include "cache_inode.h" 00049 #include "fsal.h" 00050 #include "9p.h" 00051 00052 static char version_9p200l[] = "9P2000.L" ; 00053 00054 int _9p_version( _9p_request_data_t * preq9p, 00055 void * pworker_data, 00056 u32 * plenout, char * preply) 00057 { 00058 char * cursor = preq9p->_9pmsg + _9P_HDR_SIZE + _9P_TYPE_SIZE ; 00059 00060 u16 * msgtag = NULL ; 00061 u32 * msize = NULL ; 00062 u16 * version_len = NULL ; 00063 char * version_str = NULL ; 00064 00065 if ( !preq9p || !plenout || !preply ) 00066 return -1 ; 00067 00068 /* Get data */ 00069 _9p_getptr( cursor, msgtag, u16 ) ; 00070 _9p_getptr( cursor, msize, u32 ) ; 00071 _9p_getstr( cursor, version_len, version_str ) ; 00072 00073 LogDebug( COMPONENT_9P, "TVERSION: tag=%u msize=%u version='%.*s'", (u32)*msgtag, *msize, (int)*version_len, version_str ) ; 00074 00075 if( strncmp( version_str, version_9p200l, *version_len ) ) 00076 { 00077 LogEvent( COMPONENT_9P, "RVERSION: BAD VERSION" ) ; 00078 return _9p_rerror( preq9p, msgtag, ENOENT, plenout, preply ) ; 00079 } 00080 00081 /* Good version, build the reply */ 00082 _9p_setinitptr( cursor, preply, _9P_RVERSION ) ; 00083 _9p_setptr( cursor, msgtag, u16 ) ; 00084 00085 _9p_setptr( cursor, msize, u32 ) ; 00086 _9p_setstr( cursor, *version_len, version_str ) ; 00087 _9p_setendptr( cursor, preply ) ; 00088 _9p_checkbound( cursor, preply, plenout ) ; 00089 00090 LogDebug( COMPONENT_9P, "RVERSION: msize=%u version='%.*s'", *msize, (int)*version_len, version_str ) ; 00091 00092 return 1 ; 00093 } 00094