Re: Request for cooperation with all burn backends

2006-10-12 Thread scdbackup
Hi,

> int grab_sg (int blkfd)

Seems to work well for me and my two drives sr0 and sr1.

I threw out two of my three functions and made
try_to_lock_linux_sg() using grab_sg() instead.

The call in builtin_dd() has changed a bit:

if (i == 3 && fd >= 0)
try_to_lock_linux_sg(ioctl_device, fd);


I made a small change in grab_sg() in order to distinguish
a failed locking attempt from failure to get to that attempt.

#include 

int grab_sg (int blkfd)
{
  ...

if (sgfd>=0)
{ 
 ...
}
else if (errno == EBUSY)
sgfd = -2;

  ...
}

void try_to_lock_linux_sg(char *ioctl_device, int ioctl_dev_fd)
{
int fd_sg = -1;

if ( ( ( strncmp (ioctl_device, "/dev/sr", 7) == 0
&& isdigit(ioctl_device[7]) ) ||
   ( strncmp (ioctl_device, "/dev/scd", 8) == 0
&& isdigit(ioctl_device[8]) )
   ) )
fd_sg = grab_sg(ioctl_dev_fd);
if(fd_sg == -2)
fprintf (stderr,":-( unable to O_EXCL sg equivalent of %s: "
"Other burn program active on drive ?\n",
ioctl_device),
exit (FATAL_START(errno));
}

I will now use this variation of growisofs 7.0 for my daily
backups. It will last a few days until i get opportunity
to test it on kernel 2.6 and /dev/hdX.
If my code is as intended then this should not even call
grab_sg(), and of course never abort.

Give me a note as soon as you decided for a final implementation
and i will test as good as i can.


Have a nice day :)

Thomas


PS: About -Z /dev/sr1=imagefile :

My ext3 is ok as source for image files.
My reiserfs is not. ":-( write failed: Invalid argument".
Mangling #ifdef O_DIRECT in growisofs.c enabled burning from
that reiserfs too.
Only good i watch other people's problems on this list. :))


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: Request for cooperation with all burn backends

2006-10-12 Thread Andy Polyakov

Is it really a problem between recording programs?


It is especially a problem between growisofs and libburn
on my 2.4 system.

- growisofs burns of DVD+RW experience data damage in about
25 % of the cases after libburn did a bus scan on the burning drive.

- growisofs burns of DVD-RW stall libburn bus scan as soon as the
active drive is enumerated. Affected growisofs burns have about
50 % probability to be damaged.

...

I can offer a patch of 100 to 150 lines in growisofs.c
to achieve locking of /dev/srN or /dev/scdN via the
corresponding /dev/sgM.

Since i implemented that on my system i am free of trouble 
between growisofs and libburn.

I published the test version (loudly declaring itself as
inofficial hack) on the [EMAIL PROTECTED] mailing list
in the hope of some test results ... then i wanted to approach
you.

No echo. Everybody is on 2.6 already.

See diff -puN at
http://scdbackup.sourceforge.net/dvd+rw-tools-7.0.tsA60930.diff.txt


If "sg scanning" is so intrusive, why are you using at all? Isn't there 
a way to list sg binding, say though ... /proc? And look, there is! It's 
even possible to see what kind each device is and limit search to type 
5, a.k.a. CD-ROM, devices... In either case below is function which will 
appear in next release. Test it. A.




int grab_sg (int blkfd)
{ struct { unsigned int dev_id,host_unique_id; } idlunblk,idlunsg;
  FILE *fp;
  int   host_no,channel,lun,id,type,i,sgfd=-1;
  char  str[128];
  struct stat sb;

if (ioctl (blkfd,SCSI_IOCTL_GET_IDLUN,&idlunblk) < 0) return -1;

if ((fp=fopen ("/proc/scsi/sg/devices","r")) == NULL) return -1;

for (i=0;i>=0;i++)
{   if (fgets (str,sizeof(str),fp) == NULL) break;

if (sscanf (str,"%d\t%d\t%d\t%d\t%d",
&host_no,&channel,&id,&lun,&type) != 5)
continue;

if (idlunblk.dev_id ==  ((id & 0xff) +
((lun & 0xff) << 8) +
((channel & 0xff) << 16) +
((host_no & 0xff) << 24)))
{   sprintf (str,"/dev/sg%d",i);
if (stat (str,&sb) < 0)  break;
errno = ENOENT;
if (minor(sb.st_rdev) != i) break;
sgfd = open (str,O_RDWR|O_NONBLOCK|O_EXCL);
if (sgfd>=0)
{   if (ioctl (sgfd,SCSI_IOCTL_GET_IDLUN,&idlunsg) < 0 ||
idlunblk.dev_id != idlunsg.dev_id ||
idlunblk.host_unique_id != idlunsg.host_unique_id)
close (sgfd), sgfd = -1, errno = ENOENT;
}
break;
}
}
fclose (fp);

  return sgfd;
}


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



FWD: Office closed; No work tomorrow

2006-10-12 Thread Maxwell Stephan
How are you,

Would you like to generate 1.5K to 3.5K daily just for returning calls?
If you have a phone and can return calls you are fully qualified.

Talk with us : 888.712.1138

Regards,
Maxwell Stephan



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]