Make dev_t 32-bits and provide backwards compatibility

This commit is contained in:
Thomas Veerman
2011-08-31 13:38:28 +00:00
parent e68cf3bf89
commit fde9a258d0
15 changed files with 126 additions and 12 deletions

View File

@@ -855,6 +855,13 @@ PUBLIC int uds_ioctl(message *dev_m_in, message *dev_m_out)
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) */

View File

@@ -80,6 +80,7 @@ _PROTOTYPE( int do_getsockname, (message *dev_m_in, message *dev_m_out) );
_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,

View File

@@ -882,6 +882,53 @@ PUBLIC int do_shutdown(message *dev_m_in, message *dev_m_out)
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;
@@ -906,7 +953,7 @@ PUBLIC int do_socketpair(message *dev_m_in, message *dev_m_out)
return EIO;
}
minory = (minor(minorin) & BYTE);
minory = minor(minorin);
#if DEBUG == 1
printf("socketpair() %d - %d\n", minorx, minory);

View File

@@ -224,7 +224,8 @@ EXTERN uds_fd_t uds_fd_table[NR_FDS];
/*
* 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.

View File

@@ -67,7 +67,7 @@ static void check_mknod(char *device, mode_t mode, int minor)
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);
@@ -77,7 +77,7 @@ static void check_mknod(char *device, mode_t mode, int minor)
}
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)

View File

@@ -865,6 +865,13 @@ PUBLIC int uds_ioctl(message *dev_m_in, message *dev_m_out)
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) */

View File

@@ -77,6 +77,7 @@ _PROTOTYPE( int do_getsockname, (message *dev_m_in, message *dev_m_out) );
_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,

View File

@@ -884,6 +884,53 @@ PUBLIC int do_shutdown(message *dev_m_in, message *dev_m_out)
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;
@@ -908,7 +955,7 @@ PUBLIC int do_socketpair(message *dev_m_in, message *dev_m_out)
return EIO;
}
minory = (minor(minorin) & BYTE);
minory = minor(minorin);
#if DEBUG == 1
printf("socketpair() %d - %d\n", minorx, minory);

View File

@@ -224,7 +224,8 @@ EXTERN uds_fd_t uds_fd_table[NR_FDS];
/*
* 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.