Ignore:
Timestamp:
Dec 3, 2018, 12:18:40 PM (6 years ago)
Author:
alain
Message:

Improve the FAT32 file system to support cat, rm, cp commands.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/syscalls/sys_unlink.c

    r566 r604  
    11/*
    2  * sys_unlink.c - file unlink
     2 * sys_unlink.c - file unlink a file
    33 *
    4  * Copyright (c) 2008,2009,2010,2011,2012 Ghassan Almaless
    5  * Copyright (c) 2011,2012 UPMC Sorbonne Universites
     4 * Author     Alain Greiner (2016,2017,2018)
     5 *
     6 * Copyright (c)  UPMC Sorbonne Universites
    67 *
    78 * This file is part of ALMOS-kernel.
    89 *
    9  * ALMOS-kernel is free software; you can redistribute it and/or modify it
     10 * ALMOS-MKH is free software; you can redistribute it and/or modify it
    1011 * under the terms of the GNU General Public License as published by
    1112 * the Free Software Foundation; version 2.0 of the License.
    1213 *
    13  * ALMOS-kernel is distributed in the hope that it will be useful, but
     14 * ALMOS-MKH is distributed in the hope that it will be useful, but
    1415 * WITHOUT ANY WARRANTY; without even the implied warranty of
    1516 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     
    1718 *
    1819 * You should have received a copy of the GNU General Public License
    19  * along with ALMOS-kernel; if not, write to the Free Software Foundation,
     20 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
    2021 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
    2122 */
    2223
     24#include <kernel_config.h>
    2325#include <hal_kernel_types.h>
    2426#include <hal_uspace.h>
     27#include <errno.h>
    2528#include <vfs.h>
    2629#include <process.h>
     
    3942    process_t    * process  = this->process;
    4043
     44#if (DEBUG_SYS_UNLINK || CONFIG_INSTRUMENTATION_SYSCALLS)
     45uint64_t     tm_start = hal_get_cycles();
     46#endif
     47
    4148    // check pathname length
    4249    if( hal_strlen_from_uspace( pathname ) >= CONFIG_VFS_MAX_PATH_LENGTH )
    4350    {
    44         printk("\n[ERROR] in %s : pathname too long\n", __FUNCTION__ );
     51
     52#if DEBUG_SYSCALLS_ERROR
     53printk("\n[ERROR] in %s : pathname too long\n", __FUNCTION__ );
     54#endif
    4555        this->errno = ENFILE;
    4656        return -1;
     
    5060    hal_strcpy_from_uspace( kbuf , pathname , CONFIG_VFS_MAX_PATH_LENGTH );
    5161
     62#if DEBUG_SYS_UNLINK
     63if( DEBUG_SYS_UNLINK < tm_start )
     64printk("\n[%s] thread[%x,%x] enter for <%s> / cycle %d\n",
     65__FUNCTION__, process->pid, this->trdid, kbuf, (uint32_t)tm_start );
     66#endif
     67 
    5268    // get cluster and local pointer on reference process
    5369    xptr_t      ref_xp  = process->ref_xp;
     
    6985    if( error )
    7086    {
    71         printk("\n[ERROR] in %s : cannot unlink file/dir %s\n",
    72                __FUNCTION__ , pathname );
     87
     88#if DEBUG_SYSCALLS_ERROR
     89printk("\n[ERROR] in %s : cannot unlink file/dir %s\n", __FUNCTION__, kbuf );
     90#endif
    7391        this->errno = ENFILE;
    7492        return -1;
    7593    }
    7694
     95#if (DEBUG_SYS_UNLINK || CONFIG_INSTRUMENTATION_SYSCALLS)
     96uint64_t     tm_end = hal_get_cycles();
     97#endif
     98
     99#if DEBUG_SYS_UNLINK
     100if( DEBUG_SYS_UNLINK < tm_end )
     101printk("\n[%s] thread[%x,%x] exit for <%s> / cycle %d\n",
     102__FUNCTION__, process->pid, this->trdid, kbuf, (uint32_t)tm_end );
     103#endif
     104 
     105#if CONFIG_INSTRUMENTATION_SYSCALLS
     106hal_atomic_add( &syscalls_cumul_cost[SYS_UNLINK] , tm_end - tm_start );
     107hal_atomic_add( &syscalls_occurences[SYS_UNLINK] , 1 );
     108#endif
     109
    77110    return 0;
    78111
Note: See TracChangeset for help on using the changeset viewer.