Adapt to changes in library.

(Logical change 1.139)
edge.strict_endians
cantab.net!aia21 2003-06-03 11:07:54 +00:00
parent 980387655f
commit 33c6acd353
2 changed files with 14 additions and 39 deletions

View File

@ -56,6 +56,7 @@
#include "attrib.h"
#include "mft.h"
#include "disk_io.h"
#include "device.h"
#include "logfile.h"
/**
@ -69,6 +70,7 @@ int main(int argc, char **argv)
const char *FAILED = "FAILED";
unsigned char *m = NULL, *m2 = NULL;
ntfs_volume *vol;
struct ntfs_device *dev;
unsigned long mnt_flags;
int i;
u16 flags;
@ -122,13 +124,21 @@ int main(int argc, char **argv)
}
puts(FAILED);
puts("Attempting to correct errors.");
printf("Attempting to correct errors... ");
vol = ntfs_volume_startup(argv[1], 0);
dev = ntfs_device_alloc(argv[1], 0, &ntfs_device_disk_io_ops, NULL);
if (!dev) {
puts(FAILED);
perror("Failed to allocate device");
goto error_exit;
}
vol = ntfs_volume_startup(dev, 0);
if (!vol) {
puts(FAILED);
perror("Failed to startup volume");
fprintf(stderr, "Volume is corrupt. You should run chkdsk.");
ntfs_device_free(dev);
goto error_exit;
}
@ -245,6 +255,7 @@ int main(int argc, char **argv)
m = m2 = NULL;
printf("Processing of $MFT and $MFTMirr completed successfully.\n\n");
/* ntfs_umount() will invoke ntfs_device_free() for us. */
if (ntfs_umount(vol, 0))
ntfs_umount(vol, 1);
vol = ntfs_mount(argv[1], 0);
@ -300,7 +311,7 @@ mount_ok:
/* That's all for now! */
printf("NTFS partition %s was processed successfully.\n",
vol->dev_name);
vol->dev->d_name);
/* Set return code to 0. */
i = 0;
final_exit:

View File

@ -42,7 +42,6 @@
#ifdef HAVE_ERRNO_H
# include <errno.h>
#endif
#include <fcntl.h>
#include <time.h>
#ifdef HAVE_GETOPT_H
# include <getopt.h>
@ -80,8 +79,6 @@ ntfs_volume *vol;
ntfs_inode *ni;
ntfs_attr *na = NULL;
struct flock flk;
ATTR_DEF *attr_defs;
struct {
@ -701,12 +698,6 @@ void ntfstruncate_exit(void)
fprintf(stderr, "Warning: Failed to close inode %Li: %s\n",
(long long)inode, strerror(errno));
}
/* Unlock the device. */
flk.l_type = F_UNLCK;
err = fcntl(vol->fd, F_SETLK, &flk);
if (err == -1)
fprintf(stderr, "Warning: Could not unlock %s: %s\n", dev_name,
strerror(errno));
/* Unmount the volume. */
err = ntfs_umount(vol, 0);
if (err == -1)
@ -761,26 +752,6 @@ int main(int argc, char **argv)
if (!vol)
err_exit("Failed to mount %s: %s\n", dev_name, strerror(errno));
/* Acquire exlusive (mandatory) lock on the whole device. */
memset(&flk, 0, sizeof(flk));
if (opts.no_action)
flk.l_type = F_RDLCK;
else
flk.l_type = F_WRLCK;
flk.l_whence = SEEK_SET;
flk.l_start = flk.l_len = 0LL;
err = fcntl(vol->fd, F_SETLK, &flk);
if (err == -1) {
Eprintf("Could not lock %s for %s: %s\n", dev_name,
opts.no_action ? "reading" : "writing",
strerror(errno));
err = ntfs_umount(vol, 0);
if (err == -1)
Eprintf("Warning: Could not umount %s: %s\n",
dev_name, strerror(errno));
exit(1);
}
/* Register our exit function which will unlock and close the device. */
err = atexit(&ntfstruncate_exit);
if (err == -1) {
@ -830,13 +801,6 @@ int main(int argc, char **argv)
err_exit("Failed to close inode %Li: %s\n", (long long)inode,
strerror(errno));
/* Unlock the device. */
flk.l_type = F_UNLCK;
err = fcntl(vol->fd, F_SETLK, &flk);
if (err == -1)
fprintf(stderr, "Warning: Failed to unlock %s: %s\n", dev_name,
strerror(errno));
/* Unmount the volume. */
err = ntfs_umount(vol, 0);
if (err == -1)