[
https://issues.apache.org/jira/browse/HADOOP-4110?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12636779#action_12636779
]
Pete Wyckoff commented on HADOOP-4110:
--------------------------------------
since this is non-trivial to fully implement in hdfs, I am thinking of just
implementing it for the case where bytes == 0. This is the common use case for:
cp foo bar where bar already exists. truncate(bar, 0) is called and then foo is
copied. Getting the user/permissions right would need to do a stat on the
file, get the user and groups and permissions and then do a delete, then the
create and then chown and chmod. the code would look something like:
{code}
static int dfs_truncate(const char *path, off_t size)
{
if (size != 0) {
return -ENOTSUP;
}
dfs_context *dfs = (dfs_context*)fuse_get_context()->private_data;
int ret = dfs_unlink(path);
if (ret != 0) {
return ret;
}
hdfsFS userFS;
// if not connected, try to connect and fail out if we can't.
if ((userFS = doConnectAsUser(dfs->nn_hostname,dfs->nn_port)) == NULL) {
syslog(LOG_ERR, "ERROR: could not connect to dfs %s:%d\n", __FILE__,
__LINE__);
return -EIO;
}
hdfsFile file;
if((file = (hdfsFile)hdfsOpenFile(userFS, path, O_WRONLY | O_CREAT, 0, 3,
0)) == NULL) {
syslog(LOG_ERR, "ERROR: could not connect open file %s:%d\n", __FILE__,
__LINE__);
return -EIO;
}
if(hdfsCloseFile(userFS, file) != 0) {
syslog(LOG_ERR, "ERROR: could not connect close file %s:%d\n", __FILE__,
__LINE__);
return -EIO;
}
return 0;
}
{code}
> fuse-dfs implement posix truncate functionality
> -----------------------------------------------
>
> Key: HADOOP-4110
> URL: https://issues.apache.org/jira/browse/HADOOP-4110
> Project: Hadoop Core
> Issue Type: New Feature
> Components: contrib/fuse-dfs
> Reporter: Pete Wyckoff
>
> dfs_truncate(path, bytes);
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
