source: trunk/kernel/syscalls/sys_rmdir.c @ 9

Last change on this file since 9 was 1, checked in by alain, 8 years ago

First import

File size: 1.4 KB
RevLine 
[1]1/*
2 * sys_rmdir: remove a directory
3 *
4 * Copyright (c) 2015 UPMC Sorbonne Universites
5 *
6 * This file is part of ALMOS-kernel.
7 *
8 * ALMOS-kernel is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2.0 of the License.
11 *
12 * ALMOS-kernel is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with ALMOS-kernel; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#include <cpu.h>
23#include <vfs.h>
24#include <sys-vfs.h>
25#include <thread.h>
26#include <task.h>
27
28
29int sys_rmdir (char *pathname)
30{
31        register struct thread_s *this;
32        register struct task_s *task;
33        struct ku_obj ku_path;
34        error_t err = 0;
35       
36        this = current_thread;
37        task = current_task;
38
39        if(!pathname)
40        {
41                this->info.errno = EINVAL;
42                return -1;
43        }
44
45        KU_BUFF(ku_path, pathname);
46        rwlock_wrlock(&task->cwd_lock);
47
48        if((err = vfs_rmdir(&current_task->vfs_cwd, &ku_path)))
49        {
50                current_thread->info.errno = (err < 0) ? -err : err;
51                rwlock_unlock(&task->cwd_lock); 
52                return -1;
53        }
54       
55        rwlock_unlock(&task->cwd_lock); 
56        return 0;
57}
Note: See TracBrowser for help on using the repository browser.