September, 2009

  • The Old New Thing

    Why doesn't Explorer have an interface for creating hard links?

    • 119 Comments

    Nick asks why Explorer doesn't have UI for creating hard links.

    Heck, while you're at it, why not ask "Why doesn't Explorer have a UI for hex-editing a file?"

    Remember, all features start out with minus 100 points. Explorer is not under any obligation to expose every last NTFS feature, and it's certainly not going to help to expose an NTFS feature that even technical people don't understand. Just look at all the people who ask questions like "How can I tell if a file name is a hard link instead of a normal file?" or online explanations of hard links which claim that "A hard link is only a reference to the original file, not a copy of the file. If the original file is deleted, the information will be lost." I mean, if even a techno-geek doesn't understand hard links, how is your average user supposed to have a chance?

    First, let's see how you would explain a hard link to an end user.

    When you create a hard link, you give the item an additional name. The file can be accessed by either its old name or its new name; they are equivalent. A file is not deleted until all its names are deleted.

    If you open a file by one name, make changes, and then save the file, the update is made to the file, and accessing the file by a second name will show the updated file, because the data for a file is separate from its name.

    Actually, that paragraph above is only true if the application which saves the file does so by writing directly to the name you used when you opened the file. If the application updates the file by creating a temporary file, then renaming the original to a backup name and renaming the temporary file, then updating a file by one name will sever its connection with other names for the file. The other names will continue to refer to the unmodified file; the name you used for the update will refer to the updated file. Different applications handle this situation differently; consult your application documentation for information on how it treats hard links.

    Note also that some backup programs have difficulty with hard links. Consult the documentation for your backup program for information on how it behaves when faced with hard links.

    If a file has multiple names, editing the file by using different names simultaneously may result in data corruption.

    If a file has multiple names, all the names must exist on the same drive.

    Most users clicked Cancel at about the time you said, "When you create a hard link..." You'll probably lose the rest of them while you are busy warning about the potential problems with hard links, and the brave few who managed to stick it out to the end will be completely confused and hit Cancel. (The ones who hit Cancel early on were the smart ones.)

    The problem with backup programs is particularly nasty. A backup program that is not hard-link-aware will miscalculate the necessary size of the backup volume, and when it attempts to restore the files, it will not restore the hard links.

    There was a Windows XP PowerToy for creating hard links, but the backup team recommended that it not be released because so many third party backup programs exploded when they stumbled across files that had multiple names in the file system.

  • The Old New Thing

    When people ask for security holes as features: Privileged execution

    • 69 Comments

    A customer wanted to know if there was a way to execute privileged instructions without having to write a driver.

    "I just need to execute a few instructions, and writing a driver would be overkill since it's only three instructions. Is there a way I can execute these privileged instructions without a driver?"

    The whole point of having a class of modules called drivers is to prevent somebody from doing exactly what you're asking for. Only drivers can execute privileged instructions; that's why they're called privileged instructions.

    "Yeah, but I just need three instructions. Do I have to write a whole driver just for those three instructions?"

    Even just one instruction can pwnz0r a machine. You have to be a driver in order to have that much power over the computer.

    "Maybe there's a driver somebody has already written that I can give the instructions to, and it'll execute them for me?"

    If somebody has written a driver which is designed to execute arbitrary instructions handed to it from user-mode, that person needs to be taken outside and beaten. It's one thing to have a bug that permits arbitrary code execution, but to have it as the purpose of your driver?

    Think of writing a driver as having access to the secure area of a nuclear power plant. People have to be granted the appropriate security clearance before they are allowed into enter the control room. If you want to get into the control room of the nuclear power plant, you'll have to apply for security clearance.

    "But that's so much work. I just need to go in and change a few settings on the control panel."

    Dude, that's why you're not allowed in, so you won't change those settings!

    Your options are either to get security clearance yourself, or convince somebody with security clearance to change the settings for you.

    "Well, do you know somebody who does have security clearance who will change any settings I tell him to?"

    Gosh, I sure hope not.

  • The Old New Thing

    Management-speak: Focus

    • 39 Comments

    Management likes to use the word focus. They like it so much, that anything important is called a focus.

    That's an interesting scenario, one which we hope to address, but it's not our main focus.
    We're focusing on three features for this release.

    But how can you focus on more than one thing? The first citation implies that there's more than one focus (a main focus, and maybe some secondary foci); the second citation makes explicit the mutiplicity of foci.

    But a lens doesn't focus on more than one thing. There is one focus, the point at which parallel rays from infinity converge.

    Then again, if a lens is defective, it can have more than one focal point. And there's a term for that phenomenon: Aberration.

  • The Old New Thing

    We've got your hotel surrounded (on one side) (and not even the entire side)

    • 35 Comments

    A local hotel advertises itself like so:

    Surrounding the hotel are popular Seattle attractions such as Pike Place Market, the Space Needle, Safeco Park, home of baseball's Seattle Mariners, and Qwest Field, home of football's Seattle Seahawks, all just a short drive away.

    Okay, first, it's Safeco Field, not Safeco Park. Mind you, I've misspelled Qwest Field in the past, so maybe I shouldn't complain.

    But let's look at those Seattle attractions which "surround" the hotel:

    They all lie in the same direction and subtend a total of twelve degrees of arc. This is a sense of the word "surround" I was previously unfamiliar with.

    Let's hope these marketing folks never end up working for the police department.

    "Before we continue, we need to surround the building."

    No problem, Chief, I've already got that.

    And then the bad guys sneak out the back door.

    I don't understand how they got away. We had the place surrounded!

  • The Old New Thing

    The ways people mess up IUnknown::QueryInterface, episode 2

    • 35 Comments

    Sadly, I get to add another entry to The ways people mess up IUnknown::QueryInterface:

    Blindly responding to everything.

    Some people are just too eager to please.

    HRESULT CSomething::QueryInterface(REFIID riid, void **ppvObj)
    {
      *ppvObj = this;
      this->AddRef();
      return S_OK;
    }
    

    No matter what the interface is, they say, "Sure, we do that!"

    Furthermore, no matter what you ask for, they always return the same interface. Even if it's not what you asked for.

    Exercise: Some people say that "these problems wouldn't be there if Microsoft Windows had enforced correct behavior to begin with." My exercise to you, commenter "foo", is to come up with a list of all bugs in IUnknown::QueryInterface which Windows should enforce and describe how to enforce it. (If your response is "You should have designed it differently so these bugs are impossible to write", please outline that alternate bug-resistant design. Remember that your design must be language-independent, while still supporting things like tear-offs, aggregation, and remote objects. Oh and it needs to work on typical PC-class computers of the early 1990's, which ran at 25MHz with 4MB of memory.)

  • The Old New Thing

    Things I've written that have amused other people, Episode 5

    • 30 Comments

    A question was sent to an internal discussion list for users of the XYZ tool:

    From: Q
    To: XYZ Users

    The GHI function in the JKL tool doesn't work for me. «description of problem deleted»

    I responded with this message:

    To: Q, XYZ Users

    The JKL tool is not part of XYZ. You should contact the author of the JKL tool.

    The reason why people were amused by this is that the author of the JKL tool is me. (Says so right there in the online help.)

    As a final punch line, the person never did contact me.

  • The Old New Thing

    Hey, you look Chinese, we have a class for people like you

    • 30 Comments

    (The title is a callback to this article from a few months ago.)

    A member of my extended family grew up near the city of Nanaimo, Canada. While it's true that she's ethnically Chinese, it's also true that she's a fourth generation Canadian. The community is overwhelmingly English-speaking, and English is her first language. She grew up going to an English-language school, she watched English-language television, spoke English with her friends and family, and probably dreamed dreams in English.

    Yet when the family moved to Vancouver when she was a child (I don't know the exact age, so let's say eight years old), the school district automatically enrolled her in English as a Second Language, presumably based on her Chinese last name and the fact that Mandarin and Cantonese are the mother tongues in 30% of Vancouver homes.

    Since she was only eight years old, she didn't know that the school had tagged her as a non-native English speaker. She cheerfully went to her special class for an hour each day, enjoying her time with a new teacher and new classmates.

    It wasn't for a long time (I don't know exactly, so let's say six months) that she realized, "Wait a second, this is the class for people who don't speak English well!" Once the mistake was recognized, it wasn't long before she was transferred back to the regular class.

    Though I'm kind of surprised the school district (and the class teacher) never figured out that her English was native, or, failing that, that her English was plenty good enough that she didn't need the class any more.

  • The Old New Thing

    Thanks for identifying the good programmers for us

    • 25 Comments

    Many years ago, my manager told me about a recruiting trip he made. In response to a large number of job applications submitted from a city where a major competing software company had its offices, a small group of Microsofties travelled to that city to interview those applicants and hold a mini-job fair, so that other interested parties could also show up and interview for positions.

    When the company learned that Microsoft was coming to interview people, they called an emergency meeting which all their top programmers were required to attend, timing it to coincide with the job fair. The theory must have been that if their top programmers are at the emergency meeting, then they can't go to the job fair. Problem solved.

    Well, except that the plan backfired. Sure, all the good programmers didn't come to the job fair, but it also told the interviewers which of the applicants were the good ones: They were the ones who didn't show up for their interviews!

  • The Old New Thing

    Windows 95's ticking death

    • 24 Comments

    A few years ago, Larry Osterman explained the famous beeping death. Windows 95 had its own noise-related death, what nobody has called ticking death, but that's what I'm going to call it. (Let's see how long before somebody decide to add it to Wikipedia.)

    When your machine fell into ticking death, each time you moved the mouse or pressed a key, it was acknowledged with nothing more than a tiny click from the speaker. What was the cause of ticking death?

    When the hardware drivers report a mouse or keyboard event on Windows 95, they call the mouse_input or keybd_input function. Since this happens at hardware input time, those functions are very limited in what they can do. All they do is appends the new input to a queue of "input that arrived while I was busy doing something else." When the window manager reaches a stable state, it takes the input from the "input waiting to be processed" queue and farms them out to the appropriate application input queues. The window manager needs to be stable, since mouse input gets routed depending on which window is under the mouse pointer when the pointer moves, and you don't want to do this while some other part of the window manager is in the process of rearranging the windows (and the window tree is consequently unstable).

    For compatibility reasons, the window manager promises not to change anything while 16-bit code is running, so that a 16-bit application doesn't see, for example, a window becoming destroyed behind its back. (Recall that 16-bit Windows is a co-operatively multi-tasked system, which means that applications have control of the CPU until they voluntarily relinquish it.)

    If a 16-bit application hangs, then the buffer for holding all of these "distribute this input to application queues as soon as it is safe to do so" fills up and can't accept any more input. If new input arrives and there's nowhere to save it, the window manager emits a little tick sound as a mini-error message.

    Of course, as the end user, you probably knew something was up because the screen hasn't changed in a long time. Some 16-bit application is not responding and is preventing the window manager from doing anything. To get out of this situation, you can hit Ctrl+Alt+Del and try to kill the hung application.

  • The Old New Thing

    Microspeak: Net net

    • 24 Comments

    In finance, the net is the total after you have cancelled positive values against negative values. For example, if you took in $30 and paid out $20, then your net is $10.

    In Microspeak, this term has moved into project planning and has undergone redoubling, so it's not just net; it's net net. The doubling of the word was probably added to create a sense of impatience. Here's an imaginary conversation that illustrates the term:

    Speaker 1: We're five days over on component X, but component Y is ahead of schedule, and we can have some of them h...

    Speaker 2: (interrupting) What's the net net?

    Speaker 1: Um, we're two days behind.

    The net net is not a real estate transaction but rather is a short summary of a complicated situation, what often goes by the term bottom line.

    Here is an actual citation:

    (At the top of a long email message)

    Net net, we're delaying the release we had planned for tomorrow to try and get some critical fixes in.

    Another use of the term net net is to highlight a conclusion from a lot of data.

    (at the bottom of a large information-dense PowerPoint slide)

    Net Net: Eliminate XYZ from our target set.

    Both senses of net net highlight the principle of I know you're impatient, so I'll cut to the chase.

Page 1 of 4 (37 items) 1234