Merge commit 'refs/top-bases/fix-branch' into fix-branch

This commit is contained in:
Brian Behlendorf 2010-06-29 10:15:05 -07:00
commit 0a03ec3bf5
1 changed files with 17 additions and 6 deletions

View File

@ -510,10 +510,12 @@ vn_open(char *path, int x1, int flags, int mode, vnode_t **vpp, int x2, int x3)
int fd; int fd;
vnode_t *vp; vnode_t *vp;
int old_umask; int old_umask;
char realpath[MAXPATHLEN]; char *realpath;
struct stat64 st; struct stat64 st;
int err; int err;
realpath = umem_alloc(MAXPATHLEN, UMEM_NOFAIL);
/* /*
* If we're accessing a real disk from userland, we need to use * If we're accessing a real disk from userland, we need to use
* the character interface to avoid caching. This is particularly * the character interface to avoid caching. This is particularly
@ -527,11 +529,16 @@ vn_open(char *path, int x1, int flags, int mode, vnode_t **vpp, int x2, int x3)
if (strncmp(path, "/dev/", 5) == 0) { if (strncmp(path, "/dev/", 5) == 0) {
char *dsk; char *dsk;
fd = open64(path, O_RDONLY); fd = open64(path, O_RDONLY);
if (fd == -1) if (fd == -1) {
return (errno); err = errno;
free(realpath);
return (err);
}
if (fstat64(fd, &st) == -1) { if (fstat64(fd, &st) == -1) {
err = errno;
close(fd); close(fd);
return (errno); free(realpath);
return (err);
} }
close(fd); close(fd);
(void) sprintf(realpath, "%s", path); (void) sprintf(realpath, "%s", path);
@ -541,8 +548,11 @@ vn_open(char *path, int x1, int flags, int mode, vnode_t **vpp, int x2, int x3)
dsk + 1); dsk + 1);
} else { } else {
(void) sprintf(realpath, "%s", path); (void) sprintf(realpath, "%s", path);
if (!(flags & FCREAT) && stat64(realpath, &st) == -1) if (!(flags & FCREAT) && stat64(realpath, &st) == -1) {
return (errno); err = errno;
free(realpath);
return (err);
}
} }
if (flags & FCREAT) if (flags & FCREAT)
@ -553,6 +563,7 @@ vn_open(char *path, int x1, int flags, int mode, vnode_t **vpp, int x2, int x3)
* FREAD and FWRITE to the corresponding O_RDONLY, O_WRONLY, and O_RDWR. * FREAD and FWRITE to the corresponding O_RDONLY, O_WRONLY, and O_RDWR.
*/ */
fd = open64(realpath, flags - FREAD, mode); fd = open64(realpath, flags - FREAD, mode);
free(realpath);
if (flags & FCREAT) if (flags & FCREAT)
(void) umask(old_umask); (void) umask(old_umask);