xref: /freebsd/usr.bin/mkimg/raw.c (revision f0e9dced5c460869832138e36e8d5568c49f5867)
1*f0e9dcedSMarcel Moolenaar /*-
2*f0e9dcedSMarcel Moolenaar  * Copyright (c) 2014 Juniper Networks, Inc.
3*f0e9dcedSMarcel Moolenaar  * All rights reserved.
4*f0e9dcedSMarcel Moolenaar  *
5*f0e9dcedSMarcel Moolenaar  * Redistribution and use in source and binary forms, with or without
6*f0e9dcedSMarcel Moolenaar  * modification, are permitted provided that the following conditions
7*f0e9dcedSMarcel Moolenaar  * are met:
8*f0e9dcedSMarcel Moolenaar  * 1. Redistributions of source code must retain the above copyright
9*f0e9dcedSMarcel Moolenaar  *    notice, this list of conditions and the following disclaimer.
10*f0e9dcedSMarcel Moolenaar  * 2. Redistributions in binary form must reproduce the above copyright
11*f0e9dcedSMarcel Moolenaar  *    notice, this list of conditions and the following disclaimer in the
12*f0e9dcedSMarcel Moolenaar  *    documentation and/or other materials provided with the distribution.
13*f0e9dcedSMarcel Moolenaar  *
14*f0e9dcedSMarcel Moolenaar  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15*f0e9dcedSMarcel Moolenaar  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16*f0e9dcedSMarcel Moolenaar  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17*f0e9dcedSMarcel Moolenaar  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18*f0e9dcedSMarcel Moolenaar  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19*f0e9dcedSMarcel Moolenaar  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20*f0e9dcedSMarcel Moolenaar  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21*f0e9dcedSMarcel Moolenaar  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22*f0e9dcedSMarcel Moolenaar  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23*f0e9dcedSMarcel Moolenaar  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24*f0e9dcedSMarcel Moolenaar  * SUCH DAMAGE.
25*f0e9dcedSMarcel Moolenaar  */
26*f0e9dcedSMarcel Moolenaar 
27*f0e9dcedSMarcel Moolenaar #include <sys/cdefs.h>
28*f0e9dcedSMarcel Moolenaar __FBSDID("$FreeBSD$");
29*f0e9dcedSMarcel Moolenaar 
30*f0e9dcedSMarcel Moolenaar #include <sys/types.h>
31*f0e9dcedSMarcel Moolenaar #include <sys/apm.h>
32*f0e9dcedSMarcel Moolenaar #include <sys/endian.h>
33*f0e9dcedSMarcel Moolenaar #include <sys/errno.h>
34*f0e9dcedSMarcel Moolenaar #include <stdlib.h>
35*f0e9dcedSMarcel Moolenaar #include <string.h>
36*f0e9dcedSMarcel Moolenaar #include <unistd.h>
37*f0e9dcedSMarcel Moolenaar 
38*f0e9dcedSMarcel Moolenaar #include "image.h"
39*f0e9dcedSMarcel Moolenaar #include "format.h"
40*f0e9dcedSMarcel Moolenaar #include "mkimg.h"
41*f0e9dcedSMarcel Moolenaar 
42*f0e9dcedSMarcel Moolenaar static int
43*f0e9dcedSMarcel Moolenaar raw_resize(lba_t imgsz __unused)
44*f0e9dcedSMarcel Moolenaar {
45*f0e9dcedSMarcel Moolenaar 
46*f0e9dcedSMarcel Moolenaar 	return (0);
47*f0e9dcedSMarcel Moolenaar }
48*f0e9dcedSMarcel Moolenaar 
49*f0e9dcedSMarcel Moolenaar static int
50*f0e9dcedSMarcel Moolenaar raw_write(int fd)
51*f0e9dcedSMarcel Moolenaar {
52*f0e9dcedSMarcel Moolenaar 
53*f0e9dcedSMarcel Moolenaar 	return (image_copyout(fd));
54*f0e9dcedSMarcel Moolenaar }
55*f0e9dcedSMarcel Moolenaar 
56*f0e9dcedSMarcel Moolenaar static struct mkimg_format raw_format = {
57*f0e9dcedSMarcel Moolenaar 	.name = "raw",
58*f0e9dcedSMarcel Moolenaar 	.description = "Raw Disk",
59*f0e9dcedSMarcel Moolenaar 	.resize = raw_resize,
60*f0e9dcedSMarcel Moolenaar 	.write = raw_write,
61*f0e9dcedSMarcel Moolenaar };
62*f0e9dcedSMarcel Moolenaar 
63*f0e9dcedSMarcel Moolenaar FORMAT_DEFINE(raw_format);
64