# Can't Compile CIFS into kernel (Solved)

## LoSeR_5150

Can compile as module fine but when compiling in kernel I get the following error:

```
drivers/built-in.o: In function `MD5Init':

(.text+0x1a8eb0): multiple definition of `MD5Init'

fs/built-in.o:(.text+0x175030): first defined here

drivers/built-in.o: In function `MD5Update':

(.text+0x1ac020): multiple definition of `MD5Update'

fs/built-in.o:(.text+0x175910): first defined here

drivers/built-in.o: In function `MD5Final':

(.text+0x1abf10): multiple definition of `MD5Final'

fs/built-in.o:(.text+0x1757d0): first defined here

make: *** [vmlinux.o] Error 1
```

emerge --info:

```

Portage 2.2_rc26 (default/linux/amd64/2008.0/desktop, gcc-4.3.3, glibc-2.9_p20081201-r2, 2.6.28-gentoo-r4 x86_64)

=================================================================

System uname: Linux-2.6.28-gentoo-r4-x86_64-AMD_Sempron-tm-_Processor_3000+-with-glibc2.2.5

Timestamp of tree: Fri, 20 Mar 2009 23:00:08 +0000

app-shells/bash:     4.0_p10-r1

dev-java/java-config: 2.1.7

dev-lang/python:     2.5.4-r2

dev-util/cmake:      2.6.3

sys-apps/baselayout: 2.0.0

sys-apps/openrc:     0.4.3-r1

sys-apps/sandbox:    1.6

sys-devel/autoconf:  2.13, 2.63

sys-devel/automake:  1.5, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10.2

sys-devel/binutils:  2.19.1-r1

sys-devel/gcc-config: 1.4.1

sys-devel/libtool:   2.2.6a

virtual/os-headers:  2.6.28-r1

ACCEPT_KEYWORDS="amd64 ~amd64"

CBUILD="x86_64-pc-linux-gnu"

CFLAGS="-march=native -O2 -fno-ident -msse3 -pipe"

CHOST="x86_64-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/config"

CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/splash /etc/terminfo /etc/udev/rules.d"

CXXFLAGS="-march=native -O2 -fno-ident -msse3 -pipe -fno-enforce-eh-specs"

DISTDIR="/usr/portage/distfiles"

FEATURES="distlocks fixpackages parallel-fetch preserve-libs protect-owned sandbox sfperms strict unmerge-orphans userfetch"

GENTOO_MIRRORS="http://gentoo.osuosl.org/"

LANG="en_US.UTF-8"

LC_ALL="en_US.UTF-8"

LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu"

LINGUAS="en_US.UTF-8"

MAKEOPTS="-j3"

PKGDIR="/usr/portage/packages"

PORTAGE_CONFIGROOT="/"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

PORTDIR_OVERLAY="/usr/local/portage"

SYNC="rsync://rsync.gentoo.org/gentoo-portage"

USE="3dnow 3dnowext X a52 aac acl acpi alsa amd64 artworkextra avi bash-completion berkdb bluetooth branding bzip2 cairo cdparanoia cdr cli cracklib crypt cups dbus dio directfb divx dv dvd dvdr dvdread eds emboss encode evo fam fbcon ffmpeg firefox flac fortran ftp gdbm gif glibc-omitfp glut gnome gpm gstreamer gtk gtk2 gtstreamer hal iconv ieee1394 ipv6 isdnlog ithreads java javascript jpeg kdeenablefinal kdehiddenvisibility kerberos ldap libnotify lm_sensors mad madwifi midi mikmod mmx mmxext mng mp3 mpeg mudflap multilib ncurses nfs nls nptl nptlonly nsplugin offensive ogg openal opengl openmp oss pam pcmcia pcre pdf perl php png pni ppds pppd python qt3 qt3support qt4 quicktime readline reflection samba sdl session smp spell spl sse sse2 ssl startup-notification svg symlink sysfs tcpd threads tiff truetype twinview unicode usb videos vorbis wifi xinerama xml xorg xulrunner xv xvid zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic auth_digest authn_anon authn_dbd  authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile  authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock dbd  deflate dir disk_cache env expires ext_filter file_cache filter headers ident  imagemap include info log_config logio mem_cache mime mime_magic negotiation  proxy proxy_ajp proxy_balancer proxy_connect proxy_http rewrite setenvif  speling status unique_id userdir usertrack vhost_alias" APACHE2_MPMS="worker" ELIBC="glibc" INPUT_DEVICES="keyboard evdev mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en_US.UTF-8" USERLAND="GNU" VIDEO_CARDS="nv nvidia vmware"

Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
```

.config @ http://pastebin.com/m792565d0

Also this builds fine on my Laptop... kernel config is exactly the same minus hardware differences (Network cards, IDE/SATA controllers, etc.)

----------

## pappy_mcfae

Grab a seed kernel, and put your devices into it. There is a tutorial. Follow the link in my sig.

Or, if you'd like, post the results of lspci -n, cat /proc/cpuinfo, as well as your /etc/fstab file. I'll take a look and see what I can find.

Blessed be!

Pappy

----------

## LoSeR_5150

pappy_mcfae: I'll try a seed kernel ... are they 2.6.28 based or 2.6.29-rc based?  Also I'll include my lspci -n, cat /proc/cpuinfo , and my /etc/fstab

lscpi -n:

```

00:00.0 0500: 10de:02f0 (rev a2)

00:00.2 0500: 10de:02fe (rev a2)

00:00.3 0500: 10de:02f8 (rev a2)

00:00.4 0500: 10de:02f9 (rev a2)

00:00.5 0500: 10de:02ff (rev a2)

00:00.6 0500: 10de:027f (rev a2)

00:00.7 0500: 10de:027e (rev a2)

00:02.0 0604: 10de:02fc (rev a1)

00:03.0 0604: 10de:02fd (rev a1)

00:04.0 0604: 10de:02fb (rev a1)

00:05.0 0300: 10de:0245 (rev a2)

00:09.0 0500: 10de:0270 (rev a2)

00:0a.0 0601: 10de:0260 (rev a3)

00:0a.1 0c05: 10de:0264 (rev a3)

00:0b.0 0c03: 10de:026d (rev a3)

00:0b.1 0c03: 10de:026e (rev a3)

00:0d.0 0101: 10de:0265 (rev a1)

00:0e.0 0101: 10de:0266 (rev a1)

00:0f.0 0101: 10de:0267 (rev a1)

00:10.0 0604: 10de:026f (rev a2)

00:10.1 0403: 10de:026c (rev a2)

00:14.0 0680: 10de:0269 (rev a3)

00:18.0 0600: 1022:1100

00:18.1 0600: 1022:1101

00:18.2 0600: 1022:1102

00:18.3 0600: 1022:1103

04:07.0 0280: 1814:0701

04:08.0 0c00: 1106:3044 (rev c0)

```

cat /proc/cpuinfo:

```

processor       : 0

vendor_id       : AuthenticAMD

cpu family      : 15

model           : 79

model name      : AMD Sempron(tm) Processor 3000+

stepping        : 2

cpu MHz         : 1607.413

cache size      : 256 KB

fpu             : yes

fpu_exception   : yes

cpuid level     : 1

wp              : yes

flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow up rep_good pni cx16 lahf_lm extapic cr8_legacy

bogomips        : 3216.77

TLB size        : 1024 4K pages

clflush size    : 64

cache_alignment : 64

address sizes   : 40 bits physical, 48 bits virtual

power management: ts ttp tm stc

```

/etc/fstab:

```

# <fs>                    <mountpoint>   <type>         <opts>                      <dump/pass>

/dev/sda1                 /boot          ext2           defaults                        1 2

/dev/sda3                 /              ext4           extents,noatime                 0 1

/dev/mapper/crypt-swap    none           swap           sw                              0 0

/dev/hdc                  /mnt/cdrom     iso9660,udf    noauto,ro,user                  0 0

#/dev/fd0                 /mnt/floppy    auto           noauto                          0 0

# glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for 

# POSIX shared memory (shm_open, shm_unlink).

# (tmpfs is a dynamically expandable/shrinkable ramdisk, and will

#  use almost no memory if not populated with files)

shm                      /dev/shm        tmpfs          nodev,nosuid,noexec             0 0

```

----------

## pappy_mcfae

They span from the last .22 of both vanilla and gentoo-sources to the latest .28's. Click on the link in my sig. If you want me to set you up, all I need to know is whether you're running x86 or x86_64 and which specific version you desire.

Blessed be!

Pappy

----------

## LoSeR_5150

I'll be passing on the kernel seeds... but thanks... I carefully go into my kernel and compile the options I need.  They have worked for many systems for many years with no issues.  And I like to build a monolithic kernel... I know it is *supposed* to be faster to have a lighter weight kernel and modularize everything but I use most of the crap I compile in so I would just be loading the modules anyways.  Anyhow I'd appreciate you look my config over and see if there is anything glaringly obvious that I missed.  Also I can post the config, lspci, fstab, etc... from my laptop which can compile the same kernel if i copy the config over from my desktop... I could just compile the kernel on the laptop and copy it over but I want to know why it wont compile on the desktop...

----------

## LoSeR_5150

I was thinking the only thing that is different in the two kernels is that I included some staging drivers from the 2.6.29-rc8 kernel for the rt2860 wireless chipset.  I am wondering if that could be the cause.

----------

## pappy_mcfae

It is very possible. That code is so new, the paint's still a bit wet. When that happens, you can almost rest assured there will be a bug or two associated with it. Turn it off with the kernel, and recompile.

For now, I don't use it with the zen-rc.29 kernels. I'm too busy playing with the zen stuff to worry about staging drivers. Besides, all my devices on all my systems are supported (thank the goddess).

Also, check with kernel.org's bugzilla to see if there are already bug reports on the issue. My philosophy is, if I'm having a problem, so is someone else. It's just a matter of who gets to put their name to said bug report first. As long as the report is made, it can be fixed.

Blessed be!

Pappy

----------

## pappy_mcfae

 *LoSeR_5150 wrote:*   

> Anyhow I'd appreciate you look my config over and see if there is anything glaringly obvious that I missed.  Also I can post the config, lspci, fstab, etc... from my laptop which can compile the same kernel if i copy the config over from my desktop... I could just compile the kernel on the laptop and copy it over but I want to know why it wont compile on the desktop...

 

I'd be more than happy to check your .configs. Be sure to use pastebin.com to send them. I use them pretty much exclusively.

Blessed be!

Pappy

----------

## LoSeR_5150

I've posted the configs on pastebin...

----------

## pappy_mcfae

I need a link to the .configs.

Blessed be!

Pappy

----------

## LoSeR_5150

That may help   :Embarassed:   ... 

```
http://pastebin.com/m3f5b6edd
```

that should have the cpuinfo, fstab, lspci and .config thanks again

----------

## pappy_mcfae

Ok. I'll take a looksee as soon as I check my other messages.

Blessed be!

Pappy

----------

## pappy_mcfae

I took a look, and decided to start with one of my seeds. It's easier to turn things on and install drivers than it is to turn them off and hope you got everything. I did get everything but one device; your wireless adapter. Apparently, it's so new, you need ndiswrapper and the windoze driver to make it work. I set the kernel up to work with ndiswrapper until you get a native driver for the device.

Click here for your new .config. Compile as is.

For the best results, please do the following:

1) Move your .config file out of your kernel source directory (/usr/src/linux-2.6.28-gentoo-r4  ).

2) Issue the command make mrproper. This is a destructive step. It returns the source to pristine condition. Unmoved .config files will be deleted!

3) Copy my .config into your source directory.

4) Issue the command make && make modules_install.

5) Install the kernel as you normally would, and reboot.

6) Once it boots, please post /var/log/dmesg so I can see how things loaded.

At the moment, I am only working to get CIFS installed properly in your kernel. Once it gets compiled, there will still be some work to do configuring samba. Make sure you run emerge -av samba mount-cifs so you have what you'll need to get started, if you haven't emerged them yet, that is. 

Blessed be!

Pappy

----------

## LoSeR_5150

So I have narrowed the problem down to be differences in the  md5.h from CIFS and the rt2860 staging driver from the 2.6.29-rc8 kernel.  I am not quite sure how to fix this however.  Any help is appreciated.  

diff /usr/src/linux/fs/cifs/md5.h /usr/src/linux/drivers/staging/rt2860/md5.h 

```

1,5c1,45

< #ifndef MD5_H

< #define MD5_H

< #ifndef HEADER_MD5_H

< /* Try to avoid clashes with OpenSSL */

< #define HEADER_MD5_H

---

> /*

>  *************************************************************************

>  * Ralink Tech Inc.

>  * 5F., No.36, Taiyuan St., Jhubei City,

>  * Hsinchu County 302,

>  * Taiwan, R.O.C.

>  *

>  * (c) Copyright 2002-2007, Ralink Technology, Inc.

>  *

>  * This program is free software; you can redistribute it and/or modify  *

>  * it under the terms of the GNU General Public License as published by  *

>  * the Free Software Foundation; either version 2 of the License, or     *

>  * (at your option) any later version.                                   *

>  *                                                                       *

>  * This program is distributed in the hope that it will be useful,       *

>  * but WITHOUT ANY WARRANTY; without even the implied warranty of        *

>  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *

>  * GNU General Public License for more details.                          *

>  *                                                                       *

>  * You should have received a copy of the GNU General Public License     *

>  * along with this program; if not, write to the                         *

>  * Free Software Foundation, Inc.,                                       *

>  * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *

>  *                                                                       *

>  *************************************************************************

> 

>    Module Name:

>    md5.h

> 

>    Abstract:

> 

>    Revision History:

>    Who         When         What

>    --------   ----------      ----------------------------------------------

>    Name      Date         Modification logs

>    jan         10-28-03      Initial

>    Rita       11-23-04      Modify MD5 and SHA-1

> */

> 

> #ifndef   uint8

> #define   uint8  unsigned   char

> #endif

> 

> #ifndef   uint32

> #define   uint32 unsigned   long int

8,38c48,107

< struct MD5Context {

<    __u32 buf[4];

<    __u32 bits[2];

<    unsigned char in[64];

< };

< #endif            /* !MD5_H */

< 

< #ifndef _HMAC_MD5_H

< struct HMACMD5Context {

<    struct MD5Context ctx;

<    unsigned char k_ipad[65];

<    unsigned char k_opad[65];

< };

< #endif            /* _HMAC_MD5_H */

< 

< void MD5Init(struct MD5Context *context);

< void MD5Update(struct MD5Context *context, unsigned char const *buf,

<          unsigned len);

< void MD5Final(unsigned char digest[16], struct MD5Context *context);

< 

< /* The following definitions come from lib/hmacmd5.c  */

< 

< /* void hmac_md5_init_rfc2104(unsigned char *key, int key_len,

<          struct HMACMD5Context *ctx);*/

< void hmac_md5_init_limK_to_64(const unsigned char *key, int key_len,

<          struct HMACMD5Context *ctx);

< void hmac_md5_update(const unsigned char *text, int text_len,

<          struct HMACMD5Context *ctx);

< void hmac_md5_final(unsigned char *digest, struct HMACMD5Context *ctx);

< /* void hmac_md5(unsigned char key[16], unsigned char *data, int data_len,

<          unsigned char *digest);*/

---

> 

> #ifndef   __MD5_H__

> #define   __MD5_H__

> 

> #define MD5_MAC_LEN 16

> 

> typedef struct _MD5_CTX {

>     UINT32   Buf[4];             // buffers of four states

>    UCHAR   Input[64];          // input message

>    UINT32   LenInBitCount[2];   // length counter for input message, 0 up to 64 bits

> }   MD5_CTX;

> 

> VOID MD5Init(MD5_CTX *pCtx);

> VOID MD5Update(MD5_CTX *pCtx, UCHAR *pData, UINT32 LenInBytes);

> VOID MD5Final(UCHAR Digest[16], MD5_CTX *pCtx);

> VOID MD5Transform(UINT32 Buf[4], UINT32 Mes[16]);

> 

> void md5_mac(u8 *key, size_t key_len, u8 *data, size_t data_len, u8 *mac);

> void hmac_md5(u8 *key, size_t key_len, u8 *data, size_t data_len, u8 *mac);

> 

> //

> // SHA context

> //

> typedef   struct _SHA_CTX

> {

>    UINT32   Buf[5];             // buffers of five states

>    UCHAR   Input[80];          // input message

>    UINT32   LenInBitCount[2];   // length counter for input message, 0 up to 64 bits

> 

> }   SHA_CTX;

> 

> VOID SHAInit(SHA_CTX *pCtx);

> UCHAR SHAUpdate(SHA_CTX *pCtx, UCHAR *pData, UINT32 LenInBytes);

> VOID SHAFinal(SHA_CTX *pCtx, UCHAR Digest[20]);

> VOID SHATransform(UINT32 Buf[5], UINT32 Mes[20]);

> 

> #define SHA_DIGEST_LEN 20

> #endif // __MD5_H__

> 

> /******************************************************************************/

> #ifndef   _AES_H

> #define   _AES_H

> 

> typedef   struct

> {

>    uint32 erk[64];      /* encryption round   keys */

>    uint32 drk[64];      /* decryption round   keys */

>    int   nr;            /* number of rounds   */

> }

> aes_context;

> 

> int    rtmp_aes_set_key( aes_context *ctx,   uint8 *key,   int   nbits );

> void rtmp_aes_encrypt( aes_context *ctx,   uint8 input[16], uint8 output[16] );

> void rtmp_aes_decrypt( aes_context *ctx,   uint8 input[16], uint8 output[16] );

> 

> void F(char *password, unsigned char *ssid, int ssidlength, int iterations, int count, unsigned char *output);

> int PasswordHash(char *password, unsigned char *ssid, int ssidlength, unsigned char *output);

> 

> #endif /* aes.h   */

> 

```

----------

## szczerb

The structs are the same (except names) and the functions have the same parameters. I'd try building the new driver with the old header (copy,symlink,whatever).

edit:

The new header has some aes stuff also....so make a copy of the old header and put the aes stuff in it.

----------

## LoSeR_5150

szczerb: Thanks for the tip...  I ended up just snagging CIFS from 2.6.29-rc8 and everything compiled nicely.  I had thought about modifying the md5.h, but then decided it would be much easier to see if CIFS from the 2.6.29 would just work.    

pappy_mcfae: I had originally setup the wireless card to use ndiswrapper and the Windows drivers I was bitten by a nasty bug where my wireless would die and ndiswrapper would use 100% cpu and could not be killed and would need to be shutdown/restarted.  I tried building the drivers from the Ralinktech site but with those drivers wouldn't connect to my router with WPA (AES/CCMP, TKIP, or AES/CCMP+TKIP) only WEP.  And well WEP just sucks.  I had seen an ebuild for the rt2860 drivers but when I checked them out the source uri it was what appeared to be the same drivers from Ralinktech so I passed.  Thats when I saw that they were included in the 2.6.29 staging drivers.  So I tried vanilla-2.6.29-rc7 and it worked great.  Except vmware-modules-1.0.0-15-r2 wouldn't build and I need it for VMWare Server.  And that leads me to now, which is why I had incorporated the RT2860 driver code and now the CIFS code from the 2.6.29-rc8 kernel into my gentoo-sources-2.6.28-r4 kernel.   

Anyways thanks for the help and I am happy to report I've rebooted to my new kernel 

```

uname -a

Linux Purgatory 2.6.28-gentoo-r4 #10 SMP PREEMPT Mon Mar 23 01:04:44 PDT 2009 x86_64 AMD Sempron(tm) Processor 3000+ AuthenticAMD GNU/Linux

```

and everything is functioning as expected.  w00t

----------

## pappy_mcfae

It's good to know things are going well as far as my kernel is concerned. It sucks about your wireless. Such is the horror of owning something so new, the paint is still wet. 

Blessed be!

Pappy

----------

