Changeset aca1777 in mainline


Ignore:
Timestamp:
2025-05-08T17:12:05Z (3 weeks ago)
Author:
Miroslav Cimerman <mc@…>
Children:
2f21cd4
Parents:
1cfce3f (diff), 61f28c4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge upstream into helenraid

Files:
14 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/mm/malloc.c

    r1cfce3f raca1777  
    190190                return NULL;
    191191
    192         void *obj = mem_alloc(alignof(max_align_t), size + _offset) + _offset;
     192        void *obj = mem_alloc(alignof(max_align_t), size + _offset);
     193        if (!obj)
     194                return NULL;
     195
     196        obj += _offset;
    193197
    194198        /* Remember the allocation size just before the object. */
     
    205209         * slab_free() will detect it and panic.
    206210         */
    207         size_t size = ((size_t *) obj)[-1];
    208         mem_free(obj - _offset, alignof(max_align_t), size + _offset);
     211        if (obj) {
     212                size_t size = ((size_t *) obj)[-1];
     213                mem_free(obj - _offset, alignof(max_align_t), size + _offset);
     214        }
    209215}
    210216
  • meson/part/exports/copy-export.sh

    r1cfce3f raca1777  
    4545            ar -t "$2" | xargs ar crs "${target_dir}/lib/$3"
    4646            ;;
     47        sharedlib)
     48            filename="$(basename "$2")"
     49            major_versioned_name="$3"
     50            # libfoo.so.5 -> libfoo.so (remove the last part delimited by dot)
     51            unversioned_name="${major_versioned_name%.[0-9]*}"
     52            cp -L "$2" "${target_dir}/lib/$filename"
     53            ln -s "$filename" "${target_dir}/lib/$major_versioned_name"
     54            ln -s "$filename" "${target_dir}/lib/$unversioned_name"
     55            ;;
    4756        include)
    4857            mkdir -p "${target_dir}/include/$3"
  • uspace/app/blkdump/blkdump.c

    r1cfce3f raca1777  
    9595        }
    9696
    97         if (str_cmp(*argv, "--offset") == 0) {
     97        if (*argv && str_cmp(*argv, "--offset") == 0) {
    9898                --argc;
    9999                ++argv;
     
    115115        }
    116116
    117         if (str_cmp(*argv, "--count") == 0) {
     117        if (*argv && str_cmp(*argv, "--count") == 0) {
    118118                --argc;
    119119                ++argv;
     
    136136
    137137devname:
     138        if (*argv == NULL) {
     139                printf(NAME ": Error, argument missing (device_name).\n");
     140                syntax_print();
     141                return 1;
     142        }
     143
    138144        if (argc != 1) {
    139145                printf(NAME ": Error, unexpected argument.\n");
  • uspace/app/sysinst/sysinst.c

    r1cfce3f raca1777  
    7373#define DEFAULT_DEV_0 "devices/\\hw\\sys\\00:01.1\\c0d0"
    7474#define DEFAULT_DEV_1 "devices/\\hw\\sys\\ide1\\c0d0"
     75#define DEFAULT_DEV_2 "devices/\\hw\\sys\\00:01.0\\ide1\\c0d0"
    7576//#define DEFAULT_DEV "devices/\\hw\\pci0\\00:01.2\\uhci_rh\\usb01_a1\\mass-storage0\\l0"
    7677/** Volume label for the new file system */
     
    9596        DEFAULT_DEV_0,
    9697        DEFAULT_DEV_1,
     98        DEFAULT_DEV_2,
    9799        NULL
    98100};
     
    155157static void sysinst_futil_copy_file(void *, const char *, const char *);
    156158static void sysinst_futil_create_dir(void *, const char *);
     159static errno_t sysinst_eject_dev(sysinst_t *, service_id_t);
     160static errno_t sysinst_eject_phys_by_mp(sysinst_t *, const char *);
    157161
    158162static futil_cb_t sysinst_futil_cb = {
     
    269273        case 0:
    270274                /* OK */
     275                sysinst_action(sysinst, "Ejecting installation media.");
     276                (void)sysinst_eject_phys_by_mp(sysinst, CD_MOUNT_POINT);
    271277                (void)sysinst_restart(sysinst);
    272278                break;
     
    424430}
    425431
    426 /** Label the destination device.
     432/** Label and mount the destination device.
    427433 *
    428434 * @param sysinst System installer
     
    432438 * @return EOK on success or an error code
    433439 */
    434 static errno_t sysinst_label_dev(sysinst_t *sysinst, const char *dev,
    435     service_id_t *psvc_id)
    436 {
    437         fdisk_t *fdisk;
    438         fdisk_dev_t *fdev;
     440static errno_t sysinst_label_dev(sysinst_t *sysinst, const char *dev)
     441{
     442        fdisk_t *fdisk = NULL;
     443        fdisk_dev_t *fdev = NULL;
    439444        fdisk_part_t *part;
    440445        fdisk_part_spec_t pspec;
    441446        fdisk_part_info_t pinfo;
     447        bool dir_created = false;
     448        bool label_created = false;
    442449        capa_spec_t capa;
    443450        service_id_t sid;
     
    448455        rc = loc_service_get_id(dev, &sid, 0);
    449456        if (rc != EOK)
    450                 return rc;
     457                goto error;
    451458
    452459        sysinst_debug(sysinst, "sysinst_label_dev(): open device");
     
    455462        if (rc != EOK) {
    456463                sysinst_error(sysinst, "Error initializing fdisk.");
    457                 return rc;
     464                goto error;
    458465        }
    459466
     
    461468        if (rc != EOK) {
    462469                sysinst_error(sysinst, "Error opening device.");
    463                 return rc;
     470                goto error;
    464471        }
    465472
     
    469476        if (rc != EOK) {
    470477                sysinst_error(sysinst, "Error creating mount directory.");
    471                 return rc;
    472         }
     478                goto error;
     479        }
     480
     481        dir_created = true;
    473482
    474483        sysinst_debug(sysinst, "sysinst_label_dev(): create label");
     
    477486        if (rc != EOK) {
    478487                sysinst_error(sysinst, "Error creating label.");
    479                 return rc;
    480         }
     488                goto error;
     489        }
     490
     491        label_created = true;
    481492
    482493        sysinst_debug(sysinst, "sysinst_label_dev(): create partition");
     
    486497                sysinst_error(sysinst,
    487498                    "Error getting available capacity.");
    488                 return rc;
     499                goto error;
    489500        }
    490501
     
    499510        if (rc != EOK) {
    500511                sysinst_error(sysinst, "Error creating partition.");
    501                 return rc;
     512                goto error;
    502513        }
    503514
     
    505516        if (rc != EOK) {
    506517                sysinst_error(sysinst, "Error getting partition information.");
    507                 return rc;
     518                goto error;
    508519        }
    509520
    510521        sysinst_debug(sysinst, "sysinst_label_dev(): OK");
    511         *psvc_id = pinfo.svc_id;
     522        fdisk_dev_close(fdev);
     523        fdisk_destroy(fdisk);
     524        sysinst->psvc_id = pinfo.svc_id;
     525        return EOK;
     526error:
     527        if (label_created)
     528                fdisk_label_destroy(fdev);
     529        if (dir_created)
     530                (void)vfs_unlink_path(MOUNT_POINT);
     531        if (fdev != NULL)
     532                fdisk_dev_close(fdev);
     533        if (fdisk != NULL)
     534                fdisk_destroy(fdisk);
     535        return rc;
     536}
     537
     538/** Finish/unmount destination device.
     539 *
     540 * @param sysinst System installer
     541 *
     542 * @return EOK on success or an error code
     543 */
     544static errno_t sysinst_finish_dev(sysinst_t *sysinst)
     545{
     546        errno_t rc;
     547
     548        sysinst_debug(sysinst, "sysinst_finish_dev(): eject target volume");
     549        rc = sysinst_eject_dev(sysinst, sysinst->psvc_id);
     550        if (rc != EOK)
     551                return rc;
     552
     553        sysinst_debug(sysinst, "sysinst_finish_dev(): "
     554            "deleting mount directory");
     555        (void)vfs_unlink_path(MOUNT_POINT);
     556
    512557        return EOK;
    513558}
     
    550595        rc = futil_rcopy_contents(sysinst->futil, CFG_FILES_SRC,
    551596            CFG_FILES_DEST);
    552         if (rc != EOK)
    553                 return rc;
     597        if (rc != EOK) {
     598                sysinst_error(sysinst, "Error copying initial configuration "
     599                    "files.");
     600                return rc;
     601        }
    554602
    555603        return EOK;
     
    571619            "sysinst_copy_boot_files(): copy bootloader files");
    572620        rc = futil_rcopy_contents(sysinst->futil, BOOT_FILES_SRC, MOUNT_POINT);
    573         if (rc != EOK)
    574                 return rc;
     621        if (rc != EOK) {
     622                sysinst_error(sysinst, "Error copying bootloader "
     623                    "files.");
     624                return rc;
     625        }
    575626
    576627        sysinst_debug(sysinst, "sysinst_copy_boot_files(): OK");
     
    811862 *
    812863 * @param sysinst System installer
    813  * @param psvc_id Partition service ID
     864 * @param part_id Partition service ID
    814865 * @return EOK on success or an error code
    815866 */
     
    825876        }
    826877
    827         rc = vol_part_eject(vol, part_id, vef_physical);
     878        rc = vol_part_eject(vol, part_id, vef_none);
    828879        if (rc != EOK) {
    829880                sysinst_error(sysinst, "Error ejecting volume.");
     
    837888}
    838889
     890/** Physically eject volume by mount point.
     891 *
     892 * @param sysinst System installer
     893 * @param path Mount point
     894 * @return EOK on success or an error code
     895 */
     896static errno_t sysinst_eject_phys_by_mp(sysinst_t *sysinst, const char *path)
     897{
     898        vol_t *vol = NULL;
     899        sysarg_t part_id;
     900        errno_t rc;
     901
     902        log_msg(LOG_DEFAULT, LVL_NOTE,
     903            "sysinst_eject_phys_by_mp(%s)", path);
     904
     905        rc = vol_create(&vol);
     906        if (rc != EOK) {
     907                sysinst_error(sysinst, "Error contacting volume service.");
     908                goto out;
     909        }
     910
     911        log_msg(LOG_DEFAULT, LVL_NOTE, "vol_part_by_mp: mp='%s'\n",
     912            path);
     913        rc = vol_part_by_mp(vol, path, &part_id);
     914        if (rc != EOK) {
     915                sysinst_error(sysinst,
     916                    "Error finding installation media mount point.");
     917                goto out;
     918        }
     919
     920        log_msg(LOG_DEFAULT, LVL_NOTE, "eject svc_id %lu", (unsigned long)part_id);
     921        rc = vol_part_eject(vol, part_id, vef_physical);
     922        if (rc != EOK) {
     923                sysinst_error(sysinst, "Error ejecting volume.");
     924                goto out;
     925        }
     926
     927        rc = EOK;
     928out:
     929        vol_destroy(vol);
     930        return rc;
     931}
     932
    839933/** Restart the system.
    840934 *
     
    852946        shutdown_failed = false;
    853947
     948        sysinst_action(sysinst, "Restarting the system.");
     949
    854950        rc = system_open(SYSTEM_DEFAULT, &sysinst_system_cb, NULL, &system);
    855951        if (rc != EOK) {
     
    901997{
    902998        errno_t rc;
    903         service_id_t psvc_id;
     999        bool clean_dev = false;
    9041000
    9051001        sysinst_action(sysinst, "Creating device label and file system.");
    9061002
    907         rc = sysinst_label_dev(sysinst, dev, &psvc_id);
    908         if (rc != EOK)
    909                 return rc;
     1003        rc = sysinst_label_dev(sysinst, dev);
     1004        if (rc != EOK)
     1005                goto error;
     1006
     1007        clean_dev = true;
    9101008
    9111009        sysinst_action(sysinst, "Creating system directory structure.");
    9121010        rc = sysinst_setup_sysvol(sysinst);
    9131011        if (rc != EOK)
    914                 return rc;
     1012                goto error;
    9151013
    9161014        sysinst_action(sysinst, "Copying boot files.");
    9171015        rc = sysinst_copy_boot_files(sysinst);
    9181016        if (rc != EOK)
    919                 return rc;
     1017                goto error;
    9201018
    9211019        sysinst_action(sysinst, "Configuring the system.");
    9221020        rc = sysinst_customize_initrd(sysinst);
    9231021        if (rc != EOK)
    924                 return rc;
     1022                goto error;
     1023
     1024        sysinst_action(sysinst, "Finishing system volume.");
     1025        rc = sysinst_finish_dev(sysinst);
     1026        if (rc != EOK)
     1027                goto error;
     1028
     1029        clean_dev = false;
    9251030
    9261031        sysinst_action(sysinst, "Installing boot blocks.");
     
    9291034                return rc;
    9301035
    931         sysinst_action(sysinst, "Ejecting device.");
    932         rc = sysinst_eject_dev(sysinst, psvc_id);
    933         if (rc != EOK)
    934                 return rc;
    935 
    936         return EOK;
     1036        return EOK;
     1037error:
     1038        if (clean_dev)
     1039                (void)sysinst_finish_dev(sysinst);
     1040        return rc;
    9371041}
    9381042
     
    9691073
    9701074        sysinst_progress_destroy(sysinst->progress);
     1075        sysinst->progress = NULL;
     1076
    9711077        rc = sysinst_restart_dlg_create(sysinst);
    9721078        if (rc != EOK)
     
    11471253static void sysinst_action(sysinst_t *sysinst, const char *action)
    11481254{
     1255        log_msg(LOG_DEFAULT, LVL_NOTE, "%s", action);
     1256
    11491257        if (sysinst->progress == NULL)
    11501258                return;
     
    11521260        ui_label_set_text(sysinst->progress->action, action);
    11531261        ui_label_paint(sysinst->progress->action);
    1154         log_msg(LOG_DEFAULT, LVL_NOTE, "%s", action);
    11551262}
    11561263
  • uspace/app/sysinst/sysinst.h

    r1cfce3f raca1777  
    3939#include <futil.h>
    4040#include <gfx/color.h>
     41#include <loc.h>
    4142#include <system.h>
    4243#include <ui/fixed.h>
     
    6061        sysinst_progress_t *progress;
    6162        system_t *system;
     63        /** Service ID of destination partition. */
     64        sysarg_t psvc_id;
    6265        futil_t *futil;
    6366        char errmsg[128];
  • uspace/app/vol/vol.c

    r1cfce3f raca1777  
    5454} vol_cmd_t;
    5555
    56 /** Find volume by current mount point. */
    57 static errno_t vol_cmd_part_by_mp(vol_t *vol, const char *mp,
    58     service_id_t *rid)
    59 {
    60         vol_part_info_t vinfo;
    61         service_id_t *part_ids = NULL;
    62         char *canon_mp_buf = NULL;
    63         char *canon_mp;
    64         size_t nparts;
    65         size_t i;
    66         errno_t rc;
    67 
    68         canon_mp_buf = str_dup(mp);
    69         if (canon_mp_buf == NULL) {
    70                 printf("Out of memory.\n");
    71                 rc = ENOMEM;
    72                 goto out;
    73         }
    74 
    75         canon_mp = vfs_absolutize(canon_mp_buf, NULL);
    76         if (canon_mp == NULL) {
    77                 printf("Invalid volume path '%s'.\n", mp);
    78                 rc = EINVAL;
    79                 goto out;
    80         }
    81 
    82         rc = vol_get_parts(vol, &part_ids, &nparts);
    83         if (rc != EOK) {
    84                 printf("Error getting list of volumes.\n");
    85                 goto out;
    86         }
    87 
    88         for (i = 0; i < nparts; i++) {
    89                 rc = vol_part_info(vol, part_ids[i], &vinfo);
    90                 if (rc != EOK) {
    91                         printf("Error getting volume information.\n");
    92                         rc = EIO;
    93                         goto out;
    94                 }
    95 
    96                 if (str_cmp(vinfo.cur_mp, canon_mp) == 0) {
    97                         *rid = part_ids[i];
    98                         rc = EOK;
    99                         goto out;
    100                 }
    101         }
    102 
    103         rc = ENOENT;
    104 out:
    105         free(part_ids);
    106         free(canon_mp_buf);
    107         return rc;
    108 }
    109 
    11056static errno_t vol_cmd_eject(const char *volspec, bool physical)
    11157{
     
    12066        }
    12167
    122         rc = vol_cmd_part_by_mp(vol, volspec, &part_id);
     68        rc = vol_part_by_mp(vol, volspec, &part_id);
    12369        if (rc != EOK) {
    12470                printf("Error looking up volume '%s'.\n", volspec);
  • uspace/drv/hid/usbhid/mouse/mousedev.c

    r1cfce3f raca1777  
    11/*
     2 * Copyright (c) 2025 Jiri Svoboda
    23 * Copyright (c) 2011 Lubos Slovak, Vojtech Horky
    34 * Copyright (c) 2018 Ondrej Hlavaty
     
    166167        assert(mouse_dev != NULL);
    167168
    168         if (mouse_dev->mouse_sess == NULL) {
    169                 usb_log_warning(NAME " No console session.");
    170                 return;
    171         }
     169        if (mouse_dev->mouse_sess == NULL)
     170                return;
    172171
    173172        const usb_hid_report_field_t *move_x = get_mouse_axis_move_field(
  • uspace/lib/device/include/vol.h

    r1cfce3f raca1777  
    6161extern errno_t vol_pcnt_fs_format(vol_part_cnt_t, vol_fstype_t, char **);
    6262extern errno_t vol_mountp_validate(const char *);
     63extern errno_t vol_part_by_mp(vol_t *, const char *, service_id_t *);
    6364
    6465#endif
  • uspace/lib/device/src/vol.c

    r1cfce3f raca1777  
    608608}
    609609
     610/** Find volume by current mount point.
     611 *
     612 * @param vol Volume service
     613 * @param mp Mount point
     614 * @param rid Place to store partition service ID
     615 * @return EOK on success or an error code
     616 */
     617errno_t vol_part_by_mp(vol_t *vol, const char *mp, service_id_t *rid)
     618{
     619        vol_part_info_t vinfo;
     620        service_id_t *part_ids = NULL;
     621        char *canon_mp_buf = NULL;
     622        char *canon_mp;
     623        size_t nparts;
     624        size_t i;
     625        errno_t rc;
     626
     627        canon_mp_buf = str_dup(mp);
     628        if (canon_mp_buf == NULL) {
     629                rc = ENOMEM;
     630                goto out;
     631        }
     632
     633        canon_mp = vfs_absolutize(canon_mp_buf, NULL);
     634        if (canon_mp == NULL) {
     635                rc = EINVAL;
     636                goto out;
     637        }
     638
     639        rc = vol_get_parts(vol, &part_ids, &nparts);
     640        if (rc != EOK)
     641                goto out;
     642
     643        for (i = 0; i < nparts; i++) {
     644                rc = vol_part_info(vol, part_ids[i], &vinfo);
     645                if (rc != EOK) {
     646                        rc = EIO;
     647                        goto out;
     648                }
     649
     650                if (str_cmp(vinfo.cur_mp, canon_mp) == 0) {
     651                        *rid = part_ids[i];
     652                        rc = EOK;
     653                        goto out;
     654                }
     655        }
     656
     657        rc = ENOENT;
     658out:
     659        free(part_ids);
     660        free(canon_mp_buf);
     661        return rc;
     662}
     663
    610664/** @}
    611665 */
  • uspace/lib/dltest/meson.build

    r1cfce3f raca1777  
    2828
    2929allow_shared = true
     30
    3031src = files(
    3132        'dltest.c',
  • uspace/lib/futil/src/futil.c

    r1cfce3f raca1777  
    9999                return EIO;
    100100
    101         rc = vfs_lookup_open(destp, WALK_REGULAR | WALK_MAY_CREATE, MODE_WRITE, &df);
    102         if (rc != EOK)
    103                 return EIO;
     101        rc = vfs_lookup_open(destp, WALK_REGULAR | WALK_MAY_CREATE, MODE_WRITE,
     102            &df);
     103        if (rc != EOK) {
     104                vfs_put(sf);
     105                return EIO;
     106        }
    104107
    105108        do {
     
    152155        de = readdir(dir);
    153156        while (de != NULL) {
    154                 if (asprintf(&srcp, "%s/%s", srcdir, de->d_name) < 0)
    155                         return ENOMEM;
    156                 if (asprintf(&destp, "%s/%s", destdir, de->d_name) < 0)
    157                         return ENOMEM;
     157                if (asprintf(&srcp, "%s/%s", srcdir, de->d_name) < 0) {
     158                        rc = ENOMEM;
     159                        goto error;
     160                }
     161
     162                if (asprintf(&destp, "%s/%s", destdir, de->d_name) < 0) {
     163                        rc = ENOMEM;
     164                        goto error;
     165                }
    158166
    159167                rc = vfs_stat_path(srcp, &s);
    160168                if (rc != EOK)
    161                         return EIO;
     169                        goto error;
    162170
    163171                if (s.is_file) {
    164172                        rc = futil_copy_file(futil, srcp, destp);
    165                         if (rc != EOK)
    166                                 return EIO;
     173                        if (rc != EOK) {
     174                                rc = EIO;
     175                                goto error;
     176                        }
    167177                } else if (s.is_directory) {
    168178                        if (futil->cb != NULL && futil->cb->create_dir != NULL)
     
    170180                        rc = vfs_link_path(destp, KIND_DIRECTORY, NULL);
    171181                        if (rc != EOK)
    172                                 return EIO;
     182                                goto error;
    173183                        rc = futil_rcopy_contents(futil, srcp, destp);
    174184                        if (rc != EOK)
    175                                 return EIO;
     185                                goto error;
    176186                } else {
    177                         return EIO;
     187                        rc = EIO;
     188                        goto error;
    178189                }
    179190
     
    181192        }
    182193
    183         return EOK;
     194        closedir(dir);
     195        return EOK;
     196error:
     197        closedir(dir);
     198        return rc;
    184199}
    185200
  • uspace/lib/inet/meson.build

    r1cfce3f raca1777  
    2727#
    2828
     29allow_shared = true
     30
    2931src = files(
    3032        'src/addr.c',
  • uspace/lib/meson.build

    r1cfce3f raca1777  
    288288                                dependencies: _shared_deps,
    289289                        )
     290                        exported_devel_files += [ 'sharedlib', _shared_lib, _libname ]
    290291                endif
    291292
  • uspace/lib/posix/meson.build

    r1cfce3f raca1777  
    3030includes += include_directories('include/posix', 'include')
    3131c_args += [ '-fno-builtin', '-D_XOPEN_SOURCE' ]
     32
     33allow_shared = true
    3234
    3335# TODO
Note: See TracChangeset for help on using the changeset viewer.