Hi,
I was skimming trough the code some more when I found some more
duplicated code. getconsolefd in vt.c and console_fd suspend.c. The
differences are that console_fd opens like:
fd = open(fname, O_RDONLY);
if (fd < 0 && errno == EACCES)
fd = open(fname, O_WRONLY);
and getconsolefd
fd = open(fnam, O_RDWR);
if (fd < 0)
return -1;
Also getconsolefd tries a bunch of device nodes, while console_fd only
tries /dev/console.
Attached patch makes resume use getconsolefd.
What do you think?
--- suspend.c 2007-01-24 13:43:55.000000000 +0100
+++ suspend.c 2007-01-24 14:02:54.000000000 +0100
@@ -828,26 +828,6 @@
return error;
}
-/**
- * console_fd - get file descriptor for given file name and verify
- * if that's a console descriptor (based on the code of openvt)
- */
-
-static inline int console_fd(const char *fname)
-{
- int fd;
- char arg;
-
- fd = open(fname, O_RDONLY);
- if (fd < 0 && errno == EACCES)
- fd = open(fname, O_WRONLY);
- if (fd >= 0 && (ioctl(fd, KDGKBTYPE, &arg) || (arg != KB_101 && arg !=
KB_84))) {
- close(fd);
- return -ENOTTY;
- }
- return fd;
-}
-
#ifndef TIOCL_GETKMSGREDIRECT
#define TIOCL_GETKMSGREDIRECT 17
#endif
@@ -867,7 +847,7 @@
struct vt_stat vtstat;
char clear_vt, tiocl[2];
- fd = console_fd("/dev/console");
+ fd = getconsolefd();
if (fd < 0)
return fd;
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Suspend-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/suspend-devel