blob: 4836e382ad52f40cefb4c343420fcccd8085816f [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#ifndef _ADFS_FS_H
3#define _ADFS_FS_H
4
David Howells607ca462012-10-13 10:46:48 +01005#include <uapi/linux/adfs_fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006
7/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Calculate the boot block checksum on an ADFS drive. Note that this will
9 * appear to be correct if the sector contains all zeros, so also check that
10 * 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}
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#endif