PERFORCE change 109652 for review
Jung-uk Kim
jkim at FreeBSD.org
Thu Nov 9 23:24:48 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=109652
Change 109652 by jkim at jkim_hammer on 2006/11/09 23:24:13
Fixes for 'blocking in fifoor state' problem of LTP tests.
linux_*stat*() functions were opening files with O_RDONLY to get
major/minor pair for char/block special files. Unfortunately,
when these functions are used against fifo, it is blocked forever
because there is no writer. Instead, we only open char/block special
files for major/minor conversion. We have to get rid of kern_open()
entirely from translate_path_major_minor() but today is not the day.
While I am here, add checks for errors before calling
translate_path_major_minor().
Affected files ...
.. //depot/projects/linuxolator/src/sys/compat/linux/linux_stats.c#5 edit
Differences ...
==== //depot/projects/linuxolator/src/sys/compat/linux/linux_stats.c#5 (text+ko) ====
@@ -100,23 +100,16 @@
translate_fd_major_minor(struct thread *td, int fd, struct stat *buf)
{
struct file *fp;
- int error;
int major, minor;
- if ((error = fget(td, fd, &fp)) != 0)
+ if ((!S_ISCHR(buf->st_mode) && !S_ISBLK(buf->st_mode)) ||
+ fget(td, fd, &fp) != 0)
return;
- if (fp->f_vnode) {
- if (fp->f_vnode->v_type == VCHR
- || fp->f_vnode->v_type == VBLK) {
- if (fp->f_vnode->v_un.vu_cdev) {
- if (linux_driver_get_major_minor(
- fp->f_vnode->v_un.vu_cdev->si_name,
- &major, &minor) == 0) {
- buf->st_rdev = (major << 8 | minor);
- }
- }
- }
- }
+ if (fp->f_vnode != NULL &&
+ fp->f_vnode->v_un.vu_cdev != NULL &&
+ linux_driver_get_major_minor(fp->f_vnode->v_un.vu_cdev->si_name,
+ &major, &minor) == 0)
+ buf->st_rdev = (major << 8 | minor);
fdrop(fp, td);
}
@@ -129,6 +122,8 @@
int fd;
int temp;
+ if (!S_ISCHR(buf->st_mode) && !S_ISBLK(buf->st_mode))
+ return;
temp = td->td_retval[0];
if (kern_open(td, path, UIO_SYSSPACE, O_RDONLY, 0) != 0)
return;
@@ -179,18 +174,19 @@
#endif
error = kern_stat(td, path, UIO_SYSSPACE, &buf);
- if (!error && strlen(path) > strlen("/dev/pts/") &&
- !strncmp(path, "/dev/pts/", strlen("/dev/pts/"))
- && path[9] >= '0' && path[9] <= '9') {
- /*
- * Linux checks major and minors of the slave device to make
- * sure it's a pty device, so let's make him believe it is.
- */
- buf.st_rdev = (136 << 8);
- }
-
- translate_path_major_minor(td, path, &buf);
-
+ if (!error) {
+ if (strlen(path) > strlen("/dev/pts/") &&
+ !strncmp(path, "/dev/pts/", strlen("/dev/pts/")) &&
+ path[9] >= '0' && path[9] <= '9') {
+ /*
+ * Linux checks major and minors of the slave device
+ * to make sure it's a pty device, so let's make him
+ * believe it is.
+ */
+ buf.st_rdev = (136 << 8);
+ } else
+ translate_path_major_minor(td, path, &buf);
+ }
LFREEPATH(path);
if (error)
return (error);
@@ -212,7 +208,8 @@
#endif
error = kern_lstat(td, path, UIO_SYSSPACE, &sb);
- translate_path_major_minor(td, path, &sb);
+ if (!error)
+ translate_path_major_minor(td, path, &sb);
LFREEPATH(path);
if (error)
return (error);
@@ -539,18 +536,19 @@
#endif
error = kern_stat(td, filename, UIO_SYSSPACE, &buf);
- if (!error && strlen(filename) > strlen("/dev/pts/") &&
- !strncmp(filename, "/dev/pts/", strlen("/dev/pts/"))
- && filename[9] >= '0' && filename[9] <= '9') {
- /*
- * Linux checks major and minors of the slave device to make
- * sure it's a pty deivce, so let's make him believe it is.
- */
- buf.st_rdev = (136 << 8);
+ if (!error) {
+ if (strlen(filename) > strlen("/dev/pts/") &&
+ !strncmp(filename, "/dev/pts/", strlen("/dev/pts/")) &&
+ filename[9] >= '0' && filename[9] <= '9') {
+ /*
+ * Linux checks major and minors of the slave device
+ * to make sure it's a pty deivce, so let's make him
+ * believe it is.
+ */
+ buf.st_rdev = (136 << 8);
+ } else
+ translate_path_major_minor(td, filename, &buf);
}
-
- translate_path_major_minor(td, filename, &buf);
-
LFREEPATH(filename);
if (error)
return (error);
@@ -572,7 +570,8 @@
#endif
error = kern_lstat(td, filename, UIO_SYSSPACE, &sb);
- translate_path_major_minor(td, filename, &sb);
+ if (!error)
+ translate_path_major_minor(td, filename, &sb);
LFREEPATH(filename);
if (error)
return (error);
More information about the p4-projects
mailing list