<commit_before># dfs-lib.pl
# Common functions for managing dfstab files

do '../web-lib.pl';
&init_config();
do '../ui-lib.pl';
%access = &get_module_acl();

$default_type = 'nfs';
if ($config{'fstypes_file'} && open(TYPES, $config{'fstypes_file'})) {
	if (<TYPES> =~ /^(\S+)/) {
		$default_type = $1;
		}
	close(TYPES);
	}
%access = &get_module_acl();

# list_shares()
# Returns a list of structures containing share details
sub list_shares
{
local $lnum = 0;
local @rv;
open(DFS, $config{'dfstab_file'});
while(<DFS>) {
	s/\r|\n//g; s/#.*$//;
	if (/^\s*\S*share\s+(.*)/) {
		# Found a share line
		local $share = { 'line' => $lnum,
				 'index' => scalar(@rv) };
		local $line = $1;
		while($line =~ /\\$/) {
			$_ = <DFS>;
			s/\r|\n//g; s/#.*$//;
			$line =~ s/\\$//;
			$line .= $_;
			$lnum++;
			}
		$share->{'eline'} = $lnum;
		if ($line =~ /(\/\S+)/) {
			$share->{'dir'} = $1;
			}
		if ($line =~ /-d\s+"([^"]+)"/) { $share->{'desc'} = $1; }
		elsif ($line =~ /-d\s+(\S+)/) { $share->{'desc'} = $1; }
		if ($line =~ /-o\s+"([^"]+)"/) { $share->{'opts'} = $1; }
		elsif ($line =~ /-o\s+(\S+)/) { $share->{'opts'} = $1; }
		if ($line =~ /\s-F\s+(\S+)/) { $share->{'type'} = $1; }
		else { $share->{'type'} = $default_type; }
		push(@rv, $share);
		}
	$lnum++;
	}
close(DFS);
return @rv;
}

# create_share(&share)
# Add a new share to the dfstab file
sub create_share
{
&open_tempfile(DFS, ">> $config{dfstab_file}");
&print_tempfile(DFS, &share_line($_[0]),"\n");<commit_msg>Handle shares like 172.16.31.10/24<commit_after># dfs-lib.pl
# Common functions for managing dfstab files

do '../web-lib.pl';
&init_config();
do '../ui-lib.pl';
%access = &get_module_acl();

$default_type = 'nfs';
if ($config{'fstypes_file'} && open(TYPES, $config{'fstypes_file'})) {
	if (<TYPES> =~ /^(\S+)/) {
		$default_type = $1;
		}
	close(TYPES);
	}
%access = &get_module_acl();

# list_shares()
# Returns a list of structures containing share details
sub list_shares
{
local $lnum = 0;
local @rv;
open(DFS, $config{'dfstab_file'});
while(<DFS>) {
	s/\r|\n//g; s/#.*$//;
	if (/^\s*\S*share\s+(.*)/) {
		# Found a share line
		local $share = { 'line' => $lnum,
				 'index' => scalar(@rv) };
		local $line = $1;
		while($line =~ /\\$/) {
			$_ = <DFS>;
			s/\r|\n//g; s/#.*$//;
			$line =~ s/\\$//;
			$line .= $_;
			$lnum++;
			}
		$share->{'eline'} = $lnum;
		if ($line =~ /\s(\/\S+)/) {
			$share->{'dir'} = $1;
			}
		if ($line =~ /-d\s+"([^"]+)"/) { $share->{'desc'} = $1; }
		elsif ($line =~ /-d\s+(\S+)/) { $share->{'desc'} = $1; }
		if ($line =~ /-o\s+"([^"]+)"/) { $share->{'opts'} = $1; }
		elsif ($line =~ /-o\s+(\S+)/) { $share->{'opts'} = $1; }
		if ($line =~ /\s-F\s+(\S+)/) { $share->{'type'} = $1; }
		else { $share->{'type'} = $default_type; }
		push(@rv, $share);
		}
	$lnum++;
	}
close(DFS);
return @rv;
}

# create_share(&share)
# Add a new share to the dfstab file
sub create_share
{
&open_tempfile(DFS, ">> $config{dfstab_file}");
&print_tempfile(DFS, &share_line($_[0]),"\n");
{'fraction_non_alphanumeric': 0.3045804078903377, 'fraction_numerical': 0.010364426613172852, 'mean_word_length': 3.1613351877607787, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3581204', 'n_tokens_mistral': 1445, 'n_tokens_neox': 1356, 'n_words': 260}