Jakub Kot
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # SO Lista 5 ## Zadanie 1 ![](https://i.imgur.com/JqqET6h.png) ### Pojęcia: ![](https://i.imgur.com/xX0V7hn.png) * Jednokierunkowość - komunikacja pipem odbywa się tylko w jednym kierunku. Zostaje utworzony deskryptor pliku, który zapisuje wyjście jednego zadania, do pipe'a, z którego drugi deskryptor odczytuje dane dla drugiego zadania. * bufor - Czytając dane z pipe'a, możemy wczytać jednorazowo cały strumień, o ile nie przekracza on maksymalnej wielkości buforu, opisanego jako ilość bajtów stałej ```PIPE_BUF``` ### Zadania: * Gdy bufor jest pusty - operacja ```read``` może zostać zablokowana, dopóki w buforze nie pojawią się dane. * Jeśli bufor jest pełny - operacja ```write```, może zostać zablokowana, do czasu odczytania części danych przez ```read```. * W przypadku, gdy do rury pisze wiele procesów, ale żaden z nich nie przekracza ```PIPE_BUF```, mamy gwarację atomowości zapisu, tj. dane zostaną zapisane każdorazowo w całości i w żadnym przypadku, proces zapisu nie zostanie zakłócony (przerwany). * ```Short count``` zostanie zwrócony, gdy w trakcie czytania z pipe'a, dostępne jest mniej niż ```nbyte``` bajtów do czytania lub w trakcie pisania, gdy jesteśmy blisko EOF, bądź kończy się dostępne miejsce na dysku. Rodzic nie może być połączony pipem z dzieckiem, po jego utworzeniu, bo: "Pipes can be used for communication between any two (or more) related processes, as long as the pipe was created by a common ancestor before the series of fork() calls that led to the existence of the processes." ## Zadanie 2 ![](https://i.imgur.com/hsZimni.png) ### Pojęcia: * Urządzenie znakowe służy do odczytywania/zapisywania danych z/do urządzenia znak po znaku. Z zasady nie są buforowane i służą do komunikacji o charakterze strumieniowym. Są to między innymi wszelkie konsole ```/dev/tty0```, ```/dev/tty1```, wirtualne konsole ```/dev/pts/0```, ```/dev/pts/1```, modemy, myszki, pamięć RAM, generatory liczb pseudolosowych, generator zer czy ```/dev/null`. * Urządzenie blokowe pozwala na odczytywanie/zapisywanie danych blokami, czyli większymi grupami bajtów mającymi postać: sektorów, kilobajtów czy klastrów. W większości przypadków konieczność operowania na blokach wymuszona jest logiczną budową urządzenia. Są to między innymi dyski ```/dev/hda```, ```/dev/sdb```, partycje, dyskietki, pętle zwrotne. ### Zadania: Wywołanie systemowe ```ioctl()``` (input/output control) to wywołanie systemowe do specyficznych dla danego urządzenia operacji I/O i innych operacji, których nie można wyrazić zwykłymi syscallami. Funkcja ta wygląda następująco: ```c= int ioctl(int fd, unsigned long request, ...); 75 : 27370 ioctl(10, TIOCSPGRP, [27370] <unfinished ...> ``` fd jest otwartym deskryptorem pliku, a request to zależny od urządzenia kod żądania (danej operacji) - koduje on informację o tym, czy argument jest parametrem wejściowym czy wyjściowym i rozmiar kolejnego argumentu argp w bajtach, trzecim parametrem jest nietypowany wskaźnik do pamięci, zwykle ```char *argp```, zanim ```void*``` było poprawne w C. ```DIOCEJECT``` - Eject removable disc - wysuwa dysk wymienny ```KIOCTYPE``` - Get keyboard type - zwraca typ klawiatury. Get keyboard type. The argument is of type int *, in which one of the values KB_SUN2, KB_SUN3 or KB_SUN4 will be returned. ```SIOCGIFCONF``` - Get ifnet list - zwraca listę ```ifnet``` (interfejsów jądra do zarządzania sieciami) ![](https://i.imgur.com/ooNzCB1.png) ## Zadanie 3 ![](https://i.imgur.com/u1oZiv6.png) ### Pojęcia: Nieużytek to nieużywany fragment reprezentacji katalogu. Kompaktowanie to operacja, która zmniejsza rozmiar katalogu - usuwane są nieużytki, “uklepujemy” katalog. Opłaca się ją robić, gdy w katalogu mamy dużo nieużytków ### Zadania: ![](https://i.imgur.com/LwgrEiq.png) Dodawanie pliku: Trzeba przejrzeć cały katalog, żeby sprawdzić, czy jest dany plik w tym katalogu. Jeśli nie ma miejsca, wykonywane jest kompaktowanie. Jeśli miejsce jest, to wydzielamy odpowiednią przestrzeń w statbufie i wrzucamy tam dane pliku. Usuwanie pliku: Przegląda się cały katolog, żeby wiedzieć, czy jest plik. Po usunięciu pliku miejsce, gdzie był ten plik staje się nieużytkiem, pliki nie są od razu przesuwane, lecz przestawiany jest wskaźnik przy poprzednim pliku (entry size). ## Zadanie 4 ![](https://i.imgur.com/mfyyQQK.png) ### Pojęcia: i-node to struktura przechowująca metadane pliku. Zawiera on wskaźniki na bloki danych oraz bloki pośrednie, zależnie od wielkości pliku. ```shell= stat /usr/bin/cc Plik: /usr/bin/cc -> /etc/alternatives/cc rozmiar: 20 bloków: 0 bloki I/O: 4096 dowiązanie symboliczne Urządzenie: 10304h/66308d inody: 4611054 dowiązań: 1 Dostęp: (0777/lrwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root) Dostęp: 2022-10-29 12:11:24.892885157 +0200 Modyfikacja: 2022-10-08 15:14:28.849329476 +0200 Zmiana: 2022-10-08 15:14:28.849329476 +0200 Utworzenie: 2022-10-08 15:14:28.849329476 +0200 ``` Algorytm zaczyna działanie od 2-węzła (czyli od ```/```) Nie możemy tworzyć dowiązań do innych, zamontowanych systemów plików, aby nie doprowadzić do sytuacji, w której odłączenie systemu plików, spowodowałoby, że dane nigdy nie zostaną usunięte. Skąd sterownik wie, gdzie na dysku jest i-ty bajt pliku? * W Statbuf mamy wskaźnik na bloki pamięci ![](https://i.imgur.com/ZguVBi7.png) ### Zadania: ## Zadanie 5 ![](https://i.imgur.com/JNGaOeJ.png) ### Pojęcia: ### Zadania: ## Zadanie 6 ![](https://i.imgur.com/0Dec8Xh.png) ### Pojęcia: ### Zadania: ## Zadanie 7 ![](https://i.imgur.com/HkMWyak.png) ### Pojęcia: ### Zadania:

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully