apm.c revision 263442
1263409Smarcel/*-
2263409Smarcel * Copyright (c) 2014 Juniper Networks, Inc.
3263409Smarcel * All rights reserved.
4263409Smarcel *
5263409Smarcel * Redistribution and use in source and binary forms, with or without
6263409Smarcel * modification, are permitted provided that the following conditions
7263409Smarcel * are met:
8263409Smarcel * 1. Redistributions of source code must retain the above copyright
9263409Smarcel *    notice, this list of conditions and the following disclaimer.
10263409Smarcel * 2. Redistributions in binary form must reproduce the above copyright
11263409Smarcel *    notice, this list of conditions and the following disclaimer in the
12263409Smarcel *    documentation and/or other materials provided with the distribution.
13263409Smarcel *
14263409Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15263409Smarcel * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16263409Smarcel * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17263409Smarcel * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18263409Smarcel * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19263409Smarcel * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20263409Smarcel * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21263409Smarcel * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22263409Smarcel * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23263409Smarcel * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24263409Smarcel * SUCH DAMAGE.
25263409Smarcel */
26263409Smarcel
27263409Smarcel#include <sys/cdefs.h>
28263409Smarcel__FBSDID("$FreeBSD: user/marcel/mkimg/apm.c 263442 2014-03-20 20:14:26Z marcel $");
29263409Smarcel
30263409Smarcel#include <sys/types.h>
31263409Smarcel#include <sys/apm.h>
32263442Smarcel#include <sys/errno.h>
33263409Smarcel#include <stdlib.h>
34263409Smarcel
35263409Smarcel#include "mkimg.h"
36263409Smarcel#include "scheme.h"
37263409Smarcel
38263409Smarcelstatic struct mkimg_alias apm_aliases[] = {
39263409Smarcel    {	NULL, 0 }
40263409Smarcel};
41263409Smarcel
42263440Smarcelstatic u_int
43263440Smarcelapm_metadata(u_int where, u_int parts, u_int secsz __unused)
44263409Smarcel{
45263440Smarcel	u_int secs;
46263409Smarcel
47263440Smarcel	secs = (where == SCHEME_META_IMG_START) ? parts + 1 : 0;
48263440Smarcel	return (secs);
49263409Smarcel}
50263409Smarcel
51263442Smarcelstatic int
52263442Smarcelapm_write(int fd __unused, off_t imgsz __unused, u_int parts __unused,
53263442Smarcel    u_int secsz __unused)
54263442Smarcel{
55263442Smarcel	return (ENOSYS);
56263442Smarcel}
57263442Smarcel
58263409Smarcelstatic struct mkimg_scheme apm_scheme = {
59263409Smarcel	.name = "apm",
60263409Smarcel	.description = "Apple Partition Map",
61263409Smarcel	.aliases = apm_aliases,
62263440Smarcel	.metadata = apm_metadata,
63263442Smarcel	.write = apm_write,
64263440Smarcel	.nparts = 4096
65263409Smarcel};
66263409Smarcel
67263409SmarcelSCHEME_DEFINE(apm_scheme);
68