]> git.pld-linux.org Git - packages/lin_tape.git/blob - linux-3.10.patch
e60588fec83993c935c573d0e2ab4c578ca2780f
[packages/lin_tape.git] / linux-3.10.patch
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
4 @@ -3150,6 +3150,30 @@
5         return;
6  } /* lin_tape_delete_tsm_pseudo() */
7  
8 +static int tape_proc_open(struct inode *inode, struct file *file)
9 +{
10 +       return single_open(file, tape_read_proc, PDE_DATA(inode));
11 +}
12 +
13 +static int changer_proc_open(struct inode *inode, struct file *file)
14 +{
15 +       return single_open(file, changer_read_proc, PDE_DATA(inode));
16 +}
17 +
18 +static const struct file_operations tape_proc_fops = {
19 +       .open           = tape_proc_open,
20 +       .read           = seq_read,
21 +       .llseek         = seq_lseek,
22 +       .release        = single_release,
23 +};
24 +
25 +static const struct file_operations changer_proc_fops = {
26 +       .open           = changer_proc_open,
27 +       .read           = seq_read,
28 +       .llseek         = seq_lseek,
29 +       .release        = single_release,
30 +};
31 +
32  /*******************************************************************************
33  *                                                                              *
34  *  NAME: lin_tape_create_proc                                                  *
35 @@ -3167,42 +3191,16 @@
36         DbgPrint(("lin_tape: lin_tape_create_proc entry\n"));
37  
38         WRITE_LOCK(&lin_tape_lock);
39 -       if(!tape_proc_entry) {
40 -               tape_proc_entry =
41 -                       create_proc_entry("scsi/IBMtape", 0, NULL);
42 -
43 -               if(!tape_proc_entry) {
44 -                       DbgPrint(("lin_tape: cannot initialize "\
45 -                               "/proc/scsi/IBMtape\n"));
46 -                       goto EXIT_LABEL;
47 -               } /* if */
48 -
49 -               tape_proc_entry->read_proc = tape_read_proc;
50 -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
51 -               tape_proc_entry->owner = THIS_MODULE;
52 -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
53 -               tape_proc_entry->get_info = NULL;
54 -#endif
55 -#endif
56 +       if (!proc_create("scsi/IBMtape", 0, NULL, &tape_proc_fops)) {
57 +               DbgPrint(("lin_tape: cannot initialize "\
58 +                       "/proc/scsi/IBMtape\n"));
59 +               goto EXIT_LABEL;
60         } /* if */
61  
62 -       if(!changer_proc_entry) {
63 -               changer_proc_entry =
64 -                       create_proc_entry("scsi/IBMchanger", 0, NULL);
65 -
66 -               if(!changer_proc_entry) {
67 -                       DbgPrint(("lin_tape: cannot initialize "\
68 -                               "/proc/scsi/IBMchanger\n"));
69 -                       goto EXIT_LABEL;
70 -               } /* if */
71 -
72 -               changer_proc_entry->read_proc = changer_read_proc;
73 -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
74 -               changer_proc_entry->owner = THIS_MODULE;
75 -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
76 -               changer_proc_entry->get_info = NULL;
77 -#endif
78 -#endif
79 +       if (!proc_create("scsi/IBMchanger", 0, NULL, &changer_proc_fops)) {
80 +               DbgPrint(("lin_tape: cannot initialize "\
81 +                       "/proc/scsi/IBMchanger\n"));
82 +               goto EXIT_LABEL;
83         } /* if */
84  
85  EXIT_LABEL:
86 @@ -3229,15 +3227,8 @@
87  {
88         WRITE_LOCK(&lin_tape_lock);
89  
90 -       if(tape_proc_entry) {
91 -               remove_proc_entry("scsi/IBMtape", NULL);
92 -               tape_proc_entry = NULL;
93 -       } /* if */
94 -
95 -       if(changer_proc_entry) {
96 -               remove_proc_entry("scsi/IBMchanger", NULL);
97 -               changer_proc_entry = NULL;
98 -       } /* if */
99 +       remove_proc_entry("scsi/IBMtape", NULL);
100 +       remove_proc_entry("scsi/IBMchanger", NULL);
101  
102         WRITE_UNLOCK(&lin_tape_lock);
103  
104 @@ -3262,52 +3253,36 @@
105  *  RETURNS: 0 on success or error                                              *
106  *                                                                              *
107  *******************************************************************************/
108 -
109 -static int tape_read_proc(char* buffer, char** start, off_t offset, int length,
110 -       int* eof, void* data)
111 +static int tape_read_proc(struct seq_file *m, void* data)
112  {
113 -       int buf_offset = 0, i = 0, start_dev = 0, found = 0, linelen = 0;
114 -       unchar* model = NULL, * pre_buf = NULL;
115 -       unchar temp_buf[96];
116 +       int i = 0, found = 0;
117 +       unchar* model = NULL;
118         char* sn = NULL;
119         boolean tape_des_locked = False;
120  
121         DbgPrint(("lin_tape: tape_read_proc entry\n"));
122  
123         model = kmalloc(12, GFP_KERNEL);
124 -       pre_buf = kmalloc(ONE_K / 4, GFP_KERNEL);
125         sn = kmalloc(MaxSerialNumberSize + 1, GFP_KERNEL);
126 -       if(!model || !pre_buf || !sn || !buffer || !start || !eof) {
127 -               if(start) *start = buffer;
128 -               if(eof) *eof = True;
129 +       if(!model || !sn) {
130                 goto EXIT_LABEL;
131         } /* if */
132  
133 -       memset(temp_buf, '\0', 96);
134         memset(model, '\0', 12);
135 -       memset(pre_buf, '\0', ONE_K / 4);
136         memset(sn, '\0', MaxSerialNumberSize + 1);
137  
138         i = 0;
139  
140 -       if(!offset && rd_pc_initial(buffer, &buf_offset, length, start, False))
141 -               goto EXIT_LABEL;
142 -
143 -       if(rd_pc_start_dev(&start_dev, eof, offset, buffer, &buf_offset, False))
144 -               goto EXIT_LABEL;
145 +       rd_pc_initial(m, False);
146  
147         READ_LOCK(&tape_des_lock);
148         tape_des_locked = True;
149  
150         if(!tape_devs) {
151 -               *eof = True;
152 -               if(buf_offset == length) buf_offset--;
153 -               buf_offset += sprintf(&buffer[buf_offset], "\n");
154 -               *start = buffer;
155                 goto EXIT_LABEL;
156         } /* if */
157  
158 -       for(i = start_dev; i < MaxLinTapeDevices; i++) {
159 +       for(i = 0; i < MaxLinTapeDevices; i++) {
160                 if(!tape_devs[i] || !tape_devs[i]->dev_obj) continue;
161  
162                 found = False;
163 @@ -3326,8 +3301,7 @@
164                         sn[strlen(sn) - 1] == '\t'))
165                         sn[strlen(sn) - 1] = '\0';
166  
167 -               linelen = snprintf(pre_buf, ONE_K / 4,
168 -                       "\n%-8d%-12s%-18s%-16s%-16s%-10s",
169 +               seq_printf(m, "%-8d%-12s%-18s%-16s",
170                         i,
171                         model,
172  
173 @@ -3335,12 +3309,12 @@
174                         tape_devs[i]->serial_num_len ? sn : "NA",
175  
176                         tape_devs[i]->ghost_device ? "" :
177 -                       found ? tape_devs[i]->pname : "NA",
178 +                       found ? tape_devs[i]->pname : "NA");
179  
180 -                       tape_devs[i]->ghost_device ? ""       :
181 -                       scsi_addr_str(tape_devs[i], temp_buf,
182 -                               False),
183 +               if (!tape_devs[i]->ghost_device)
184 +                       scsi_addr_str(tape_devs[i], m, False);
185  
186 +               seq_printf(m, "%-10s\n",
187                         tape_devs[i]->ghost_device ? ""       :
188                         !found ? "NA"                         :
189                         !tape_devs[i]->serial_num_len ? "NA"  :
190 @@ -3349,45 +3323,23 @@
191                         tape_devs[i]->isPrimary ? "Primary"   :
192                         "Alternate");
193  
194 -               if(buf_offset > length) {
195 -                       buf_offset = length;
196 -                       break;
197 -               } else if(buf_offset + linelen >= length) {
198 -                       memset(&buffer[buf_offset], ' ', length - buf_offset);
199 -                       buf_offset = length;
200 -                       break;
201 -               } /* if */
202 -
203 -               buf_offset += sprintf(&buffer[buf_offset], "%s", pre_buf);
204                 tape_devs[i]->proc_read = True;
205         } /* for */
206  
207         tape_des_locked = False;
208         READ_UNLOCK(&tape_des_lock);
209  
210 -       if(i == start_dev || i >= MaxLinTapeDevices) {
211 -               if(buf_offset == length) buf_offset--;
212 -               buf_offset += sprintf(&buffer[buf_offset], "\n");
213 -               *eof = True;
214 -               if(i >= MaxLinTapeDevices) *start = buffer;
215 -               goto EXIT_LABEL;
216 -       } /* if */
217 -
218 -       *start = buffer;
219 -
220  EXIT_LABEL:
221  
222 -       if(pre_buf) kfree(pre_buf);
223         if(model) kfree(model);
224         if(sn) kfree(sn);
225  
226         if(tape_des_locked) READ_UNLOCK(&tape_des_lock);
227         tape_des_locked = False;
228  
229 -       if(buf_offset == 1 && *eof) buf_offset = 0;
230 -       DbgPrint(("tape_read_proc exit: %d\n", buf_offset));
231 +       DbgPrint(("tape_read_proc exit:\n"));
232  
233 -       return buf_offset;
234 +       return 0;
235  } /* tape_read_proc() */
236  
237  /*******************************************************************************
238 @@ -3409,12 +3361,10 @@
239  *                                                                              *
240  *******************************************************************************/
241  
242 -static int changer_read_proc(char* buffer, char** start, off_t offset,
243 -                               int length, int* eof, void* data)
244 +static int changer_read_proc(struct seq_file *m, void* data)
245  {
246 -       int buf_offset = 0, i = 0, start_dev = 0, found = 0, linelen = 0;
247 -       unchar* model = NULL, * pre_buf = NULL;
248 -       unchar temp_buf[96];
249 +       int i = 0, found = 0;
250 +       unchar* model = NULL;
251         char* sn = NULL;
252         boolean changer_des_locked = False;
253  
254 @@ -3423,37 +3373,24 @@
255         i = 0;
256  
257         model = kmalloc(12, GFP_KERNEL);
258 -       pre_buf = kmalloc(ONE_K / 4, GFP_KERNEL);
259         sn = kmalloc(MaxSerialNumberSize + 1, GFP_KERNEL);
260 -       if(!model || !pre_buf || !sn || !buffer || !start || !eof) {
261 -               if(start) *start = buffer;
262 -               if(eof) *eof = True;
263 +       if(!model || !sn) {
264                 goto EXIT_LABEL;
265         } /* if */
266  
267 -       memset(temp_buf, '\0', 96);
268         memset(model, '\0', 12);
269 -       memset(pre_buf, '\0', ONE_K / 4);
270         memset(sn, '\0', MaxSerialNumberSize + 1);
271  
272 -       if(!offset && rd_pc_initial(buffer, &buf_offset, length, start, True))
273 -               goto EXIT_LABEL;
274 -
275 -       if(rd_pc_start_dev(&start_dev, eof, offset, buffer, &buf_offset, True))
276 -               goto EXIT_LABEL;
277 +       rd_pc_initial(m, True);
278  
279         READ_LOCK(&changer_des_lock);
280         changer_des_locked = True;
281  
282         if(!changer_devs) {
283 -               *eof = True;
284 -               if(buf_offset == length) buf_offset--;
285 -               buf_offset += sprintf(&buffer[buf_offset], "\n");
286 -               *start = buffer;
287                 goto EXIT_LABEL;
288         } /* if */
289  
290 -       for(i = start_dev; i < MaxLinTapeChangerDevices; i++) {
291 +       for(i = 0; i < MaxLinTapeChangerDevices; i++) {
292                 if(!changer_devs[i] || !changer_devs[i]->dev_obj) continue;
293  
294                 found = False;
295 @@ -3472,8 +3409,7 @@
296                         sn[strlen(sn) - 1] == '\t'))
297                         sn[strlen(sn) - 1] = '\0';
298  
299 -               linelen = snprintf(pre_buf, ONE_K / 4,
300 -                       "\n%-8d%-12s%-18s%-16s%-16s%-10s",
301 +               seq_printf(m, "%-8d%-12s%-18s%-16s",
302                         i,
303                         model,
304  
305 @@ -3481,14 +3417,12 @@
306                         changer_devs[i]->serial_num_len ? sn : "NA",
307  
308                         changer_devs[i]->ghost_device ? "" :
309 -                       found ? changer_devs[i]->pname : "NA",
310 +                       found ? changer_devs[i]->pname : "NA");
311  
312 -                       changer_devs[i]->ghost_device ? ""       :
313 -                       scsi_addr_str((struct tape_descriptor*)
314 -                               changer_devs[i],
315 -                               temp_buf,
316 -                               True),
317 +               if (!changer_devs[i]->ghost_device)
318 +                       scsi_addr_str((struct tape_descriptor*)changer_devs[i], m, True);
319  
320 +               seq_printf(m, "%-10s\n",
321                         changer_devs[i]->ghost_device                 ? ""   :
322                         !found                                        ? "NA" :
323                         changer_devs[i]->chg_id == IBM_3590
324 @@ -3498,45 +3432,23 @@
325                         changer_devs[i]->isPrimary            ? "Primary"     :
326                         "Alternate");
327  
328 -               if(buf_offset > length) {
329 -                       buf_offset = length;
330 -                       break;
331 -               } else if(buf_offset + linelen >= length) {
332 -                       memset(&buffer[buf_offset], ' ', length - buf_offset);
333 -                       buf_offset = length;
334 -                       break;
335 -               } /* if */
336 -
337 -               buf_offset += sprintf(&buffer[buf_offset], "%s", pre_buf);
338                 changer_devs[i]->proc_read = True;
339         } /* for */
340  
341         changer_des_locked = False;
342         READ_UNLOCK(&changer_des_lock);
343  
344 -       if(i == start_dev || i >= MaxLinTapeChangerDevices) {
345 -               if(buf_offset == length) buf_offset--;
346 -               buf_offset += sprintf(&buffer[buf_offset], "\n");
347 -               *eof = True;
348 -               if(i >= MaxLinTapeChangerDevices) *start = buffer;
349 -               goto EXIT_LABEL;
350 -       } /* if */
351 -
352 -       *start = buffer;
353 -
354  EXIT_LABEL:
355  
356         if(model) kfree(model);
357 -       if(pre_buf) kfree(pre_buf);
358         if(sn) kfree(sn);
359  
360         if(changer_des_locked) READ_UNLOCK(&changer_des_lock);
361         changer_des_locked = False;
362  
363 -       if(buf_offset == 1 && *eof) buf_offset = 0;
364 -       DbgPrint(("changer_read_proc exit: %d\n", buf_offset));
365 +       DbgPrint(("changer_read_proc exit\n"));
366  
367 -       return buf_offset;
368 +       return 0;
369  } /* changer_read_proc() */
370  
371  /*******************************************************************************
372 @@ -3557,15 +3469,12 @@
373  *                                                                              *
374  *******************************************************************************/
375  
376 -int rd_pc_initial(char* buffer, int* buf_offset, int length, char** start,
377 -       boolean chg)
378 +int rd_pc_initial(struct seq_file *m, boolean chg)
379  {
380 -       int rc = 1, count = 0, i = 0, max_devices = 0;
381 -       char tmp_buf[96];
382 +       int i = 0, max_devices = 0;
383  
384         DbgPrint(("rd_pc_initial entry\n"));
385  
386 -       memset(tmp_buf, '\0', 96);
387         max_devices = chg ? MaxLinTapeChangerDevices : MaxLinTapeDevices;
388  
389         /* set proc_read flag for each logical device to false */
390 @@ -3580,47 +3489,14 @@
391         } /* if */
392         WRITE_UNLOCK(chg ? &changer_des_lock : &tape_des_lock);
393  
394 -       count = sprintf(tmp_buf, "lin_tape version: %s", LIN_TAPE_VERSION);
395 -       if(count > length) goto EXIT_LABEL;
396 -
397 -       count = sprintf(buffer, "lin_tape version: %s", LIN_TAPE_VERSION);
398 -       *buf_offset = count;
399 -
400 -       count = sprintf(tmp_buf, "\nlin_tape major number: %d", lin_tape_major);
401 -       if(*buf_offset + count > length) goto EXIT_LABEL;
402 -
403 -       count = sprintf(buffer + *buf_offset,
404 -               "\nlin_tape major number: %d", lin_tape_major);
405 -       *buf_offset += count;
406 -
407 -       count = sprintf(tmp_buf, "\nAttached %s Devices:",
408 -               chg ? "Changer" : "Tape");
409 -       if(*buf_offset + count > length) goto EXIT_LABEL;
410 -
411 -       count = sprintf(buffer + *buf_offset, "\nAttached %s Devices:",
412 -               chg ? "Changer" : "Tape");
413 -       *buf_offset += count;
414 -
415 -       count = sprintf(tmp_buf, "\n%-8s%-12s%-18s%-16s%-16s%-10s",
416 -                       "Number", "model", "SN", "HBA", "SCSI", "FO Path");
417 -       if(*buf_offset + count > length) goto EXIT_LABEL;
418 -
419 -       count = sprintf(buffer + *buf_offset, "\n%-8s%-12s%-18s%-16s%-16s%-10s",
420 +       seq_printf(m, "lin_tape version: %s\n", LIN_TAPE_VERSION);
421 +       seq_printf(m, "lin_tape major number: %d\n", lin_tape_major);
422 +       seq_printf(m, "Attached %s Devices:\n", chg ? "Changer" : "Tape");
423 +       seq_printf(m, "%-8s%-12s%-18s%-16s%-16s%-10s\n",
424                 "Number", "model", "SN", "HBA", "SCSI", "FO Path");
425 -       *buf_offset += count;
426 -
427 -       rc = 0;
428  
429 -EXIT_LABEL:
430 -
431 -       if(rc) {
432 -               memset(buffer + *buf_offset, ' ', length - *buf_offset);
433 -               *buf_offset = length;
434 -               *start = buffer;
435 -       } /* if */
436 -
437 -       DbgPrint(("rd_pc_initial  exit: %d\n", rc));
438 -       return rc;
439 +       DbgPrint(("rd_pc_initial exit\n"));
440 +       return 0;
441  } /* rd_pc_initial() */
442  
443  /*******************************************************************************
444 @@ -3642,8 +3518,8 @@
445  *                                                                              *
446  *******************************************************************************/
447  
448 -int rd_pc_start_dev(int* start_dev, int* eof, off_t offset, char* buffer,
449 -       int* buf_offset, boolean chg)
450 +int rd_pc_start_dev(int* start_dev, int* eof, off_t offset, struct seq_file *m,
451 +       boolean chg)
452  {
453         int found = False, rc = 0, i = 0, max_devices = 0;
454  
455 @@ -3678,7 +3554,7 @@
456  
457         if(*start_dev >= max_devices) {
458                 *eof = True;
459 -               *buf_offset += sprintf(&buffer[*buf_offset], "\n");
460 +               seq_printf(m, "\n");
461                 rc = 1;
462                 goto EXIT_LABEL;
463         } /* if */
464 @@ -3705,17 +3581,16 @@
465  *                                                                              *
466  *******************************************************************************/
467  
468 -char* scsi_addr_str(struct tape_descriptor* drv, char* buffer, boolean cgr)
469 +void scsi_addr_str(struct tape_descriptor* drv, struct seq_file *m, boolean cgr)
470  {
471         struct changer_descriptor* chg = (struct changer_descriptor*)drv;
472  
473         if(cgr)
474 -               sprintf(buffer, "%d:%d:%d:%d",
475 +               seq_printf(m, "%d:%d:%d:%d",
476                         chg->host, chg->channel, chg->target, chg->lun);
477         else
478 -               sprintf(buffer, "%d:%d:%d:%d",
479 +               seq_printf(m, "%d:%d:%d:%d",
480                         drv->host, drv->channel, drv->target, drv->lun);
481 -       return buffer;
482  } /* scsi_addr_str() */
483  
484  /*******************************************************************************
485 diff -ur lin_tape-2.1.0/lin_tape_scsi_config.h lin_tape-2.1.0-3.10/lin_tape_scsi_config.h
486 --- lin_tape-2.1.0/lin_tape_scsi_config.h       2013-06-12 23:07:31.000000000 +0200
487 +++ lin_tape-2.1.0-3.10/lin_tape_scsi_config.h  2013-08-25 14:22:14.635373745 +0200
488 @@ -178,14 +178,11 @@
489  #endif
490  static void lin_tape_rescan(struct device *);
491  
492 -static int tape_read_proc(char *, char **, off_t, int, int *, void *);
493 -int rd_pc_initial(char* buffer, int* buf_offset, int length, char** start,
494 -       boolean chg);
495 -int rd_pc_start_dev(int* start_dev, int* eof, off_t offset, char* buffer,
496 -       int* buf_offset, boolean chg);
497 -char* scsi_addr_str(struct tape_descriptor* drv, char* buffer, boolean cgr);
498 +static int tape_read_proc(struct seq_file *, void *);
499 +int rd_pc_initial(struct seq_file *, boolean chg);
500 +void scsi_addr_str(struct tape_descriptor* drv, struct seq_file *m, boolean cgr);
501  
502 -static int changer_read_proc(char *, char **, off_t, int, int *, void *);
503 +static int changer_read_proc(struct seq_file *, void *);
504  
505  /* global variables */
506  static unchar lin_tape_cleanup_module = 0;
507 @@ -222,9 +219,6 @@
508  atomic_t tsm_tp_open = {0};
509  static unsigned int lin_tape_major;
510  
511 -static struct proc_dir_entry *tape_proc_entry = NULL;
512 -static struct proc_dir_entry *changer_proc_entry = NULL;
513 -
514  #if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
515  rwlock_t hba_lock = RW_LOCK_UNLOCKED;
516  #else
This page took 0.109257 seconds and 2 git commands to generate.