2015-06-09 Gary Benson <gbenson@redhat.com>
+ * common/fileio.h (fileio_to_host_mode): New declaration.
+ * common/fileio.c (fileio_to_host_mode): New Function.
+ * inf-child.c (inf_child_fileio_open): Process mode argument
+ with fileio_to_host_mode.
+
+2015-06-09 Gary Benson <gbenson@redhat.com>
+
* common/fileio.c (fileio_mode_pack): Fix preprocessor
conditional.
return 0;
}
+/* See fileio.h. */
+
+int
+fileio_to_host_mode (int fileio_mode, mode_t *mode_p)
+{
+ mode_t mode = 0;
+
+ if (fileio_mode & ~FILEIO_S_SUPPORTED)
+ return -1;
+
+ if (fileio_mode & FILEIO_S_IFREG)
+ mode |= S_IFREG;
+ if (fileio_mode & FILEIO_S_IFDIR)
+ mode |= S_IFDIR;
+ if (fileio_mode & FILEIO_S_IFCHR)
+ mode |= S_IFCHR;
+ if (fileio_mode & FILEIO_S_IRUSR)
+ mode |= S_IRUSR;
+ if (fileio_mode & FILEIO_S_IWUSR)
+ mode |= S_IWUSR;
+ if (fileio_mode & FILEIO_S_IXUSR)
+ mode |= S_IXUSR;
+#ifdef S_IRGRP
+ if (fileio_mode & FILEIO_S_IRGRP)
+ mode |= S_IRGRP;
+#endif
+#ifdef S_IWGRP
+ if (fileio_mode & FILEIO_S_IWGRP)
+ mode |= S_IWGRP;
+#endif
+#ifdef S_IXGRP
+ if (fileio_mode & FILEIO_S_IXGRP)
+ mode |= S_IXGRP;
+#endif
+ if (fileio_mode & FILEIO_S_IROTH)
+ mode |= S_IROTH;
+#ifdef S_IWOTH
+ if (fileio_mode & FILEIO_S_IWOTH)
+ mode |= S_IWOTH;
+#endif
+#ifdef S_IXOTH
+ if (fileio_mode & FILEIO_S_IXOTH)
+ mode |= S_IXOTH;
+#endif
+
+ *mode_p = mode;
+ return 0;
+}
+
/* Convert a host-format mode_t into a bitmask of File-I/O flags. */
static LONGEST
extern int fileio_to_host_openflags (int fflags, int *flags);
+/* Convert File-I/O mode FMODE to host format, storing
+ the result in *MODE. Return 0 on success, -1 on error. */
+
+extern int fileio_to_host_mode (int fmode, mode_t *mode);
+
/* Pack a host-format integer into a byte buffer in big-endian
format. BYTES specifies the size of the integer to pack in
bytes. */
+2015-06-09 Gary Benson <gbenson@redhat.com>
+
+ * hostio.c (handle_open): Process mode argument with
+ fileio_to_host_mode.
+
2015-06-01 Yao Qi <yao.qi@linaro.org>
* linux-s390-low.c (PTRACE_GETREGSET, PTRACE_SETREGSET): Remove.
{
char filename[HOSTIO_PATH_MAX];
char *p;
- int fileio_flags, mode, flags, fd;
+ int fileio_flags, fileio_mode, flags, fd;
+ mode_t mode;
struct fd_list *new_fd;
p = own_buf + strlen ("vFile:open:");
|| require_comma (&p)
|| require_int (&p, &fileio_flags)
|| require_comma (&p)
- || require_int (&p, &mode)
+ || require_int (&p, &fileio_mode)
|| require_end (p)
- || fileio_to_host_openflags (fileio_flags, &flags))
+ || fileio_to_host_openflags (fileio_flags, &flags)
+ || fileio_to_host_mode (fileio_mode, &mode))
{
hostio_packet_error (own_buf);
return;
int *target_errno)
{
int nat_flags;
+ mode_t nat_mode;
int fd;
- if (fileio_to_host_openflags (flags, &nat_flags) == -1)
+ if (fileio_to_host_openflags (flags, &nat_flags) == -1
+ || fileio_to_host_mode (mode, &nat_mode) == -1)
{
*target_errno = FILEIO_EINVAL;
return -1;
}
- /* We do not need to convert MODE, since the fileio protocol uses
- the standard values. */
- fd = gdb_open_cloexec (filename, nat_flags, mode);
+ fd = gdb_open_cloexec (filename, nat_flags, nat_mode);
if (fd == -1)
*target_errno = host_to_fileio_error (errno);