sfdisk buffer overflow failure under FC4

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I am hoping I can get some help. I had created a simple series of scripts to do backups to USB hard drives under a 2.5 kernel. Since moving to FC4 the recognition of the USB drivces is much more robust, but one important part fails. The users doing the backups are not sys admins and need some help partioning and creating file systems. I created a very simple script to automate this. Unfortunately the key element, the sfdisk command, does not work under FC4.

I have tried the command from a shell prompt and I get the same error. I can use sfdisk to interogate the disk but I can not use it to create the partition it always fails. below is an example of the error message I get.

Disk /dev/sda doesn't contain a valid partition table
Disk is not partitioned. Running sfdisk Checking that no-one is using this disk right now ...
OK

sfdisk: ERROR: sector 0 does not have an msdos signature
/dev/sda: unrecognized partition table type
No partitions found
*** buffer overflow detected ***: sfdisk terminated
======= Backtrace: =========
/lib/libc.so.6(__chk_fail+0x41)[0x2e4565]
sfdisk[0x804c563]
sfdisk[0x804d805]
sfdisk[0x804eaba]
/lib/libc.so.6(__libc_start_main+0xc6)[0x21ade6]
sfdisk[0x8048dc1]
======= Memory map: ========
001e8000-00202000 r-xp 00000000 fd:00 7275549    /lib/ld-2.3.5.so
00202000-00203000 r-xp 00019000 fd:00 7275549    /lib/ld-2.3.5.so
00203000-00204000 rwxp 0001a000 fd:00 7275549    /lib/ld-2.3.5.so
00206000-0032a000 r-xp 00000000 fd:00 7275550    /lib/libc-2.3.5.so
0032a000-0032c000 r-xp 00124000 fd:00 7275550    /lib/libc-2.3.5.so
0032c000-0032e000 rwxp 00126000 fd:00 7275550    /lib/libc-2.3.5.so
0032e000-00330000 rwxp 0032e000 00:00 0
00cfd000-00d06000 r-xp 00000000 fd:00 7275557 /lib/libgcc_s-4.0.0-20050520.so.1 00d06000-00d07000 rwxp 00009000 fd:00 7275557 /lib/libgcc_s-4.0.0-20050520.so.1
00ffb000-00ffc000 r-xp 00ffb000 00:00 0
08048000-08053000 r-xp 00000000 fd:00 19824820   /sbin/sfdisk
08053000-08054000 rw-p 0000b000 fd:00 19824820   /sbin/sfdisk
08054000-0805e000 rw-p 08054000 00:00 0
08432000-08453000 rw-p 08432000 00:00 0          [heap]
b7d21000-b7d22000 rw-p b7d21000 00:00 0
b7d22000-b7f22000 r--p 00000000 fd:00 461728 /usr/lib/locale/locale-archive
b7f22000-b7f23000 rw-p b7f22000 00:00 0
b7f2c000-b7f2d000 rw-p b7f2c000 00:00 0
bfc17000-bfc2d000 rw-p bfc17000 00:00 0          [stack]
sh: line 1: 31164 Aborted                 sfdisk /dev/sda </tmp/partition
device is /dev/sda1


Are there any alternatives to sfdisk?

Thanks for any help I receive

Hugh
,14946,L,,,,;
#!/usr/bin/perl

# setting following because I think it will solve my buffering problem
$| = 1;

$sd_mount=`df -k | grep "^/dev/sd" | awk -f /usr/local/bin/device_parse`;
@mount_array=split(',',$sd_mount);

$usb_avail=`fdisk -l 2>/dev/null | grep "^/dev/sd" | awk -f /usr/local/bin/device_parse`;
$new_usb_avail=`fdisk -l 2>/dev/null | grep "/dev/sd" | awk -f /usr/local/bin/fdisk_device_parse`;

if ( $new_usb_avail =~ "^end" ) {
  print "Done";
  sleep 5;
  exit(0);
}
else {
  @usb_array=split(',',$new_usb_avail);
  
  foreach $usb_dev ( @usb_array ) {
    foreach $disk_mount ( @mount_array ) {
      if ( $disk_mount =~ /$usb_dev/ ) {
        # nothing to do disk is mounted
      }
      else {
        #print "Checking to see if disk is partitioned....";
        $usb_part=`export DISK=$usb_dev; fdisk -l $usb_dev | awk -f /usr/local/bin/fdisk_parse`;
        if ( $usb_part == 0 ) {
          print "Disk is not partitioned. Running sfdisk ";
	  if ( -f "/tmp/partition" ) { `rm /tmp/partition`;}
	  `sfdisk  -l $usb_dev 2>&1 | awk -f /usr/local/bin/sfdisk_parse > /tmp/partition`;
          `sfdisk $usb_dev < /tmp/partition`;
	  $usb_file = $usb_dev . "1";
          print "device is $usb_file\n";
	  `mkfs -t ext3 $usb_file`;
	  print "Enter the name for the disk: ";
          $name = <STDIN>;
          chop($name);
          if ( $usb_file =~ /sda1/ ) { 
            `mount /dev/sda1 /mnt/sda1`;
            `chmod 777 /mnt/sda1`;
            `touch /mnt/sda1/$name`;
            `umount /mnt/sda1`;
          }
          if ( $usb_file =~ /sdb1/ ) { 
            `mount /dev/sdb1 /mnt/sdb1`;
            `chmod 777 /mnt/sdb1`;
            `touch /mnt/sdb1/$name`;
            `umount /mnt/sdb1`;
          }
          #print $usb_dev;
	  #`fdisk $usb_dev`;
          exit(0);
        }
      }
    }
  }
}
  
print "Done";

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux