ROOTDEST = /export DEST = $(ROOTDEST)/Mandrake/mdkinst RPMS = $(wildcard $(ROOTDEST)/Mandrake/RPMS/*.rpm) DIRS = ddcprobe serial_probe aewm-drakx BASE = $(ROOTDEST)/Mandrake/base CFLAGS = -Wall ARCH := $(shell arch | egrep "(x86_64|sparc64|s390x)") ifneq ("x$(ARCH)", "x") LIB_NAME = lib64 else LIB_NAME = lib endif .PHONY: clean install $(DIRS) all: $(DIRS) xhost+ rpcinfo-flushed install $(DIRS): make -C $@ install: @install -d $(ROOTDEST)/misc/auto @install make_mdkinst_stage2 $(ROOTDEST)/misc @cd /usr/bin ; install packdrake $(ROOTDEST)/misc || { echo "packdrake is missing"; exit 1; } @cd /usr/bin ; install gendistrib rpm2header $(ROOTDEST)/misc || { echo "install rpmtools first!" ; exit 1; } @eval `perl -V:installvendorlib`; cd $$installvendorlib ; cp -rf packdrake.pm $(ROOTDEST)/misc || { echo "install rpmtools first!" ; exit 1; } @eval `perl -V:installvendorarch`; cd $$installvendorarch ; cp -rf URPM* $(ROOTDEST)/misc || { echo "install perl-URPM first!" ; exit 1; } @eval `perl -V:installvendorarch`; cd $$installvendorarch/auto ; cp -rf URPM $(ROOTDEST)/misc/auto || { echo "install perl-URPM first!" ; exit 1; } @mkdir -p $(DEST)/usr/bin xhost+: %: %.c $(CC) $(CFLAGS) $< -L/usr/X11R6/$(LIB_NAME) -lX11 -o $@ ddcprobe/ddcxinfos: $(MAKE) -C ddcprobe ddcxinfos clean: for i in $(DIRS); do $(MAKE) -C $$i clean; done rm -rf *~ xhost+ rpcinfo-flushed ddcprobe/ddcxinfos */*.o value='distro/mes6'>distro/mes6 Mageia Installer and base platform for many utilitiesThierry Vignaud [tv]
summaryrefslogtreecommitdiffstats
path: root/perl-install/resize_fat/io.pm
blob: cbe0033ca61e59f9b572a15826bfc5f42ebe316b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package resize_fat::io;

use diagnostics;
use strict;

use resize_fat::fat;

1;


sub read($$$) {
    my ($fs, $pos, $size) = @_;
    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;
}
sub write($$$$) {
    my ($fs, $pos, $size, $buf) = @_;
    sysseek $fs->{fd}, $pos, 0 or die "seeking to byte #$pos failed on device $fs->{fs_name}";
    syswrite $fs->{fd}, $buf or die "writing at byte #$pos failed on device $fs->{fs_name}";
}

sub read_cluster($$) {
    my ($fs, $cluster) = @_;
    my $buf;

    eval {
	$buf = &read($fs,
		     $fs->{cluster_offset} + $cluster * $fs->{cluster_size},
		     $fs->{cluster_size});
    }; @$ and die "reading cluster #$cluster failed on device $fs->{fs_name}";
    $buf;
}
sub write_cluster($$$) {
    my ($fs, $cluster, $buf) = @_;

    eval {
    &write($fs,
	   $fs->{cluster_offset} + $cluster * $fs->{cluster_size},
	   $fs->{cluster_size},
	   $buf);
    }; @$ and die "writing cluster #$cluster failed on device $fs->{fs_name}";
}

sub read_file($$) {
    my ($fs, $cluster) = @_;
    my $buf = '';

    for (; !resize_fat::fat::is_eof($cluster); $cluster = resize_fat::fat::next ($fs, $cluster)) {
	$cluster == 0 and die "Bad FAT: unterminated chain\n";
	$buf .= read_cluster($fs, $cluster);
    }
    $buf;
}

sub check_mounted($) {
    my ($f) = @_;

    local *F;
    open F, "/proc/mounts" or die "error opening /proc/mounts\n";
    foreach (<F>) {
	/^$f\s/ and die "device is mounted";
    }
}

sub open($) {
    my ($fs) = @_;

    check_mounted($fs->{device});

    sysopen F, $fs->{fs_name}, 2 or sysopen F, $fs->{fs_name}, 0 or die "error opening device $fs->{fs_name} for writing\n";
    $fs->{fd} = *F;
}