Changes in / [4006447:463e734] in mainline


Ignore:
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • Makefile

    r4006447 r463e734  
    4141CONFIG_HEADER = config.h
    4242
    43 .PHONY: all precheck cscope autotool config_auto config_default config distclean clean
     43.PHONY: all precheck cscope autotool config_default config distclean clean
    4444
    4545all: $(COMMON_MAKEFILE) $(COMMON_HEADER) $(CONFIG_MAKEFILE) $(CONFIG_HEADER)
     
    6666
    6767config_default: $(CONFIG_RULES)
    68 ifeq ($(HANDS_OFF),y)
    69         $(CONFIG) $< hands-off $(PROFILE)
    70 else
    71         $(CONFIG) $< default $(PROFILE)
    72 endif
     68        $(CONFIG) $< default
    7369
    7470config: $(CONFIG_RULES)
  • tools/config.py

    r4006447 r463e734  
    33# Copyright (c) 2006 Ondrej Palkovsky
    44# Copyright (c) 2009 Martin Decky
    5 # Copyright (c) 2010 Jiri Svoboda
    65# All rights reserved.
    76#
     
    4140import xtui
    4241
    43 RULES_FILE = sys.argv[1]
     42INPUT = sys.argv[1]
    4443MAKEFILE = 'Makefile.config'
    4544MACROS = 'config.h'
    46 PRESETS_DIR = 'defaults'
    47 
    48 def read_config(fname, config):
    49         "Read saved values from last configuration run or a preset file"
     45PRECONF = 'defaults'
     46
     47def read_defaults(fname, defaults):
     48        "Read saved values from last configuration run"
    5049       
    5150        inf = open(fname, 'r')
     
    5352        for line in inf:
    5453                res = re.match(r'^(?:#!# )?([^#]\w*)\s*=\s*(.*?)\s*$', line)
    55                 if res:
    56                         config[res.group(1)] = res.group(2)
     54                if (res):
     55                        defaults[res.group(1)] = res.group(2)
    5756       
    5857        inf.close()
    5958
    60 def check_condition(text, config, rules):
     59def check_condition(text, defaults, ask_names):
    6160        "Check that the condition specified on input line is True (only CNF and DNF is supported)"
    6261       
    6362        ctype = 'cnf'
    6463       
    65         if (')|' in text) or ('|(' in text):
     64        if ((')|' in text) or ('|(' in text)):
    6665                ctype = 'dnf'
    6766       
    68         if ctype == 'cnf':
     67        if (ctype == 'cnf'):
    6968                conds = text.split('&')
    7069        else:
     
    7271       
    7372        for cond in conds:
    74                 if cond.startswith('(') and cond.endswith(')'):
     73                if (cond.startswith('(')) and (cond.endswith(')')):
    7574                        cond = cond[1:-1]
    7675               
    77                 inside = check_inside(cond, config, ctype)
     76                inside = check_inside(cond, defaults, ctype)
    7877               
    7978                if (ctype == 'cnf') and (not inside):
    8079                        return False
    8180               
    82                 if (ctype == 'dnf') and inside:
     81                if (ctype == 'dnf') and (inside):
    8382                        return True
    8483       
    85         if ctype == 'cnf':
     84        if (ctype == 'cnf'):
    8685                return True
    8786        return False
    8887
    89 def check_inside(text, config, ctype):
     88def check_inside(text, defaults, ctype):
    9089        "Check for condition"
    9190       
    92         if ctype == 'cnf':
     91        if (ctype == 'cnf'):
    9392                conds = text.split('|')
    9493        else:
     
    9796        for cond in conds:
    9897                res = re.match(r'^(.*?)(!?=)(.*)$', cond)
    99                 if not res:
     98                if (not res):
    10099                        raise RuntimeError("Invalid condition: %s" % cond)
    101100               
     
    104103                condval = res.group(3)
    105104               
    106                 if not condname in config:
     105                if (not condname in defaults):
    107106                        varval = ''
    108107                else:
    109                         varval = config[condname]
     108                        varval = defaults[condname]
    110109                        if (varval == '*'):
    111110                                varval = 'y'
    112111               
    113                 if ctype == 'cnf':
     112                if (ctype == 'cnf'):
    114113                        if (oper == '=') and (condval == varval):
    115114                                return True
     
    124123                                return False
    125124       
    126         if ctype == 'cnf':
     125        if (ctype == 'cnf'):
    127126                return False
    128127       
    129128        return True
    130129
    131 def parse_rules(fname, rules):
    132         "Parse rules file"
     130def parse_config(fname, ask_names):
     131        "Parse configuration file"
    133132       
    134133        inf = open(fname, 'r')
     
    139138        for line in inf:
    140139               
    141                 if line.startswith('!'):
     140                if (line.startswith('!')):
    142141                        # Ask a question
    143142                        res = re.search(r'!\s*(?:\[(.*?)\])?\s*([^\s]+)\s*\((.*)\)\s*$', line)
    144143                       
    145                         if not res:
     144                        if (not res):
    146145                                raise RuntimeError("Weird line: %s" % line)
    147146                       
     
    150149                        vartype = res.group(3)
    151150                       
    152                         rules.append((varname, vartype, name, choices, cond))
     151                        ask_names.append((varname, vartype, name, choices, cond))
    153152                        name = ''
    154153                        choices = []
    155154                        continue
    156155               
    157                 if line.startswith('@'):
     156                if (line.startswith('@')):
    158157                        # Add new line into the 'choices' array
    159158                        res = re.match(r'@\s*(?:\[(.*?)\])?\s*"(.*?)"\s*(.*)$', line)
     
    165164                        continue
    166165               
    167                 if line.startswith('%'):
     166                if (line.startswith('%')):
    168167                        # Name of the option
    169168                        name = line[1:].strip()
    170169                        continue
    171170               
    172                 if line.startswith('#') or (line == '\n'):
     171                if ((line.startswith('#')) or (line == '\n')):
    173172                        # Comment or empty line
    174173                        continue
     
    182181        "Return '*' if yes, ' ' if no"
    183182       
    184         if default == 'y':
     183        if (default == 'y'):
    185184                return '*'
    186185       
     
    200199        cnt = 0
    201200        for key, val in choices:
    202                 if (default) and (key == default):
     201                if ((default) and (key == default)):
    203202                        position = cnt
    204203               
     
    208207        (button, value) = xtui.choice_window(screen, name, 'Choose value', options, position)
    209208       
    210         if button == 'cancel':
     209        if (button == 'cancel'):
    211210                return None
    212211       
    213212        return choices[value][0]
    214213
    215 ## Infer and verify configuration values.
    216 #
    217 # Augment @a config with values that can be inferred, purge invalid ones
    218 # and verify that all variables have a value (previously specified or inferred).
    219 #
    220 # @param config Configuration to work on
    221 # @param rules  Rules
    222 #
    223 # @return True if configuration is complete and valid, False
    224 #         otherwise.
    225 #
    226 def infer_verify_choices(config, rules):
    227         "Infer and verify configuration values."
    228        
    229         for rule in rules:
    230                 varname, vartype, name, choices, cond = rule
    231                
    232                 if cond and (not check_condition(cond, config, rules)):
    233                         continue
    234                
    235                 if not varname in config:
    236                         value = None
    237                 else:
    238                         value = config[varname]
    239                
    240                 if not validate_rule_value(rule, value):
    241                         value = None
    242                
    243                 default = get_default_rule(rule)
    244                 if default != None:
    245                         config[varname] = default
    246                
    247                 if not varname in config:
     214def check_choices(defaults, ask_names):
     215        "Check whether all accessible variables have a default"
     216       
     217        for varname, vartype, name, choices, cond in ask_names:
     218                if ((cond) and (not check_condition(cond, defaults, ask_names))):
     219                        continue
     220               
     221                if (not varname in defaults):
    248222                        return False
    249223       
    250224        return True
    251225
    252 ## Get default value from a rule.
    253 def get_default_rule(rule):
    254         varname, vartype, name, choices, cond = rule
    255        
    256         default = None
    257        
    258         if vartype == 'choice':
    259                 # If there is just one option, use it
    260                 if len(choices) == 1:
    261                         default = choices[0][0]
    262         elif vartype == 'y':
    263                 default = '*'
    264         elif vartype == 'n':
    265                 default = 'n'
    266         elif vartype == 'y/n':
    267                 default = 'y'
    268         elif vartype == 'n/y':
    269                 default = 'n'
    270         else:
    271                 raise RuntimeError("Unknown variable type: %s" % vartype)
    272        
    273         return default
    274 
    275 ## Get option from a rule.
    276 #
    277 # @param rule  Rule for a variable
    278 # @param value Current value of the variable
    279 #
    280 # @return Option (string) to ask or None which means not to ask.
    281 #
    282 def get_rule_option(rule, value):
    283         varname, vartype, name, choices, cond = rule
    284        
    285         option = None
    286        
    287         if vartype == 'choice':
    288                 # If there is just one option, don't ask
    289                 if len(choices) != 1:
    290                         if (value == None):
    291                                 option = "?     %s --> " % name
    292                         else:
    293                                 option = "      %s [%s] --> " % (name, value)
    294         elif vartype == 'y':
    295                 pass
    296         elif vartype == 'n':
    297                 pass
    298         elif vartype == 'y/n':
    299                 option = "  <%s> %s " % (yes_no(value), name)
    300         elif vartype == 'n/y':
    301                 option ="  <%s> %s " % (yes_no(value), name)
    302         else:
    303                 raise RuntimeError("Unknown variable type: %s" % vartype)
    304        
    305         return option
    306 
    307 ## Check if variable value is valid.
    308 #
    309 # @param rule  Rule for the variable
    310 # @param value Value of the variable
    311 #
    312 # @return True if valid, False if not valid.
    313 #
    314 def validate_rule_value(rule, value):
    315         varname, vartype, name, choices, cond = rule
    316        
    317         if value == None:
    318                 return True
    319        
    320         if vartype == 'choice':
    321                 if not value in [choice[0] for choice in choices]:
    322                         return False
    323         elif vartype == 'y':
    324                 if value != 'y':
    325                         return False
    326         elif vartype == 'n':
    327                 if value != 'n':
    328                         return False
    329         elif vartype == 'y/n':
    330                 if not value in ['y', 'n']:
    331                         return False
    332         elif vartype == 'n/y':
    333                 if not value in ['y', 'n']:
    334                         return False
    335         else:
    336                 raise RuntimeError("Unknown variable type: %s" % vartype)
    337        
    338         return True
    339 
    340 def create_output(mkname, mcname, config, rules):
     226def create_output(mkname, mcname, defaults, ask_names):
    341227        "Create output configuration"
    342228       
     
    352238                sys.stderr.write("failed\n")
    353239       
    354         if len(version) == 3:
     240        if (len(version) == 3):
    355241                revision = version[1]
    356                 if version[0] != 1:
     242                if (version[0] != 1):
    357243                        revision += 'M'
    358244                revision += ' (%s)' % version[2]
     
    373259        defs = 'CONFIG_DEFS ='
    374260       
    375         for varname, vartype, name, choices, cond in rules:
    376                 if cond and (not check_condition(cond, config, rules)):
    377                         continue
    378                
    379                 if not varname in config:
    380                         value = ''
     261        for varname, vartype, name, choices, cond in ask_names:
     262                if ((cond) and (not check_condition(cond, defaults, ask_names))):
     263                        continue
     264               
     265                if (not varname in defaults):
     266                        default = ''
    381267                else:
    382                         value = config[varname]
    383                         if (value == '*'):
    384                                 value = 'y'
    385                
    386                 outmk.write('# %s\n%s = %s\n\n' % (name, varname, value))
    387                
    388                 if vartype in ["y", "n", "y/n", "n/y"]:
    389                         if value == "y":
     268                        default = defaults[varname]
     269                        if (default == '*'):
     270                                default = 'y'
     271               
     272                outmk.write('# %s\n%s = %s\n\n' % (name, varname, default))
     273               
     274                if ((vartype == "y") or (vartype == "n") or (vartype == "y/n") or (vartype == "n/y")):
     275                        if (default == "y"):
    390276                                outmc.write('/* %s */\n#define %s\n\n' % (name, varname))
    391277                                defs += ' -D%s' % varname
    392278                else:
    393                         outmc.write('/* %s */\n#define %s %s\n#define %s_%s\n\n' % (name, varname, value, varname, value))
    394                         defs += ' -D%s=%s -D%s_%s' % (varname, value, varname, value)
    395        
    396         if revision is not None:
     279                        outmc.write('/* %s */\n#define %s %s\n#define %s_%s\n\n' % (name, varname, default, varname, default))
     280                        defs += ' -D%s=%s -D%s_%s' % (varname, default, varname, default)
     281       
     282        if (revision is not None):
    397283                outmk.write('REVISION = %s\n' % revision)
    398284                outmc.write('#define REVISION %s\n' % revision)
     
    413299        return list
    414300
    415 ## Ask user to choose a configuration profile.
    416 #
    417 def choose_profile(root, fname, screen, config):
     301def read_preconfigured(root, fname, screen, defaults):
    418302        options = []
    419303        opt2path = {}
     
    425309                canon = os.path.join(path, fname)
    426310               
    427                 if os.path.isdir(path) and os.path.exists(canon) and os.path.isfile(canon):
     311                if ((os.path.isdir(path)) and (os.path.exists(canon)) and (os.path.isfile(canon))):
    428312                        subprofile = False
    429313                       
     
    433317                                subcanon = os.path.join(subpath, fname)
    434318                               
    435                                 if os.path.isdir(subpath) and os.path.exists(subcanon) and os.path.isfile(subcanon):
     319                                if ((os.path.isdir(subpath)) and (os.path.exists(subcanon)) and (os.path.isfile(subcanon))):
    436320                                        subprofile = True
    437321                                        options.append("%s (%s)" % (name, subname))
    438                                         opt2path[cnt] = [name, subname]
     322                                        opt2path[cnt] = (canon, subcanon)
    439323                                        cnt += 1
    440324                       
    441                         if not subprofile:
     325                        if (not subprofile):
    442326                                options.append(name)
    443                                 opt2path[cnt] = [name]
     327                                opt2path[cnt] = (canon, None)
    444328                                cnt += 1
    445329       
    446330        (button, value) = xtui.choice_window(screen, 'Load preconfigured defaults', 'Choose configuration profile', options, None)
    447331       
    448         if button == 'cancel':
     332        if (button == 'cancel'):
    449333                return None
    450334       
    451         return opt2path[value]
    452 
    453 ## Read presets from a configuration profile.
    454 #
    455 # @param profile Profile to load from (a list of string components)
    456 # @param config  Output configuration
    457 #
    458 def read_presets(profile, config):
    459         path = os.path.join(PRESETS_DIR, profile[0], MAKEFILE)
    460         read_config(path, config)
    461        
    462         if len(profile) > 1:
    463                 path = os.path.join(PRESETS_DIR, profile[0], profile[1], MAKEFILE)
    464                 read_config(path, config)
    465 
    466 ## Parse profile name (relative OS path) into a list of components.
    467 #
    468 # @param profile_name Relative path (using OS separator)
    469 # @return             List of components
    470 #
    471 def parse_profile_name(profile_name):
    472         profile = []
    473        
    474         head, tail = os.path.split(profile_name)
    475         if head != '':
    476                 profile.append(head)
    477        
    478         profile.append(tail)
    479         return profile
     335        read_defaults(opt2path[value][0], defaults)
     336        if (opt2path[value][1] != None):
     337                read_defaults(opt2path[value][1], defaults)
    480338
    481339def main():
    482         profile = None
    483         config = {}
    484         rules = []
    485        
    486         # Parse rules file
    487         parse_rules(RULES_FILE, rules)
    488        
    489         # Input configuration file can be specified on command line
    490         # otherwise configuration from previous run is used.
    491         if len(sys.argv) >= 4:
    492                 profile = parse_profile_name(sys.argv[3])
    493                 read_presets(profile, config)
    494         elif os.path.exists(MAKEFILE):
    495                 read_config(MAKEFILE, config)
    496        
    497         # Default mode: check values and regenerate configuration files
    498         if (len(sys.argv) >= 3) and (sys.argv[2] == 'default'):
    499                 if (infer_verify_choices(config, rules)):
    500                         create_output(MAKEFILE, MACROS, config, rules)
     340        defaults = {}
     341        ask_names = []
     342       
     343        # Parse configuration file
     344        parse_config(INPUT, ask_names)
     345       
     346        # Read defaults from previous run
     347        if os.path.exists(MAKEFILE):
     348                read_defaults(MAKEFILE, defaults)
     349       
     350        # Default mode: only check defaults and regenerate configuration
     351        if ((len(sys.argv) >= 3) and (sys.argv[2] == 'default')):
     352                if (check_choices(defaults, ask_names)):
     353                        create_output(MAKEFILE, MACROS, defaults, ask_names)
    501354                        return 0
    502355       
    503         # Hands-off mode: check values and regenerate configuration files,
    504         # but no interactive fallback
    505         if (len(sys.argv) >= 3) and (sys.argv[2] == 'hands-off'):
    506                 # We deliberately test sys.argv >= 4 because we do not want
    507                 # to read implicitly any possible previous run configuration
    508                 if len(sys.argv) < 4:
    509                         sys.stderr.write("Configuration error: No presets specified\n")
    510                         return 2
    511                
    512                 if (infer_verify_choices(config, rules)):
    513                         create_output(MAKEFILE, MACROS, config, rules)
    514                         return 0
    515                
    516                 sys.stderr.write("Configuration error: The presets are ambiguous\n")
    517                 return 1
    518        
    519         # Check mode: only check configuration
    520         if (len(sys.argv) >= 3) and (sys.argv[2] == 'check'):
    521                 if infer_verify_choices(config, rules):
     356        # Check mode: only check defaults
     357        if ((len(sys.argv) >= 3) and (sys.argv[2] == 'check')):
     358                if (check_choices(defaults, ask_names)):
    522359                        return 0
    523360                return 1
     
    529366                while True:
    530367                       
    531                         # Cancel out all values which have to be deduced
    532                         for varname, vartype, name, choices, cond in rules:
    533                                 if (vartype == 'y') and (varname in config) and (config[varname] == '*'):
    534                                         config[varname] = None
     368                        # Cancel out all defaults which have to be deduced
     369                        for varname, vartype, name, choices, cond in ask_names:
     370                                if ((vartype == 'y') and (varname in defaults) and (defaults[varname] == '*')):
     371                                        defaults[varname] = None
    535372                       
    536373                        options = []
     
    540377                        options.append("  --- Load preconfigured defaults ... ")
    541378                       
    542                         for rule in rules:
    543                                 varname, vartype, name, choices, cond = rule
    544                                
    545                                 if cond and (not check_condition(cond, config, rules)):
     379                        for varname, vartype, name, choices, cond in ask_names:
     380                               
     381                                if ((cond) and (not check_condition(cond, defaults, ask_names))):
    546382                                        continue
    547383                               
    548                                 if varname == selname:
     384                                if (varname == selname):
    549385                                        position = cnt
    550386                               
    551                                 if not varname in config:
    552                                         value = None
     387                                if (not varname in defaults):
     388                                        default = None
    553389                                else:
    554                                         value = config[varname]
    555                                
    556                                 if not validate_rule_value(rule, value):
    557                                         value = None
    558                                
    559                                 default = get_default_rule(rule)
    560                                 if default != None:
    561                                         if value == None:
    562                                                 value = default
    563                                         config[varname] = value
    564                                
    565                                 option = get_rule_option(rule, value)
    566                                 if option != None:
    567                                         options.append(option)
     390                                        default = defaults[varname]
     391                               
     392                                if (vartype == 'choice'):
     393                                        # Check if the default is an acceptable value
     394                                        if ((default) and (not default in [choice[0] for choice in choices])):
     395                                                default = None
     396                                                defaults.pop(varname)
     397                                       
     398                                        # If there is just one option, use it
     399                                        if (len(choices) == 1):
     400                                                defaults[varname] = choices[0][0]
     401                                                continue
     402                                       
     403                                        if (default == None):
     404                                                options.append("?     %s --> " % name)
     405                                        else:
     406                                                options.append("      %s [%s] --> " % (name, default))
     407                                elif (vartype == 'y'):
     408                                        defaults[varname] = '*'
     409                                        continue
     410                                elif (vartype == 'n'):
     411                                        defaults[varname] = 'n'
     412                                        continue
     413                                elif (vartype == 'y/n'):
     414                                        if (default == None):
     415                                                default = 'y'
     416                                                defaults[varname] = default
     417                                        options.append("  <%s> %s " % (yes_no(default), name))
     418                                elif (vartype == 'n/y'):
     419                                        if (default == None):
     420                                                default = 'n'
     421                                                defaults[varname] = default
     422                                        options.append("  <%s> %s " % (yes_no(default), name))
    568423                                else:
    569                                         continue
     424                                        raise RuntimeError("Unknown variable type: %s" % vartype)
    570425                               
    571426                                opt2row[cnt] = (varname, vartype, name, choices)
     
    578433                        (button, value) = xtui.choice_window(screen, 'HelenOS configuration', 'Choose configuration option', options, position)
    579434                       
    580                         if button == 'cancel':
     435                        if (button == 'cancel'):
    581436                                return 'Configuration canceled'
    582437                       
    583                         if button == 'done':
    584                                 if (infer_verify_choices(config, rules)):
     438                        if (button == 'done'):
     439                                if (check_choices(defaults, ask_names)):
    585440                                        break
    586441                                else:
     
    588443                                        continue
    589444                       
    590                         if value == 0:
    591                                 profile = choose_profile(PRESETS_DIR, MAKEFILE, screen, config)
    592                                 if profile != None:
    593                                         read_presets(profile, config)
     445                        if (value == 0):
     446                                read_preconfigured(PRECONF, MAKEFILE, screen, defaults)
    594447                                position = 1
    595448                                continue
    596449                       
    597450                        position = None
    598                         if not value in opt2row:
     451                        if (not value in opt2row):
    599452                                raise RuntimeError("Error selecting value: %s" % value)
    600453                       
    601454                        (selname, seltype, name, choices) = opt2row[value]
    602455                       
    603                         if not selname in config:
    604                                 value = None
     456                        if (not selname in defaults):
     457                                        default = None
    605458                        else:
    606                                 value = config[selname]
    607                        
    608                         if seltype == 'choice':
    609                                 config[selname] = subchoice(screen, name, choices, value)
    610                         elif (seltype == 'y/n') or (seltype == 'n/y'):
    611                                 if config[selname] == 'y':
    612                                         config[selname] = 'n'
     459                                default = defaults[selname]
     460                       
     461                        if (seltype == 'choice'):
     462                                defaults[selname] = subchoice(screen, name, choices, default)
     463                        elif ((seltype == 'y/n') or (seltype == 'n/y')):
     464                                if (defaults[selname] == 'y'):
     465                                        defaults[selname] = 'n'
    613466                                else:
    614                                         config[selname] = 'y'
     467                                        defaults[selname] = 'y'
    615468        finally:
    616469                xtui.screen_done(screen)
    617470       
    618         create_output(MAKEFILE, MACROS, config, rules)
     471        create_output(MAKEFILE, MACROS, defaults, ask_names)
    619472        return 0
    620473
  • uspace/app/netecho/print_error.c

    r4006447 r463e734  
    164164        case EDESTADDRREQ:
    165165                fprintf(output, "Destination address required (%d) error", error_code);
    166         case EAGAIN:
     166        case TRY_AGAIN:
    167167                fprintf(output, "Try again (%d) error", error_code);
    168168        default:
  • uspace/lib/c/generic/adt/char_map.c

    r4006447 r463e734  
    9090        }
    9191
    92         map->items[map->next]->c = *identifier;
    93         identifier++;
    94         map->next++;
    95         if ((length > 1) || ((length == 0) && *identifier)) {
     92        map->items[map->next]->c = * identifier;
     93        ++ identifier;
     94        ++ map->next;
     95        if ((length > 1) || ((length == 0) && (*identifier))) {
    9696                map->items[map->next - 1]->value = CHAR_MAP_NULL;
    9797                return char_map_add_item(map->items[map->next - 1], identifier,
     
    142142    const int value)
    143143{
    144         if (char_map_is_valid(map) && identifier && (length || *identifier)) {
     144        if (char_map_is_valid(map) && (identifier) &&
     145            ((length) || (*identifier))) {
    145146                int index;
    146147
    147                 for (index = 0; index < map->next; index++) {
     148                for (index = 0; index < map->next; ++ index) {
    148149                        if (map->items[index]->c != *identifier)
    149150                                continue;
    150151                               
    151                         identifier++;
    152                         if((length > 1) || ((length == 0) && *identifier)) {
     152                        ++ identifier;
     153                        if((length > 1) || ((length == 0) && (*identifier))) {
    153154                                return char_map_add(map->items[index],
    154155                                    identifier, length ? length - 1 : 0, value);
     
    177178
    178179                map->magic = 0;
    179                 for (index = 0; index < map->next; index++)
     180                for (index = 0; index < map->next; ++index)
    180181                        char_map_destroy(map->items[index]);
    181182
     
    206207                return NULL;
    207208
    208         if (length || *identifier) {
     209        if (length || (*identifier)) {
    209210                int index;
    210211
    211                 for (index = 0; index < map->next; index++) {
     212                for (index = 0; index < map->next; ++index) {
    212213                        if (map->items[index]->c == *identifier) {
    213                                 identifier++;
     214                                ++identifier;
    214215                                if (length == 1)
    215216                                        return map->items[index];
  • uspace/lib/c/include/adt/generic_field.h

    r4006447 r463e734  
    9191                        } \
    9292                        field->items[field->next] = value; \
    93                         field->next++; \
     93                        ++field->next; \
    9494                        field->items[field->next] = NULL; \
    9595                        return field->next - 1; \
     
    108108                        int index; \
    109109                        field->magic = 0; \
    110                         for (index = 0; index < field->next; index++) { \
     110                        for (index = 0; index < field->next; ++ index) { \
    111111                                if (field->items[index]) \
    112112                                        free(field->items[index]); \
  • uspace/lib/c/include/errno.h

    r4006447 r463e734  
    8383#define ENOTCONN        (-10057)
    8484
    85 /** The requested operation was not performed. Try again later. */
    86 #define EAGAIN          (-11002)
     85/** The requested operation was not performed.
     86 *  Try again later.
     87 */
     88#define TRY_AGAIN       (-11002)
    8789
    8890/** No data.
  • uspace/lib/c/include/ipc/vfs.h

    r4006447 r463e734  
    3636#define LIBC_IPC_VFS_H_
    3737
     38#include <sys/types.h>
    3839#include <ipc/ipc.h>
    39 #include <sys/types.h>
    40 #include <bool.h>
    4140
    4241#define FS_NAME_MAXLEN  20
     
    5655        /** Unique identifier of the fs. */
    5756        char name[FS_NAME_MAXLEN + 1];
    58         bool concurrent_read_write;
    59         bool write_retains_size;
    6057} vfs_info_t;
    6158
  • uspace/lib/drv/generic/driver.c

    r4006447 r463e734  
    418418                goto failure;
    419419
    420         return EOK;
     420        goto leave;
    421421
    422422failure:
     
    431431        }
    432432
     433leave:
    433434        return rc;
    434435}
  • uspace/srv/devman/devman.c

    r4006447 r463e734  
    766766                start_driver(drv);
    767767        }
     768        fibril_mutex_unlock(&drv->driver_mutex);
     769       
     770        fibril_mutex_lock(&drv->driver_mutex);
    768771        bool is_running = drv->state == DRIVER_RUNNING;
    769772        fibril_mutex_unlock(&drv->driver_mutex);
  • uspace/srv/devman/main.c

    r4006447 r463e734  
    246246
    247247        /*
    248          * Try to find a suitable driver and assign it to the device.  We do
    249          * not want to block the current fibril that is used for processing
    250          * incoming calls: we will launch a separate fibril to handle the
    251          * driver assigning. That is because assign_driver can actually include
    252          * task spawning which could take some time.
     248         * Try to find suitable driver and assign it to the device.
     249         * We do not want to block current fibril that is used to processing
     250         * incoming calls: we will launch a separate fibril to handle
     251         * the driver assigning. That is because assign_driver can actually
     252         * include task spawning which could take some time.
    253253         */
    254254        fid_t assign_fibril = fibril_create(assign_driver_fibril, node);
  • uspace/srv/devman/match.c

    r4006447 r463e734  
    4646        if (str_cmp(driver->id, device->id) == 0) {
    4747                /*
    48                  * The strings match, return the product of their scores.
     48                 * The strings matches, return their score multiplied.
    4949                 */
    5050                return driver->score * device->score;
     
    6666       
    6767        /*
    68          * Go through all pairs, return the highest score obtained.
     68         * Go through all pairs, return the highest score obtainetd.
    6969         */
    7070        int highest_score = 0;
  • uspace/srv/fs/devfs/devfs.c

    r4006447 r463e734  
    5353static vfs_info_t devfs_vfs_info = {
    5454        .name = NAME,
    55         .concurrent_read_write = false,
    56         .write_retains_size = false,
    5755};
    5856
  • uspace/srv/fs/fat/fat.c

    r4006447 r463e734  
    5252vfs_info_t fat_vfs_info = {
    5353        .name = NAME,
    54         .concurrent_read_write = false,
    55         .write_retains_size = false,   
    5654};
    5755
  • uspace/srv/fs/tmpfs/tmpfs.c

    r4006447 r463e734  
    5757vfs_info_t tmpfs_vfs_info = {
    5858        .name = NAME,
    59         .concurrent_read_write = false,
    60         .write_retains_size = false,
    6159};
    6260
  • uspace/srv/net/il/arp/arp.c

    r4006447 r463e734  
    7272#define NAME  "arp"
    7373
    74 /** Number of microseconds to wait for an ARP reply. */
    75 #define ARP_TRANS_WAIT  1000000
    76 
    7774/** ARP global data. */
    7875arp_globals_t arp_globals;
     
    8077DEVICE_MAP_IMPLEMENT(arp_cache, arp_device_t);
    8178INT_MAP_IMPLEMENT(arp_protos, arp_proto_t);
    82 GENERIC_CHAR_MAP_IMPLEMENT(arp_addr, arp_trans_t);
    83 
    84 static void arp_clear_trans(arp_trans_t *trans)
    85 {
    86         if (trans->hw_addr) {
    87                 free(trans->hw_addr);
    88                 trans->hw_addr = NULL;
    89         }
    90         fibril_condvar_broadcast(&trans->cv);
    91 }
    92 
    93 static void arp_clear_addr(arp_addr_t *addresses)
    94 {
    95         int count;
    96         arp_trans_t *trans;
    97 
    98         for (count = arp_addr_count(addresses) - 1; count >= 0; count--) {
    99                 trans = arp_addr_items_get_index(&addresses->values, count);
    100                 if (trans)
    101                         arp_clear_trans(trans);
    102         }
    103 }
    104 
     79GENERIC_CHAR_MAP_IMPLEMENT(arp_addr, measured_string_t);
    10580
    10681/** Clears the device specific data.
     
    12196                        if (proto->addr_data)
    12297                                free(proto->addr_data);
    123                         arp_clear_addr(&proto->addresses);
    12498                        arp_addr_destroy(&proto->addresses);
    12599                }
     
    133107        arp_device_t *device;
    134108
    135         fibril_mutex_lock(&arp_globals.lock);
     109        fibril_rwlock_write_lock(&arp_globals.lock);
    136110        for (count = arp_cache_count(&arp_globals.cache) - 1; count >= 0;
    137111            count--) {
     
    146120        }
    147121        arp_cache_clear(&arp_globals.cache);
    148         fibril_mutex_unlock(&arp_globals.lock);
     122        fibril_rwlock_write_unlock(&arp_globals.lock);
    149123        printf("Cache cleaned\n");
    150124        return EOK;
     
    156130        arp_device_t *device;
    157131        arp_proto_t *proto;
    158         arp_trans_t *trans;
    159 
    160         fibril_mutex_lock(&arp_globals.lock);
     132
     133        fibril_rwlock_write_lock(&arp_globals.lock);
    161134        device = arp_cache_find(&arp_globals.cache, device_id);
    162135        if (!device) {
    163                 fibril_mutex_unlock(&arp_globals.lock);
     136                fibril_rwlock_write_unlock(&arp_globals.lock);
    164137                return ENOENT;
    165138        }
    166139        proto = arp_protos_find(&device->protos, protocol);
    167140        if (!proto) {
    168                 fibril_mutex_unlock(&arp_globals.lock);
     141                fibril_rwlock_write_unlock(&arp_globals.lock);
    169142                return ENOENT;
    170143        }
    171         trans = arp_addr_find(&proto->addresses, address->value, address->length);
    172         if (trans)
    173                 arp_clear_trans(trans);
    174144        arp_addr_exclude(&proto->addresses, address->value, address->length);
    175         fibril_mutex_unlock(&arp_globals.lock);
     145        fibril_rwlock_write_unlock(&arp_globals.lock);
    176146        return EOK;
    177147}
     
    182152        arp_device_t *device;
    183153
    184         fibril_mutex_lock(&arp_globals.lock);
     154        fibril_rwlock_write_lock(&arp_globals.lock);
    185155        device = arp_cache_find(&arp_globals.cache, device_id);
    186156        if (!device) {
    187                 fibril_mutex_unlock(&arp_globals.lock);
     157                fibril_rwlock_write_unlock(&arp_globals.lock);
    188158                return ENOENT;
    189159        }
    190160        arp_clear_device(device);
    191161        printf("Device %d cleared\n", device_id);
    192         fibril_mutex_unlock(&arp_globals.lock);
     162        fibril_rwlock_write_unlock(&arp_globals.lock);
    193163        return EOK;
    194164}
     
    251221        int rc;
    252222
    253         fibril_mutex_lock(&arp_globals.lock);
     223        fibril_rwlock_write_lock(&arp_globals.lock);
    254224
    255225        /* An existing device? */
     
    259229                if (device->service != service) {
    260230                        printf("Device %d already exists\n", device->device_id);
    261                         fibril_mutex_unlock(&arp_globals.lock);
     231                        fibril_rwlock_write_unlock(&arp_globals.lock);
    262232                        return EEXIST;
    263233                }
     
    271241                        rc = arp_proto_create(&proto, protocol, address);
    272242                        if (rc != EOK) {
    273                                 fibril_mutex_unlock(&arp_globals.lock);
     243                                fibril_rwlock_write_unlock(&arp_globals.lock);
    274244                                return rc;
    275245                        }
     
    277247                            proto);
    278248                        if (index < 0) {
    279                                 fibril_mutex_unlock(&arp_globals.lock);
     249                                fibril_rwlock_write_unlock(&arp_globals.lock);
    280250                                free(proto);
    281251                                return index;
     
    292262                device = (arp_device_t *) malloc(sizeof(arp_device_t));
    293263                if (!device) {
    294                         fibril_mutex_unlock(&arp_globals.lock);
     264                        fibril_rwlock_write_unlock(&arp_globals.lock);
    295265                        return ENOMEM;
    296266                }
     
    299269                rc = arp_protos_initialize(&device->protos);
    300270                if (rc != EOK) {
    301                         fibril_mutex_unlock(&arp_globals.lock);
     271                        fibril_rwlock_write_unlock(&arp_globals.lock);
    302272                        free(device);
    303273                        return rc;
     
    305275                rc = arp_proto_create(&proto, protocol, address);
    306276                if (rc != EOK) {
    307                         fibril_mutex_unlock(&arp_globals.lock);
     277                        fibril_rwlock_write_unlock(&arp_globals.lock);
    308278                        free(device);
    309279                        return rc;
     
    311281                index = arp_protos_add(&device->protos, proto->service, proto);
    312282                if (index < 0) {
    313                         fibril_mutex_unlock(&arp_globals.lock);
     283                        fibril_rwlock_write_unlock(&arp_globals.lock);
    314284                        arp_protos_destroy(&device->protos);
    315285                        free(device);
     
    323293                    arp_globals.client_connection);
    324294                if (device->phone < 0) {
    325                         fibril_mutex_unlock(&arp_globals.lock);
     295                        fibril_rwlock_write_unlock(&arp_globals.lock);
    326296                        arp_protos_destroy(&device->protos);
    327297                        free(device);
     
    333303                    &device->packet_dimension);
    334304                if (rc != EOK) {
    335                         fibril_mutex_unlock(&arp_globals.lock);
     305                        fibril_rwlock_write_unlock(&arp_globals.lock);
    336306                        arp_protos_destroy(&device->protos);
    337307                        free(device);
     
    343313                    &device->addr_data);
    344314                if (rc != EOK) {
    345                         fibril_mutex_unlock(&arp_globals.lock);
     315                        fibril_rwlock_write_unlock(&arp_globals.lock);
    346316                        arp_protos_destroy(&device->protos);
    347317                        free(device);
     
    353323                    &device->broadcast_addr, &device->broadcast_data);
    354324                if (rc != EOK) {
    355                         fibril_mutex_unlock(&arp_globals.lock);
     325                        fibril_rwlock_write_unlock(&arp_globals.lock);
    356326                        free(device->addr);
    357327                        free(device->addr_data);
     
    364334                    device);
    365335                if (rc != EOK) {
    366                         fibril_mutex_unlock(&arp_globals.lock);
     336                        fibril_rwlock_write_unlock(&arp_globals.lock);
    367337                        free(device->addr);
    368338                        free(device->addr_data);
     
    377347                    device->service, protocol);
    378348        }
    379         fibril_mutex_unlock(&arp_globals.lock);
     349        fibril_rwlock_write_unlock(&arp_globals.lock);
    380350       
    381351        return EOK;
     
    393363        int rc;
    394364
    395         fibril_mutex_initialize(&arp_globals.lock);
    396         fibril_mutex_lock(&arp_globals.lock);
     365        fibril_rwlock_initialize(&arp_globals.lock);
     366        fibril_rwlock_write_lock(&arp_globals.lock);
    397367        arp_globals.client_connection = client_connection;
    398368        rc = arp_cache_initialize(&arp_globals.cache);
    399         fibril_mutex_unlock(&arp_globals.lock);
     369        fibril_rwlock_write_unlock(&arp_globals.lock);
    400370       
    401371        return rc;
     
    413383        arp_device_t *device;
    414384
    415         fibril_mutex_lock(&arp_globals.lock);
     385        fibril_rwlock_write_lock(&arp_globals.lock);
    416386        device = arp_cache_find(&arp_globals.cache, device_id);
    417387        if (!device) {
    418                 fibril_mutex_unlock(&arp_globals.lock);
     388                fibril_rwlock_write_unlock(&arp_globals.lock);
    419389                return ENOENT;
    420390        }
    421391        device->packet_dimension.content = mtu;
    422         fibril_mutex_unlock(&arp_globals.lock);
     392        fibril_rwlock_write_unlock(&arp_globals.lock);
    423393        printf("arp - device %d changed mtu to %zu\n\n", device_id, mtu);
    424394        return EOK;
     
    451421        arp_device_t *device;
    452422        arp_proto_t *proto;
    453         arp_trans_t *trans;
     423        measured_string_t *hw_source;
    454424        uint8_t *src_hw;
    455425        uint8_t *src_proto;
     
    482452        des_hw = src_proto + header->protocol_length;
    483453        des_proto = des_hw + header->hardware_length;
    484         trans = arp_addr_find(&proto->addresses, (char *) src_proto,
     454        hw_source = arp_addr_find(&proto->addresses, (char *) src_proto,
    485455            CONVERT_SIZE(uint8_t, char, header->protocol_length));
    486456        /* Exists? */
    487         if (trans && trans->hw_addr) {
    488                 if (trans->hw_addr->length != CONVERT_SIZE(uint8_t, char,
     457        if (hw_source) {
     458                if (hw_source->length != CONVERT_SIZE(uint8_t, char,
    489459                    header->hardware_length)) {
    490460                        return EINVAL;
    491461                }
    492                 memcpy(trans->hw_addr->value, src_hw, trans->hw_addr->length);
     462                memcpy(hw_source->value, src_hw, hw_source->length);
    493463        }
    494464        /* Is my protocol address? */
     
    500470            proto->addr->length)) {
    501471                /* Not already updated? */
    502                 if (!trans) {
    503                         trans = (arp_trans_t *) malloc(sizeof(arp_trans_t));
    504                         if (!trans)
     472                if (!hw_source) {
     473                        hw_source = measured_string_create_bulk((char *) src_hw,
     474                            CONVERT_SIZE(uint8_t, char,
     475                            header->hardware_length));
     476                        if (!hw_source)
    505477                                return ENOMEM;
    506                         trans->hw_addr = NULL;
    507                         fibril_condvar_initialize(&trans->cv);
     478
    508479                        rc = arp_addr_add(&proto->addresses, (char *) src_proto,
    509                             CONVERT_SIZE(uint8_t, char, header->protocol_length),
    510                             trans);
    511                         if (rc != EOK) {
    512                                 /* The generic char map has already freed trans! */
     480                            CONVERT_SIZE(uint8_t, char,
     481                            header->protocol_length), hw_source);
     482                        if (rc != EOK)
    513483                                return rc;
    514                         }
    515                 }
    516                 if (!trans->hw_addr) {
    517                         trans->hw_addr = measured_string_create_bulk(
    518                             (char *) src_hw, CONVERT_SIZE(uint8_t, char,
    519                             header->hardware_length));
    520                         if (!trans->hw_addr)
    521                                 return ENOMEM;
    522 
    523                         /* Notify the fibrils that wait for the translation. */
    524                         fibril_condvar_broadcast(&trans->cv);
    525484                }
    526485                if (ntohs(header->operation) == ARPOP_REQUEST) {
     
    531490                        memcpy(src_hw, device->addr->value,
    532491                            device->packet_dimension.addr_len);
    533                         memcpy(des_hw, trans->hw_addr->value,
     492                        memcpy(des_hw, hw_source->value,
    534493                            header->hardware_length);
    535494                       
     
    557516 * @param[in] protocol  The protocol service.
    558517 * @param[in] target    The target protocol address.
    559  * @param[out] translation Where the hardware address of the target is stored.
    560  * @return              EOK on success.
    561  * @return              EAGAIN if the caller should try again.
    562  * @return              Other error codes in case of error.
    563  */
    564 static int
     518 * @return              The hardware address of the target.
     519 * @return              NULL if the target parameter is NULL.
     520 * @return              NULL if the device is not found.
     521 * @return              NULL if the device packet is too small to send a
     522 *                      request.
     523 * @return              NULL if the hardware address is not found in the cache.
     524 */
     525static measured_string_t *
    565526arp_translate_message(device_id_t device_id, services_t protocol,
    566     measured_string_t *target, measured_string_t **translation)
     527    measured_string_t *target)
    567528{
    568529        arp_device_t *device;
    569530        arp_proto_t *proto;
    570         arp_trans_t *trans;
     531        measured_string_t *addr;
    571532        size_t length;
    572533        packet_t *packet;
    573534        arp_header_t *header;
    574         bool retry = false;
    575         int rc;
    576 
    577 restart:
    578         if (!target || !translation)
    579                 return EBADMEM;
     535
     536        if (!target)
     537                return NULL;
    580538
    581539        device = arp_cache_find(&arp_globals.cache, device_id);
    582540        if (!device)
    583                 return ENOENT;
     541                return NULL;
    584542
    585543        proto = arp_protos_find(&device->protos, protocol);
    586544        if (!proto || (proto->addr->length != target->length))
    587                 return ENOENT;
    588 
    589         trans = arp_addr_find(&proto->addresses, target->value, target->length);
    590         if (trans) {
    591                 if (trans->hw_addr) {
    592                         *translation = trans->hw_addr;
    593                         return EOK;
    594                 }
    595                 if (retry)
    596                         return EAGAIN;
    597                 rc = fibril_condvar_wait_timeout(&trans->cv, &arp_globals.lock,
    598                     ARP_TRANS_WAIT);
    599                 if (rc == ETIMEOUT)
    600                         return ENOENT;
    601                 retry = true;
    602                 goto restart;
    603         }
    604         if (retry)
    605                 return EAGAIN;
     545                return NULL;
     546
     547        addr = arp_addr_find(&proto->addresses, target->value, target->length);
     548        if (addr)
     549                return addr;
    606550
    607551        /* ARP packet content size = header + (address + translation) * 2 */
     
    609553            CONVERT_SIZE(char, uint8_t, device->addr->length));
    610554        if (length > device->packet_dimension.content)
    611                 return ELIMIT;
     555                return NULL;
    612556
    613557        packet = packet_get_4_remote(arp_globals.net_phone,
     
    615559            length, device->packet_dimension.suffix);
    616560        if (!packet)
    617                 return ENOMEM;
     561                return NULL;
    618562
    619563        header = (arp_header_t *) packet_suffix(packet, length);
    620564        if (!header) {
    621565                pq_release_remote(arp_globals.net_phone, packet_get_id(packet));
    622                 return ENOMEM;
     566                return NULL;
    623567        }
    624568
     
    639583        memcpy(((uint8_t *) header) + length, target->value, target->length);
    640584
    641         rc = packet_set_addr(packet, (uint8_t *) device->addr->value,
     585        if (packet_set_addr(packet, (uint8_t *) device->addr->value,
    642586            (uint8_t *) device->broadcast_addr->value,
    643             CONVERT_SIZE(char, uint8_t, device->addr->length));
    644         if (rc != EOK) {
     587            CONVERT_SIZE(char, uint8_t, device->addr->length)) != EOK) {
    645588                pq_release_remote(arp_globals.net_phone, packet_get_id(packet));
    646                 return rc;
     589                return NULL;
    647590        }
    648591
    649592        nil_send_msg(device->phone, device_id, packet, SERVICE_ARP);
    650 
    651         trans = (arp_trans_t *) malloc(sizeof(arp_trans_t));
    652         if (!trans)
    653                 return ENOMEM;
    654         trans->hw_addr = NULL;
    655         fibril_condvar_initialize(&trans->cv);
    656         rc = arp_addr_add(&proto->addresses, target->value, target->length,
    657             trans);
    658         if (rc != EOK) {
    659                 /* The generic char map has already freed trans! */
    660                 return rc;
    661         }
    662        
    663         rc = fibril_condvar_wait_timeout(&trans->cv, &arp_globals.lock,
    664             ARP_TRANS_WAIT);
    665         if (rc == ETIMEOUT)
    666                 return ENOENT;
    667         retry = true;
    668         goto restart;
     593        return NULL;
    669594}
    670595
     
    717642                        return rc;
    718643               
    719                 fibril_mutex_lock(&arp_globals.lock);
    720                 rc = arp_translate_message(IPC_GET_DEVICE(call),
    721                     IPC_GET_SERVICE(call), address, &translation);
     644                fibril_rwlock_read_lock(&arp_globals.lock);
     645                translation = arp_translate_message(IPC_GET_DEVICE(call),
     646                    IPC_GET_SERVICE(call), address);
    722647                free(address);
    723648                free(data);
    724                 if (rc != EOK) {
    725                         fibril_mutex_unlock(&arp_globals.lock);
    726                         return rc;
    727                 }
    728649                if (!translation) {
    729                         fibril_mutex_unlock(&arp_globals.lock);
     650                        fibril_rwlock_read_unlock(&arp_globals.lock);
    730651                        return ENOENT;
    731652                }
    732653                rc = measured_strings_reply(translation, 1);
    733                 fibril_mutex_unlock(&arp_globals.lock);
     654                fibril_rwlock_read_unlock(&arp_globals.lock);
    734655                return rc;
    735656
     
    761682                        return rc;
    762683               
    763                 fibril_mutex_lock(&arp_globals.lock);
     684                fibril_rwlock_read_lock(&arp_globals.lock);
    764685                do {
    765686                        next = pq_detach(packet);
     
    771692                        packet = next;
    772693                } while (packet);
    773                 fibril_mutex_unlock(&arp_globals.lock);
     694                fibril_rwlock_read_unlock(&arp_globals.lock);
    774695               
    775696                return EOK;
  • uspace/srv/net/il/arp/arp.h

    r4006447 r463e734  
    6565typedef struct arp_proto arp_proto_t;
    6666
    67 /** Type definition of the ARP address translation record.
    68  * @see arp_trans
    69  */
    70 typedef struct arp_trans arp_trans_t;
    71 
    7267/** ARP address map.
    7368 *
     
    7570 * @see generic_char_map.h
    7671 */
    77 GENERIC_CHAR_MAP_DECLARE(arp_addr, arp_trans_t);
     72GENERIC_CHAR_MAP_DECLARE(arp_addr, measured_string_t);
    7873
    7974/** ARP address cache.
     
    9489struct arp_device {
    9590        /** Actual device hardware address. */
    96         measured_string_t *addr;
     91        measured_string_t * addr;
    9792        /** Actual device hardware address data. */
    9893        char *addr_data;
    9994        /** Broadcast device hardware address. */
    100         measured_string_t *broadcast_addr;
     95        measured_string_t * broadcast_addr;
    10196        /** Broadcast device hardware address data. */
    10297        char *broadcast_data;
     
    134129        int net_phone;
    135130        /** Safety lock. */
    136         fibril_mutex_t lock;
     131        fibril_rwlock_t lock;
    137132};
    138133
     
    149144};
    150145
    151 /** ARP address translation record. */
    152 struct arp_trans {
    153         /**
    154          * Hardware address for the translation. NULL denotes an incomplete
    155          * record with possible waiters.
    156          */
    157         measured_string_t *hw_addr;
    158         /** Condition variable used for waiting for completion of the record. */
    159         fibril_condvar_t cv;
    160 };
    161 
    162146#endif
    163147
    164148/** @}
    165149 */
    166 
  • uspace/srv/vfs/vfs.h

    r4006447 r463e734  
    172172
    173173extern fs_handle_t fs_name_to_handle(char *, bool);
    174 extern vfs_info_t *fs_handle_to_info(fs_handle_t);
    175174
    176175extern int vfs_lookup_internal(char *, int, vfs_lookup_res_t *,
  • uspace/srv/vfs/vfs_ops.c

    r4006447 r463e734  
    781781static void vfs_rdwr(ipc_callid_t rid, ipc_call_t *request, bool read)
    782782{
    783         vfs_info_t *vi;
    784783
    785784        /*
     
    808807        fibril_mutex_lock(&file->lock);
    809808
    810         vi = fs_handle_to_info(file->node->fs_handle);
    811         assert(vi);
    812 
    813809        /*
    814810         * Lock the file's node so that no other client can read/write to it at
    815          * the same time unless the FS supports concurrent reads/writes and its
    816          * write implementation does not modify the file size.
    817          */
    818         if (read || (vi->concurrent_read_write && vi->write_retains_size))
     811         * the same time.
     812         */
     813        if (read)
    819814                fibril_rwlock_read_lock(&file->node->contents_rwlock);
    820815        else
     
    862857       
    863858        /* Unlock the VFS node. */
    864         if (read || (vi->concurrent_read_write && vi->write_retains_size))
     859        if (read)
    865860                fibril_rwlock_read_unlock(&file->node->contents_rwlock);
    866861        else {
  • uspace/srv/vfs/vfs_register.c

    r4006447 r463e734  
    333333}
    334334
    335 /** Find the VFS info structure.
    336  *
    337  * @param handle        FS handle for which the VFS info structure is sought.
    338  * @return              VFS info structure on success or NULL otherwise.
    339  */
    340 vfs_info_t *fs_handle_to_info(fs_handle_t handle)
    341 {
    342         vfs_info_t *info = NULL;
    343         link_t *cur;
    344 
    345         fibril_mutex_lock(&fs_head_lock);
    346         for (cur = fs_head.next; cur != &fs_head; cur = cur->next) {
    347                 fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link);
    348                 if (fs->fs_handle == handle) {
    349                         info = &fs->vfs_info;
    350                         break;
    351                 }
    352         }
    353         fibril_mutex_unlock(&fs_head_lock);
    354 
    355         return info;
    356 }
    357 
    358335/**
    359336 * @}
Note: See TracChangeset for help on using the changeset viewer.