1234567891011121314151617181920212223242526272829303132333435363738(*
* Copyright (C) 2011-2013 Citrix Inc
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; version 2.1 only. with the special
* exception on linking described in file LICENSE.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*)letuse_unbuffered=reffalseexternalopenfile_unbuffered:string->bool->int->Unix.file_descr="stub_openfile_direct"letopenfile_bufferedfilenamerwperm=Unix.openfilefilename([ifrwthenUnix.O_RDWRelseUnix.O_RDONLY])permletopenfilefilenamerwperm=(if!use_unbufferedthenopenfile_unbufferedelseopenfile_buffered)filenamerwpermexternalblkgetsize64:string->int64="stub_blkgetsize64"letget_file_sizex=letst=Unix.LargeFile.statxinmatchst.Unix.LargeFile.st_kindwith|Unix.S_REG->st.Unix.LargeFile.st_size|Unix.S_BLK->blkgetsize64x|_->failwith(Printf.sprintf"get_file_size: %s not a file or block device"x)externalfsync:Unix.file_descr->unit="stub_fsync"externallseek_data:Unix.file_descr->int64->int64="stub_lseek64_data"externallseek_hole:Unix.file_descr->int64->int64="stub_lseek64_hole"