/* wait for keys */
do {
- int key = getch();
+ key = getch();
if (ui_resize)
ui_menu_resize(cf);
case 'W': /* Write */
{
char buf[64] = { 0 };
- int rc;
if (fdisk_is_readonly(cf->cxt)) {
warn = _("Device open in read-only mode");
ui_warnx(_("Device open in read-only mode."));
do {
- int rc = 0, key = getch();
+ int key = getch();
+ rc = 0;
if (ui_resize)
/* Note that ncurses getch() returns ERR when interrupted
* by signal, but SLang does not interrupt at all. */
/* Input status of 0 to print help and exit without an error. */
static void __attribute__((__noreturn__)) usage(int status)
{
- FILE *stream = status ? stderr : stdout;
+ FILE *out = status ? stderr : stdout;
- fputs(USAGE_HEADER, stream);
- fprintf(stream,
+ fputs(USAGE_HEADER, out);
+ fprintf(out,
_(" %s [options] <file>\n"), program_invocation_short_name);
- fputs(USAGE_SEPARATOR, stream);
- fputs(_("Check and repair a compressed ROM filesystem.\n"), stream);
-
- fputs(USAGE_OPTIONS, stream);
- fputs(_(" -a for compatibility only, ignored\n"), stream);
- fputs(_(" -v, --verbose be more verbose\n"), stream);
- fputs(_(" -y for compatibility only, ignored\n"), stream);
- fputs(_(" -b, --blocksize <size> use this blocksize, defaults to page size\n"), stream);
- fputs(_(" --extract[=<dir>] test uncompression, optionally extract into <dir>\n"), stream);
- fputs(USAGE_SEPARATOR, stream);
- fputs(USAGE_HELP, stream);
- fputs(USAGE_VERSION, stream);
- fputs(USAGE_SEPARATOR, stream);
+ fputs(USAGE_SEPARATOR, out);
+ fputs(_("Check and repair a compressed ROM filesystem.\n"), out);
+
+ fputs(USAGE_OPTIONS, out);
+ fputs(_(" -a for compatibility only, ignored\n"), out);
+ fputs(_(" -v, --verbose be more verbose\n"), out);
+ fputs(_(" -y for compatibility only, ignored\n"), out);
+ fputs(_(" -b, --blocksize <size> use this blocksize, defaults to page size\n"), out);
+ fputs(_(" --extract[=<dir>] test uncompression, optionally extract into <dir>\n"), out);
+ fputs(USAGE_SEPARATOR, out);
+ fputs(USAGE_HELP, out);
+ fputs(USAGE_VERSION, out);
+ fputs(USAGE_SEPARATOR, out);
+
exit(status);
}
#define lchown chown
#endif
-static void do_uncompress(char *path, int fd, unsigned long offset,
+static void do_uncompress(char *path, int outfd, unsigned long offset,
unsigned long size)
{
unsigned long curr = offset + 4 * ((size + blksize - 1) / blksize);
}
size -= out;
if (*extract_dir != '\0')
- if (write(fd, outbuffer, out) < 0)
+ if (write(outfd, outbuffer, out) < 0)
err(FSCK_EX_ERROR, _("write failed: %s"),
path);
curr = next;
static void do_file(char *path, struct cramfs_inode *i)
{
unsigned long offset = i->offset << 2;
- int fd = 0;
+ int outfd = 0;
if (offset == 0 && i->size != 0)
errx(FSCK_EX_UNCORRECTED,
if (opt_verbose)
print_node('f', i, path);
if (*extract_dir != '\0') {
- fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, i->mode);
- if (fd < 0)
+ outfd = open(path, O_WRONLY | O_CREAT | O_TRUNC, i->mode);
+ if (outfd < 0)
err(FSCK_EX_ERROR, _("cannot open %s"), path);
}
if (i->size)
- do_uncompress(path, fd, offset, i->size);
+ do_uncompress(path, outfd, offset, i->size);
if ( *extract_dir != '\0') {
- if (close_fd(fd) != 0)
+ if (close_fd(outfd) != 0)
err(FSCK_EX_ERROR, _("write failed: %s"), path);
change_file_status(path, i);
}
sunlabel->nhead = cpu_to_be16(cxt->geom.heads);
sunlabel->nsect = cpu_to_be16(cxt->geom.sectors);
- if (cxt->geom.cylinders != be16_to_cpu(sunlabel->ncyl))
- sunlabel->ncyl = cpu_to_be16( cxt->geom.cylinders
- - be16_to_cpu(sunlabel->acyl) );
+ if (cxt->geom.cylinders != be16_to_cpu(sunlabel->ncyl)) {
+ int a = cpu_to_be16(cxt->geom.cylinders);
+ int b = be16_to_cpu(sunlabel->acyl);
+ sunlabel->ncyl = a - b;
+ }
ush = (unsigned short *) sunlabel;
}
while (fdisk_table_next_partition(tb, &itr, &x) == 0) {
- fdisk_sector_t end, best_end = 0;
+ fdisk_sector_t the_end, best_end = 0;
if (!fdisk_partition_has_end(x))
continue;
- end = fdisk_partition_get_end(x);
+ the_end = fdisk_partition_get_end(x);
if (best)
best_end = fdisk_partition_get_end(best);
- if (end < pa->start && (!best || best_end < end))
+ if (the_end < pa->start && (!best || best_end < the_end))
best = x;
}
/* remove "(deleted)" suffix */
sz = strlen(fs->target);
if (sz > PATH_DELETED_SUFFIX_SZ) {
- char *p = fs->target + (sz - PATH_DELETED_SUFFIX_SZ);
+ char *ptr = fs->target + (sz - PATH_DELETED_SUFFIX_SZ);
- if (strcmp(p, PATH_DELETED_SUFFIX) == 0)
- *p = '\0';
+ if (strcmp(ptr, PATH_DELETED_SUFFIX) == 0)
+ *ptr = '\0';
}
unmangle_string(fs->root);
}
} else if (width < tb->termwidth) {
/* enlarge the last column */
- struct libscols_column *cl = list_entry(
+ struct libscols_column *col = list_entry(
tb->tb_columns.prev, struct libscols_column, cl_columns);
DBG(TAB, ul_debugobj(tb, " enlarge width (last column)"));
- if (!scols_column_is_right(cl) && tb->termwidth - width > 0) {
- cl->width += tb->termwidth - width;
+ if (!scols_column_is_right(col) && tb->termwidth - width > 0) {
+ col->width += tb->termwidth - width;
width = tb->termwidth;
}
}
static struct libscols_table *setup_table(struct lslogins_control *ctl)
{
- struct libscols_table *tb = scols_new_table();
+ struct libscols_table *table = scols_new_table();
int n = 0;
- if (!tb)
+ if (!table)
errx(EXIT_FAILURE, _("failed to initialize output table"));
if (ctl->noheadings)
- scols_table_enable_noheadings(tb, 1);
+ scols_table_enable_noheadings(table, 1);
switch(outmode) {
case OUT_COLON:
- scols_table_enable_raw(tb, 1);
- scols_table_set_column_separator(tb, ":");
+ scols_table_enable_raw(table, 1);
+ scols_table_set_column_separator(table, ":");
break;
case OUT_NEWLINE:
- scols_table_set_column_separator(tb, "\n");
+ scols_table_set_column_separator(table, "\n");
/* fallthrough */
case OUT_EXPORT:
- scols_table_enable_export(tb, 1);
+ scols_table_enable_export(table, 1);
break;
case OUT_NUL:
- scols_table_set_line_separator(tb, "\0");
+ scols_table_set_line_separator(table, "\0");
/* fallthrough */
case OUT_RAW:
- scols_table_enable_raw(tb, 1);
+ scols_table_enable_raw(table, 1);
break;
case OUT_PRETTY:
- scols_table_enable_noheadings(tb, 1);
+ scols_table_enable_noheadings(table, 1);
default:
break;
}
if (ctl->notrunc)
flags &= ~SCOLS_FL_TRUNC;
- if (!scols_table_new_column(tb,
+ if (!scols_table_new_column(table,
coldescs[columns[n]].name,
coldescs[columns[n]].whint,
flags))
++n;
}
- return tb;
+ return table;
fail:
- scols_unref_table(tb);
+ scols_unref_table(table);
return NULL;
}
}
#endif
-static int print_pretty(struct libscols_table *tb)
+static int print_pretty(struct libscols_table *table)
{
struct libscols_iter *itr = scols_new_iter(SCOLS_ITER_FORWARD);
struct libscols_column *col;
const char *hstr, *dstr;
int n = 0;
- ln = scols_table_get_line(tb, 0);
- while (!scols_table_next_column(tb, itr, &col)) {
+ ln = scols_table_get_line(table, 0);
+ while (!scols_table_next_column(table, itr, &col)) {
data = scols_line_get_cell(ln, n);
* Parses mountinfo and calls mnt_cache_set_targets(cache, mtab). Only
* necessary if @tb in main() was read from a non-kernel source.
*/
-static void cache_set_targets(struct libmnt_cache *cache)
+static void cache_set_targets(struct libmnt_cache *tmp)
{
struct libmnt_table *tb;
const char *path;
_PATH_PROC_MOUNTS;
if (mnt_table_parse_file(tb, path) == 0)
- mnt_cache_set_targets(cache, tb);
+ mnt_cache_set_targets(tmp, tb);
mnt_unref_table(tb);
}
* Return the absolute path of a file from
* a given inode number (and its size)
*/
-static char *get_filename_sz(ino_t inode, pid_t pid, size_t *size)
+static char *get_filename_sz(ino_t inode, pid_t lock_pid, size_t *size)
{
struct stat sb;
struct dirent *dp;
* iterate the *entire* filesystem searching
* for the damn file.
*/
- sprintf(path, "/proc/%d/fd/", pid);
+ sprintf(path, "/proc/%d/fd/", lock_pid);
if (!(dirp = opendir(path)))
return NULL;
/* -o <options> or fstab */
static int parse_options(const char *optstr,
- int *priority, int *discard, int *nofail)
+ int *prio, int *disc, int *nofail)
{
char *arg = NULL;
assert(optstr);
- assert(priority);
- assert(discard);
+ assert(prio);
+ assert(disc);
assert(nofail);
if (mnt_optstr_get_option(optstr, "nofail", NULL, 0) == 0)
*nofail = 1;
if (mnt_optstr_get_option(optstr, "discard", &arg, NULL) == 0) {
- *discard |= SWAP_FLAG_DISCARD;
+ *disc |= SWAP_FLAG_DISCARD;
if (arg) {
/* only single-time discards are wanted */
if (strcmp(arg, "once") == 0)
- *discard |= SWAP_FLAG_DISCARD_ONCE;
+ *disc |= SWAP_FLAG_DISCARD_ONCE;
/* do discard for every released swap page */
if (strcmp(arg, "pages") == 0)
- *discard |= SWAP_FLAG_DISCARD_PAGES;
+ *disc |= SWAP_FLAG_DISCARD_PAGES;
}
}
arg = NULL;
if (mnt_optstr_get_option(optstr, "pri", &arg, NULL) == 0 && arg)
- *priority = atoi(arg);
+ *prio = atoi(arg);
return 0;
}
if (z)
fill_table_row(tb, z); /* just one device specified */
else {
- size_t i; /* list all used devices */
+ /* list all used devices */
z = new_zram(NULL);
for (i = 0; ; i++) {