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

Re: [Xen-devel] [PATCH 2/6] osstest: introduce a helper to create a weblink to a directory


  • To: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • From: Ian Jackson <ian.jackson@xxxxxxxxxx>
  • Date: Thu, 23 May 2019 10:57:08 +0100
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=ian.jackson@xxxxxxxxxx; spf=Pass smtp.mailfrom=Ian.Jackson@xxxxxxxxxx; spf=None smtp.helo=postmaster@xxxxxxxxxxxxxxxxxxxxxxxxxx
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 23 May 2019 09:57:50 +0000
  • Ironport-sdr: WyjKrYgr8ao3YvYNV+CYWc6b77oVrYAs0Oe7kt3RJJIT/ZsVa5LNR+MveF8jkppfISvEDLnJAl 9Ht4dWIHnCYMtS2bXWMq+kXVGv7m697gVggdGEhMKoZE2RKAhP4gy0AnpSOIyg/ilXvKXBrXzu oq16uaa1Z70s2fGdXtPgw5QBCoTNCmyN14iRlFrTk1Xpy7bwACEA6Lj/tLqczdrGNxm9pTS18l 66+ITrPLImTyivkZ0f/FbR4AdGV6z9awG66yGT9wgT6//2yZYZN4JzytADMuFJ8yPnSJHXW4aY 4EU=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Roger Pau Monne writes ("[Xen-devel] [PATCH 2/6] osstest: introduce a helper to 
create a weblink to a directory"):
> +sub create_weblink ($$$) {
> +    my ($ho, $tail, $target) = @_;
> +    my $wf_rhs= hostnamepath($ho)."_".$tail;
> +    my $wf_common= $c{WebspaceCommon}.$wf_rhs;
> +    my $wf_url= $c{WebspaceUrl}.$wf_common;
> +    my $wf_file= $c{WebspaceFile}.$wf_common;
> +
> +    unlink $wf_file;
> +    symlink $target, $wf_file or die "$wf_file $!";
> +    return $wf_url;

Most of this is the start of create_webfile.  Can you factor that
out ?

I have three suggestions for the shape:

      my ($wf_file, $wf_url) = prepare_create_webfile($ho, $tail);
      symlink $target, $wf_file or die "$wf_file $!";
      return $wf_url;
  }
      
or split create_webfile into create_web_fsobject which takes a
subref, and the call to file_link_contents:

      create_web_fsobject($ho, $tail, sub {
          my ($wf_file) = @_;
          symlink $target, $wf_file or die "$wf_file $!";
      });
  }

or the same but make passing a subref as $contents legal for
create_webfile,

 sub create_webfile ($$$) {
     my .... $contents_spec);
     # $contents as for file_link_contents, or a subref
     # which will be called as $contents_spec($wf_file,$wf_url);
     ...
     if (ref($contents_spec) ne 'CODE') {
         my $contents =  $contents_spec;
         $contents_spec = sub {
             my ($wf_file) = @_;
             file_link_contents($wf_file, $contents, "webspace-$wf_rhs");
         };
     }

Take your pick, or do something similar ?

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.