adfs_fs.h 535 B

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