From: Frank Ch. Eigler Date: Tue, 26 Apr 2016 21:02:33 +0000 (-0400) Subject: staprun: reinstate -d '*' operation X-Git-Tag: release-3.1~779 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=14a09f02e3d66a5b3c2940815f787779febd1f15;p=systemtap.git staprun: reinstate -d '*' operation PR14245 created a new relay_basedir_fd variable, for use when staprun/stapio passes staprun a file descriptor for the base directory of the sysfs systemtap-module directory. (This is necessary in order to get around 0700 mount-dir permissions.) This broke staprun -d '*' operation, since that variable got set (badly) once within the readdir loop, and thence made actual removes inoperative. Now we clear out that variable so each actual module subdirectory will get a good cleaning. --- diff --git a/staprun/staprun.c b/staprun/staprun.c index 89e6d8be4..c09e59b7c 100644 --- a/staprun/staprun.c +++ b/staprun/staprun.c @@ -229,9 +229,13 @@ static void remove_all_modules(void) moddir = opendir(base); if (moddir) { - while ((d = readdir(moddir))) + while ((d = readdir(moddir))) { + if (strcmp(d->d_name, ".") == 0) continue; + if (strcmp(d->d_name, "..") == 0) continue; + relay_basedir_fd = -1; /* each time! */ if (remove_module(d->d_name, 0) == 0) printf("Module %s removed.\n", d->d_name); + } closedir(moddir); } } @@ -256,7 +260,8 @@ static int remove_module(const char *name, int verb) /* We call init_ctl_channel/close_ctl_channel to check whether the module is a systemtap-built one (having the right files), and that it's already unattached (because otherwise it'd EBUSY - the opens. */ + the opens, and that it belongs to our uid (because otherwise + a faccessat(2) test on the .cmd file will fail). */ ret = init_ctl_channel (name, 0); if (ret < 0) { err("'%s' is not a zombie systemtap module.\n", name);