File: version.c

package info (click to toggle)
raidtools2 0.90.990824-5
  • links: PTS
  • area: main
  • in suites: potato
  • size: 688 kB
  • ctags: 468
  • sloc: ansic: 2,631; makefile: 143; sh: 114
file content (30 lines) | stat: -rw-r--r-- 505 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "common.h"

int getMdVersion(struct md_version * ver) {
    int file;
    int ret;

    file = open("/dev/md0",O_RDONLY);
    if (file < 0) {
	file = open("/dev/md/0",O_RDONLY);
	if (file < 0)
		return -1;
    }

    ret = ioctl(file, RAID_VERSION, (unsigned long)ver);
    if (ret == -1) {
	if (errno == EINVAL) {
	    /* just fake it */
	    ver->major = 0;
	    ver->minor = 36;
	    ver->patchlevel = 0;
	} else {
	    close(file);
	    return -1;
	}
    }

    close(file);

    return 0;
}