package resize_fat::any; # $Id$ use diagnostics; use strict; use vars qw($FREE $FILE $DIRECTORY $UNMOVEABLE); use common; use resize_fat::fat; use resize_fat::directory; use resize_fat::dir_entry; use resize_fat::c_rewritten; $FREE = 0; $FILE = 1; $DIRECTORY = 2; $UNMOVEABLE = 8; 1; #- returns the number of clusters for a given filesystem type sub min_cluster_count($) { my ($fs) = @_; (1 << $ {{ FAT16 => 12, FAT32 => 12 }}{$fs->{fs_type}}) - 12; } sub max_cluster_count($) { my ($fs) = @_; (1 << $ {{ FAT16 => 16, FAT32 => 28 }}{$fs->{fs_type}}) - 11; } #- patch to get the function last_used that return the last used cluster of a fs. sub last_used($) { my ($fs) = @_; #- count in negative so absolute value count back to 2. foreach (-($fs->{nb_clusters}+1)..-2) { return -$_ if resize_fat::c_rewritten::flag(-$_) } die "any: empty FAT table of $fs->{nb_clusters} clusters"; } #- patch to get the function last_unmoveable that return the last unmoveable cluster of a fs. sub last_unmoveable($) { my ($fs) = @_; #- count in negative so absolute value count back to 2. foreach (-($fs->{nb_clusters}+1)..-2) { return -$_ if 0x8 & resize_fat::c_rewritten::flag(-$_) } #- Oh at this point there are no unmoveable blocks! 2; } #- calculates the minimum size of a partition, in physical sectors sub min_size($) { my ($fs) = @_; my $count = $fs->{clusters}{count}; #- directories are both in `used' and `dirs', so are counted twice #- It's done on purpose since we're moving all directories. So at the worse #- moment, 2 directories are there, but that way nothing wrong can happen :) my $min_cluster_count = max(2 + $count->{used} + $count->{bad} + $count->{dirs}, min_cluster_count($fs)); $min_cluster_count = max($min_cluster_count, last_unmoveable($fs)); my $size = $min_cluster_count * divide($fs->{cluster_size}, $SECTORSIZE) + divide($fs->{cluster_offset}, $SECTORSIZE) + 64*1024*1024 / $SECTORSIZE; #- help with such more sectors (ie 64Mb). #- help zindozs again with 512Mb+ at least else partition is ignored. if ($resize_fat::isFAT32) { $size = max($size, 524*1024*1024 / $SECTORSIZE); } $size; } #- calculates the maximum size of a partition, in physical sectors sub max_size($) { my ($fs) = @_; my $max_cluster_count = min($fs->{nb_fat_entries} - 2, max_cluster_count($fs)); $max_cluster_count * divide($fs->{cluster_size}, $SECTORSIZE) + divide($fs->{cluster_offset}, $SECTORSIZE); } #- calculates used size in order to avoid modifying anything. sub used_size($) { my ($fs) = @_; my $used_cluster_count = max(last_used($fs), min_cluster_count($fs)); $used_cluster_count * divide($fs->{cluster_size}, $SECTORSIZE) + divide($fs->{cluster_offset}, $SECTORSIZE); } #- fills in fat_flag_map in c_rewritten. #- Each FAT entry is flagged as either FREE, FILE or DIRECTORY. sub flag_clusters { my ($fs) = @_; my ($cluster, $curr_dir_name, $entry, $type, $nb_dirs); my $f = sub { ($curr_dir_name, $entry) = @_; $cluster = resize_fat::dir_entry::get_cluster($entry); if (resize_fat::dir_entry::is_file($entry)) { $type = $FILE; $type |= $UNMOVEABLE if resize_fat::dir_entry::is_unmoveable($entry); } elsif (resize_fat::dir_entry::is_directory($entry)) { $type = $DIRECTORY; } else { return } my $nb = resize_fat::c_rewritten::checkFat($cluster, $type, "$curr_dir_name/$entry->{name}"); print "resize_fat:flag_clusters: check fat returned $nb of type $type for $curr_dir_name/$entry->{name}\n"; $nb_dirs += $nb if $type == $DIRECTORY; 0; }; #- this must call allocate_fat_flag that zeroes the buffer allocated. resize_fat::c_rewritten::allocate_fat_flag($fs->{nb_clusters} + 2); resize_fat::directory::traverse_all($fs, $f); $fs->{clusters}{count}{dirs} = $nb_dirs; } cue-systemd'>user/colin/rescue-systemd</option> <option value='user/ennael/mga6'>user/ennael/mga6</option> <option value='user/erwan/bug-13680'>user/erwan/bug-13680</option> <option value='user/jibz/aarch64'>user/jibz/aarch64</option> <option value='user/martinw/mga6'>user/martinw/mga6</option> <option value='user/pterjan/arm64'>user/pterjan/arm64</option> </select> <input type='submit' value='switch'/></form></td></tr> <tr><td class='sub'>Mageia Installer and base platform for many utilities</td><td class='sub right'>Thierry Vignaud [tv]</td></tr></table> <table class='tabs'><tr><td> <a href='/software/drakx/?h=18.61'>summary</a><a href='/software/drakx/refs/?h=18.61&id=7f2587f6c640783b56b39bd5f25e0a78c977f301'>refs</a><a href='/software/drakx/log/perl-install/standalone/localedrake?h=18.61'>log</a><a class='active' href='/software/drakx/tree/perl-install/standalone/localedrake?h=18.61&id=7f2587f6c640783b56b39bd5f25e0a78c977f301'>tree</a><a href='/software/drakx/commit/perl-install/standalone/localedrake?h=18.61&id=7f2587f6c640783b56b39bd5f25e0a78c977f301'>commit</a><a href='/software/drakx/diff/perl-install/standalone/localedrake?h=18.61&id=7f2587f6c640783b56b39bd5f25e0a78c977f301'>diff</a><a href='/software/drakx/stats/perl-install/standalone/localedrake?h=18.61'>stats</a></td><td class='form'><form class='right' method='get' action='/software/drakx/log/perl-install/standalone/localedrake'> <input type='hidden' name='h' value='18.61'/><input type='hidden' name='id' value='7f2587f6c640783b56b39bd5f25e0a78c977f301'/><select name='qt'> <option value='grep'>log msg</option> <option value='author'>author</option> <option value='committer'>committer</option> <option value='range'>range</option> </select> <input class='txt' type='search' size='10' name='q' value=''/> <input type='submit' value='search'/> </form> </td></tr></table> <div class='path'>path: <a href='/software/drakx/tree/?h=18.61&id=7f2587f6c640783b56b39bd5f25e0a78c977f301'>root</a>/<a href='/software/drakx/tree/perl-install?h=18.61&id=7f2587f6c640783b56b39bd5f25e0a78c977f301'>perl-install</a>/<a href='/software/drakx/tree/perl-install/standalone?h=18.61&id=7f2587f6c640783b56b39bd5f25e0a78c977f301'>standalone</a>/<a href='/software/drakx/tree/perl-install/standalone/localedrake?h=18.61&id=7f2587f6c640783b56b39bd5f25e0a78c977f301'>localedrake</a></div><div class='content'>blob: e89804d3f16fbfc1f76dab8018c39401fef85a29 (<a href='/software/drakx/plain/perl-install/standalone/localedrake?h=18.61&id=7f2587f6c640783b56b39bd5f25e0a78c977f301'>plain</a>) <table summary='blob content' class='blob'> <tr><td class='linenumbers'><pre><a id='n1' href='#n1'>1</a> <a id='n2' href='#n2'>2</a> <a id='n3' href='#n3'>3</a> <a id='n4' href='#n4'>4</a> <a id='n5' href='#n5'>5</a> <a id='n6' href='#n6'>6</a> <a id='n7' href='#n7'>7</a> <a id='n8' href='#n8'>8</a> <a id='n9' href='#n9'>9</a> <a id='n10' href='#n10'>10</a> <a id='n11' href='#n11'>11</a> <a id='n12' href='#n12'>12</a> <a id='n13' href='#n13'>13</a> <a id='n14' href='#n14'>14</a> <a id='n15' href='#n15'>15</a> <a id='n16' href='#n16'>16</a> <a id='n17' href='#n17'>17</a> <a id='n18' href='#n18'>18</a> <a id='n19' href='#n19'>19</a> <a id='n20' href='#n20'>20</a> <a id='n21' href='#n21'>21</a> <a id='n22' href='#n22'>22</a> <a id='n23' href='#n23'>23</a> <a id='n24' href='#n24'>24</a> <a id='n25' href='#n25'>25</a> <a id='n26' href='#n26'>26</a> <a id='n27' href='#n27'>27</a> <a id='n28' href='#n28'>28</a> <a id='n29' href='#n29'>29</a> <a id='n30' href='#n30'>30</a> <a id='n31' href='#n31'>31</a> <a id='n32' href='#n32'>32</a> <a id='n33' href='#n33'>33</a> <a id='n34' href='#n34'>34</a> <a id='n35' href='#n35'>35</a> <a id='n36' href='#n36'>36</a> <a id='n37' href='#n37'>37</a> <a id='n38' href='#n38'>38</a> <a id='n39' href='#n39'>39</a> <a id='n40' href='#n40'>40</a> <a id='n41' href='#n41'>41</a> <a id='n42' href='#n42'>42</a> <a id='n43' href='#n43'>43</a> <a id='n44' href='#n44'>44</a> <a id='n45' href='#n45'>45</a> <a id='n46' href='#n46'>46</a> <a id='n47' href='#n47'>47</a> <a id='n48' href='#n48'>48</a> <a id='n49' href='#n49'>49</a> <a id='n50' href='#n50'>50</a> <a id='n51' href='#n51'>51</a> <a id='n52' href='#n52'>52</a> <a id='n53' href='#n53'>53</a> <a id='n54' href='#n54'>54</a> <a id='n55' href='#n55'>55</a> <a id='n56' href='#n56'>56</a> <a id='n57' href='#n57'>57</a> <a id='n58' href='#n58'>58</a> <a id='n59' href='#n59'>59</a> <a id='n60' href='#n60'>60</a> <a id='n61' href='#n61'>61</a> <a id='n62' href='#n62'>62</a> <a id='n63' href='#n63'>63</a> <a id='n64' href='#n64'>64</a> <a id='n65' href='#n65'>65</a> <a id='n66' href='#n66'>66</a> <a id='n67' href='#n67'>67</a> <a id='n68' href='#n68'>68</a> </pre></td> <td class='lines'><pre><code>#!/usr/bin/perl use lib qw(/usr/lib/libDrakX); use standalone; #- warning, standalone must be loaded very first, for 'explanations' use interactive; use common; use lang; use any; my ($klang, $kcountry, $apply); foreach (@ARGV) { $apply = /--apply/; $klang = $1 if /--kde_lang=(.*)/; $kcountry = uc($1) if /--kde_country=(.*)/; } if (defined $klang) { $klang or exit(-1); my $lang = member($klang, lang::list_langs()) ? $klang : 'en_US'; my $country = member($kcountry, lang::list_countries()) ? $kcountry : 'US'; my $locale = lang::read('', $>); $klang and $locale->{lang} = $lang; $kcountry and $locale->{country} = $country; lang::write('', $locale, $>, 'dont_touch_kde_files') if $apply; #- help KDE defaulting to the right charset print lang::charset2kde_charset(lang::l2charset($lang)), "\n"; exit(0); } my $locale = lang::read('', $>); my $in = 'interactive'->vnew; sub select_language() { $locale->{lang} = any::selectLanguage($in, $locale->{lang}); } sub select_country() { any::selectCountry($in, $locale); } eval { language: select_language() or goto the_end; select_country() or goto language; }; if ($@) { if ($@ =~ /^one lang only/) { select_country() or goto the_end; } else { die; } } lang::write('', $locale, $>); if ($>) { if (my $wm = any::running_window_manager()) { $in->ask_okcancel('', N("The change is done, but to be effective you must logout"), 1) and any::ask_window_manager_to_logout($wm); } } the_end: $in->exit(0); </code></pre></td></tr></table> </div> <!-- class=content --> <div class='footer'>generated by <a href='https://git.zx2c4.com/cgit/about/'>cgit v1.2.1</a> (<a href='https://git-scm.com/'>git 2.21.0</a>) at 2024-12-26 02:39:22 +0000</div> </div> <!-- id=cgit --> </body> </html>