Lines 1-5
Link Here
|
1 |
--- libntfs-3g/unix_io.c.orig Tue Dec 12 20:16:43 2006 |
1 |
--- libntfs-3g/unix_io.c.orig Fri Jun 8 23:35:33 2007 |
2 |
+++ libntfs-3g/unix_io.c Thu May 3 22:27:13 2007 |
2 |
+++ libntfs-3g/unix_io.c Mon Jul 16 07:58:02 2007 |
3 |
@@ -54,6 +54,22 @@ |
3 |
@@ -54,6 +54,22 @@ |
4 |
#include <linux/fd.h> |
4 |
#include <linux/fd.h> |
5 |
#endif |
5 |
#endif |
Lines 264-275
Link Here
|
264 |
|
264 |
|
265 |
if (!NDevOpen(dev)) { |
265 |
if (!NDevOpen(dev)) { |
266 |
errno = EBADF; |
266 |
errno = EBADF; |
267 |
@@ -155,14 +325,21 @@ |
267 |
@@ -160,12 +330,19 @@ |
268 |
} |
268 |
return -1; |
269 |
if (NDevDirty(dev)) |
269 |
} |
270 |
fsync(DEV_FD(dev)); |
270 |
|
271 |
+#if USE_LOCK |
271 |
+#if USE_LOCK |
272 |
/* Release exclusive (mandatory) lock on the whole device. */ |
|
|
273 |
memset(&flk, 0, sizeof(flk)); |
272 |
memset(&flk, 0, sizeof(flk)); |
274 |
flk.l_type = F_UNLCK; |
273 |
flk.l_type = F_UNLCK; |
275 |
flk.l_whence = SEEK_SET; |
274 |
flk.l_whence = SEEK_SET; |
Lines 277-294
Link Here
|
277 |
- if (fcntl(DEV_FD(dev), F_SETLK, &flk)) |
276 |
- if (fcntl(DEV_FD(dev), F_SETLK, &flk)) |
278 |
+ |
277 |
+ |
279 |
+ if (!NDevBlock(dev) && fcntl(DEV_FD(dev), F_SETLK, &flk)) |
278 |
+ if (!NDevBlock(dev) && fcntl(DEV_FD(dev), F_SETLK, &flk)) |
280 |
ntfs_log_perror("ntfs_device_unix_io_close: Warning: Could not " |
279 |
ntfs_log_perror("Could not unlock %s", dev->d_name); |
281 |
- "unlock %s", dev->d_name); |
|
|
282 |
+ "unlock %s", dev->d_name); |
283 |
+#endif |
280 |
+#endif |
284 |
+#if USE_UBLIO |
281 |
+#if USE_UBLIO |
285 |
+ if (DEV_HANDLE(dev)->ublio_fh) |
282 |
+ if (DEV_HANDLE(dev)->ublio_fh) |
286 |
+ ublio_close(DEV_HANDLE(dev)->ublio_fh); |
283 |
+ ublio_close(DEV_HANDLE(dev)->ublio_fh); |
287 |
+#endif |
284 |
+#endif |
288 |
/* Close the file descriptor and clear our open flag. */ |
285 |
if (close(DEV_FD(dev))) { |
289 |
if (close(DEV_FD(dev))) |
286 |
ntfs_log_perror("Failed to close device %s", dev->d_name); |
290 |
return -1; |
287 |
return -1; |
291 |
@@ -185,10 +362,235 @@ |
288 |
@@ -189,9 +366,234 @@ |
292 |
static s64 ntfs_device_unix_io_seek(struct ntfs_device *dev, s64 offset, |
289 |
static s64 ntfs_device_unix_io_seek(struct ntfs_device *dev, s64 offset, |
293 |
int whence) |
290 |
int whence) |
294 |
{ |
291 |
{ |
Lines 325-332
Link Here
|
325 |
+#else |
322 |
+#else |
326 |
return lseek(DEV_FD(dev), offset, whence); |
323 |
return lseek(DEV_FD(dev), offset, whence); |
327 |
+#endif |
324 |
+#endif |
328 |
+} |
325 |
} |
329 |
+ |
326 |
|
330 |
+#if USE_ALIGNED_IO |
327 |
+#if USE_ALIGNED_IO |
331 |
+ |
328 |
+ |
332 |
+#if USE_UBLIO |
329 |
+#if USE_UBLIO |
Lines 408-416
Link Here
|
408 |
+ if (nr > count) |
405 |
+ if (nr > count) |
409 |
+ nr = count; |
406 |
+ nr = count; |
410 |
+ return nr; |
407 |
+ return nr; |
411 |
} |
408 |
+} |
412 |
|
409 |
+ |
413 |
/** |
410 |
+/** |
414 |
+ * aligned_pwrite - Perform an aligned positioned write from the device |
411 |
+ * aligned_pwrite - Perform an aligned positioned write from the device |
415 |
+ */ |
412 |
+ */ |
416 |
+static s64 aligned_pwrite(struct ntfs_device *dev, void *buf, s64 count, s64 offset) |
413 |
+static s64 aligned_pwrite(struct ntfs_device *dev, void *buf, s64 count, s64 offset) |
Lines 520-530
Link Here
|
520 |
+ |
517 |
+ |
521 |
+#endif |
518 |
+#endif |
522 |
+ |
519 |
+ |
523 |
+/** |
520 |
/** |
524 |
* ntfs_device_unix_io_read - Read from the device, from the current location |
521 |
* ntfs_device_unix_io_read - Read from the device, from the current location |
525 |
* @dev: |
522 |
* @dev: |
526 |
* @buf: |
523 |
@@ -205,6 +607,29 @@ |
527 |
@@ -201,6 +603,29 @@ |
|
|
528 |
static s64 ntfs_device_unix_io_read(struct ntfs_device *dev, void *buf, |
524 |
static s64 ntfs_device_unix_io_read(struct ntfs_device *dev, void *buf, |
529 |
s64 count) |
525 |
s64 count) |
530 |
{ |
526 |
{ |
Lines 554-560
Link Here
|
554 |
return read(DEV_FD(dev), buf, count); |
550 |
return read(DEV_FD(dev), buf, count); |
555 |
} |
551 |
} |
556 |
|
552 |
|
557 |
@@ -222,6 +647,28 @@ |
553 |
@@ -226,6 +651,28 @@ |
558 |
return -1; |
554 |
return -1; |
559 |
} |
555 |
} |
560 |
NDevSetDirty(dev); |
556 |
NDevSetDirty(dev); |
Lines 583-589
Link Here
|
583 |
return write(DEV_FD(dev), buf, count); |
579 |
return write(DEV_FD(dev), buf, count); |
584 |
} |
580 |
} |
585 |
|
581 |
|
586 |
@@ -239,6 +686,13 @@ |
582 |
@@ -243,6 +690,13 @@ |
587 |
static s64 ntfs_device_unix_io_pread(struct ntfs_device *dev, void *buf, |
583 |
static s64 ntfs_device_unix_io_pread(struct ntfs_device *dev, void *buf, |
588 |
s64 count, s64 offset) |
584 |
s64 count, s64 offset) |
589 |
{ |
585 |
{ |
Lines 597-603
Link Here
|
597 |
return pread(DEV_FD(dev), buf, count, offset); |
593 |
return pread(DEV_FD(dev), buf, count, offset); |
598 |
} |
594 |
} |
599 |
|
595 |
|
600 |
@@ -261,6 +715,13 @@ |
596 |
@@ -265,6 +719,13 @@ |
601 |
return -1; |
597 |
return -1; |
602 |
} |
598 |
} |
603 |
NDevSetDirty(dev); |
599 |
NDevSetDirty(dev); |
Lines 611-623
Link Here
|
611 |
return pwrite(DEV_FD(dev), buf, count, offset); |
607 |
return pwrite(DEV_FD(dev), buf, count, offset); |
612 |
} |
608 |
} |
613 |
|
609 |
|
614 |
@@ -275,7 +736,16 @@ |
610 |
@@ -281,6 +742,13 @@ |
615 |
static int ntfs_device_unix_io_sync(struct ntfs_device *dev) |
611 |
int res = 0; |
616 |
{ |
612 |
|
617 |
if (!NDevReadOnly(dev)) { |
613 |
if (!NDevReadOnly(dev)) { |
618 |
- int res = fsync(DEV_FD(dev)); |
|
|
619 |
+ int res; |
620 |
+ |
621 |
+#if USE_UBLIO |
614 |
+#if USE_UBLIO |
622 |
+ if (DEV_HANDLE(dev)->ublio_fh) { |
615 |
+ if (DEV_HANDLE(dev)->ublio_fh) { |
623 |
+ res = ublio_fsync(DEV_HANDLE(dev)->ublio_fh); |
616 |
+ res = ublio_fsync(DEV_HANDLE(dev)->ublio_fh); |
Lines 625-631
Link Here
|
625 |
+ return res; |
618 |
+ return res; |
626 |
+ } |
619 |
+ } |
627 |
+#endif |
620 |
+#endif |
628 |
+ res = fsync(DEV_FD(dev)); |
621 |
res = fsync(DEV_FD(dev)); |
629 |
if (!res) |
622 |
if (res) |
630 |
NDevClearDirty(dev); |
623 |
ntfs_log_perror("Failed to sync device %s", dev->d_name); |
631 |
return res; |
|
|