mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-05 16:00:05 +01:00
Rewrite and export crypt_wipe function.
The crypt_wipe can be used to wipe any part of the device, and also to initialize integrity based device (to reset checksum).
This commit is contained in:
@@ -30,6 +30,9 @@
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/fs.h>
|
||||
#include <unistd.h>
|
||||
#ifdef HAVE_SYS_SYSMACROS_H
|
||||
# include <sys/sysmacros.h> /* for major, minor */
|
||||
#endif
|
||||
#include "internal.h"
|
||||
|
||||
struct device {
|
||||
@@ -482,7 +485,10 @@ int device_block_adjust(struct crypt_device *cd,
|
||||
if (r == -EBUSY)
|
||||
log_err(cd, _("Cannot use device %s which is in use "
|
||||
"(already mapped or mounted).\n"),
|
||||
device->path);
|
||||
device->path);
|
||||
else if (r == -EACCES)
|
||||
log_err(cd, _("Cannot use device %s, permission denied.\n"),
|
||||
device->path);
|
||||
else
|
||||
log_err(cd, _("Cannot get info about device %s.\n"),
|
||||
device->path);
|
||||
@@ -547,3 +553,16 @@ int device_is_identical(struct device *device1, struct device *device2)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int device_is_rotational(struct device *device)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
if (stat(device_path(device), &st) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
if (!S_ISBLK(st.st_mode))
|
||||
return 0;
|
||||
|
||||
return crypt_dev_is_rotational(major(st.st_rdev), minor(st.st_rdev));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user