             ##################################################
             #  PERL SCRIPTS FOR EXTENDED ATTRIBUTES          #
             #  Author: Ritu Sati                             #
             #  eMail : sritu@novell.com                      #
             #  Version : 1.0                                 # 
             ################################################## 



@char=('r','r_vp','rt56','hj-k3','hg@%k','op*_fd','gfghgf','tyty_soos_3000','th651','hdhs','hg_%$j','gnb','4dq','f5','hi','df','gds','567-op','hrt_5','hdgdf','rst','gdfg','6tdr','dr54','jh43','hg_243','jh87h','9876');

#------------------------------------------------------------------------------------------------------------------------------------------------
# file creation:

mkdir ("test" ,0777);
{
  print ( "\n enter the no of files");
   $file=<stdin>;

  for ( $j=1;$j<=$file;$j++)
    {
     $a=z;
     $op = open (S, ">test/data$j");
     print S ($a x 1024);
     close (S);
     }
     chdir ("test");
    }
 


#------------------------------------------------------------------
#---- name  values pair for files and directories:                                                                                                                                     

for ( $j=1;$j<=$file;$j++)
 {
 $usr=int(rand(10));
 $user=$usr +1;
   for ($u=1;$u<=$user;$u++)
   {
   $nspace[j]=1;
   $attr ="user";
   $op = int(rand(40));
   $ext =$op +1;
    for ($i=1;$i<=$ext;$i++)
     {
      $in = int(rand(26));
      $name =$char[$in];
      $no =$name;
      $attr =$attr."." .$no;
      $rt[$j]=$attr;
      $nspace[j]++;
     }
                                                                                                                                    
   $stl= int(rand(500));
   $stl1 =$stl+1;
   my $random_string=&generate_random_string($stl1);
   $valu[$j]=$random_string;
                                                                                                                                    
   print( "\n namespace=$nspace[j] ");
   print ("\n Vlength=$stl1");
   print("\n"); 

                                                                                                                                    
  print ("\n NAME= $rt[$j]");
  print ("\n");
  print ("\n VALUE= $valu[$j]");
  print ("\n");
                                                                                                                                    
system ( setfattr." " .-n." ".$rt[$j]." ".-v ."    " .$valu[$j]. " " ."data$j");
    }
 }


#-----------------------------------------------------------------------------
# random string generation function:
                                                                                                                                    
                                                                                                                                    
sub generate_random_string
{
        my $length_of_randomstring=shift;
        my @chars=('a'..'z','A'..'Z','0'..'9', '#','%','*','^','$','@' );
       # my @chars=('&');
          my $random_string;
        foreach (1..$length_of_randomstring)
        {
                # rand @chars will generate a random
                # number between 0 and scalar @chars
                $random_string.=$chars[rand @chars];
        }
        return $random_string;
}
#------------------------------------------------------------------------------
#End of program:
























                                                                                                                                   
                                                                                                                                                                                                                                                                     



                                                                                                                                  
                                                                                                                                  



                                                                                                                                  
                                                                                                                                  


                                                                                                                                 
                                                                                                                                  


                                                                                                                                  
                                                                                                                                  













