View "cvs diff" output in two columns with vim - vim

I have "cvs diff" output (for all files in project) in unified diff format.
Format could be like this:
Index: somefile.cpp
===================================================================
RCS file: /CVS_repo/SomeProject/somefile.cpp,v
retrieving revision 1.19
diff -r1.19 somefile.cpp
31c31
< return "Read line four times";
---
> return "Read line five times";
36c36
< return "Make a bad thing";
---
> return "Make a good thing";
Index: otherfile.cpp
===================================================================
RCS file: /CVS_repo/SomeProject/otherfile.cpp,v
retrieving revision 1.19
< ........
---
> ........
or even like this:
Index: somefile.cpp
===================================================================
RCS file: /CVS_repo/SomeProject/somefile.cpp,v
retrieving revision 1.19
diff -u -r1.19 somefile.cpp
--- somefile.cpp 13 Mar 2013 08:45:18 -0000 1.19
+++ somefile.cpp 26 Mar 2013 08:10:33 -0000
## -28,12 +28,12 ##
//---------------------------------------------------------------------------
extern "C" char *FuncGetSomeText()
{
- return "Read line four times";
+ return "Read line five times";
}
//---------------------------------------------------------------------------
extern "C" char *FuncGetAwesomeText()
{
- return "Make a bad thing";
+ return "Make a good thing";
}
//---------------------------------------------------------------------------
Index: otherfile.cpp
===================================================================
RCS file: /CVS_repo/SomeProject/otherfile.cpp,v
retrieving revision 1.19
diff -u -r1.19 otherfile.cpp
--- otherfile.cpp 13 Mar 2013 08:45:18 -0000 1.19
+++ otherfile.cpp 26 Mar 2013 08:10:33 -0000
## -28,12 +28,12 ##
//---------------------------------------------------------------------------
extern "C" char *Func()
{
- .......
+ .......
}
//---------------------------------------------------------------------------
Is there any way to view this text side-by-side with vim?
Or maybe it's possible to change default diff tool in cvs to vimdiff?

Some sed magic help me:
\cvs -n diff -u > ~diff.tmp; vim -O <(sed -r -e 's/^\+[^\+]+.*$//g;s/^\+$//g' ~diff.tmp) <(sed -r -e 's/^-[^-]+.*$//g;s/^-$//g' ~diff.tmp) +'set scb | set nowrap | wincmd w | set scb | set nowrap'
It is not perfect solution, but better then nothing. Here what this script doing:
\cvs -n diff -u > ~diff.tmp;
Write CVS diff output in unified format (-u option) to temp file ~diff.tmp. '\' char prevent from taking alias of "cvs" command.
(sed -r -e 's/^\+[^\+]+.*$//g;s/^\+$//g' ~diff.tmp)
(sed -r -e 's/^-[^-]+.*$//g;s/^-$//g' ~diff.tmp)
This commands output text from ~diff.tmp, replace lines beginning with '+' and '-' symbols with empty line.
vim -O <(sed...) <(sed...) +'set scb | set nowrap | wincmd w | set scb | set nowrap'
Open two windows (-O option) with sed's output in each. Command followed '+' set srollbind on and nowrap for first window, then switch to second window (with 'wincmd w') and do same things

Related

use a shell script to update version

#include "calcmarks.h"
// calcmarks, version 1, released Thu Mar 23 13:16:49 WST 2017
int main(int argc, char *argv[])
{
int nmarks = 0;
if(argc == 1) {
nmarks += readmarks(stdin);
Don't care what this code is, what I want is a shellscript to update and version.After do the shellscript,the comment above will become
// calcmarks, version 2, released (time you execute the script)
Tried to do below which didn't work.
a=$(date)
sed -i "_bak" s'/Thu Mar 23 13:16:49 WST 2017/$a/g' "calcmarks.c"
Here is a list of commands that will perform the trick.
Nota : If you are using a different -version-numbering system (2.1, 2.1.1, etc), you'll need to change it slightly.
prev_version=$(sed -n '\%.*// calcmarks, version %!d;s///;s/ .*//p' "$file")
new_version=$((prev_version+1))
curr_date=$(date "+%a %b %d %H:%M:%S %Z %Y")
sed -i -e "s#\(// calcmarks, version \)${prev_version}.*#\1${new_version}, released ${curr_date}#g" "$file"

missing separator on Makefile

I am now having problems with a autotools generated Makefile, and it first looks like this. When I was trying make an error arised:
Makefile:327: *** missing separator. Stop.
Then, I tried the following change:
326,327c326
< LDFLAGS = -Wl,-O1,--sort-common,--as-needed,-z,relro -L/home/tjm/tmp/fake-root/libgd/usr/local/lib/ -L /home/tjm/tmp/fake-root/libpng/usr/local/lib -L /home/tjm/tmp/fake-root/freetype/usr/local/lib -L /home/tjm/tmp/fake-root/libpng/usr/local/lib -L /home/tjm/tmp/jpeg-6b
< -static
---
> LDFLAGS = -Wl,-O1,--sort-common,--as-needed,-z,relro -L/home/tjm/tmp/fake-root/libgd/usr/local/lib/ -L /home/tjm/tmp/fake-root/libpng/usr/local/lib -L /home/tjm/tmp/fake-root/freetype/usr/local/lib -L /home/tjm/tmp/fake-root/libpng/usr/local/lib -L /home/tjm/tmp/jpeg-6b -static
But, this time, I got this error:
Making all in intl
Makefile:35: *** missing separator. Stop.
make[1]: *** [Makefile:582: all-recursive] Error 1
make: *** [Makefile:489: all] Error 2
The related lines look like these:
32 skip_next=no; \
33 strip_trailopt () \
34 { \
35 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
36 }; \
And I teird a lot of things like:
34 { flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; }; \
34 { \
35 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; }; \
33 strip_trailopt () { flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; }; \
and
35 ^Iflg=printf '%s\n' "$$flg" | sed "s/$$1.*$$//"; \$
But still got the same error.
Does anyone can give me some ieda about how to fix it?
(Note: I'm not sure if this is correct in StackOverflow vs SuperUser.)
If you edited the Makefile, it'll not be useful as it'll just re-generate out of Makefile.in, and that one in turn will be generated out of Makefile.am.
Check your Makefile.am file, and put -static in the same line as everything else; what is happening is that it does not have a continuation symbol at the end of the previous line (\), so the variable definition is not continued. And because of that it tries to parse it as a rule, which it's not.

How to monitor newly created file in a directory with bash?

I have a log directory that consists of bunch of log files, one log file is created once an system event has happened. I want to write an oneline bash script that always monitors the file list and display the content of the newly created file on the terminal. Here is what it looks like:
Currently, all I have is to display the content of the whole directory:
for f in *; do cat $f; done
It lacks the monitoring feature that I wanted. One limitation of my system is that I do not have watch command. I also don't have any package manager to install fancy tools. Raw BSD is all I have. I do have tail, I was thinking of something like tail -F $(ls) but this tails each file instead of the file list.
In summary, I want to modify my script such that I can monitor the content of all newly created files.
First approach - use a hidden file in you dir (in my example it has a name .watch). Then you one-liner might look like:
for f in $(find . -type f -newer .watch); do cat $f; done; touch .watch
Second approach - use inotify-tools: https://unix.stackexchange.com/questions/273556/when-a-particular-file-arrives-then-execute-a-procedure-using-shell-script/273563#273563
You can cram it into a one-liner if you want, but I'd recommend just running the script in the background:
#!/bin/bash
[ ! -d "$1" ] && {
printf "error: argument is not a valid directory to monitory.\n"
exit 1
}
while :; fname="$1/$(inotifywait -q -e modify -e create --format '%f' "$1")"; do
cat "$fname"
done
Which will watch the directory given as the first argument, and cat any new or changed file in that directory. Example:
$ bash watchdir.sh my_logdir &
Which will then cat new or changed files in my_logdir.
Using inotifywait in monitor mode
First this little demo:
Open one terminal and run this:
ext=(php css other)
while :;do
subname=''
((RANDOM%10))||printf -v subname -- "-%04x" $RANDOM
date >/tmp/test$subname.${ext[RANDOM%3]}
sleep 1
done
This will create randomly files named /tmp/test.php, /tmp/test.css and /tmp/test.other, but randomly (approx 1 time / 10), the name will be /tmp/test-XXXX.[css|php|other] where XXXX is an hexadecimal random number.
Open another terminal and run this:
waitPaths=(/{home,tmp})
while read file ;do
if [ "$file" ] &&
( [ -z "${file##*.php}" ] || [ -z "${file##*.css}" ] ) ;then
(($(stat -c %Y-%X $file)))||echo -n new
echo file: $file, content:
cat $file
fi
done < <(
inotifywait -qme close_write --format %w%f ${waitPaths[*]}
)
This may produce something like:
file: /tmp/test.css, content:
Tue Apr 26 18:53:19 CEST 2016
file: /tmp/test.php, content:
Tue Apr 26 18:53:21 CEST 2016
file: /tmp/test.php, content:
Tue Apr 26 18:53:23 CEST 2016
file: /tmp/test.css, content:
Tue Apr 26 18:53:25 CEST 2016
file: /tmp/test.php, content:
Tue Apr 26 18:53:27 CEST 2016
newfile: /tmp/test-420b.php, content:
Tue Apr 26 18:53:28 CEST 2016
file: /tmp/test.php, content:
Tue Apr 26 18:53:29 CEST 2016
file: /tmp/test.php, content:
Tue Apr 26 18:53:30 CEST 2016
file: /tmp/test.php, content:
Tue Apr 26 18:53:31 CEST 2016
Some explanation:
waitPaths=(/{home,tmp}) could be written waitPaths=(/home /tmp) or for only one directory: waitPaths=/var/log
if condition search for filenames matching *.php or *.css
(($(stat -c %Y-%X $file)))||echo -n new will compare creation and modification time.
inotifywait
-q to stay quiet (don't print more then required)
-m for monitor mode: Command don't termine, but print each matching event.
-e close_write react only to specified kind of event.
-f %w%f Output format: path/file
Another way:
There is a more sophisticated sample:
Listenning for two kind of events (CLOSE_WRITE | CREATE)
Using a list of new files flags for knowing which files are new when CLOSE_WRITE event occur.
In second console, hit Ctrl+C, or in new terminal, tris this:
waitPaths=(/{home,tmp})
declare -A newFiles
while read path event file; do
if [ "$file" ] && ( [ -z "${file##*.php}" ] || [ -z "${file##*.css}" ] ); then
if [ "$event" ] && [ -z "${event//*CREATE*}" ]; then
newFiles[$file]=1
else
if [ "${newFiles[$file]}" ]; then
unset newFiles[$file]
echo NewFile: $file, content:
sed 's/^/>+ /' $file
else
echo file: $file, content:
sed 's/^/> /' $path/$file
fi
fi
fi
done < <(inotifywait -qme close_write -e create ${waitPaths[*]})
May produce something like:
file: test.css, content:
> Tue Apr 26 22:16:02 CEST 2016
file: test.php, content:
> Tue Apr 26 22:16:03 CEST 2016
NewFile: test-349b.css, content:
>+ Tue Apr 26 22:16:05 CEST 2016
file: test.css, content:
> Tue Apr 26 22:16:08 CEST 2016
file: test.css, content:
> Tue Apr 26 22:16:10 CEST 2016
file: test.css, content:
> Tue Apr 26 22:16:13 CEST 2016
Watching for new files AND new lines in old files, using bash
There is another solution by using some bashisms like associative arrays:
Sample:
wpath=/var/log
while : ;do
while read -a crtfile ;do
if [ "${crtfile:0:1}" = "-" ] &&
[ "${crtfile[8]##*.}" != "gz" ] &&
[ "${files[${crtfile[8]}]:-0}" -lt ${crtfile[4]} ] ;then
printf "\e[47m## %-14s :- %(%a %d %b %y %T)T ##\e[0m\n" ${crtfile[8]} -1
tail -c +$[1+${files[${crtfile[8]}]:-0}] $wpath/${crtfile[8]}
files[${crtfile[8]}]=${crtfile[4]}
fi
done < <( /bin/ls -l $wpath )
sleep 1
done
This will dump each files (with filename not ending by .gz) in /var/log, and watch for modification or new files, then dump new lines.
Demo:
In a first terminal console, hit:
ext=(php css other)
( while :; do
subname=''
((RANDOM%10)) || printf -v subname -- "-%04x" $RANDOM
name=test$subname.${ext[RANDOM%3]}
printf "%-16s" $name
{
date +"%a %d %b %y %T" | tee /dev/fd/5
fortune /usr/share/games/fortunes/bofh-excuses
} >> /tmp/$name
sleep 1
done ) 5>&1
You need to have fortune installed with BOFH excuses librarie.
If you really not have fortune, you could use this instead:
LANG=C ext=(php css other)
( while :; do
subname=''
((RANDOM%10)) || printf -v subname -- "-%04x" $RANDOM
name=test$subname.${ext[RANDOM%3]}
printf "%-16s" $name
{
date +"%a %d %b %y %T" | tee /dev/fd/5
for ((1; RANDOM%5; 1))
do
printf -v str %$[RANDOM&12]s
str=${str// /blah, }
echo ${str%, }.
done
} >> /tmp/$name
sleep 1
done ) 5>&1
This may output something like:
test.css Thu 28 Apr 16 12:00:02
test.php Thu 28 Apr 16 12:00:03
test.other Thu 28 Apr 16 12:00:04
test.css Thu 28 Apr 16 12:00:05
test.css Thu 28 Apr 16 12:00:06
test.other Thu 28 Apr 16 12:00:07
test.php Thu 28 Apr 16 12:00:08
test.css Thu 28 Apr 16 12:00:09
test.other Thu 28 Apr 16 12:00:10
test.other Thu 28 Apr 16 12:00:11
test.php Thu 28 Apr 16 12:00:12
test.other Thu 28 Apr 16 12:00:13
In a second terminal console, hit:
declare -A files
wpath=/tmp
while :; do
while read -a crtfile; do
if [ "${crtfile:0:1}" = "-" ] && [ "${crtfile[8]:0:4}" = "test" ] &&
( [ "${crtfile[8]##*.}" = "css" ] || [ "${crtfile[8]##*.}" = "php" ] ) &&
[ "${files[${crtfile[8]}]:-0}" -lt ${crtfile[4]} ]; then
printf "\e[47m## %-14s :- %(%a %d %b %y %T)T ##\e[0m\n" ${crtfile[8]} -1
tail -c +$[1+${files[${crtfile[8]}]:-0}] $wpath/${crtfile[8]}
files[${crtfile[8]}]=${crtfile[4]}
fi
done < <(/bin/ls -l $wpath)
sleep 1
done
This will each seconds
for all entries in watched directory
search for files (first caracter is -),
search for filenames begining by test,
search for filenames ending by css or php,
compare already printed sizes with new file size,
if new size greater,
print out new bytes by using tail -c and
store new already printed size
sleep 1 seconds
this may output something like:
## test.css :- Thu 28 Apr 16 12:00:09 ##
Thu 28 Apr 16 12:00:02
BOFH excuse #216:
What office are you in? Oh, that one. Did you know that your building was built over the universities first nuclear research site? And wow, aren't you the lucky one, your office is right over where the core is buried!
Thu 28 Apr 16 12:00:05
BOFH excuse #145:
Flat tire on station wagon with tapes. ("Never underestimate the bandwidth of a station wagon full of tapes hurling down the highway" Andrew S. Tannenbaum)
Thu 28 Apr 16 12:00:06
BOFH excuse #301:
appears to be a Slow/Narrow SCSI-0 Interface problem
## test.php :- Thu 28 Apr 16 12:00:09 ##
Thu 28 Apr 16 12:00:03
BOFH excuse #36:
dynamic software linking table corrupted
Thu 28 Apr 16 12:00:08
BOFH excuse #367:
Webmasters kidnapped by evil cult.
## test.css :- Thu 28 Apr 16 12:00:10 ##
Thu 28 Apr 16 12:00:09
BOFH excuse #25:
Decreasing electron flux
## test.php :- Thu 28 Apr 16 12:00:13 ##
Thu 28 Apr 16 12:00:12
BOFH excuse #3:
electromagnetic radiation from satellite debris
Nota: If some file are modified more than one time between two checks, all modification will be printed on next check.
Although not really nice, the following gives (and repeats) the last 50 lines of the newest file in the current directory:
while true; do tail -n 50 $(ls -Art | tail -n 1); sleep 5; done
You can refresh every minute using a cronjob:
$crontabe -e
* * * * * /home/script.sh
if you need to refresh in less than a minute you can use the command "sleep" inside your script.

is there a way to turn off "A append-to-register?

from :help "A
"Vim fills these registers only when you say so. Specify them as lowercase
letters to replace their previous contents or as uppercase letters to append
to their previous contents"
Is there a way to turn this off?
it's super annoying: when I hold down shift to type double quote " to append to a register, its pretty often the case I hold the shift for a split second too long and input "A instead of "a (so it appends to register a instead of replacing it altogether)
If you wish to implement what #romainl has suggested it can be done in a six lines (three if you don’t mind having magic numbers, leaving unneeded variables and remapping in operator-pending mode):
let s:capshift=char2nr('A')-char2nr('a')
for s:ch in range(char2nr('A'), char2nr('B'))
execute 'nnoremap "'.nr2char(s:ch).' "'.nr2char(s:ch-s:capshift)
execute 'vnoremap "'.nr2char(s:ch).' "'.nr2char(s:ch-s:capshift)
endfor
unlet s:capshift s:ch
. But this solution has a drawback: you now loose ability to wait indefinitely between pressing " and A (unless you want to set notimeout which has problems on its own).
i ended up writing a small patch which adds a "registerappend" option
...with this you can:set noregisterappend to disable it!
diff -r 4cb1f10316ca -r aedf9e836670 src/ops.c
--- a/src/ops.c Thu Oct 11 04:44:33 2012 +0200
+++ b/src/ops.c Tue Oct 16 01:28:47 2012 -0700
## -894,7 +894,8 ## get_yank_register(regname, writing)
else if (ASCII_ISUPPER(i))
{
i = CharOrdUp(i) + 10;
- y_append = TRUE;
+ if(p_regappend)
+ y_append = TRUE;
}
else if (regname == '-')
i = DELETION_REGISTER;
diff -r 4cb1f10316ca -r aedf9e836670 src/option.c
--- a/src/option.c Thu Oct 11 04:44:33 2012 +0200
+++ b/src/option.c Tue Oct 16 01:28:47 2012 -0700
## -2068,6 +2068,9 ## static struct vimoption
(char_u *)NULL, PV_NONE,
#endif
{(char_u *)2000L, (char_u *)0L} SCRIPTID_INIT},
+ {"registerappend", NULL, P_BOOL,
+ (char_u *)&p_regappend, PV_NONE,
+ {(char_u *)TRUE, (char_u *)TRUE} SCRIPTID_INIT},
{"relativenumber", "rnu", P_BOOL|P_VI_DEF|P_RWIN,
(char_u *)VAR_WIN, PV_RNU,
{(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
diff -r 4cb1f10316ca -r aedf9e836670 src/option.h
--- a/src/option.h Thu Oct 11 04:44:33 2012 +0200
+++ b/src/option.h Tue Oct 16 01:28:47 2012 -0700
## -495,6 +495,7 ## EXTERN char_u *p_popt; /* 'printoptions'
EXTERN char_u *p_header; /* 'printheader' */
#endif
EXTERN int p_prompt; /* 'prompt' */
+EXTERN int p_regappend; /* 'registerappend' */
#ifdef FEAT_GUI
EXTERN char_u *p_guifont; /* 'guifont' */
# ifdef FEAT_XFONTSET

How do I get an equivalent of /dev/one in Linux

You can use
dd if=/dev/zero of=file count=1024 bs=1024
to zero fill a file.
Instead of that I want to one fill a file. How do I do that?
There is no /dev/one file, so how can I simulate that effect via on bash shell?
tr '\0' '\377' < /dev/zero | dd bs=64K of=/dev/sdx
This should be much faster. Choose your blocksizes (or add counts) like you need at. Writing ones to a SSD-Disk till full with a blocksize of 99M gave me 350M/s write performance.
Try this:
dd if=<(yes $'\01' | tr -d "\n") of=file count=1024 bs=1024
Substitute $'\377' or $'\xFF' if you want all the bits to be ones.
MacOS tr may complain about "Illegal byte sequence". Setting LC_CTYPE=C will prevent that. This version can also be used in Linux:
dd if=<(yes $'\01' | LC_CTYPE=C tr -d "\n") of=file count=1024 bs=1024
Well, you could do this:
dd if=/dev/zero count=1024 bs=1024 |
tr '\000' '\001' > file
pv /dev/zero |tr \\000 \\377 >targetfile
...where \377 is the octal representation of 255 (a byte with all bits set to one). Why tr only works with octal numbers, I don't know -- but be careful not to subconsciously translate this to 3FF.
The syntax for using tr is error prone. I recommend verifying that it is making the desired translation...
cat /dev/zero |tr \\000 \\377 |hexdump -C
Note: pv is a nice utility that replaces cat and adds a progress/rate display.
I created a device driver in my github. Installing it creates a file /dev/one that is writing only bits set to 1.
The c file called one.c (the only interesting part is in device_file_read):
// File Driver to create a devince /dev/one like the /dev/zero
#include <linux/init.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/uaccess.h>
MODULE_LICENSE("GPL");
static int device_file_major_number = 0;
static const char device_name[] = "one";
static ssize_t device_file_read(
struct file *file_ptr,
char __user *user_buffer,
size_t count,
loff_t *position) {
printk( KERN_NOTICE "One: Device file is read at offset = %i, read bytes count = %u\n" , (int)*position , (unsigned int)count );
// Allocate Kernel buffer
char* ptr = (char*) vmalloc(count);
// Fill it with one, byte per byte
// -- Note that byte is the smallest accesible data unit
memset(ptr, 0xFF, count);
char res = copy_to_user(user_buffer, ptr, count);
if (res != 0){ return -EFAULT; }
// Return number of byte read
return count;
}
static struct file_operations simple_driver_fops = {
.owner = THIS_MODULE,
.read = device_file_read,
};
int register_device(void) {
int res = 0;
printk( KERN_NOTICE "One: register_device() is called.\n" );
res = register_chrdev( 0, device_name, &simple_driver_fops );
if( res < 0 ) {
printk( KERN_WARNING "One: can\'t register character device with error code = %i\n", res );
return res;
}
device_file_major_number = res;
printk( KERN_NOTICE "One: registered character device with major number = %i and minor numbers 0...255\n", device_file_major_number );
return 0;
}
void unregister_device(void) {
printk( KERN_NOTICE "One: unregister_device() is called\n" );
if(device_file_major_number != 0) {
unregister_chrdev(device_file_major_number, device_name);
}
}
static int my_init(void) {
register_device();
return 0;
}
static void my_exit(void) {
unregister_device();
return;
}
// Declare register and unregister command
module_init(my_init);
module_exit(my_exit);
The Makefile
TARGET_MODULE:=one
BUILDSYSTEM_DIR:=/lib/modules/$(shell uname -r)/build
PWD:=$(shell pwd)
obj-m := $(TARGET_MODULE).o
# See: https://stackoverflow.com/questions/15910064/how-to-compile-a-linux-kernel-module-using-std-gnu99
ccflags-y := -std=gnu99 -Wno-declaration-after-statement
build:
# run kernel build system to make module
$(MAKE) -C $(BUILDSYSTEM_DIR) M=$(PWD) modules
clean:
# run kernel build system to cleanup in current directory
$(MAKE) -C $(BUILDSYSTEM_DIR) M=$(PWD) clean
rm -f MOK.priv MOK*.der
key:
echo "Creating key"
openssl req -new -x509 -newkey rsa:2048 -days 36500 -keyout MOK.priv -outform DER -out MOK.der -nodes -subj "/CN=TinmarinoUnsafe/"
#
echo "\e[31;1mPlease enter a password you will be asked for on reboot:\e[0m"
mokutil --import MOK.der
echo "\e[31;1mNow you must: 1/ reboot, 2/ Select Unroll MOK, 3/ Enter password you previously gave\e[0m"
sign:
cp one.ko one.ko.bck
/usr/src/linux-headers-$(shell uname -r)/scripts/sign-file sha256 MOK.priv MOK.der one.ko
load:
insmod ./$(TARGET_MODULE).ko
unload:
rmmod ./$(TARGET_MODULE).ko
create:
mknod /dev/one c $(shell cat /proc/devices | grep one$ | cut -d ' ' -f1) 0
delete:
rm /dev/one
test:
[ "$(shell xxd -p -l 10 /dev/one)" = "ffffffffffffffffffff" ] \
&& echo "\e[32mSUCCESS\e[0m" \
|| echo "\e[31mFAILED\e[0m"
The instalation is long (3min) due to the driver signature enforcement. Froget this part if you disabled it in your UEFI.
git clone https://github.com/tinmarino/dev_one.git DevOne && cd DevOne # Download
make build # Compile
make key # Generate key for signing
sudo make sign # Sign driver module to permit MOK enforcement (security)
sudo reboot now # Reboot and enable Mok
A blue screen (MOK manager) will appear
Choose "Enroll MOK"
Choose "Continue"
Choose "Yes" (when asked "Enroll the key")
Enter the password you gave at make sign
Choose "Reboot" (again)
sudo make load # Load
sudo make device # Create /dev/one
make test # Test if all is ok
You can simulate a /dev/one without a special device, with a FIFO + yes:
mkfifo ddfifo
dd if=ddfifo of=<file> iflag=fullblock count=1024 bs=1024 status=progress & yes "" | tr '\n' '\1' > ddfifo
tee may be used to double the throughput:
mkfifo ddfifo
dd if=ddfifo of=<file> iflag=fullblock count=1024 bs=1024 status=progress & yes "" | tr '\n' '\1' | tee ddfifo > ddfifo
If you'd like bytes with all bits set to one, swap '\1' for '\377'.

Resources