mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Patterson <andrew.patterson@hp.com>
To: Tejun Heo <teheo@suse.de>
Cc: Greg KH <greg@kroah.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, linux-hotplug@vger.kernel.org,
	bjorn.helgaas@hp.com
Subject: Re: Error returns not handled correctly	by	sysfs.c:subsys_attr_store()
Date: Thu, 03 Jan 2008 16:51:13 -0700	[thread overview]
Message-ID: <1199404273.7025.21.camel@bluto.andrew> (raw)
In-Reply-To: <1196716558.20124.179.camel@bluto.andrew>

On Mon, 2007-12-03 at 14:15 -0700, Andrew Patterson wrote:
> On Thu, 2007-11-29 at 10:07 +0900, Tejun Heo wrote:
> > Andrew Patterson wrote:
> > > I tried with clean 2.6.24-rc3 and get the same bad behavior.  This is on
> > > an ia64 box, so maybe that is an issue. I can try on an x86 box as well.
> > > Oh, one other thing.  I tried a "uname -r" to make sure I had the
> > > correct kernel booted and got:
> > > 
> > > # uname -r
> > > 2.6.24-rc3
> > > x
> > > y
> > > z
> > > #
> > 
> > Yeah, please try it on another machine from clean tree.  sysfs code is
> > definitely not endian dependent and is 64 bit clean.  Heck, all my test
> > machines run 64 bit these days.  I would be surprised if it's something
> > architecture dependent but please try on a different machine with
> > different userland with kernel built from fresh source tree.
> > 
> > Thanks.
> 
> I tried this on a AMD system running an i386 kernel. I get the same bad
> behavior.  This is from a 2.6.24-rc3 kernel downloaded from kernel.org.
> I ran "make mrproper" followed by "make oldconfig" and accepted all the
> defaults for the config.
> 
> There is one slight change with this experiment.  Other nodes are not
> getting corrupted, i.e., uname -r is getting the correct value.

It looks like this is a shell issue.  After looking through the sysfs
code, I realized that this problem seems to be driven from user-land.
So I performed some experiments:

     1. Wrote a simple program that just used write(2) to write to the
        sysfs entry. This works fine.
     2. Used /bin/echo instead of the built-in echo command.  This too
        works fine.
     3. Tried several shells.  Zsh and Bash both fail.  Csh works fine.

I then ran strace on the following shell-script:

#!/bin/bash

echo x > allow_restart
echo y > allow_restart
echo z > allow_restart

and got:

# strace -e trace=write ~/tmp/tester.sh 
write(1, "x\n", 2)                      = -1 EINVAL (Invalid argument)
write(1, "x\n", 2)                      = -1 EINVAL (Invalid argument)
write(2, "/home/andrew/tmp/tester.sh: line"..., 72/home/andrew/tmp/tester.sh: line 4: echo: write error: Invalid argument
) = 72
write(1, "x\ny\n", 4)                   = -1 EINVAL (Invalid argument)
write(1, "x\ny\n", 4)                   = -1 EINVAL (Invalid argument)
write(2, "/home/andrew/tmp/tester.sh: line"..., 72/home/andrew/tmp/tester.sh: line 5: echo: write error: Invalid argument
) = 72
write(1, "x\ny\nz\n", 6)                = -1 EINVAL (Invalid argument)
write(1, "x\ny\nz\n", 6)                = -1 EINVAL (Invalid argument)
write(2, "/home/andrew/tmp/tester.sh: line"..., 72/home/andrew/tmp/tester.sh: line 6: echo: write error: Invalid argument
) = 72
write(1, "x\ny\nz\n", 6x
y
z
)                = 6
Process 3800 detached

As you can see, subsequent echo commands have their arguments appended
to the previous command. So it seems that the shell is not resetting the
buffer between failed echo commands.  

-- 
Andrew Patterson
Hewlett-Packard Company


  parent reply	other threads:[~2008-01-03 23:51 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-21 22:16 Andrew Patterson
2007-11-27  4:31 ` Andrew Morton
2007-11-27  5:33   ` Greg KH
2007-11-27  5:38     ` Tejun Heo
2007-11-28  7:42     ` Tejun Heo
2007-11-28 19:31       ` Andrew Patterson
2007-11-28 20:05         ` Greg KH
2007-11-29  1:07         ` Tejun Heo
2007-12-03 21:15           ` Andrew Patterson
2007-12-21 20:35             ` Greg KH
2008-01-03 23:51             ` Andrew Patterson [this message]
2008-01-04  0:07               ` Tejun Heo
2008-01-04  0:17                 ` Andrew Patterson
2008-01-04  0:56                   ` Andrew Patterson
2008-01-04  7:30                     ` Andrey Borzenkov
2008-01-07 21:13                   ` Andrew Patterson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1199404273.7025.21.camel@bluto.andrew \
    --to=andrew.patterson@hp.com \
    --cc=akpm@linux-foundation.org \
    --cc=bjorn.helgaas@hp.com \
    --cc=greg@kroah.com \
    --cc=linux-hotplug@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=teheo@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome