Changes by: cha0smaster
Update of /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27378/ntfsprogs
Modified Files:
ntfsmount.c
Log Message:
* attrib.c: refix ntfs_attr_p{read,write}
* ntfsmount.c: code that now not really needed, but for any case
Index: ntfsmount.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfsmount.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -p -r1.18 -r1.19
--- ntfsmount.c 1 Aug 2005 22:04:28 -0000 1.18
+++ ntfsmount.c 3 Aug 2005 13:52:51 -0000 1.19
@@ -378,11 +378,10 @@ static int ntfs_fuse_read(const char *or
{
ntfs_volume *vol;
ntfs_inode *ni = NULL;
- ntfs_attr *na;
- int res;
+ ntfs_attr *na = NULL;
char *path = NULL;
ntfschar *stream_name;
- int stream_name_len;
+ int stream_name_len, res, total = 0;
stream_name_len = ntfs_fuse_parse_path(org_path, &path, &stream_name);
if (stream_name_len < 0)
@@ -398,11 +397,25 @@ static int ntfs_fuse_read(const char *or
res = -errno;
goto exit;
}
- res = ntfs_attr_pread(na, offset, size, buf);
- if (res == -1)
- res = -errno;
- ntfs_attr_close(na);
+ if (offset + size > na->data_size)
+ size = na->data_size - offset;
+ while (size) {
+ res = ntfs_attr_pread(na, offset, size, buf);
+ if (res < size)
+ perror("ntfs_attr_pread returned less bytes than "
+ "requested.");
+ if (res <= 0) {
+ res = -errno;
+ goto exit;
+ }
+ size -= res;
+ offset += res;
+ total += res;
+ }
+ res = total;
exit:
+ if (na)
+ ntfs_attr_close(na);
if (ni && ntfs_inode_close(ni))
perror("Failed to close inode");
free(path);
@@ -416,11 +429,10 @@ static int ntfs_fuse_write(const char *o
{
ntfs_volume *vol;
ntfs_inode *ni = NULL;
- ntfs_attr *na;
- int res;
+ ntfs_attr *na = NULL;
char *path = NULL;
ntfschar *stream_name;
- int stream_name_len;
+ int stream_name_len, res, total = 0;
stream_name_len = ntfs_fuse_parse_path(org_path, &path, &stream_name);
if (stream_name_len < 0)
@@ -436,14 +448,24 @@ static int ntfs_fuse_write(const char *o
res = -errno;
goto exit;
}
- res = ntfs_attr_pwrite(na, offset, size, buf);
- if (res == -1)
- res = -errno;
- if (res < size)
- perror("ntfs_attr_pwrite returned less than requested.");
+ while (size) {
+ res = ntfs_attr_pwrite(na, offset, size, buf);
+ if (res < size)
+ perror("ntfs_attr_pwrite returned less bytes than "
+ "requested.");
+ if (res <= 0) {
+ res = -errno;
+ goto exit;
+ }
+ size -= res;
+ offset += res;
+ total += res;
+ }
+ res = total;
+exit:
ctx->state |= (NF_FreeClustersOutdate | NF_FreeMFTOutdate);
- ntfs_attr_close(na);
-exit:
+ if (na)
+ ntfs_attr_close(na);
if (ni && ntfs_inode_close(ni))
perror("Failed to close inode");
free(path);
|