/* Open Group Base Specifications Issue 6 (not complete) */
typedef long useconds_t; /* Time in microseconds */
-typedef short dev_t; /* holds (major|minor) device pair */
+typedef u32_t dev_t; /* holds (major|minor) device pair */
typedef u32_t big_dev_t;
/* Types used in disk, inode, etc. data structures.
#define NWIOSUDSBLOG _IOW ('n', 73, int) /* listen() */
#define NWIOSUDSCONN _IOW ('n', 74, struct sockaddr_un) /* connect() */
#define NWIOSUDSSHUT _IOW ('n', 75, int) /* shutdown() */
+#define NWIOSUDSPAIROLD _IOW ('n', 76, short) /* socketpair() */
#define NWIOSUDSPAIR _IOW ('n', 76, dev_t) /* socketpair() */
#define NWIOSUDSACCEPT _IOW ('n', 77, struct sockaddr_un) /* accept() */
#define NWIOSUDSCTRL _IOW ('n', 78, struct msg_control) /* sendmsg() */
struct minix_prev_stat {
- dev_t st_dev; /* major/minor device number */
+ short st_dev; /* major/minor device number */
ino_t st_ino; /* i-node number */
mode_t st_mode; /* file mode, protection bits, etc. */
nlink_t st_nlink; /* # links; */
uid_t st_uid; /* uid of the file's owner */
short int st_gid; /* gid; TEMPORARY HACK: should be gid_t */
- dev_t st_rdev;
+ short st_rdev;
off_t st_size; /* file size */
time_t st_atime; /* time of last access */
time_t st_mtime; /* time of last data modification */
#define NWIOSUDSCONN _IOW ('n', 74, struct sockaddr_un) /* connect() */
#define NWIOSUDSSHUT _IOW ('n', 75, int) /* shutdown() */
#define NWIOSUDSPAIR _IOW ('n', 76, dev_t) /* socketpair() */
+#define NWIOSUDSPAIROLD _IOW ('n', 76, short) /* socketpair() */
#define NWIOSUDSACCEPT _IOW ('n', 77, struct sockaddr_un) /* accept() */
#define NWIOSUDSCTRL _IOW ('n', 78, struct msg_control) /* sendmsg() */
#define NWIOGUDSCTRL _IORW('n', 79, struct msg_control) /* recvmsg() */
struct minix_prev_stat {
- dev_t st_dev; /* major/minor device number */
+ short st_dev; /* major/minor device number */
ino_t st_ino; /* i-node number */
mode_t st_mode; /* file mode, protection bits, etc. */
nlink_t st_nlink; /* # links; */
uid_t st_uid; /* uid of the file's owner */
short int st_gid; /* gid; TEMPORARY HACK: should be gid_t */
- dev_t st_rdev;
+ short st_rdev;
off_t st_size; /* file size */
time_t st_atime; /* time of last access */
time_t st_mtime; /* time of last data modification */
#endif
-typedef short dev_t; /* device number */
+typedef uint32_t dev_t; /* device number */
typedef uint32_t fixpt_t; /* fixed point number */
#ifndef gid_t
break;
+ case NWIOSUDSPAIROLD:
+
+ /* connect two sockets -- socketpair() */
+ rc = do_socketpair_old(dev_m_in, dev_m_out);
+
+ break;
+
case NWIOGUDSSOTYPE:
/* get socket type -- getsockopt(SO_TYPE) */
_PROTOTYPE( int do_getpeername, (message *dev_m_in, message *dev_m_out) );
_PROTOTYPE( int do_shutdown, (message *dev_m_in, message *dev_m_out) );
_PROTOTYPE( int do_socketpair, (message *dev_m_in, message *dev_m_out) );
+_PROTOTYPE( int do_socketpair_old, (message *dev_m_in, message *dev_m_out) );
_PROTOTYPE( int do_getsockopt_sotype,
(message *dev_m_in, message *dev_m_out) );
_PROTOTYPE( int do_getsockopt_peercred,
return OK;
}
+PUBLIC int do_socketpair_old(message *dev_m_in, message *dev_m_out)
+{
+ int rc;
+ short minorin;
+ int minorx, minory;
+ struct sockaddr_un addr;
+
+#if DEBUG == 1
+ static int call_count = 0;
+ printf("(uds) [%d] do_socketpair() call_count=%d\n",
+ uds_minor(dev_m_in), ++call_count);
+#endif
+
+ /* first ioctl param is the first socket */
+ minorx = uds_minor_old(dev_m_in);
+
+ /* third ioctl param is the minor number of the second socket */
+ rc = sys_safecopyfrom(VFS_PROC_NR, (cp_grant_id_t) dev_m_in->IO_GRANT,
+ (vir_bytes) 0, (vir_bytes) &minorin, sizeof(short), D);
+
+ if (rc != OK) {
+ return EIO;
+ }
+
+ minory = minor(minorin);
+
+#if DEBUG == 1
+ printf("socketpair() %d - %d\n", minorx, minory);
+#endif
+
+ /* security check - both sockets must have the same endpoint (owner) */
+ if (uds_fd_table[minorx].owner != uds_fd_table[minory].owner) {
+
+ /* we won't allow you to magically connect your socket to
+ * someone elses socket
+ */
+ return EPERM;
+ }
+
+ addr.sun_family = AF_UNIX;
+ addr.sun_path[0] = 'X';
+ addr.sun_path[1] = '\0';
+
+ uds_fd_table[minorx].syscall_done = 1;
+ return perform_connection(dev_m_in, dev_m_out, &addr, minorx, minory);
+}
+
PUBLIC int do_socketpair(message *dev_m_in, message *dev_m_out)
{
int rc;
return EIO;
}
- minory = (minor(minorin) & BYTE);
+ minory = minor(minorin);
#if DEBUG == 1
printf("socketpair() %d - %d\n", minorx, minory);
/*
* Take message m and get the index in uds_fd_table.
*/
-#define uds_minor(m) (minor((dev_t) m->DEVICE) & BYTE)
+#define uds_minor(m) (minor((dev_t) m->DEVICE))
+#define uds_minor_old(m) (minor((short) m->DEVICE))
/*
* Fill in a reply message.
struct stat st;
dev_t dev;
- dev= (ip_dev & 0xFF00) | minor;
+ dev= makedev(major(ip_dev), minor);
if (stat(device, &st) < 0) {
if (errno != ENOENT) fatal(device);
}
if (mknod(device, S_IFCHR | mode, dev) < 0) fatal(device);
- printf("mknod %s c %d %d\n", device, (ip_dev >> 8), minor);
+ printf("mknod %s c %d %d\n", device, major(ip_dev), minor);
}
static void check_ln(char *old, char *new)
break;
+ case NWIOSUDSPAIROLD:
+
+ /* connect two sockets -- socketpair() */
+ rc = do_socketpair_old(dev_m_in, dev_m_out);
+
+ break;
+
case NWIOGUDSSOTYPE:
/* get socket type -- getsockopt(SO_TYPE) */
_PROTOTYPE( int do_getpeername, (message *dev_m_in, message *dev_m_out) );
_PROTOTYPE( int do_shutdown, (message *dev_m_in, message *dev_m_out) );
_PROTOTYPE( int do_socketpair, (message *dev_m_in, message *dev_m_out) );
+_PROTOTYPE( int do_socketpair_old, (message *dev_m_in, message *dev_m_out) );
_PROTOTYPE( int do_getsockopt_sotype,
(message *dev_m_in, message *dev_m_out) );
_PROTOTYPE( int do_getsockopt_peercred,
return OK;
}
+PUBLIC int do_socketpair_old(message *dev_m_in, message *dev_m_out)
+{
+ int rc;
+ short minorin;
+ int minorx, minory;
+ struct sockaddr_un addr;
+
+#if DEBUG == 1
+ static int call_count = 0;
+ printf("(uds) [%d] do_socketpair() call_count=%d\n",
+ uds_minor(dev_m_in), ++call_count);
+#endif
+
+ /* first ioctl param is the first socket */
+ minorx = uds_minor_old(dev_m_in);
+
+ /* third ioctl param is the minor number of the second socket */
+ rc = sys_safecopyfrom(VFS_PROC_NR, (cp_grant_id_t) dev_m_in->IO_GRANT,
+ (vir_bytes) 0, (vir_bytes) &minorin, sizeof(short), D);
+
+ if (rc != OK) {
+ return EIO;
+ }
+
+ minory = minor(minorin);
+
+#if DEBUG == 1
+ printf("socketpair() %d - %d\n", minorx, minory);
+#endif
+
+ /* security check - both sockets must have the same endpoint (owner) */
+ if (uds_fd_table[minorx].owner != uds_fd_table[minory].owner) {
+
+ /* we won't allow you to magically connect your socket to
+ * someone elses socket
+ */
+ return EPERM;
+ }
+
+ addr.sun_family = AF_UNIX;
+ addr.sun_path[0] = 'X';
+ addr.sun_path[1] = '\0';
+
+ uds_fd_table[minorx].syscall_done = 1;
+ return perform_connection(dev_m_in, dev_m_out, &addr, minorx, minory);
+}
+
PUBLIC int do_socketpair(message *dev_m_in, message *dev_m_out)
{
int rc;
return EIO;
}
- minory = (minor(minorin) & BYTE);
+ minory = minor(minorin);
#if DEBUG == 1
printf("socketpair() %d - %d\n", minorx, minory);
/*
* Take message m and get the index in uds_fd_table.
*/
-#define uds_minor(m) (minor((dev_t) m->DEVICE) & BYTE)
+#define uds_minor(m) (minor((dev_t) m->DEVICE))
+#define uds_minor_old(m) (minor((short) m->DEVICE))
/*
* Fill in a reply message.