yuezonghe | 824eb0c | 2024-06-27 02:32:26 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * getversion.c - Get a file version on an ext2 file system |
| 3 | * |
| 4 | * Copyright (C) 1993, 1994 Remy Card <card@masi.ibp.fr> |
| 5 | * Laboratoire MASI, Institut Blaise Pascal |
| 6 | * Universite Pierre et Marie Curie (Paris VI) |
| 7 | * |
| 8 | * %Begin-Header% |
| 9 | * This file may be redistributed under the terms of the GNU Library |
| 10 | * General Public License, version 2. |
| 11 | * %End-Header% |
| 12 | */ |
| 13 | |
| 14 | /* |
| 15 | * History: |
| 16 | * 93/10/30 - Creation |
| 17 | */ |
| 18 | |
| 19 | #include "config.h" |
| 20 | #if HAVE_ERRNO_H |
| 21 | #include <errno.h> |
| 22 | #endif |
| 23 | #include <sys/ioctl.h> |
| 24 | |
| 25 | #include "e2p.h" |
| 26 | |
| 27 | int getversion (int fd, unsigned long * version) |
| 28 | { |
| 29 | #if HAVE_EXT2_IOCTLS |
| 30 | int r, ver; |
| 31 | |
| 32 | r = ioctl (fd, EXT2_IOC_GETVERSION, &ver); |
| 33 | *version = ver; |
| 34 | return r; |
| 35 | #else /* ! HAVE_EXT2_IOCTLS */ |
| 36 | extern int errno; |
| 37 | errno = EOPNOTSUPP; |
| 38 | return -1; |
| 39 | #endif /* ! HAVE_EXT2_IOCTLS */ |
| 40 | } |