CSCI 1730 April 2 nd, 2014. C review – 4 data types /* A review of the basic data types in C. */ #include int main() { intx,y; chara; floatf,e; doubled;

Slides:



Advertisements
Similar presentations
File Types in Unix regular file - can be text, binary, can be executable directory file - "folder type" file FIFO file - special pipe device file, allows.
Advertisements

The UNIX File System Harry Chen Department of CSEE University of MD Baltimore County.
CSCI 1730 April 1 st, Materials Class notes slides & some “plain old” html & source code examples linked from course calendar board notes & diagrams.
MORE FILE ATTRIBUTES. ls –l to display file attributes (properties) Listing of a specific directory Ownership and group ownership Different file permissions.
The Unix File System. What are the three parts of every file on a Unix filesystem? And where is each stored? Filename - stored in directories Inode -
File Security. Viewing Permissions ls –l Permission Values.
Files. System Calls for File System Accessing files –Open, read, write, lseek, close Creating files –Create, mknod.
Linux+ Guide to Linux Certification, Second Edition
6/24/2015B.RamamurthyPage 1 File System B. Ramamurthy.
Linux Linux File System.
Variables and constants Applications of Computer Programming in Earth Sciences Instructor: Dr. Cheng-Chien LiuCheng-Chien Liu Department of Earth Sciences.
UNIX Files and Security Software Tools. Slide 2 File Systems l What is a file system? A means of organizing information on the computer. A file system.
7/15/2015B.RamamurthyPage 1 File System B. Ramamurthy.
Getting Started with Linux Linux System Administration Permissions.
Introduction to Linux and Shell Scripting Jacob Chan.
CSCI 1730 March 27 th, Text System Programming with C and Unix by Hoover Ch 1: Introduction Ch 2: Bits, Bytes and Data Types Ch 3: Arrays and Strings.
O.S security Ge Zhang Karlstad University. Outline Why O.S. security is important? Security schemes in Unix/Linux system Security schemes in windows system.
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
Filesystem Hierarchy Standard (FHS) –Standard of outlining the location of set files and directories on a Linux system –Gives Linux software developers.
1 THE UNIX FILE SYSTEM By Chokechai Chuensukanant ID COSC 513 Operating System.
The file structure and related utilities CS240 Computer Science II.
CECS 121 EXAM 1. /* C Programming for the Absolute Beginner */ // by Michael Vine #include main() { printf(“\nC you later\n”); system(“pause”); }
Files & Directories Objectives –to be able to describe and use the Unix file system model and concepts Contents –directory structure –file system concepts.
File Permissions. What are the three categories of users that apply to file permissions? Owner (or user) Group All others (public, world, others)
Linux+ Guide to Linux Certification, Second Edition
C Tokens Identifiers Keywords Constants Operators Special symbols.
Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2011 by the Trustees of Indiana University except as noted.
INTRODUCTION TO LINUX Jacob Chan. GNU/Linux Consists of Linux kernel, GNU utilities, and open source and commercial applications Works like Unix –Multi-user.
File Systems CSCI What is a file? A file is information that is stored on disks or other external media.
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved Chapter 5 File Management File Overview.
/* C Programming for the Absolute Beginner */ // by Michael Vine #include main() { printf(“\nC you later\n”); system(“pause”); }
Managing Files. Module 5 Managing Files ♦ Introduction “On a Linux system, everything is a file; if something is not a file, it is a process.” ♦ Topics.
These notes were originally developed for CpSc 210 (C version) by Dr. Mike Westall in the Department of Computer Science at Clemson.
Files and Directories File types stat functions for file information
Linux+ Guide to Linux Certification, Third Edition
Linux+ Guide to Linux Certification, Third Edition
PacNOG 6: Nadi, Fiji UNIX ™/ /Linux Permissions Hervey Allen Network Startup Resource Center.
Privileges: who can control what Introduction to Unix June 16, 2009 Papeete, French Polynesia Hervey Allen.
/* C Programming for the Absolute Beginner */ // by Michael Vine #include main() { printf(“\nC you later\n”); system(“pause”); }
Privileges: who can control what Introduction to Unix May 24, 2008 Rabat, Morocco Hervey Allen.
Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2007 by the Trustees of Indiana University except as noted.
Today’s topic Access and manipulate meta data for files –File type, ownership, access permissions, access time, etc How to determine if a file is not there?
The Unix File system (UFS) Presented by: Gurpreet Singh Assistant Professor Department of School of Computing and Engineering Galgotias University.
THE FILE SYSTEM Files long-term storage RAM short-term storage Programs, data, and text are all stored in files, which is stored on.
CIT 383: Administrative ScriptingSlide #1 CIT 383: Administrative Scripting Directories.
UNIX filesystem CS 2204 Class meeting 2 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
File System Security ls -l. First Columm d = directory l = symbolic link b = block special file c = character special file p = fifo (or named pipe) special.
CSCI 330 UNIX and Network Programming Unit VIII: I/O Management II.
UNIX file systems Learning Objectives: 1. To understand the basics of file systems 2. To understand the hierarchical structure in Unix file system 3. To.
The Unix File System R Bigelow. The UNIX File System The file system refers to the way in which UNIX implements files and directories. The UNIX file system.
Java Basics. Tokens: 1.Keywords int test12 = 10, i; int TEst12 = 20; Int keyword is used to declare integer variables All Key words are lower case java.
Chapter 2: Exploring the UNIX File System (For Tuesday Section) File and File Systems.
Karlstad University Operating System security Ge Zhang Karlstad University.
Linux Filesystem Management
Getting Started with Linux
Privileges: who can control what
Permissions: who can control what Unix/IP Preparation Course July 19, 2009 Eugene, Oregon, USA
The Machine Model Memory
Privileges: who can control what
CIT 383: Administrative Scripting
Introduction to Programming
Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Character Set Uppercase Alphabets A,
File System B. Ramamurthy B.Ramamurthy 11/27/2018.
Security and File Permission
Program Breakdown, Variables, Types, Control Flow, and Input/Output
Hard Link when a file is copied, both the original and copy occupy separate space on the disk. unix allows a file to have more than one name and yet maintain.
Department of School of Computing and Engineering
Software I: Utilities and Internals
C Language B. DHIVYA 17PCA140 II MCA.
January 26th, 2004 Class Meeting 2
Presentation transcript:

CSCI 1730 April 2 nd, 2014

C review – 4 data types /* A review of the basic data types in C. */ #include int main() { intx,y; chara; floatf,e; doubled; x=4; y=7; a='H'; f=-3.4; d= ; e= ; printf("%d %c %f %lf\n",x,a,e,d); printf("%d %c %.9f %.9lf\n",x,a,e,d); }

C review – arithmetic /* A review of the basic arithmetic operators in C. */ #include int main() { int x,y; int r1,r2,r3,r4,r5; x=4; y=7; r1=x+y; r2=x-y; r3=x/y; r4=x*y; printf("%d %d %d %d\n",r1,r2,r3,r4); r3++; r4--; r5=r4%r1; printf("%d %d %d\n",r3,r4,r5); }

C review – loops #include /* A review of the loop types in C. */ int main() { int i,x; x=0; for (i=0; i<4; i++) { x=x+i; printf("%d\n",x); } while (i<7) { x=x+i; i++; printf("%d\n",x); } do { x=x+i; i++; printf("%d\n",x); } while (i<9); }

C review – blocks /* A review of conditionals and blocks in C. */ #include int main() { int i,x; x=0; for (i=0; i<5; i++) { if (i%2 == 0 || i == 1) x=x+i; else x=x-i; printf("%d\n",x); }

C review – flow control /* A review of flow control statements in C. */ #include int main() { int i,x; x=0; for (i=0; i<5; i++) { if (i%2 == 0) continue; x=x-i; if (i%4 == 0) break; printf("%d\n",x); }

ASCII /* This program shows the dual interpretations of char and ** unsigned char data types. */ #include main() { char a; unsigned char b; a='A'; b='B'; printf("%c %c %d %d\n",a,b,a,b); a=183; b=255; printf("%d %d\n",a,b); }

sizeof() operator /* This program demonstrates the sizeof() operator. */ #include main() { int i; char c; double d; printf("%d %d %d %d\n",sizeof(i),sizeof(c),sizeof(d),sizeof(float)); }

Bitwise NOT /* This program demonstrates the bitwise not operator. */ #include main() { unsigned char a; a=17; a=~a; printf("%d\n",a); }

Bitwise AND /* This program demonstrates the bitwise and operator. */ #include main() { unsigned char a,b; a=17; b=22; a=a & b; printf("%d\n",a); }

Bitwise OR /* This program demonstrates the bitwise or operator. */ #include main() { unsigned char a,b; a=17; b=22; a=a | b; printf("%d\n",a); }

Bit operators (variables and constants) /* This program demonstrates using the bitwise operators ** with variables and constants. */ #include main() { char x,y; x=7; y=6; x=x&y; y=x|16; printf("%d %d\n",x,y); }

Left/Right shift /* This program demonstrates the bitwise shift operators, ** left-shift and right-shift. */ #include main() { unsigned char a,b; a=17; a=a << 2; b=64; b=b >> 3; printf("%d %d\n",a,b); }

Bitwise right-shift (negative) /* This program demonstrates right-shifting a negative integer ** so that the shifted-in bits are 1 instead of 0 */ #include main() { char a,b; a=17; a=a >> 2; b=-65; b=b >> 2; printf("%d %d\n",a,b); }

Bitmasks /* This program demonstrates setting a bit, clearing a bit, and ** reading a bit. */ #include main() { char a; int i; a=17; a=a | (1 << 3); /* set 3rd bit */ printf("%d\n",a); a=a & (~(1<<4)); /* clear 4th bit */ printf("%d\n",a); for (i=7; i>=0; i--) printf("%d ",(a&(1 > i); /* read i'th bit */ printf("\n"); }

Memory map 1 /* Draw the memory map for this code (pg 65) */ #include main() { char a,b,c; a=7; b=-13; c=0; }

Memory map 2 /* Draw the memory map for this code (pg 65) */ #include main() { char a; int b; float c; double d; a=7; b=-13; c=0.1; d=42.5; }

Memory map 3 /* Draw the memory map for this code. Showing the bit patterns ** emphasizes the differences in storage of "6" (pg 66) */ #include main() { char a; short int b; char c; a=6; b=13; c='6'; }

Memory map 4 /* Draw the memory map for this code. It can emphasize the ** value of a loop counter after the loop is done (pg 67) */ #include main() { int i,n; n=0; for (i=1; i<=4; i++) n=n+i; }

Memory map 5 /* Draw the memory map for this code. It can emphasize an ** unitialized variable (pgs 67-68) */ #include main() { int i,sum; printf("%d\n",sum); for (i=1; i<=10; i++) if (i%2 == 0) sum=sum+i; printf("%d\n",sum); }

File Types in Unix regular file - can be text, binary, can be executable directory file - "folder type" file FIFO file - special pipe device file, allows unrelated processes to communiate block device file - represents physical device that transmit data a block at a time character device file - represents physical device that doesn't necessarily transmit data a block at a time symbolic link file - contains a pathname that references another file (some versions of UNIX)

creating and removing files directory created using mkdir, removed using rmdir mkdir /usr/tmp/junkdir rmdir /usr/tmp/junkdir device files created using mknod (need to be superuser) mknod /dev/cdsk c mknod /dev/bdsk b

Creating and removing files FIFO created using mkfifo mkfifo /usr/tmp/fifo.mine to make a link, use ln : ln -s /usr/jose/original /usr/mary/slink then, if you type more /usr/mary/slink you get the contents of /usr/jose/original... the link is followed (like a pointer)

File attributes file type access permission - for owner, group, other hard link count uid - user id of the file owner (linked to user via password file) gid - group id of the file owner file size - in bytes last access time last modify time last change time – time file permission, uid, gid, or hard link count changed inode number - sytem inode number of the file file system id major and minor device numbers

File attributes You can see many of the file attributes by typing: ls -l -rw-r--r--. 1 eileen users 199 Apr 2 04:41 arithmetic.c -rw-r--r--. 1 eileen users 142 Apr 2 04:41 ascii.c -rw-r--r--. 1 eileen users 205 Apr 2 04:41 basic_types.c -rw-r--r--. 1 eileen users 91 Apr 2 04:41 bit.c -rw-r--r--. 1 eileen users 253 Apr 2 04:41 bitmask.c -rw-r--r--. 1 eileen users 155 Apr 2 04:41 blocks.c -rw-r--r--. 1 eileen users 6021 Apr 1 08:41 buggy.c -rw-r--r--. 1 eileen users 6178 Apr 1 08:33 commented.c

File attributes used by the kernel in managing files uid and gid are compared against those of a process attempting to access the file to determine which access permissions apply The make utility looks at the last modification time Not all fields make sense for every file: size doesn't apply to device files device number doesn't apply to regular files

Some file attributes can’t be changed inode number file type file system id major and minor device number

Changing file attributes -- UNIX command ---- System call ---- Attributes changed -- chmod access permissions last change time chown uid last change time chgrpchown gid last change time chmod access permissions last change time touchutime last access time modification time lnlink increase hard link count rmunlink decrease hard link count