solaris: implement blockdev size getting
authorJens Axboe <jens.axboe@oracle.com>
Tue, 4 Aug 2009 10:49:59 +0000 (12:49 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Tue, 4 Aug 2009 10:49:59 +0000 (12:49 +0200)
Just use lseek(..., SEEK_END), we should actually be able to use that
on all platforms.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
os/os-solaris.h

index f00aae1089b19380fd05d2f8017facea2847cea5..c49ce8d99abdd21f611c11ec5c90952314cd1c05 100644 (file)
@@ -28,7 +28,13 @@ typedef struct solaris_rand_seed os_random_state_t;
  */
 static inline int blockdev_size(int fd, unsigned long long *bytes)
 {
  */
 static inline int blockdev_size(int fd, unsigned long long *bytes)
 {
-       return EINVAL;
+       off_t end = lseek(fd, 0, SEEK_END);
+
+       if (end < 0)
+               return errno;
+
+       *bytes = end;
+       return 0;
 }
 
 static inline int blockdev_invalidate_cache(int fd)
 }
 
 static inline int blockdev_invalidate_cache(int fd)