mirror of
https://git.openafs.org/openafs.git
synced 2025-01-31 13:38:01 +00:00
vol: Remove O_EXCL|O_TRUNC combinations
A few places were specifying both O_EXCL and O_TRUNC to open(). O_TRUNC does not make any sense with O_EXCL, and doesn't do anything, so remove O_TRUNC from these instances to make the code more clear. Reviewed-on: http://gerrit.openafs.org/5832 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Derrick Brashear <shadow@dementix.org> (cherry picked from commit 4c679e380f697760de777d35fe057229bf2bf762) Change-Id: Iae79f552d17d626bbf2a7c9428bc9c7bbf91fae9 Reviewed-on: http://gerrit.openafs.org/9433 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Derrick Brashear <shadow@your-file-system.com> Reviewed-by: Andrew Deason <adeason@sinenomine.net> Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
This commit is contained in:
parent
8f33982b23
commit
3f19ea5ffc
@ -806,11 +806,11 @@ namei_icreate(IHandle_t * lh, char *part, afs_uint32 p1, afs_uint32 p2, afs_uint
|
|||||||
p++;
|
p++;
|
||||||
for (tag = 0; tag < NAMEI_MAXVOLS; tag++) {
|
for (tag = 0; tag < NAMEI_MAXVOLS; tag++) {
|
||||||
*p = *int_to_base32(str1, tag);
|
*p = *int_to_base32(str1, tag);
|
||||||
fd = afs_open((char *)&name.n_path, O_CREAT | O_RDWR | O_TRUNC | O_EXCL, 0666);
|
fd = afs_open((char *)&name.n_path, O_CREAT | O_RDWR | O_EXCL, 0666);
|
||||||
if (fd == INVALID_FD) {
|
if (fd == INVALID_FD) {
|
||||||
if (errno == ENOTDIR || errno == ENOENT) {
|
if (errno == ENOTDIR || errno == ENOENT) {
|
||||||
if (namei_CreateDataDirectories(&name, &created_dir) == 0)
|
if (namei_CreateDataDirectories(&name, &created_dir) == 0)
|
||||||
fd = afs_open((char *)&name.n_path, O_CREAT | O_RDWR | O_TRUNC | O_EXCL, 0666);
|
fd = afs_open((char *)&name.n_path, O_CREAT | O_RDWR | O_EXCL, 0666);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -942,12 +942,12 @@ namei_icreate(IHandle_t * lh, char *part, afs_uint32 p1, afs_uint32 p2, afs_uint
|
|||||||
}
|
}
|
||||||
|
|
||||||
namei_HandleToName(&name, &tmp);
|
namei_HandleToName(&name, &tmp);
|
||||||
fd = afs_open(name.n_path, O_CREAT | O_EXCL | O_TRUNC | O_RDWR, 0);
|
fd = afs_open(name.n_path, O_CREAT | O_EXCL | O_RDWR, 0);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
if (errno == ENOTDIR || errno == ENOENT) {
|
if (errno == ENOTDIR || errno == ENOENT) {
|
||||||
if (namei_CreateDataDirectories(&name, &created_dir) < 0)
|
if (namei_CreateDataDirectories(&name, &created_dir) < 0)
|
||||||
goto bad;
|
goto bad;
|
||||||
fd = afs_open(name.n_path, O_CREAT | O_EXCL | O_TRUNC | O_RDWR,
|
fd = afs_open(name.n_path, O_CREAT | O_EXCL | O_RDWR,
|
||||||
0);
|
0);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
goto bad;
|
goto bad;
|
||||||
@ -1198,7 +1198,7 @@ namei_copy_on_write(IHandle_t *h)
|
|||||||
if (!fdP)
|
if (!fdP)
|
||||||
return EIO;
|
return EIO;
|
||||||
afs_snprintf(path, sizeof(path), "%s-tmp", name.n_path);
|
afs_snprintf(path, sizeof(path), "%s-tmp", name.n_path);
|
||||||
fd = afs_open(path, O_CREAT | O_EXCL | O_TRUNC | O_RDWR, 0);
|
fd = afs_open(path, O_CREAT | O_EXCL | O_RDWR, 0);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
FDH_CLOSE(fdP);
|
FDH_CLOSE(fdP);
|
||||||
return EIO;
|
return EIO;
|
||||||
@ -2977,7 +2977,7 @@ namei_ConvertROtoRWvolume(char *pname, afs_uint32 volumeId)
|
|||||||
}
|
}
|
||||||
t_ih.ih_ino = namei_MakeSpecIno(ih->ih_vid, VI_VOLINFO);
|
t_ih.ih_ino = namei_MakeSpecIno(ih->ih_vid, VI_VOLINFO);
|
||||||
namei_HandleToName(&n, &t_ih);
|
namei_HandleToName(&n, &t_ih);
|
||||||
fd2 = afs_open(n.n_path, O_CREAT | O_EXCL | O_TRUNC | O_RDWR, 0);
|
fd2 = afs_open(n.n_path, O_CREAT | O_EXCL | O_RDWR, 0);
|
||||||
if (fd2 == INVALID_FD) {
|
if (fd2 == INVALID_FD) {
|
||||||
Log("1 namei_ConvertROtoRWvolume: could not create RW info file: %s\n", n.n_path);
|
Log("1 namei_ConvertROtoRWvolume: could not create RW info file: %s\n", n.n_path);
|
||||||
OS_CLOSE(fd);
|
OS_CLOSE(fd);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user