blob: ec6621dcc9310c5bf7c4a874c9ba4a9c11975196 [file] [log] [blame]
Theodore Ts'o3839e651997-04-26 13:21:57 +00001/*
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 *
Theodore Ts'o543547a2010-05-17 21:31:56 -04008 * %Begin-Header%
9 * This file may be redistributed under the terms of the GNU Library
10 * General Public License, version 2.
11 * %End-Header%
Theodore Ts'o3839e651997-04-26 13:21:57 +000012 */
13
14/*
15 * History:
16 * 93/10/30 - Creation
17 */
18
Theodore Ts'o50e1e101997-04-26 13:58:21 +000019#if HAVE_ERRNO_H
Theodore Ts'o3839e651997-04-26 13:21:57 +000020#include <errno.h>
Theodore Ts'o50e1e101997-04-26 13:58:21 +000021#endif
Theodore Ts'o3839e651997-04-26 13:21:57 +000022#include <sys/ioctl.h>
23
Theodore Ts'o3839e651997-04-26 13:21:57 +000024#include "e2p.h"
25
26int getversion (int fd, unsigned long * version)
27{
Theodore Ts'o50e1e101997-04-26 13:58:21 +000028#if HAVE_EXT2_IOCTLS
Theodore Ts'occe382b1998-03-09 13:07:09 +000029 int r, ver;
Theodore Ts'oefc6f622008-08-27 23:07:54 -040030
Theodore Ts'occe382b1998-03-09 13:07:09 +000031 r = ioctl (fd, EXT2_IOC_GETVERSION, &ver);
32 *version = ver;
JP Abgralle0ed7402014-03-19 19:08:39 -070033 return r;
Theodore Ts'o50e1e101997-04-26 13:58:21 +000034#else /* ! HAVE_EXT2_IOCTLS */
35 extern int errno;
36 errno = EOPNOTSUPP;
37 return -1;
38#endif /* ! HAVE_EXT2_IOCTLS */
Theodore Ts'o3839e651997-04-26 13:21:57 +000039}