Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
gfalFS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Data Management Clients
gfalFS
Commits
4dbc2fcc
Commit
4dbc2fcc
authored
7 years ago
by
Alejandro Alvarez Ayllon
Browse files
Options
Downloads
Patches
Plain Diff
DMC-982
: Migrating to gfal2 api
parent
935b95c2
No related branches found
No related tags found
No related merge requests found
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/gfal_ext.c
+0
-122
0 additions, 122 deletions
src/gfal_ext.c
src/gfal_ext.h
+0
-72
0 additions, 72 deletions
src/gfal_ext.h
src/gfal_opers.c
+317
-302
317 additions, 302 deletions
src/gfal_opers.c
with
317 additions
and
496 deletions
src/gfal_ext.c
deleted
100644 → 0
+
0
−
122
View file @
935b95c2
/*
* Copyright (c) CERN 2013-2017
*
* Copyright (c) Members of the EMI Collaboration. 2010-2013
* See http://www.eu-emi.eu/partners for details on the copyright
* holders.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file gfal_ext.c
* Some extended functionalities for gfalFS
**/
#include
<errno.h>
#include
<math.h>
#include
<string.h>
#include
<gfal_api.h>
#include
"gfal_ext.h"
gfalFS_dir_handle
gfalFS_dir_handle_new
(
void
*
fh
,
const
char
*
dirpath
)
{
gfalFS_dir_handle
ret
=
g_new0
(
struct
_gfalFS_dir_handle
,
1
);
g_strlcpy
(
ret
->
path
,
dirpath
,
GFALFS_URL_MAX_LEN
);
ret
->
fh
=
fh
;
ret
->
offset
=
0
;
ret
->
mut
=
g_mutex_new
();
return
ret
;
}
void
gfalFS_dir_handle_delete
(
gfalFS_dir_handle
handle
)
{
if
(
handle
)
{
g_mutex_free
(
handle
->
mut
);
free
(
handle
);
}
}
int
gfalFS_dir_handle_readdir
(
gfalFS_dir_handle
handle
,
off_t
offset
,
void
*
buf
,
fuse_fill_dir_t
filler
)
{
char
buff
[
2048
];
char
err_buff
[
1024
];
int
ret
;
if
(
offset
!=
handle
->
offset
)
{
// corrupted seq
gfal2_log
(
G_LOG_LEVEL_WARNING
,
"gfalfs_readdir err : Dir descriptor corruption, not in order %ld %ld"
,
(
long
)
offset
,
(
long
)
handle
->
offset
);
return
-
(
EFAULT
);
}
if
(
handle
->
dir
!=
NULL
)
{
// try to recover from previous saved status
struct
stat
st
;
memset
(
&
st
,
0
,
sizeof
(
st
));
st
.
st_ino
=
handle
->
dir
->
d_ino
;
st
.
st_mode
=
handle
->
dir
->
d_type
<<
12
;
gfalfs_tune_stat
(
&
st
);
if
(
filler
(
buf
,
handle
->
dir
->
d_name
,
&
st
,
handle
->
offset
+
1
)
==
1
)
{
return
0
;
// filler buffer full
}
else
{
handle
->
offset
+=
1
;
handle
->
dir
=
NULL
;
return
0
;
}
}
while
((
handle
->
dir
=
gfal_readdir
(
handle
->
fh
))
!=
NULL
)
{
if
(
fuse_interrupted
())
{
return
-
(
ECANCELED
);
}
struct
stat
st
;
memset
(
&
st
,
0
,
sizeof
(
st
));
st
.
st_ino
=
handle
->
dir
->
d_ino
;
st
.
st_mode
=
handle
->
dir
->
d_type
<<
12
;
ret
=
filler
(
buf
,
handle
->
dir
->
d_name
,
&
st
,
handle
->
offset
+
1
);
if
(
ret
==
1
)
{
// buffer full
return
0
;
}
handle
->
offset
+=
1
;
}
if
((
ret
=
-
(
gfal_posix_code_error
())))
{
gfal2_log
(
G_LOG_LEVEL_WARNING
,
"gfalfs_readdir err %d for path %s: %s "
,
gfal_posix_code_error
(),
buff
,
gfal_posix_strerror_r
(
err_buff
,
1024
));
gfal_posix_clear_error
();
return
ret
;
}
return
0
;
}
void
*
gfalFS_dir_handle_get_fd
(
gfalFS_dir_handle
handle
)
{
return
handle
->
fh
;
}
void
gfalfs_tune_stat
(
struct
stat
*
st
)
{
// tune block size to 16Mega for cp optimization with big files on network file system
st
->
st_blksize
=
(
1
<<
24
);
// workaround for utilities like du that use st_blocks (LCGUTIL-289)
st
->
st_blocks
=
ceil
(
st
->
st_size
/
512
.
0
);
}
This diff is collapsed.
Click to expand it.
src/gfal_ext.h
deleted
100644 → 0
+
0
−
72
View file @
935b95c2
/*
* Copyright (c) CERN 2013-2017
*
* Copyright (c) Members of the EMI Collaboration. 2010-2013
* See http://www.eu-emi.eu/partners for details on the copyright
* holders.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
/**
* @file gfal_ext.c
* @brief Header for some extended functionalities for gfalFS
*/
#include
<stdlib.h>
#include
<glib.h>
#include
"gfal_opers.h"
#define GFALFS_URL_MAX_LEN 2048
typedef
struct
_gfalFS_file_handle
{
char
path
[
GFALFS_URL_MAX_LEN
];
void
*
fh
;
off_t
offset
;
GMutex
*
mut
;
}
*
gfalFS_file_handle
;
typedef
struct
_gfalFS_dir_handle
{
char
path
[
GFALFS_URL_MAX_LEN
];
void
*
fh
;
off_t
offset
;
// current offset
struct
dirent
*
dir
;
// last dir, NULL if no state
GMutex
*
mut
;
}
*
gfalFS_dir_handle
;
gfalFS_dir_handle
gfalFS_dir_handle_new
(
void
*
fh
,
const
char
*
dirpath
);
int
gfalFS_dir_handle_readdir
(
gfalFS_dir_handle
handle
,
off_t
offset
,
void
*
buff
,
fuse_fill_dir_t
filler
);
void
*
gfalFS_dir_handle_get_fd
(
gfalFS_dir_handle
handle
);
void
gfalFS_dir_handle_delete
(
gfalFS_dir_handle
handle
);
gfalFS_file_handle
gfalFS_file_handle_new
(
void
*
fh
,
const
char
*
path
);
void
gfalFS_file_handle_delete
(
gfalFS_file_handle
handle
);
void
*
gfalFS_file_handle_get_fd
(
gfalFS_file_handle
handle
);
int
gfalFS_file_handle_write
(
gfalFS_file_handle
handle
,
const
char
*
buf
,
size_t
size
,
off_t
offset
);
int
gfalFS_file_handle_read
(
gfalFS_file_handle
handle
,
const
char
*
buf
,
size_t
size
,
off_t
offset
);
void
gfalfs_tune_stat
(
struct
stat
*
st
);
This diff is collapsed.
Click to expand it.
src/gfal_opers.c
+
317
−
302
View file @
4dbc2fcc
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment