libblkid
--------
- - remove strerrr() from debug messages (use %m) to make BLKID_DEBUG= output
- thread-safe
-
- (!) don't use internally blkid_loff_t, rather use off_t, size_t, ssize_t,
stdint.h types and so on...
}
IN = open(device_name,repair?O_RDWR:O_RDONLY);
if (IN < 0)
- die(_("unable to open '%s': %s"), device_name, strerror(errno));
+ die(_("unable to open '%s': %m"), device_name);
for (count=0 ; count<3 ; count++)
sync();
read_superblock();
err = stat(block_name, &statbuf);
if (err) {
fprintf (stderr,
- _("Cannot locate block device '%s' (%s)\n"),
- block_name, strerror(errno));
+ _("Cannot locate block device '%s' (%m)\n"),
+ block_name);
exit(2);
}
err = stat(raw_name, &statbuf);
if (err) {
- fprintf (stderr, _("Cannot locate raw device '%s' (%s)\n"),
- raw_name, strerror(errno));
+ fprintf (stderr, _("Cannot locate raw device '%s' (%m)\n"),
+ raw_name);
exit(2);
}
if (has_worked && errno == EINVAL)
return 0;
fprintf (stderr,
- _("Error querying raw device (%s)\n"),
- strerror(errno));
+ _("Error querying raw device (%m)\n"));
exit(3);
}
/* If one query has worked, mark that fact so that we don't
err = ioctl(master_fd, RAW_SETBIND, &rq);
if (err < 0) {
fprintf (stderr,
- _("Error setting raw device (%s)\n"),
- strerror(errno));
+ _("Error setting raw device (%m)\n"));
exit(3);
}
printf (_("%sraw%d: bound to major %d, minor %d\n"),
}
if (i) {
- printf(_("\nWARNING: Re-reading the partition table failed with error %d: %s.\n"
+ printf(_("\nWARNING: Re-reading the partition table failed with error %d: %m.\n"
"The kernel still uses the old table. The new table will be used at\n"
"the next reboot or after you run partprobe(8) or kpartx(8)\n"),
- errno, strerror(errno));
+ errno);
}
if (dos_changed)
rc = fstat(fd, &s);
if (rc == -1)
{
- fprintf(stderr, "last_lba() could not stat: %s\n",
- strerror(errno));
+ fprintf(stderr, "last_lba() could not stat: %m\n");
return 0;
}
if (S_ISBLK(s.st_mode))
lseek(dev_port_fd, clock_ctl_addr, 0);
if (write(dev_port_fd, &v, 1) == -1 && debug)
printf(_
- ("cmos_read(): write to control address %X failed: %s\n"),
- clock_ctl_addr, strerror(errno));
+ ("cmos_read(): write to control address %X failed: %m\n"),
+ clock_ctl_addr);
lseek(dev_port_fd, clock_data_addr, 0);
if (read(dev_port_fd, &v, 1) == -1 && debug)
printf(_
- ("cmos_read(): read data address %X failed: %s\n"),
- clock_data_addr, strerror(errno));
+ ("cmos_read(): read data address %X failed: %m\n"),
+ clock_data_addr);
return v;
} else {
/*
lseek(dev_port_fd, clock_ctl_addr, 0);
if (write(dev_port_fd, &v, 1) == -1 && debug)
printf(_
- ("cmos_write(): write to control address %X failed: %s\n"),
- clock_ctl_addr, strerror(errno));
+ ("cmos_write(): write to control address %X failed: %m\n"),
+ clock_ctl_addr);
v = (val & 0xff);
lseek(dev_port_fd, clock_data_addr, 0);
if (write(dev_port_fd, &v, 1) == -1 && debug)
printf(_
- ("cmos_write(): write to data address %X failed: %s\n"),
- clock_data_addr, strerror(errno));
+ ("cmos_write(): write to data address %X failed: %m\n"),
+ clock_data_addr);
} else {
outb(reg, clock_ctl_addr);
outb(val, clock_data_addr);
fprintf(stderr, ": ");
}
if (adderr)
- fprintf(stderr, "%s", strerror(errno));
+ fprintf(stderr, "%m");
fprintf(stderr, "\n");
if (doexit)
exit(excode);
DBG(DEBUG_DEVNAME, printf("opening %s\n", lvm_device));
if ((lvf = fopen(lvm_device, "r")) == NULL) {
- DBG(DEBUG_DEVNAME, printf("%s: (%d) %s\n", lvm_device, errno,
- strerror(errno)));
+ DBG(DEBUG_DEVNAME, printf("%s: (%d) %m\n", lvm_device, errno));
return 0;
}
if (stat(dev->bid_name, &st) < 0) {
DBG(DEBUG_PROBE,
- printf("blkid_verify: error %s (%d) while "
- "trying to stat %s\n", strerror(errno), errno,
+ printf("blkid_verify: error %m (%d) while "
+ "trying to stat %s\n", errno,
dev->bid_name));
open_err:
if ((errno == EPERM) || (errno == EACCES) || (errno == ENOENT)) {
fd = open(dev->bid_name, O_RDONLY);
if (fd < 0) {
- DBG(DEBUG_PROBE, printf("blkid_verify: error %s (%d) while "
- "opening %s\n", strerror(errno), errno,
+ DBG(DEBUG_PROBE, printf("blkid_verify: error %m (%d) while "
+ "opening %s\n", errno,
dev->bid_name));
goto open_err;
}
rc = mnt_context_mount(cxt);
if (rc)
- printf("failed to mount %s\n", strerror(errno));
+ printf("failed to mount: %m\n");
else
printf("successfully mounted\n");
fd = open(tty, O_RDWR | O_NONBLOCK);
if (fd == -1) {
- syslog(LOG_ERR, _("FATAL: can't reopen tty: %s"),
- strerror(errno));
+ syslog(LOG_ERR, _("FATAL: can't reopen tty: %m"));
sleepexit(EXIT_FAILURE);
}
lockfd = open(orig_file, O_RDONLY, 0);
if (lockfd < 0) {
- (void)fprintf(stderr, "%s: %s: %s\n",
- progname, orig_file, strerror(errno));
+ (void)fprintf(stderr, "%s: %s: %m\n", progname, orig_file);
unlink(tmp_file);
exit(EXIT_FAILURE);
}
fd = open(devname, O_RDONLY);
if (fd < 0) {
- fprintf(stderr, "error: %s: %s\n", devname, strerror(errno));
+ fprintf(stderr, "error: %s: %m\n", devname);
return 2;
}
if (blkid_probe_set_device(pr, fd, offset, size))
fd_pidfile = open(pidfile_path, O_CREAT | O_RDWR, 0664);
if (fd_pidfile < 0) {
if (!quiet)
- fprintf(stderr, _("Failed to open/create %s: %s\n"),
- pidfile_path, strerror(errno));
+ fprintf(stderr, _("Failed to open/create %s: %m\n"),
+ pidfile_path);
exit(EXIT_FAILURE);
}
cleanup_pidfile = pidfile_path;
if ((errno == EAGAIN) || (errno == EINTR))
continue;
if (!quiet)
- fprintf(stderr, _("Failed to lock %s: %s\n"),
- pidfile_path, strerror(errno));
+ fprintf(stderr, _("Failed to lock %s: %m\n"), pidfile_path);
exit(EXIT_FAILURE);
}
ret = call_daemon(socket_path, 0, reply_buf, sizeof(reply_buf), 0, 0);
if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
if (!quiet)
- fprintf(stderr, _("Couldn't create unix stream "
- "socket: %s"), strerror(errno));
+ fprintf(stderr, _("Couldn't create unix stream socket: %m"));
exit(EXIT_FAILURE);
}
sizeof(struct sockaddr_un)) < 0) {
if (!quiet)
fprintf(stderr,
- _("Couldn't bind unix socket %s: %s\n"),
- socket_path, strerror(errno));
+ _("Couldn't bind unix socket %s: %m\n"), socket_path);
exit(EXIT_FAILURE);
}
umask(save_umask);
if (listen(s, SOMAXCONN) < 0) {
if (!quiet)
fprintf(stderr, _("Couldn't listen on unix "
- "socket %s: %s\n"), socket_path,
- strerror(errno));
+ "socket %s: %m\n"), socket_path);
exit(EXIT_FAILURE);
}
ret = call_daemon(socket_path, do_type + 2, buf,
sizeof(buf), &num, &err_context);
if (ret < 0) {
- printf(_("Error calling uuidd daemon (%s): %s\n"),
- err_context, strerror(errno));
+ printf(_("Error calling uuidd daemon (%s): %m\n"), err_context);
return EXIT_FAILURE;
}
if (do_type == UUIDD_OP_TIME_UUID) {
ret = call_daemon(socket_path, do_type, (char *) &uu,
sizeof(uu), 0, &err_context);
if (ret < 0) {
- printf(_("Error calling uuidd daemon (%s): %s\n"),
- err_context, strerror(errno));
+ printf(_("Error calling uuidd daemon (%s): %m\n"), err_context);
return EXIT_FAILURE;
}
if (ret != sizeof(uu))
if (!quiet)
fprintf(stderr,
_("Couldn't kill uuidd running "
- "at pid %d: %s\n"), do_kill,
- strerror(errno));
+ "at pid %d: %m\n"), do_kill);
return EXIT_FAILURE;
}
if (!quiet)
nloops = atoi(argv[4]);
if (stat(filename, &st) < -1)
- die(EXIT_FAILURE, "%s: %s\n", filename, strerror(errno));
+ die(EXIT_FAILURE, "%s: %m\n", filename);
fprintf(stderr, "%05d (pid=%05d): START\n", id, pid);
if (errno == EBUSY) {
if (verbose)
- printf(_("ioctl LOOP_SET_FD failed: %s\n"),
- strerror(errno));
+ printf(_("ioctl LOOP_SET_FD failed: %m\n"));
rc = 2;
} else
perror("ioctl: LOOP_SET_FD");
int i = 0;
if (setgid(getgid()) < 0)
- die(EX_FAIL, _("mount: cannot set group id: %s"), strerror(errno));
+ die(EX_FAIL, _("mount: cannot set group id: %m"));
if (setuid(getuid()) < 0)
- die(EX_FAIL, _("mount: cannot set user id: %s"), strerror(errno));
+ die(EX_FAIL, _("mount: cannot set user id: %m"));
oo = fix_opts_string (flags, extra_opts, NULL);
mountargs[i++] = mountprog; /* 1 */
_("mount: cannot open %s for setting speed"),
spec);
if (ioctl(cdrom, CDROM_SELECT_SPEED, speed) < 0)
- die(EX_FAIL, _("mount: cannot set speed: %s"),
- strerror(errno));
+ die(EX_FAIL, _("mount: cannot set speed: %m"));
close(cdrom);
}
}
int i = 0;
if(setgid(getgid()) < 0)
- die(EX_FAIL, _("umount: cannot set group id: %s"), strerror(errno));
+ die(EX_FAIL, _("umount: cannot set group id: %m"));
if(setuid(getuid()) < 0)
- die(EX_FAIL, _("umount: cannot set user id: %s"), strerror(errno));
+ die(EX_FAIL, _("umount: cannot set user id: %m"));
umountargs[i++] = umountprog;
umountargs[i++] = xstrdup(node);
}
if (chdir(parent) == -1)
- die (2, _("umount: failed to chdir to %s: %s"),
- parent, strerror(errno));
+ die (2, _("umount: failed to chdir to %s: %m"), parent);
if (!getcwd(buf, sizeof(buf)))
- die (2, _("umount: failed to obtain current directory: %s"),
- strerror(errno));
+ die (2, _("umount: failed to obtain current directory: %m"));
if (strcmp(buf, parent) != 0)
die (2, _("umount: mountpoint moved (%s -> %s)"), parent, buf);
printf(_("CPU %d enable failed "
"(CPU is deconfigured)\n"), cpu);
else if (rc == -1)
- printf(_("CPU %d enable failed (%s)\n"), cpu,
- strerror(errno));
+ printf(_("CPU %d enable failed (%m)\n"), cpu);
else
printf(_("CPU %d enabled\n"), cpu);
} else {
}
rc = path_writestr("0", _PATH_SYS_CPU "/cpu%d/online", cpu);
if (rc == -1)
- printf(_("CPU %d disable failed (%s)\n"), cpu,
- strerror(errno));
+ printf(_("CPU %d disable failed (%m)\n"), cpu);
else {
printf(_("CPU %d disabled\n"), cpu);
if (onlinecpus)
if (configure) {
rc = path_writestr("1", _PATH_SYS_CPU "/cpu%d/configure", cpu);
if (rc == -1)
- printf(_("CPU %d configure failed (%s)\n"), cpu,
- strerror(errno));
+ printf(_("CPU %d configure failed (%m)\n"), cpu);
else
printf(_("CPU %d configured\n"), cpu);
} else {
rc = path_writestr("0", _PATH_SYS_CPU "/cpu%d/configure", cpu);
if (rc == -1)
- printf(_("CPU %d deconfigure failed (%s)\n"), cpu,
- strerror(errno));
+ printf(_("CPU %d deconfigure failed (%m)\n"), cpu);
else
printf(_("CPU %d deconfigured\n"), cpu);
}
exit(1);
}
if (write(fd, &multiplier, to_write) != to_write) {
- fprintf(stderr, _("readprofile: error writing %s: %s\n"),
- defaultpro, strerror(errno));
+ fprintf(stderr, _("readprofile: error writing %s: %m\n"),
+ defaultpro);
exit(1);
}
close(fd);
if (((proFd=open(proFile,O_RDONLY)) < 0)
|| ((int)(len=lseek(proFd,0,SEEK_END)) < 0)
|| (lseek(proFd,0,SEEK_SET) < 0)) {
- fprintf(stderr,"%s: %s: %s\n",prgname,proFile,strerror(errno));
+ fprintf(stderr,"%s: %s: %m\n", prgname, proFile);
exit(1);
}
rc = read(proFd,buf,len);
if (rc < 0 || (size_t) rc != len) {
- fprintf(stderr,"%s: %s: %s\n",prgname,proFile,strerror(errno));
+ fprintf(stderr,"%s: %s: %m\n", prgname, proFile);
exit(1);
}
close(proFd);
return (NULL);
if (strlen(strerror(errno)) > 1000)
return (NULL);
- (void) sprintf(errbuf, "%s: %s", device, strerror(errno));
+ (void) sprintf(errbuf, "%s: %m", device);
errbuf[1024] = 0;
return (errbuf);
}