1 /* 2 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana 3 * University Research and Technology 4 * Corporation. All rights reserved. 5 * Copyright (c) 2004-2011 The University of Tennessee and The University 6 * of Tennessee Research Foundation. All rights 7 * reserved. 8 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 9 * University of Stuttgart. All rights reserved. 10 * Copyright (c) 2004-2005 The Regents of the University of California. 11 * All rights reserved. 12 * Copyright (c) 2008-2018 University of Houston. All rights reserved. 13 * Copyright (c) 2018 Research Organization for Information Science 14 * and Technology (RIST). All rights reserved. 15 * $COPYRIGHT$ 16 * 17 * Additional copyrights may follow 18 * 19 * $HEADER$ 20 */ 21 22 23 #include "ompi_config.h" 24 #include "base.h" 25 #include "mpi.h" 26 #include "ompi/constants.h" 27 #include "ompi/mca/fs/fs.h" 28 29 #include <unistd.h> 30 31 /* 32 * file_get_size_ufs 33 * 34 * Function: - get_size of a file 35 * Accepts: - same arguments as MPI_File_get_size() 36 * Returns: - Success if size is retrieved 37 */ mca_fs_base_file_get_size(ompio_file_t * fh,OMPI_MPI_OFFSET_TYPE * size)38int mca_fs_base_file_get_size (ompio_file_t *fh, 39 OMPI_MPI_OFFSET_TYPE *size) 40 { 41 *size = lseek(fh->fd, 0, SEEK_END); 42 if (-1 == *size) { 43 perror ("lseek"); 44 return OMPI_ERROR; 45 } 46 47 if (-1 == (lseek(fh->fd, fh->f_offset, SEEK_SET))) { 48 perror ("lseek"); 49 return OMPI_ERROR; 50 } 51 return OMPI_SUCCESS; 52 } 53