<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://bugs.gentoo.org/bugzilla.dtd">

<bugzilla version="2.22.7"
          urlbase="http://bugs.gentoo.org/"
          maintainer="bugzilla@gentoo.org"
>

    <bug>
          <bug_id>211167</bug_id>
          
          <creation_ts>2008-02-23 11:47 0000</creation_ts>
          <short_desc>sys-fs/mdadm-2.6.4 should not create /dev/dev</short_desc>
          <delta_ts>2008-02-26 19:14:19 0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Gentoo Linux</product>
          <component>Core system</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>RonnyPeine@gmx.de</reporter>
          <assigned_to>base-system@gentoo.org</assigned_to>
          <cc>gentoo-bugs.f@umsar.org</cc>
    
    <cc>robbat2@gentoo.org</cc>

      

      
          <long_desc isprivate="0">
            <who>RonnyPeine@gmx.de</who>
            <bug_when>2008-02-23 11:47:54 0000</bug_when>
            <thetext>sys-fs/mdadm-2.6.4 creates the directory /dev/dev, which i have found by accident because rkhunter barks about it. In this directory it has created an md0 block-device-file which is also created in /dev/md (the correct place for this). I have a software raid so this is expected but not the entry in /dev/dev. This is a regression compared to sys-fs/mdadm-2.6.2 which doesn&apos;t create /dev/dev.

Reproducible: Always</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vapier@gentoo.org</who>
            <bug_when>2008-02-23 20:50:08 0000</bug_when>
            <thetext>works fine on my server

you&apos;ll need to trace the code and find out who is creating it ... look at the addon in /lib/rcscripts/addons/raid-start.sh

also, post your mdadm.conf file as an attachment</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>RonnyPeine@gmx.de</who>
            <bug_when>2008-02-24 11:15:41 0000</bug_when>
            <thetext>(In reply to comment #1)
&gt; works fine on my server
&gt; 
&gt; you&apos;ll need to trace the code and find out who is creating it ... look at the
&gt; addon in /lib/rcscripts/addons/raid-start.sh
&gt; 
&gt; also, post your mdadm.conf file as an attachment
&gt; 

Hello SpanKY,

i have found the bug. Here is the trace:
+ &apos;[&apos; -f /proc/mdstat &apos;]&apos;
+ MAJOR=9
+ mdadm_conf=/etc/mdadm/mdadm.conf
+ &apos;[&apos; -e /etc/mdadm.conf &apos;]&apos;
+ mdadm_conf=/etc/mdadm.conf
+ &apos;[&apos; -x /sbin/mdadm -a -f /etc/mdadm.conf &apos;]&apos;
++ awk &apos;/^[[:space:]]*ARRAY/ { print $2 }&apos; /etc/mdadm.conf
+ devs=/dev/md0
+ &apos;[&apos; -n /dev/md0 &apos;]&apos;
+ create_devs /dev/md0
+ local node dir minor
+ for node in &apos;$@&apos;
+ &apos;[&apos; /md0 &apos;!=&apos; /dev/md0 &apos;]&apos;
+ node=/dev//dev/md0
+ &apos;[&apos; -e /dev//dev/md0 &apos;]&apos;
+ dir=/dev//dev
+ &apos;[&apos; &apos;!&apos; -d /dev//dev &apos;]&apos;
+ mkdir -p /dev//dev
+ minor=md0
+ mknod /dev//dev/md0 b 9 0
+ ebegin &apos;Starting up RAID devices (mdadm)&apos;
/lib/rcscripts/addons/raid-start-real.sh: line 34: ebegin: command not found
++ mdadm -As
+ output=&apos;mdadm: /dev/md0 has been started with 2 drives.&apos;
+ ret=0
+ &apos;[&apos; 0 -ne 0 &apos;]&apos;
+ eend 0
/lib/rcscripts/addons/raid-start-real.sh: line 38: eend: command not found
++ ls &apos;/dev/md_d*&apos;
+ partitioned_devs=
+ &apos;[&apos; -n &apos;&apos; &apos;]&apos;

The problem lies in the line
[ &quot;${node#/dev}&quot; != &quot;${node}&quot; ] &amp;&amp; node=&quot;/dev/${node}&quot;
in create_devs().
It evaluates for node=&quot;/dev/md0&quot; which is the value in my mdadm.conf for the raiddevice to node=&quot;/dev//dev/md0&quot;.
It should not be &quot;!=&quot;, it should be &quot;=&quot;. Tested here and works fine.
I think the line should test if the node already inhibits the /dev, if not it should put it as prefix in it. I&apos;m wondering why you can&apos;t reproduce it. Maybe you haven&apos;t rebooted since the update or you are using just &quot;md0&quot; in mdadm.conf as devicename.
For tracing i have renamed raid-start.sh to raid-start-real.sh and written a wrapper raid-start.sh which invokes raid-start-real.sh with bash -x, therefor the ebegin error.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vapier@gentoo.org</who>
            <bug_when>2008-02-24 11:27:48 0000</bug_when>
            <thetext>looks like robbat2 broke it ... i was testing the last version i wrote, and it works fine ;)</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vapier@gentoo.org</who>
            <bug_when>2008-02-24 19:10:05 0000</bug_when>
            <thetext>Created an attachment (id=144526)
raid-start.sh-2.6.3-r4

please test this for me</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>RonnyPeine@gmx.de</who>
            <bug_when>2008-02-25 20:36:28 0000</bug_when>
            <thetext>(In reply to comment #4)
&gt; Created an attachment (id=144526) [edit]
&gt; raid-start.sh-2.6.3-r4
&gt; 
&gt; please test this for me
&gt; 

Well, i have just read your script and your quoting seems to be not so well.
The quotes are better in robbat2&apos;s script, he uses &apos;&quot;&apos; with care where it should be. I prefer robbat2&apos;s script with just my small &quot;=&quot;-fix.
Be careful with using &quot;&quot; in a for loop like &apos;for node in &quot;$@&quot;&apos;. This works for this variable but can be wrong in other ways like FOO=&quot;a b c d&quot;; for i in &quot;${FOO}&quot;; do echo $i; done. It&apos;s better to omit these &apos;&quot;&apos; in most cases.
The other quotes are better solved in robbat2&apos;s which would also allow spaces and things like that in devicenames even if this won&apos;t ever occur.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vapier@gentoo.org</who>
            <bug_when>2008-02-25 22:12:41 0000</bug_when>
            <thetext>are you saying that without testing/knowing for real ?  i removed quotes where they were not actually needed

if you know of a specific place where quotes are missing, state them now

you also dont know the difference between &quot;$@&quot; and &quot;$*&quot;.  mine is correct, robbat2&apos;s is not.  consult the bash man page.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>RonnyPeine@gmx.de</who>
            <bug_when>2008-02-26 07:04:01 0000</bug_when>
            <thetext>(In reply to comment #6)
&gt; are you saying that without testing/knowing for real ?  i removed quotes where
&gt; they were not actually needed
&gt; 
&gt; if you know of a specific place where quotes are missing, state them now
&gt; 
&gt; you also dont know the difference between &quot;$@&quot; and &quot;$*&quot;.  mine is correct,
&gt; robbat2&apos;s is not.  consult the bash man page.
&gt; 

Ok, you are right with the &quot;$@&quot; as stated before, but i like more to quote with &apos;&quot;&apos; for variable initialization like devs=&quot;$(awk &apos;/^[[:space:]]*ARRAY/ { print $2 }&apos; ${mdadm_conf})&quot; instead of omitting &apos;&quot;&apos; here, it&apos;s more about taste here. Your script will work, i don&apos;t need to test it. Changes are minor and mostly only quoting.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vapier@gentoo.org</who>
            <bug_when>2008-02-26 07:17:07 0000</bug_when>
            <thetext>pointless quoting around assignments like:
var=&quot;$(command)&quot;
leads to ugliness when you need to quote inside of the $(...):
var=&quot;$(command &quot;${arg}&quot;)&quot;

added to 2.6.4-r1</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>RonnyPeine@gmx.de</who>
            <bug_when>2008-02-26 19:13:33 0000</bug_when>
            <thetext>(In reply to comment #8)
&gt; pointless quoting around assignments like:
&gt; var=&quot;$(command)&quot;
&gt; leads to ugliness when you need to quote inside of the $(...):
&gt; var=&quot;$(command &quot;${arg}&quot;)&quot;
&gt; 
&gt; added to 2.6.4-r1
&gt; 

Let&apos;s summarize it as different tastes :) Your script works, maybe inclusion in a sys-fs/mdadm-2.6.4-r1 possible?</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>RonnyPeine@gmx.de</who>
            <bug_when>2008-02-26 19:14:19 0000</bug_when>
            <thetext>(In reply to comment #9)
&gt; (In reply to comment #8)
&gt; &gt; pointless quoting around assignments like:
&gt; &gt; var=&quot;$(command)&quot;
&gt; &gt; leads to ugliness when you need to quote inside of the $(...):
&gt; &gt; var=&quot;$(command &quot;${arg}&quot;)&quot;
&gt; &gt; 
&gt; &gt; added to 2.6.4-r1
&gt; &gt; 
&gt; 
&gt; Let&apos;s summarize it as different tastes :) Your script works, maybe inclusion in
&gt; a sys-fs/mdadm-2.6.4-r1 possible?
&gt; 

Hmm i should have read your comment more deeply :)</thetext>
          </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>144526</attachid>
            <date>2008-02-24 19:10 0000</date>
            <desc>raid-start.sh-2.6.3-r4</desc>
            <filename>raid-start.sh-2.6.3-r4</filename>
            <type>text/plain</type>
            <data encoding="base64">IyAvbGliL3Jjc2NyaXB0cy9hZGRvbnMvcmFpZC1zdGFydC5zaDogIFNldHVwIHJhaWQgdm9sdW1l
cyBhdCBib290CiMgQ29weXJpZ2h0IDE5OTktMjAwOCBHZW50b28gRm91bmRhdGlvbgojIERpc3Ry
aWJ1dGVkIHVuZGVyIHRoZSB0ZXJtcyBvZiB0aGUgR05VIEdlbmVyYWwgUHVibGljIExpY2Vuc2Ug
djIKIyAkSGVhZGVyOiAvdmFyL2N2c3Jvb3QvZ2VudG9vLXg4Ni9zeXMtZnMvbWRhZG0vZmlsZXMv
cmFpZC1zdGFydC5zaC0yLjYuMy1yNCx2IDEuMSAyMDA3LzEwLzA4IDIxOjA3OjA3IHJvYmJhdDIg
RXhwICQKClsgLWYgL3Byb2MvbWRzdGF0IF0gfHwgZXhpdCAwCgojIFdlIGNvdWxkIG1ha2UgdGhp
cyBkeW5hbWljLCBidXQgZWgKI1sgLXogJHtNQUpPUn0gXSAmJiBleHBvcnQgTUFKT1I9JChhd2sg
JyQyID09ICJtZCIgeyBwcmludCAkMSB9JyAvcHJvYy9kZXZpY2VzKQpNQUpPUj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