2
* Copyright (c) International Business Machines Corp., 2000
2
* Copyright (c) International Business Machines Corp., 2000-2002
4
4
* This program is free software; you can redistribute it and/or modify
5
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
6
* the Free Software Foundation; either version 2 of the License, or
7
7
* (at your option) any later version.
9
9
* This program is distributed in the hope that it will be useful,
10
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
12
12
* the GNU General Public License for more details.
14
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
15
* along with this program; if not, write to the Free Software
16
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
* COMPONENT_NAME: jfs fsck
24
* This module was created by copying jfs_ValidateFEAList from
27
* Any changes to this code in jfs_ea.c require corresponding
32
#define INCL_DOSERRORS
33
#define INCL_DOSPROCESS
35
#define _cdecl __cdecl
39
/* some macros for dealing with variable length EA lists.
42
#define FEA_SIZE(ea) ((ea)->cbValue + (ea)->cbName + 1 + sizeof (FEA))
43
#define NEXT_FEA(ea) ((FEA*)(((char *) (ea)) + (FEA_SIZE (ea))))
19
#include "jfs_byteorder.h"
21
/* some macros for dealing with variable length EA lists. */
22
#define FEA_SIZE(ea) (__le16_to_cpu((ea)->cbValue) + (ea)->cbName + 1 + \
24
#define NEXT_FEA(ea) ((struct FEA*)(((char *) (ea)) + (FEA_SIZE (ea))))
45
26
#define GEA_SIZE(ea) ((ea)->cbName + sizeof (GEA))
46
27
#define NEXT_GEA(ea) ((GEA*)(((char *) (ea)) + (GEA_SIZE (ea))))
57
38
* jfs_ValidateFEAList -- validate structure of an FEALIST
60
int jfs_ValidateFEAList ( FEALIST *pfeal,
61
unsigned long *poError )
41
int jfs_ValidateFEAList(struct FEALIST *pfeal, int size, unsigned long *poError)
63
unsigned short cbLeft; /* count of bytes left in FEA list */
64
PFEA pfea = pfeal->list; /* pointer to current FEA */
65
unsigned short cbFEA; /* count of bytes in current FEA */
67
if ((cbLeft = (unsigned short) pfeal->cbList - sizeof (pfeal->cbList)) == 0)
71
/* check for our reserved bits
73
if (pfea->fEA & ~(FEA_NEEDEA) || cbLeft < sizeof *pfea)
74
return ERROR_EA_LIST_INCONSISTENT;
76
cbFEA = FEA_SIZE (pfea);
77
pfea = NEXT_FEA (pfea);
80
*poError = (((char *) pfea) - ((char *) pfeal));
81
return ERROR_EA_LIST_INCONSISTENT;
84
} while ((cbLeft -= cbFEA) > 0);
43
unsigned int cbLeft; /* count of bytes left in FEA list */
44
struct FEA *pfea = pfeal->list; /* pointer to current FEA */
45
unsigned int cbFEA; /* count of bytes in current FEA */
47
cbLeft = __le32_to_cpu(pfeal->cbList);
49
return ERROR_EA_LIST_INCONSISTENT;
51
cbLeft -= sizeof (pfeal->cbList);
57
/* check for our reserved bits
59
if (pfea->fEA & ~(FEA_NEEDEA) || cbLeft < sizeof *pfea)
60
return ERROR_EA_LIST_INCONSISTENT;
62
cbFEA = FEA_SIZE(pfea);
63
pfea = NEXT_FEA(pfea);
66
*poError = (((char *) pfea) - ((char *) pfeal));
67
return ERROR_EA_LIST_INCONSISTENT;
70
} while ((cbLeft -= cbFEA) > 0);