diff options
Diffstat (limited to 'perl-install/c/stuff.xs.pl')
| -rwxr-xr-x[-rw-r--r--] | perl-install/c/stuff.xs.pl | 675 |
1 files changed, 358 insertions, 317 deletions
diff --git a/perl-install/c/stuff.xs.pl b/perl-install/c/stuff.xs.pl index ec4b72569..1a148b497 100644..100755 --- a/perl-install/c/stuff.xs.pl +++ b/perl-install/c/stuff.xs.pl @@ -5,9 +5,6 @@ print ' #include "perl.h" #include "XSUB.h" -/* workaround for glibc and kernel header files not in sync */ -#define dev_t dev_t - #include <ctype.h> #include <stdlib.h> #include <stdio.h> @@ -24,6 +21,7 @@ print ' #include <sys/utsname.h> #include <sys/mount.h> #undef __USE_MISC +#include <linux/if.h> #include <linux/wireless.h> #include <linux/keyboard.h> #include <linux/kd.h> @@ -38,18 +36,9 @@ print ' #include <net/route.h> #include <netinet/in.h> #include <linux/sockios.h> - -// for ethtool structs: -typedef unsigned long long u64; -typedef __uint32_t u32; -typedef __uint16_t u16; -typedef __uint8_t u8; - #include <linux/ethtool.h> - -/* for is_ext3 */ -#include <ext2fs/ext2_fs.h> -#include <ext2fs/ext2fs.h> +#include <linux/input.h> +#include <execinfo.h> // for UPS on USB: # define HID_MAX_USAGES 1024 @@ -57,20 +46,11 @@ typedef __uint8_t u8; #include <libldetect.h> -#include <langinfo.h> #include <string.h> -#include <iconv.h> - -#include <libintl.h> #define SECTORSIZE 512 -char *prom_getopt(); -void prom_setopt(); -char *prom_getproperty(); -char *disk2PromPath(); -char *promRootName(); - +#include <parted/parted.h> '; $Config{archname} =~ /i.86/ and print ' @@ -78,25 +58,8 @@ char *pcmcia_probe(void); '; print ' -#undef Fflush -#undef Mkdir -#undef Stat -#include <rpm/rpmlib.h> -#include <rpm/rpmio.h> - -void rpmError_callback_empty(void) {} - -int rpmError_callback_data; -void rpmError_callback(void) { - if (rpmErrorCode() != RPMERR_UNLINK && rpmErrorCode() != RPMERR_RMDIR) { - write(rpmError_callback_data, rpmErrorString(), strlen(rpmErrorString())); - } -} - -'; - -print ' +/* log_message and log_perror are used in stage1 pcmcia probe */ void log_message(const char * s, ...) { va_list args; va_list args_copy; @@ -121,39 +84,58 @@ void log_message(const char * s, ...) { fclose(logtty); va_end(args_copy); } +void log_perror(const char *msg) { + log_message("%s: %s", msg, strerror(errno)); +} + +HV* common_pciusb_hash_init(struct pciusb_entry *e) { + HV *rh = (HV *)sv_2mortal((SV *)newHV()); + hv_store(rh, "vendor", 6, newSViv(e->vendor), 0); + hv_store(rh, "subvendor", 9, newSViv(e->subvendor), 0); + hv_store(rh, "id", 2, newSViv(e->device), 0); + hv_store(rh, "subid", 5, newSViv(e->subdevice), 0); + hv_store(rh, "driver", 6, newSVpv(e->module ? e->module : "unknown", 0), 0); + hv_store(rh, "description", 11, newSVpv(e->text, 0), 0); + hv_store(rh, "pci_bus", 7, newSViv(e->pci_bus), 0); + hv_store(rh, "pci_device", 10, newSViv(e->pci_device), 0); + return rh; +} '; print ' -SV * iconv_(char* s, char* from_charset, char* to_charset) { - iconv_t cd = iconv_open(to_charset, from_charset); - char* retval = s; - if (cd != (iconv_t) (-1)) { - size_t s_len = strlen(retval); - /* the maximum expansion when converting happens when converting - tscii to utf-8; each tscii char can become up to 4 unicode chars - and each one of those unicode chars can be 3 bytes long */ - char *buf = alloca(4 * 3 * s_len); - { - char *ptr = buf; - size_t ptr_len = 4 * 3 * s_len; - if ((iconv(cd, &s, &s_len, &ptr, &ptr_len)) != (size_t) (-1)) { - *ptr = 0; - retval = buf; - } - } - iconv_close(cd); - } - return newSVpv(retval, 0); -} - int length_of_space_padded(char *str, int len) { while (len >= 0 && str[len-1] == \' \') --len; return len; } +PedPartitionFlag string_to_pedpartflag(char*type) { + PedPartitionFlag flag = 0; + if (!strcmp(type, "ESP")) { + flag = PED_PARTITION_ESP; + } else if (!strcmp(type, "BIOS_GRUB")) { + flag = PED_PARTITION_BIOS_GRUB; + } else if (!strcmp(type, "LVM")) { + flag = PED_PARTITION_LVM; + } else if (!strcmp(type, "RAID")) { + flag = PED_PARTITION_RAID; + } else { + printf("set_partition_flag: unknown type: %s\n", type); + } + return flag; +} + +int is_recovery_partition(PedPartition*part) { + /* FIXME: not sure everything is covered ... */ + return ped_partition_get_flag(part, PED_PARTITION_HPSERVICE) // HP-UX service partition + || ped_partition_get_flag(part, PED_PARTITION_MSFT_RESERVED) // Microsoft Reserved Partition -> LDM metadata, ... + || ped_partition_get_flag(part, PED_PARTITION_DIAG) // ==> PARTITION_MSFT_RECOVERY (Windows Recovery Environment) + || ped_partition_get_flag(part, PED_PARTITION_APPLE_TV_RECOVERY) + || ped_partition_get_flag(part, PED_PARTITION_HIDDEN); +} + MODULE = c::stuff PACKAGE = c::stuff '; @@ -164,11 +146,6 @@ pcmcia_probe() '; print ' -char * -dgettext(domainname, msgid) - char * domainname - char * msgid - int del_partition(hd, part_number) int hd @@ -212,60 +189,21 @@ is_secure_file(filename) OUTPUT: RETVAL -int -is_ext3(device_name) - char * device_name - CODE: - { - ext2_filsys fs; - int retval = ext2fs_open (device_name, 0, 0, 0, unix_io_manager, &fs); - if (retval) { - RETVAL = 0; - } else { - RETVAL = fs->super->s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL; - ext2fs_close(fs); - } - } - OUTPUT: - RETVAL - -char * -get_ext2_label(device_name) - char * device_name - CODE: - { - ext2_filsys fs; - int retval = ext2fs_open (device_name, 0, 0, 0, unix_io_manager, &fs); - if (retval) { - RETVAL = 0; - } else { - RETVAL = fs->super->s_volume_name; - ext2fs_close(fs); - } - } - OUTPUT: - RETVAL - void -setlocale() +init_setlocale() CODE: setlocale(LC_ALL, ""); setlocale(LC_NUMERIC, "C"); /* otherwise eval "1.5" returns 1 in fr_FR for example */ char * -bindtextdomain(domainname, dirname) - char * domainname - char * dirname - -char * -bind_textdomain_codeset(domainname, codeset) - char * domainname - char * codeset +setlocale(category, locale = NULL) + int category + char * locale int lseek_sector(fd, sector, offset) int fd - long sector + unsigned long sector long offset CODE: RETVAL = lseek64(fd, (off64_t) sector * SECTORSIZE + offset, SEEK_SET) >= 0; @@ -306,32 +244,15 @@ floppy_info(name) OUTPUT: RETVAL -unsigned int +NV total_sectors(fd) int fd CODE: { - long s; - RETVAL = ioctl(fd, BLKGETSIZE, &s) == 0 ? s : 0; - } - OUTPUT: - RETVAL - -void -unlimit_core() - CODE: - { - struct rlimit rlim = { RLIM_INFINITY, RLIM_INFINITY }; - setrlimit(RLIMIT_CORE, &rlim); - } - -int -getlimit_core() - CODE: - { - struct rlimit rlim; - getrlimit(RLIMIT_CORE, &rlim); - RETVAL = rlim.rlim_cur; + unsigned long long ll; + unsigned long l; + RETVAL = ioctl(fd, BLKGETSIZE64, &ll) == 0 ? ll / 512 : + ioctl(fd, BLKGETSIZE, &l) == 0 ? l : 0; } OUTPUT: RETVAL @@ -350,7 +271,7 @@ syslog(priority, mesg) int priority char *mesg CODE: - syslog(priority, mesg); + syslog(priority, "%s", mesg); void setsid() @@ -363,26 +284,43 @@ void usleep(microseconds) unsigned long microseconds -int -detectSMP() -int -dmiDetectMemory() +char* +get_pci_description(int vendor_id,int device_id) + +void +hid_probe() + PPCODE: + struct hid_entries entries = hid_probe(); + int i; + + EXTEND(SP, entries.nb); + for (i = 0; i < entries.nb; i++) { + struct hid_entry *e = &entries.entries[i]; + HV *rh = (HV *)sv_2mortal((SV *)newHV()); + hv_store(rh, "description", 11, newSVpv(e->text, 0), 0); + hv_store(rh, "driver", 6, newSVpv(e->module, 0), 0); + PUSHs(newRV((SV *)rh)); + } + hid_entries_free(&entries); void pci_probe() PPCODE: struct pciusb_entries entries = pci_probe(); - char buf[2048]; int i; EXTEND(SP, entries.nb); for (i = 0; i < entries.nb; i++) { struct pciusb_entry *e = &entries.entries[i]; - snprintf(buf, sizeof(buf), "%04x\t%04x\t%04x\t%04x\t%d\t%d\t%d\t%s\t%s\t%s", - e->vendor, e->device, e->subvendor, e->subdevice, e->pci_bus, e->pci_device, e->pci_function, - pci_class2text(e->class_), e->module ? e->module : "unknown", e->text); - PUSHs(sv_2mortal(newSVpv(buf, 0))); + HV * rh = common_pciusb_hash_init(e); + hv_store(rh, "pci_domain", 10, newSViv(e->pci_domain), 0); + hv_store(rh, "pci_function", 12, newSViv(e->pci_function), 0); + hv_store(rh, "pci_revision", 12, newSViv(e->pci_revision), 0); + hv_store(rh, "is_pciexpress", 13, newSViv(e->is_pciexpress), 0); + hv_store(rh, "nice_media_type", 15, newSVpv(e->class, 0), 0); + hv_store(rh, "media_type", 10, newSVpv(pci_class2text(e->class_id), 0), 0); + PUSHs(newRV((SV *)rh)); } pciusb_free(&entries); @@ -396,10 +334,12 @@ usb_probe() EXTEND(SP, entries.nb); for (i = 0; i < entries.nb; i++) { struct pciusb_entry *e = &entries.entries[i]; - struct usb_class_text class_text = usb_class2text(e->class_); - snprintf(buf, sizeof(buf), "%04x\t%04x\t%s|%s|%s\t%s\t%s\t%d\t%d", - e->vendor, e->device, class_text.usb_class_text, class_text.usb_sub_text, class_text.usb_prot_text, e->module ? e->module : "unknown", e->text, e->pci_bus, e->pci_device); - PUSHs(sv_2mortal(newSVpv(buf, 0))); + struct usb_class_text class_text = usb_class2text(e->class_id); + snprintf(buf, sizeof(buf), "%s|%s|%s", class_text.usb_class_text, class_text.usb_sub_text, class_text.usb_prot_text); + HV * rh = common_pciusb_hash_init(e); + hv_store(rh, "usb_port", 8, newSViv(e->usb_port), 0); + hv_store(rh, "media_type", 10, newSVpv(buf, 0), 0); + PUSHs(newRV((SV *)rh)); } pciusb_free(&entries); @@ -410,14 +350,14 @@ dmi_probe() //dmidecode_file = "../../soft/ldetect-lst/test/dmidecode.Laptop.Sony-Vaio-GRX316MP"; struct dmi_entries entries = dmi_probe(); - char buf[2048]; int i; EXTEND(SP, entries.nb); for (i = 0; i < entries.nb; i++) { - snprintf(buf, sizeof(buf), "%s\t%s", - entries.entries[i].module, entries.entries[i].constraints); - PUSHs(sv_2mortal(newSVpv(buf, 0))); + HV * rh = (HV *)sv_2mortal((SV *)newHV()); + hv_store(rh, "driver", 6, newSVpv(entries.entries[i].module, 0), 0); + hv_store(rh, "description", 11, newSVpv(entries.entries[i].constraints, 0), 0); + PUSHs(newRV((SV *)rh)); } dmi_entries_free(entries); @@ -438,22 +378,8 @@ get_usb_ups_name(int fd) RETVAL - int -hasNetDevice(device) - char * device - CODE: - struct ifreq req; - int s = socket(AF_INET, SOCK_DGRAM, 0); - if (s == -1) { RETVAL = 0; return; } - - strncpy(req.ifr_name, device, IFNAMSIZ); - - RETVAL = ioctl(s, SIOCGIFFLAGS, &req) == 0; - close(s); - OUTPUT: - RETVAL - +res_init() int isNetDeviceWirelessAware(device) @@ -471,25 +397,6 @@ isNetDeviceWirelessAware(device) RETVAL -int enable_net_device(device) - char * device - CODE: - struct ifreq ifr; - int err; - int s = socket(AF_INET, SOCK_DGRAM, 0); - - strncpy(ifr.ifr_name, device, IFNAMSIZ); - err = ioctl(s, SIOCGIFFLAGS, &ifr); - if (!err && !(ifr.ifr_flags & IFF_UP)) { - ifr.ifr_flags |= IFF_UP; - err = ioctl(s, SIOCSIFFLAGS, &ifr); - } - if (err) - perror("SIOCSIFFLAGS"); - RETVAL = err; - OUTPUT: - RETVAL - void get_netdevices() PPCODE: @@ -507,6 +414,7 @@ get_netdevices() if (ioctl(s, SIOCGIFCONF, &ifc) < 0) { perror("SIOCGIFCONF"); + close(s); return; } if (ifc.ifc_len == sizeof(struct ifreq) * numreqs) { @@ -553,6 +461,7 @@ getNetDriver(char* device) break; } } else { perror("SIOCETHTOOL"); RETVAL = strdup(""); } + close(s); OUTPUT: RETVAL @@ -604,13 +513,69 @@ get_hw_address(const char* ifname) RETVAL = NULL; return; } - a = ifr.ifr_hwaddr.sa_data; + a = (unsigned char*)ifr.ifr_hwaddr.sa_data; asprintf(&res, "%02x:%02x:%02x:%02x:%02x:%02x", a[0],a[1],a[2],a[3],a[4],a[5]); RETVAL= res; OUTPUT: RETVAL +void +strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1) + char * fmt + int sec + int min + int hour + int mday + int mon + int year + int wday + int yday + int isdst + CODE: + { + char *buf = my_strftime(fmt, sec, min, hour, mday, mon, year, wday, yday, isdst); + if (buf) { + ST(0) = sv_2mortal(newSVpv(buf, 0)); + Safefree(buf); + } + } + +#define BITS_PER_LONG (sizeof(long) * 8) +#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1) +#define OFF(x) ((x)%BITS_PER_LONG) +#define BIT(x) (1UL<<OFF(x)) +#define LONG(x) ((x)/BITS_PER_LONG) +#define test_bit(bit, array) ((array[LONG(bit)] >> OFF(bit)) & 1) + +void +EVIocGBitKey (char *file) + PPCODE: + int fd; + int i; + long bitmask[NBITS(KEY_MAX)]; + + fd = open (file, O_RDONLY); + if (fd < 0) { + warn("Cannot open %s: %s\n", file, strerror(errno)); + return; + } + + if (ioctl (fd, EVIOCGBIT(EV_KEY, sizeof (bitmask)), bitmask) < 0) { + perror ("ioctl EVIOCGBIT failed"); + close (fd); + return; + } + + close (fd); + for (i = NBITS(KEY_MAX) - 1; i > 0; i--) + if (bitmask[i]) + break; + + for (; i >= 0; i--) { + EXTEND(sp, 1); + PUSHs(sv_2mortal(newSViv(bitmask[i]))); + } char * kernel_version() @@ -620,173 +585,250 @@ kernel_version() OUTPUT: RETVAL -int -prom_open() +void +set_tagged_utf8(s) + SV *s + CODE: + SvUTF8_on(s); void -prom_close() +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))) { + size_t vol_id_len = length_of_space_padded(voldesc.volume_id, sizeof(voldesc.volume_id)); + size_t app_id_len = length_of_space_padded(voldesc.application_id, sizeof(voldesc.application_id)); + XPUSHs(vol_id_len != -1 ? sv_2mortal(newSVpv(voldesc.volume_id, vol_id_len)) : newSVpvs("")); + XPUSHs(app_id_len != -1 ? sv_2mortal(newSVpv(voldesc.application_id, app_id_len)) : newSVpvs("")); + } + } -int -prom_getsibling(node) - int node +'; -int -prom_getchild(node) - int node +print ' -void -prom_getopt(key) - char *key - PPCODE: - int lenp = 0; - char *value = NULL; - value = prom_getopt(key, &lenp); - EXTEND(sp, 1); - if (value != NULL) { - PUSHs(sv_2mortal(newSVpv(value, 0))); +TYPEMAP: <<HERE +PedDisk* T_PTROBJ +HERE + + + +int +set_partition_flag(PedDisk *disk, int part_number, char * type) + CODE: + RETVAL = 0; + PedPartition* part = ped_disk_get_partition(disk, part_number); + if (!part) { + printf("set_partition_flag: failed to find partition\n"); } else { - PUSHs(&PL_sv_undef); + PedPartitionFlag flag = string_to_pedpartflag(type); + if (flag) { + RETVAL = ped_partition_set_flag(part, flag, 1); + } } + OUTPUT: + RETVAL -void -prom_setopt(key, value) - char *key - char *value -void -prom_getproperty(key) - char *key - PPCODE: - int lenp = 0; - char *value = NULL; - value = prom_getproperty(key, &lenp); - EXTEND(sp, 1); - if (value != NULL) { - PUSHs(sv_2mortal(newSVpv(value, lenp))); - } else { - PUSHs(&PL_sv_undef); +const char * +get_disk_type(char * device_path) + CODE: + PedDevice *dev = ped_device_get(device_path); + RETVAL = NULL; + if(dev) { + PedDiskType* type = ped_disk_probe(dev); + if(type) { + RETVAL = type->name; + } } + OUTPUT: + RETVAL void -prom_getstring(key) - char *key +get_disk_partitions(char * device_path) PPCODE: - int lenp = 0; - char *value = NULL; - value = prom_getproperty(key, &lenp); - EXTEND(sp, 1); - if (value != NULL) { - PUSHs(sv_2mortal(newSVpv(value, 0))); - } else { - PUSHs(&PL_sv_undef); + PedDevice *dev = ped_device_get(device_path); + if(dev) { + PedDisk* disk = ped_disk_new(dev); + PedPartition *part = NULL, *first_part = NULL; + int count = 1; + if(!disk) + return; + first_part = part = ped_disk_next_partition(disk, NULL); + while(part) { + part = ped_disk_next_partition(disk, part); + count++; + } + EXTEND(SP, count); + part = first_part; + while(part) { + if(part->num == -1) { + part = ped_disk_next_partition(disk, part); + continue; + } + char *path = ped_partition_get_path(part); + char *flag = ""; + if (ped_partition_get_flag(part, PED_PARTITION_ESP)) { + flag = "ESP"; + } else if (ped_partition_get_flag(part, PED_PARTITION_BIOS_GRUB)) { + flag = "BIOS_GRUB"; + } else if (ped_partition_get_flag(part, PED_PARTITION_LVM)) { + flag = "LVM"; + } else if (ped_partition_get_flag(part, PED_PARTITION_RAID)) { + flag = "RAID"; + } else if (is_recovery_partition(part)) { + flag = "RECOVERY"; + } + HV * rh = (HV *)sv_2mortal((SV *)newHV()); + hv_store(rh, "part_number", 11, newSViv(part->num), 0); + hv_store(rh, "real_device", 11, newSVpv(path, 0), 0); + hv_store(rh, "start", 5, newSViv(part->geom.start), 0); + hv_store(rh, "size", 4, newSViv(part->geom.length), 0); + hv_store(rh, "pt_type", 7, newSViv(0xba), 0); + hv_store(rh, "flag", 4, newSVpv(flag, 0), 0); + free(path); + if(part->fs_type) + hv_store(rh, "fs_type", 7, newSVpv(part->fs_type->name, 0), 0); + PUSHs(newRV((SV *)rh)); + part = ped_disk_next_partition(disk, part); + } + ped_disk_destroy(disk); } -int -prom_getbool(key) - char *key - -void -initSilo() - -char * -disk2PromPath(disk) - unsigned char *disk +PedDisk* +disk_open(char * device_path, const char * type_name = NULL) + CODE: + PedDevice *dev = ped_device_get(device_path); + RETVAL = NULL; + if(dev) { + if(type_name) { + PedDiskType* type = ped_disk_type_get(type_name); + if(type) { + RETVAL = ped_disk_new_fresh(dev, type); + } + } else { + RETVAL = ped_disk_new(dev); + } + } + OUTPUT: + RETVAL int -hasAliases() - -char * -promRootName() - -void -setPromVars(linuxAlias, bootDevice) - char *linuxAlias - char *bootDevice - -SV * -iconv(s, from_charset, to_charset) - char *s - char *from_charset - char *to_charset +disk_delete_all(PedDisk* disk) CODE: - RETVAL = iconv_(s, from_charset, to_charset); + RETVAL = 0; + if (ped_disk_delete_all(disk)) { + RETVAL = 1; + } OUTPUT: RETVAL int -is_tagged_utf8(s) - SV *s - CODE: - RETVAL = SvUTF8(s); - OUTPUT: - RETVAL - -void -set_tagged_utf8(s) - SV *s - CODE: - SvUTF8_on(s); - -void -upgrade_utf8(s) - SV *s - CODE: - sv_utf8_upgrade(s); - -void -unset_tagged_utf8(s) - SV *s - CODE: - SvUTF8_off(s); +disk_del_partition(PedDisk* disk, int part_number) + CODE: + RETVAL = 0; + PedPartition* part = ped_disk_get_partition(disk, part_number); + if(!part) { + printf("disk_del_partition: failed to find partition\n"); + } else { + RETVAL = ped_disk_delete_partition(disk, part); + } + OUTPUT: + RETVAL -char * -standard_charset() +int +disk_add_partition(PedDisk* disk, double start, double length, const char * fs_type) CODE: - RETVAL = nl_langinfo(CODESET); + RETVAL=0; + PedGeometry* geom = ped_geometry_new(disk->dev, (long long)start, (long long)length); + PedPartition* part = ped_partition_new (disk, PED_PARTITION_NORMAL, ped_file_system_type_get(fs_type), (long long)start, (long long)start+length-1); + PedConstraint* constraint = ped_constraint_new_from_max(geom); + if(!part) { + printf("ped_partition_new failed\n"); + } else { + RETVAL = ped_disk_add_partition (disk, part, constraint); + } + ped_geometry_destroy(geom); + ped_constraint_destroy(constraint); OUTPUT: RETVAL -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))))); +int +disk_commit(PedDisk *disk) + CODE: + RETVAL = 0; + /* As done in ped_disk_commit(), open the device here, so that the underlying + file descriptor is not closed between the call to ped_disk_commit_to_dev() + and the call to ped_disk_commit_to_os(). This avoids unwanted udev events. */ + if (ped_device_open(disk->dev)) { + if (ped_disk_commit_to_dev(disk)) { + RETVAL = 1; + if (ped_disk_commit_to_os(disk)) { + RETVAL = 2; + } } + ped_device_close(disk->dev); } + ped_disk_destroy(disk); + OUTPUT: + RETVAL -'; +int +tell_kernel_to_reread_partition_table(char * device_path) + CODE: + PedDevice *dev = ped_device_get(device_path); + RETVAL=0; + if(dev) { + PedDisk* disk = ped_disk_new(dev); + if (disk) { + if (ped_disk_commit_to_os (disk)) + RETVAL=1; + ped_disk_destroy(disk); + } + } + OUTPUT: + RETVAL -print ' -const char * -rpmErrorString() +#define BACKTRACE_DEPTH 20 + -void -rpmSetVeryVerbose() +char* +C_backtrace() CODE: - rpmSetVerbosity(RPMMESS_DEBUG); + static char buf[1024]; + int nAddresses, i; + unsigned long idx = 0; + void * addresses[BACKTRACE_DEPTH]; + char ** symbols = NULL; + nAddresses = backtrace(addresses, BACKTRACE_DEPTH); + symbols = backtrace_symbols(addresses, nAddresses); + if (symbols == NULL) { + idx += sprintf(buf+idx, "ERROR: Retrieving symbols failed.\n"); + } else { + /* dump stack trace */ + for (i = 0; i < nAddresses; ++i) + idx += sprintf(buf+idx, "%d: %s\n", i, symbols[i]); + } + RETVAL = strdup(buf); + OUTPUT: + RETVAL + + -void -rpmErrorSetCallback(fd) - int fd - CODE: - rpmError_callback_data = fd; - rpmErrorSetCallback(rpmError_callback); -int -rpmvercmp(char *a, char *b); '; @macros = ( - [ qw(int S_IFCHR S_IFBLK S_IFIFO KDSKBENT KT_SPEC K_NOSUCHMAP NR_KEYS MAX_NR_KEYMAPS BLKRRPART TIOCSCTTY - HDIO_GETGEO BLKGETSIZE LOOP_GET_STATUS HIDIOCAPPLICATION - MS_MGC_VAL MS_RDONLY O_NONBLOCK F_SETFL F_GETFL O_CREAT SECTORSIZE WNOHANG - VT_ACTIVATE VT_WAITACTIVE VT_GETSTATE CDROM_LOCKDOOR CDROMEJECT CDROM_DRIVE_STATUS CDS_DISC_OK + [ qw(int S_IFCHR S_IFBLK S_IFIFO S_IFMT KDSKBENT K_NOSUCHMAP NR_KEYS MAX_NR_KEYMAPS BLKRRPART TIOCSCTTY + HDIO_GETGEO LOOP_GET_STATUS + MS_MGC_VAL O_WRONLY O_RDWR O_CREAT O_NONBLOCK F_SETFL F_GETFL WNOHANG + VT_ACTIVATE VT_WAITACTIVE VT_GETSTATE + CDROMEJECT CDROMCLOSETRAY CDROM_LOCKDOOR LOG_WARNING LOG_INFO LOG_LOCAL1 + LC_COLLATE ) ], ); @@ -813,4 +855,3 @@ print ' PROTOTYPES: DISABLE '; - |
