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
This commit is contained in:
parent
96b3577b2c
commit
cef3ce969a
12 changed files with 29 additions and 29 deletions
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue