source: trunk/kernel/syscalls/sys_chmod.c

Last change on this file was 670, checked in by alain, 14 months ago

1) Introduce up to 4 command lines arguments in the KSH "load" command.
These arguments are transfered to the user process through the
argc/argv mechanism, using the user space "args" vseg.

2) Introduce the named and anonymous "pipes", for inter-process communication
through the pipe() and mkfifo() syscalls.

3) Introduce the "chat" application to validate the two above mechanisms.

4) Improve printk() and assert() fonctions in printk.c.

File size: 2.5 KB
Line 
1/*
2 * sys_chmod.c - Change file access rights.
3 *
4 * Author       Alain Greiner  (2016,2017,2018,2019,2020)
5 *
6 * Copyright (c) 2015 UPMC Sorbonne Universites
7 *
8 * This file is part of ALMOS-MKH.
9 *
10 * ALMOS-MKH is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 2.0 of the License.
13 *
14 * ALMOS-MKH is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#include <hal_kernel_types.h>
25#include <hal_uspace.h>
26#include <vfs.h>
27#include <vmm.h>
28#include <printk.h>
29#include <thread.h>
30#include <process.h>
31#include <syscalls.h>
32
33///////////////////////////////////
34int sys_chmod( char     * pathname,
35               uint32_t   rights __attribute__((unused)) )
36{
37    char        kbuf[CONFIG_VFS_MAX_PATH_LENGTH];
38
39    thread_t  * this    = CURRENT_THREAD;
40
41#if DEBUG_SYS_CHMOD || DEBUG_SYSCALLS_ERROR || CONFIG_INSTRUMENTATION_SYSCALLS
42process_t * process  = this->process;
43uint64_t    tm_start = hal_get_cycles();
44#endif
45
46    // check pathname length
47    if( hal_strlen_from_uspace( pathname ) >= CONFIG_VFS_MAX_PATH_LENGTH )
48    {
49
50#if DEBUG_SYSCALLS_ERROR
51if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start )
52printk("\n[ERROR] in %s : thread[%x,%x] / pathname too long\n",
53__FUNCTION__, this->trdid, process->pid );
54#endif
55        this->errno = ENFILE;
56        return -1;
57    }
58
59    // copy pathname in kernel space
60    hal_strcpy_from_uspace( XPTR( local_cxy , kbuf ),
61                            pathname,
62                            CONFIG_VFS_MAX_PATH_LENGTH );
63
64
65
66
67    printk("\n[ERROR] in %s : not implemented yet\n", __FUNCTION__ );
68    return -1;
69
70
71
72
73    hal_fence();
74
75#if (DEBUG_SYS_CHMOD || CONFIG_INSTRUMENTATION_SYSCALLS)
76uint64_t     tm_end = hal_get_cycles();
77#endif
78
79#if DEBUG_SYS_CHMOD
80if( DEBUG_SYS_CHMOD < tm_end )
81printk("\n[%s] thread[%x,%x] exit for / cycle %d\n",
82__FUNCTION__, process->pid, this->trdid, (uint32_t)tm_end );
83#endif
84 
85#if CONFIG_INSTRUMENTATION_SYSCALLS
86hal_atomic_add( &syscalls_cumul_cost[SYS_CHMOD] , tm_end - tm_start );
87hal_atomic_add( &syscalls_occurences[SYS_CHMOD] , 1 );
88#endif
89
90    return 0;
91
92}  // end sys_chmod()
Note: See TracBrowser for help on using the repository browser.