On 03/25/2014 01:57 PM, Greg Wooledge wrote: > On Tue, Mar 25, 2014 at 08:24:13PM +0900, Kusanagi Kouichi wrote: >> Description: >> Bash's builtin printf cannot write more than one line to >> /proc/pid/uid_map because printf writes one line at a time >> and uid_map can be written only once. > > Sounds like Bash is using the standard I/O library routines, in line > buffering mode (i.e. setvbuf(..., _IOLBF, ...); ). It's not clear > to me whether this can be considered a bug, as line-buffered output > is common, and situations where it fails are rare. > >> Repeat-By: >> # printf '0 0 1\n1 1 1' > /proc/31861/uid_map >> printf: write error: Operation not permitted > > As a workaround, you might consider something like: > > printf '0 0 1\n1 1 1' | dd bs=1024 > /proc/31861/uid_map
Note dd will immediately write any short reads in that case too. Though not a specific issue here (since the printf will issue a single write()), to generall get dd to coalesce reads you needs to specify obs separately like: printf '0 0 1\n1 1 1' | dd obs=1024 > /proc/31861/uid_map BTW it's a bit surprising that bash doesn't use standard "default buffering modes" mentioned here: http://www.pixelbeat.org/programming/stdio_buffering/ If you want to use the external printf to achieve more standard buffering modes, you can use `env` like: env printf '%s' '0 0 1\n1 1 1' > /proc/31861/uid_map thanks, Pádraig.