int osl_errno;
};
+struct user_summary_line_info {
+ struct format_info *fi;
+ uint32_t count;
+};
static FILE *output_file;
static int print_user_summary_line(struct user_info *ui, void *data)
{
- struct format_info *fi = data;
+ struct user_summary_line_info *usli = data;
union atom_value values[] = {
[usa_pw_name] = {.string_value = ui->pw_name?
ui->pw_name : "?"},
[usa_size] = {.num_value = (long long unsigned)ui->bytes}
};
char *buf;
- int ret;
+ int ret = -E_LOOP_COMPLETE;
- buf = format_items(fi, values);
+ if (!usli->count)
+ return ret;
+
+ buf = format_items(usli->fi, values);
ret = output("%s", buf);
free(buf);
+ usli->count--;
return ret;
}
{
int ret;
int (*comp)(struct user_info *a, struct user_info *b);
+ struct user_summary_line_info usli = {
+ .fi = fi,
+ .count = select_conf.limit_arg
+ };
if (!select_conf.no_headers_given) {
ret = output("User summary\n");
break;
}
sort_hash_table(comp);
- return for_each_admissible_user(print_user_summary_line, fi);
+ ret = for_each_admissible_user(print_user_summary_line, &usli);
+ if (ret == -E_LOOP_COMPLETE)
+ ret = 1;
+ return ret;
}
static int user_list_loop_function(struct osl_row *row, void *data)