mirror of
https://git.code.sf.net/p/ntfs-3g/ntfs-3g.git
synced 2024-11-23 10:04:00 +08:00
Adapted to ntfs-3g.1.2712
This commit is contained in:
parent
5dbdb30df8
commit
412838056a
@ -3317,6 +3317,7 @@ int ntfs_attr_rm(ntfs_attr *na)
|
||||
}
|
||||
ntfs_attr_reinit_search_ctx(ctx);
|
||||
}
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
if (errno != ENOENT) {
|
||||
ntfs_log_trace("Attribute lookup failed. Probably leaving inconstant "
|
||||
"metadata.\n");
|
||||
|
@ -117,10 +117,12 @@ static int ntfs_bitmap_set_bits_in_run(ntfs_attr *na, s64 start_bit,
|
||||
{
|
||||
s64 bufsize, br;
|
||||
u8 *buf, *lastbyte_buf;
|
||||
int bit, firstbyte, lastbyte, lastbyte_pos, tmp, err;
|
||||
int bit, firstbyte, lastbyte, lastbyte_pos, tmp, ret = -1;
|
||||
|
||||
if (!na || start_bit < 0 || count < 0) {
|
||||
errno = EINVAL;
|
||||
ntfs_log_perror("%s: Invalid argument (%p, %lld, %lld)",
|
||||
__FUNCTION__, na, (long long)start_bit, (long long)count);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -147,9 +149,9 @@ static int ntfs_bitmap_set_bits_in_run(ntfs_attr *na, s64 start_bit,
|
||||
/* read it in... */
|
||||
br = ntfs_attr_pread(na, start_bit >> 3, 1, buf);
|
||||
if (br != 1) {
|
||||
free(buf);
|
||||
errno = EIO;
|
||||
return -1;
|
||||
if (br >= 0)
|
||||
errno = EIO;
|
||||
goto free_err_out;
|
||||
}
|
||||
/* and set or clear the appropriate bits in it. */
|
||||
while ((bit & 7) && count--) {
|
||||
@ -172,9 +174,9 @@ static int ntfs_bitmap_set_bits_in_run(ntfs_attr *na, s64 start_bit,
|
||||
lastbyte_pos = ((count + 7) >> 3) + firstbyte;
|
||||
if (!lastbyte_pos) {
|
||||
// FIXME: Eeek! BUG!
|
||||
ntfs_log_trace("Eeek! lastbyte is zero. Leaving "
|
||||
ntfs_log_error("Lastbyte is zero. Leaving "
|
||||
"inconsistent metadata.\n");
|
||||
err = EIO;
|
||||
errno = EIO;
|
||||
goto free_err_out;
|
||||
}
|
||||
/* and it is in the currently loaded bitmap window... */
|
||||
@ -186,10 +188,11 @@ static int ntfs_bitmap_set_bits_in_run(ntfs_attr *na, s64 start_bit,
|
||||
3, 1, lastbyte_buf);
|
||||
if (br != 1) {
|
||||
// FIXME: Eeek! We need rollback! (AIA)
|
||||
ntfs_log_trace("Eeek! Read of last byte "
|
||||
"failed. Leaving "
|
||||
"inconsistent metadata.\n");
|
||||
err = EIO;
|
||||
if (br >= 0)
|
||||
errno = EIO;
|
||||
ntfs_log_perror("Reading of last byte "
|
||||
"failed (%lld). Leaving inconsistent "
|
||||
"metadata", (long long)br);
|
||||
goto free_err_out;
|
||||
}
|
||||
/* and set/clear the appropriate bits in it. */
|
||||
@ -211,9 +214,11 @@ static int ntfs_bitmap_set_bits_in_run(ntfs_attr *na, s64 start_bit,
|
||||
br = ntfs_attr_pwrite(na, tmp, bufsize, buf);
|
||||
if (br != bufsize) {
|
||||
// FIXME: Eeek! We need rollback! (AIA)
|
||||
ntfs_log_trace("Eeek! Failed to write buffer to bitmap. "
|
||||
"Leaving inconsistent metadata.\n");
|
||||
err = EIO;
|
||||
if (br >= 0)
|
||||
errno = EIO;
|
||||
ntfs_log_perror("Failed to write buffer to bitmap "
|
||||
"(%lld != %lld). Leaving inconsistent metadata",
|
||||
(long long)br, (long long)bufsize);
|
||||
goto free_err_out;
|
||||
}
|
||||
|
||||
@ -234,22 +239,19 @@ static int ntfs_bitmap_set_bits_in_run(ntfs_attr *na, s64 start_bit,
|
||||
|
||||
if (lastbyte && count != 0) {
|
||||
// FIXME: Eeek! BUG!
|
||||
ntfs_log_trace("Eeek! Last buffer but count is not zero (= "
|
||||
"%lli). Leaving inconsistent metadata.\n",
|
||||
(long long)count);
|
||||
err = EIO;
|
||||
ntfs_log_error("Last buffer but count is not zero "
|
||||
"(%lld). Leaving inconsistent metadata.\n",
|
||||
(long long)count);
|
||||
errno = EIO;
|
||||
goto free_err_out;
|
||||
}
|
||||
} while (count > 0);
|
||||
|
||||
/* Done! */
|
||||
free(buf);
|
||||
return 0;
|
||||
|
||||
|
||||
ret = 0;
|
||||
|
||||
free_err_out:
|
||||
free(buf);
|
||||
errno = err;
|
||||
return -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1433,10 +1433,9 @@ int ntfs_volume_write_flags(ntfs_volume *vol, const u16 flags)
|
||||
vol->flags = c->flags = flags & VOLUME_FLAGS_MASK;
|
||||
/* Write them to disk. */
|
||||
ntfs_inode_mark_dirty(vol->vol_ni);
|
||||
if (ntfs_inode_sync(vol->vol_ni)) {
|
||||
ntfs_log_perror("Error writing $Volume");
|
||||
if (ntfs_inode_sync(vol->vol_ni))
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
ret = 0; /* success */
|
||||
err_out:
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
|
@ -2589,7 +2589,17 @@ int main(int argc, char *argv[])
|
||||
struct fuse *fh;
|
||||
fuse_fstype fstype = FSTYPE_UNKNOWN;
|
||||
struct stat sbuf;
|
||||
int err;
|
||||
int err, fd;
|
||||
|
||||
/*
|
||||
* Make sure file descriptors 0, 1 and 2 are open,
|
||||
* otherwise chaos would ensue.
|
||||
*/
|
||||
do {
|
||||
fd = open("/dev/null", O_RDWR);
|
||||
if (fd > 2)
|
||||
close(fd);
|
||||
} while (fd >= 0 && fd <= 2);
|
||||
|
||||
#ifndef FUSE_INTERNAL
|
||||
if ((getuid() != geteuid()) || (getgid() != getegid())) {
|
||||
|
Loading…
Reference in New Issue
Block a user