Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
c219ba96
Commit
c219ba96
authored
May 16, 2020
by
houkime
Committed by
Esteban Blanc
Nov 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make gdb sensitive to TMPDIR
parent
7fb8a3b0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
17 deletions
+49
-17
src/lib/rt/src/rt_gdb.c
src/lib/rt/src/rt_gdb.c
+37
-13
src/lib/rt/src/rt_gdb.h
src/lib/rt/src/rt_gdb.h
+12
-4
No files found.
src/lib/rt/src/rt_gdb.c
View file @
c219ba96
...
@@ -80,6 +80,22 @@ static int compCatt(ptree_sTable* tp, ptree_sNode* x, ptree_sNode* y)
...
@@ -80,6 +80,22 @@ static int compCatt(ptree_sTable* tp, ptree_sNode* x, ptree_sNode* y)
return
1
;
return
1
;
}
}
/* Set paths for ftok-used files according to TMPDIR */
static
void
initPaths
(
gdb_sLocal
*
root
)
{
char
*
tmpdir
=
getenv
(
"TMPDIR"
);
if
(
!
tmpdir
)
{
tmpdir
=
gdb_cDefaultTmpDir
;
}
sprintf
(
root
->
db_path
,
"%s/%s"
,
tmpdir
,
gdb_cFileNameDatabase
);
sprintf
(
root
->
db_lock_path
,
"%s/%s"
,
tmpdir
,
gdb_cFileNameDbLock
);
sprintf
(
root
->
pool_path
,
"%s/%s"
,
tmpdir
,
gdb_cFileNamePool
);
sprintf
(
root
->
rtdb_path
,
"%s/%s"
,
tmpdir
,
gdb_cFileNameRtdb
);
}
static
void
evaluateInit
(
gdb_sInit
*
ip
)
static
void
evaluateInit
(
gdb_sInit
*
ip
)
{
{
ip
->
volumes
=
MAX
(
ip
->
volumes
,
gdb_cMin_volumes
);
ip
->
volumes
=
MAX
(
ip
->
volumes
,
gdb_cMin_volumes
);
...
@@ -582,10 +598,14 @@ gdb_sLocal* gdb_CreateDb(pwr_tStatus* sts, gdb_sInit* ip)
...
@@ -582,10 +598,14 @@ gdb_sLocal* gdb_CreateDb(pwr_tStatus* sts, gdb_sInit* ip)
gdbroot
->
my_pid
=
getpid
();
gdbroot
->
my_pid
=
getpid
();
/* Init token files' paths. */
initPaths
(
gdbroot
);
/* Create lock section. */
/* Create lock section. */
gdbroot
->
lock
=
sect_Alloc
(
sts
,
&
created
,
&
gdbroot
->
h
.
lock
,
gdbroot
->
lock
=
sect_Alloc
(
sts
,
&
created
,
&
gdbroot
->
h
.
lock
,
sizeof
(
sect_sMutex
),
gdb
_cNameDbLock
,
sect_mFlags_Create
);
sizeof
(
sect_sMutex
),
gdb
root
->
db_lock_path
,
sect_mFlags_Create
);
if
(
gdbroot
->
lock
==
NULL
)
if
(
gdbroot
->
lock
==
NULL
)
errh_Bugcheck
(
*
sts
,
"creating database lock"
);
errh_Bugcheck
(
*
sts
,
"creating database lock"
);
if
(
!
created
)
if
(
!
created
)
...
@@ -595,21 +615,21 @@ gdb_sLocal* gdb_CreateDb(pwr_tStatus* sts, gdb_sInit* ip)
...
@@ -595,21 +615,21 @@ gdb_sLocal* gdb_CreateDb(pwr_tStatus* sts, gdb_sInit* ip)
evaluateInit
(
ip
);
evaluateInit
(
ip
);
unlinkPool
(
gdb
_cNamePool
);
unlinkPool
(
gdb
root
->
pool_path
);
unlinkPool
(
gdb
_cNameRtdb
);
unlinkPool
(
gdb
root
->
rtdb_path
);
gdbroot
->
pool
=
pool_Create
(
gdbroot
->
pool
=
pool_Create
(
sts
,
&
gdbroot
->
h
.
pool
,
gdb
_cNamePool
,
ip
->
pool_isize
,
ip
->
pool_esize
);
sts
,
&
gdbroot
->
h
.
pool
,
gdb
root
->
pool_path
,
ip
->
pool_isize
,
ip
->
pool_esize
);
if
(
gdbroot
->
pool
==
NULL
)
if
(
gdbroot
->
pool
==
NULL
)
errh_Bugcheck
(
*
sts
,
"initating pool"
);
errh_Bugcheck
(
*
sts
,
"initating pool"
);
gdbroot
->
rtdb
=
pool_Create
(
gdbroot
->
rtdb
=
pool_Create
(
sts
,
&
gdbroot
->
h
.
rtdb
,
gdb
_cNameRtdb
,
ip
->
rtdb_isize
,
ip
->
rtdb_esize
);
sts
,
&
gdbroot
->
h
.
rtdb
,
gdb
root
->
rtdb_path
,
ip
->
rtdb_isize
,
ip
->
rtdb_esize
);
if
(
gdbroot
->
rtdb
==
NULL
)
if
(
gdbroot
->
rtdb
==
NULL
)
errh_Bugcheck
(
*
sts
,
"initiating rtdb"
);
errh_Bugcheck
(
*
sts
,
"initiating rtdb"
);
gdbroot
->
db
=
pool_AllocNamedSegment
(
gdbroot
->
db
=
pool_AllocNamedSegment
(
sts
,
gdbroot
->
pool
,
sizeof
(
*
gdbroot
->
db
),
gdb
_cNameDatabase
);
sts
,
gdbroot
->
pool
,
sizeof
(
*
gdbroot
->
db
),
gdb
root
->
db_path
);
if
(
gdbroot
->
db
==
NULL
)
if
(
gdbroot
->
db
==
NULL
)
errh_Bugcheck
(
*
sts
,
"database directory"
);
errh_Bugcheck
(
*
sts
,
"database directory"
);
...
@@ -820,15 +840,15 @@ void gdb_UnlinkDb()
...
@@ -820,15 +840,15 @@ void gdb_UnlinkDb()
/* Unlink pool. */
/* Unlink pool. */
unlinkPool
(
gdb
_cNamePool
);
unlinkPool
(
gdb
root
->
pool_path
);
unlinkPool
(
gdb
_cNameRtdb
);
unlinkPool
(
gdb
root
->
rtdb_path
);
/* Remove database lock. */
/* Remove database lock. */
strncpy
(
busid
,
(
str
?
str
:
"XXX"
),
3
);
strncpy
(
busid
,
(
str
?
str
:
"XXX"
),
3
);
busid
[
3
]
=
'\0'
;
busid
[
3
]
=
'\0'
;
sprintf
(
segname
,
"%s_%.3s"
,
gdb
_cNameDbLock
,
busid
);
sprintf
(
segname
,
"%s_%.3s"
,
gdb
root
->
db_lock_path
,
busid
);
key
=
ftok
(
segname
,
'P'
);
key
=
ftok
(
segname
,
'P'
);
shm_id
=
shmget
(
key
,
0
,
0660
);
shm_id
=
shmget
(
key
,
0
,
0660
);
...
@@ -1014,10 +1034,14 @@ gdb_sLocal* gdb_MapDb(pwr_tStatus* sts, qcom_sQid* qid, const char* name)
...
@@ -1014,10 +1034,14 @@ gdb_sLocal* gdb_MapDb(pwr_tStatus* sts, qcom_sQid* qid, const char* name)
gdbroot
->
my_pid
=
getpid
();
gdbroot
->
my_pid
=
getpid
();
/* Init token files' paths. */
initPaths
(
gdbroot
);
/* Map lock sections. */
/* Map lock sections. */
gdbroot
->
lock
=
sect_Alloc
(
gdbroot
->
lock
=
sect_Alloc
(
sts
,
&
created
,
&
gdbroot
->
h
.
lock
,
sizeof
(
sect_sMutex
),
gdb
_cNameDbLock
,
0
);
sts
,
&
created
,
&
gdbroot
->
h
.
lock
,
sizeof
(
sect_sMutex
),
gdb
root
->
db_lock_path
,
0
);
if
(
gdbroot
->
lock
==
NULL
)
{
if
(
gdbroot
->
lock
==
NULL
)
{
errh_Fatal
(
"Error mapping db lock
\n
%m"
,
*
sts
);
errh_Fatal
(
"Error mapping db lock
\n
%m"
,
*
sts
);
pwr_Return
(
NULL
,
sts
,
GDH__DBLOCK
);
pwr_Return
(
NULL
,
sts
,
GDH__DBLOCK
);
...
@@ -1029,16 +1053,16 @@ gdb_sLocal* gdb_MapDb(pwr_tStatus* sts, qcom_sQid* qid, const char* name)
...
@@ -1029,16 +1053,16 @@ gdb_sLocal* gdb_MapDb(pwr_tStatus* sts, qcom_sQid* qid, const char* name)
/* Map 'pool' & 'rtdb' pools. */
/* Map 'pool' & 'rtdb' pools. */
gdbroot
->
pool
=
pool_Create
(
sts
,
&
gdbroot
->
h
.
pool
,
gdb
_cNamePool
,
0
,
0
);
gdbroot
->
pool
=
pool_Create
(
sts
,
&
gdbroot
->
h
.
pool
,
gdb
root
->
pool_path
,
0
,
0
);
if
(
gdbroot
->
pool
==
NULL
)
if
(
gdbroot
->
pool
==
NULL
)
errh_Bugcheck
(
*
sts
,
"initating pool"
);
errh_Bugcheck
(
*
sts
,
"initating pool"
);
gdbroot
->
rtdb
=
pool_Create
(
sts
,
&
gdbroot
->
h
.
rtdb
,
gdb
_cNameRtdb
,
0
,
0
);
gdbroot
->
rtdb
=
pool_Create
(
sts
,
&
gdbroot
->
h
.
rtdb
,
gdb
root
->
rtdb_path
,
0
,
0
);
if
(
gdbroot
->
rtdb
==
NULL
)
if
(
gdbroot
->
rtdb
==
NULL
)
errh_Bugcheck
(
*
sts
,
"initiating rtdb"
);
errh_Bugcheck
(
*
sts
,
"initiating rtdb"
);
gdbroot
->
db
=
pool_AllocNamedSegment
(
gdbroot
->
db
=
pool_AllocNamedSegment
(
sts
,
gdbroot
->
pool
,
sizeof
(
*
gdbroot
->
db
),
gdb
_cNameDatabase
);
sts
,
gdbroot
->
pool
,
sizeof
(
*
gdbroot
->
db
),
gdb
root
->
db_path
);
if
(
gdbroot
->
db
==
NULL
)
if
(
gdbroot
->
db
==
NULL
)
errh_Bugcheck
(
*
sts
,
"database directory"
);
errh_Bugcheck
(
*
sts
,
"database directory"
);
...
...
src/lib/rt/src/rt_gdb.h
View file @
c219ba96
...
@@ -55,10 +55,13 @@
...
@@ -55,10 +55,13 @@
#define gdb_cVersion 7
#define gdb_cVersion 7
#define gdb_cNameDatabase "/tmp/pwr_gdb"
/* This can be overriden with TMPDIR */
#define gdb_cNamePool "/tmp/pwr_pool"
#define gdb_cDefaultTmpDir "/tmp/"
#define gdb_cNameRtdb "/tmp/pwr_rtdb"
#define gdb_cNameDbLock "/tmp/pwr_db_lock"
#define gdb_cFileNameDatabase "pwr_gdb"
#define gdb_cFileNamePool "pwr_pool"
#define gdb_cFileNameRtdb "pwr_rtdb"
#define gdb_cFileNameDbLock "pwr_db_lock"
#define gdb_cMin_objects 3000
#define gdb_cMin_objects 3000
#define gdb_cMin_volumes 30
#define gdb_cMin_volumes 30
...
@@ -999,6 +1002,11 @@ typedef struct {
...
@@ -999,6 +1002,11 @@ typedef struct {
qcom_sAid
my_aid
;
/**< The QueId of this job */
qcom_sAid
my_aid
;
/**< The QueId of this job */
pid_t
my_pid
;
/**< The process id of this job */
pid_t
my_pid
;
/**< The process id of this job */
pwr_tBoolean
is_tmon
;
/**< Set if tmon */
pwr_tBoolean
is_tmon
;
/**< Set if tmon */
pwr_tFileName
db_lock_path
;
pwr_tFileName
db_path
;
/* NOTE: no real need to have an actual file path here*/
pwr_tFileName
pool_path
;
pwr_tFileName
rtdb_path
;
}
gdb_sLocal
;
}
gdb_sLocal
;
/* The root of all data, the only `global' variable... */
/* The root of all data, the only `global' variable... */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment