Whamcloud - gitweb
ChangeLog, ls.c:
[tools/e2fsprogs.git] / lib / e2p / fsetversion.c
1 /*
2  * fsetversion.c        - Set 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  * This file can be redistributed under the terms of the GNU Library General
9  * Public License
10  */
11
12 /*
13  * History:
14  * 93/10/30     - Creation
15  */
16
17 #if HAVE_ERRNO_H
18 #include <errno.h>
19 #endif
20 #if HAVE_UNISTD_H
21 #include <unistd.h>
22 #endif
23 #include <fcntl.h>
24 #include <sys/ioctl.h>
25
26 #include "e2p.h"
27
28 int fsetversion (const char * name, unsigned long version)
29 {
30 #if HAVE_EXT2_IOCTLS
31         int fd, r, ver;
32
33         fd = open (name, O_RDONLY|O_NONBLOCK);
34         if (fd == -1)
35                 return -1;
36         ver = (int) version;
37         r = ioctl (fd, EXT2_IOC_SETVERSION, &ver);
38         close (fd);
39         return r;
40 #else /* ! HAVE_EXT2_IOCTLS */
41         extern int errno;
42         errno = EOPNOTSUPP;
43         return -1;
44 #endif /* ! HAVE_EXT2_IOCTLS */
45 }