uint64_t val = *dirnum;
struct osl_object obj;
int ret;
+ char *pfx;
again:
obj.data = &val;
ret = osl(osl_get_object(dir_table, row, DT_NAME, &obj));
if (ret < 0)
goto out;
- if (val || conf.print_base_dir_given) {
- if (result) {
- tmp = make_message("%s/%s", (char *)obj.data, result);
- free(result);
- result = tmp;
- } else
- result = adu_strdup((char *)obj.data);
- }
+ pfx = (conf.print_base_dir_given || val)? (char *)obj.data : ".";
+ tmp = make_message("%s/%s", pfx, result? result : "");
+ free(result);
+ result = tmp;
if (val)
goto again;
out:
if (ret < 0) {
free(result);
*name = NULL;
- } else
+ } else {
+ assert(result);
*name = result;
+ }
return ret;
}
{
struct osl_object obj;
int ret;
- char *this_dir, *prefix = NULL;
*name = NULL;
- ret = osl(osl_get_object(dir_table, dir_table_row, DT_NAME, &obj));
+ ret = osl(osl_get_object(dir_table, dir_table_row, DT_NUM, &obj));
if (ret < 0)
return ret;
- this_dir = adu_strdup((char *)obj.data);
- ret = osl(osl_get_object(dir_table, dir_table_row, DT_PARENT_NUM, &obj));
- if (ret < 0)
- goto out;
- if (!*(uint64_t *)obj.data) {
- *name = this_dir;
- return 1;
- }
- ret = get_dir_name_by_number((uint64_t *)obj.data, &prefix);
- if (ret < 0)
- goto out;
- *name = make_message("%s/%s", prefix, this_dir);
- free(prefix);
- ret = 1;
-out:
- free(this_dir);
- return ret;
+ return get_dir_name_by_number((uint64_t *)obj.data, name);
}
+
static int user_stats_loop_function(struct osl_row *row, void *data)
{
struct user_stats_info *usi = data;