+2015-04-09 Gary Benson <gbenson@redhat.com>
+
+ * common/common-remote-fileio.h (remote_fileio_to_fio_error):
+ New declaration.
+ * common/common-remote-fileio.c (remote_fileio_to_fio_error):
+ New function, factored out the named functions below.
+ * inf-child.c (gdb/fileio.h): Remove include.
+ (common-remote-fileio.h): New include.
+ (inf_child_errno_to_fileio_error): Remove function. Update
+ all callers to use remote_fileio_to_fio_error.
+ * remote-fileio.c (remote_fileio_errno_to_target): Likewise.
+
2015-04-09 Andy Wingo <wingo@igalia.com>
* MAINTAINERS (Write After Approval): Add Andy Wingo.
#include "common-remote-fileio.h"
#include <sys/stat.h>
+/* See common-remote-fileio.h. */
+
+int
+remote_fileio_to_fio_error (int error)
+{
+ switch (error)
+ {
+ case EPERM:
+ return FILEIO_EPERM;
+ case ENOENT:
+ return FILEIO_ENOENT;
+ case EINTR:
+ return FILEIO_EINTR;
+ case EIO:
+ return FILEIO_EIO;
+ case EBADF:
+ return FILEIO_EBADF;
+ case EACCES:
+ return FILEIO_EACCES;
+ case EFAULT:
+ return FILEIO_EFAULT;
+ case EBUSY:
+ return FILEIO_EBUSY;
+ case EEXIST:
+ return FILEIO_EEXIST;
+ case ENODEV:
+ return FILEIO_ENODEV;
+ case ENOTDIR:
+ return FILEIO_ENOTDIR;
+ case EISDIR:
+ return FILEIO_EISDIR;
+ case EINVAL:
+ return FILEIO_EINVAL;
+ case ENFILE:
+ return FILEIO_ENFILE;
+ case EMFILE:
+ return FILEIO_EMFILE;
+ case EFBIG:
+ return FILEIO_EFBIG;
+ case ENOSPC:
+ return FILEIO_ENOSPC;
+ case ESPIPE:
+ return FILEIO_ESPIPE;
+ case EROFS:
+ return FILEIO_EROFS;
+ case ENOSYS:
+ return FILEIO_ENOSYS;
+ case ENAMETOOLONG:
+ return FILEIO_ENAMETOOLONG;
+ }
+ return FILEIO_EUNKNOWN;
+}
+
/* Convert a host-format mode_t into a bitmask of File-I/O flags. */
static LONGEST
#include "gdb/fileio.h"
#include <sys/stat.h>
+/* Convert a errno error number to a File-I/O error number for
+ transmission over the remote protocol. */
+
+extern int remote_fileio_to_fio_error (int error);
+
/* Pack a host-format integer into a byte buffer in big-endian format
ready for transmission over the remote protocol. BYTES specifies
the size of the integer to pack in bytes. */
+2015-04-09 Gary Benson <gbenson@redhat.com>
+
+ * hostio-errno.c (errno_to_fileio_error): Remove function.
+ Update caller to use remote_fileio_to_fio_error.
+
2015-04-09 Yao Qi <yao.qi@linaro.org>
* linux-low.c (linux_insert_point): Call
on top of errno. */
#include "server.h"
-#include "gdb/fileio.h"
-
-static int
-errno_to_fileio_error (int error)
-{
- switch (error)
- {
- case EPERM:
- return FILEIO_EPERM;
- case ENOENT:
- return FILEIO_ENOENT;
- case EINTR:
- return FILEIO_EINTR;
- case EIO:
- return FILEIO_EIO;
- case EBADF:
- return FILEIO_EBADF;
- case EACCES:
- return FILEIO_EACCES;
- case EFAULT:
- return FILEIO_EFAULT;
- case EBUSY:
- return FILEIO_EBUSY;
- case EEXIST:
- return FILEIO_EEXIST;
- case ENODEV:
- return FILEIO_ENODEV;
- case ENOTDIR:
- return FILEIO_ENOTDIR;
- case EISDIR:
- return FILEIO_EISDIR;
- case EINVAL:
- return FILEIO_EINVAL;
- case ENFILE:
- return FILEIO_ENFILE;
- case EMFILE:
- return FILEIO_EMFILE;
- case EFBIG:
- return FILEIO_EFBIG;
- case ENOSPC:
- return FILEIO_ENOSPC;
- case ESPIPE:
- return FILEIO_ESPIPE;
- case EROFS:
- return FILEIO_EROFS;
- case ENOSYS:
- return FILEIO_ENOSYS;
- case ENAMETOOLONG:
- return FILEIO_ENAMETOOLONG;
- }
-
- return FILEIO_EUNKNOWN;
-}
+#include "common-remote-fileio.h"
void
hostio_last_error_from_errno (char *buf)
{
int error = errno;
- int fileio_error = errno_to_fileio_error (error);
+ int fileio_error = remote_fileio_to_fio_error (error);
sprintf (buf, "F-1,%x", fileio_error);
}
#include "inferior.h"
#include <sys/stat.h>
#include "inf-child.h"
-#include "gdb/fileio.h"
+#include "common-remote-fileio.h"
#include "agent.h"
#include "gdb_wait.h"
#include "filestuff.h"
return 0;
}
-static int
-inf_child_errno_to_fileio_error (int errnum)
-{
- switch (errnum)
- {
- case EPERM:
- return FILEIO_EPERM;
- case ENOENT:
- return FILEIO_ENOENT;
- case EINTR:
- return FILEIO_EINTR;
- case EIO:
- return FILEIO_EIO;
- case EBADF:
- return FILEIO_EBADF;
- case EACCES:
- return FILEIO_EACCES;
- case EFAULT:
- return FILEIO_EFAULT;
- case EBUSY:
- return FILEIO_EBUSY;
- case EEXIST:
- return FILEIO_EEXIST;
- case ENODEV:
- return FILEIO_ENODEV;
- case ENOTDIR:
- return FILEIO_ENOTDIR;
- case EISDIR:
- return FILEIO_EISDIR;
- case EINVAL:
- return FILEIO_EINVAL;
- case ENFILE:
- return FILEIO_ENFILE;
- case EMFILE:
- return FILEIO_EMFILE;
- case EFBIG:
- return FILEIO_EFBIG;
- case ENOSPC:
- return FILEIO_ENOSPC;
- case ESPIPE:
- return FILEIO_ESPIPE;
- case EROFS:
- return FILEIO_EROFS;
- case ENOSYS:
- return FILEIO_ENOSYS;
- case ENAMETOOLONG:
- return FILEIO_ENAMETOOLONG;
- }
- return FILEIO_EUNKNOWN;
-}
-
/* Open FILENAME on the target, using FLAGS and MODE. Return a
target file descriptor, or -1 if an error occurs (and set
*TARGET_ERRNO). */
the standard values. */
fd = gdb_open_cloexec (filename, nat_flags, mode);
if (fd == -1)
- *target_errno = inf_child_errno_to_fileio_error (errno);
+ *target_errno = remote_fileio_to_fio_error (errno);
return fd;
}
}
if (ret == -1)
- *target_errno = inf_child_errno_to_fileio_error (errno);
+ *target_errno = remote_fileio_to_fio_error (errno);
return ret;
}
}
if (ret == -1)
- *target_errno = inf_child_errno_to_fileio_error (errno);
+ *target_errno = remote_fileio_to_fio_error (errno);
return ret;
}
ret = fstat (fd, sb);
if (ret == -1)
- *target_errno = inf_child_errno_to_fileio_error (errno);
+ *target_errno = remote_fileio_to_fio_error (errno);
return ret;
}
ret = close (fd);
if (ret == -1)
- *target_errno = inf_child_errno_to_fileio_error (errno);
+ *target_errno = remote_fileio_to_fio_error (errno);
return ret;
}
ret = unlink (filename);
if (ret == -1)
- *target_errno = inf_child_errno_to_fileio_error (errno);
+ *target_errno = remote_fileio_to_fio_error (errno);
return ret;
}
len = readlink (filename, buf, sizeof buf);
if (len < 0)
{
- *target_errno = inf_child_errno_to_fileio_error (errno);
+ *target_errno = remote_fileio_to_fio_error (errno);
return NULL;
}
}
static int
-remote_fileio_errno_to_target (int error)
-{
- switch (error)
- {
- case EPERM:
- return FILEIO_EPERM;
- case ENOENT:
- return FILEIO_ENOENT;
- case EINTR:
- return FILEIO_EINTR;
- case EIO:
- return FILEIO_EIO;
- case EBADF:
- return FILEIO_EBADF;
- case EACCES:
- return FILEIO_EACCES;
- case EFAULT:
- return FILEIO_EFAULT;
- case EBUSY:
- return FILEIO_EBUSY;
- case EEXIST:
- return FILEIO_EEXIST;
- case ENODEV:
- return FILEIO_ENODEV;
- case ENOTDIR:
- return FILEIO_ENOTDIR;
- case EISDIR:
- return FILEIO_EISDIR;
- case EINVAL:
- return FILEIO_EINVAL;
- case ENFILE:
- return FILEIO_ENFILE;
- case EMFILE:
- return FILEIO_EMFILE;
- case EFBIG:
- return FILEIO_EFBIG;
- case ENOSPC:
- return FILEIO_ENOSPC;
- case ESPIPE:
- return FILEIO_ESPIPE;
- case EROFS:
- return FILEIO_EROFS;
- case ENOSYS:
- return FILEIO_ENOSYS;
- case ENAMETOOLONG:
- return FILEIO_ENAMETOOLONG;
- }
- return FILEIO_EUNKNOWN;
-}
-
-static int
remote_fileio_seek_flag_to_host (long num, int *flag)
{
if (!flag)
remote_fileio_return_errno (int retcode)
{
remote_fileio_reply (retcode, retcode < 0
- ? remote_fileio_errno_to_target (errno) : 0);
+ ? remote_fileio_to_fio_error (errno) : 0);
}
static void