blob: 8880634d9f5f586aa847dac5b9a0da05945cc4f7 (
plain)
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
31
32
33
34
35
36
37
38
39
40
41
|
/*
* Linux sysfs_kernel cluster
*
* Copyright (c) 2009,2014 Red Hat.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#include "sysfs_kernel.h"
#include "indom.h"
int
refresh_sysfs_kernel(sysfs_kernel_t *sk)
{
char buf[MAXPATHLEN];
int fd, n;
snprintf(buf, sizeof(buf), "%s/sys/kernel/uevent_seqnum", linux_statspath);
if ((fd = open(buf, O_RDONLY)) < 0) {
sk->valid_uevent_seqnum = 0;
return -oserror();
}
if ((n = read(fd, buf, sizeof(buf))) <= 0)
sk->valid_uevent_seqnum = 0;
else {
buf[n-1] = '\0';
sscanf(buf, "%llu", (long long unsigned int *)&sk->uevent_seqnum);
sk->valid_uevent_seqnum = 1;
}
close(fd);
return 0;
}
|