From 3f19ea5ffc3c56a342f8eb7f9c8b73eeca4d8aa6 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Thu, 10 Nov 2011 11:05:28 -0600 Subject: [PATCH] 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 Reviewed-by: Derrick Brashear (cherry picked from commit 4c679e380f697760de777d35fe057229bf2bf762) Change-Id: Iae79f552d17d626bbf2a7c9428bc9c7bbf91fae9 Reviewed-on: http://gerrit.openafs.org/9433 Tested-by: BuildBot Reviewed-by: Derrick Brashear Reviewed-by: Andrew Deason Reviewed-by: Stephan Wiesand --- src/vol/namei_ops.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/vol/namei_ops.c b/src/vol/namei_ops.c index 254e9a0580..9095c96a8a 100644 --- a/src/vol/namei_ops.c +++ b/src/vol/namei_ops.c @@ -806,11 +806,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 = 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 (errno == ENOTDIR || errno == ENOENT) { 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); - 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 (errno == ENOTDIR || errno == ENOENT) { if (namei_CreateDataDirectories(&name, &created_dir) < 0) 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); if (fd < 0) goto bad; @@ -1198,7 +1198,7 @@ namei_copy_on_write(IHandle_t *h) if (!fdP) return EIO; 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) { FDH_CLOSE(fdP); return EIO; @@ -2977,7 +2977,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 = 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) { Log("1 namei_ConvertROtoRWvolume: could not create RW info file: %s\n", n.n_path); OS_CLOSE(fd);