# Supermount patch for mm-sources

## Tim77

As far as I see, mm-sources-2.6.0-mm1 don't include the supermount-patch. Does anyone know if it's planned to include the patch in the near future?

If not I will patch the kernel myself.

----------

## Rosjahh

I don't know. But I do know that the gentoo-dev-sources includes a supermount patch, maybe you could just as well go with them. Don't know what your needs are though.

----------

## Tim77

I use the mm-sources and I'll stick with them  :Wink:  If it's not going to be supported, I will patch it myself. This should not be a problem, I think.

----------

## steel300

supermount is a controversial patch. -mm has no intentions, as of now, in including it in any kernel.

----------

## dub.wav

Results of trying to patch 2.6.1-rc2-mm1 with supermount:

```
patching file Documentation/filesystems/supermount.txt

patching file fs/supermount/Kconfig

patching file fs/supermount/Makefile

patching file fs/supermount/changelog

patching file fs/supermount/dentry.c

patching file fs/supermount/file.c

patching file fs/supermount/filemap.c

patching file fs/supermount/init.c

patching file fs/supermount/mediactl.c

patching file fs/supermount/namei.c

patching file fs/supermount/proc.c

patching file fs/supermount/subfs.c

patching file fs/supermount/super.c

patching file fs/supermount/supermount.h

patching file include/linux/supermount_media.h

patching file Documentation/filesystems/00-INDEX

patching file drivers/cdrom/cdrom.c

Hunk #1 succeeded at 275 (offset 6 lines).

Hunk #2 succeeded at 334 (offset 20 lines).

Hunk #3 FAILED at 450.

Hunk #4 succeeded at 771 (offset 328 lines).

Hunk #5 FAILED at 854.

Hunk #6 succeeded at 868 (offset 328 lines).

Hunk #7 FAILED at 946.

Hunk #8 succeeded at 1217 (offset 334 lines).

Hunk #9 succeeded at 1840 (offset 334 lines).

Hunk #10 succeeded at 2674 (offset 333 lines).

3 out of 10 hunks FAILED -- saving rejects to file drivers/cdrom/cdrom.c.rej

patching file drivers/cdrom/cdu31a.c

patching file drivers/cdrom/cm206.c

patching file drivers/cdrom/mcd.c

patching file drivers/cdrom/mcdx.c

patching file drivers/cdrom/sbpcd.c

patching file drivers/ide/ide-cd.c

Hunk #1 succeeded at 3421 (offset 68 lines).

Hunk #2 succeeded at 3473 (offset 68 lines).

patching file drivers/ide/ide-floppy.c

patching file drivers/scsi/sd.c

Hunk #2 succeeded at 436 (offset 4 lines).

Hunk #3 succeeded at 467 (offset 4 lines).

Hunk #4 succeeded at 591 (offset 4 lines).

Hunk #5 succeeded at 600 (offset 4 lines).

Hunk #6 succeeded at 648 (offset 4 lines).

Hunk #7 succeeded at 700 (offset 4 lines).

patching file drivers/scsi/sr.c

Hunk #1 succeeded at 423 (offset 1 line).

Hunk #2 succeeded at 468 (offset 1 line).

Hunk #3 succeeded at 484 (offset 1 line).

patching file fs/Kconfig

Hunk #1 succeeded at 921 (offset 28 lines).

patching file fs/Makefile

patching file fs/block_dev.c

Hunk #1 succeeded at 504 (offset 4 lines).

patching file fs/dnotify.c

patching file fs/namespace.c

Hunk #1 succeeded at 781 (offset 8 lines).

patching file fs/super.c

Hunk #1 succeeded at 80 (offset 1 line).

Hunk #2 succeeded at 503 (offset 1 line).

Hunk #3 succeeded at 613 (offset 1 line).

Hunk #4 succeeded at 727 (offset 1 line).

Hunk #5 succeeded at 765 (offset 1 line).

patching file fs/ext2/super.c

patching file fs/isofs/inode.c

patching file fs/udf/super.c

patching file include/linux/cdrom.h

Hunk #1 succeeded at 934 with fuzz 2 (offset 154 lines).

patching file include/linux/fs.h

Hunk #2 succeeded at 114 (offset 1 line).

Hunk #3 FAILED at 529.

Hunk #4 succeeded at 723 (offset 10 lines).

Hunk #5 succeeded at 789 (offset 15 lines).

1 out of 5 hunks FAILED -- saving rejects to file include/linux/fs.h.rej

patching file include/linux/genhd.h
```

 Good luck   :Wink: 

----------

## Tim77

In other words: Someone who did not ever patch a kernel before (like me...) should not mess around with it..?   :Wink: 

I thought it is "apply the patch, make menuconfig, compile, ready"...

----------

## trbecker

the -mm sources change some calls of functions, removing one parameter (struct file *file; anyone knows to what this struct is related?) and altering the other. the second is easy to patch, but the first is kind of hard. Anyone want to try (as i'm doing right now)?

I would like to see this patch applied to -mm since -love and -rml (as his posts on his blog) are based on -mm.

----------

## dub.wav

I applied the diff manually, and it seems like it's working. I guess the old supermount patch (I think there was a new one yesterday, not all the sf mirrors had it yet when I was getting it) was harder to patch.

EDIT: I just tried to do a ls /mnt/cdrom2, and ls hung up (it worked earlier). dmesg output below.

```
cdrom: hdd: mrw address space DMA selected

UDF-fs DEBUG fs/udf/lowlevel.c:57:udf_get_last_session: XA disk: no, vol_desc_st                                                                                                                                 art=0

UDF-fs DEBUG fs/udf/super.c:1550:udf_fill_super: Multi-session=0

UDF-fs DEBUG fs/udf/super.c:538:udf_vrs: Starting at sector 16 (2048 byte sector                                                                                                                                 s)

UDF-fs DEBUG fs/udf/super.c:565:udf_vrs: ISO9660 Primary Volume Descriptor found

UDF-fs DEBUG fs/udf/super.c:568:udf_vrs: ISO9660 Supplementary Volume Descriptor                                                                                                                                  found

UDF-fs DEBUG fs/udf/super.c:574:udf_vrs: ISO9660 Volume Descriptor Set Terminato                                                                                                                                 r found

UDF-fs: No VRS found

ISO 9660 Extensions: Microsoft Joliet Level 3

ISOFS: changing to secondary root

Unable to handle kernel paging request at virtual address 40b6f9d4

 printing eip:

c01e0acb

*pde = 00000000

Oops: 0002 [#1]

PREEMPT 

CPU:    0

EIP:    0060:[<c01e0acb>]    Tainted: PF  VLI

EFLAGS: 00010206

EIP is at get_subfs_file+0x8b/0x130

eax: df3b8440   ebx: c0351c00   ecx: 40b6f9c0   edx: decea200

esi: d9819500   edi: 40b6f9c0   ebp: d3314ef1   esp: ce5b5f3c

ds: 007b   es: 007b   ss: 0068

Process ls (pid: 9061, threadinfo=ce5b4000 task=d280cd00)

Stack: ffffff8c decea014 d9819500 d9819500 c01e0f36 d9819500 00000000 00010cfc 

       00000001 00000000 decea084 decea014 d9819500 00001000 c01685bc d9819500 

       ce5b5fa0 c01688a0 08060280 d9819500 fffffff7 c0168a1f d9819500 c01688a0 

Call Trace:

 [<c01e0f36>] supermount_readdir+0x86/0x150

 [<c01685bc>] vfs_readdir+0x7c/0x80

 [<c01688a0>] filldir64+0x0/0x110

 [<c0168a1f>] sys_getdents64+0x6f/0xa9

 [<c01688a0>] filldir64+0x0/0x110

 [<c02f1867>] syscall_call+0x7/0xb

Code: 82 6c 01 00 00 85 c0 74 6f 8b 48 10 85 c9 74 27 8b 8e 84 00 00 00 bf 8c ff                                                                                                                                  ff ff f6 41 18 01 75 16 8b 49 0c 85 c9 74 0f 8b 7d 0c <ff> 47 14 8b 82 6c 01 00                                                                                                                                  00 8b 5a 20 85 d2 74 33 81 fb 00 1c 35 

Badness in unblank_screen at drivers/char/vt.c:2793

Call Trace:

 [<c0213896>] unblank_screen+0x126/0x130

 [<c011b3ec>] bust_spinlocks+0x2c/0x60

 [<c010ce75>] die+0x95/0x100

 [<c011b85e>] do_page_fault+0x1de/0x50c

 [<c0247278>] ide_cdrom_check_media_change_real+0x28/0x60

 [<c011b680>] do_page_fault+0x0/0x50c

 [<c02f2273>] error_code+0x2f/0x38

 [<c01e0acb>] get_subfs_file+0x8b/0x130

 [<c01e0f36>] supermount_readdir+0x86/0x150

 [<c01685bc>] vfs_readdir+0x7c/0x80

 [<c01688a0>] filldir64+0x0/0x110

 [<c0168a1f>] sys_getdents64+0x6f/0xa9

 [<c01688a0>] filldir64+0x0/0x110

 [<c02f1867>] syscall_call+0x7/0xb
```

----------

## trbecker

 *dub.wav wrote:*   

> I applied the diff manually, and it seems like it's working. I guess the old supermount patch (I think there was a new one yesterday, not all the sf mirrors had it yet when I was getting it) was harder to patch.

 

the diff aplied without hunk failures? i would try it, but i'm at a windowze machine at the office (ugh!). I can't wait to go home...

If you applied the patch and fixed something, can you post the diff file for this?

----------

## dub.wav

 *sasquati wrote:*   

>  *dub.wav wrote:*   I applied the diff manually, and it seems like it's working. I guess the old supermount patch (I think there was a new one yesterday, not all the sf mirrors had it yet when I was getting it) was harder to patch. 
> 
> the diff aplied without hunk failures? i would try it, but i'm at a windowze machine at the office (ugh!). I can't wait to go home...
> 
> If you applied the patch and fixed something, can you post the diff file for this?

 No, I got the hunk failures listed above. There didn't seem to be much difference in the code from the little I could see in the patch, so I just copied in the failed hunks manually.

EDIT: Almost forgot, here's the diff. Apply the original patch, and then the below.

```
diff -urN orig/drivers/cdrom/cdrom.c new/drivers/cdrom/cdrom.c

--- orig/drivers/cdrom/cdrom.c   2004-01-08 19:04:29.958670720 +0100

+++ new/drivers/cdrom/cdrom.c   2004-01-08 18:48:50.000000000 +0100

@@ -753,7 +753,7 @@

          if (cdrom_open_write(cdi))

             goto err;

       }

-      ret = open_for_data(cdi);

+      ret = open_for_data(cdi, ip->i_bdev);

    }

 

    if (ret)

@@ -868,7 +868,8 @@

    is a goto to avoid bloating the driver with redundant code. */ 

 clean_up_and_return:

    cdinfo(CD_OPEN, "open failed.\n"); 

-   if (CDROM_CAN(CDC_LOCK) && cdi->options & CDO_LOCK) {

+   if (CDROM_CAN(CDC_LOCK) && cdi->options & CDO_LOCK &&

+       supermount_usage_count(bdev, cdi->use_count) > 0) {

          cdo->lock_door(cdi, 0);

          cdinfo(CD_OPEN, "door unlocked.\n");

    }

@@ -944,7 +945,7 @@

       cdi->use_count--;

    if (cdi->use_count == 0)

       cdinfo(CD_CLOSE, "Use count for \"/dev/%s\" now zero\n", cdi->name);

-   if (cdi->use_count == 0 &&

+   if (supermount_usage_count(fp ? fp->f_dentry->d_inode->i_bdev : 0, cdi->use_count) == 0 &&

        (cdo->capability & CDC_LOCK) && !keeplocked) {

       cdinfo(CD_CLOSE, "Unlocking door!\n");

       cdo->lock_door(cdi, 0);

diff -urN orig/include/linux/fs.h new/include/linux/fs.h

--- orig/include/linux/fs.h   2004-01-08 19:04:30.000000000 +0100

+++ new/include/linux/fs.h   2004-01-08 18:52:13.000000000 +0100

@@ -536,6 +536,11 @@

    spinlock_t      f_ep_lock;

 #endif /* #ifdef CONFIG_EPOLL */

    struct address_space   *f_mapping;

+   

+   #if defined(CONFIG_SUPERMOUNT) || defined(CONFIG_SUPERMOUNT_MODULE)

+   /* Used by supermount. Use(fullness) unconfirmed */

+   void                    *f_supermount;

+ #endif

 };

 extern spinlock_t files_lock;

 #define file_list_lock() spin_lock(&files_lock);
```

----------

## RikBlankestijn

EDIT 2: removed previous question

EDIT 1:

I just did it and I think it's correct. But I saw this message coming by:

```

  CC      fs/supermount/dentry.o

  CC      fs/supermount/file.o

fs/supermount/file.c: In function `supermount_release':

fs/supermount/file.c:553: warning: unused variable `bug'

  CC      fs/supermount/filemap.o

fs/supermount/filemap.c: In function `supermount_vm_nopage':

fs/supermount/filemap.c:102: warning: passing arg 3 of pointer to function makes pointer from integer without a cast

fs/supermount/filemap.c: At top level:

fs/supermount/filemap.c:206: warning: initialization from incompatible pointer type

```

but these are just warnings and should be a problem right?

EDIT 3: 

Excellent!!It works!!! Thanks a lot!!!

----------

## trbecker

well, it isn't patching in 2.6.1-mm4. i'll be moving to udev/hal/hotplug to mount things. maybe it will work.

----------

## RikBlankestijn

Cool let us know how it goes ok?! I just stick with this version now it works great for me. When I know what I need to do, I'll go on to a next version.  :Wink: 

----------

## trbecker

ok. i'll be working at it too tonite. if i have any to littele success you'll know...

@bedtime

in supermount-ng's sf page exists a patch that applies cleanly over -mm5 and compiles cleanly too. but is for sm-ng 2.0.3b which is not BLEEDING EDGE, so i think it doesn't fit in love-sources  :Wink: 

can someone apply this to love and report back, please? i'm going to bed right now  :Wink: 

my gentoo is completelly broke, so for udev/hotplug/hal/d-bus combo, i'll wait until system regeneration. tonite i'm emerging world, tomorow i'll see what i do.

----------

