08639c8faf
- A complete boot log (both early userspace and kernel) is preserved and can be obtained via `dmesg` - Messages are ordered and timestamped, so the log is more clear Example: [ 5.616453] [U] * /sbin/mount.cifs //10.42.0.4/dist/slinux-9.1-x86_64.iso /image -oguest,vers=1.0 [ 5.616932] CIFS: Attempting to mount //10.42.0.4/dist/slinux-9.1-x86_64.iso [ 5.616940] CIFS: VFS: Use of the less secure dialect vers=1.0 is not recommended unless required for access to very old servers [ 5.621647] CIFS: VFS: Could not allocate crypto cmac(aes) [ 5.623263] CIFS: VFS: Could not allocate crypto cmac(aes) [ 5.626645] [U] mount error(20): Not a directory [ 5.626649] [U] Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) and kernel log messages (dmesg) [ 5.626747] [U] * assuming ISO image, Samba path://10.42.0.4/dist [ 5.626749] [U] * mounting //10.42.0.4/dist on /image as type cifs [ 5.626753] [U] * cifsmount: attempting to mount //10.42.0.4/dist with default protocol version [ 5.626758] [U] * /sbin/mount.cifs //10.42.0.4/dist /image -oguest [ 5.627299] CIFS: Attempting to mount //10.42.0.4/dist [ 5.629106] CIFS: VFS: Could not allocate crypto cmac(aes) [ 5.631290] CIFS: VFS: Could not allocate crypto cmac(aes) [ 5.638261] CIFS: VFS: \\10.42.0.4 generate_key: crypto alloc failed [ 5.638264] CIFS: VFS: \\10.42.0.4 Send error in SessSetup = -2 [ 5.638275] CIFS: VFS: cifs_mount failed w/return code = -2 [ 5.638294] [U] mount error(2): No such file or directory [ 5.638296] [U] Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) and kernel log messages (dmesg) [ 5.638376] [U] * cifsmount: failed, retrying with vers=1.0 [ 5.638383] [U] * /sbin/mount.cifs //10.42.0.4/dist /image -oguest,vers=1.0 [ 5.639582] CIFS: Attempting to mount //10.42.0.4/dist [ 5.639590] CIFS: VFS: Use of the less secure dialect vers=1.0 is not recommended unless required for access to very old servers [ 5.649559] [U] * assuming ISO image, path:/image/slinux-9.1-x86_64.iso Related: #40554
125 lines
2.1 KiB
C
125 lines
2.1 KiB
C
/*
|
|
* Guillaume Cottenceau (gc@mandrakesoft.com)
|
|
*
|
|
* Copyright 2000 MandrakeSoft
|
|
*
|
|
* This software may be freely redistributed under the terms of the GNU
|
|
* public license.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
*
|
|
*/
|
|
|
|
/*
|
|
* Portions from Erik Troan (ewt@redhat.com)
|
|
*
|
|
* Copyright 1996 Red Hat Software
|
|
*
|
|
*/
|
|
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <fcntl.h>
|
|
#include <stdarg.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <time.h>
|
|
#include <errno.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include "stage1.h"
|
|
|
|
#include "log.h"
|
|
|
|
|
|
static FILE * logfile = NULL;
|
|
|
|
|
|
void vlog_message(const char * s, va_list args)
|
|
{
|
|
fprintf(logfile, "* ");
|
|
vfprintf(logfile, s, args);
|
|
fprintf(logfile, "\n");
|
|
fflush(logfile);
|
|
}
|
|
|
|
|
|
void log_message(const char * s, ...)
|
|
{
|
|
va_list args;
|
|
|
|
if (!logfile) {
|
|
fprintf(stderr, "Log is not open!\n");
|
|
return;
|
|
}
|
|
|
|
va_start(args, s);
|
|
vlog_message(s, args);
|
|
va_end(args);
|
|
|
|
return;
|
|
}
|
|
|
|
void log_perror(char *msg)
|
|
{
|
|
log_message("%s: %s", msg, strerror(errno));
|
|
}
|
|
|
|
|
|
void open_log(void)
|
|
{
|
|
if (!IS_TESTING) {
|
|
mknod("/dev/ttyprintk", S_IFCHR, MKDEV(5, 3));
|
|
logfile = fopen("/dev/ttyprintk", "w");
|
|
if (!logfile)
|
|
logfile = fopen("/tmp/install.log", "a");
|
|
}
|
|
else
|
|
logfile = fopen("debug.log", "w");
|
|
}
|
|
|
|
void close_log(void)
|
|
{
|
|
if (logfile) {
|
|
log_message("stage1: disconnecting life support systems");
|
|
fclose(logfile);
|
|
}
|
|
}
|
|
|
|
int redirect2log(int fd)
|
|
{
|
|
int rc;
|
|
if (!logfile) {
|
|
fprintf(stderr, "%s: log file is not open", __func__);
|
|
return -1;
|
|
}
|
|
rc = dup2(fileno(logfile), fd);
|
|
if (rc < 0) {
|
|
log_message("%s: dup2 %d: error: %s", __func__, fd, strerror(errno));
|
|
}
|
|
return rc;
|
|
}
|
|
|
|
int redirect2null(int fd)
|
|
{
|
|
int nullfd = -1, newfd = -1;
|
|
nullfd = open("/dev/null", O_RDONLY);
|
|
if (nullfd < 0) {
|
|
log_message("%s: open /dev/null: %s", __func__, strerror(errno));
|
|
goto out;
|
|
}
|
|
newfd = dup2(nullfd, fd);
|
|
if (newfd < 0) {
|
|
log_message("%s: dup2: %s", __func__, strerror(errno));
|
|
goto out;
|
|
}
|
|
out:
|
|
if (nullfd >= 0) {
|
|
close(nullfd);
|
|
}
|
|
return newfd;
|
|
}
|
|
|