Prevent reading of inode generation for special files
Kernel API does not support at the momement reading of generation number of special files, so do not do it. Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
This commit is contained in:
parent
05017f3e98
commit
fd08fdeeb5
32
src/evmctl.c
32
src/evmctl.c
@ -730,8 +730,8 @@ static int get_uuid(struct stat *st, char *uuid)
|
|||||||
static int calc_evm_hash(const char *file, unsigned char *hash)
|
static int calc_evm_hash(const char *file, unsigned char *hash)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
int fd, err;
|
int err;
|
||||||
uint32_t generation;
|
uint32_t generation = 0;
|
||||||
EVP_MD_CTX ctx;
|
EVP_MD_CTX ctx;
|
||||||
unsigned int mdlen;
|
unsigned int mdlen;
|
||||||
char **xattrname;
|
char **xattrname;
|
||||||
@ -740,24 +740,26 @@ static int calc_evm_hash(const char *file, unsigned char *hash)
|
|||||||
ssize_t list_size;
|
ssize_t list_size;
|
||||||
char uuid[16];
|
char uuid[16];
|
||||||
|
|
||||||
fd = open(file, 0);
|
if (lstat(file, &st)) {
|
||||||
if (fd < 0) {
|
log_err("lstat() failed\n");
|
||||||
log_err("Unable to open %s\n", file);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fstat(fd, &st)) {
|
if (S_ISREG(st.st_mode) || S_ISDIR(st.st_mode)) {
|
||||||
log_err("fstat() failed\n");
|
/* we cannot at the momement to get generation of special files..
|
||||||
return -1;
|
* kernel API does not support it */
|
||||||
|
int fd = open(file, 0);
|
||||||
|
if (fd < 0) {
|
||||||
|
log_err("Unable to open %s\n", file);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (ioctl(fd, EXT34_IOC_GETVERSION, &generation)) {
|
||||||
|
log_err("ioctl() failed\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ioctl(fd, EXT34_IOC_GETVERSION, &generation)) {
|
|
||||||
log_err("ioctl() failed\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
close(fd);
|
|
||||||
|
|
||||||
log_info("generation: %u\n", generation);
|
log_info("generation: %u\n", generation);
|
||||||
|
|
||||||
list_size = llistxattr(file, list, sizeof(list));
|
list_size = llistxattr(file, list, sizeof(list));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user