Introduced burn_drive_enumerator_t to allow more complete sg-freebsd implementation
This commit is contained in:
parent
1bda5fe4fa
commit
980e573b9f
@ -1 +1 @@
|
||||
#define Cdrskin_timestamP "2006.10.13.114554"
|
||||
#define Cdrskin_timestamP "2006.10.14.105224"
|
||||
|
@ -831,16 +831,17 @@ int burn_drive_resolve_link(char *path, char adr[], int *recursion_count)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* ts A60922 ticket 33 */
|
||||
/* ts A60922 - A61014 ticket 33 */
|
||||
/* Try to find an enumerated address with the given stat.st_rdev number */
|
||||
int burn_drive_find_devno(dev_t devno, char adr[])
|
||||
{
|
||||
char fname[4096], msg[4096+100];
|
||||
int i, ret = 0, first = 1;
|
||||
int ret = 0, first = 1;
|
||||
struct stat stbuf;
|
||||
burn_drive_enumerator_t enm;
|
||||
|
||||
while (1) {
|
||||
ret= sg_give_next_adr(&i, fname, sizeof(fname), first);
|
||||
ret = sg_give_next_adr(&enm, fname, sizeof(fname), first);
|
||||
if(ret <= 0)
|
||||
break;
|
||||
first = 0;
|
||||
@ -856,9 +857,13 @@ int burn_drive_find_devno(dev_t devno, char adr[])
|
||||
(long) devno, fname);
|
||||
burn_drive_adr_debug_msg(msg, NULL);
|
||||
strcpy(adr, fname);
|
||||
return 1;
|
||||
{ ret = 1; goto ex;}
|
||||
}
|
||||
return 0;
|
||||
ret = 0;
|
||||
ex:;
|
||||
if (first == 0)
|
||||
sg_give_next_adr(&enm, fname, sizeof(fname), -1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* ts A60923 */
|
||||
@ -904,16 +909,16 @@ int burn_drive_convert_scsi_adr(int bus_no, int host_no, int channel_no,
|
||||
int target_no, int lun_no, char adr[])
|
||||
{
|
||||
char fname[4096],msg[4096+100];
|
||||
int i, ret = 0, first = 1, i_bus_no = -1;
|
||||
int ret = 0, first = 1, i_bus_no = -1;
|
||||
int i_host_no = -1, i_channel_no = -1, i_target_no = -1, i_lun_no = -1;
|
||||
|
||||
burn_drive_enumerator_t enm;
|
||||
|
||||
sprintf(msg,"burn_drive_convert_scsi_adr( %d,%d,%d,%d,%d )",
|
||||
bus_no, host_no, channel_no, target_no, lun_no);
|
||||
burn_drive_adr_debug_msg(msg, NULL);
|
||||
|
||||
while (1) {
|
||||
ret= sg_give_next_adr(&i, fname, sizeof(fname), first);
|
||||
ret= sg_give_next_adr(&enm, fname, sizeof(fname), first);
|
||||
if(ret <= 0)
|
||||
break;
|
||||
first = 0;
|
||||
@ -932,13 +937,17 @@ int burn_drive_convert_scsi_adr(int bus_no, int host_no, int channel_no,
|
||||
if(lun_no >= 0 && i_lun_no != lun_no)
|
||||
continue;
|
||||
if(strlen(fname) >= BURN_DRIVE_ADR_LEN)
|
||||
return -1;
|
||||
{ ret = -1; goto ex;}
|
||||
burn_drive_adr_debug_msg(
|
||||
"burn_drive_convert_scsi_adr() found %s", fname);
|
||||
strcpy(adr, fname);
|
||||
return 1;
|
||||
{ ret = 1; goto ex;}
|
||||
}
|
||||
return 0;
|
||||
ret = 0;
|
||||
ex:;
|
||||
if (first == 0)
|
||||
sg_give_next_adr(&enm, fname, sizeof(fname), -1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* ts A60922 ticket 33 */
|
||||
|
@ -47,7 +47,18 @@ extern int burn_sg_open_abort_busy;
|
||||
<<< debug: for tracing calls which might use open drive fds */
|
||||
int mmc_function_spy(char * text);
|
||||
|
||||
int sg_give_next_adr(int *idx, char adr[], int adr_size, int initialize)
|
||||
/** Returns the next index number and the next enumerated drive address.
|
||||
@param idx An opaque handle. Make no own theories about it.
|
||||
@param adr Takes the reply
|
||||
@param adr_size Gives maximum size of reply including final 0
|
||||
@param initialize 1 = start new,
|
||||
0 = continue, use no other values for now
|
||||
-1 = finish
|
||||
@return 1 = reply is a valid address , 0 = no further address available
|
||||
-1 = severe error (e.g. adr_size too small)
|
||||
*/
|
||||
int sg_give_next_adr(burn_drive_enumerator_t *idx,
|
||||
char adr[], int adr_size, int initialize)
|
||||
{
|
||||
|
||||
return (0);
|
||||
|
@ -121,18 +121,25 @@ int sg_handle_busy_device(char *fname, int os_errno)
|
||||
|
||||
/* ts A60922 ticket 33 */
|
||||
/** Returns the next index number and the next enumerated drive address.
|
||||
@param idx An opaque number handle. Make no own theories about it.
|
||||
@param idx An opaque handle. Make no own theories about it.
|
||||
@param adr Takes the reply
|
||||
@param adr_size Gives maximum size of reply including final 0
|
||||
@param initialize 1 = start new, 0 = continue, use no other values for now
|
||||
@param initialize 1 = start new,
|
||||
0 = continue, use no other values for now
|
||||
-1 = finish
|
||||
@return 1 = reply is a valid address , 0 = no further address available
|
||||
-1 = severe error (e.g. adr_size too small)
|
||||
*/
|
||||
int sg_give_next_adr(int *idx, char adr[], int adr_size, int initialize)
|
||||
int sg_give_next_adr(burn_drive_enumerator_t *idx,
|
||||
char adr[], int adr_size, int initialize)
|
||||
{
|
||||
/* sg.h : typedef int burn_drive_enumerator_t; */
|
||||
static int sg_limit = 32, ata_limit = 26;
|
||||
int baseno = 0;
|
||||
|
||||
if (initialize == -1)
|
||||
return 0;
|
||||
|
||||
if (initialize == 1)
|
||||
*idx = -1;
|
||||
(*idx)++;
|
||||
|
@ -3,6 +3,28 @@
|
||||
#ifndef __SG
|
||||
#define __SG
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
|
||||
/* >>> To hold all state information of BSD device enumeration
|
||||
which are now local in sg_enumerate() . So that sg_give_next_adr()
|
||||
can work in BSD and sg_enumerate() can use it. */
|
||||
struct burn_drive_enumeration_state {
|
||||
int dummy;
|
||||
};
|
||||
typedef struct burn_drive_enumeration_state burn_drive_enumerator_t;
|
||||
|
||||
#else /* __FreeBSD__ */
|
||||
|
||||
/* <<< just for testing the C syntax */
|
||||
struct burn_drive_enumeration_state {
|
||||
int dummy;
|
||||
};
|
||||
typedef struct burn_drive_enumeration_state burn_drive_enumerator_tX;
|
||||
|
||||
typedef int burn_drive_enumerator_t;
|
||||
|
||||
#endif /* ! __FreeBSD__ */
|
||||
|
||||
struct burn_drive;
|
||||
struct command;
|
||||
|
||||
@ -13,7 +35,8 @@ enum response
|
||||
int sg_close_drive_fd(char *fname, int driveno, int *fd, int sorry);
|
||||
|
||||
/* ts A60922 ticket 33 */
|
||||
int sg_give_next_adr(int *idx, char adr[], int adr_size, int initialize);
|
||||
int sg_give_next_adr(burn_drive_enumerator_t *enm_context,
|
||||
char adr[], int adr_size, int initialize);
|
||||
int sg_is_enumerable_adr(char *adr);
|
||||
int sg_obtain_scsi_adr(char *path, int *bus_no, int *host_no, int *channel_no,
|
||||
int *target_no, int *lun_no);
|
||||
@ -32,4 +55,5 @@ int sg_release(struct burn_drive *);
|
||||
int sg_issue_command(struct burn_drive *, struct command *);
|
||||
enum response scsi_error(struct burn_drive *, unsigned char *, int);
|
||||
|
||||
|
||||
#endif /* __SG */
|
||||
|
Loading…
Reference in New Issue
Block a user