]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
NTFS: Fix several occurences of a bug where we would perform 'var & ~const'
authorAnton Altaparmakov <aia21@cantab.net>
Sat, 25 Jun 2005 15:51:58 +0000 (16:51 +0100)
committerAnton Altaparmakov <aia21@cantab.net>
Sat, 25 Jun 2005 15:51:58 +0000 (16:51 +0100)
      with a 64-bit variable and a int, i.e. 32-bit, constant.  This causes
      the higher order 32-bits of the 64-bit variable to be zeroed.  To fix
      this cast the 'const' to the same 64-bit type as 'var'.

Signed-off-by: Anton Altaparmakov <aia21@cantab.net>
fs/ntfs/ChangeLog
fs/ntfs/dir.c
fs/ntfs/inode.h
fs/ntfs/lcnalloc.c
fs/ntfs/logfile.c

index c089bf0c02ac351f720d808e84378ceca494006e..a916c8b0697aff187862d1c4862530f7d687ca2f 100644 (file)
@@ -128,6 +128,10 @@ ToDo/Notes:
        - Detect the case when Windows has been suspended to disk on the volume
          to be mounted and if this is the case do not allow (re)mounting
          read-write.  This is done by parsing hiberfil.sys if present.
+       - Fix several occurences of a bug where we would perform 'var & ~const'
+         with a 64-bit variable and a int, i.e. 32-bit, constant.  This causes
+         the higher order 32-bits of the 64-bit variable to be zeroed.  To fix
+         this cast the 'const' to the same 64-bit type as 'var'.
 
 2.1.22 - Many bug and race fixes and error handling improvements.
 
index a56ca1821eed9bbf9fcdf3b4a2e4a34df489dbaf..46779471c542ee70bf73e7df0e4914b6a3b1e6bc 100644 (file)
@@ -1308,7 +1308,8 @@ find_next_index_buffer:
        ntfs_debug("Handling index buffer 0x%llx.",
                        (unsigned long long)bmp_pos + cur_bmp_pos);
        /* If the current index buffer is in the same page we reuse the page. */
-       if ((prev_ia_pos & PAGE_CACHE_MASK) != (ia_pos & PAGE_CACHE_MASK)) {
+       if ((prev_ia_pos & (s64)PAGE_CACHE_MASK) !=
+                       (ia_pos & (s64)PAGE_CACHE_MASK)) {
                prev_ia_pos = ia_pos;
                if (likely(ia_page != NULL)) {
                        unlock_page(ia_page);
index 6eb99777a722949c663d3415aa1911cff4c76d80..3de5c0231966708c0ae8346dcf24795ecf761c8d 100644 (file)
@@ -110,7 +110,7 @@ struct _ntfs_inode {
                        u8 block_size_bits;     /* Log2 of the above. */
                        u8 vcn_size_bits;       /* Log2 of the above. */
                } index;
-               struct { /* It is a compressed file or an attribute inode. */
+               struct { /* It is a compressed/sparse file/attribute inode. */
                        s64 size;               /* Copy of compressed_size from
                                                   $DATA. */
                        u32 block_size;         /* Size of a compression block
index 7087b5b0e6cea11c90098d39715bc01b73a6e0ad..a4bc07616e5dd5afe4d6ede562b3dfff7f0d7169 100644 (file)
@@ -293,7 +293,7 @@ runlist_element *ntfs_cluster_alloc(ntfs_volume *vol, const VCN start_vcn,
                        buf_size = i_size - last_read_pos;
                buf_size <<= 3;
                lcn = bmp_pos & 7;
-               bmp_pos &= ~7;
+               bmp_pos &= ~(LCN)7;
                ntfs_debug("Before inner while loop: buf_size %i, lcn 0x%llx, "
                                "bmp_pos 0x%llx, need_writeback %i.", buf_size,
                                (unsigned long long)lcn,
@@ -311,7 +311,7 @@ runlist_element *ntfs_cluster_alloc(ntfs_volume *vol, const VCN start_vcn,
                                        (unsigned int)*byte);
                        /* Skip full bytes. */
                        if (*byte == 0xff) {
-                               lcn = (lcn + 8) & ~7;
+                               lcn = (lcn + 8) & ~(LCN)7;
                                ntfs_debug("Continuing while loop 1.");
                                continue;
                        }
index e680dd0cdb641bbb4c70f00eeb3c42fe5cd7c5cc..8edb8e20fb08f18e8fe5d2b57257d0c0f099a7c3 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * logfile.c - NTFS kernel journal handling. Part of the Linux-NTFS project.
  *
- * Copyright (c) 2002-2004 Anton Altaparmakov
+ * Copyright (c) 2002-2005 Anton Altaparmakov
  *
  * This program/include file is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as published
@@ -410,7 +410,7 @@ err_out:
 }
 
 /**
- * ntfs_ckeck_logfile - check in the journal if the volume is consistent
+ * ntfs_check_logfile - check the journal for consistency
  * @log_vi:    struct inode of loaded journal $LogFile to check
  *
  * Check the $LogFile journal for consistency and return TRUE if it is
@@ -464,7 +464,7 @@ BOOL ntfs_check_logfile(struct inode *log_vi)
         * optimize log_page_size and log_page_bits into constants.
         */
        log_page_bits = generic_ffs(log_page_size) - 1;
-       size &= ~(log_page_size - 1);
+       size &= ~(s64)(log_page_size - 1);
        /*
         * Ensure the log file is big enough to store at least the two restart
         * pages and the minimum number of log record pages.