From: Andrew Deason Date: Thu, 10 Nov 2011 17:05:28 +0000 (-0600) Subject: vol: Remove O_EXCL|O_TRUNC combinations X-Git-Tag: openafs-stable-1_8_0pre1~3058 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=4c679e380f697760de777d35fe057229bf2bf762 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. Change-Id: Ie8d9d7b9912a96683ef34f762607e75468b5ac78 Reviewed-on: http://gerrit.openafs.org/5832 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- diff --git a/src/vol/namei_ops.c b/src/vol/namei_ops.c index 811beae..904b81c 100644 --- a/src/vol/namei_ops.c +++ b/src/vol/namei_ops.c @@ -749,11 +749,11 @@ namei_icreate(IHandle_t * lh, char *part, afs_uint32 p1, afs_uint32 p2, afs_uint p++; for (tag = 0; tag < NAMEI_MAXVOLS; tag++) { *p = *int_to_base32(str1, tag); - fd = OS_OPEN((char *)&name.n_path, O_CREAT | O_RDWR | O_TRUNC | O_EXCL, 0666); + fd = OS_OPEN((char *)&name.n_path, O_CREAT | O_RDWR | O_EXCL, 0666); if (fd == INVALID_FD) { if (errno == ENOTDIR || errno == ENOENT) { if (namei_CreateDataDirectories(&name, &created_dir) == 0) - fd = OS_OPEN((char *)&name.n_path, O_CREAT | O_RDWR | O_TRUNC | O_EXCL, 0666); + fd = OS_OPEN((char *)&name.n_path, O_CREAT | O_RDWR | O_EXCL, 0666); } } @@ -885,12 +885,12 @@ namei_icreate(IHandle_t * lh, char *part, afs_uint32 p1, afs_uint32 p2, afs_uint } namei_HandleToName(&name, &tmp); - fd = OS_OPEN(name.n_path, O_CREAT | O_EXCL | O_TRUNC | O_RDWR, 0); + fd = OS_OPEN(name.n_path, O_CREAT | O_EXCL | O_RDWR, 0); if (fd == INVALID_FD) { if (errno == ENOTDIR || errno == ENOENT) { if (namei_CreateDataDirectories(&name, &created_dir) < 0) goto bad; - fd = OS_OPEN(name.n_path, O_CREAT | O_EXCL | O_TRUNC | O_RDWR, + fd = OS_OPEN(name.n_path, O_CREAT | O_EXCL | O_RDWR, 0); if (fd == INVALID_FD) goto bad; @@ -1137,7 +1137,7 @@ namei_copy_on_write(IHandle_t *h) if (!fdP) return EIO; snprintf(path, sizeof(path), "%s-tmp", name.n_path); - fd = OS_OPEN(path, O_CREAT | O_EXCL | O_TRUNC | O_RDWR, 0); + fd = OS_OPEN(path, O_CREAT | O_EXCL | O_RDWR, 0); if (fd == INVALID_FD) { FDH_CLOSE(fdP); return EIO; @@ -2890,7 +2890,7 @@ namei_ConvertROtoRWvolume(char *pname, afs_uint32 volumeId) } t_ih.ih_ino = namei_MakeSpecIno(ih->ih_vid, VI_VOLINFO); namei_HandleToName(&n, &t_ih); - fd2 = OS_OPEN(n.n_path, O_CREAT | O_EXCL | O_TRUNC | O_RDWR, 0); + fd2 = OS_OPEN(n.n_path, O_CREAT | O_EXCL | O_RDWR, 0); if (fd2 == INVALID_FD) { Log("1 namei_ConvertROtoRWvolume: could not create RW info file: %s\n", n.n_path); OS_CLOSE(fd);