misc/67793: gbde doesn't complain correctly when file does not exists.

Amir Shalem amir at active.ath.cx
Thu Jun 10 12:20:43 GMT 2004


>Number:         67793
>Category:       misc
>Synopsis:       gbde doesn't complain correctly when file does not exists.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jun 10 12:20:21 GMT 2004
>Closed-Date:
>Last-Modified:
>Originator:     Amir Shalem
>Release:        FreeBSD 5.2-CURRENT i386
>Organization:
None
>Environment:
System: FreeBSD active.ath.cx 5.2-CURRENT FreeBSD 5.2-CURRENT #0: Wed May 5 21:12:19 IDT 2004 amir at active.ath.cx:/usr/obj/usr/src/sys/ACTIVE i386


>Description:
	gbde doesn't open the device correctly, 
	it tries to open it with O_CREAT,
	which in case the file doesn't exists (or was given without /dev/)
	it creates it.

	beside creating the file, which doesn't fails,
	it tries than to ioctl() it, which fails ofcourse,
	so, what the user sees is:
	gbde: read: Inappropriate ioctl for device
	instand of:
	gbde: file: No such file or directory

>How-To-Repeat:
	in a directory where user can create files:
	$ gbde init ad0s1f
	$ gbde destroy test

	any command which involves setting doopen in gbde.c

>Fix:
	remove the O_CREAT flag.

--- gbde.c.orig Thu Jun 10 15:05:10 2004
+++ gbde.c      Thu Jun 10 15:01:13 2004
@@ -795,13 +795,13 @@
                }

        if (doopen) {
-               dfd = open(dest, O_RDWR | O_CREAT, 0644);
+               dfd = open(dest, O_RDWR, 0644);
                if (dfd < 0) {
                        if (snprintf(buf, sizeof(buf), "%s%s",
                            _PATH_DEV, dest) >= (ssize_t)sizeof(buf))
                                errno = ENAMETOOLONG;
                        else
-                               dfd = open(buf, O_RDWR | O_CREAT, 0644);
+                               dfd = open(buf, O_RDWR, 0644);
                }
                if (dfd < 0)
                        err(1, "%s", dest);


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list