Loading arch/sparc/kernel/leon_pci.c +0 −13 Original line number Original line Diff line number Diff line Loading @@ -45,7 +45,6 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info) void __devinit pcibios_fixup_bus(struct pci_bus *pbus) void __devinit pcibios_fixup_bus(struct pci_bus *pbus) { { struct leon_pci_info *info = pbus->sysdata; struct pci_dev *dev; struct pci_dev *dev; int i, has_io, has_mem; int i, has_io, has_mem; u16 cmd; u16 cmd; Loading Loading @@ -111,18 +110,6 @@ int pcibios_enable_device(struct pci_dev *dev, int mask) return pci_enable_resources(dev, mask); return pci_enable_resources(dev, mask); } } struct device_node *pci_device_to_OF_node(struct pci_dev *pdev) { /* * Currently the OpenBoot nodes are not connected with the PCI device, * this is because the LEON PROM does not create PCI nodes. Eventually * this will change and the same approach as pcic.c can be used to * match PROM nodes with pci devices. */ return NULL; } EXPORT_SYMBOL(pci_device_to_OF_node); void __devinit pcibios_update_irq(struct pci_dev *dev, int irq) void __devinit pcibios_update_irq(struct pci_dev *dev, int irq) { { #ifdef CONFIG_PCI_DEBUG #ifdef CONFIG_PCI_DEBUG Loading arch/sparc/mm/fault_32.c +30 −7 Original line number Original line Diff line number Diff line Loading @@ -225,6 +225,8 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write, unsigned long g2; unsigned long g2; int from_user = !(regs->psr & PSR_PS); int from_user = !(regs->psr & PSR_PS); int fault, code; int fault, code; unsigned int flags = (FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE | (write ? FAULT_FLAG_WRITE : 0)); if(text_fault) if(text_fault) address = regs->pc; address = regs->pc; Loading @@ -251,6 +253,7 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write, perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address); perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address); retry: down_read(&mm->mmap_sem); down_read(&mm->mmap_sem); /* /* Loading Loading @@ -289,7 +292,11 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write, * make sure we exit gracefully rather than endlessly redo * make sure we exit gracefully rather than endlessly redo * the fault. * the fault. */ */ fault = handle_mm_fault(mm, vma, address, write ? FAULT_FLAG_WRITE : 0); fault = handle_mm_fault(mm, vma, address, flags); if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current)) return; if (unlikely(fault & VM_FAULT_ERROR)) { if (unlikely(fault & VM_FAULT_ERROR)) { if (fault & VM_FAULT_OOM) if (fault & VM_FAULT_OOM) goto out_of_memory; goto out_of_memory; Loading @@ -297,13 +304,29 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write, goto do_sigbus; goto do_sigbus; BUG(); BUG(); } } if (flags & FAULT_FLAG_ALLOW_RETRY) { if (fault & VM_FAULT_MAJOR) { if (fault & VM_FAULT_MAJOR) { current->maj_flt++; current->maj_flt++; perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs, address); perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs, address); } else { } else { current->min_flt++; current->min_flt++; perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs, address); perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs, address); } if (fault & VM_FAULT_RETRY) { flags &= ~FAULT_FLAG_ALLOW_RETRY; /* No need to up_read(&mm->mmap_sem) as we would * have already released it in __lock_page_or_retry * in mm/filemap.c. */ goto retry; } } } up_read(&mm->mmap_sem); up_read(&mm->mmap_sem); return; return; Loading arch/sparc/mm/fault_64.c +30 −7 Original line number Original line Diff line number Diff line Loading @@ -279,6 +279,7 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs) unsigned int insn = 0; unsigned int insn = 0; int si_code, fault_code, fault; int si_code, fault_code, fault; unsigned long address, mm_rss; unsigned long address, mm_rss; unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE; fault_code = get_thread_fault_code(); fault_code = get_thread_fault_code(); Loading Loading @@ -333,6 +334,8 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs) insn = get_fault_insn(regs, insn); insn = get_fault_insn(regs, insn); goto handle_kernel_fault; goto handle_kernel_fault; } } retry: down_read(&mm->mmap_sem); down_read(&mm->mmap_sem); } } Loading Loading @@ -423,7 +426,12 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs) goto bad_area; goto bad_area; } } fault = handle_mm_fault(mm, vma, address, (fault_code & FAULT_CODE_WRITE) ? FAULT_FLAG_WRITE : 0); flags |= ((fault_code & FAULT_CODE_WRITE) ? FAULT_FLAG_WRITE : 0); fault = handle_mm_fault(mm, vma, address, flags); if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current)) return; if (unlikely(fault & VM_FAULT_ERROR)) { if (unlikely(fault & VM_FAULT_ERROR)) { if (fault & VM_FAULT_OOM) if (fault & VM_FAULT_OOM) goto out_of_memory; goto out_of_memory; Loading @@ -431,12 +439,27 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs) goto do_sigbus; goto do_sigbus; BUG(); BUG(); } } if (flags & FAULT_FLAG_ALLOW_RETRY) { if (fault & VM_FAULT_MAJOR) { if (fault & VM_FAULT_MAJOR) { current->maj_flt++; current->maj_flt++; perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs, address); perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs, address); } else { } else { current->min_flt++; current->min_flt++; perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs, address); perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs, address); } if (fault & VM_FAULT_RETRY) { flags &= ~FAULT_FLAG_ALLOW_RETRY; /* No need to up_read(&mm->mmap_sem) as we would * have already released it in __lock_page_or_retry * in mm/filemap.c. */ goto retry; } } } up_read(&mm->mmap_sem); up_read(&mm->mmap_sem); Loading arch/um/drivers/cow.h +0 −35 Original line number Original line Diff line number Diff line Loading @@ -3,41 +3,6 @@ #include <asm/types.h> #include <asm/types.h> #if defined(__KERNEL__) # include <asm/byteorder.h> # if defined(__BIG_ENDIAN) # define ntohll(x) (x) # define htonll(x) (x) # elif defined(__LITTLE_ENDIAN) # define ntohll(x) be64_to_cpu(x) # define htonll(x) cpu_to_be64(x) # else # error "Could not determine byte order" # endif #else /* For the definition of ntohl, htonl and __BYTE_ORDER */ #include <endian.h> #include <netinet/in.h> #if defined(__BYTE_ORDER) # if __BYTE_ORDER == __BIG_ENDIAN # define ntohll(x) (x) # define htonll(x) (x) # elif __BYTE_ORDER == __LITTLE_ENDIAN # define ntohll(x) bswap_64(x) # define htonll(x) bswap_64(x) # else # error "Could not determine byte order: __BYTE_ORDER uncorrectly defined" # endif #else /* ! defined(__BYTE_ORDER) */ # error "Could not determine byte order: __BYTE_ORDER not defined" #endif #endif /* ! defined(__KERNEL__) */ extern int init_cow_file(int fd, char *cow_file, char *backing_file, extern int init_cow_file(int fd, char *cow_file, char *backing_file, int sectorsize, int alignment, int *bitmap_offset_out, int sectorsize, int alignment, int *bitmap_offset_out, unsigned long *bitmap_len_out, int *data_offset_out); unsigned long *bitmap_len_out, int *data_offset_out); Loading arch/um/drivers/cow_user.c +21 −22 Original line number Original line Diff line number Diff line Loading @@ -8,11 +8,10 @@ * that. * that. */ */ #include <unistd.h> #include <unistd.h> #include <byteswap.h> #include <errno.h> #include <errno.h> #include <string.h> #include <string.h> #include <arpa/inet.h> #include <arpa/inet.h> #include <asm/types.h> #include <endian.h> #include "cow.h" #include "cow.h" #include "cow_sys.h" #include "cow_sys.h" Loading Loading @@ -214,8 +213,8 @@ int write_cow_header(char *cow_file, int fd, char *backing_file, "header\n"); "header\n"); goto out; goto out; } } header->magic = htonl(COW_MAGIC); header->magic = htobe32(COW_MAGIC); header->version = htonl(COW_VERSION); header->version = htobe32(COW_VERSION); err = -EINVAL; err = -EINVAL; if (strlen(backing_file) > sizeof(header->backing_file) - 1) { if (strlen(backing_file) > sizeof(header->backing_file) - 1) { Loading Loading @@ -246,10 +245,10 @@ int write_cow_header(char *cow_file, int fd, char *backing_file, goto out_free; goto out_free; } } header->mtime = htonl(modtime); header->mtime = htobe32(modtime); header->size = htonll(*size); header->size = htobe64(*size); header->sectorsize = htonl(sectorsize); header->sectorsize = htobe32(sectorsize); header->alignment = htonl(alignment); header->alignment = htobe32(alignment); header->cow_format = COW_BITMAP; header->cow_format = COW_BITMAP; err = cow_write_file(fd, header, sizeof(*header)); err = cow_write_file(fd, header, sizeof(*header)); Loading Loading @@ -301,8 +300,8 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg, magic = header->v1.magic; magic = header->v1.magic; if (magic == COW_MAGIC) if (magic == COW_MAGIC) version = header->v1.version; version = header->v1.version; else if (magic == ntohl(COW_MAGIC)) else if (magic == be32toh(COW_MAGIC)) version = ntohl(header->v1.version); version = be32toh(header->v1.version); /* No error printed because the non-COW case comes through here */ /* No error printed because the non-COW case comes through here */ else goto out; else goto out; Loading @@ -327,9 +326,9 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg, "header\n"); "header\n"); goto out; goto out; } } *mtime_out = ntohl(header->v2.mtime); *mtime_out = be32toh(header->v2.mtime); *size_out = ntohll(header->v2.size); *size_out = be64toh(header->v2.size); *sectorsize_out = ntohl(header->v2.sectorsize); *sectorsize_out = be32toh(header->v2.sectorsize); *bitmap_offset_out = sizeof(header->v2); *bitmap_offset_out = sizeof(header->v2); *align_out = *sectorsize_out; *align_out = *sectorsize_out; file = header->v2.backing_file; file = header->v2.backing_file; Loading @@ -341,10 +340,10 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg, "header\n"); "header\n"); goto out; goto out; } } *mtime_out = ntohl(header->v3.mtime); *mtime_out = be32toh(header->v3.mtime); *size_out = ntohll(header->v3.size); *size_out = be64toh(header->v3.size); *sectorsize_out = ntohl(header->v3.sectorsize); *sectorsize_out = be32toh(header->v3.sectorsize); *align_out = ntohl(header->v3.alignment); *align_out = be32toh(header->v3.alignment); if (*align_out == 0) { if (*align_out == 0) { cow_printf("read_cow_header - invalid COW header, " cow_printf("read_cow_header - invalid COW header, " "align == 0\n"); "align == 0\n"); Loading @@ -366,16 +365,16 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg, * this was used until Dec2005 - 64bits are needed to represent * this was used until Dec2005 - 64bits are needed to represent * 2038+. I.e. we can safely do this truncating cast. * 2038+. I.e. we can safely do this truncating cast. * * * Additionally, we must use ntohl() instead of ntohll(), since * Additionally, we must use be32toh() instead of be64toh(), since * the program used to use the former (tested - I got mtime * the program used to use the former (tested - I got mtime * mismatch "0 vs whatever"). * mismatch "0 vs whatever"). * * * Ever heard about bug-to-bug-compatibility ? ;-) */ * Ever heard about bug-to-bug-compatibility ? ;-) */ *mtime_out = (time32_t) ntohl(header->v3_b.mtime); *mtime_out = (time32_t) be32toh(header->v3_b.mtime); *size_out = ntohll(header->v3_b.size); *size_out = be64toh(header->v3_b.size); *sectorsize_out = ntohl(header->v3_b.sectorsize); *sectorsize_out = be32toh(header->v3_b.sectorsize); *align_out = ntohl(header->v3_b.alignment); *align_out = be32toh(header->v3_b.alignment); if (*align_out == 0) { if (*align_out == 0) { cow_printf("read_cow_header - invalid COW header, " cow_printf("read_cow_header - invalid COW header, " "align == 0\n"); "align == 0\n"); Loading Loading
arch/sparc/kernel/leon_pci.c +0 −13 Original line number Original line Diff line number Diff line Loading @@ -45,7 +45,6 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info) void __devinit pcibios_fixup_bus(struct pci_bus *pbus) void __devinit pcibios_fixup_bus(struct pci_bus *pbus) { { struct leon_pci_info *info = pbus->sysdata; struct pci_dev *dev; struct pci_dev *dev; int i, has_io, has_mem; int i, has_io, has_mem; u16 cmd; u16 cmd; Loading Loading @@ -111,18 +110,6 @@ int pcibios_enable_device(struct pci_dev *dev, int mask) return pci_enable_resources(dev, mask); return pci_enable_resources(dev, mask); } } struct device_node *pci_device_to_OF_node(struct pci_dev *pdev) { /* * Currently the OpenBoot nodes are not connected with the PCI device, * this is because the LEON PROM does not create PCI nodes. Eventually * this will change and the same approach as pcic.c can be used to * match PROM nodes with pci devices. */ return NULL; } EXPORT_SYMBOL(pci_device_to_OF_node); void __devinit pcibios_update_irq(struct pci_dev *dev, int irq) void __devinit pcibios_update_irq(struct pci_dev *dev, int irq) { { #ifdef CONFIG_PCI_DEBUG #ifdef CONFIG_PCI_DEBUG Loading
arch/sparc/mm/fault_32.c +30 −7 Original line number Original line Diff line number Diff line Loading @@ -225,6 +225,8 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write, unsigned long g2; unsigned long g2; int from_user = !(regs->psr & PSR_PS); int from_user = !(regs->psr & PSR_PS); int fault, code; int fault, code; unsigned int flags = (FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE | (write ? FAULT_FLAG_WRITE : 0)); if(text_fault) if(text_fault) address = regs->pc; address = regs->pc; Loading @@ -251,6 +253,7 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write, perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address); perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address); retry: down_read(&mm->mmap_sem); down_read(&mm->mmap_sem); /* /* Loading Loading @@ -289,7 +292,11 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write, * make sure we exit gracefully rather than endlessly redo * make sure we exit gracefully rather than endlessly redo * the fault. * the fault. */ */ fault = handle_mm_fault(mm, vma, address, write ? FAULT_FLAG_WRITE : 0); fault = handle_mm_fault(mm, vma, address, flags); if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current)) return; if (unlikely(fault & VM_FAULT_ERROR)) { if (unlikely(fault & VM_FAULT_ERROR)) { if (fault & VM_FAULT_OOM) if (fault & VM_FAULT_OOM) goto out_of_memory; goto out_of_memory; Loading @@ -297,13 +304,29 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write, goto do_sigbus; goto do_sigbus; BUG(); BUG(); } } if (flags & FAULT_FLAG_ALLOW_RETRY) { if (fault & VM_FAULT_MAJOR) { if (fault & VM_FAULT_MAJOR) { current->maj_flt++; current->maj_flt++; perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs, address); perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs, address); } else { } else { current->min_flt++; current->min_flt++; perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs, address); perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs, address); } if (fault & VM_FAULT_RETRY) { flags &= ~FAULT_FLAG_ALLOW_RETRY; /* No need to up_read(&mm->mmap_sem) as we would * have already released it in __lock_page_or_retry * in mm/filemap.c. */ goto retry; } } } up_read(&mm->mmap_sem); up_read(&mm->mmap_sem); return; return; Loading
arch/sparc/mm/fault_64.c +30 −7 Original line number Original line Diff line number Diff line Loading @@ -279,6 +279,7 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs) unsigned int insn = 0; unsigned int insn = 0; int si_code, fault_code, fault; int si_code, fault_code, fault; unsigned long address, mm_rss; unsigned long address, mm_rss; unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE; fault_code = get_thread_fault_code(); fault_code = get_thread_fault_code(); Loading Loading @@ -333,6 +334,8 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs) insn = get_fault_insn(regs, insn); insn = get_fault_insn(regs, insn); goto handle_kernel_fault; goto handle_kernel_fault; } } retry: down_read(&mm->mmap_sem); down_read(&mm->mmap_sem); } } Loading Loading @@ -423,7 +426,12 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs) goto bad_area; goto bad_area; } } fault = handle_mm_fault(mm, vma, address, (fault_code & FAULT_CODE_WRITE) ? FAULT_FLAG_WRITE : 0); flags |= ((fault_code & FAULT_CODE_WRITE) ? FAULT_FLAG_WRITE : 0); fault = handle_mm_fault(mm, vma, address, flags); if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current)) return; if (unlikely(fault & VM_FAULT_ERROR)) { if (unlikely(fault & VM_FAULT_ERROR)) { if (fault & VM_FAULT_OOM) if (fault & VM_FAULT_OOM) goto out_of_memory; goto out_of_memory; Loading @@ -431,12 +439,27 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs) goto do_sigbus; goto do_sigbus; BUG(); BUG(); } } if (flags & FAULT_FLAG_ALLOW_RETRY) { if (fault & VM_FAULT_MAJOR) { if (fault & VM_FAULT_MAJOR) { current->maj_flt++; current->maj_flt++; perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs, address); perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs, address); } else { } else { current->min_flt++; current->min_flt++; perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs, address); perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs, address); } if (fault & VM_FAULT_RETRY) { flags &= ~FAULT_FLAG_ALLOW_RETRY; /* No need to up_read(&mm->mmap_sem) as we would * have already released it in __lock_page_or_retry * in mm/filemap.c. */ goto retry; } } } up_read(&mm->mmap_sem); up_read(&mm->mmap_sem); Loading
arch/um/drivers/cow.h +0 −35 Original line number Original line Diff line number Diff line Loading @@ -3,41 +3,6 @@ #include <asm/types.h> #include <asm/types.h> #if defined(__KERNEL__) # include <asm/byteorder.h> # if defined(__BIG_ENDIAN) # define ntohll(x) (x) # define htonll(x) (x) # elif defined(__LITTLE_ENDIAN) # define ntohll(x) be64_to_cpu(x) # define htonll(x) cpu_to_be64(x) # else # error "Could not determine byte order" # endif #else /* For the definition of ntohl, htonl and __BYTE_ORDER */ #include <endian.h> #include <netinet/in.h> #if defined(__BYTE_ORDER) # if __BYTE_ORDER == __BIG_ENDIAN # define ntohll(x) (x) # define htonll(x) (x) # elif __BYTE_ORDER == __LITTLE_ENDIAN # define ntohll(x) bswap_64(x) # define htonll(x) bswap_64(x) # else # error "Could not determine byte order: __BYTE_ORDER uncorrectly defined" # endif #else /* ! defined(__BYTE_ORDER) */ # error "Could not determine byte order: __BYTE_ORDER not defined" #endif #endif /* ! defined(__KERNEL__) */ extern int init_cow_file(int fd, char *cow_file, char *backing_file, extern int init_cow_file(int fd, char *cow_file, char *backing_file, int sectorsize, int alignment, int *bitmap_offset_out, int sectorsize, int alignment, int *bitmap_offset_out, unsigned long *bitmap_len_out, int *data_offset_out); unsigned long *bitmap_len_out, int *data_offset_out); Loading
arch/um/drivers/cow_user.c +21 −22 Original line number Original line Diff line number Diff line Loading @@ -8,11 +8,10 @@ * that. * that. */ */ #include <unistd.h> #include <unistd.h> #include <byteswap.h> #include <errno.h> #include <errno.h> #include <string.h> #include <string.h> #include <arpa/inet.h> #include <arpa/inet.h> #include <asm/types.h> #include <endian.h> #include "cow.h" #include "cow.h" #include "cow_sys.h" #include "cow_sys.h" Loading Loading @@ -214,8 +213,8 @@ int write_cow_header(char *cow_file, int fd, char *backing_file, "header\n"); "header\n"); goto out; goto out; } } header->magic = htonl(COW_MAGIC); header->magic = htobe32(COW_MAGIC); header->version = htonl(COW_VERSION); header->version = htobe32(COW_VERSION); err = -EINVAL; err = -EINVAL; if (strlen(backing_file) > sizeof(header->backing_file) - 1) { if (strlen(backing_file) > sizeof(header->backing_file) - 1) { Loading Loading @@ -246,10 +245,10 @@ int write_cow_header(char *cow_file, int fd, char *backing_file, goto out_free; goto out_free; } } header->mtime = htonl(modtime); header->mtime = htobe32(modtime); header->size = htonll(*size); header->size = htobe64(*size); header->sectorsize = htonl(sectorsize); header->sectorsize = htobe32(sectorsize); header->alignment = htonl(alignment); header->alignment = htobe32(alignment); header->cow_format = COW_BITMAP; header->cow_format = COW_BITMAP; err = cow_write_file(fd, header, sizeof(*header)); err = cow_write_file(fd, header, sizeof(*header)); Loading Loading @@ -301,8 +300,8 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg, magic = header->v1.magic; magic = header->v1.magic; if (magic == COW_MAGIC) if (magic == COW_MAGIC) version = header->v1.version; version = header->v1.version; else if (magic == ntohl(COW_MAGIC)) else if (magic == be32toh(COW_MAGIC)) version = ntohl(header->v1.version); version = be32toh(header->v1.version); /* No error printed because the non-COW case comes through here */ /* No error printed because the non-COW case comes through here */ else goto out; else goto out; Loading @@ -327,9 +326,9 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg, "header\n"); "header\n"); goto out; goto out; } } *mtime_out = ntohl(header->v2.mtime); *mtime_out = be32toh(header->v2.mtime); *size_out = ntohll(header->v2.size); *size_out = be64toh(header->v2.size); *sectorsize_out = ntohl(header->v2.sectorsize); *sectorsize_out = be32toh(header->v2.sectorsize); *bitmap_offset_out = sizeof(header->v2); *bitmap_offset_out = sizeof(header->v2); *align_out = *sectorsize_out; *align_out = *sectorsize_out; file = header->v2.backing_file; file = header->v2.backing_file; Loading @@ -341,10 +340,10 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg, "header\n"); "header\n"); goto out; goto out; } } *mtime_out = ntohl(header->v3.mtime); *mtime_out = be32toh(header->v3.mtime); *size_out = ntohll(header->v3.size); *size_out = be64toh(header->v3.size); *sectorsize_out = ntohl(header->v3.sectorsize); *sectorsize_out = be32toh(header->v3.sectorsize); *align_out = ntohl(header->v3.alignment); *align_out = be32toh(header->v3.alignment); if (*align_out == 0) { if (*align_out == 0) { cow_printf("read_cow_header - invalid COW header, " cow_printf("read_cow_header - invalid COW header, " "align == 0\n"); "align == 0\n"); Loading @@ -366,16 +365,16 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg, * this was used until Dec2005 - 64bits are needed to represent * this was used until Dec2005 - 64bits are needed to represent * 2038+. I.e. we can safely do this truncating cast. * 2038+. I.e. we can safely do this truncating cast. * * * Additionally, we must use ntohl() instead of ntohll(), since * Additionally, we must use be32toh() instead of be64toh(), since * the program used to use the former (tested - I got mtime * the program used to use the former (tested - I got mtime * mismatch "0 vs whatever"). * mismatch "0 vs whatever"). * * * Ever heard about bug-to-bug-compatibility ? ;-) */ * Ever heard about bug-to-bug-compatibility ? ;-) */ *mtime_out = (time32_t) ntohl(header->v3_b.mtime); *mtime_out = (time32_t) be32toh(header->v3_b.mtime); *size_out = ntohll(header->v3_b.size); *size_out = be64toh(header->v3_b.size); *sectorsize_out = ntohl(header->v3_b.sectorsize); *sectorsize_out = be32toh(header->v3_b.sectorsize); *align_out = ntohl(header->v3_b.alignment); *align_out = be32toh(header->v3_b.alignment); if (*align_out == 0) { if (*align_out == 0) { cow_printf("read_cow_header - invalid COW header, " cow_printf("read_cow_header - invalid COW header, " "align == 0\n"); "align == 0\n"); Loading