]> xenbits.xen.org Git - xenclient/ioemu-pq.git/commitdiff
tidy up atapi passthrough locking code
authorJames Mckenzie <jamesmck@british-chap.cam.xci-test.com>
Sat, 28 Nov 2009 02:59:34 +0000 (02:59 +0000)
committerJames Mckenzie <jamesmck@british-chap.cam.xci-test.com>
Sat, 28 Nov 2009 02:59:34 +0000 (02:59 +0000)
master/do-atapi-locking-properly

index 4cf2a7b6581159c8ee83c9d1d18adfd187a424fe..31e3170e67bdc4ce9099fd7f3c83daf4f4f4e820 100644 (file)
@@ -1,5 +1,5 @@
 diff --git a/hw/atapi-pt.c b/hw/atapi-pt.c
-index 09cf6bb..f0b71ca 100644
+index 09cf6bb..aed333d 100644
 --- a/hw/atapi-pt.c
 +++ b/hw/atapi-pt.c
 @@ -29,7 +29,6 @@ static int debug_enabled=-1;
@@ -24,14 +24,14 @@ index 09cf6bb..f0b71ca 100644
 +
 +static int lock_fd = -1, we_have_lock = 0;
 +
-+int open_lock_file(void) 
++static int open_lock_file(void) 
 +{
 +    lock_fd = open( IDE_ATAPI_PT_EXCLUSIVE_CD_FILE, O_RDWR | O_CREAT, 0666);
 +    return (lock_fd<0) ? 1:0;
 +}
 +
 +
-+int get_atapi_pt_lock_state(void) 
++static int get_atapi_pt_lock_state(void) 
 +{
 +    struct flock lock = {0};
 +
@@ -53,7 +53,7 @@ index 09cf6bb..f0b71ca 100644
 +    return ATAPI_PT_LOCK_STATE_LOCKED_BY_OTHER;
 +}
 +
-+int get_atapi_pt_lock(void) 
++static int get_atapi_pt_lock(void) 
 +{
 +    struct flock lock = {0};
 +
@@ -75,7 +75,7 @@ index 09cf6bb..f0b71ca 100644
 +    return 0;
 +}
 +
-+int release_atapi_pt_lock(void) 
++static int release_atapi_pt_lock(void) 
 +{
 +    struct flock lock = {0};
 +
@@ -136,7 +136,7 @@ index 09cf6bb..f0b71ca 100644
      {
          uint8_t sense[18] = {0x70, 0, 2, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0x3a, 1, 0, 0, 0, 0};
          
-@@ -1118,17 +1194,14 @@ static void ide_atapi_pt_cmd(IDEState *s)
+@@ -1118,17 +1194,17 @@ static void ide_atapi_pt_cmd(IDEState *s)
         cmd_code == GPCMD_WRITE_10 || cmd_code == GPCMD_WRITE_12 || cmd_code == GPCMD_WRITE_AND_VERIFY_10 ||
         cmd_code == GPCMD_WRITE_BUFFER)
      {
@@ -153,10 +153,13 @@ index 09cf6bb..f0b71ca 100644
 -            close(fd);
 +        if(get_atapi_pt_lock()) {
 +            DEBUG_PRINTF("Could not open CD exclusivity lock file for writing\n");
++#if 0 
++          // FIXME XXX - make this throw an error
 +            memcpy(&s->atapi_pt.sense, sense, 18);
 +            ide_atapi_pt_set_error(s, sense[2], sense[12], sense[13], 0x70);
 +            pthread_mutex_unlock(&s->atapi_pt.sgio_mutex);
 +          return;
++#endif
          }
      }