ns-3 Direct Code Execution
Home
Tutorials ▼
Docs ▼
Wiki
Manual
Develop ▼
API
Bugs
API
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
dce-at.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2011 INRIA
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Frederic Urbani <frederic.urbani@inria.fr>
19
*
20
*/
21
#include "
dce-fcntl.h
"
22
#include "
sys/dce-stat.h
"
23
#include "
process.h
"
24
#include "
utils.h
"
25
#include "ns3/log.h"
26
#include "errno.h"
27
#include <string.h>
28
#include <fcntl.h>
29
#include <unistd.h>
30
31
NS_LOG_COMPONENT_DEFINE
(
"DceAt"
);
32
33
using namespace
ns3;
34
35
int
dce___fxstatat
(
int
ver,
int
fd,
const
char
*pathname,
struct
stat *buf,
int
flag)
36
{
37
Thread
*current =
Current
();
38
NS_LOG_FUNCTION (current <<
UtilsGetNodeId
() << pathname << buf);
39
NS_ASSERT (current != 0);
40
int
retval = -1;
41
42
if
((0 == pathname) || (0 == buf))
43
{
44
current->
err
= EFAULT;
45
return
-1;
46
}
47
if
(std::string (pathname) ==
""
)
48
{
49
current->
err
= ENOENT;
50
return
-1;
51
}
52
if
(fd != AT_FDCWD && pathname[0] !=
'/'
)
53
{
54
int
realFd =
getRealFd
(fd, current);
55
56
if
(realFd < 0)
57
{
58
current->
err
= EBADF;
59
return
-1;
60
}
61
retval = ::__fxstatat (ver, realFd, pathname, buf, flag);
62
}
63
else
64
{
65
std::string path =
UtilsGetCurrentDirName
() +
"/"
+
UtilsGetRealFilePath
(pathname);
66
retval = ::__fxstatat (ver, fd, path.c_str (), buf, flag);
67
}
68
if
(retval == -1)
69
{
70
current->
err
=
errno
;
71
return
-1;
72
}
73
return
retval;
74
}
75
void
unlink_notify
(std::string fullpath);
76
int
dce_unlinkat
(
int
fd,
const
char
*pathname,
int
flags)
77
{
78
Thread
*current =
Current
();
79
NS_LOG_FUNCTION (current <<
UtilsGetNodeId
() << pathname);
80
NS_ASSERT (current != 0);
81
int
retval = -1;
82
std::string realpath =
""
;
83
84
if
(0 == pathname)
85
{
86
current->
err
= EFAULT;
87
return
-1;
88
}
89
if
(std::string (pathname) ==
""
)
90
{
91
current->
err
= ENOENT;
92
return
-1;
93
}
94
if
(fd != AT_FDCWD && pathname[0] !=
'/'
)
95
{
96
int
realFd =
getRealFd
(fd, current);
97
98
if
(realFd < 0)
99
{
100
current->
err
= EBADF;
101
return
-1;
102
}
103
retval = ::unlinkat (realFd, pathname, flags);
104
if
(retval == 0)
105
{
106
realpath =
PathOfFd
(realFd);
107
}
108
}
109
else
110
{
111
realpath =
UtilsGetCurrentDirName
() +
"/"
+
UtilsGetRealFilePath
(pathname);
112
retval = ::unlinkat (fd, realpath.c_str (), flags);
113
}
114
if
(retval == -1)
115
{
116
current->
err
=
errno
;
117
return
-1;
118
}
119
120
if
(retval == 0)
121
{
122
unlink_notify
(realpath);
123
}
124
125
return
retval;
126
}
model
dce-at.cc
Generated on Fri Aug 30 2013 13:57:55 for ns-3-dce by
1.8.1.2