Re: [master 2/2] Redownload and extract updates.img during anaconda restart.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> diff --git a/loader/loader.c b/loader/loader.c
> index 6a701e4..d9c0589 100644
> --- a/loader/loader.c
> +++ b/loader/loader.c
> @@ -1712,9 +1712,15 @@ void loaderUsrXHandler(int signum) {
>      init_sig = signum;
>  }
>  
> -int restart_anaconda() {
> +int restart_anaconda(struct loaderData_s *loaderData) {
>      if (access("/tmp/restart_anaconda", R_OK))
>          return 0;
> +    if (loaderData->updatessrc) {
> +        if (rm_rf("/tmp/updates"))
> +            fprintf(stderr, "Error removing /tmp/updates. Updates won't be re-downloaded.");
> +        else
> +            loadUpdatesFromRemote(loaderData->updatessrc, loaderData);
> +    }
>      puts("Restarting Anaconda.");
>      return 1;
>  }

It seems like we're bound to start building up a longer and longer list
of these sorts of things that will need to be done on restart, doesn't
it?  Any ideas for what to do once there are three or four tasks that
need to be done?

> diff --git a/loader/loadermisc.c b/loader/loadermisc.c
> index 2e667f5..b9e64f0 100644
> --- a/loader/loadermisc.c
> +++ b/loader/loadermisc.c
> @@ -87,6 +87,40 @@ int copyFile(char * source, char * dest) {
>      return rc;
>  }
>  
> +int rm_rf(const char* target) {
> +    /**
> +     * Do "rm -rf" on the target directory.
> +     *
> +     * Returns 0 on success, nonzero otherwise (i.e. directory doesn't exist or
> +     * some of its contents couldn't be removed.
> +     */
> +    DIR* dir = opendir(target);
> +    if (!dir)
> +        return(1);
> +    struct dirent* ent;
> +    char* entrypath;
> +    while ((ent=readdir(dir))) {
> +        if (!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, ".."))
> +            continue;
> +        asprintf(&entrypath, "%s/%s", target, ent->d_name);
> +        if (ent->d_type == DT_DIR) {
> +            if (rm_rf(entrypath))
> +                goto error;
> +        }
> +        else {
> +            if (remove(entrypath))
> +                goto error;
> +        }
> +    }
> +    if (remove(target))
> +        goto error;
> +    closedir(dir);
> +    return(0);
> + error:
> +    closedir(dir);
> +    return(1);
> +}
> +
>  int simpleStringCmp(const void * a, const void * b) {
>      const char * first = *((const char **) a);
>      const char * second = *((const char **) b);

I looked for a good while for some code that we already have that does
this, but it turns out there isn't any.  Barring that, pjones suggests
copying this code:

http://git.kernel.org/?p=utils/util-linux-ng/kzak/libmount.git;a=blob;f=sys-utils/switch_root.c;h=c43225da2e14dbc671251a037caef022b5b35c40;hb=HEAD#l41

It's already in use, and it already handles some corner cases.  I just
wish it were in a library.

- Chris

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux