> -----Original Message----- > From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Jyotiswarup > Raiturkar > Sent: Tuesday, February 04, 2014 3:33 AM > To: dev at dpdk.org > Cc: Jyotiswarup Raiturkar > Subject: [dpdk-dev] couple of minor compilation errors in DPDK 1.6 > (/lib/librte_eal/linuxapp/eal/eal_ivshmem.c) > > Hi > > I downloaded DPDK 1.6 from the Intel website and ran into couple of > compilation errors with /lib/librte_eal/linuxapp/eal/eal_ivshmem.c. > The following changes seem to fix it. Have other people seen these? > > Thanks > Jyoti > > > @@ -472,7 +472,7 @@ > rte_snprintf(path, sizeof(path), IVSHMEM_CONFIG_PATH, > internal_config.hugefile_prefix); > > - fd = open(path, O_CREAT | O_RDWR); > + fd = open(path, O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO ); > > if (fd < 0) { > RTE_LOG(ERR, EAL, "Could not open %s: %s\n", path, strerror(errno)); > @@ - > 486,7 +486,8 @@ > return -1; > } > > - ftruncate(fd, sizeof(struct ivshmem_shared_config)); > + if (ftruncate(fd, sizeof(struct ivshmem_shared_config))) { > + close(fd); return -1; > + } > > ivshmem_config = mmap(NULL, sizeof(struct ivshmem_shared_config), > PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
Hi I don't think assigning 0777 to a newly created file is a good idea, I would prefer 0666. Other than that, there is also another place where a call to close() should be added, so the correct patch would be: @@ -443,7 +443,7 @@ create_shared_config(void) rte_snprintf(path, sizeof(path), IVSHMEM_CONFIG_PATH, internal_config.hugefile_prefix); - fd = open(path, O_CREAT | O_RDWR); + fd = open(path, O_CREAT | O_RDWR, 0666); if (fd < 0) { RTE_LOG(ERR, EAL, "Could not open %s: %s\n", path, strerror(errno)); @@ -462,14 +462,17 @@ create_shared_config(void) ivshmem_config = mmap(NULL, sizeof(struct ivshmem_shared_config), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); - if (ivshmem_config == MAP_FAILED) + if (ivshmem_config == MAP_FAILED) { + close(fd); return -1; + } memset(ivshmem_config, 0, sizeof(struct ivshmem_shared_config)); /* change the exclusive lock we got earlier to a shared lock */ if (flock(fd, LOCK_SH | LOCK_NB) == -1) { RTE_LOG(ERR, EAL, "Locking %s failed: %s \n", path, strerror(errno)); + close(fd); return -1; } Best regards, Anatoly Burakov DPDK SW Engineer -------------------------------------------------------------- Intel Shannon Limited Registered in Ireland Registered Office: Collinstown Industrial Park, Leixlip, County Kildare Registered Number: 308263 Business address: Dromore House, East Park, Shannon, Co. Clare This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.