SECTOR_SIZE
int fd, len, size = SECTOR_SIZE;
char boot_sect[SECTOR_SIZE];
if (fd == -1 || read(fd, boot_sect, SECTOR_SIZE) != SECTOR_SIZE) {
if (size % SECTOR_SIZE != 0)
if (size % SECTOR_SIZE != 0)
static size_t sector_size = SECTOR_SIZE;
if (sector_size != SECTOR_SIZE)
SECTOR_SIZE - STAGE1_SIG);
bcopy(dest, src, SECTOR_SIZE);
read(fd, data, SECTOR_SIZE) != SECTOR_SIZE) {
return (SECTOR_SIZE);
buf_size = P2ROUNDUP(bblock->file_size, SECTOR_SIZE);
buf_size = P2ROUNDUP(bblock->file_size + SECTOR_SIZE,
SECTOR_SIZE);
buf_size = P2ROUNDUP(size + SECTOR_SIZE, SECTOR_SIZE);
if (read_in(dev_fd, dest, size, SECTOR_SIZE) != BC_SUCCESS) {
if (write_out(device->fd, bufptr, size, SECTOR_SIZE) != BC_SUCCESS) {
SECTOR_SIZE) != BC_SUCCESS) {
buf_size = src_bblock->file_size + SECTOR_SIZE;
dest_bblock->buf_size = P2ROUNDUP(buf_size, SECTOR_SIZE);
#define BBLK_DATA_RSVD_SIZE (15 * SECTOR_SIZE)
#define BBLK_ZFS_EXTRA_OFF (SECTOR_SIZE * 1024)
offset = STAGE2_BLKOFF(device->type) * SECTOR_SIZE;
(stage2->buf_size / SECTOR_SIZE) + 1, STAGE2_BLKOFF(device->type),
read(fd, dest->stage1_buf, SECTOR_SIZE) != SECTOR_SIZE) {
buf_size = stage2->file_size + SECTOR_SIZE;
stage2->buf_size = P2ROUNDUP(buf_size, SECTOR_SIZE);
stage2->buf_size / SECTOR_SIZE);
char bpb_sect[SECTOR_SIZE];
if (pread(device->part_fd, bpb_sect, SECTOR_SIZE, 0)
!= SECTOR_SIZE) {
SECTOR_SIZE - BOOTSZ);
if (read_in(dev_fd, stage1_buf, SECTOR_SIZE, 0) != BC_SUCCESS) {
STAGE2_BLKOFF(type) * SECTOR_SIZE) != BC_SUCCESS) {
buf_size = P2ROUNDUP(size + SECTOR_SIZE, SECTOR_SIZE);
SECTOR_SIZE) != BC_SUCCESS) {
uint32_t blocklist[SECTOR_SIZE / sizeof (uint32_t)];
uint32_t install_addr = STAGE2_MEMADDR + SECTOR_SIZE;
install_addr += blocklist[i + 1] * SECTOR_SIZE;
buf_size = src_stage2->file_size + SECTOR_SIZE;
dest_stage2->buf_size = P2ROUNDUP(buf_size, SECTOR_SIZE);
if (read(device->disk_fd, device->boot_sector, SECTOR_SIZE)
!= SECTOR_SIZE) {
if (write_out(device->part_fd, stage2->file, SECTOR_SIZE,
stage2->pcfs_first_sectors[0] * SECTOR_SIZE)
write_out(device->part_fd, stage2->file + SECTOR_SIZE,
SECTOR_SIZE, stage2->pcfs_first_sectors[1] * SECTOR_SIZE)
char boot_sector[SECTOR_SIZE];
char stage1_buf[SECTOR_SIZE];
#define STAGE2_BLOCKLIST (SECTOR_SIZE - 0x8)
#define STAGE2_INSTALLPART (SECTOR_SIZE + 0x8)
#define STAGE2_FORCE_LBA (SECTOR_SIZE + 0x11)
uint64_t size = SECTOR_SIZE;
CTASSERT(sizeof (*mbr) == SECTOR_SIZE);
if (header->efi_gpt_HeaderSize > SECTOR_SIZE) {
size_t sector_size = SECTOR_SIZE;
offset = (loff_t) sector * (loff_t) SECTOR_SIZE;
off_t offset = (off_t) sector * (off_t) SECTOR_SIZE;
if (nread (fd, buf, SECTOR_SIZE) != SECTOR_SIZE)
buf += SECTOR_SIZE;
if (nread (fd, buf, nsec * SECTOR_SIZE) != nsec * SECTOR_SIZE)
hex_dump (buf, nsec * SECTOR_SIZE);
if (nwrite (fd, buf, nsec * SECTOR_SIZE) != nsec * SECTOR_SIZE)
geom->sector_size = SECTOR_SIZE;
offset = (loff_t) sector * (loff_t) SECTOR_SIZE;
off_t offset = (off_t) sector * (off_t) SECTOR_SIZE;
if (write (fd, buf, size * SECTOR_SIZE) != (size * SECTOR_SIZE))
geometry->sector_size = SECTOR_SIZE;
geometry->sector_size = SECTOR_SIZE;
geometry->sector_size = SECTOR_SIZE;
text_len = filemax - data_len - SECTOR_SIZE;
if (data_len + SECTOR_SIZE <= MULTIBOOT_SEARCH)
data_len + SECTOR_SIZE);
data_len + SECTOR_SIZE - MULTIBOOT_SEARCH);
grub_seek (data_len + SECTOR_SIZE);
size = (len + SECTOR_SIZE - 1) / SECTOR_SIZE;
char mbr[SECTOR_SIZE];
char ezbios_check[2*SECTOR_SIZE];
if (! rawread (current_drive, PC_MBR_SECTOR, 0, SECTOR_SIZE, mbr))
if (! rawread (current_drive, 1, 0, 2 * SECTOR_SIZE, ezbios_check))
char buf[SECTOR_SIZE];
&& offset == 0 && last_length == SECTOR_SIZE)
if (last_length == SECTOR_SIZE)
char *stage2_buffer = stage1_buffer + SECTOR_SIZE;
char *old_sect = stage2_buffer + SECTOR_SIZE;
char *stage2_first_buffer = old_sect + SECTOR_SIZE;
char *stage2_second_buffer = stage2_first_buffer + SECTOR_SIZE;
char *config_filename = stage2_second_buffer + SECTOR_SIZE;
char *dummy = config_filename + SECTOR_SIZE;
int last_length = SECTOR_SIZE;
if (offset != 0 || length != SECTOR_SIZE)
if (offset != 0 || last_length != SECTOR_SIZE)
|| installlist == (int) stage2_first_buffer + SECTOR_SIZE + 4)
|| ! grub_read (stage1_buffer, SECTOR_SIZE) == SECTOR_SIZE)
|| ! devread (0, 0, SECTOR_SIZE, old_sect))
if (grub_read (stage2_first_buffer, SECTOR_SIZE) != SECTOR_SIZE)
if (grub_read (stage2_second_buffer, SECTOR_SIZE) != SECTOR_SIZE)
i = (int) stage2_first_buffer + SECTOR_SIZE - 4;
installlist = (int) stage2_first_buffer + SECTOR_SIZE + 4;
installaddr += SECTOR_SIZE;
grub_seek (SECTOR_SIZE);
grub_seek (SECTOR_SIZE);
if (grub_read (stage2_buffer, SECTOR_SIZE) != SECTOR_SIZE)
if (fseek (fp, SECTOR_SIZE, SEEK_SET) != 0)
if (fwrite (stage2_buffer, 1, SECTOR_SIZE, fp)
!= SECTOR_SIZE)
if (fwrite (stage2_first_buffer, 1, SECTOR_SIZE, fp) != SECTOR_SIZE)
if (fwrite (stage2_second_buffer, 1, SECTOR_SIZE, fp) != SECTOR_SIZE)
if (! rawread (current_drive, 0, 0, SECTOR_SIZE, mbr))
char sect[SECTOR_SIZE];
if (! rawread (current_drive, saved_sectors[0], 0, SECTOR_SIZE,
if (! rawread (current_drive, saved_sectors[1], 0, SECTOR_SIZE,
if (! rawread (current_drive, saved_sectors[0], 0, SECTOR_SIZE,
if (grub_read ((char *) BOOTSEC_LOCATION, SECTOR_SIZE) != SECTOR_SIZE)
0, SECTOR_SIZE, (char *) SCRATCHADDR))
filemax += (tmp * SECTOR_SIZE);
if ((filepos - (BLK_CUR_FILEPOS & ~(SECTOR_SIZE - 1)))
>= SECTOR_SIZE)
BLK_CUR_FILEPOS += SECTOR_SIZE;
off = filepos & (SECTOR_SIZE - 1);
* SECTOR_SIZE) - off;
byte_offset &= SECTOR_SIZE - 1;
memmove ((char *) SCRATCHADDR, buf, SECTOR_SIZE);
if (! rawread (saved_drive, 0, 0, SECTOR_SIZE, mbr))
0, SECTOR_SIZE, buf))
if (! rawread (drive, *start + SOL_LABEL_LOC, 0, SECTOR_SIZE, buf))
if (! rawread (drive, *offset, 0, SECTOR_SIZE, buf))
if (! rawread (drive, 1, 0, SECTOR_SIZE, buf))
if (! rawread (drive, *offset, 0, SECTOR_SIZE, buf))
char buf[SECTOR_SIZE];
|| FAT_CVT_U16(bpb.bytes_per_sect) != SECTOR_SIZE
|| (FAT_SUPER->fat_size * FAT_SUPER->num_clust / (2 * SECTOR_SIZE)
FAT_SUPER->cached_fat = (fat_entry & ~(2*SECTOR_SIZE - 1));
+ FAT_SUPER->cached_fat / (2*SECTOR_SIZE);
#define FSYSREISER_MIN_BLOCKSIZE SECTOR_SIZE
|| (SECTOR_SIZE << INFO->blocksize_shift) != super.s_blocksize)
((((entry) * (size) + 1) & ~(SECTOR_SIZE - 1)) >> SECTOR_BITS)
((((entry) * (size) + 1) & (SECTOR_SIZE - 1)) - 1)
grub_read ((char *) 0x8000, SECTOR_SIZE * 2);
ret = grub_read ((char *) 0x8000 + SECTOR_SIZE * 2, -1);
buf_size = P2ROUNDUP(sb.st_size + SECTOR_SIZE, SECTOR_SIZE);