2013-07-06 20:44:27 |
Hubert |
description |
In the portion of code copied below from mhddfs/main.c, version 0.1.38, the function mhdd_statfs does
stats = calloc(mhdd.cdirs, sizeof(struct statvfs));
and it should do
stats = calloc(mhdd.cdirs, mhdd.cdirs*sizeof(struct statvfs));
because they are used as arrays with stats[i] and devices[i]
I'm not 100% sure about this being an actual error, and I'm guessing this may be working with some compilers or in some circumstances, yet I think this:
int ret = statvfs(mhdd.dirs[i], stats+i); //HERE
should be replaced by this:
int ret = statvfs(mhdd.dirs[i], stats+i); //HERE
Here is the portion of code,
static int mhdd_statfs(const char *path, struct statvfs *buf)
{
int i, j;
struct statvfs * stats;
struct stat st;
dev_t * devices;
mhdd_debug(MHDD_MSG, "mhdd_statfs: %s\n", path);
stats = calloc(mhdd.cdirs, sizeof(struct statvfs)); // HERE
devices = calloc(mhdd.cdirs, sizeof(dev_t)); //HERE
for (i = 0; i < mhdd.cdirs; i++) {
int ret = statvfs(mhdd.dirs[i], stats+i); //HERE
if (ret != 0) {
free(stats);
free(devices);
return -errno;
}
ret = stat(mhdd.dirs[i], &st);
if (ret != 0) {
free(stats);
free(devices);
return -errno;
}
devices[i] = st.st_dev;
}
unsigned long
min_block = stats[0].f_bsize,
min_frame = stats[0].f_frsize;
for (i = 1; i<mhdd.cdirs; i++) {
if (min_block>stats[i].f_bsize) min_block = stats[i].f_bsize;
if (min_frame>stats[i].f_frsize) min_frame = stats[i].f_frsize;
}
...
}
/*
mhddfs - Multi HDD [FUSE] File System
Copyright (C) 2008 Dmitry E. Oboukhov <dimka@avanto.org>
...
Modified by Glenn Washburn <gwashburn@Crossroads.com>
(added support for extended attributes.)
*/ |
In the portion of code copied below from mhddfs/main.c, version 0.1.38, the function mhdd_statfs does:
stats = calloc(mhdd.cdirs, sizeof(struct statvfs));
devices = calloc(mhdd.cdirs, sizeof(dev_t));
and it should do:
stats = calloc(mhdd.cdirs, mhdd.cdirs*sizeof(struct statvfs));
devices = calloc(mhdd.cdirs, mhdd.cdirs*sizeof(dev_t));
because they are used as arrays with stats[i] and devices[i]
I'm not 100% sure about this being an actual error, and I'm guessing this may be working with some compilers or in some circumstances, yet I think this:
int ret = statvfs(mhdd.dirs[i], stats+i);
should be replaced by this:
int ret = statvfs(mhdd.dirs[i], stats[i]);
Here is the portion of code:
static int mhdd_statfs(const char *path, struct statvfs *buf)
{
int i, j;
struct statvfs * stats;
struct stat st;
dev_t * devices;
mhdd_debug(MHDD_MSG, "mhdd_statfs: %s\n", path);
stats = calloc(mhdd.cdirs, sizeof(struct statvfs)); // HERE
devices = calloc(mhdd.cdirs, sizeof(dev_t)); //HERE
for (i = 0; i < mhdd.cdirs; i++) {
int ret = statvfs(mhdd.dirs[i], stats+i); //HERE
if (ret != 0) {
free(stats);
free(devices);
return -errno;
}
ret = stat(mhdd.dirs[i], &st);
if (ret != 0) {
free(stats);
free(devices);
return -errno;
}
devices[i] = st.st_dev;
}
unsigned long
min_block = stats[0].f_bsize,
min_frame = stats[0].f_frsize;
for (i = 1; i<mhdd.cdirs; i++) {
if (min_block>stats[i].f_bsize) min_block = stats[i].f_bsize;
if (min_frame>stats[i].f_frsize) min_frame = stats[i].f_frsize;
}
...
}
/*
mhddfs - Multi HDD [FUSE] File System
Copyright (C) 2008 Dmitry E. Oboukhov <dimka@avanto.org>
...
Modified by Glenn Washburn <gwashburn@Crossroads.com>
(added support for extended attributes.)
*/ |
|
2013-07-06 21:48:18 |
Hubert |
description |
In the portion of code copied below from mhddfs/main.c, version 0.1.38, the function mhdd_statfs does:
stats = calloc(mhdd.cdirs, sizeof(struct statvfs));
devices = calloc(mhdd.cdirs, sizeof(dev_t));
and it should do:
stats = calloc(mhdd.cdirs, mhdd.cdirs*sizeof(struct statvfs));
devices = calloc(mhdd.cdirs, mhdd.cdirs*sizeof(dev_t));
because they are used as arrays with stats[i] and devices[i]
I'm not 100% sure about this being an actual error, and I'm guessing this may be working with some compilers or in some circumstances, yet I think this:
int ret = statvfs(mhdd.dirs[i], stats+i);
should be replaced by this:
int ret = statvfs(mhdd.dirs[i], stats[i]);
Here is the portion of code:
static int mhdd_statfs(const char *path, struct statvfs *buf)
{
int i, j;
struct statvfs * stats;
struct stat st;
dev_t * devices;
mhdd_debug(MHDD_MSG, "mhdd_statfs: %s\n", path);
stats = calloc(mhdd.cdirs, sizeof(struct statvfs)); // HERE
devices = calloc(mhdd.cdirs, sizeof(dev_t)); //HERE
for (i = 0; i < mhdd.cdirs; i++) {
int ret = statvfs(mhdd.dirs[i], stats+i); //HERE
if (ret != 0) {
free(stats);
free(devices);
return -errno;
}
ret = stat(mhdd.dirs[i], &st);
if (ret != 0) {
free(stats);
free(devices);
return -errno;
}
devices[i] = st.st_dev;
}
unsigned long
min_block = stats[0].f_bsize,
min_frame = stats[0].f_frsize;
for (i = 1; i<mhdd.cdirs; i++) {
if (min_block>stats[i].f_bsize) min_block = stats[i].f_bsize;
if (min_frame>stats[i].f_frsize) min_frame = stats[i].f_frsize;
}
...
}
/*
mhddfs - Multi HDD [FUSE] File System
Copyright (C) 2008 Dmitry E. Oboukhov <dimka@avanto.org>
...
Modified by Glenn Washburn <gwashburn@Crossroads.com>
(added support for extended attributes.)
*/ |
REMOVED |
|