static char *read_cmdline (void);
-/* Also in guestfs.c */
-#define GUESTFWD_ADDR "10.0.2.4"
-#define GUESTFWD_PORT "6666"
+/* This is the default address we connect to for very old libraries
+ * which didn't specify the address and port number explicitly on the
+ * kernel command line. It's now recommended to always specify the
+ * address and port number on the command line, so this will not be
+ * used any more.
+ */
+#define OLD_GUESTFWD_ADDR "10.0.2.4"
+#define OLD_GUESTFWD_PORT "6666"
/* This is only a hint. If not defined, ignore it. */
#ifndef AI_ADDRCONFIG
setenv ("PATH", "/sbin:/usr/sbin:/bin:/usr/bin", 1);
setenv ("SHELL", "/bin/sh", 1);
setenv ("LC_ALL", "C", 1);
+ setenv ("TERM", "dumb", 1);
#ifndef WIN32
/* We document that umask defaults to 022 (it should be this anyway). */
/* Default vmchannel. */
if (vmchannel == NULL) {
- vmchannel = strdup ("tcp:" GUESTFWD_ADDR ":" GUESTFWD_PORT);
+ vmchannel = strdup ("tcp:" OLD_GUESTFWD_ADDR ":" OLD_GUESTFWD_PORT);
if (!vmchannel) {
perror ("strdup");
exit (EXIT_FAILURE);
* the device nodes themselves will exist in the appliance.
*/
int
-device_name_translation (char *device, const char *func)
+device_name_translation (char *device)
{
int fd;
fd = open (device, O_RDONLY);
if (fd >= 0) {
+ close_ok:
close (fd);
return 0;
}
- if (errno != ENXIO && errno != ENOENT) {
- error:
- reply_with_perror ("%s: %s", func, device);
+ if (errno != ENXIO && errno != ENOENT)
return -1;
- }
/* If the name begins with "/dev/sd" then try the alternatives. */
if (STRNEQLEN (device, "/dev/sd", 7))
- goto error;
+ return -1;
device[5] = 'h'; /* /dev/hd (old IDE driver) */
fd = open (device, O_RDONLY);
- if (fd >= 0) {
- close (fd);
- return 0;
- }
+ if (fd >= 0)
+ goto close_ok;
device[5] = 'v'; /* /dev/vd (for virtio devices) */
fd = open (device, O_RDONLY);
- if (fd >= 0) {
- close (fd);
- return 0;
- }
+ if (fd >= 0)
+ goto close_ok;
device[5] = 's'; /* Restore original device name. */
- goto error;
+ return -1;
}
/* Check program exists and is executable on $PATH. Actually, we