|
|
1.1 ! root 1: /* ! 2: * libhfs - library for reading and writing Macintosh HFS volumes ! 3: * Copyright (C) 1996-1998 Robert Leslie ! 4: * ! 5: * This program is free software; you can redistribute it and/or modify ! 6: * it under the terms of the GNU General Public License as published by ! 7: * the Free Software Foundation; either version 2 of the License, or ! 8: * (at your option) any later version. ! 9: * ! 10: * This program is distributed in the hope that it will be useful, ! 11: * but WITHOUT ANY WARRANTY; without even the implied warranty of ! 12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! 13: * GNU General Public License for more details. ! 14: * ! 15: * You should have received a copy of the GNU General Public License ! 16: * along with this program; if not, write to the Free Software ! 17: * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, ! 18: * MA 02110-1301, USA. ! 19: * ! 20: * $Id: medium.c,v 1.4 1998/11/02 22:09:04 rob Exp $ ! 21: */ ! 22: ! 23: #include "config.h" ! 24: #include "libhfs.h" ! 25: #include "block.h" ! 26: #include "low.h" ! 27: #include "medium.h" ! 28: ! 29: ! 30: /* ! 31: * NAME: medium->findpmentry() ! 32: * DESCRIPTION: locate a partition map entry ! 33: */ ! 34: int m_findpmentry(hfsvol *vol, const char *type, ! 35: Partition *map, unsigned long *start) ! 36: { ! 37: unsigned long bnum; ! 38: int found = 0; ! 39: ! 40: if (start && *start > 0) ! 41: { ! 42: bnum = *start; ! 43: ! 44: if (bnum++ >= (unsigned long) map->pmMapBlkCnt) ! 45: ERROR(EINVAL, "partition not found"); ! 46: } ! 47: else ! 48: bnum = 1; ! 49: ! 50: while (1) ! 51: { ! 52: if (l_getpmentry(vol, map, bnum) == -1) ! 53: { ! 54: found = -1; ! 55: goto fail; ! 56: } ! 57: ! 58: if (map->pmSig != HFS_PM_SIGWORD) ! 59: { ! 60: found = -1; ! 61: ! 62: if (map->pmSig == HFS_PM_SIGWORD_OLD) ! 63: ERROR(EINVAL, "old partition map format not supported"); ! 64: else ! 65: ERROR(EINVAL, "invalid partition map"); ! 66: } ! 67: ! 68: if (strcmp((char *) map->pmParType, type) == 0) ! 69: { ! 70: found = 1; ! 71: goto done; ! 72: } ! 73: ! 74: if (bnum++ >= (unsigned long) map->pmMapBlkCnt) ! 75: ERROR(EINVAL, "partition not found"); ! 76: } ! 77: ! 78: done: ! 79: if (start) ! 80: *start = bnum; ! 81: ! 82: fail: ! 83: return found; ! 84: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.