nfs-ganesha 1.4

posixdb_lock.c

Go to the documentation of this file.
00001 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil; -*-
00002  * vim:expandtab:shiftwidth=4:tabstop=4:
00003  */
00004 #ifdef HAVE_CONFIG_H
00005 #include "config.h"
00006 #endif
00007 #include "posixdb_internal.h"
00008 #include <string.h>
00009 
00021 fsal_posixdb_status_t fsal_posixdb_lockHandleForUpdate(fsal_posixdb_conn * p_conn,      /* IN */
00022                                                        fsal_posixdb_fileinfo_t *
00023                                                        p_info /* IN */ )
00024 {
00025   result_handle_t res;
00026   fsal_posixdb_status_t st;
00027   char query[2048];
00028 
00029   BeginTransaction(p_conn);
00030 
00031   snprintf(query, 2048, "SELECT handleid, handlets, nlink, ctime, ftype "
00032            "FROM Handle WHERE deviceid=%llu AND inode=%llu "
00033            "FOR UPDATE", (unsigned long long)p_info->devid, (unsigned long long)p_info->inode);
00034 
00035   st = db_exec_sql(p_conn, query, &res);
00036   if(FSAL_POSIXDB_IS_ERROR(st))
00037     {
00038       RollbackTransaction(p_conn);
00039       return st;
00040     }
00041 
00042   mysql_free_result(res);
00043 
00044   /* Do not end the transaction, because it will be closed by the next call to a posixdb function */
00045 
00046   ReturnCodeDB(ERR_FSAL_POSIXDB_NOERR, 0);
00047 }
00048 
00058 fsal_posixdb_status_t fsal_posixdb_cancelHandleLock(fsal_posixdb_conn * p_conn /* IN */ )
00059 {
00060   RollbackTransaction(p_conn);
00061 
00062   ReturnCodeDB(ERR_FSAL_POSIXDB_NOERR, 0);
00063 }