1 diff -ur lin_tape-2.1.0/lin_tape_scsi_config.c lin_tape-2.1.0-3.10/lin_tape_scsi_config.c
2 --- lin_tape-2.1.0/lin_tape_scsi_config.c 2013-06-12 23:07:31.000000000 +0200
3 +++ lin_tape-2.1.0-3.10/lin_tape_scsi_config.c 2013-08-25 14:24:13.053537972 +0200
6 } /* lin_tape_delete_tsm_pseudo() */
8 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
9 +static int tape_proc_open(struct inode *inode, struct file *file)
11 + return single_open(file, tape_read_proc, PDE_DATA(inode));
14 +static int changer_proc_open(struct inode *inode, struct file *file)
16 + return single_open(file, changer_read_proc, PDE_DATA(inode));
19 +static const struct file_operations tape_proc_fops = {
20 + .open = tape_proc_open,
22 + .llseek = seq_lseek,
23 + .release = single_release,
26 +static const struct file_operations changer_proc_fops = {
27 + .open = changer_proc_open,
29 + .llseek = seq_lseek,
30 + .release = single_release,
33 /*******************************************************************************
35 * NAME: lin_tape_create_proc *
36 @@ -3167,42 +3191,56 @@
37 DbgPrint(("lin_tape: lin_tape_create_proc entry\n"));
39 WRITE_LOCK(&lin_tape_lock);
40 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
41 if(!tape_proc_entry) {
43 create_proc_entry("scsi/IBMtape", 0, NULL);
45 if(!tape_proc_entry) {
46 DbgPrint(("lin_tape: cannot initialize "\
47 "/proc/scsi/IBMtape\n"));
51 tape_proc_entry->read_proc = tape_read_proc;
52 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
53 tape_proc_entry->owner = THIS_MODULE;
54 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
55 tape_proc_entry->get_info = NULL;
59 + if (!proc_create("scsi/IBMtape", 0, NULL, &tape_proc_fops)) {
60 + DbgPrint(("lin_tape: cannot initialize "\
61 + "/proc/scsi/IBMtape\n"));
66 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
67 if(!changer_proc_entry) {
69 create_proc_entry("scsi/IBMchanger", 0, NULL);
71 if(!changer_proc_entry) {
72 DbgPrint(("lin_tape: cannot initialize "\
73 "/proc/scsi/IBMchanger\n"));
77 changer_proc_entry->read_proc = changer_read_proc;
78 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
79 changer_proc_entry->owner = THIS_MODULE;
80 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
81 changer_proc_entry->get_info = NULL;
85 + if (!proc_create("scsi/IBMchanger", 0, NULL, &changer_proc_fops)) {
86 + DbgPrint(("lin_tape: cannot initialize "\
87 + "/proc/scsi/IBMchanger\n"));
93 @@ -3229,15 +3227,20 @@
95 WRITE_LOCK(&lin_tape_lock);
97 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
99 remove_proc_entry("scsi/IBMtape", NULL);
100 tape_proc_entry = NULL;
103 if(changer_proc_entry) {
104 remove_proc_entry("scsi/IBMchanger", NULL);
105 changer_proc_entry = NULL;
108 + remove_proc_entry("scsi/IBMtape", NULL);
109 + remove_proc_entry("scsi/IBMchanger", NULL);
112 WRITE_UNLOCK(&lin_tape_lock);
114 @@ -3262,51 +3253,80 @@
116 *******************************************************************************/
118 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
119 static int tape_read_proc(char* buffer, char** start, off_t offset, int length,
120 int* eof, void* data)
122 +static int tape_read_proc(struct seq_file *m, void* data)
125 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
126 int buf_offset = 0, i = 0, start_dev = 0, found = 0, linelen = 0;
127 unchar* model = NULL, * pre_buf = NULL;
130 + int i = 0, found = 0;
131 + unchar* model = NULL;
134 boolean tape_des_locked = False;
136 DbgPrint(("lin_tape: tape_read_proc entry\n"));
138 model = kmalloc(12, GFP_KERNEL);
139 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
140 pre_buf = kmalloc(ONE_K / 4, GFP_KERNEL);
142 sn = kmalloc(MaxSerialNumberSize + 1, GFP_KERNEL);
143 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
144 if(!model || !pre_buf || !sn || !buffer || !start || !eof) {
145 if(start) *start = buffer;
148 + if(!model || !sn) {
153 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
154 memset(temp_buf, '\0', 96);
156 memset(model, '\0', 12);
157 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
158 memset(pre_buf, '\0', ONE_K / 4);
160 memset(sn, '\0', MaxSerialNumberSize + 1);
164 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
165 if(!offset && rd_pc_initial(buffer, &buf_offset, length, start, False))
168 if(rd_pc_start_dev(&start_dev, eof, offset, buffer, &buf_offset, False))
171 + rd_pc_initial(m, False);
174 READ_LOCK(&tape_des_lock);
175 tape_des_locked = True;
178 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
180 if(buf_offset == length) buf_offset--;
181 buf_offset += sprintf(&buffer[buf_offset], "\n");
187 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
188 for(i = start_dev; i < MaxLinTapeDevices; i++) {
190 + for(i = 0; i < MaxLinTapeDevices; i++) {
192 if(!tape_devs[i] || !tape_devs[i]->dev_obj) continue;
195 @@ -3326,8 +3301,12 @@
196 sn[strlen(sn) - 1] == '\t'))
197 sn[strlen(sn) - 1] = '\0';
199 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
200 linelen = snprintf(pre_buf, ONE_K / 4,
201 "\n%-8d%-12s%-18s%-16s%-16s%-10s",
203 + seq_printf(m, "%-8d%-12s%-18s%-16s",
208 @@ -3335,12 +3309,22 @@
209 tape_devs[i]->serial_num_len ? sn : "NA",
211 tape_devs[i]->ghost_device ? "" :
212 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
213 found ? tape_devs[i]->pname : "NA",
215 + found ? tape_devs[i]->pname : "NA");
218 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
219 tape_devs[i]->ghost_device ? "" :
220 scsi_addr_str(tape_devs[i], temp_buf,
223 + if (!tape_devs[i]->ghost_device)
224 + scsi_addr_str(tape_devs[i], m, False);
226 + seq_printf(m, "%-10s\n",
228 tape_devs[i]->ghost_device ? "" :
230 !tape_devs[i]->serial_num_len ? "NA" :
231 @@ -3349,45 +3323,59 @@
232 tape_devs[i]->isPrimary ? "Primary" :
235 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
236 if(buf_offset > length) {
239 } else if(buf_offset + linelen >= length) {
240 memset(&buffer[buf_offset], ' ', length - buf_offset);
245 buf_offset += sprintf(&buffer[buf_offset], "%s", pre_buf);
247 tape_devs[i]->proc_read = True;
250 tape_des_locked = False;
251 READ_UNLOCK(&tape_des_lock);
253 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
254 if(i == start_dev || i >= MaxLinTapeDevices) {
255 if(buf_offset == length) buf_offset--;
256 buf_offset += sprintf(&buffer[buf_offset], "\n");
258 if(i >= MaxLinTapeDevices) *start = buffer;
267 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
268 if(pre_buf) kfree(pre_buf);
270 if(model) kfree(model);
273 if(tape_des_locked) READ_UNLOCK(&tape_des_lock);
274 tape_des_locked = False;
276 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
277 if(buf_offset == 1 && *eof) buf_offset = 0;
278 DbgPrint(("tape_read_proc exit: %d\n", buf_offset));
280 + DbgPrint(("tape_read_proc exit:\n"));
283 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
288 } /* tape_read_proc() */
290 /*******************************************************************************
291 @@ -3409,12 +3361,21 @@
293 *******************************************************************************/
295 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
296 static int changer_read_proc(char* buffer, char** start, off_t offset,
297 int length, int* eof, void* data)
299 +static int changer_read_proc(struct seq_file *m, void* data)
302 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
303 int buf_offset = 0, i = 0, start_dev = 0, found = 0, linelen = 0;
304 unchar* model = NULL, * pre_buf = NULL;
307 + int i = 0, found = 0;
308 + unchar* model = NULL;
311 boolean changer_des_locked = False;
313 @@ -3423,37 +3373,57 @@
316 model = kmalloc(12, GFP_KERNEL);
317 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
318 pre_buf = kmalloc(ONE_K / 4, GFP_KERNEL);
320 sn = kmalloc(MaxSerialNumberSize + 1, GFP_KERNEL);
321 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
322 if(!model || !pre_buf || !sn || !buffer || !start || !eof) {
323 if(start) *start = buffer;
326 + if(!model || !sn) {
331 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
332 memset(temp_buf, '\0', 96);
334 memset(model, '\0', 12);
335 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
336 memset(pre_buf, '\0', ONE_K / 4);
338 memset(sn, '\0', MaxSerialNumberSize + 1);
340 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
341 if(!offset && rd_pc_initial(buffer, &buf_offset, length, start, True))
344 if(rd_pc_start_dev(&start_dev, eof, offset, buffer, &buf_offset, True))
347 + rd_pc_initial(m, True);
350 READ_LOCK(&changer_des_lock);
351 changer_des_locked = True;
354 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
356 if(buf_offset == length) buf_offset--;
357 buf_offset += sprintf(&buffer[buf_offset], "\n");
363 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
364 for(i = start_dev; i < MaxLinTapeChangerDevices; i++) {
366 + for(i = 0; i < MaxLinTapeChangerDevices; i++) {
368 if(!changer_devs[i] || !changer_devs[i]->dev_obj) continue;
371 @@ -3472,8 +3409,12 @@
372 sn[strlen(sn) - 1] == '\t'))
373 sn[strlen(sn) - 1] = '\0';
375 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
376 linelen = snprintf(pre_buf, ONE_K / 4,
377 "\n%-8d%-12s%-18s%-16s%-16s%-10s",
379 + seq_printf(m, "%-8d%-12s%-18s%-16s",
384 @@ -3481,14 +3417,24 @@
385 changer_devs[i]->serial_num_len ? sn : "NA",
387 changer_devs[i]->ghost_device ? "" :
388 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
389 found ? changer_devs[i]->pname : "NA",
391 + found ? changer_devs[i]->pname : "NA");
394 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
395 changer_devs[i]->ghost_device ? "" :
396 scsi_addr_str((struct tape_descriptor*)
401 + if (!changer_devs[i]->ghost_device)
402 + scsi_addr_str((struct tape_descriptor*)changer_devs[i], m, True);
404 + seq_printf(m, "%-10s\n",
406 changer_devs[i]->ghost_device ? "" :
408 changer_devs[i]->chg_id == IBM_3590
409 @@ -3498,45 +3432,59 @@
410 changer_devs[i]->isPrimary ? "Primary" :
413 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
414 if(buf_offset > length) {
417 } else if(buf_offset + linelen >= length) {
418 memset(&buffer[buf_offset], ' ', length - buf_offset);
423 buf_offset += sprintf(&buffer[buf_offset], "%s", pre_buf);
425 changer_devs[i]->proc_read = True;
428 changer_des_locked = False;
429 READ_UNLOCK(&changer_des_lock);
431 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
432 if(i == start_dev || i >= MaxLinTapeChangerDevices) {
433 if(buf_offset == length) buf_offset--;
434 buf_offset += sprintf(&buffer[buf_offset], "\n");
436 if(i >= MaxLinTapeChangerDevices) *start = buffer;
445 if(model) kfree(model);
446 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
447 if(pre_buf) kfree(pre_buf);
451 if(changer_des_locked) READ_UNLOCK(&changer_des_lock);
452 changer_des_locked = False;
454 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
455 if(buf_offset == 1 && *eof) buf_offset = 0;
456 DbgPrint(("changer_read_proc exit: %d\n", buf_offset));
458 + DbgPrint(("changer_read_proc exit\n"));
461 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
466 } /* changer_read_proc() */
468 /*******************************************************************************
469 @@ -3557,15 +3469,25 @@
471 *******************************************************************************/
473 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
474 int rd_pc_initial(char* buffer, int* buf_offset, int length, char** start,
477 +int rd_pc_initial(struct seq_file *m, boolean chg)
480 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
481 int rc = 1, count = 0, i = 0, max_devices = 0;
484 + int i = 0, max_devices = 0;
487 DbgPrint(("rd_pc_initial entry\n"));
489 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
490 memset(tmp_buf, '\0', 96);
492 max_devices = chg ? MaxLinTapeChangerDevices : MaxLinTapeDevices;
494 /* set proc_read flag for each logical device to false */
495 @@ -3580,47 +3489,59 @@
497 WRITE_UNLOCK(chg ? &changer_des_lock : &tape_des_lock);
499 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
500 count = sprintf(tmp_buf, "lin_tape version: %s", LIN_TAPE_VERSION);
501 if(count > length) goto EXIT_LABEL;
503 count = sprintf(buffer, "lin_tape version: %s", LIN_TAPE_VERSION);
506 count = sprintf(tmp_buf, "\nlin_tape major number: %d", lin_tape_major);
507 if(*buf_offset + count > length) goto EXIT_LABEL;
509 count = sprintf(buffer + *buf_offset,
510 "\nlin_tape major number: %d", lin_tape_major);
511 *buf_offset += count;
513 count = sprintf(tmp_buf, "\nAttached %s Devices:",
514 chg ? "Changer" : "Tape");
515 if(*buf_offset + count > length) goto EXIT_LABEL;
517 count = sprintf(buffer + *buf_offset, "\nAttached %s Devices:",
518 chg ? "Changer" : "Tape");
519 *buf_offset += count;
521 count = sprintf(tmp_buf, "\n%-8s%-12s%-18s%-16s%-16s%-10s",
522 "Number", "model", "SN", "HBA", "SCSI", "FO Path");
523 if(*buf_offset + count > length) goto EXIT_LABEL;
525 count = sprintf(buffer + *buf_offset, "\n%-8s%-12s%-18s%-16s%-16s%-10s",
527 + seq_printf(m, "lin_tape version: %s\n", LIN_TAPE_VERSION);
528 + seq_printf(m, "lin_tape major number: %d\n", lin_tape_major);
529 + seq_printf(m, "Attached %s Devices:\n", chg ? "Changer" : "Tape");
530 + seq_printf(m, "%-8s%-12s%-18s%-16s%-16s%-10s\n",
532 "Number", "model", "SN", "HBA", "SCSI", "FO Path");
533 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
534 *buf_offset += count;
541 memset(buffer + *buf_offset, ' ', length - *buf_offset);
542 *buf_offset = length;
546 DbgPrint(("rd_pc_initial exit: %d\n", rc));
549 + DbgPrint(("rd_pc_initial exit\n"));
552 } /* rd_pc_initial() */
554 /*******************************************************************************
555 @@ -3642,8 +3518,13 @@
557 *******************************************************************************/
559 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
560 int rd_pc_start_dev(int* start_dev, int* eof, off_t offset, char* buffer,
561 int* buf_offset, boolean chg)
563 +int rd_pc_start_dev(int* start_dev, int* eof, off_t offset, struct seq_file *m,
567 int found = False, rc = 0, i = 0, max_devices = 0;
569 @@ -3678,7 +3554,11 @@
571 if(*start_dev >= max_devices) {
573 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
574 *buf_offset += sprintf(&buffer[*buf_offset], "\n");
576 + seq_printf(m, "\n");
581 @@ -3705,17 +3581,31 @@
583 *******************************************************************************/
585 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
586 char* scsi_addr_str(struct tape_descriptor* drv, char* buffer, boolean cgr)
588 +void scsi_addr_str(struct tape_descriptor* drv, struct seq_file *m, boolean cgr)
591 struct changer_descriptor* chg = (struct changer_descriptor*)drv;
594 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
595 sprintf(buffer, "%d:%d:%d:%d",
597 + seq_printf(m, "%d:%d:%d:%d",
599 chg->host, chg->channel, chg->target, chg->lun);
601 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
602 sprintf(buffer, "%d:%d:%d:%d",
604 + seq_printf(m, "%d:%d:%d:%d",
606 drv->host, drv->channel, drv->target, drv->lun);
607 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
610 } /* scsi_addr_str() */
612 /*******************************************************************************
613 diff -ur lin_tape-2.1.0/lin_tape_scsi_config.h lin_tape-2.1.0-3.10/lin_tape_scsi_config.h
614 --- lin_tape-2.1.0/lin_tape_scsi_config.h 2013-06-12 23:07:31.000000000 +0200
615 +++ lin_tape-2.1.0-3.10/lin_tape_scsi_config.h 2013-08-25 14:22:14.635373745 +0200
616 @@ -178,14 +178,24 @@
618 static void lin_tape_rescan(struct device *);
620 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
621 static int tape_read_proc(char *, char **, off_t, int, int *, void *);
622 int rd_pc_initial(char* buffer, int* buf_offset, int length, char** start,
624 int rd_pc_start_dev(int* start_dev, int* eof, off_t offset, char* buffer,
625 int* buf_offset, boolean chg);
626 char* scsi_addr_str(struct tape_descriptor* drv, char* buffer, boolean cgr);
628 +static int tape_read_proc(struct seq_file *, void *);
629 +int rd_pc_initial(struct seq_file *, boolean chg);
630 +void scsi_addr_str(struct tape_descriptor* drv, struct seq_file *m, boolean cgr);
633 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
634 static int changer_read_proc(char *, char **, off_t, int, int *, void *);
636 +static int changer_read_proc(struct seq_file *, void *);
639 /* global variables */
640 static unchar lin_tape_cleanup_module = 0;
642 atomic_t tsm_tp_open = {0};
643 static unsigned int lin_tape_major;
645 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
646 static struct proc_dir_entry *tape_proc_entry = NULL;
647 static struct proc_dir_entry *changer_proc_entry = NULL;
650 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
651 rwlock_t hba_lock = RW_LOCK_UNLOCKED;