Last change
on this file since 3492 was 1765, checked in by Bruno Cornec, 17 years ago |
Update to busybox 1.7.2
|
-
Property svn:eol-style
set to
native
|
File size:
1.6 KB
|
Rev | Line | |
---|
[1765] | 1 | /* vi: set sw=4 ts=4: */
|
---|
| 2 | /*
|
---|
| 3 | * fgetversion.c - Get a file version on an ext2 file system
|
---|
| 4 | * fsetversion.c - Set a file version on an ext2 file system
|
---|
| 5 | *
|
---|
| 6 | *
|
---|
| 7 | * Copyright (C) 1993, 1994 Remy Card <card@masi.ibp.fr>
|
---|
| 8 | * Laboratoire MASI, Institut Blaise Pascal
|
---|
| 9 | * Universite Pierre et Marie Curie (Paris VI)
|
---|
| 10 | *
|
---|
| 11 | * This file can be redistributed under the terms of the GNU Library General
|
---|
| 12 | * Public License
|
---|
| 13 | */
|
---|
| 14 |
|
---|
| 15 | /*
|
---|
| 16 | * History:
|
---|
| 17 | * 93/10/30 - Creation
|
---|
| 18 | */
|
---|
| 19 |
|
---|
| 20 | #ifdef HAVE_ERRNO_H
|
---|
| 21 | #include <errno.h>
|
---|
| 22 | #endif
|
---|
| 23 | #ifdef HAVE_UNISTD_H
|
---|
| 24 | #include <unistd.h>
|
---|
| 25 | #endif
|
---|
| 26 | #include <fcntl.h>
|
---|
| 27 | #include <sys/ioctl.h>
|
---|
| 28 |
|
---|
| 29 | #include "e2p.h"
|
---|
| 30 |
|
---|
| 31 | #ifdef O_LARGEFILE
|
---|
| 32 | #define OPEN_FLAGS (O_RDONLY|O_NONBLOCK|O_LARGEFILE)
|
---|
| 33 | #else
|
---|
| 34 | #define OPEN_FLAGS (O_RDONLY|O_NONBLOCK)
|
---|
| 35 | #endif
|
---|
| 36 |
|
---|
| 37 | /*
|
---|
| 38 | To do fsetversion: unsigned long *ptr_version must be set to NULL.
|
---|
| 39 | and unsigned long version must be set to a value
|
---|
| 40 | To do fgetversion: unsigned long *ptr_version must NOT be set to NULL
|
---|
| 41 | and unsigned long version is ignored.
|
---|
| 42 | TITO.
|
---|
| 43 | */
|
---|
| 44 |
|
---|
| 45 | int fgetsetversion (const char * name, unsigned long * get_version, unsigned long set_version)
|
---|
| 46 | {
|
---|
| 47 | #ifdef HAVE_EXT2_IOCTLS
|
---|
| 48 | int fd, r, ver, save_errno = 0;
|
---|
| 49 |
|
---|
| 50 | fd = open (name, OPEN_FLAGS);
|
---|
| 51 | if (fd == -1)
|
---|
| 52 | return -1;
|
---|
| 53 | if (!get_version) {
|
---|
| 54 | ver = (int) set_version;
|
---|
| 55 | r = ioctl (fd, EXT2_IOC_SETVERSION, &ver);
|
---|
| 56 | } else {
|
---|
| 57 | r = ioctl (fd, EXT2_IOC_GETVERSION, &ver);
|
---|
| 58 | *get_version = ver;
|
---|
| 59 | }
|
---|
| 60 | if (r == -1)
|
---|
| 61 | save_errno = errno;
|
---|
| 62 | close (fd);
|
---|
| 63 | if (save_errno)
|
---|
| 64 | errno = save_errno;
|
---|
| 65 | return r;
|
---|
| 66 | #else /* ! HAVE_EXT2_IOCTLS */
|
---|
| 67 | errno = EOPNOTSUPP;
|
---|
| 68 | return -1;
|
---|
| 69 | #endif /* ! HAVE_EXT2_IOCTLS */
|
---|
| 70 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.