e2fsprogs/lib/e2p/fsetversion.c

46 lines
938 B
C
Raw Normal View History

1997-04-26 17:21:57 +04:00
/*
* fsetversion.c - Set a file version on an ext2 file system
*
* Copyright (C) 1993, 1994 Remy Card <card@masi.ibp.fr>
* Laboratoire MASI, Institut Blaise Pascal
* Universite Pierre et Marie Curie (Paris VI)
*
* This file can be redistributed under the terms of the GNU Library General
* Public License
*/
/*
* History:
* 93/10/30 - Creation
*/
1997-04-26 17:58:21 +04:00
#if HAVE_ERRNO_H
1997-04-26 17:21:57 +04:00
#include <errno.h>
1997-04-26 17:58:21 +04:00
#endif
#if HAVE_UNISTD_H
1997-04-26 17:21:57 +04:00
#include <unistd.h>
1997-04-26 17:58:21 +04:00
#endif
#include <fcntl.h>
1997-04-26 17:21:57 +04:00
#include <sys/ioctl.h>
#include "e2p.h"
int fsetversion (const char * name, unsigned long version)
{
1997-04-26 17:58:21 +04:00
#if HAVE_EXT2_IOCTLS
int fd, r, ver;
1997-04-26 17:21:57 +04:00
1997-04-26 18:37:06 +04:00
fd = open (name, O_RDONLY|O_NONBLOCK);
1997-04-26 17:21:57 +04:00
if (fd == -1)
return -1;
ver = (int) version;
r = ioctl (fd, EXT2_IOC_SETVERSION, &ver);
1997-04-26 17:21:57 +04:00
close (fd);
return r;
1997-04-26 17:58:21 +04:00
#else /* ! HAVE_EXT2_IOCTLS */
extern int errno;
errno = EOPNOTSUPP;
return -1;
#endif /* ! HAVE_EXT2_IOCTLS */
1997-04-26 17:21:57 +04:00
}