summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>1999-11-14 23:09:15 +0000
committerPascal Rigaux <pixel@mandriva.com>1999-11-14 23:09:15 +0000
commit773013b8e45a6916a74ea64152e51fb6cb951920 (patch)
tree1fe018ccc96d5ddf11081ea8d57f263b3be6ae00 /perl-install
parent16caaa0fdfae2bdcec187bdffac3f12d7bb9a8a1 (diff)
downloaddrakx-773013b8e45a6916a74ea64152e51fb6cb951920.tar
drakx-773013b8e45a6916a74ea64152e51fb6cb951920.tar.gz
drakx-773013b8e45a6916a74ea64152e51fb6cb951920.tar.bz2
drakx-773013b8e45a6916a74ea64152e51fb6cb951920.tar.xz
drakx-773013b8e45a6916a74ea64152e51fb6cb951920.zip
no_comment
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/Newt/.cvsignore6
-rw-r--r--perl-install/Newt/Av_CharPtrPtr.c99
-rw-r--r--perl-install/Newt/Av_CharPtrPtr.h4
-rw-r--r--perl-install/Newt/Makefile.PL13
-rw-r--r--perl-install/Newt/Newt.pm16
-rw-r--r--perl-install/Newt/Newt.xs546
-rw-r--r--perl-install/Newt/typemap25
-rw-r--r--perl-install/fsedit.pm130
-rw-r--r--perl-install/install2.pm29
-rw-r--r--perl-install/install_steps_interactive.pm6
-rw-r--r--perl-install/partition_table.pm13
-rw-r--r--perl-install/resize_fat/any.pm7
-rw-r--r--perl-install/resize_fat/c_rewritten.xs100
-rw-r--r--perl-install/resize_fat/dir_entry.pm4
-rw-r--r--perl-install/resize_fat/directory.pm14
-rw-r--r--perl-install/resize_fat/fat.pm50
-rw-r--r--perl-install/resize_fat/io.pm2
-rw-r--r--perl-install/resize_fat/main.pm13
18 files changed, 916 insertions, 161 deletions
diff --git a/perl-install/Newt/.cvsignore b/perl-install/Newt/.cvsignore
new file mode 100644
index 000000000..c296b7faf
--- /dev/null
+++ b/perl-install/Newt/.cvsignore
@@ -0,0 +1,6 @@
+Newt.bs
+Newt.c
+pm_to_blib
+blib
+Makefile
+Makefile_c
diff --git a/perl-install/Newt/Av_CharPtrPtr.c b/perl-install/Newt/Av_CharPtrPtr.c
new file mode 100644
index 000000000..d108ef5d0
--- /dev/null
+++ b/perl-install/Newt/Av_CharPtrPtr.c
@@ -0,0 +1,99 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+#include "Av_CharPtrPtr.h" /* XS_*_charPtrPtr() */
+#ifdef __cplusplus
+}
+#endif
+
+
+/* Used by the INPUT typemap for char**.
+ * Will convert a Perl AV* (containing strings) to a C char**.
+ */
+char **
+XS_unpack_charPtrPtr( rv )
+SV *rv;
+{
+ AV *av;
+ SV **ssv;
+ char **s;
+ int avlen;
+ int x;
+
+ if( SvROK( rv ) && (SvTYPE(SvRV(rv)) == SVt_PVAV) )
+ av = (AV*)SvRV(rv);
+ else {
+ warn("XS_unpack_charPtrPtr: rv was not an AV ref");
+ return( (char**)NULL );
+ }
+
+ /* is it empty? */
+ avlen = av_len(av);
+ if( avlen < 0 ){
+ warn("XS_unpack_charPtrPtr: array was empty");
+ return( (char**)NULL );
+ }
+
+ /* av_len+2 == number of strings, plus 1 for an end-of-array sentinel.
+ */
+ s = (char **)safemalloc( sizeof(char*) * (avlen + 2) );
+ if( s == NULL ){
+ warn("XS_unpack_charPtrPtr: unable to malloc char**");
+ return( (char**)NULL );
+ }
+ for( x = 0; x <= avlen; ++x ){
+ ssv = av_fetch( av, x, 0 );
+ if( ssv != NULL ){
+ if( SvPOK( *ssv ) ){
+ s[x] = (char *)safemalloc( SvCUR(*ssv) + 1 );
+ if( s[x] == NULL )
+ warn("XS_unpack_charPtrPtr: unable to malloc char*");
+ else
+ strcpy( s[x], SvPV( *ssv, na ) );
+ }
+ else
+ warn("XS_unpack_charPtrPtr: array elem %d was not a string.", x );
+ }
+ else
+ s[x] = (char*)NULL;
+ }
+ s[x] = (char*)NULL; /* sentinel */
+ return( s );
+}
+
+/* Used by the OUTPUT typemap for char**.
+ * Will convert a C char** to a Perl AV*.
+ */
+void
+XS_pack_charPtrPtr( st, s )
+SV *st;
+char **s;
+{
+ AV *av = newAV();
+ SV *sv;
+ char **c;
+
+ for( c = s; *c != NULL; ++c ){
+ sv = newSVpv( *c, 0 );
+ av_push( av, sv );
+ }
+ sv = newSVrv( st, NULL ); /* upgrade stack SV to an RV */
+ SvREFCNT_dec( sv ); /* discard */
+ SvRV( st ) = (SV*)av; /* make stack RV point at our AV */
+}
+
+
+/* cleanup the temporary char** from XS_unpack_charPtrPtr */
+void
+XS_release_charPtrPtr(s)
+char **s;
+{
+ char **c;
+ for( c = s; *c != NULL; ++c )
+ safefree( *c );
+ safefree( s );
+}
+
diff --git a/perl-install/Newt/Av_CharPtrPtr.h b/perl-install/Newt/Av_CharPtrPtr.h
new file mode 100644
index 000000000..765f1a731
--- /dev/null
+++ b/perl-install/Newt/Av_CharPtrPtr.h
@@ -0,0 +1,4 @@
+char ** XS_unpack_charPtrPtr _(( SV *rv ));
+void XS_pack_charPtrPtr _(( SV *st, char **s ));
+void XS_release_charPtrPtr _(( char **s ));
+
diff --git a/perl-install/Newt/Makefile.PL b/perl-install/Newt/Makefile.PL
new file mode 100644
index 000000000..6378a8f31
--- /dev/null
+++ b/perl-install/Newt/Makefile.PL
@@ -0,0 +1,13 @@
+use ExtUtils::MakeMaker;
+# See lib/ExtUtils/MakeMaker.pm for details of how to influence
+# the contents of the Makefile that is written.
+
+WriteMakefile(
+ 'NAME' => 'Newt',
+ 'OBJECT' => 'Av_CharPtrPtr.o Newt.o',
+ 'MAKEFILE' => 'Makefile_c',
+ 'OPTIMIZE' => '-Os',
+ 'VERSION_FROM' => 'Newt.pm', # finds $VERSION
+ 'LIBS' => ['-lnewt -lslang'],
+ 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
+);
diff --git a/perl-install/Newt/Newt.pm b/perl-install/Newt/Newt.pm
new file mode 100644
index 000000000..80dbaf54f
--- /dev/null
+++ b/perl-install/Newt/Newt.pm
@@ -0,0 +1,16 @@
+package Newt;
+
+use strict;
+use vars qw($VERSION @ISA);
+use DynaLoader;
+
+use vars qw($VERSION @ISA);
+@ISA = qw(DynaLoader);
+$VERSION = '0.01';
+bootstrap Newt $VERSION;
+
+package Newt::Component;
+package Newt::Grid;
+
+
+1;
diff --git a/perl-install/Newt/Newt.xs b/perl-install/Newt/Newt.xs
new file mode 100644
index 000000000..e60583de1
--- /dev/null
+++ b/perl-install/Newt/Newt.xs
@@ -0,0 +1,546 @@
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+#include <newt.h>
+
+static void suspend() {
+ newtSuspend();
+ raise(SIGTSTP);
+ newtResume();
+}
+
+typedef newtComponent Newt__Component;
+typedef newtGrid Newt__Grid;
+
+
+MODULE = Newt PACKAGE = Newt PREFIX = newt
+
+void
+DESTROY()
+ CODE:
+ {
+ newtFinished();
+ }
+
+void
+changeColors()
+ CODE:
+{
+const struct newtColors colors = {
+ "cyan", "black", /* root fg, bg */
+ "black", "blue", /* border fg, bg */
+ "white", "blue", /* window fg, bg */
+ "white", "black", /* shadow fg, bg */
+ "white", "blue", /* title fg, bg */
+ "yellow", "cyan", /* button fg, bg */
+ "white", "cyan", /* active button fg, bg */
+ "yellow", "blue", /* checkbox fg, bg */
+ "blue", "brown", /* active checkbox fg, bg */
+ "yellow", "blue", /* entry box fg, bg */
+ "white", "blue", /* label fg, bg */
+ "black", "cyan", /* listbox fg, bg */
+ "yellow", "cyan", /* active listbox fg, bg */
+ "white", "blue", /* textbox fg, bg */
+ "cyan", "black", /* active textbox fg, bg */
+ "white", "blue", /* help line */
+ "yellow", "blue", /* root text */
+ "blue", /* scale full */
+ "red", /* scale empty */
+ "blue", "cyan", /* disabled entry fg, bg */
+ "white", "blue", /* compact button fg, bg */
+ "yellow", "red", /* active & sel listbox */
+ "black", "brown" /* selected listbox */
+};
+ newtSetColors(colors);
+}
+
+int
+newtInit()
+
+int
+newtFinished()
+
+void
+newtCls()
+
+int
+newtCenteredWindow(width,height,title)
+ int width;
+ int height;
+ const char * title;
+
+void
+newtPopWindow()
+
+void
+newtRefresh()
+
+void
+newtPushHelpLine(text)
+ const char * text;
+
+void
+newtDrawRootText(row,col,text)
+ int row;
+ int col;
+ const char * text;
+
+void
+newtGetScreenSize()
+ PPCODE:
+{
+ int cols, rows;
+ newtGetScreenSize(&cols, &rows);
+ PUSHs(sv_2mortal(newSViv(cols)));
+ PUSHs(sv_2mortal(newSViv(rows)));
+}
+
+void
+newtSetSuspendCallback()
+ CODE:
+ {
+ newtSetSuspendCallback(suspend, NULL);
+ }
+
+
+void
+newtWinMessage(title,buttonText,text)
+ char * title;
+ char * buttonText;
+ char * text;
+
+int
+newtWinChoice(title,button1,button2,text)
+ char * title;
+ char * button1;
+ char * button2;
+ char * text;
+
+int
+newtWinTernary(title,button1,button2,button3,message)
+ char * title;
+ char * button1;
+ char * button2;
+ char * button3;
+ char * message;
+
+void
+newtWinMenu(title,text,suggestedWidth,flexDown,flexUp,maxListHeight,list,def,buttons, ...)
+ char * title;
+ char * text;
+ int suggestedWidth;
+ int flexDown;
+ int flexUp;
+ int maxListHeight;
+ char **list;
+ int def;
+ char *buttons;
+ PPCODE:
+ {
+ int button;
+#define nb 8
+#define a(i) SvPV(ST(i + nb),PL_na)
+ button = newtWinMenu(title, text, suggestedWidth, flexDown, flexUp, maxListHeight, list, &def,
+ items > nb + 0 ? a( 0) : NULL,
+ items > nb + 1 ? a( 1) : NULL,
+ items > nb + 2 ? a( 2) : NULL,
+ items > nb + 3 ? a( 3) : NULL,
+ items > nb + 4 ? a( 4) : NULL,
+ items > nb + 5 ? a( 5) : NULL,
+ items > nb + 6 ? a( 6) : NULL,
+ items > nb + 7 ? a( 7) : NULL,
+ items > nb + 8 ? a( 8) : NULL,
+ items > nb + 9 ? a( 9) : NULL,
+ items > nb + 10 ? a(10) : NULL,
+ NULL);
+#undef a
+ EXTEND(SP, 2);
+ PUSHs(sv_2mortal(newSViv(button)));
+ PUSHs(sv_2mortal(newSViv(def)));
+ }
+
+MODULE = Newt PACKAGE = Newt::Component PREFIX = newt
+
+Newt::Component
+newtCompactButton(left,top,text)
+ int left;
+ int top;
+ const char * text;
+
+Newt::Component
+newtButton(left,top,text)
+ int left;
+ int top;
+ const char * text;
+
+Newt::Component
+newtCheckbox(left,top,text,defValue,seq,result)
+ int left;
+ int top;
+ const char * text;
+ char *defValue;
+ const char * seq;
+ int *result;
+ CODE:
+ RETVAL = newtCheckbox(left, top, text, defValue[0], seq, (char*)result);
+ OUTPUT:
+ RETVAL
+
+int
+newtCheckboxGetValue(co)
+ Newt::Component co;
+
+void
+newtCheckboxSetValue(co, value)
+ Newt::Component co;
+ char *value;
+ CODE:
+ newtCheckboxSetValue(co, value[0]);
+
+Newt::Component
+newtLabel(left,top,text)
+ int left;
+ int top;
+ const char * text;
+
+void
+newtLabelSetText(co,text)
+ Newt::Component co;
+ const char * text;
+
+Newt::Component
+newtVerticalScrollbar(left,top,height,normalColorset,thumbColorset)
+ int left;
+ int top;
+ int height;
+ int normalColorset;
+ int thumbColorset;
+
+void
+newtScrollbarSet(co,where,total)
+ Newt::Component co;
+ int where;
+ int total;
+
+Newt::Component
+newtListbox(left,top,height,flags)
+ int left;
+ int top;
+ int height;
+ int flags;
+
+void *
+newtListboxGetCurrent(co)
+ Newt::Component co;
+
+void
+newtListboxSetCurrent(co,num)
+ Newt::Component co;
+ int num;
+
+void
+newtListboxSetCurrentByKey(co,key)
+ Newt::Component co;
+ void * key;
+
+void
+newtListboxSetText(co,num,text)
+ Newt::Component co;
+ int num;
+ const char * text;
+
+void
+newtListboxSetEntry(co,num,text)
+ Newt::Component co;
+ int num;
+ const char * text;
+
+void
+newtListboxSetWidth(co,width)
+ Newt::Component co;
+ int width;
+
+# return the data passed to AddEntry
+void
+newtListboxSetData(co,num,data)
+ Newt::Component co;
+ int num;
+ void * data;
+
+int
+newtListboxAddEntry(co,text,data)
+ Newt::Component co;
+ const char * text;
+ const void * data;
+
+# Send the key to insert after, or NULL to insert at the top
+int
+newtListboxInsertEntry(co,text,data,key)
+ Newt::Component co;
+ const char * text;
+ const void * data;
+ void * key;
+
+int
+newtListboxDeleteEntry(co,data)
+ Newt::Component co;
+ void * data;
+
+# removes all entries from listbox
+void
+newtListboxClear(co)
+ Newt::Component co;
+
+void
+newtListboxGetEntry(co,num,text,data)
+ Newt::Component co;
+ int num;
+ char * text;
+ void * data;
+ PPCODE:
+ {
+ newtListboxGetEntry(co, num, &text, data);
+ }
+
+# Returns an array of data pointers from items, last element is NULL
+void *
+newtListboxGetSelection(co,numitems)
+ Newt::Component co;
+ int *numitems;
+
+void
+newtListboxClearSelection(co)
+ Newt::Component co;
+
+void
+newtListboxSelectItem(co,key,sense)
+ Newt::Component co;
+ void *key
+ enum newtFlagsSense sense;
+
+Newt::Component
+newtTextboxReflowed(left,top,text,width,flexDown,flexUp,flags)
+ int left;
+ int top;
+ char * text;
+ int width;
+ int flexDown;
+ int flexUp;
+ int flags;
+
+Newt::Component
+newtTextbox(left,top,width,height,flags)
+ int left;
+ int top;
+ int width;
+ int height;
+ int flags;
+
+void
+newtTextboxSetText(co,text)
+ Newt::Component co;
+ const char * text;
+
+void
+newtTextboxSetHeight(co,height)
+ Newt::Component co;
+ int height;
+
+int
+newtTextboxGetNumLines(co)
+ Newt::Component co;
+
+char *
+newtReflowText(text,width,flexDown,flexUp,actualWidth,actualHeight)
+ char * text;
+ int width;
+ int flexDown;
+ int flexUp;
+ int * actualWidth;
+ int * actualHeight;
+
+Newt::Component
+newtForm(vertBar,help,flags)
+ Newt::Component vertBar;
+ const char * help;
+ int flags;
+
+void
+newtFormSetSize(co)
+ Newt::Component co;
+
+Newt::Component
+newtFormGetCurrent(co)
+ Newt::Component co;
+
+void
+newtFormSetBackground(co,color)
+ Newt::Component co;
+ int color;
+
+void
+newtFormSetCurrent(co,subco)
+ Newt::Component co;
+ Newt::Component subco;
+
+void
+newtFormAddComponent(form,co)
+ Newt::Component form;
+ Newt::Component co;
+
+void
+newtFormSetHeight(co,height)
+ Newt::Component co;
+ int height;
+
+void
+newtFormSetWidth(co,width)
+ Newt::Component co;
+ int width;
+
+Newt::Component
+newtRunForm(form)
+ Newt::Component form;
+
+void
+newtDrawForm(form)
+ Newt::Component form;
+
+Newt::Component
+newtEntry(left,top,initialValue,width,flag)
+ int left;
+ int top;
+ const char * initialValue;
+ int width;
+ int flag;
+ CODE:
+ {
+ char *result;
+ RETVAL = newtEntry(left,top,initialValue,width,&result,flag);
+ }
+ OUTPUT:
+ RETVAL
+
+void
+newtEntrySet(co,value,cursorAtEnd)
+ Newt::Component co;
+ const char * value;
+ int cursorAtEnd;
+
+char *
+newtEntryGetValue(co)
+ Newt::Component co;
+
+void
+newtFormDestroy(form)
+ Newt::Component form;
+
+MODULE = Newt PACKAGE = Newt::Grid PREFIX = newt
+
+Newt::Grid
+newtCreateGrid(cols,rows)
+ int cols;
+ int rows;
+
+Newt::Grid
+HCloseStacked(first, ...)
+ Newt::Component first;
+ CODE:
+ {
+ int i;
+#define a(i) (newtComponent)SvIV((SV*)SvRV( ST(i) ))
+ RETVAL =
+ newtGridHCloseStacked(
+ items > 0 ? 1 : 0, items > 0 ? a( 0) : NULL,
+ items > 1 ? 1 : 0, items > 1 ? a( 1) : NULL,
+ items > 2 ? 1 : 0, items > 2 ? a( 2) : NULL,
+ items > 3 ? 1 : 0, items > 3 ? a( 3) : NULL,
+ items > 4 ? 1 : 0, items > 4 ? a( 4) : NULL,
+ items > 5 ? 1 : 0, items > 5 ? a( 5) : NULL,
+ items > 6 ? 1 : 0, items > 6 ? a( 6) : NULL,
+ items > 7 ? 1 : 0, items > 7 ? a( 7) : NULL,
+ items > 8 ? 1 : 0, items > 8 ? a( 8) : NULL,
+ items > 9 ? 1 : 0, items > 9 ? a( 9) : NULL,
+ items > 10 ? 1 : 0, items > 10 ? a(10) : NULL,
+ NULL);
+#undef a
+ }
+OUTPUT:
+RETVAL
+
+
+Newt::Grid
+newtGridBasicWindow(text,middle,buttons)
+ Newt::Component text;
+ Newt::Grid middle;
+ Newt::Grid buttons;
+
+
+Newt::Grid
+newtGridSimpleWindow(text,middle,buttons)
+ Newt::Component text;
+ Newt::Component middle;
+ Newt::Grid buttons;
+
+void
+newtGridSetField(grid,col,row,type,val,padLeft,padTop,padRight,padBottom,anchor,flags)
+ Newt::Grid grid;
+ int col;
+ int row;
+ enum newtGridElement type;
+ void * val;
+ int padLeft;
+ int padTop;
+ int padRight;
+ int padBottom;
+ int anchor;
+ int flags;
+
+
+void
+newtGridFree(grid,recurse)
+ Newt::Grid grid;
+ int recurse;
+
+void
+newtGridGetSize(grid,width,height)
+ Newt::Grid grid;
+ int * width;
+ int * height;
+
+void
+newtGridWrappedWindow(grid,title)
+ Newt::Grid grid;
+ char * title;
+
+void
+newtGridAddComponentsToForm(grid,form,recurse)
+ Newt::Grid grid;
+ Newt::Component form;
+ int recurse;
+
+Newt::Grid
+newtButtonBar(button1, ...)
+ char * button1;
+ PPCODE:
+ {
+ static newtComponent p[11];
+ int i;
+ EXTEND(SP, items + 1);
+#define a(i) (char *)SvPV(ST(i),PL_na)
+ PUSHs(sv_setref_pv(sv_newmortal(), "Newt::Grid",
+ newtButtonBar(items > 0 ? a( 0) : NULL, items > 0 ? &p[ 0] : NULL,
+ items > 1 ? a( 1) : NULL, items > 1 ? &p[ 1] : NULL,
+ items > 2 ? a( 2) : NULL, items > 2 ? &p[ 2] : NULL,
+ items > 3 ? a( 3) : NULL, items > 3 ? &p[ 3] : NULL,
+ items > 4 ? a( 4) : NULL, items > 4 ? &p[ 4] : NULL,
+ items > 5 ? a( 5) : NULL, items > 5 ? &p[ 5] : NULL,
+ items > 6 ? a( 6) : NULL, items > 6 ? &p[ 6] : NULL,
+ items > 7 ? a( 7) : NULL, items > 7 ? &p[ 7] : NULL,
+ items > 8 ? a( 8) : NULL, items > 8 ? &p[ 8] : NULL,
+ items > 9 ? a( 9) : NULL, items > 9 ? &p[ 9] : NULL,
+ items > 10 ? a(10) : NULL, items > 10 ? &p[10] : NULL,
+ NULL)));
+#undef a
+ for (i = 0; i < items; i++) PUSHs(sv_setref_pv(sv_newmortal(), "Newt::Component", p[i]));
+ }
diff --git a/perl-install/Newt/typemap b/perl-install/Newt/typemap
new file mode 100644
index 000000000..5aaa2f668
--- /dev/null
+++ b/perl-install/Newt/typemap
@@ -0,0 +1,25 @@
+TYPEMAP
+
+const char * T_PV
+const void * T_PV
+int * T_PV
+void ** T_PACKED
+
+enum newtFlagsSense T_IV
+enum newtGridElement T_IV
+SV ** T_SV
+
+Newt::Component NewtComponent
+Newt::Grid NewtGrid
+
+INPUT
+NewtComponent
+ $var = ($type) SvIV((SV*)SvRV($arg))
+NewtGrid
+ $var = ($type) SvIV((SV*)SvRV($arg))
+
+OUTPUT
+NewtComponent
+ sv_setref_pv($arg, "Newt::Component", (void*) $var);
+NewtGrid
+ sv_setref_pv($arg, "Newt::Grid", (void*) $var);
diff --git a/perl-install/fsedit.pm b/perl-install/fsedit.pm
index dec35b258..ebae53669 100644
--- a/perl-install/fsedit.pm
+++ b/perl-install/fsedit.pm
@@ -20,14 +20,14 @@ use log;
#- Globals
#-#####################################################################################
my @suggestions = (
- { mntpoint => "/boot", minsize => 10 << 11, size => 16 << 11, type => 0x83 },
- { mntpoint => "/", minsize => 50 << 11, size => 100 << 11, type => 0x83 },
- { mntpoint => "swap", minsize => 30 << 11, size => 60 << 11, type => 0x82 },
- { mntpoint => "/usr", minsize => 200 << 11, size => 600 << 11, type => 0x83 },
- { mntpoint => "/home", minsize => 50 << 11, size => 200 << 11, type => 0x83 },
- { mntpoint => "/var", minsize => 200 << 11, size => 250 << 11, type => 0x83 },
- { mntpoint => "/tmp", minsize => 50 << 11, size => 100 << 11, type => 0x83 },
- { mntpoint => "/mnt/iso", minsize => 700 << 11, size => 800 << 11, type => 0x83 },
+ { mntpoint => "/boot", size => 16 << 11, type => 0x83, maxsize => 30 << 11 },
+ { mntpoint => "/", size => 50 << 11, type => 0x83, ratio => 1, maxsize => 300 << 11 },
+ { mntpoint => "swap", size => 30 << 11, type => 0x82, ratio => 1, maxsize => 250 << 11 },
+ { mntpoint => "/usr", size => 200 << 11, type => 0x83, ratio => 6, maxsize =>1500 << 11 },
+ { mntpoint => "/home", size => 50 << 11, type => 0x83, ratio => 3 },
+ { mntpoint => "/var", size => 200 << 11, type => 0x83, ratio => 1, maxsize =>1000 << 11 },
+ { mntpoint => "/tmp", size => 50 << 11, type => 0x83, ratio => 3, maxsize => 500 << 11 },
+ { mntpoint => "/mnt/iso", size => 700 << 11, type => 0x83 },
);
my @suggestions_mntpoints = qw(/mnt/dos);
@@ -44,12 +44,6 @@ sub typeOfPart($) { typeFromMagic(devices::make($_[0]), @partitions_signatures)
#-######################################################################################
#- Functions
#-######################################################################################
-sub suggestions_mntpoint($) {
- my ($hds) = @_;
- sort grep { !/swap/ && !has_mntpoint($_, $hds) }
- (@suggestions_mntpoints, map { $_->{mntpoint} } @suggestions);
-}
-
sub hds($$) {
my ($drives, $flags) = @_;
my @hds;
@@ -94,6 +88,10 @@ sub get_fstab(@) {
map { partition_table::get_normal_parts($_) } @_;
}
+sub free_space(@) {
+ sum map { $_->{size} } map { partition_table::get_holes($_) } @_;
+}
+
sub hasRAID {
my $b = 0;
map { $b ||= isRAID($_) } get_fstab(@_);
@@ -107,30 +105,50 @@ sub get_root($) {
}
sub get_root_ { get_root([ get_fstab(@{$_[0]}) ]) }
+
+sub computeSize($$$$) {
+ my ($part, $best, $hds, $suggestions) = @_;
+ my $max = $part->{maxsize} || $part->{size};
+ my $tot_ratios = sum(map { $_->{ratio} } grep { !has_mntpoint($_->{mntpoint}, $hds) } @$suggestions);
+
+ min($max,
+ $best->{maxsize} || $max,
+ $best->{size}
+ + free_space(@$hds)
+ * ($tot_ratios && $best->{ratio} / $tot_ratios));
+}
+
sub suggest_part($$$;$) {
my ($hd, $part, $hds, $suggestions) = @_;
$suggestions ||= \@suggestions;
- foreach (@$suggestions) { $_->{minsize} ||= $_->{size} }
my $has_swap = grep { isSwap($_) } get_fstab(@$hds);
my ($best, $second) =
- grep { $part->{size} >= $_->{minsize} }
- grep { ! has_mntpoint($_->{mntpoint}, $hds) || isSwap($_) && !$has_swap }
+ grep { !$_->{maxsize} || $part->{size} <= $_->{maxsize} }
+ grep { $_->{size} <= ($part->{maxsize} || $part->{size}) }
+ grep { !has_mntpoint($_->{mntpoint}, $hds) || isSwap($_) && !$has_swap }
+ grep { !$part->{type} || $part->{type} == $_->{type} }
@$suggestions or return;
$best = $second if
$best->{mntpoint} eq '/boot' &&
- $part->{start} + $best->{minsize} > 1024 * partition_table::cylinder_size($hd); #- if the empty slot is beyond the 1024th cylinder, no use having /boot
+ $part->{start} + $best->{size} > 1024 * partition_table::cylinder_size($hd); #- if the empty slot is beyond the 1024th cylinder, no use having /boot
defined $best or return; #- sorry no suggestion :(
$part->{mntpoint} = $best->{mntpoint};
$part->{type} = $best->{type};
- $part->{size} = min($part->{size}, $best->{size});
+ $part->{size} = computeSize($part, $best, $hds, $suggestions);
+ print "<<<<$part->{size}, $part->{maxsize}\n";
1;
}
+sub suggestions_mntpoint($) {
+ my ($hds) = @_;
+ sort grep { !/swap/ && !has_mntpoint($_, $hds) }
+ (@suggestions_mntpoints, map { $_->{mntpoint} } @suggestions);
+}
#-sub partitionDrives {
#-
@@ -183,78 +201,32 @@ sub add($$$;$) {
($part->{mntpoint} = 'swap') :
$options->{force} || check_mntpoint($part->{mntpoint}, $hd, $part, $hds);
+ delete $part->{maxsize};
partition_table::add($hd, $part, $options->{primaryOrExtended});
}
-sub removeFromList($$$) {
- my ($start, $end, $list) = @_;
- my $err = "error in removeFromList: removing an non-free block";
-
- for (my $i = 0; $i < @$list; $i += 2) {
- $start < $list->[$i] and die $err;
- $start > $list->[$i + 1] and next;
-
- if ($start == $list->[$i]) {
- $end > $list->[$i + 1] and die $err;
- if ($end == $list->[$i + 1]) {
- #- the free block is just the same size, removing it
- splice(@$list, $i, 2);
- } else {
- #- the free block now start just after this block
- $list->[$i] = $end;
- }
- } else {
- $end <= $list->[$i + 1] or die $err;
- if ($end < $list->[$i + 1]) {
- splice(@$list, $i + 2, 0, $end, $list->[$i + 1]);
- }
- $list->[$i + 1] = $start; #- shorten the free block
- }
- return;
- }
-}
-
-
sub allocatePartitions($$) {
my ($hds, $to_add) = @_;
- my %free_sectors = map { $_->{device} => [1, $_->{totalsectors} ] } @$hds; #- first sector is always occupied by the MBR
- my $remove = sub { removeFromList($_[0]{start}, $_[0]->{start} + $_[0]->{size}, $free_sectors{$_[0]->{rootDevice}}) };
- my $success = 0;
-
- foreach (get_fstab(@$hds)) { &$remove($_); }
- FSTAB: foreach (@$to_add) {
- my %e = %$_;
- foreach my $hd (@$hds) {
- my $v = $free_sectors{$hd->{device}};
- for (my $i = 0; $i < @$v; $i += 2) {
- my $size = $v->[$i + 1] - $v->[$i];
- $e{size} > $size and next;
-
- if ($v->[$i] + $e{size} > 1024 * partition_table::cylinder_size($hd)) {
- next if $e{mntpoint} eq "/boot" ||
- $e{mntpoint} eq "/" && !has_mntpoint("/boot", $hds);
- }
- $e{start} = $v->[$i];
- $e{rootDevice} = $hd->{device};
- partition_table::adjustStartAndEnd($hd, \%e);
- &$remove(\%e);
- partition_table::add($hd, \%e);
- $success++;
- next FSTAB;
+ foreach my $hd (@$hds) {
+ foreach (partition_table::get_holes($hd)) {
+ my ($start, $size) = @$_{"start", "size"};
+ my $part;
+ while (suggest_part($hd,
+ $part = { start => $start, size => 0, maxsize => $size },
+ $hds, $to_add)) {
+ add($hd, $part, $hds);
+ $start = $part->{start} + $part->{size};
+ $size -= $part->{size};
}
+ $start = $_->{start} + $_->{size};
}
- log::ld("can't allocate partition $e{mntpoint} of size $e{size}, not enough room");
}
- $success;
}
sub auto_allocate($;$) {
- my ($hds, $suggestions) = @_;
- allocatePartitions($hds, [
- grep { ! has_mntpoint($_->{mntpoint}, $hds) }
- @{ $suggestions || \@suggestions }
- ]);
+ my ($hds, $suggestions) = @_;
+ allocatePartitions($hds, $suggestions || \@suggestions);
map { partition_table::assign_device_numbers($_) } @$hds;
}
diff --git a/perl-install/install2.pm b/perl-install/install2.pm
index b6b928c38..0438e885f 100644
--- a/perl-install/install2.pm
+++ b/perl-install/install2.pm
@@ -90,24 +90,25 @@ my @install_classes = (__("beginner"), __("developer"), __("server"), __("expert
#- partition layout
my %suggestedPartitions = (
normal => my $b = [
- { mntpoint => "/", size => 700 << 11, type => 0x83 },
- { mntpoint => "swap", size => 128 << 11, type => 0x82 },
- { mntpoint => "/home", size => 300 << 11, type => 0x83 },
+ { mntpoint => "/boot", size => 10 << 11, type => 0x83, maxsize => 30 << 11 },
+ { mntpoint => "/", size => 300 << 11, type => 0x83, ratio => 5, maxsize => 1500 << 11 },
+ { mntpoint => "swap", size => 64 << 11, type => 0x82, ratio => 1, maxsize => 250 << 11 },
+ { mntpoint => "/home", size => 300 << 11, type => 0x83, ratio => 5 },
],
developer => [
- { mntpoint => "/boot", size => 16 << 11, type => 0x83 },
- { mntpoint => "swap", size => 128 << 11, type => 0x82 },
- { mntpoint => "/", size => 200 << 11, type => 0x83 },
- { mntpoint => "/usr", size => 600 << 11, type => 0x83 },
- { mntpoint => "/home", size => 500 << 11, type => 0x83 },
+ { mntpoint => "/boot", size => 10 << 11, type => 0x83, maxsize => 30 << 11 },
+ { mntpoint => "swap", size => 64 << 11, type => 0x82, ratio => 1, maxsize => 250 << 11 },
+ { mntpoint => "/", size => 150 << 11, type => 0x83, ratio => 1, maxsize => 300 << 11 },
+ { mntpoint => "/usr", size => 300 << 11, type => 0x83, ratio => 4, maxsize =>1500 << 11 },
+ { mntpoint => "/home", size => 100 << 11, type => 0x83, ratio => 5 },
],
server => [
- { mntpoint => "/boot", size => 16 << 11, type => 0x83 },
- { mntpoint => "swap", size => 512 << 11, type => 0x82 },
- { mntpoint => "/", size => 200 << 11, type => 0x83 },
- { mntpoint => "/usr", size => 600 << 11, type => 0x83 },
- { mntpoint => "/var", size => 600 << 11, type => 0x83 },
- { mntpoint => "/home", size => 500 << 11, type => 0x83 },
+ { mntpoint => "/boot", size => 10 << 11, type => 0x83, maxsize => 30 << 11 },
+ { mntpoint => "swap", size => 64 << 11, type => 0x82, ratio => 2, maxsize => 400 << 11 },
+ { mntpoint => "/", size => 150 << 11, type => 0x83, ratio => 1, maxsize => 250 << 11 },
+ { mntpoint => "/usr", size => 300 << 11, type => 0x83, ratio => 3, maxsize =>1500 << 11 },
+ { mntpoint => "/var", size => 100 << 11, type => 0x83, ratio => 4 },
+ { mntpoint => "/home", size => 100 << 11, type => 0x83, ratio => 5 },
],
);
diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm
index 886328b6b..d1c789056 100644
--- a/perl-install/install_steps_interactive.pm
+++ b/perl-install/install_steps_interactive.pm
@@ -749,17 +749,17 @@ _("Linear (needed for some SCSI drives)") => { val => \$b->{linear}, type => "bo
_("Compact") => { val => \$b->{compact}, type => "bool", text => _("compact") },
_("Delay before booting default image") => \$b->{timeout},
_("Video mode") => { val => \$b->{vga}, list => [ keys %lilo::vga_modes ], not_edit => $::beginner },
-$o->{security} < 2 ? () : (
+$o->{security} >= 4 ? () : (
_("Password") => { val => \$b->{password}, hidden => 1 },
_("Restrict command line options") => { val => \$b->{restricted}, type => "bool", text => _("restrict") },
)
);
- @l = @l[0..3] if $::beginner;
+ @l = @l[0..3] unless $::expert;
$b->{vga} ||= 'Normal';
$o->ask_from_entries_refH('', _("LILO main options"), \@l,
complete => sub {
- $o->{security} > 4 && length($b->{password}) < 6 and $o->ask_warn('', _("At this level of security, a password (and a good one) in lilo is requested")), return 1;
+#- $o->{security} > 4 && length($b->{password}) < 6 and $o->ask_warn('', _("At this level of security, a password (and a good one) in lilo is requested")), return 1;
$b->{restricted} && !$b->{password} and $o->ask_warn('', _("Option ``Restrict command line options'' is of no use without a password")), return 1;
0;
}
diff --git a/perl-install/partition_table.pm b/perl-install/partition_table.pm
index 094481c3a..05d30b916 100644
--- a/perl-install/partition_table.pm
+++ b/perl-install/partition_table.pm
@@ -220,7 +220,7 @@ sub verifyInside($$) {
sub verifyParts_ {
foreach my $i (@_) { foreach (@_) {
- $i != $_ and verifyNotOverlap($i, $_) || cdie "partitions sector #$i->{start} ($i->{size}bytes) and sector #$_->{start} ($_->{size}bytes) are overlapping!";
+ $i != $_ and verifyNotOverlap($i, $_) || cdie sprintf "partitions sector #$i->{start} (%dMB) and sector #$_->{start} (%dMB) are overlapping!", $i->{size} >> 9, $_->{size} >> 9;
}}
}
sub verifyParts($) {
@@ -300,6 +300,17 @@ sub get_normal_parts($) {
@{$hd->{primary}{normal} || []}, map { $_->{normal} } @{$hd->{extended} || []}
}
+sub get_holes($) {
+ my ($hd) = @_;
+
+ my $start = 1;
+ map {
+ my $current = $start;
+ $start = $_->{start} + $_->{size};
+ { start => $current, size => $_->{start} - $current }
+ } sort { $a->{start} <=> $b->{start} } get_normal_parts($hd), { start => $hd->{totalsectors}, size => 0 };
+}
+
sub read_one($$) {
my ($hd, $sector) = @_;
diff --git a/perl-install/resize_fat/any.pm b/perl-install/resize_fat/any.pm
index ff0045d0b..252caed4b 100644
--- a/perl-install/resize_fat/any.pm
+++ b/perl-install/resize_fat/any.pm
@@ -54,12 +54,11 @@ sub max_size($) {
divide($fs->{cluster_offset}, $SECTORSIZE);
}
-#- fills in $fs->{fat_flag_map}.
+#- fills in fat_flag_map in c_rewritten.
#- Each FAT entry is flagged as either FREE, FILE or DIRECTORY.
sub flag_clusters {
my ($fs) = @_;
my ($cluster, $entry, $type, $nb_dirs);
- my $fat_flag_map = "\0" x ($fs->{nb_clusters} + 2);
my $f = sub {
($entry) = @_;
@@ -71,11 +70,11 @@ sub flag_clusters {
$type = $DIRECTORY;
} else { return }
- my $nb = resize_fat::c_rewritten::checkFat($fat_flag_map, $cluster, $type, $entry->{name});
+ my $nb = resize_fat::c_rewritten::checkFat($cluster, $type, $entry->{name});
$nb_dirs += $nb if $type == $DIRECTORY;
0;
};
+ resize_fat::c_rewritten::allocate_fat_flag($fs->{nb_clusters} + 2);
resize_fat::directory::traverse_all($fs, $f);
- $fs->{fat_flag_map} = $fat_flag_map;
$fs->{clusters}{count}{dirs} = $nb_dirs;
}
diff --git a/perl-install/resize_fat/c_rewritten.xs b/perl-install/resize_fat/c_rewritten.xs
index a42f3d133..388f8b9ea 100644
--- a/perl-install/resize_fat/c_rewritten.xs
+++ b/perl-install/resize_fat/c_rewritten.xs
@@ -4,8 +4,10 @@
/* set by scan_fat, used by next */
short *fat = NULL;
+char *fat_flag_map = NULL;
+unsigned int *fat_remap = NULL;
+int fat_remap_size;
int type_size, nb_clusters, bad_cluster_value;
-char *fat_flag_map;
unsigned int next(unsigned int cluster) {
short *p = fat + type_size * cluster;
@@ -13,19 +15,63 @@ unsigned int next(unsigned int cluster) {
return type_size == 1 ? *p : *((unsigned int *) p);
}
+void set_next(unsigned int cluster, unsigned int val) {
+ short *p = fat + type_size * cluster;
+ if (cluster > nb_clusters + 2) croak("fat::set_next: cluster %d outside filesystem", cluster);
+ type_size == 1 ? *p : *((unsigned int *) p) = val;
+}
+
MODULE = resize_fat::c_rewritten PACKAGE = resize_fat::c_rewritten
+void
+read_fat(fd, offset, size, magic)
+ int fd
+ int offset
+ int size
+ unsigned char magic
+ PPCODE:
+{
+ fat = (short *) malloc(size);
+ if (lseek(fd, offset, SEEK_SET) != offset ||
+ read(fd, fat, size) != size) {
+ free(fat); fat = NULL;
+ croak("reading FAT failed");
+ }
+ if (magic != *(unsigned char *) fat) {
+ free(fat); fat = NULL;
+ croak("FAT has invalid signature");
+ }
+}
+
void
-scan_fat(fat_, nb_clusters_, type_size_)
- char *fat_
+write_fat(fd, size)
+ int fd
+ int size
+ PPCODE:
+{
+ if (write(fd, fat, size) != size) croak("write_fat: write failed");
+}
+
+void
+free_all()
+ PPCODE:
+#define FREE(p) if (p) free(p), p = NULL;
+ FREE(fat);
+ FREE(fat_flag_map);
+ FREE(fat_remap);
+#undef FREE
+
+void
+scan_fat(nb_clusters_, type_size_)
int nb_clusters_
int type_size_
PPCODE:
+{
unsigned int v;
int free = 0, bad = 0, used = 0;
short *p;
- fat = (short*) fat_; type_size = type_size_; nb_clusters = nb_clusters_;
+ type_size = type_size_; nb_clusters = nb_clusters_;
bad_cluster_value = type_size ? 0xffffff7 : 0xfff7;
if (type_size % 16) fprintf(stderr, "unable to handle type_size"), exit(1);
@@ -42,6 +88,7 @@ scan_fat(fat_, nb_clusters_, type_size_)
PUSHs(sv_2mortal(newSViv(free)));
PUSHs(sv_2mortal(newSViv(bad)));
PUSHs(sv_2mortal(newSViv(used)));
+}
unsigned int
next(unused, cluster)
@@ -52,15 +99,27 @@ next(unused, cluster)
OUTPUT:
RETVAL
+void
+set_next(unused, cluster, val)
+ void *unused
+ unsigned int cluster
+ unsigned int val
+ CODE:
+ set_next(cluster, val);
+
+void
+allocate_fat_flag(size)
+ int size
+ CODE:
+ fat_flag_map = malloc(size);
+
int
-checkFat(fat_flag_map_, cluster, type, name)
- char *fat_flag_map_
+checkFat(cluster, type, name)
unsigned int cluster
int type
char *name
CODE:
int nb = 0;
- fat_flag_map = fat_flag_map_;
for (; cluster < bad_cluster_value; cluster = next(cluster)) {
if (cluster == 0) croak("Bad FAT: unterminated chain for %s\n", name);
@@ -88,3 +147,30 @@ set_flag(cluster, flag)
CODE:
fat_flag_map[cluster] = flag;
+void
+allocate_fat_remap(size)
+ int size
+ CODE:
+ fat_remap_size = size / 4;
+ fat_remap = (unsigned int *) malloc(size);
+
+unsigned int
+fat_remap(cluster)
+ unsigned int cluster
+ CODE:
+ if (cluster >= bad_cluster_value) {
+ RETVAL = cluster; /* special cases */
+ } else {
+ if (fat_remap == NULL) croak("fat_remap NULL in fat_remap");
+ if (cluster >= fat_remap_size) croak("cluster %d >= %d in fat_remap", cluster, fat_remap_size);
+ RETVAL = fat_remap[cluster];
+ }
+ OUTPUT:
+ RETVAL
+
+void
+set_fat_remap(cluster, val)
+ unsigned int cluster
+ unsigned int val
+ CODE:
+ fat_remap[cluster] = val;
diff --git a/perl-install/resize_fat/dir_entry.pm b/perl-install/resize_fat/dir_entry.pm
index 0739b0951..be3bd436a 100644
--- a/perl-install/resize_fat/dir_entry.pm
+++ b/perl-install/resize_fat/dir_entry.pm
@@ -51,12 +51,12 @@ sub is_special_entry($) {
#- return true if entry has been modified
sub remap {
- my ($fat_remap, $entry) = @_;
+ my ($entry) = @_;
is_special_entry($entry) and return;
my $cluster = get_cluster($entry);
- my $new_cluster = $fat_remap->[$cluster];
+ my $new_cluster = resize_fat::c_rewritten::fat_remap($cluster);
#-print "remapping cluster ", get_first_cluster($fs, $entry), " to $new_cluster";
diff --git a/perl-install/resize_fat/directory.pm b/perl-install/resize_fat/directory.pm
index f62203e50..22d2a1fae 100644
--- a/perl-install/resize_fat/directory.pm
+++ b/perl-install/resize_fat/directory.pm
@@ -32,8 +32,8 @@ sub entry_size { $psizeof_format }
#- call `f' for each entry of the directory
#- if f return true, then modification in the entry are taken back
-sub traverse($$$) {
- my ($fs, $directory, $f) = @_;
+sub traverse($$) {
+ my ($directory, $f) = @_;
for (my $i = 0;; $i++) {
my $raw = \substr($directory, $i * $psizeof_format, $psizeof_format);
@@ -58,7 +58,7 @@ sub traverse_all($$) {
&$f($entry);
resize_fat::dir_entry::is_directory($entry)
- and traverse($fs, resize_fat::io::read_file($fs, resize_fat::dir_entry::get_cluster($entry)), $traverse_all);
+ and traverse(resize_fat::io::read_file($fs, resize_fat::dir_entry::get_cluster($entry)), $traverse_all);
undef; #- no need to write back (cf traverse)
};
@@ -66,14 +66,14 @@ sub traverse_all($$) {
my $directory = $resize_fat::isFAT32 ?
resize_fat::io::read_file($fs, $fs->{fat32_root_dir_cluster}) :
resize_fat::io::read($fs, $fs->{root_dir_offset}, $fs->{root_dir_size});
- traverse($fs, $directory, $traverse_all);
+ traverse($directory, $traverse_all);
+ $traverse_all = undef; #- circular reference is no good for perl's poor GC :(
}
#- function used by construct_dir_tree to translate the `cluster' fields in each
#- directory entry
-sub remap {
+sub remap($$) {
my ($fs, $directory) = @_;
-
- traverse($fs->{fat_remap}, $directory, sub { resize_fat::dir_entry::remap($fs->{fat_remap}, $_[0]) });
+ traverse($directory, \&resize_fat::dir_entry::remap);
}
diff --git a/perl-install/resize_fat/fat.pm b/perl-install/resize_fat/fat.pm
index 67c64165c..83426471a 100644
--- a/perl-install/resize_fat/fat.pm
+++ b/perl-install/resize_fat/fat.pm
@@ -12,17 +12,10 @@ use resize_fat::c_rewritten;
sub read($) {
my ($fs) = @_;
- @{$fs->{fats}} = map {
- my $fat = eval { resize_fat::io::read($fs, $fs->{fat_offset} + $_ * $fs->{fat_size}, $fs->{fat_size}) };
- $@ and die "reading fat #$_ failed";
- vec($fat, 0, 8) == $fs->{media} or die "FAT $_ has invalid signature";
- $fat;
- } (0 .. $fs->{nb_fats} - 1);
-
- $fs->{fat} = $fs->{fats}[0];
+ resize_fat::c_rewritten::read_fat(fileno $fs->{fd}, $fs->{fat_offset}, $fs->{fat_size}, $fs->{media});
@{$fs->{clusters}{count}}{qw(free bad used)} =
- resize_fat::c_rewritten::scan_fat($fs->{fat}, $fs->{nb_clusters}, $fs->{fs_type_size});
+ resize_fat::c_rewritten::scan_fat($fs->{nb_clusters}, $fs->{fs_type_size});
}
sub write($) {
@@ -30,7 +23,7 @@ sub write($) {
sysseek $fs->{fd}, $fs->{fat_offset}, 0 or die "write_fat: seek failed";
foreach (1..$fs->{nb_fats}) {
- syswrite $fs->{fd}, $fs->{fat} or die "write_fat: write failed";
+ resize_fat::c_rewritten::write_fat(fileno $fs->{fd}, $fs->{fat_size});
}
}
@@ -43,7 +36,7 @@ sub write($) {
sub allocate_remap {
my ($fs, $cut_point) = @_;
my ($cluster, $new_cluster);
- my $remap = sub { $fs->{fat_remap}[$cluster] = $new_cluster; };
+ my $remap = sub { resize_fat::c_rewritten::set_fat_remap($cluster, $new_cluster) };
my $get_new = sub {
$new_cluster = get_free($fs);
0 < $new_cluster && $new_cluster < $cut_point or die "no free clusters";
@@ -51,7 +44,8 @@ sub allocate_remap {
#-log::ld("resize_fat: [$cluster,", &next($fs, $cluster), "...]->$new_cluster...");
};
- $fs->{fat_remap}[0] = 0;
+ resize_fat::c_rewritten::allocate_fat_remap($fs->{fat_size});
+
$fs->{last_free_cluster} = 2;
for ($cluster = 2; $cluster < $fs->{nb_clusters} + 2; $cluster++) {
if ($cluster < $cut_point) {
@@ -76,30 +70,19 @@ sub update {
for (my $cluster = 2; $cluster < $fs->{nb_clusters} + 2; $cluster++) {
if (resize_fat::c_rewritten::flag($cluster)) {
my $old_next = &next($fs, $cluster);
- my $new = $fs->{fat_remap}[$cluster];
- my $new_next = $fs->{fat_remap}[$old_next];
+ my $new = resize_fat::c_rewritten::fat_remap($cluster);
+ my $new_next = resize_fat::c_rewritten::fat_remap($old_next);
set_available($fs, $cluster);
is_eof($old_next) ?
set_eof($fs, $new) :
- set_next($fs, $new, $new_next);
+ set_next ($fs, $new, $new_next);
}
}
}
-#- - compares the two FATs (one's a backup that should match) - skips first entry
-#- - its just a signature (already checked above) NOTE: checks for cross-linking
-#- are done in count.c
-sub check($) {
- my ($fs) = @_;
- return;
- foreach (@{$fs->{fats}}) {
- $_ eq $fs->{fats}[0] or die "FAT tables do not match";
- }
-}
-
sub endianness16($) { (($_[0] & 0xff) << 8) + ($_[0] >> 8); }
sub endianness($$) {
my ($val, $nb_bits) = @_;
@@ -113,18 +96,9 @@ sub endianness($$) {
$r;
}
-#-sub next($$) {
-#- my ($fs, $cluster) = @_;
-#- $cluster > $fs->{nb_clusters} + 2 and die "fat::next: cluster $cluster outside filesystem";
-#- endianness(vec($fs->{fat}, $cluster, $fs->{fs_type_size}), $fs->{fs_type_size});
-#-}
*next = \&resize_fat::c_rewritten::next;
+*set_next = \&resize_fat::c_rewritten::set_next;
-sub set_next($$$) {
- my ($fs, $cluster, $new_v) = @_;
- $cluster > $fs->{nb_clusters} + 2 and die "fat::set_next: cluster $cluster outside filesystem";
- vec($fs->{fat}, $cluster, $fs->{fs_type_size}) = endianness($new_v, $fs->{fs_type_size});
-}
sub get_free($) {
@@ -143,7 +117,7 @@ sub is_eof($) {
}
sub set_eof($$) {
my ($fs, $cluster) = @_;
- set_next($fs, $cluster, $resize_fat::bad_cluster_value + 1);
+ set_next ($fs, $cluster, $resize_fat::bad_cluster_value + 1);
}
#- returns true if <cluster> is empty. Note that this includes bad clusters.
@@ -159,5 +133,5 @@ sub is_available($) {
}
sub set_available($$) {
my ($fs, $cluster) = @_;
- set_next($fs, $cluster, 0);
+ set_next ($fs, $cluster, 0);
}
diff --git a/perl-install/resize_fat/io.pm b/perl-install/resize_fat/io.pm
index 8cf21d929..cbe0033ca 100644
--- a/perl-install/resize_fat/io.pm
+++ b/perl-install/resize_fat/io.pm
@@ -10,7 +10,7 @@ use resize_fat::fat;
sub read($$$) {
my ($fs, $pos, $size) = @_;
- my $buf;
+ my $buf = "\0" x $size;
sysseek $fs->{fd}, $pos, 0 or die "seeking to byte #$pos failed on device $fs->{fs_name}";
sysread $fs->{fd}, $buf, $size or die "reading at byte #$pos failed on device $fs->{fs_name}";
$buf;
diff --git a/perl-install/resize_fat/main.pm b/perl-install/resize_fat/main.pm
index 762d18bca..ade04122c 100644
--- a/perl-install/resize_fat/main.pm
+++ b/perl-install/resize_fat/main.pm
@@ -45,12 +45,13 @@ sub new($$$) {
resize_fat::boot_sector::read($fs);
$resize_fat::isFAT32 and eval { resize_fat::info_sector::read($fs) };
resize_fat::fat::read($fs);
- resize_fat::fat::check($fs);
resize_fat::any::flag_clusters($fs);
bless $fs, $type;
}
+sub DESTROY { resize_fat::c_rewritten::free_all() }
+
#- copy all clusters >= <start_cluster> to a new place on the partition, less
#- than <start_cluster>. Only copies files, not directories.
#- (use of buffer needed because the seeks slow like hell the hard drive)
@@ -65,7 +66,9 @@ sub copy_clusters {
};
for (; $cluster < $fs->{nb_clusters} + 2; $cluster++) {
resize_fat::c_rewritten::flag($cluster) == $resize_fat::any::FILE or next;
- push @buffer, $fs->{fat_remap}[$cluster], resize_fat::io::read_cluster($fs, $cluster);
+ push @buffer,
+ resize_fat::c_rewritten::fat_remap($cluster),
+ resize_fat::io::read_cluster($fs, $cluster);
@buffer > 50 and &$flush();
}
&$flush();
@@ -85,8 +88,8 @@ sub construct_dir_tree {
resize_fat::c_rewritten::flag($cluster) == $resize_fat::any::DIRECTORY or next;
resize_fat::io::write_cluster($fs,
- $fs->{fat_remap}[$cluster],
- resize_fat::directory::remap($fs, resize_fat::io::read_cluster($fs, $cluster)));
+ resize_fat::c_rewritten::fat_remap($cluster),
+ resize_fat::directory::remap($fs, resize_fat::io::read_cluster($fs, $cluster)));
}
sync();
@@ -101,7 +104,7 @@ sub construct_dir_tree {
my $cluster = $fs->{fat32_root_dir_cluster};
resize_fat::io::write_cluster($fs,
- $fs->{fat_remap}[$cluster],
+ resize_fat::c_rewritten::fat_remap($cluster),
resize_fat::directory::remap($fs, resize_fat::io::read_cluster($fs, $cluster)));
} else {
resize_fat::io::write($fs, $fs->{root_dir_offset}, $fs->{root_dir_size},