From 622997696fb4a7bcedee2b81ddcf07598c3d2e52 Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Fri, 18 Jun 2004 05:20:25 +0000 Subject: in disk-iso install, automatically choose and change ISO images, according to their volume id and application id --- perl-install/c/stuff.xs.pl | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'perl-install/c') diff --git a/perl-install/c/stuff.xs.pl b/perl-install/c/stuff.xs.pl index 2097f0efc..c4049eb95 100644 --- a/perl-install/c/stuff.xs.pl +++ b/perl-install/c/stuff.xs.pl @@ -33,6 +33,7 @@ print ' #include #include #include +#include #include #include #include @@ -146,6 +147,12 @@ SV * iconv_(char* s, char* from_charset, char* to_charset) { return newSVpv(retval, 0); } +int length_of_space_padded(char *str, int len) { + while (len >= 0 && str[len-1] == \' \') + --len; + return len; +} + MODULE = c::stuff PACKAGE = c::stuff '; @@ -697,6 +704,27 @@ standard_charset() OUTPUT: RETVAL +void +get_loopback_name(int fd) + INIT: + struct loop_info loopinfo; + PPCODE: + if (!ioctl(fd, LOOP_GET_STATUS, &loopinfo)) + XPUSHs(sv_2mortal(newSVpv(loopinfo.lo_name, 0))); + +void +get_iso_volume_ids(int fd) + INIT: + struct iso_primary_descriptor voldesc; + PPCODE: + lseek(fd, 16 * ISOFS_BLOCK_SIZE, SEEK_SET); + if (read(fd, &voldesc, sizeof(struct iso_primary_descriptor)) == sizeof(struct iso_primary_descriptor)) { + if (voldesc.type[0] == ISO_VD_PRIMARY && !strncmp(voldesc.id, ISO_STANDARD_ID, sizeof(voldesc.id))) { + XPUSHs(sv_2mortal(newSVpv(voldesc.volume_id, length_of_space_padded(voldesc.volume_id, sizeof(voldesc.volume_id))))); + XPUSHs(sv_2mortal(newSVpv(voldesc.application_id, length_of_space_padded(voldesc.application_id, sizeof(voldesc.application_id))))); + } + } + '; $ENV{C_RPM} and print ' -- cgit v1.2.1