Re: [DNG] How to stop udev from re-ordering devices

2016-06-23 Thread Simon Hobson
Rainer Weikusat  wrote:

> Reportedly, Linux hotplug already had the same problem.

OK, that's what I'd have been seeing in the past then.

> During initialization, the kernel walks through the bus or busses it
> finds in order to locate all devices and enables them by calling the
> responsible driver init routines with information about the physical
> devices which were found. This means the names will be stable if all
> needed drivers are compiled into the kernel (in absence of deliberate
> sabotage by the drivers themselves).
> 
> If there's no compiled-in driver for some device, a so-called hotplug
> event is generated

Right. That explains a lot.
So if the driver is built in then devices will be stable and determinate, if 
not then they won't. Which I guess means that a custom kernel with all drivers 
needed compiled in will have stable devices, but a general purpose one with 
loads of modules won't ? And as the vast majority of systems run generic 
modular kernels ...

And udev comes along with a mechanism to remember device-name mappings and 
"unscramble" things in a determinate way. And then udev gets borged by the 
freedesktop lot and we're waiting for vdev to be ready to replace it ?

> I've designed and implemented a complete hotplugging system for a
> Linux-based UTM appliance which took care of preserving this order in
> the past. But apparently, this idea doesn't have many fans.

My suspicion is that your use case isn't all that common - well it's common 
enough, just a small fraction of systems. And people making "appliances" will 
have more control over what goes into the system - eg do their own kernels with 
all drivers included, and run on a limited range of hardware. Those will be far 
outweighed by the general purpose systems with random hardware.

___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] Studying C as told. (For help)

2016-06-23 Thread Simon Walter

On 06/23/2016 11:26 AM, Adam Borowski wrote:
...

[1]. Actually, the English alphabet had more letters: þ, ð, ƿ[2] and ȝ, but
they got dropped as early printing presses imported from Germany lacked
these characters.  Before the technology was copied and fonts could be
manufactured domestically, the English suddenly had orders of magnitude more
reading material lacking their letters than older handwritten works.
(This is a gross simplification.)  So let's have this in mind when you skip
support for non-modern-English characters.


Funny how this is now the other way around with ß.

___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


[DNG] [OT] Re: Studying C as told. (For help)

2016-06-23 Thread KatolaZ
On Thu, Jun 23, 2016 at 02:42:13AM +0200, Irrwahn wrote:

[cut]

> 
> Actually, I think it in fact /still/ invokes undefined behavior, 
> as it is only valid to cast from a pointer-to-T to a pointer to a 
> compatible type (and back), or from a pointer-to-T to void pointer
> (or a pointer-to-unsigned-char[1]) and back to a type compatible 
> with T.
> 
> So, your casts to char* are at least fishy (since we cannot tell 
> if char is signed or unsigned, as that is implementation defined), 
> and the cast to float* is downright wrong. You only avoided the 
> compiler barfing[2] at you by hiding the error behind explicit 
> type casts. If you remove the bogus casts, even gcc coughs up 
> appropriate diagnostics[2] about the incompatibility of the 
> pointer types involved.
>

Thanks for your explanation :) Actually, my point was simply that the
language allows you to do whatever you want with allocated space that
you think is "an array of T". If I remove the explicit casts, the
compiler gives a few warning (incompatible pointer type) but still
compiles the code into an executable.

I am not saying that this is the way to proceed. Such warnings have to
be always resolved in any serious piece of code. But the language
allows you to do that, simply because there is no strong typing
whatsoever of any kind of either statically or dynamically allocated
memory. Consider the snippet (no malloc here...):

===
#include 
int main(){

int a = 17;
char *b;

b = (char*)&a;
b[2]=21;
printf("a: %d\n", a);
b[2]=0;
printf("a: %d\n", a);
}
===

whose execution gives:

katolaz@akela:~/test$ ./pointer_wierd
a: 1376273
a: 17
katolaz@akela:~/test$ 

What is the type of the variable a?  What is an array of "char"? Even
worse, this code will run smoothly on some architectures and give
segfault on other ones. And is still perfectly *legal* ANSI C :) 

HND

KatolaZ

-- 
[ ~.,_  Enzo Nicosia aka KatolaZ - GLUGCT -- Freaknet Medialab  ]  
[ "+.  katolaz [at] freaknet.org --- katolaz [at] yahoo.it  ]
[   @)   http://kalos.mine.nu ---  Devuan GNU + Linux User  ]
[ @@)  http://maths.qmul.ac.uk/~vnicosia --  GPG: 0B5F062F  ] 
[ (@@@)  Twitter: @KatolaZ - skype: katolaz -- github: KatolaZ  ]
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] tool to check for updates without root??

2016-06-23 Thread Didier Kryn

Le 22/06/2016 14:20, Irrwahn a écrit :

On Wed, 22 Jun 2016 13:46:43 +0200, Emninger wrote:

Am Wed, 22 Jun 2016 08:35:48 +
schrieb KatolaZ :

The easiest way is to have a cron script that runs once a day, with
root provileges, and calls "apt-get update".

[...]

Thanks for your pointer. So, essentially, there is no way to play
around the need of root.

Actually, I am much more in favor of the brilliant suggestion
made by Giovanni Rapagnani in another reply:

  | another way of periodically updating the lists of packages is
  | to add this line in a file under /etc/apt/apt.conf.d/ e.g.
  | /etc/apt/apt.conf.d/10periodic:
  |
  | APT::Periodic::Update-Package-Lists "1";

I already had the funny feeling I was missing some already
existing mechanism to solve the problem! (Emninger and I
already discussed this topic off-list.)



If the question was only to be informed, I would use apt-watch. If 
it is to upgrade my system automatically, I would be afraid it brings in 
some undesired systemd/gnome/*kit dependency; therefore it isn't 
something I want.


Didier

___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] [OT] Re: Studying C as told. (For help)

2016-06-23 Thread Irrwahn
On Thu, 23 Jun 2016 08:23:01 +0100, Katolaz wrote:
[...]
> Thanks for your explanation :) Actually, my point was simply that the
> language allows you to do whatever you want with allocated space that
> you think is "an array of T". If I remove the explicit casts, the
> compiler gives a few warning (incompatible pointer type) but still
> compiles the code into an executable.

Unfortunately it does, I might add. :->

> I am not saying that this is the way to proceed. Such warnings have to
> be always resolved in any serious piece of code. But the language
> allows you to do that, simply because there is no strong typing
> whatsoever of any kind of either statically or dynamically allocated
> memory. Consider the snippet (no malloc here...):
> 
> ===
> #include 
> int main(){
> 
> int a = 17;
> char *b;
> 
> b = (char*)&a;
> b[2]=21;
> printf("a: %d\n", a);
> b[2]=0;
> printf("a: %d\n", a);
> }
> ===

For the sake of argument I will pretend you actually meant 
to write "unsigned char" above, so we do not step into the 
realm of dreaded undefined behavior right from the start.  ;-)

> whose execution gives:
> 
> katolaz@akela:~/test$ ./pointer_wierd
> a: 1376273
> a: 17
> katolaz@akela:~/test$ 
> 
> What is the type of the variable a?  

That is obvious: int. 

A variable is an object (i.e. a contiguous region of memory) 
that contains a value that is to be interpreted according to 
the rules pertaining to the declared type of the variable, and 
which has a designator (the name of the variable) attached to 
it. (Those are my own words, not actual "Standardese".)

> What is an array of "char"? Even
> worse, this code will run smoothly on some architectures and give
> segfault on other ones. 

That is already a very strong indication that it probably 
is severely broken.

> And is still perfectly *legal* ANSI C :) 

Alas, it is not. By making assumptions on the width of an int 
(at least 3 bytes in this case) you are already deep in 
implementation defined land, IOW your code is not portable. 
And then there's the issue of possible trap representations[1] 
in an int, which makes above code (at least potentially) 
invoke undefined behavior: 

| Certain object representations need not represent a value of 
| the object type. If the stored value of an object has such a 
| representation and is read by an lvalue expression that does 
| not have character type, the behavior is undefined. 
(C99 6.2.6.1p5, same in C11)

IIRC it can be derived from the standard that an unsigned int 
can neither contain padding bits, nor can it have any trap 
representations. Furthermore, we know an unsigned int has to 
be at least 2 bytes in width. Thus we can indeed convert your 
example into one that *actually* *is* ISO C compliant:

#include 
int main(void) {
unsigned int a = 17;
unsigned char *b;
b = (unsigned char *)&a;
b[1]=21;
printf("a: %u\n", a);
b[1]=0;
printf("a: %u\n", a);
}

But that's (almost?) as far as you can get with accessing a 
typed[2] object after you tampered with its value by means of 
altering (part of) its binary representation through an 
unsigned char pointer. (Unless you know about architecture 
and implementation details, but that's neither here nor there, 
from the standard's POV.)

Caveat: Since we still know nothing about the endianness of the 
machine it's run on, the output of the program is still 
implementation defined. Tweaking it so it does produce the same 
output regardless of endianness is left as an exercise.  8^)

Lesson:  Although C has a lot of "loopholes" in its typing system 
(despite being a statically typed language) that does not imply 
you can get away with everything. The wording in the standard 
puts a lot of constraints on which forms of type conversion, 
type coercing (a.k.a. casts) and bit fiddling are well defined. 
Due to that C is actually surprisingly strongly typed, even if 
that trait is not always instantaneously obvious. 
(Sub-lesson: The statement "It compiles!" is worthless as it is.)


[1] I concede that this is merely theoretical, as it does 
apply mostly to ancient or exotic architectures, AFAIK. 
Nevertheless it is to be respected when discussing 
"perfectly legal ANSI C".  

[2] Other than character type.

HTH, Regards
Urban

___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] tool to check for updates without root??

2016-06-23 Thread Irrwahn
On Thu, 23 Jun 2016 10:46:24 +0200, Didier Kryn wrote:
> Le 22/06/2016 14:20, Irrwahn a écrit :
>> Actually, I am much more in favor of the brilliant suggestion
>> made by Giovanni Rapagnani in another reply:
>>
>>   | another way of periodically updating the lists of packages is
>>   | to add this line in a file under /etc/apt/apt.conf.d/ e.g.
>>   | /etc/apt/apt.conf.d/10periodic:
>>   |
>>   | APT::Periodic::Update-Package-Lists "1";
[...]
> 
>  If the question was only to be informed, I would use apt-watch. If 
> it is to upgrade my system automatically, I would be afraid it brings in 
> some undesired systemd/gnome/*kit dependency; therefore it isn't 
> something I want.

Above suggestion only periodically performs the equivalent of 
"apt-get update", which does no harm.  To let it automagically 
run any pending upgrades (something I am not fond of either)  
one would have to add these two lines:

  APT::Periodic::Download-Upgradeable-Packages "1";
  APT::Periodic::Unattended-Upgrade "1";

I'm under the impression that the apt-watch backend basically 
serves as a proxy for "apt-get ". And the apt-watch 
frontend is a Gnome applet. (Yuck!) And it's only available in 
wheezy and in unstable. (D'oh!)

Regards
Urban
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] How to stop udev from re-ordering devices

2016-06-23 Thread Didier Kryn

Le 22/06/2016 16:29, Rainer Weikusat a écrit :

If you'll neither believe me nor the code wrt causes these 'random
device names', may I try some kind of authority?

7.4.3.7. Device naming order changes randomly after rebooting

This is due to the fact that Udev, by design, handles uevents
and loads modules in parallel, and thus in an unpredictable
order.


According to your own words, the disorder comes from Udev, not the 
kernel :-)


AFAIR, amongst the infos available to Udev, there is a name 
provided by the kernel (ethX, for Ethernet), which Udev config may 
decide to keep or to change.


Didier

___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] How to stop udev from re-ordering devices

2016-06-23 Thread Didier Kryn

Le 23/06/2016 09:05, Simon Hobson a écrit :

Rainer Weikusat  wrote:


>Reportedly, Linux hotplug already had the same problem.

OK, that's what I'd have been seeing in the past then.


>During initialization, the kernel walks through the bus or busses it
>finds in order to locate all devices and enables them by calling the
>responsible driver init routines with information about the physical
>devices which were found. This means the names will be stable if all
>needed drivers are compiled into the kernel (in absence of deliberate
>sabotage by the drivers themselves).
>
>If there's no compiled-in driver for some device, a so-called hotplug
>event is generated

Right. That explains a lot.
So if the driver is built in then devices will be stable and determinate, if 
not then they won't. Which I guess means that a custom kernel with all drivers 
needed compiled in will have stable devices, but a general purpose one with 
loads of modules won't ? And as the vast majority of systems run generic 
modular kernels ...


Hence the solution is simple: for random machine, edit udev rules 
to assign names according to the MAC address; for mass-production 
devices use a custom kernel with all drivers statically linked in the 
kernel. For disks, use UUID.


Didier

___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] Studying C as told. (For help)

2016-06-23 Thread Edward Bartolo
Hi,

At this point of my C studies, I did a test to get feedback of my C
language learning progress. I found an online C test which consisted
of 20 questions and a time duration of 30 minutes.

Link: http://www.indiabix.com/online-test/c-programming-test/random

The test included concepts and syntax constructs that I haven´t yet
covered in "The C programming language" (Kernighan & Ritchie). My
score was 12/20 and oddly enough I scored the two most difficult
questions correct while making mistakes in trivialities. :(

I will give the test a second try to make sure my learning progress is real.

Edward
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] A proposal for usability ;)

2016-06-23 Thread vmlinux
Thanks for this! There's is no bane to the existence of the touchpad greater 
than that of my thumbs accidentally bouncing off it and moving the cursor to 
places unknown.


::Here's a shellscript, called touchtoggle, that I hooked to
::hotkey Ctrl+Shift+j, that turns the mousepad alternately on or off
::every time the hotkey is pressed.

-- 
Sent from a Mobile device.
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] tool to check for updates without root??

2016-06-23 Thread Adam Borowski
On Thu, Jun 23, 2016 at 11:08:48AM +0200, Irrwahn wrote:
> On Thu, 23 Jun 2016 10:46:24 +0200, Didier Kryn wrote:
> >  If the question was only to be informed, I would use apt-watch. If 
> > it is to upgrade my system automatically, I would be afraid it brings in 
> > some undesired systemd/gnome/*kit dependency; therefore it isn't 
> > something I want.
>
> I'm under the impression that the apt-watch backend basically 
> serves as a proxy for "apt-get ". And the apt-watch 
> frontend is a Gnome applet. (Yuck!) And it's only available in 
> wheezy and in unstable. (D'oh!)

It's not in unstable: https://bugs.debian.org/772785
I guess it could be reintroduced for mate or xfce, but at least I am not
volunteering to do the work.


Meow!
-- 
An imaginary friend squared is a real enemy.
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] tool to check for updates without root??

2016-06-23 Thread Didier Kryn

Le 23/06/2016 13:53, Adam Borowski a écrit :

On Thu, Jun 23, 2016 at 11:08:48AM +0200, Irrwahn wrote:

On Thu, 23 Jun 2016 10:46:24 +0200, Didier Kryn wrote:

  If the question was only to be informed, I would use apt-watch. If
it is to upgrade my system automatically, I would be afraid it brings in
some undesired systemd/gnome/*kit dependency; therefore it isn't
something I want.

I'm under the impression that the apt-watch backend basically
serves as a proxy for "apt-get ". And the apt-watch
frontend is a Gnome applet. (Yuck!) And it's only available in
wheezy and in unstable. (D'oh!)

It's not in unstable: https://bugs.debian.org/772785
I guess it could be reintroduced for mate or xfce, but at least I am not
volunteering to do the work.

I thought of it because I found it sometimes installed by default 
(and removed it). Sorry for the noise.Didier


___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] Studying C as told. (For help)

2016-06-23 Thread Edward Bartolo
Hi,

I am doing exercise 1-21 Pg 48 The C programming language" (Kernighan
& Ritchie). Since I am finding difficulty inspecting tabs in XFCE4.10
terminal, I would like someone to inspect this program which replaces
repeating spaces with tabs when there are sufficient consecutive
spaces. I am not asking for a long reply. A short reply giving me
feedback as to whether the code is good or not, is enough.

exercise 1-21
---

#include 

/* insert tabs instead of repeated spaces */

int tab_width = 3;

void replace_spaces_with_tabs(char c) {
  int count = 0;
  if (c == ' ') {
++count;

while((c = getchar()) == ' ') {
  ++count;
  if (count == tab_width) {
putchar('\t');
count = 0;
  }

  if (count < tab_width && count > 0)
while(putchar(' ') && --count);
}
  } else putchar(c);
}

int main() {
  char c;
  while((c = getchar()) != EOF) {
replace_spaces_with_tabs(c);
  } else putchar(c);

  return 0;
}

--


Edward

On 23/06/2016, Edward Bartolo  wrote:
> Hi,
>
> At this point of my C studies, I did a test to get feedback of my C
> language learning progress. I found an online C test which consisted
> of 20 questions and a time duration of 30 minutes.
>
> Link: http://www.indiabix.com/online-test/c-programming-test/random
>
> The test included concepts and syntax constructs that I haven´t yet
> covered in "The C programming language" (Kernighan & Ritchie). My
> score was 12/20 and oddly enough I scored the two most difficult
> questions correct while making mistakes in trivialities. :(
>
> I will give the test a second try to make sure my learning progress is
> real.
>
> Edward
>
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] Studying C as told. (For help)

2016-06-23 Thread Edward Bartolo
Ooops, this is the corrected program for exercise1-21

#include 

/* insert tabs instead of repeated spaces
*  I am assuming a tab is equivalent to 3 spaces and forgetting tabs
that are defined at specific columns */

int tab_width = 3;

void replace_spaces_with_tabs(char c) {
  int count = 0;
  if (c == ' ') {
++count;

while((c = getchar()) == ' ') {
  ++count;
  if (count == tab_width) {
putchar('\t');
count = 0;
  } else continue;

  if (count < tab_width && count > 0)
while(putchar(' ') && --count);
}
  }

  putchar(c);
}

int main() {
  char c;
  while((c = getchar()) != EOF) {
replace_spaces_with_tabs(c);
  }

  return 0;
}

On 23/06/2016, Edward Bartolo  wrote:
> Hi,
>
> I am doing exercise 1-21 Pg 48 The C programming language" (Kernighan
> & Ritchie). Since I am finding difficulty inspecting tabs in XFCE4.10
> terminal, I would like someone to inspect this program which replaces
> repeating spaces with tabs when there are sufficient consecutive
> spaces. I am not asking for a long reply. A short reply giving me
> feedback as to whether the code is good or not, is enough.
>
> exercise 1-21
> ---
>
> #include 
>
> /* insert tabs instead of repeated spaces */
>
> int tab_width = 3;
>
> void replace_spaces_with_tabs(char c) {
>   int count = 0;
>   if (c == ' ') {
> ++count;
>
> while((c = getchar()) == ' ') {
>   ++count;
>   if (count == tab_width) {
> putchar('\t');
> count = 0;
>   }
>
>   if (count < tab_width && count > 0)
> while(putchar(' ') && --count);
> }
>   } else putchar(c);
> }
>
> int main() {
>   char c;
>   while((c = getchar()) != EOF) {
> replace_spaces_with_tabs(c);
>   } else putchar(c);
>
>   return 0;
> }
>
> --
>
>
> Edward
>
> On 23/06/2016, Edward Bartolo  wrote:
>> Hi,
>>
>> At this point of my C studies, I did a test to get feedback of my C
>> language learning progress. I found an online C test which consisted
>> of 20 questions and a time duration of 30 minutes.
>>
>> Link: http://www.indiabix.com/online-test/c-programming-test/random
>>
>> The test included concepts and syntax constructs that I haven´t yet
>> covered in "The C programming language" (Kernighan & Ritchie). My
>> score was 12/20 and oddly enough I scored the two most difficult
>> questions correct while making mistakes in trivialities. :(
>>
>> I will give the test a second try to make sure my learning progress is
>> real.
>>
>> Edward
>>
>
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] Studying C as told. (For help)

2016-06-23 Thread KatolaZ
On Thu, Jun 23, 2016 at 02:17:37PM +0200, Edward Bartolo wrote:
> Hi,
> 
> I am doing exercise 1-21 Pg 48 The C programming language" (Kernighan
> & Ritchie). Since I am finding difficulty inspecting tabs in XFCE4.10
> terminal, I would like someone to inspect this program which replaces
> repeating spaces with tabs when there are sufficient consecutive
> spaces. I am not asking for a long reply. A short reply giving me
> feedback as to whether the code is good or not, is enough.
> 

"hexdump" will help you understand if you have tabs in the right
places. Tab is ASCII character 9. 

HND

KatolaZ

-- 
[ ~.,_  Enzo Nicosia aka KatolaZ - GLUGCT -- Freaknet Medialab  ]  
[ "+.  katolaz [at] freaknet.org --- katolaz [at] yahoo.it  ]
[   @)   http://kalos.mine.nu ---  Devuan GNU + Linux User  ]
[ @@)  http://maths.qmul.ac.uk/~vnicosia --  GPG: 0B5F062F  ] 
[ (@@@)  Twitter: @KatolaZ - skype: katolaz -- github: KatolaZ  ]
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] tool to check for updates without root??

2016-06-23 Thread Irrwahn
On Thu, 23 Jun 2016 13:53:49 +0200, Adam Borowski wrote:
> On Thu, Jun 23, 2016 at 11:08:48AM +0200, Irrwahn wrote:
>> On Thu, 23 Jun 2016 10:46:24 +0200, Didier Kryn wrote:
>>>  If the question was only to be informed, I would use apt-watch. 
>> And it's only available in 
>> wheezy and in unstable. (D'oh!)
> 
> It's not in unstable: https://bugs.debian.org/772785

Oops, you are right! The page I looked at [1] listed it 
only for the arm64 architecture, oddly enough. 

> I guess it could be reintroduced for mate or xfce, but at least I am not
> volunteering to do the work.

Since even the Gnome folks seem to have no use for it,  
it shall rest in peace.

[1] 
https://packages.debian.org/search?keywords=apt-watch&searchon=names&suite=sid§ion=all

Regards
Urban
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] How to stop udev from re-ordering devices

2016-06-23 Thread Rainer Weikusat
Simon Hobson  writes:
> Rainer Weikusat  wrote:
>
>> Reportedly, Linux hotplug already had the same problem.
>
> OK, that's what I'd have been seeing in the past then.
>
>> During initialization, the kernel walks through the bus or busses it
>> finds in order to locate all devices and enables them by calling the
>> responsible driver init routines with information about the physical
>> devices which were found. This means the names will be stable if all
>> needed drivers are compiled into the kernel (in absence of deliberate
>> sabotage by the drivers themselves).
>> 
>> If there's no compiled-in driver for some device, a so-called hotplug
>> event is generated

| What happens then is entirely the
| responsibility of the userspace software processing these events.

> Right. That explains a lot.  So if the driver is built in then devices
> will be stable and determinate, if not then they won't.

They won't in certain cases (if there are devices sharing a namespace,
eg ethX or sdX, but using different drivers) unless the abovementioned
userspace software takes care of this.

Assuming hotplug already had this problem (I never encountered it), it
was probably completely ignored on the grounds that it only happens
'rarely'. One of the reasons udev came into being was to support abitrary
'naming policies' via udev rules.
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


[DNG] How to get rfcomm working again?

2016-06-23 Thread dr . klepp
Hi all!

Somehow bluetooth stopped working on my Devuan jessie machines. In february I 
set up rfcomm connection from my embedded system via rfcomm to my desktop. 
Pairing went smoothly, I set up the rfcomm connetion with 

# rfcomm bind 0 00:00:62:81:B4:24 1
$ cat /dev/rfcomm0

and out came the data. Now 4 months and some updates later the very same 
hardware is not able to keep/craeate a rfcomm connection.

The used USB BT dongles are:
0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

# uname -a
Linux t61 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-2 (2016-04-08) x86_64 
GNU/Linux

[bluetooth]# paired-devices
Device 00:00:62:81:B4:24 MS_MD-10
[bluetooth]# show
Controller 00:1B:DC:06:32:2B
Name: thinkpad
Alias: thinkpad
Class: 0x00010c
Powered: yes
Discoverable: no
Pairable: yes
UUID: PnP Information   (1200--1000-8000-00805f9b34fb)
UUID: Generic Access Profile(1800--1000-8000-00805f9b34fb)
UUID: Generic Attribute Profile (1801--1000-8000-00805f9b34fb)
UUID: A/V Remote Control(110e--1000-8000-00805f9b34fb)
UUID: A/V Remote Control Target (110c--1000-8000-00805f9b34fb)
Modalias: usb:v1D6Bp0246d0517
Discovering: no
[bluetooth]# info 00:00:62:81:B4:24
Device 00:00:62:81:B4:24
Name: MS_MD-10
Alias: MS_MD-10
Paired: yes
Trusted: yes
Blocked: no
Connected: no
LegacyPairing: no
UUID: Serial Port   (1101--1000-8000-00805f9b34fb)
[bluetooth]# connect 00:00:62:81:B4:24
Attempting to connect to 00:00:62:81:B4:24
[CHG] Device 00:00:62:81:B4:24 Connected: yes
Failed to connect: org.bluez.Error.NotAvailable
[CHG] Device 00:00:62:81:B4:24 Connected: no



The moment the connection error appears, I get in /var/log/messages:

Jun 23 16:37:53 t61 kernel: [ 1465.300298] CPU: 1 PID: 7399 Comm: kworker/u5:1 
Tainted: GW 3.16.0-4-amd64 #1 Debian 3.16.7-ckt25-2
Jun 23 16:37:53 t61 kernel: [ 1465.300303] Hardware name: LENOVO 
88986DG/88986DG, BIOS 7LETC9WW (2.29 ) 03/18/2011
Jun 23 16:37:53 t61 kernel: [ 1465.300321] Workqueue: hci0 hci_conn_timeout 
[bluetooth]
Jun 23 16:37:53 t61 kernel: [ 1465.300327]   8150e835 
 0009
Jun 23 16:37:53 t61 kernel: [ 1465.300335]  810677f7 8801363018b8 
 880136301800
Jun 23 16:37:53 t61 kernel: [ 1465.300342]  880136ec5100  
a05b7c7a 8800ba217b80
Jun 23 16:37:53 t61 kernel: [ 1465.300349] Call Trace:
Jun 23 16:37:53 t61 kernel: [ 1465.300364]  [] ? 
dump_stack+0x5d/0x78
Jun 23 16:37:53 t61 kernel: [ 1465.300374]  [] ? 
warn_slowpath_common+0x77/0x90
Jun 23 16:37:53 t61 kernel: [ 1465.300393]  [] ? 
hci_conn_timeout+0x4a/0x280 [bluetooth]
Jun 23 16:37:53 t61 kernel: [ 1465.300402]  [] ? 
process_one_work+0x172/0x420
Jun 23 16:37:53 t61 kernel: [ 1465.300409]  [] ? 
worker_thread+0x113/0x4f0
Jun 23 16:37:53 t61 kernel: [ 1465.300415]  [] ? 
rescuer_thread+0x2d0/0x2d0
Jun 23 16:37:53 t61 kernel: [ 1465.300423]  [] ? 
kthread+0xbd/0xe0
Jun 23 16:37:53 t61 kernel: [ 1465.300431]  [] ? 
kthread_create_on_node+0x180/0x180
Jun 23 16:37:53 t61 kernel: [ 1465.300439]  [] ? 
ret_from_fork+0x58/0x90
Jun 23 16:37:53 t61 kernel: [ 1465.300447]  [] ? 
kthread_create_on_node+0x180/0x180
Jun 23 16:37:53 t61 kernel: [ 1465.300452] ---[ end trace 206e8915664ac1e5 ]---

Does anybody know what to do about this?

Nik


-- 
Please do not email me anything that you are not comfortable also sharing with 
the NSA.
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] Studying C as told. (For help)

2016-06-23 Thread Edward Bartolo
Hi,

I am using nano. I paste the program's output in nano and use the
cursor keys to investigate the position of tabs.

This is the final debugged version of the tab insertion program. It
assumes tabs are 8 characters apart with the first column having no
tab.


#include 

/* insert tabs instead of repeated spaces */

int tab_width = 8;
int col = 0;

int is_tab_stop(int col) {
  return (col % tab_width == 0 && col > 1);
}

void replace_spaces_with_tabs(char c) {
  int count = 0;
  if (c == ' ') {
++count;

while((c = getchar()) == ' ') {
  ++col;
  ++count;
  if (is_tab_stop(col)) {
putchar('\t');
count = 0;
  }
}
  }

  if (count > 0)
while(putchar(' ') && --count);

  putchar(c);
}

int main() {
  char c;

  while((c = getchar()) != EOF) {
++col;
replace_spaces_with_tabs(c);
  }

  return 0;
}

On 23/06/2016, KatolaZ  wrote:
> On Thu, Jun 23, 2016 at 02:17:37PM +0200, Edward Bartolo wrote:
>> Hi,
>>
>> I am doing exercise 1-21 Pg 48 The C programming language" (Kernighan
>> & Ritchie). Since I am finding difficulty inspecting tabs in XFCE4.10
>> terminal, I would like someone to inspect this program which replaces
>> repeating spaces with tabs when there are sufficient consecutive
>> spaces. I am not asking for a long reply. A short reply giving me
>> feedback as to whether the code is good or not, is enough.
>>
>
> "hexdump" will help you understand if you have tabs in the right
> places. Tab is ASCII character 9.
>
> HND
>
> KatolaZ
>
> --
> [ ~.,_  Enzo Nicosia aka KatolaZ - GLUGCT -- Freaknet Medialab  ]
> [ "+.  katolaz [at] freaknet.org --- katolaz [at] yahoo.it  ]
> [   @)   http://kalos.mine.nu ---  Devuan GNU + Linux User  ]
> [ @@)  http://maths.qmul.ac.uk/~vnicosia --  GPG: 0B5F062F  ]
> [ (@@@)  Twitter: @KatolaZ - skype: katolaz -- github: KatolaZ  ]
> ___
> Dng mailing list
> Dng@lists.dyne.org
> https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
>
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] How to stop udev from re-ordering devices

2016-06-23 Thread Rainer Weikusat
Didier Kryn  writes:
> Le 23/06/2016 09:05, Simon Hobson a écrit :
>> Rainer Weikusat  wrote:
>>
>>> >Reportedly, Linux hotplug already had the same problem.
>> OK, that's what I'd have been seeing in the past then.
>>
>>> >During initialization, the kernel walks through the bus or busses it
>>> >finds in order to locate all devices and enables them by calling the
>>> >responsible driver init routines with information about the physical
>>> >devices which were found. This means the names will be stable if all
>>> >needed drivers are compiled into the kernel (in absence of deliberate
>>> >sabotage by the drivers themselves).
>>> >
>>> >If there's no compiled-in driver for some device, a so-called hotplug
>>> >event is generated
>> Right. That explains a lot.
>> So if the driver is built in then devices will be stable and
>>> >determinate, if not then they won't. Which I guess means that a
>>> >custom kernel with all drivers needed compiled in will have stable
>>> >devices, but a general purpose one with loads of modules won't ?
>>> >And as the vast majority of systems run generic modular kernels ...
>
> Hence the solution is simple: for random machine, edit udev rules
> to assign names according to the MAC address; for mass-production
> devices use a custom kernel with all drivers statically linked in the
> kernel. For disks, use UUID.

That's you're preferred set of workarounds. 'Assigning names based on
MAC addresses' is problematic as a MAC address is a typically
programmable property of a NIC. Assigning names based on bus-location is
more universally useful because this means names stick to devices unless
the hardware configuration of a system changes. But the idea to encode
the current bus configuration in the device names is braindead and the
kernel already assigns names based on bus location.
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] Studying C as told. (For help)

2016-06-23 Thread Peter Olson
> On June 23, 2016 at 10:48 AM Edward Bartolo  wrote:
>   if (count > 0)
> while(putchar(' ') && --count);

I strongly recommend using the continue statement here:

  while(putchar(' ') && --count) continue;

The reason is that the semicolon by itself is almost unnoticeable and you can 
create a difficult to understand malfunction if you don't notice you forgot to 
type it.

Another habit I have is to avoid a statement like:

if (abc == 42)

and write it as

if (42 == abc)

instead.  The compiler will issue an error message if you type only one = in 
the latter form, whereas the first form will happily execute by setting abc to 
42 and always taking the true clause.

Peter Olson
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng