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