G'day,

I said I was going to post some new code for the changer modlue once uit
was tested and working to an acceptable standard and seeing as it is (well
in the autofs code at least.... cd-rom module is playing up in the kernel,
which is resetting the drive but that different)

Patched version: 3.1.4 
Final code works on: 4.0.0pre10 (Spose its time to update)
Command Used: diff mount_changer.c.old mount_changer.c
-- 8<--- Diff --------- 8<--
52a53,55
> // H O O K: Define for options browsing
>   char *p, *q, *noptions;
>   int l;
74a78,130
> /* H O O K: Next option should be slot to change, 2nd should be fstype
>      fs=     is used in place of fstype
>      slot=   is used for the slot number - backward compatible, but now
>                     allows for different names eg. cdrom-1 for slot 1
>                   or even onecd, twocd...
>      
>      Code copied from the sun parsing code and modified to look for the
>      two options, for slot the name is changed as I dont see it referenced
>      anywhere beyond the slot changing. 
> */
> 
>   noptions = strdup(options);
>   p = options;
>                     
>   for ( q = strtok(noptions, ",") ; q ; q = strtok(NULL, ",") ) {
>     if ( !strncmp(q, "fs=", 3) ) {
>       fstype = alloca(strlen(q+3)+1);
>       if ( !fstype ) {
>            syslog(LOG_ERR, MODPREFIX "alloca: %s");
>            return 1;
>       }
>                           
>       strcpy(fstype, q+3);
>     }
>     else if ( !strncmp(q, "slot=", 5) ) {
>       name = alloca(strlen(q+5)+1);
>       if ( !name ) {
>            syslog(LOG_ERR, MODPREFIX "alloca: %s");
>            return 1;
>       }
>                           
>       strcpy(name, q+5);
>     }
>     else {
>       l = strlen(q);
>       memcpy(p, q, l);
>       p += l;
>       *p = ',';
>       p++;
>     }
>   }
> 
>   if ( p > options ) {
>     --p;                        /* Delete last comma */
>     *p = '\0';
>   } else {
>     free(options);              /* No options - mount modules want NULL here */
>     options = NULL;
>   }
>   free(noptions);
>                       
> // H O O K: Done....
-- 8<--- End Diff ----- 8<--

Give the comment at the top of the 'main' modification of the code a read
for instructions as to what ive added... these may need to be added to the
docs for the changer module.

There is proberly one smaller disadvantage to this code in that it takes a
little more time to process (as its doing another options loop) but
otherwise it seems all code :)

Cheereo,
 .-`~`-. | James Hook
 H O O K | [EMAIL PROTECTED]
 ~-._.-~ | http://hooksoft.8m.com

... First sign of maturity: Discovering volume knobs also turn to the left.

Reply via email to