Description: static int64_t
mydu_getblocks(const char*path)
{
int i
int64_t sum=0
static struct stat stat_result
glob_t glob_result
static int ret
static char fullpath[PATHMAX]
if (lstat(path, &stat_result)<0) {
perror("lstat()")
return 0
}
if (!S_ISDIR(stat_result.st_mode)) {
return stat_result.st_blocks
}
/************************************************/
snprintf(fullpath, PATHMAX, " s/*", path)
ret = glob(fullpath, GLOB_NOCHECK|GLOB_NOSORT, NULL, &glob_result)
if (ret!=0) {
perror("glob()")
return 0
}
snprintf(fullpath, PATHMAX, " s/.*", path)
ret = glob(fullpath, GLOB_NOCHECK|GLOB_NOSORT|GLOB_APPEND, NULL, &glob_result)
if (ret!=0) {
perror("glob()")
return 0
}
sum+= stat_result.st_blocks
for (i=0 i<glob_result.gl_pathc ++i) {
if (isvalid(glob_result.gl_pathv[i])) {
sum+= mydu_getblocks(glob_result.gl_pathv[i])
}
}
globfree(&glob_result)
return sum
}
File list (Check if you may need any files):
65695314mydu.tar