(root)/
util-linux-2.39/
libblkid/
src/
getsize.c
       1  /*
       2   * getsize.c --- get the size of a partition.
       3   *
       4   * Copyright (C) 1995, 1995 Theodore Ts'o.
       5   * Copyright (C) 2010 Karel Zak <kzak@redhat.com>
       6   *
       7   * %Begin-Header%
       8   * This file may be redistributed under the terms of the
       9   * GNU Lesser General Public License.
      10   * %End-Header%
      11   */
      12  
      13  #include <stdio.h>
      14  #include <sys/stat.h>
      15  #include <sys/types.h>
      16  
      17  #include "blkidP.h"
      18  
      19  /**
      20   * blkid_get_dev_size:
      21   * @fd: file descriptor
      22   *
      23   * Returns: size (in bytes) of the block device or size of the regular file or 0.
      24   */
      25  blkid_loff_t blkid_get_dev_size(int fd)
      26  {
      27  	unsigned long long bytes;
      28  
      29  	if (blkdev_get_size(fd, &bytes))
      30  		return 0;
      31  
      32  	return bytes;
      33  }
      34