From nobody@FreeBSD.org  Mon May  7 15:45:47 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id DB6FA106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  7 May 2012 15:45:47 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id ADD5E8FC1C
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  7 May 2012 15:45:47 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q47FjlHS088635
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 7 May 2012 15:45:47 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q47FjlOt088620;
	Mon, 7 May 2012 15:45:47 GMT
	(envelope-from nobody)
Message-Id: <201205071545.q47FjlOt088620@red.freebsd.org>
Date: Mon, 7 May 2012 15:45:47 GMT
From: Zaytsev Artem <a.arepo@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: fusefs. Incorrect signal handling with direct_io
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         167688
>Category:       kern
>Synopsis:       [fusefs] Incorrect signal handling with direct_io
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-fs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon May 07 15:50:12 UTC 2012
>Closed-Date:    
>Last-Modified:  Mon May 07 18:49:46 UTC 2012
>Originator:     Zaytsev Artem
>Release:        FreeBSD 9.0
>Organization:
>Environment:
FreeBSD home 9.0-STABLE FreeBSD 9.0-STABLE #1 r233749M: Sat Mar 31 20:44:17 MSK 2012 amd64
fusefs-kmod-0.3.9.p1.20080208_9 Kernel module for fuse
fusefs-libs-2.7.4   FUSE allows filesystem implementation in userspace
>Description:
If while reading a file from fusefs signal is received, then read(2) will return 0 and errno 0 (just like EOF) instead of EINTR.
>How-To-Repeat:
/* --------------------------- fuse.c ------------------------ */
#include <fuse.h>
#include <string.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <unistd.h>

int fs_getattr(const char *name, struct stat *st) {
	st->st_mode = S_IFREG;
	st->st_size = 1;
	
	return 0;
}

int fs_read(const char *name, char *buf, size_t bufSize, off_t off, struct fuse_file_info *fi) {
	sleep(10);
	return 1;
}

int main(int argc, char **argv) {
	struct fuse_operations operations;

	memset(&operations, 0, sizeof(operations));
	operations.read = fs_read;
	operations.getattr = fs_getattr;

	return fuse_main(argc, argv, &operations, NULL);
}
/* ----------------------------------------------------------- */


/* ------------------------- reader.c ------------------------ */
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <errno.h>
#include <signal.h>

void on_alarm(int s) {
	fprintf(stderr, "alarm\n");
}

int main(int argc, char **argv) {
	int fd, readed;
	char buf[16];
	
	if(argc < 2)
		exit(255);

	fd = open(argv[1], O_RDONLY);
	if(fd < 0) {
		perror("open");
		exit(errno);
	}

	/* handler required, SIG_IGN will mask the error */
	signal(SIGALRM, on_alarm);
	alarm(1);

	readed = read(fd, buf, sizeof(buf));
	fprintf(stderr, "Readed: %d, errno=%d\n", (int)readed, (int)errno);

	return 0;
}
/* ---------------------------------------------------------- */

# cc -o fs -Wall -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26 -I/usr/local/include -L/usr/local/lib -pthread -lfuse fuse.c
# cc -o reader -Wall reader.c

# mkdir mnt

# ./fs -o allow_other -o direct_io mnt
# ./reader mnt
<<< sleep for 1 second >>>
alarm
Readed: 0, errno=0
>Fix:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-fs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Mon May 7 18:49:28 UTC 2012 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=167688 
>Unformatted:
