xfsprogs: Replace deprecated ustat and sig(relse/hold) glibc APIs
cover xfsprogs: Replace deprecated ustat and sig(relse/hold) glibc APIs
Replacing deprecated APis with new ones.
[PATCH 1/2] xfsprogs: replace deprecated ustat call with statfs in libxfs/linux.c [PATCH 2/2] xfsprogs: Use Posix signal API signprocmask instead of sigrelse/sighold in xfs_copy.c
Kamal
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 1/2 xfsprogs: replace deprecated ustat call with statfs in libxfs/linux.c
Quoted 1 line
From the ustat man page
NOTES
ustat() is deprecated and has only been provided for compatibility. All new programs should use statfs(2) instead.
--- libxfs/linux.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
libxfs/linux.c +5 -3
@@ -21,7 +21,9 @@#include <mntent.h> #include <sys/stat.h> #undef ustat -#include <sys/ustat.h> +#include <sys/statfs.h> +#include <sys/types.h> +#include <sys/mount.h> #include <sys/ioctl.h> #include <sys/sysinfo.h>
@@ -50,7 +52,7 @@ int platform_check_ismounted(char *name, char *block, struct stat64 *s, int verbose) {/* Pad ust; pre-2.6.28 linux copies out too much in 32bit compat mode */ -struct ustat ust[2 ]; +struct statfs fst;struct stat64 st;if (!s) {
@@ -61,7 +63,7 @@ platform_check_ismounted(char *name, char *block, struct stat64 *s, int verbose) s = &st; } -if (ustat (s->st_rdev, ust) >=0 ) { +if (statfs (block, &fst) >=0 ) {if (verbose) fprintf(stderr, _("%s: %s contains a mounted filesystem\n"),
Signature · 7 lines
1.7.5.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 2/2 xfsprogs: Use Posix signal API signprocmask instead of sigrelse/sighold in xfs_copy.c
From sigrelse and sighold man page
DESCRIPTION
These functions are provided in glibc as a compatibility interface for programs that make use of the historical System V signal API. This API is obsolete: new applications should use the POSIX signal API (sigac‐ tion(2), sigprocmask(2), etc.)
--- copy/xfs_copy.c | 17 ++++++++++++++--- 1 files changed, 14 insertions(+), 3 deletions(-)
copy/xfs_copy.c +14 -3
@@ -71,6 +71,17 @@ xfs_off_t write_log_header(int fd, wbuf *w, xfs_mount_t *mp);#define PRE 0x08/* append strerror string */ #define LAST 0x10/* final message we print */ + +void +signal_maskfunc (int addset,int newset) +{ +sigset_t set; + +sigemptyset (&set); +sigaddset (&set, addset); +sigprocmask (newset, &set,NULL ); +} +void do_message (int flags,int code,const char *fmt, ...) {
@@ -478,9 +489,9 @@ write_wbuf(void)if (target[i].state !=INACTIVE )pthread_mutex_unlock (&targ[i].wait);/* wake up */ -sigrelse (SIGCHLD ); +signal_maskfunc (SIGCHLD ,SIG_UNBLOCK );pthread_mutex_lock (&mainwait); -sighold (SIGCHLD ); +signal_maskfunc (SIGCHLD ,SIG_BLOCK ); }
@@ -847,7 +858,7 @@ main(int argc, char **argv)/* set up sigchild signal handler */ signal (SIGCHLD , handler); -sighold (SIGCHLD ); +signal_maskfunc (SIGCHLD ,SIG_BLOCK );/* make children */
Signature · 7 lines
1.7.5.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 1/2] xfsprogs: replace deprecated ustat call with statfs in libxfs/linux.c
In reply to Kamal DasuQuoted 5 lines · Kamal Dasu
Quoted 1 line
From the ustat man page
NOTES
ustat()is deprecated and has only been provided for compatibility. All new programs should use statfs(2) instead.
xfsprogs isn't new :)
More seriously - ustat provides the benefit to check if the block device is mounted anywhere, which we make use of here. A statfs of the block device path doesn't provide that functionality at all.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 1/2] xfsprogs: replace deprecated ustat call with statfs in libxfs/linux.c
Christoph,
Quoted 4 lines
More seriously - ustat provides the benefit to check if the block device is mounted anywhere, which we make use of here. A statfs of the block device path doesn't provide that functionality at all.
Now I understand your concern. However if we would want to replace the deprecated ustat call, then what other way would be acceptable to achieve the same. Would parsing the /proc/mounts for the block device name suffice ?.
Thanks
Kamal
Quoted 7 lines · Christoph Hellwig
Quoted 5 lines · Kamal Dasu
Quoted 1 line
From the ustat man page
NOTES
ustat() is deprecated and has only been provided for compatibility. All new programs should use statfs(2) instead.
Quoted 6 lines
xfsprogs isn't new :)
More seriously - ustat provides the benefit to check if the block device is mounted anywhere, which we make use of here. A statfs of the block device path doesn't provide that functionality at all.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs