Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _ADFS_FS_H |
| 2 | #define _ADFS_FS_H |
| 3 | |
David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 4 | #include <uapi/linux/adfs_fs.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | |
| 6 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * Calculate the boot block checksum on an ADFS drive. Note that this will |
| 8 | * appear to be correct if the sector contains all zeros, so also check that |
| 9 | * the disk size is non-zero!!! |
| 10 | */ |
| 11 | static inline int adfs_checkbblk(unsigned char *ptr) |
| 12 | { |
| 13 | unsigned int result = 0; |
| 14 | unsigned char *p = ptr + 511; |
| 15 | |
| 16 | do { |
| 17 | result = (result & 0xff) + (result >> 8); |
| 18 | result = result + *--p; |
| 19 | } while (p != ptr); |
| 20 | |
| 21 | return (result & 0xff) != ptr[511]; |
| 22 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #endif |