Lines 131-192
Link Here
|
131 |
} |
131 |
} |
132 |
|
132 |
|
133 |
|
133 |
|
134 |
/* blocklist */ |
134 |
/* blocklist_read_helper nee disk_read_blocklist_func was a nested |
135 |
static int |
135 |
* function, to which pointers were taken and exposed globally. Even |
136 |
blocklist_func (char *arg, int flags) |
136 |
* in the GNU-C nested functions extension, they have local linkage, |
|
|
137 |
* and aren't guaranteed to be accessable *at all* outside of their |
138 |
* containing scope. |
139 |
* |
140 |
* Above and beyond all of that, the variables within blocklist_func_context |
141 |
* are originally local variables, with local (not even static) linkage, |
142 |
* from within blocklist_func. These were each referenced by |
143 |
* disk_read_blocklist_func, which is only called from other functions |
144 |
* through a globally scoped pointer. |
145 |
* |
146 |
* The documentation in GCC actually uses the words "all hell will break |
147 |
* loose" to describe this scenario. |
148 |
* |
149 |
* Also, "start_sector" was also used uninitialized, but gcc doesn't warn |
150 |
* about it (possibly because of the scoping madness?) |
151 |
*/ |
152 |
|
153 |
static struct { |
154 |
int start_sector; |
155 |
int num_sectors; |
156 |
int num_entries; |
157 |
int last_length; |
158 |
} blocklist_func_context = { |
159 |
.start_sector = 0, |
160 |
.num_sectors = 0, |
161 |
.num_entries = 0, |
162 |
.last_length = 0 |
163 |
}; |
164 |
|
165 |
/* Collect contiguous blocks into one entry as many as possible, |
166 |
and print the blocklist notation on the screen. */ |
167 |
static void |
168 |
blocklist_read_helper (int sector, int offset, int length) |
137 |
{ |
169 |
{ |
138 |
char *dummy = (char *) RAW_ADDR (0x100000); |
170 |
int *start_sector = &blocklist_func_context.start_sector; |
139 |
int start_sector; |
171 |
int *num_sectors = &blocklist_func_context.num_sectors; |
140 |
int num_sectors = 0; |
172 |
int *num_entries = &blocklist_func_context.num_entries; |
141 |
int num_entries = 0; |
173 |
int *last_length = &blocklist_func_context.last_length; |
142 |
int last_length = 0; |
|
|
143 |
|
174 |
|
144 |
auto void disk_read_blocklist_func (int sector, int offset, int length); |
175 |
if (*num_sectors > 0) |
145 |
|
176 |
{ |
146 |
/* Collect contiguous blocks into one entry as many as possible, |
177 |
if (*start_sector + *num_sectors == sector |
147 |
and print the blocklist notation on the screen. */ |
178 |
&& offset == 0 && *last_length == SECTOR_SIZE) |
148 |
auto void disk_read_blocklist_func (int sector, int offset, int length) |
|
|
149 |
{ |
179 |
{ |
150 |
if (num_sectors > 0) |
180 |
*num_sectors++; |
151 |
{ |
181 |
*last_length = length; |
152 |
if (start_sector + num_sectors == sector |
182 |
return; |
153 |
&& offset == 0 && last_length == SECTOR_SIZE) |
183 |
} |
154 |
{ |
184 |
else |
155 |
num_sectors++; |
185 |
{ |
156 |
last_length = length; |
186 |
if (*last_length == SECTOR_SIZE) |
157 |
return; |
187 |
grub_printf ("%s%d+%d", *num_entries ? "," : "", |
158 |
} |
188 |
*start_sector - part_start, *num_sectors); |
159 |
else |
189 |
else if (*num_sectors > 1) |
160 |
{ |
190 |
grub_printf ("%s%d+%d,%d[0-%d]", *num_entries ? "," : "", |
161 |
if (last_length == SECTOR_SIZE) |
191 |
*start_sector - part_start, *num_sectors-1, |
162 |
grub_printf ("%s%d+%d", num_entries ? "," : "", |
192 |
*start_sector + *num_sectors-1 - part_start, |
163 |
start_sector - part_start, num_sectors); |
193 |
*last_length); |
164 |
else if (num_sectors > 1) |
|
|
165 |
grub_printf ("%s%d+%d,%d[0-%d]", num_entries ? "," : "", |
166 |
start_sector - part_start, num_sectors-1, |
167 |
start_sector + num_sectors-1 - part_start, |
168 |
last_length); |
169 |
else |
170 |
grub_printf ("%s%d[0-%d]", num_entries ? "," : "", |
171 |
start_sector - part_start, last_length); |
172 |
num_entries++; |
173 |
num_sectors = 0; |
174 |
} |
175 |
} |
176 |
|
177 |
if (offset > 0) |
178 |
{ |
179 |
grub_printf("%s%d[%d-%d]", num_entries ? "," : "", |
180 |
sector-part_start, offset, offset+length); |
181 |
num_entries++; |
182 |
} |
183 |
else |
194 |
else |
184 |
{ |
195 |
grub_printf ("%s%d[0-%d]", *num_entries ? "," : "", |
185 |
start_sector = sector; |
196 |
*start_sector - part_start, *last_length); |
186 |
num_sectors = 1; |
197 |
*num_entries++; |
187 |
last_length = length; |
198 |
*num_sectors = 0; |
188 |
} |
|
|
189 |
} |
199 |
} |
|
|
200 |
} |
201 |
|
202 |
if (offset > 0) |
203 |
{ |
204 |
grub_printf("%s%d[%d-%d]", *num_entries ? "," : "", |
205 |
sector-part_start, offset, offset+length); |
206 |
*num_entries++; |
207 |
} |
208 |
else |
209 |
{ |
210 |
*start_sector = sector; |
211 |
*num_sectors = 1; |
212 |
*last_length = length; |
213 |
} |
214 |
} |
215 |
|
216 |
/* blocklist */ |
217 |
static int |
218 |
blocklist_func (char *arg, int flags) |
219 |
{ |
220 |
char *dummy = (char *) RAW_ADDR (0x100000); |
221 |
int *start_sector = &blocklist_func_context.start_sector; |
222 |
int *num_sectors = &blocklist_func_context.num_sectors; |
223 |
int *num_entries = &blocklist_func_context.num_entries; |
190 |
|
224 |
|
191 |
/* Open the file. */ |
225 |
/* Open the file. */ |
192 |
if (! grub_open (arg)) |
226 |
if (! grub_open (arg)) |
Lines 206-220
Link Here
|
206 |
grub_printf (")"); |
240 |
grub_printf (")"); |
207 |
|
241 |
|
208 |
/* Read in the whole file to DUMMY. */ |
242 |
/* Read in the whole file to DUMMY. */ |
209 |
disk_read_hook = disk_read_blocklist_func; |
243 |
disk_read_hook = blocklist_read_helper; |
210 |
if (! grub_read (dummy, -1)) |
244 |
if (! grub_read (dummy, -1)) |
211 |
goto fail; |
245 |
goto fail; |
212 |
|
246 |
|
213 |
/* The last entry may not be printed yet. Don't check if it is a |
247 |
/* The last entry may not be printed yet. Don't check if it is a |
214 |
* full sector, since it doesn't matter if we read too much. */ |
248 |
* full sector, since it doesn't matter if we read too much. */ |
215 |
if (num_sectors > 0) |
249 |
if (*num_sectors > 0) |
216 |
grub_printf ("%s%d+%d", num_entries ? "," : "", |
250 |
grub_printf ("%s%d+%d", *num_entries ? "," : "", |
217 |
start_sector - part_start, num_sectors); |
251 |
*start_sector - part_start, *num_sectors); |
218 |
|
252 |
|
219 |
grub_printf ("\n"); |
253 |
grub_printf ("\n"); |
220 |
|
254 |
|
Lines 1740-1745
Link Here
|
1740 |
|
1774 |
|
1741 |
|
1775 |
|
1742 |
/* install */ |
1776 |
/* install */ |
|
|
1777 |
static struct { |
1778 |
int saved_sector; |
1779 |
int installaddr; |
1780 |
int installlist; |
1781 |
char *stage2_first_buffer; |
1782 |
} install_func_context = { |
1783 |
.saved_sector = 0, |
1784 |
.installaddr = 0, |
1785 |
.installlist = 0, |
1786 |
.stage2_first_buffer = NULL, |
1787 |
}; |
1788 |
|
1789 |
/* Save the first sector of Stage2 in STAGE2_SECT. */ |
1790 |
/* Formerly disk_read_savesect_func with local scope inside install_func */ |
1791 |
static void |
1792 |
install_savesect_helper(int sector, int offset, int length) |
1793 |
{ |
1794 |
if (debug) |
1795 |
printf ("[%d]", sector); |
1796 |
|
1797 |
/* ReiserFS has files which sometimes contain data not aligned |
1798 |
on sector boundaries. Returning an error is better than |
1799 |
silently failing. */ |
1800 |
if (offset != 0 || length != SECTOR_SIZE) |
1801 |
errnum = ERR_UNALIGNED; |
1802 |
|
1803 |
install_func_context.saved_sector = sector; |
1804 |
} |
1805 |
|
1806 |
/* Write SECTOR to INSTALLLIST, and update INSTALLADDR and INSTALLSECT. */ |
1807 |
/* Formerly disk_read_blocklist_func with local scope inside install_func */ |
1808 |
static void |
1809 |
install_blocklist_helper (int sector, int offset, int length) |
1810 |
{ |
1811 |
int *installaddr = &install_func_context.installaddr; |
1812 |
int *installlist = &install_func_context.installlist; |
1813 |
char **stage2_first_buffer = &install_func_context.stage2_first_buffer; |
1814 |
/* Was the last sector full? */ |
1815 |
static int last_length = SECTOR_SIZE; |
1816 |
|
1817 |
if (debug) |
1818 |
printf("[%d]", sector); |
1819 |
|
1820 |
if (offset != 0 || last_length != SECTOR_SIZE) |
1821 |
{ |
1822 |
/* We found a non-sector-aligned data block. */ |
1823 |
errnum = ERR_UNALIGNED; |
1824 |
return; |
1825 |
} |
1826 |
|
1827 |
last_length = length; |
1828 |
|
1829 |
if (*((unsigned long *) (*installlist - 4)) |
1830 |
+ *((unsigned short *) *installlist) != sector |
1831 |
|| *installlist == (int) *stage2_first_buffer + SECTOR_SIZE + 4) |
1832 |
{ |
1833 |
*installlist -= 8; |
1834 |
|
1835 |
if (*((unsigned long *) (*installlist - 8))) |
1836 |
errnum = ERR_WONT_FIT; |
1837 |
else |
1838 |
{ |
1839 |
*((unsigned short *) (*installlist + 2)) = (*installaddr >> 4); |
1840 |
*((unsigned long *) (*installlist - 4)) = sector; |
1841 |
} |
1842 |
} |
1843 |
|
1844 |
*((unsigned short *) *installlist) += 1; |
1845 |
*installaddr += 512; |
1846 |
} |
1847 |
|
1743 |
static int |
1848 |
static int |
1744 |
install_func (char *arg, int flags) |
1849 |
install_func (char *arg, int flags) |
1745 |
{ |
1850 |
{ |
Lines 1747-1754
Link Here
|
1747 |
char *stage1_buffer = (char *) RAW_ADDR (0x100000); |
1852 |
char *stage1_buffer = (char *) RAW_ADDR (0x100000); |
1748 |
char *stage2_buffer = stage1_buffer + SECTOR_SIZE; |
1853 |
char *stage2_buffer = stage1_buffer + SECTOR_SIZE; |
1749 |
char *old_sect = stage2_buffer + SECTOR_SIZE; |
1854 |
char *old_sect = stage2_buffer + SECTOR_SIZE; |
1750 |
char *stage2_first_buffer = old_sect + SECTOR_SIZE; |
1855 |
/* stage2_first_buffer used to be defined as: |
1751 |
char *stage2_second_buffer = stage2_first_buffer + SECTOR_SIZE; |
1856 |
* char *stage2_first_buffer = old_sect + SECTOR_SIZE; */ |
|
|
1857 |
char **stage2_first_buffer = &install_func_context.stage2_first_buffer; |
1858 |
/* and stage2_second_buffer was: |
1859 |
* char *stage2_second_buffer = stage2_first_buffer + SECTOR_SIZE; */ |
1860 |
char *stage2_second_buffer = old_sect + SECTOR_SIZE + SECTOR_SIZE; |
1752 |
/* XXX: Probably SECTOR_SIZE is reasonable. */ |
1861 |
/* XXX: Probably SECTOR_SIZE is reasonable. */ |
1753 |
char *config_filename = stage2_second_buffer + SECTOR_SIZE; |
1862 |
char *config_filename = stage2_second_buffer + SECTOR_SIZE; |
1754 |
char *dummy = config_filename + SECTOR_SIZE; |
1863 |
char *dummy = config_filename + SECTOR_SIZE; |
Lines 1757-1766
Link Here
|
1757 |
int src_drive, src_partition, src_part_start; |
1866 |
int src_drive, src_partition, src_part_start; |
1758 |
int i; |
1867 |
int i; |
1759 |
struct geometry dest_geom, src_geom; |
1868 |
struct geometry dest_geom, src_geom; |
1760 |
int saved_sector; |
1869 |
int *saved_sector = &install_func_context.saved_sector; |
1761 |
int stage2_first_sector, stage2_second_sector; |
1870 |
int stage2_first_sector, stage2_second_sector; |
1762 |
char *ptr; |
1871 |
char *ptr; |
1763 |
int installaddr, installlist; |
1872 |
int *installaddr = &install_func_context.installaddr; |
|
|
1873 |
int *installlist = &install_func_context.installlist; |
1764 |
/* Point to the location of the name of a configuration file in Stage 2. */ |
1874 |
/* Point to the location of the name of a configuration file in Stage 2. */ |
1765 |
char *config_file_location; |
1875 |
char *config_file_location; |
1766 |
/* If FILE is a Stage 1.5? */ |
1876 |
/* If FILE is a Stage 1.5? */ |
Lines 1769-1776
Link Here
|
1769 |
int is_open = 0; |
1879 |
int is_open = 0; |
1770 |
/* If LBA is forced? */ |
1880 |
/* If LBA is forced? */ |
1771 |
int is_force_lba = 0; |
1881 |
int is_force_lba = 0; |
1772 |
/* Was the last sector full? */ |
1882 |
*stage2_first_buffer = old_sect + SECTOR_SIZE; |
1773 |
int last_length = SECTOR_SIZE; |
|
|
1774 |
|
1883 |
|
1775 |
#ifdef GRUB_UTIL |
1884 |
#ifdef GRUB_UTIL |
1776 |
/* If the Stage 2 is in a partition mounted by an OS, this will store |
1885 |
/* If the Stage 2 is in a partition mounted by an OS, this will store |
Lines 1778-1836
Link Here
|
1778 |
char *stage2_os_file = 0; |
1887 |
char *stage2_os_file = 0; |
1779 |
#endif /* GRUB_UTIL */ |
1888 |
#endif /* GRUB_UTIL */ |
1780 |
|
1889 |
|
1781 |
auto void disk_read_savesect_func (int sector, int offset, int length); |
|
|
1782 |
auto void disk_read_blocklist_func (int sector, int offset, int length); |
1783 |
|
1784 |
/* Save the first sector of Stage2 in STAGE2_SECT. */ |
1785 |
auto void disk_read_savesect_func (int sector, int offset, int length) |
1786 |
{ |
1787 |
if (debug) |
1788 |
printf ("[%d]", sector); |
1789 |
|
1790 |
/* ReiserFS has files which sometimes contain data not aligned |
1791 |
on sector boundaries. Returning an error is better than |
1792 |
silently failing. */ |
1793 |
if (offset != 0 || length != SECTOR_SIZE) |
1794 |
errnum = ERR_UNALIGNED; |
1795 |
|
1796 |
saved_sector = sector; |
1797 |
} |
1798 |
|
1799 |
/* Write SECTOR to INSTALLLIST, and update INSTALLADDR and |
1800 |
INSTALLSECT. */ |
1801 |
auto void disk_read_blocklist_func (int sector, int offset, int length) |
1802 |
{ |
1803 |
if (debug) |
1804 |
printf("[%d]", sector); |
1805 |
|
1806 |
if (offset != 0 || last_length != SECTOR_SIZE) |
1807 |
{ |
1808 |
/* We found a non-sector-aligned data block. */ |
1809 |
errnum = ERR_UNALIGNED; |
1810 |
return; |
1811 |
} |
1812 |
|
1813 |
last_length = length; |
1814 |
|
1815 |
if (*((unsigned long *) (installlist - 4)) |
1816 |
+ *((unsigned short *) installlist) != sector |
1817 |
|| installlist == (int) stage2_first_buffer + SECTOR_SIZE + 4) |
1818 |
{ |
1819 |
installlist -= 8; |
1820 |
|
1821 |
if (*((unsigned long *) (installlist - 8))) |
1822 |
errnum = ERR_WONT_FIT; |
1823 |
else |
1824 |
{ |
1825 |
*((unsigned short *) (installlist + 2)) = (installaddr >> 4); |
1826 |
*((unsigned long *) (installlist - 4)) = sector; |
1827 |
} |
1828 |
} |
1829 |
|
1830 |
*((unsigned short *) installlist) += 1; |
1831 |
installaddr += 512; |
1832 |
} |
1833 |
|
1834 |
/* First, check the GNU-style long option. */ |
1890 |
/* First, check the GNU-style long option. */ |
1835 |
while (1) |
1891 |
while (1) |
1836 |
{ |
1892 |
{ |
Lines 1862-1871
Link Here
|
1862 |
addr = skip_to (0, file); |
1918 |
addr = skip_to (0, file); |
1863 |
|
1919 |
|
1864 |
/* Get the installation address. */ |
1920 |
/* Get the installation address. */ |
1865 |
if (! safe_parse_maxint (&addr, &installaddr)) |
1921 |
if (! safe_parse_maxint (&addr, installaddr)) |
1866 |
{ |
1922 |
{ |
1867 |
/* ADDR is not specified. */ |
1923 |
/* ADDR is not specified. */ |
1868 |
installaddr = 0; |
1924 |
*installaddr = 0; |
1869 |
ptr = addr; |
1925 |
ptr = addr; |
1870 |
errnum = 0; |
1926 |
errnum = 0; |
1871 |
} |
1927 |
} |
Lines 1961-1977
Link Here
|
1961 |
= 0x9090; |
2017 |
= 0x9090; |
1962 |
|
2018 |
|
1963 |
/* Read the first sector of Stage 2. */ |
2019 |
/* Read the first sector of Stage 2. */ |
1964 |
disk_read_hook = disk_read_savesect_func; |
2020 |
disk_read_hook = install_savesect_helper; |
1965 |
if (grub_read (stage2_first_buffer, SECTOR_SIZE) != SECTOR_SIZE) |
2021 |
if (grub_read (*stage2_first_buffer, SECTOR_SIZE) != SECTOR_SIZE) |
1966 |
goto fail; |
2022 |
goto fail; |
1967 |
|
2023 |
|
1968 |
stage2_first_sector = saved_sector; |
2024 |
stage2_first_sector = *saved_sector; |
1969 |
|
2025 |
|
1970 |
/* Read the second sector of Stage 2. */ |
2026 |
/* Read the second sector of Stage 2. */ |
1971 |
if (grub_read (stage2_second_buffer, SECTOR_SIZE) != SECTOR_SIZE) |
2027 |
if (grub_read (stage2_second_buffer, SECTOR_SIZE) != SECTOR_SIZE) |
1972 |
goto fail; |
2028 |
goto fail; |
1973 |
|
2029 |
|
1974 |
stage2_second_sector = saved_sector; |
2030 |
stage2_second_sector = *saved_sector; |
1975 |
|
2031 |
|
1976 |
/* Check for the version of Stage 2. */ |
2032 |
/* Check for the version of Stage 2. */ |
1977 |
if (*((short *) (stage2_second_buffer + STAGE2_VER_MAJ_OFFS)) |
2033 |
if (*((short *) (stage2_second_buffer + STAGE2_VER_MAJ_OFFS)) |
Lines 1987-2013
Link Here
|
1987 |
|
2043 |
|
1988 |
/* If INSTALLADDR is not specified explicitly in the command-line, |
2044 |
/* If INSTALLADDR is not specified explicitly in the command-line, |
1989 |
determine it by the Stage 2 id. */ |
2045 |
determine it by the Stage 2 id. */ |
1990 |
if (! installaddr) |
2046 |
if (! *installaddr) |
1991 |
{ |
2047 |
{ |
1992 |
if (! is_stage1_5) |
2048 |
if (! is_stage1_5) |
1993 |
/* Stage 2. */ |
2049 |
/* Stage 2. */ |
1994 |
installaddr = 0x8000; |
2050 |
*installaddr = 0x8000; |
1995 |
else |
2051 |
else |
1996 |
/* Stage 1.5. */ |
2052 |
/* Stage 1.5. */ |
1997 |
installaddr = 0x2000; |
2053 |
*installaddr = 0x2000; |
1998 |
} |
2054 |
} |
1999 |
|
2055 |
|
2000 |
*((unsigned long *) (stage1_buffer + STAGE1_STAGE2_SECTOR)) |
2056 |
*((unsigned long *) (stage1_buffer + STAGE1_STAGE2_SECTOR)) |
2001 |
= stage2_first_sector; |
2057 |
= stage2_first_sector; |
2002 |
*((unsigned short *) (stage1_buffer + STAGE1_STAGE2_ADDRESS)) |
2058 |
*((unsigned short *) (stage1_buffer + STAGE1_STAGE2_ADDRESS)) |
2003 |
= installaddr; |
2059 |
= *installaddr; |
2004 |
*((unsigned short *) (stage1_buffer + STAGE1_STAGE2_SEGMENT)) |
2060 |
*((unsigned short *) (stage1_buffer + STAGE1_STAGE2_SEGMENT)) |
2005 |
= installaddr >> 4; |
2061 |
= *installaddr >> 4; |
2006 |
|
2062 |
|
2007 |
i = (int) stage2_first_buffer + SECTOR_SIZE - 4; |
2063 |
i = (int) *stage2_first_buffer + SECTOR_SIZE - 4; |
2008 |
while (*((unsigned long *) i)) |
2064 |
while (*((unsigned long *) i)) |
2009 |
{ |
2065 |
{ |
2010 |
if (i < (int) stage2_first_buffer |
2066 |
if (i < (int) *stage2_first_buffer |
2011 |
|| (*((int *) (i - 4)) & 0x80000000) |
2067 |
|| (*((int *) (i - 4)) & 0x80000000) |
2012 |
|| *((unsigned short *) i) >= 0xA00 |
2068 |
|| *((unsigned short *) i) >= 0xA00 |
2013 |
|| *((short *) (i + 2)) == 0) |
2069 |
|| *((short *) (i + 2)) == 0) |
Lines 2021-2033
Link Here
|
2021 |
i -= 8; |
2077 |
i -= 8; |
2022 |
} |
2078 |
} |
2023 |
|
2079 |
|
2024 |
installlist = (int) stage2_first_buffer + SECTOR_SIZE + 4; |
2080 |
*installlist = (int) *stage2_first_buffer + SECTOR_SIZE + 4; |
2025 |
installaddr += SECTOR_SIZE; |
2081 |
*installaddr += SECTOR_SIZE; |
2026 |
|
2082 |
|
2027 |
/* Read the whole of Stage2 except for the first sector. */ |
2083 |
/* Read the whole of Stage2 except for the first sector. */ |
2028 |
grub_seek (SECTOR_SIZE); |
2084 |
grub_seek (SECTOR_SIZE); |
2029 |
|
2085 |
|
2030 |
disk_read_hook = disk_read_blocklist_func; |
2086 |
disk_read_hook = install_blocklist_helper; |
2031 |
if (! grub_read (dummy, -1)) |
2087 |
if (! grub_read (dummy, -1)) |
2032 |
goto fail; |
2088 |
goto fail; |
2033 |
|
2089 |
|
Lines 2110-2116
Link Here
|
2110 |
/* Skip the first sector. */ |
2166 |
/* Skip the first sector. */ |
2111 |
grub_seek (SECTOR_SIZE); |
2167 |
grub_seek (SECTOR_SIZE); |
2112 |
|
2168 |
|
2113 |
disk_read_hook = disk_read_savesect_func; |
2169 |
disk_read_hook = install_savesect_helper; |
2114 |
if (grub_read (stage2_buffer, SECTOR_SIZE) != SECTOR_SIZE) |
2170 |
if (grub_read (stage2_buffer, SECTOR_SIZE) != SECTOR_SIZE) |
2115 |
goto fail; |
2171 |
goto fail; |
2116 |
|
2172 |
|
Lines 2180-2186
Link Here
|
2180 |
else |
2236 |
else |
2181 |
#endif /* GRUB_UTIL */ |
2237 |
#endif /* GRUB_UTIL */ |
2182 |
{ |
2238 |
{ |
2183 |
if (! devwrite (saved_sector - part_start, 1, stage2_buffer)) |
2239 |
if (! devwrite (*saved_sector - part_start, 1, stage2_buffer)) |
2184 |
goto fail; |
2240 |
goto fail; |
2185 |
} |
2241 |
} |
2186 |
} |
2242 |
} |
Lines 2202-2208
Link Here
|
2202 |
goto fail; |
2258 |
goto fail; |
2203 |
} |
2259 |
} |
2204 |
|
2260 |
|
2205 |
if (fwrite (stage2_first_buffer, 1, SECTOR_SIZE, fp) != SECTOR_SIZE) |
2261 |
if (fwrite (*stage2_first_buffer, 1, SECTOR_SIZE, fp) != SECTOR_SIZE) |
2206 |
{ |
2262 |
{ |
2207 |
fclose (fp); |
2263 |
fclose (fp); |
2208 |
errnum = ERR_WRITE; |
2264 |
errnum = ERR_WRITE; |
Lines 2229-2235
Link Here
|
2229 |
goto fail; |
2285 |
goto fail; |
2230 |
|
2286 |
|
2231 |
if (! devwrite (stage2_first_sector - src_part_start, 1, |
2287 |
if (! devwrite (stage2_first_sector - src_part_start, 1, |
2232 |
stage2_first_buffer)) |
2288 |
*stage2_first_buffer)) |
2233 |
goto fail; |
2289 |
goto fail; |
2234 |
|
2290 |
|
2235 |
if (! devwrite (stage2_second_sector - src_part_start, 1, |
2291 |
if (! devwrite (stage2_second_sector - src_part_start, 1, |