I'm trying to use the "mknod" call in C to create a clone of /dev/null. I am stumped as to the final parameter I should provide to "mknod()". I am supposed to give it a type dev_t, which specifies a major & minor number. I want to specify major 3, minor 1, but how can I do this?
dev_t seems to be a long long. It takes up 8 bytes, but I can't find anything about it. I've searched through quite a few /usr/include files, but I still can't find anything (nor on google).
If I 'stat()' /dev/null and then print the value of st_dev as an int (%d), I get '16'. But when I try and create a file called 'mynull', a clone of /dev/null, I get a major number of 0 and minor number of 16 , as shown below ( mknod() fails unless I call it as root ).
From my man page:
Does anyone have any ideas as to how I can create a character special file with major number 1 and minor number 3?
Here's what I get when I stat /dev/null:
$ a.out
dev_t for /dev/null = 16
nathan,
You are referencing the wrong struct member to get device numbers. You should be referring to st_rdev and not st_dev.
From man stat:
Also, if you know the major and the minor device numbers, you can use the makedevice macro to create the device number. The makedevice macro is defined in /usr/include/sys/sysmacros.h. Maybe you could take a look at that file as well.
blowtorch, thanks for the explanation. You are right, the macro is defined in /usr/include/sys/sysmacros.h. I was able to find the correct value using makedev(1,3).
If I would have printed the correct member from the stat() call, I would have found that it is the number 259.
Friends have the following problem
a search may not find anything which would correct example:
ls -ltr *prueba.txt | nawk '{ print $9 }' > Procesar.dat 2>/dev/null
When he finds nothing gives me the following error
ls: prueba.txt: No such file or directory
because 2> / dev / null... (4 Replies)
Hello All and a Happy New year to yous guys.
I'm running the below command on my AIX box and it keeps giving me the message that the file doesn't exist. I know the file don't exist, but I don't want to see the error. 2>/dev/null doesn't work.
bash-3.00$ ls -l C* | wc -l 2>/dev/null
ls:... (2 Replies)
I apologize if this question has been answered else where or is too elementary.
I ran across a KSH script (long unimportant story) that does this:
if ; then
CAS_SRC_LOG="/var/log/cas_src.log 2>&1"
else
CAS_SRC_LOG="/dev/null 2>&1"
fithen does this:
/usr/bin/echo "heartbeat:... (5 Replies)
Hello friends,
I Working with Solaris 8 on a SunFireV890, 150 GB SCSI HD's in Raid 1 (mirroring), my problem is that the master disk failed and going to put the slave (mirror) as a Master in the slot 0 (SCSI) will not start.
The original mounting this, mirror in Raid 0:
c1t0d0s0 (master)... (10 Replies)
How are these two different? They both prevent output and error from being displayed. I don't see the use of the "&"
echo "hello" > /dev/null 2>&1
echo "hello" > /dev/null 2>1 (3 Replies)
Hi expert,
May I know what is the difference between below cron tab entry ?
0,12 * * * * /abc/myscript.sh > /dev/null 2>&1
0,12 * * * * /abc/myscript.sh (7 Replies)
Hi, Anyone can help
My solaris 8 system has the following
/dev/null , /dev/tty and /dev/console
All permission are lrwxrwxrwx
Can this be change to a non-world write ??
any impact ?? (12 Replies)
hello all,
In many shell scripts i found '> /dev/null' , i am not able to get this,
will any one please explain why we are using this.
thanks
sudha (2 Replies)
Hi,
Q1-What does
nroff -ms > /dev/null
Q2- What does mean -A under STAT column :
ps aux |head -20
UTIL PID %CPU %MEM SZ RSS TTY STAT STIME TIME COMMAND
root 516 93,0 0,0 12 12 - A 04 nov 3906:51 wait
Thank you. (4 Replies)