Deleted Added
full compact
scheme.c (263829) scheme.c (263844)
1/*-
2 * Copyright (c) 2013,2014 Juniper Networks, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 158 unchanged lines hidden (view full) ---

167u_int
168scheme_max_secsz(void)
169{
170
171 return (scheme->maxsecsz);
172}
173
174lba_t
1/*-
2 * Copyright (c) 2013,2014 Juniper Networks, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 158 unchanged lines hidden (view full) ---

167u_int
168scheme_max_secsz(void)
169{
170
171 return (scheme->maxsecsz);
172}
173
174lba_t
175scheme_first_block(void)
175scheme_metadata(u_int where, lba_t start)
176{
176{
177 lba_t blks;
177 lba_t secs;
178
178
179 blks = scheme->metadata(SCHEME_META_IMG_START) +
180 scheme->metadata(SCHEME_META_PART_BEFORE);
181 return (blks);
179 secs = scheme->metadata(where);
180 return (round_block(start + secs));
182}
183
181}
182
184lba_t
185scheme_next_block(lba_t start, lba_t size)
186{
187 lba_t blks;
188
189 blks = scheme->metadata(SCHEME_META_PART_AFTER) +
190 scheme->metadata(SCHEME_META_PART_BEFORE);
191 return (start + size + blks);
192}
193
194int
195scheme_write(int fd, lba_t end)
196{
183int
184scheme_write(int fd, lba_t end)
185{
186 u_int cylsz;
197 int error;
198
187 int error;
188
199 /* Fixup block: it has an extra metadata before the partition */
200 end -= scheme->metadata(SCHEME_META_PART_BEFORE);
201 end += scheme->metadata(SCHEME_META_IMG_END);
189 cylsz = nsecs * nheads;
190 ncyls = end + cylsz - 1 / cylsz;
191
202 if (ftruncate(fd, end * secsz) == -1)
203 return (errno);
204
205 error = scheme->write(fd, end, bootcode);
206 return (error);
207}
192 if (ftruncate(fd, end * secsz) == -1)
193 return (errno);
194
195 error = scheme->write(fd, end, bootcode);
196 return (error);
197}