Raphael S.Carvalho
2013-Aug-31 20:01 UTC
[syslinux] [PATCH 1/1] core: Check if ldlinux.sys exceeds the limit at its building time.
Calc the size of ldlinux.sys from ldlinux.bin, and check if it exceeds the limit. ldlinux.sys must fit between the bootsector and two copies of ADV whose size may vary. Thus, the size of ldlinux.sys (limit) can be at most: 65536 - 2 * ADV_SIZE - 512. Certain file systems (such as BTRFS and UFS2) will rely on ldlinux.sys being installed on the 0-64k range, thus it can't exceed the limit, otherwise the superblock would be corrupted. Signed-off-by: Raphael S.Carvalho <raphael.scarv at gmail.com> --- core/Makefile | 1 + core/ldlinux_limit.pl | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 0 deletions(-) create mode 100755 core/ldlinux_limit.pl diff --git a/core/Makefile b/core/Makefile index f795a5c..e0daafc 100644 --- a/core/Makefile +++ b/core/Makefile @@ -220,6 +220,7 @@ ldlinux.bss: ldlinux.bin dd if=$< of=$@ bs=512 count=1 ldlinux.sys: ldlinux.bin + $(PERL) $(SRC)/ldlinux_limit.pl $< \ dd if=$< of=$@ bs=512 skip=2 codepage.cp: $(OBJ)/../codepage/$(CODEPAGE).cp diff --git a/core/ldlinux_limit.pl b/core/ldlinux_limit.pl new file mode 100755 index 0000000..923d516 --- /dev/null +++ b/core/ldlinux_limit.pl @@ -0,0 +1,39 @@ +#!/usr/bin/perl +## ----------------------------------------------------------------------- +## +## Copyright 2013 Raphael S. Carvalho <raphael.scarv at gmail.com> +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, Inc., 53 Temple Place Ste 330, +## Boston MA 02111-1307, USA; either version 2 of the License, or +## (at your option) any later version; incorporated herein by reference. +## +## ----------------------------------------------------------------------- + +## ldlinux_limit.pl: Calc the size of ldlinux.sys and check if it exceeds the limit. +## ldlinux.sys must fit between the bootsector and two copies of ADV whose size may vary. +## +## Certain file systems will simply install ldlinux.sys as an ordinary file, but UFS2 and +## BTRFS for example, rely on ldlinux.sys being installed on the 0-64k range. +## +## 0-64k range: +## [0](bootsector)[512](ldlinux.sys)[65536 - 2 * ADV_SIZE](2 copies of ADV)[65536] + +use File::stat; + +($ldlinux_bin) = @ARGV; +$adv_size = 512; +$limit = 65536 - 2 * $adv_size - 512; +$pad = 512; + +$ldlinux_size = stat($ldlinux_bin)->size - 1024; +$align = $ldlinux_size % $pad; +$ldlinux_size += $pad - $align; + +if ($ldlinux_size > $limit) { + print STDERR "$0: ldlinux.sys ($ldlinux_size) larger than limit ($limit).\n"; + exit 1; +} + +exit 0; -- 1.7.2.5
Matt Fleming
2013-Sep-16 14:08 UTC
[syslinux] [PATCH 1/1] core: Check if ldlinux.sys exceeds the limit at its building time.
Peter, does this look OK to you? Raphael, I can't work out why ADV_SIZE is a constant in this file? On Sat, 31 Aug, at 05:01:20PM, Raphael S.Carvalho wrote:> Calc the size of ldlinux.sys from ldlinux.bin, and check if it exceeds the limit. > ldlinux.sys must fit between the bootsector and two copies of ADV whose size may vary. > Thus, the size of ldlinux.sys (limit) can be at most: 65536 - 2 * ADV_SIZE - 512. > > Certain file systems (such as BTRFS and UFS2) will rely on ldlinux.sys being installed on the 0-64k range, > thus it can't exceed the limit, otherwise the superblock would be corrupted. > > Signed-off-by: Raphael S.Carvalho <raphael.scarv at gmail.com> > --- > core/Makefile | 1 + > core/ldlinux_limit.pl | 39 +++++++++++++++++++++++++++++++++++++++ > 2 files changed, 40 insertions(+), 0 deletions(-) > create mode 100755 core/ldlinux_limit.pl > > diff --git a/core/Makefile b/core/Makefile > index f795a5c..e0daafc 100644 > --- a/core/Makefile > +++ b/core/Makefile > @@ -220,6 +220,7 @@ ldlinux.bss: ldlinux.bin > dd if=$< of=$@ bs=512 count=1 > > ldlinux.sys: ldlinux.bin > + $(PERL) $(SRC)/ldlinux_limit.pl $< \ > dd if=$< of=$@ bs=512 skip=2 > > codepage.cp: $(OBJ)/../codepage/$(CODEPAGE).cp > diff --git a/core/ldlinux_limit.pl b/core/ldlinux_limit.pl > new file mode 100755 > index 0000000..923d516 > --- /dev/null > +++ b/core/ldlinux_limit.pl > @@ -0,0 +1,39 @@ > +#!/usr/bin/perl > +## ----------------------------------------------------------------------- > +## > +## Copyright 2013 Raphael S. Carvalho <raphael.scarv at gmail.com> > +## > +## This program is free software; you can redistribute it and/or modify > +## it under the terms of the GNU General Public License as published by > +## the Free Software Foundation, Inc., 53 Temple Place Ste 330, > +## Boston MA 02111-1307, USA; either version 2 of the License, or > +## (at your option) any later version; incorporated herein by reference. > +## > +## ----------------------------------------------------------------------- > + > +## ldlinux_limit.pl: Calc the size of ldlinux.sys and check if it exceeds the limit. > +## ldlinux.sys must fit between the bootsector and two copies of ADV whose size may vary. > +## > +## Certain file systems will simply install ldlinux.sys as an ordinary file, but UFS2 and > +## BTRFS for example, rely on ldlinux.sys being installed on the 0-64k range. > +## > +## 0-64k range: > +## [0](bootsector)[512](ldlinux.sys)[65536 - 2 * ADV_SIZE](2 copies of ADV)[65536] > + > +use File::stat; > + > +($ldlinux_bin) = @ARGV; > +$adv_size = 512; > +$limit = 65536 - 2 * $adv_size - 512; > +$pad = 512; > + > +$ldlinux_size = stat($ldlinux_bin)->size - 1024; > +$align = $ldlinux_size % $pad; > +$ldlinux_size += $pad - $align; > + > +if ($ldlinux_size > $limit) { > + print STDERR "$0: ldlinux.sys ($ldlinux_size) larger than limit ($limit).\n"; > + exit 1; > +} > + > +exit 0; > -- > 1.7.2.5 >-- Matt Fleming, Intel Open Source Technology Center
Raphael S Carvalho
2013-Sep-16 14:46 UTC
[syslinux] [PATCH 1/1] core: Check if ldlinux.sys exceeds the limit at its building time.
On Mon, Sep 16, 2013 at 11:08 AM, Matt Fleming <matt at console-pimps.org> wrote:> Peter, does this look OK to you? > > Raphael, I can't work out why ADV_SIZE is a constant in this file?Matt, ADV_SIZE is currently a constant value, but it may change in the future. So it would need some care. Regards, Raphael S. Carvalho
Geert Stappers
2014-May-25 07:35 UTC
[syslinux] [PATCH 1/1] core: Check if ldlinux.sys exceeds the limit at its building time.
While going throug old posts found: Op 2013-08-31 om 17:01 schreef Raphael S.Carvalho:> Calc the size of ldlinux.sys from ldlinux.bin, and check if it exceeds the limit. > ldlinux.sys must fit between the bootsector and two copies of ADV whose size may vary. > Thus, the size of ldlinux.sys (limit) can be at most: 65536 - 2 * ADV_SIZE - 512. > > Certain file systems (such as BTRFS and UFS2) will rely on ldlinux.sys being installed on the 0-64k range, > thus it can't exceed the limit, otherwise the superblock would be corrupted. > > Signed-off-by: Raphael S.Carvalho <raphael.scarv at gmail.com> > --- > core/Makefile | 1 + > core/ldlinux_limit.pl | 39 +++++++++++++++++++++++++++++++++++++++ > 2 files changed, 40 insertions(+), 0 deletions(-) > create mode 100755 core/ldlinux_limit.pl > > diff --git a/core/Makefile b/core/Makefile > index f795a5c..e0daafc 100644 > --- a/core/Makefile > +++ b/core/Makefile > @@ -220,6 +220,7 @@ ldlinux.bss: ldlinux.bin > dd if=$< of=$@ bs=512 count=1 > > ldlinux.sys: ldlinux.bin > + $(PERL) $(SRC)/ldlinux_limit.pl $< \ > dd if=$< of=$@ bs=512 skip=2 > > codepage.cp: $(OBJ)/../codepage/$(CODEPAGE).cp > diff --git a/core/ldlinux_limit.pl b/core/ldlinux_limit.pl > new file mode 100755 > index 0000000..923d516 > --- /dev/null > +++ b/core/ldlinux_limit.pl > @@ -0,0 +1,39 @@ > +#!/usr/bin/perl > +## ----------------------------------------------------------------------- > +## > +## Copyright 2013 Raphael S. Carvalho <raphael.scarv at gmail.com> > +## > +## This program is free software; you can redistribute it and/or modify > +## it under the terms of the GNU General Public License as published by > +## the Free Software Foundation, Inc., 53 Temple Place Ste 330, > +## Boston MA 02111-1307, USA; either version 2 of the License, or > +## (at your option) any later version; incorporated herein by reference. > +## > +## ----------------------------------------------------------------------- > + > +## ldlinux_limit.pl: Calc the size of ldlinux.sys and check if it exceeds the limit. > +## ldlinux.sys must fit between the bootsector and two copies of ADV whose size may vary. > +## > +## Certain file systems will simply install ldlinux.sys as an ordinary file, but UFS2 and > +## BTRFS for example, rely on ldlinux.sys being installed on the 0-64k range. > +## > +## 0-64k range: > +## [0](bootsector)[512](ldlinux.sys)[65536 - 2 * ADV_SIZE](2 copies of ADV)[65536] > + > +use File::stat; > + > +($ldlinux_bin) = @ARGV; > +$adv_size = 512; > +$limit = 65536 - 2 * $adv_size - 512; > +$pad = 512; > + > +$ldlinux_size = stat($ldlinux_bin)->size - 1024; > +$align = $ldlinux_size % $pad; > +$ldlinux_size += $pad - $align; > + > +if ($ldlinux_size > $limit) { > + print STDERR "$0: ldlinux.sys ($ldlinux_size) larger than limit ($limit).\n"; > + exit 1; > +} > + > +exit 0; > -- > 1.7.2.5 >Among the follow-up messsages was | op 2013-09-16 om 17:23 schreef Matt Fleming: | > On Mon, 16 Sep, at 09:49:01AM, H. Peter Anvin wrote: | > > We probably will need to increase out to 4K because of newer drives. | > | > Raphael, is there any way we could extract the ADV_SIZE value from | > libinstaller/setadv.h and pass it to ldlinux_limit.pl? That would allow | > things to keep working in future when we do upgrade to 4K. | > IMNSHO is including core/ldlinux_limit.pl better than waiting for a better core/ldlinux_limit.pl Groeten Geert Stappers -- Leven en laten leven
Gene Cumm
2014-May-25 14:27 UTC
[syslinux] [PATCH 1/1] core: Check if ldlinux.sys exceeds the limit at its building time.
On May 25, 2014 3:39 AM, "Geert Stappers" <stappers at stappers.nl> wrote:> > > While going throug old posts found: > > Op 2013-08-31 om 17:01 schreef Raphael S.Carvalho: > > Calc the size of ldlinux.sys from ldlinux.bin, and check if it exceedsthe limit.> > ldlinux.sys must fit between the bootsector and two copies of ADV whosesize may vary.> > Thus, the size of ldlinux.sys (limit) can be at most: 65536 - 2 *ADV_SIZE - 512.> > > > Certain file systems (such as BTRFS and UFS2) will rely on ldlinux.sysbeing installed on the 0-64k range,> > thus it can't exceed the limit, otherwise the superblock would becorrupted. Raphael/Paulo: does UFS2 have a hard 64kiB limit? I know it's not installed to the first sector where the first superblock is located.> IMNSHO is including core/ldlinux_limit.pl better > than waiting for a better core/ldlinux_limit.plThis should be rendered obsolete and unnecessary with the recent patch for ldlinux.sys on btrfs (but might be relevant for UFS2). --Gene
Possibly Parallel Threads
- [PATCH 1/1] core: Check if ldlinux.sys exceeds the limit at its building time.
- [PATCH 1/1] core: Check if ldlinux.sys exceeds the limit at its building time.
- [PATCH v2] core: Check size of ldlinux.sys at building time.
- [PATCH 1/1] core: Check if ldlinux.sys exceeds the limit at its building time.
- [PATCH 1/1] core: Check if ldlinux.sys exceeds the limit at its building time.