r3801: added allocation size rounding. This is needed for ifstest.
authorAndrew Tridgell <tridge@samba.org>
Wed, 17 Nov 2004 07:17:55 +0000 (07:17 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:05:55 +0000 (13:05 -0500)
(This used to be commit 8a6fa43156667f75e058c7d44b1c15a6cf7067b2)

source4/ntvfs/posix/pvfs_fileinfo.c
source4/ntvfs/posix/pvfs_setfileinfo.c
source4/ntvfs/posix/pvfs_streams.c
source4/ntvfs/posix/pvfs_util.c
source4/ntvfs/posix/pvfs_xattr.c

index dbf18edccea2c3e65ea414763bc63c146460304f..32c7ae34fa2991aae27dce803ad32fc439a425cf 100644 (file)
@@ -93,7 +93,7 @@ NTSTATUS pvfs_fill_dos_info(struct pvfs_state *pvfs, struct pvfs_filename *name,
        name->dos.change_time += name->st.st_ctim.tv_nsec / 100;
 #endif
        name->dos.attrib = dos_mode_from_stat(pvfs, &name->st);
-       name->dos.alloc_size = name->st.st_size;
+       name->dos.alloc_size = pvfs_round_alloc_size(pvfs, name->st.st_size);
        name->dos.nlink = name->st.st_nlink;
        name->dos.ea_size = 0;
        name->dos.file_id = (((uint64_t)name->st.st_dev)<<32) | name->st.st_ino;
@@ -113,7 +113,8 @@ mode_t pvfs_fileperms(struct pvfs_state *pvfs, uint32 attrib)
                mode |= S_IXUSR | S_IXGRP | S_IXOTH;
        }
 
-       if (!(attrib & FILE_ATTRIBUTE_READONLY)) {
+       if (!(attrib & FILE_ATTRIBUTE_READONLY) ||
+           (pvfs->flags & PVFS_FLAG_XATTR_ENABLE)) {
                mode |= S_IWUSR;
        }
 
index 58a3372f820daf86a6fb09ae0ac5b51d3b9a20b2..37d8a290b8625b36683f556a102b873e08295c96 100644 (file)
@@ -273,6 +273,8 @@ NTSTATUS pvfs_setfileinfo(struct ntvfs_module_context *ntvfs,
                if (newstats.dos.alloc_size < newstats.st.st_size) {
                        newstats.st.st_size = newstats.dos.alloc_size;
                }
+               newstats.dos.alloc_size = pvfs_round_alloc_size(pvfs, 
+                                                               newstats.dos.alloc_size);
                break;
 
        case RAW_SFILEINFO_END_OF_FILE_INFO:
@@ -443,6 +445,8 @@ NTSTATUS pvfs_setpathinfo(struct ntvfs_module_context *ntvfs,
                if (newstats.dos.alloc_size < newstats.st.st_size) {
                        newstats.st.st_size = newstats.dos.alloc_size;
                }
+               newstats.dos.alloc_size = pvfs_round_alloc_size(pvfs, 
+                                                               newstats.dos.alloc_size);
                break;
 
        case RAW_SFILEINFO_END_OF_FILE_INFO:
index 7edf111fc97d8c463e95236e81d0cea97b773a4a..13a4ca1265a81ad0dc058a465db864b913602e1a 100644 (file)
@@ -99,7 +99,7 @@ NTSTATUS pvfs_stream_info(struct pvfs_state *pvfs, struct pvfs_filename *name, i
        for (i=0;i<streams->num_streams;i++) {
                struct xattr_DosStream *s = &streams->streams[i];
                if (StrCaseCmp(s->name, name->stream_name) == 0) {
-                       name->dos.alloc_size = s->alloc_size;
+                       name->dos.alloc_size = pvfs_round_alloc_size(pvfs, s->alloc_size);
                        name->st.st_size     = s->size;
                        name->stream_exists = True;
                        talloc_free(streams);
@@ -141,7 +141,7 @@ static NTSTATUS pvfs_stream_update_size(struct pvfs_state *pvfs, struct pvfs_fil
                struct xattr_DosStream *s = &streams->streams[i];
                if (StrCaseCmp(s->name, name->stream_name) == 0) {
                        s->size       = size;
-                       s->alloc_size = size;
+                       s->alloc_size = pvfs_round_alloc_size(pvfs, size);
                        break;
                }
        }
@@ -160,7 +160,7 @@ static NTSTATUS pvfs_stream_update_size(struct pvfs_state *pvfs, struct pvfs_fil
                
                s->flags      = XATTR_STREAM_FLAG_INTERNAL;
                s->size       = size;
-               s->alloc_size = size;
+               s->alloc_size = pvfs_round_alloc_size(pvfs, size);
                s->name       = name->stream_name;
        }
 
index 9f617d39d48292f5ff6857805630f84be6210157..67dd9d22b33782192c3445ec112e68f282f8cf61 100644 (file)
@@ -187,3 +187,14 @@ uint32_t pvfs_name_hash(const char *key, size_t length)
 
        return value;
 }
+
+
+/*
+  file allocation size rounding. This is required to pass ifstest
+*/
+uint64_t pvfs_round_alloc_size(struct pvfs_state *pvfs, uint64_t size)
+{
+       const uint64_t round_value = 511;
+       if (size == 0) return 0;
+       return (size + round_value) & ~round_value;
+}
index ff0c0f511623f93422bff45d660b093914243508..6984c2d284df4cd4785a71cc6e8321ef3af056f2 100644 (file)
@@ -224,7 +224,8 @@ NTSTATUS pvfs_dosattrib_load(struct pvfs_state *pvfs, struct pvfs_filename *name
                name->dos.attrib = pvfs_attrib_normalise(info1->attrib);
                name->dos.ea_size = info1->ea_size;
                if (name->st.st_size == info1->size) {
-                       name->dos.alloc_size = info1->alloc_size;
+                       name->dos.alloc_size = 
+                               pvfs_round_alloc_size(pvfs, info1->alloc_size);
                }
                if (info1->create_time != 0) {
                        name->dos.create_time = info1->create_time;