From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752651AbcEKOsQ (ORCPT ); Wed, 11 May 2016 10:48:16 -0400 Received: from ns.pmeerw.net ([84.19.176.92]:58703 "EHLO pmeerw.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751789AbcEKOsO (ORCPT ); Wed, 11 May 2016 10:48:14 -0400 Date: Wed, 11 May 2016 16:48:12 +0200 (CEST) From: Peter Meerwald-Stadler To: Felix von Leitner cc: LKML Subject: Re: getting mysterious (to me) EINVAL from inotify_rm_watch In-Reply-To: <20160511142251.GA30812@qarx.de> Message-ID: References: <20160511142251.GA30812@qarx.de> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, > I am trying to add inotify support to my tail implementation (for -F). > This is what happens: > > inotify_init() = 4 > inotify_add_watch(4, "/tmp/foo", IN_MODIFY) = 1 > inotify_rm_watch(4, 1) = -1 EINVAL (Invalid argument) > inotify_add_watch(4, "/tmp/foo", IN_MODIFY) = 2 > > There is also some polling, some reading and some statting going on here, but > those are on other descriptors than 4 so they should not matter). > > Can somebody explain the EINVAL I'm getting from inotify_rm_watch to me? > This is a stock kernel 4.5.0. #include #include int main() { int fd, i, j; printf("init %d\n", fd=inotify_init()); // 3 printf("add %d\n", i=inotify_add_watch(fd, "/tmp/foo", IN_MODIFY)); // 1 printf("rm %d\n", inotify_rm_watch(fd, i)); // 0 printf("add %d\n", j=inotify_add_watch(fd, "/tmp/foo", IN_MODIFY)); // 2 return 0; } Ubuntu kernel x86_64 4.4.0-21, seems to work here so we have to guess what's going on between _add and _rm? regards, p. -- Peter Meerwald-Stadler +43-664-2444418 (mobile)