From e15498973cf809fcd8353007f56f0ade11b4a872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 24 Aug 2009 15:49:08 +0000 Subject: [PATCH] * The read/write routines were pretty much broken. This was the cause of #4317. +alphabranch git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32655 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/file_systems/ntfs/fs_func.c | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/add-ons/kernel/file_systems/ntfs/fs_func.c b/src/add-ons/kernel/file_systems/ntfs/fs_func.c index f6327a192c..9a43862957 100644 --- a/src/add-ons/kernel/file_systems/ntfs/fs_func.c +++ b/src/add-ons/kernel/file_systems/ntfs/fs_func.c @@ -976,7 +976,7 @@ fs_read(fs_volume *_vol, fs_vnode *_dir, void *_cookie, off_t offset, void *buf, ntfs_attr *na = NULL; size_t size = *len; int total = 0; - status_t result = B_NO_ERROR; + status_t result = B_OK; LOCK_VOL(ns); @@ -1012,20 +1012,22 @@ fs_read(fs_volume *_vol, fs_vnode *_dir, void *_cookie, off_t offset, void *buf, size = na->data_size - offset; while (size) { - result = ntfs_attr_pread(na, offset, size, buf); - if (result < (s64)size) - ntfs_log_error("ntfs_attr_pread returned less bytes than requested.\n"); - if (result <= 0) { + off_t bytesRead = ntfs_attr_pread(na, offset, size, buf); + if (bytesRead < (s64)size) { + ntfs_log_error("ntfs_attr_pread returned less bytes than " + "requested.\n"); + } + if (bytesRead <= 0) { *len = 0; result = EINVAL; goto exit; } - size -= result; - offset += result; - total += result; + size -= bytesRead; + offset += bytesRead; + total += bytesRead; } - result = total; - *len = result; + + *len = total; exit: if (na) @@ -1054,7 +1056,7 @@ fs_write(fs_volume *_vol, fs_vnode *_dir, void *_cookie, off_t offset, ntfs_attr *na = NULL; int total = 0; size_t size = *len; - status_t result = B_NO_ERROR; + status_t result = B_OK; if (ns->flags & B_FS_IS_READONLY) { ERRPRINT("ntfs is read-only\n"); @@ -1106,22 +1108,22 @@ fs_write(fs_volume *_vol, fs_vnode *_dir, void *_cookie, off_t offset, } while (size) { - result = ntfs_attr_pwrite(na, offset, size, buf); - if (result < (s64)size) + off_t bytesWritten = ntfs_attr_pwrite(na, offset, size, buf); + if (bytesWritten < (s64)size) ERRPRINT("fs_write - ntfs_attr_pwrite returned less bytes than requested.\n"); - if (result <= 0) { + if (bytesWritten <= 0) { ERRPRINT(("fs_write - ntfs_attr_pwrite()<=0\n")); *len = 0; result = EINVAL; goto exit; } - size -= result; - offset += result; - total += result; + size -= bytesWritten; + offset += bytesWritten; + total += bytesWritten; } + *len = total; ERRPRINT(("fs_write - OK\n")); - result = B_NO_ERROR; exit: if (na)