[LU-8724] several llapi functions use opendir() when open() would suffice Created: 18/Oct/16  Updated: 23/Dec/16  Resolved: 23/Dec/16

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: Lustre 2.9.0
Fix Version/s: Lustre 2.10.0

Type: Bug Priority: Minor
Reporter: John Hammond Assignee: Steve Guminski (Inactive)
Resolution: Fixed Votes: 0
Labels: easy, llapi

Severity: 3
Rank (Obsolete): 9223372036854775807

 Description   

llapi_get_obd_count(), llapi_ostlist(), llapi_quotactl(), llapi_get_connect_flags(), and possibly other llapi functions are using opendir(), dirfd(), and closedir() when open() and close() would suffice.



 Comments   
Comment by Steve Guminski (Inactive) [ 28/Nov/16 ]

I don't think llapi_ostlist() should be changed, because it uses the opened directory as a parameter to setup_obd_uuid(), which takes a DIR pointer.

Comment by Gerrit Updater [ 28/Nov/16 ]

Steve Guminski (stephenx.guminski@intel.com) uploaded a new patch: http://review.whamcloud.com/23981
Subject: LU-8724 utils: Use open() instead of opendir() with dirfd()
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: f57b28954e8fff0467e3d7877c003c62cefe768f

Comment by James A Simmons [ 28/Nov/16 ]

While you are at it another issue exist as well with newer platforms. On my Ubuntu 16 system I get the following build issues:

gcc -DHAVE_CONFIG_H -I. -I../.. -include /usr/src/lustre-2.8.60/undef.h -include /usr/src/lustre-2.8.60/config.h -I/usr/src/lustre-2.8.60/libcfs/include -I/usr/src/lustre-2.8.60/lnet/include -I/usr/src/lustre-2.8.60/lustre/include -fPIC -D_GNU_SOURCE -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 -DLUSTRE_UTILS=1 -g -O2 -Wall -Werror -MT liblustreapi.o -MD -MP -MF .deps/liblustreapi.Tpo -c -o liblustreapi.o liblustreapi.c
liblustreapi.c: In function ‘llapi_get_poollist’:
liblustreapi.c:1196:3: error: ‘readdir_r’ is deprecated [-Werror=deprecated-declarations]
rc = readdir_r(dir, &pool, &cookie);
^~
In file included from /usr/include/features.h:364:0,
from /usr/include/mntent.h:22,
from liblustreapi.c:44:
/usr/include/dirent.h:189:12: note: declared here
extern int __REDIRECT (readdir_r,
^
cc1: all warnings being treated as errors
Makefile:1191: recipe for target 'liblustreapi.o' failed

readdir() is the replacement for this function,

Comment by John Hammond [ 28/Nov/16 ]

> I don't think llapi_ostlist() should be changed, because it uses the opened directory as a parameter to setup_obd_uuid(), which takes a DIR pointer.

setup_obd_uuid() only uses the dir parameter as an argument to dirfd(). So its DIR *dir parameter should be replaced with int fd.

Comment by John Hammond [ 28/Nov/16 ]

James, please open a new issue.

Comment by Steve Guminski (Inactive) [ 28/Nov/16 ]

OK. setup_obd_uuid() is called elsewhere, so I'll have to update the other code that will be impacted. I'll upload a new patch when those changes are made.

Comment by Gerrit Updater [ 23/Dec/16 ]

Oleg Drokin (oleg.drokin@intel.com) merged in patch https://review.whamcloud.com/23981/
Subject: LU-8724 utils: Use open() instead of opendir() with dirfd()
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 44b6af40f70cf065e8198b6b438d6c953063d003

Comment by Peter Jones [ 23/Dec/16 ]

Landed for 2.10

Generated at Sat Feb 10 02:20:00 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.