From: Lionel Sambuc Date: Mon, 12 May 2014 14:30:43 +0000 (+0200) Subject: Message type for path related calls. X-Git-Tag: v3.3.0~304 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/mdoc.3.txt?a=commitdiff_plain;h=cef3ce969a794b40e41aa9f18a7cff13ad64cd64;p=minix.git Message type for path related calls. - Updated system calls VFS_ACCESS, VFS_CHDIR, VFS_CHMOD, VFS_CHROOT, VFS_MKDIR, VFS_OPEN, VFS_RMDIR, VSF_UNLINK - Removed M3_STRING and M3_LONG_STRING, which are tied to a specific "generic" message, and replaced where needed with M_PATH_STRING_MAX, which is tied to the mess_lc_vfs_path message. Change-Id: If287c74f5ece937b9431e5d95b5b58a3c83ebff1 --- diff --git a/include/minix/callnr.h b/include/minix/callnr.h index da1fbb8cc..565a4ed23 100644 --- a/include/minix/callnr.h +++ b/include/minix/callnr.h @@ -232,15 +232,6 @@ #define NR_VFS_CALLS 49 /* highest number from base plus one */ -/* Field names for the open(2), chdir(2), chmod(2), chroot(2), rmdir(2), and - * unlink(2) calls. - */ -#define VFS_PATH_NAME m3_p1 /* const char * */ -#define VFS_PATH_LEN m3_i1 /* size_t */ -#define VFS_PATH_FLAGS m3_i2 /* int */ -#define VFS_PATH_MODE m3_i2 /* mode_t */ -#define VFS_PATH_BUF m3_ca1 /* char[M3_STRING] */ - /* Field names for the creat(2) call. */ #define VFS_CREAT_NAME m1_p1 /* const char * */ #define VFS_CREAT_LEN m1_i1 /* size_t */ diff --git a/include/minix/ipc.h b/include/minix/ipc.h index ff4bce19d..0f5dffe24 100644 --- a/include/minix/ipc.h +++ b/include/minix/ipc.h @@ -13,8 +13,7 @@ #define M1 1 #define M3 3 #define M4 4 -#define M3_STRING 44 /* legacy m3_ca1 size (must not be changed) */ -#define M3_LONG_STRING 44 /* current m3_ca1 size (may be increased) */ +#define M_PATH_STRING_MAX 40 typedef struct { uint8_t data[56]; @@ -58,7 +57,7 @@ _ASSERT_MSG_SIZE(mess_2); typedef struct { int m3i1, m3i2; char *m3p1; - char m3ca1[M3_LONG_STRING]; + char m3ca1[44]; } mess_3; _ASSERT_MSG_SIZE(mess_3); @@ -242,6 +241,15 @@ typedef struct { } mess_lc_vfs_mount; _ASSERT_MSG_SIZE(mess_lc_vfs_mount); +typedef struct { + vir_bytes name; + size_t len; + int flags; + mode_t mode; + char buf[M_PATH_STRING_MAX]; +} mess_lc_vfs_path; +_ASSERT_MSG_SIZE(mess_lc_vfs_path); + typedef struct { int fd0; int fd1; @@ -807,6 +815,7 @@ typedef struct { mess_lc_vfs_lseek m_lc_vfs_lseek; mess_lc_vfs_mknod m_lc_vfs_mknod; mess_lc_vfs_mount m_lc_vfs_mount; + mess_lc_vfs_path m_lc_vfs_path; mess_lc_vfs_pipe2 m_lc_vfs_pipe2; mess_lc_vfs_readlink m_lc_vfs_readlink; mess_lc_vfs_select m_lc_vfs_select; diff --git a/lib/libc/sys-minix/access.c b/lib/libc/sys-minix/access.c index bc168adc2..addc6970f 100644 --- a/lib/libc/sys-minix/access.c +++ b/lib/libc/sys-minix/access.c @@ -12,7 +12,7 @@ int mode; message m; memset(&m, 0, sizeof(m)); - m.VFS_PATH_MODE = mode; + m.m_lc_vfs_path.mode = mode; _loadname(name, &m); return(_syscall(VFS_PROC_NR, VFS_ACCESS, &m)); } diff --git a/lib/libc/sys-minix/chmod.c b/lib/libc/sys-minix/chmod.c index c1bf04969..af7e52741 100644 --- a/lib/libc/sys-minix/chmod.c +++ b/lib/libc/sys-minix/chmod.c @@ -10,7 +10,7 @@ int chmod(const char *name, mode_t mode) message m; memset(&m, 0, sizeof(m)); - m.VFS_PATH_MODE = mode; + m.m_lc_vfs_path.mode = mode; _loadname(name, &m); return(_syscall(VFS_PROC_NR, VFS_CHMOD, &m)); } diff --git a/lib/libc/sys-minix/loadname.c b/lib/libc/sys-minix/loadname.c index 0cd4974df..a4187cd8b 100644 --- a/lib/libc/sys-minix/loadname.c +++ b/lib/libc/sys-minix/loadname.c @@ -13,7 +13,7 @@ void _loadname(const char *name, message *msgptr) register size_t k; k = strlen(name) + 1; - msgptr->VFS_PATH_LEN = k; - msgptr->VFS_PATH_NAME = (char *) __UNCONST(name); - if (k <= M3_STRING) strcpy(msgptr->VFS_PATH_BUF, name); + msgptr->m_lc_vfs_path.len = k; + msgptr->m_lc_vfs_path.name = (vir_bytes)name; + if (k <= M_PATH_STRING_MAX) strcpy(msgptr->m_lc_vfs_path.buf, name); } diff --git a/lib/libc/sys-minix/mkdir.c b/lib/libc/sys-minix/mkdir.c index 17196bc74..0ce1f47c3 100644 --- a/lib/libc/sys-minix/mkdir.c +++ b/lib/libc/sys-minix/mkdir.c @@ -10,7 +10,7 @@ int mkdir(const char *name, mode_t mode) message m; memset(&m, 0, sizeof(m)); - m.VFS_PATH_MODE = mode; + m.m_lc_vfs_path.mode = mode; _loadname(name, &m); return(_syscall(VFS_PROC_NR, VFS_MKDIR, &m)); } diff --git a/lib/libc/sys-minix/open.c b/lib/libc/sys-minix/open.c index d8ccfcdf3..7f5a6dd7e 100644 --- a/lib/libc/sys-minix/open.c +++ b/lib/libc/sys-minix/open.c @@ -25,7 +25,7 @@ int open(const char *name, int flags, ...) call = VFS_CREAT; } else { _loadname(name, &m); - m.VFS_PATH_FLAGS = flags; + m.m_lc_vfs_path.flags = flags; call = VFS_OPEN; } va_end(argp); diff --git a/lib/libusb/usb.c b/lib/libusb/usb.c index 3a67914a2..a6c8f6f6e 100644 --- a/lib/libusb/usb.c +++ b/lib/libusb/usb.c @@ -132,7 +132,7 @@ int usb_init(char *name) msg.m_type = USB_RQ_INIT; - strncpy(msg.USB_RB_INIT_NAME, name, M3_LONG_STRING); + strncpy(msg.USB_RB_INIT_NAME, name, M_PATH_STRING_MAX); res = ipc_sendrec(hcd_ep, &msg); diff --git a/servers/vfs/const.h b/servers/vfs/const.h index 9fbb6d2d0..0cce3cf1b 100644 --- a/servers/vfs/const.h +++ b/servers/vfs/const.h @@ -32,7 +32,7 @@ #define LABEL_MAX 16 /* maximum label size (including '\0'). Should * not be smaller than 16 or bigger than - * M3_LONG_STRING. + * M_PATH_STRING_MAX. */ #define FSTYPE_MAX VFS_NAMELEN /* maximum file system type size */ diff --git a/servers/vfs/open.c b/servers/vfs/open.c index 098726963..e60608d7c 100644 --- a/servers/vfs/open.c +++ b/servers/vfs/open.c @@ -42,7 +42,7 @@ int do_open(void) int open_flags; char fullpath[PATH_MAX]; - open_flags = job_m_in.VFS_PATH_FLAGS; + open_flags = job_m_in.m_lc_vfs_path.flags; if (open_flags & O_CREAT) return EINVAL; @@ -562,7 +562,7 @@ int do_mkdir(void) if (copy_path(fullpath, sizeof(fullpath)) != OK) return(err_code); - dirmode = (mode_t) job_m_in.VFS_PATH_MODE; + dirmode = job_m_in.m_lc_vfs_path.mode; lookup_init(&resolve, fullpath, PATH_NOFLAGS, &vmp, &vp); resolve.l_vmnt_lock = VMNT_WRITE; diff --git a/servers/vfs/protect.c b/servers/vfs/protect.c index 9beaecce7..98b20dbf1 100644 --- a/servers/vfs/protect.c +++ b/servers/vfs/protect.c @@ -44,7 +44,7 @@ int do_chmod(void) resolve.l_vnode_lock = VNODE_WRITE; if (job_call_nr == VFS_CHMOD) { - new_mode = job_m_in.VFS_PATH_MODE; + new_mode = job_m_in.m_lc_vfs_path.mode; /* Temporarily open the file */ if (copy_path(fullpath, sizeof(fullpath)) != OK) return(err_code); @@ -207,7 +207,7 @@ int do_access(void) struct lookup resolve; mode_t access; - access = job_m_in.VFS_PATH_MODE; + access = job_m_in.m_lc_vfs_path.mode; lookup_init(&resolve, fullpath, PATH_NOFLAGS, &vmp, &vp); resolve.l_vmnt_lock = VMNT_READ; diff --git a/servers/vfs/utility.c b/servers/vfs/utility.c index 4f4e4ed49..ce531096f 100644 --- a/servers/vfs/utility.c +++ b/servers/vfs/utility.c @@ -32,8 +32,8 @@ int copy_path(char *dest, size_t size) assert(size >= PATH_MAX); - name = (vir_bytes) job_m_in.VFS_PATH_NAME; - len = job_m_in.VFS_PATH_LEN; + name = job_m_in.m_lc_vfs_path.name; + len = job_m_in.m_lc_vfs_path.len; if (len > size) { /* 'len' includes terminating-nul */ err_code = ENAMETOOLONG; @@ -41,11 +41,11 @@ int copy_path(char *dest, size_t size) } /* Is the string contained in the message? If not, perform a normal copy. */ - if (len > M3_STRING) + if (len > M_PATH_STRING_MAX) return fetch_name(name, len, dest); /* Just copy the path from the message */ - strncpy(dest, job_m_in.VFS_PATH_BUF, len); + strncpy(dest, job_m_in.m_lc_vfs_path.buf, len); if (dest[len - 1] != '\0') { err_code = ENAMETOOLONG;