From 967c65a99059fd459b956c1588ce0ba227912c4e Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Tue, 16 Dec 1997 05:34:03 +0000 Subject: Merge with Linux 2.1.72, part 1. --- fs/autofs/waitq.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'fs/autofs/waitq.c') diff --git a/fs/autofs/waitq.c b/fs/autofs/waitq.c index 7e4558d9d..607b4314e 100644 --- a/fs/autofs/waitq.c +++ b/fs/autofs/waitq.c @@ -42,31 +42,36 @@ void autofs_catatonic_mode(struct autofs_sb_info *sbi) static int autofs_write(struct file *file, const void *addr, int bytes) { - unsigned long fs; - unsigned long old_signal; + unsigned long sigpipe, flags; + mm_segment_t fs; const char *data = (const char *)addr; - int written = 0; + ssize_t wr = 0; /** WARNING: this is not safe for writing more than PIPE_BUF bytes! **/ + sigpipe = sigismember(¤t->signal, SIGPIPE); + /* Save pointer to user space and point back to kernel space */ fs = get_fs(); set_fs(KERNEL_DS); - old_signal = current->signal; - - while ( bytes && (written = file->f_op->write(file,data,bytes,&file->f_pos)) > 0 ) { - data += written; - bytes -= written; + while (bytes && + (wr = file->f_op->write(file,data,bytes,&file->f_pos)) > 0) { + data += wr; + bytes -= wr; } - if ( written == -EPIPE && !(old_signal & (1 << (SIGPIPE-1))) ) { - /* Keep the currently executing process from receiving a - SIGPIPE unless it was already supposed to get one */ - current->signal &= ~(1 << (SIGPIPE-1)); - } set_fs(fs); + /* Keep the currently executing process from receiving a + SIGPIPE unless it was already supposed to get one */ + if (wr == -EPIPE && !sigpipe) { + spin_lock_irqsave(¤t->sigmask_lock, flags); + sigdelset(¤t->signal, SIGPIPE); + recalc_sigpending(current); + spin_unlock_irqrestore(¤t->sigmask_lock, flags); + } + return (bytes > 0); } -- cgit v1.2.3