adfs_fs.h 574 B

123456789101112131415161718192021222324
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ADFS_FS_H
  3. #define _ADFS_FS_H
  4. #include <uapi/linux/adfs_fs.h>
  5. /*
  6. * Calculate the boot block checksum on an ADFS drive. Note that this will
  7. * appear to be correct if the sector contains all zeros, so also check that
  8. * the disk size is non-zero!!!
  9. */
  10. static inline int adfs_checkbblk(unsigned char *ptr)
  11. {
  12. unsigned int result = 0;
  13. unsigned char *p = ptr + 511;
  14. do {
  15. result = (result & 0xff) + (result >> 8);
  16. result = result + *--p;
  17. } while (p != ptr);
  18. return (result & 0xff) != ptr[511];
  19. }
  20. #endif