source: trunk/kernel/syscalls/sys_chmod.c @ 670

Last change on this file since 670 was 670, checked in by alain, 3 years 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
RevLine 
[1]1/*
[23]2 * sys_chmod.c - Change file access rights.
[302]3 *
[670]4 * Author       Alain Greiner  (2016,2017,2018,2019,2020)
[23]5 *
[1]6 * Copyright (c) 2015 UPMC Sorbonne Universites
7 *
[23]8 * This file is part of ALMOS-MKH.
[1]9 *
[23]10 * ALMOS-MKH is free software; you can redistribute it and/or modify it
[1]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 *
[23]14 * ALMOS-MKH is distributed in the hope that it will be useful, but
[1]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
[23]20 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
[1]21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
[457]24#include <hal_kernel_types.h>
[23]25#include <hal_uspace.h>
[1]26#include <vfs.h>
[23]27#include <vmm.h>
28#include <printk.h>
[1]29#include <thread.h>
[23]30#include <process.h>
[506]31#include <syscalls.h>
32
[566]33///////////////////////////////////
34int sys_chmod( char     * pathname,
35               uint32_t   rights __attribute__((unused)) )
[1]36{
[23]37    char        kbuf[CONFIG_VFS_MAX_PATH_LENGTH];
[1]38
[302]39    thread_t  * this    = CURRENT_THREAD;
[1]40
[670]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
[407]46    // check pathname length
47    if( hal_strlen_from_uspace( pathname ) >= CONFIG_VFS_MAX_PATH_LENGTH )
[23]48    {
[566]49
50#if DEBUG_SYSCALLS_ERROR
[670]51if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start )
52printk("\n[ERROR] in %s : thread[%x,%x] / pathname too long\n",
[637]53__FUNCTION__, this->trdid, process->pid );
[566]54#endif
[302]55        this->errno = ENFILE;
[23]56        return -1;
57    }
58
[407]59    // copy pathname in kernel space
[637]60    hal_strcpy_from_uspace( XPTR( local_cxy , kbuf ),
61                            pathname,
62                            CONFIG_VFS_MAX_PATH_LENGTH );
[407]63
[670]64
65
66
[566]67    printk("\n[ERROR] in %s : not implemented yet\n", __FUNCTION__ );
68    return -1;
69
[23]70
71
72
[670]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
[302]90    return 0;
91
92}  // end sys_chmod()
Note: See TracBrowser for help on using the repository browser.